/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/root/caloExample.cpp File Reference

#include "MicroException.hh"
#include "mysql/Mysql.hh"
#include "root/CaloRun.hh"
#include "root/CaloEvent.hh"
#include "root/CaloHit.hh"
#include "TKey.h"
#include <TList.h>
#include <TTree.h>
#include <TFile.h>
#include "XMLTool.hh"
#include "geometry/Detector.hh"
#include "Log.hh"
#include <iostream>
#include <iomanip>

Include dependency graph for caloExample.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 27 of file caloExample.cpp.

00027                               {
00028    if ( argc !=2  ) {
00029    FILE_LOG(logERROR)  << "usage: caloExample rootFile " << endl;
00030    exit(1);
00031   }
00032 
00033   // Build detector from XML file
00034   Detector detector;
00035   // Get detector information
00036   
00037   SteerDesc steerDesc;
00038   XMLTool xml;
00039   xml.parse(steerDesc, "/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/SteerFiles/TestBeam2012/calice_cubic_metter.xml");
00040   detector.build(steerDesc);
00041 
00042 
00043   string rootName;
00044   rootName.assign(argv[1]);
00045   int nbHit = 0;
00046   int nbEvt = 0;
00047   
00048   TFile f(rootName.c_str());
00049   TIter nextkey(f.GetListOfKeys());
00050   TKey *key;
00051 
00052   while (key = (TKey*)nextkey()) 
00053   {
00054 
00055     TString keyname = key->GetName();
00056 
00057     TTree *tree = (TTree*)key->ReadObj();                
00058     cout << "---------------------------- NEW TTREE ---------------------------"<< endl;
00059     nbEvt =0;
00060     nbHit = 0;
00061 
00062     try {
00063       CaloRun *run=dynamic_cast<CaloRun *>(tree->GetUserInfo()->First());
00064       if ( run != NULL) 
00065       {
00066         cout << "Run[" << run->GetRunId() << "] " << endl ; 
00067       }
00068     }
00069     catch ( ... ) {}
00070 
00071     CaloEvent *evt =  new CaloEvent();
00072     TBranch *branch= tree->GetBranch("CaloEvent");
00073     branch->SetAddress(&evt);
00074 
00075     CaloHit* hit =NULL;
00076     int nbEntries = tree->GetEntries();
00077     for ( int evtNum = 0; evtNum < nbEntries ; evtNum++)
00078     {
00079       tree->GetEntry(evtNum);
00080       nbEvt++;
00081       int nbHits = evt->GetNHits();
00082       for(int i=0 ; i < nbHits ; i++)
00083       {
00084         hit = (CaloHit*)evt->GetHits()->UncheckedAt(i);
00085         Int_t xpos = hit->GetX();
00086         Int_t ypos = hit->GetY();
00087         cout << "\t Nw Hit " << endl;
00088         hit->GetSolftId().ToString();
00089         cout << "new hit layer[" << hit->GetLayer() << endl;
00090         cout << "\thit abs row [" << hit->GetRowInChamber() << setprecision(12) << "], posX[" << xpos << "]"  << endl;
00091         cout << "\thit abs col [" << hit->GetColInChamber() << setprecision(12) << "], posY[" << ypos << "]"  << endl;
00092       }
00093 
00094 
00095     } // end event
00096 /*
00097 */
00098   } // end run ( TTree )
00099 
00100 return 0;
00101 }


Generated on Mon Jun 11 16:57:24 2012 for MicromegasFramework by  doxygen 1.4.7