#include "MicroException.hh"
#include "Mysql.hh"
#include "Toolbox.hh"
#include "CaloRun.hh"
#include "CaloEvent.hh"
#include "CaloHit.hh"
#include "TKey.h"
#include <TList.h>
#include <TTree.h>
#include <TFile.h>
#include "XMLTool.hh"
#include "geometry/Detector.hh"
#include "geometry/Chamber.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) |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 29 of file caloExample.cpp.
00029 { 00030 if ( argc !=2 ) { 00031 FILE_LOG(logERROR) << "usage: caloExample rootFile " << endl; 00032 exit(1); 00033 } 00034 00035 // Get detector from SQL and runId 00036 Detector detector; 00037 00038 string rootName; 00039 rootName.assign(argv[1]); 00040 int nbHit = 0; 00041 int nbEvt = 0; 00042 00043 TFile f(rootName.c_str()); 00044 TIter nextkey(f.GetListOfKeys()); 00045 TKey *key; 00046 00047 while (key = (TKey*)nextkey()) 00048 { 00049 00050 TString keyname = key->GetName(); 00051 00052 TTree *tree = (TTree*)key->ReadObj(); 00053 cout << "---------------------------- NEW TTREE ---------------------------"<< endl; 00054 nbEvt =0; 00055 nbHit = 0; 00056 00057 unsigned int runId = 0; 00058 try { 00059 CaloRun *run=dynamic_cast<CaloRun *>(tree->GetUserInfo()->First()); 00060 if ( run != NULL) 00061 { 00062 runId = run->GetRunId() ; 00063 cout << "RunId[" << run->GetRunId() << "] " << endl ; 00064 } 00065 } 00066 catch ( ... ) {} 00067 Detector detector; 00068 Toolbox::getDetector(runId,detector); 00069 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 Int_t layer = hit->GetLayer(); 00088 Chamber& chamber = detector.getChamberById(layer); 00089 cout << "Hit in chamber id " << layer <<", chamber type " << chamber.getType() << endl; 00090 00091 cout << "\t Nw Hit " << endl; 00092 hit->GetSolftId().ToString(); 00093 cout << "new hit layer[" << hit->GetLayer() << endl; 00094 cout << "\thit abs row [" << hit->GetRowInChamber() << setprecision(12) << "], posX[" << xpos << "]" << endl; 00095 cout << "\thit abs col [" << hit->GetColInChamber() << setprecision(12) << "], posY[" << ypos << "]" << endl; 00096 } 00097 00098 00099 } // end event 00100 /* 00101 */ 00102 } // end run ( TTree ) 00103 00104 return 0; 00105 }