Geant4 Cross Reference |
1 // Include files 1 // Include files 2 #include "TROOT.h" 2 #include "TROOT.h" 3 #include "TFile.h" 3 #include "TFile.h" 4 #include "TSystem.h" 4 #include "TSystem.h" 5 #include "TKey.h" 5 #include "TKey.h" 6 //******************************************** 6 //***************************************************************************** 7 // To run this macro in cint do (after replaci 7 // To run this macro in cint do (after replacing the location_of_your_libraries below): 8 // .include $G4INCLUDE 8 // .include $G4INCLUDE >> 9 // gSystem->Load("libCintex.so"); 9 // gSystem->Load("<location_of_your_libraries> 10 // gSystem->Load("<location_of_your_libraries>/libExP01ClassesDict.so"); >> 11 // ROOT::Cintex::Cintex::Enable(); 10 // .L hits.C++ 12 // .L hits.C++ 11 // hits(); 13 // hits(); 12 //******************************************** 14 //***************************************************************************** 13 #include "include/ExP01TrackerHit.hh" 15 #include "include/ExP01TrackerHit.hh" 14 16 15 void hits() 17 void hits() 16 { 18 { 17 TFile fo("hits.root"); 19 TFile fo("hits.root"); 18 20 19 std::vector<ExP01TrackerHit*>* hits; 21 std::vector<ExP01TrackerHit*>* hits; 20 fo.GetListOfKeys()->Print(); 22 fo.GetListOfKeys()->Print(); 21 23 22 TIter next(fo.GetListOfKeys()); 24 TIter next(fo.GetListOfKeys()); 23 TKey *key; 25 TKey *key; 24 double tot_en; 26 double tot_en; 25 while ((key=(TKey*)next())) 27 while ((key=(TKey*)next())) 26 { 28 { 27 fo.GetObject(key->GetName(), hits); 29 fo.GetObject(key->GetName(), hits); 28 30 29 tot_en = 0; 31 tot_en = 0; 30 cout << "Collection: " << key->GetName() < 32 cout << "Collection: " << key->GetName() << endl; 31 cout << "Number of hits: " << hits->size() 33 cout << "Number of hits: " << hits->size() << endl; 32 for (int i=0;i!=hits->size();i++) 34 for (int i=0;i!=hits->size();i++) 33 { 35 { 34 (*hits)[i]->Print(); 36 (*hits)[i]->Print(); 35 } 37 } 36 } 38 } 37 } 39 } 38 40