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("<location_of_your_libraries> 9 // gSystem->Load("<location_of_your_libraries>/libExP01ClassesDict.so"); 10 // .L hits.C++ 10 // .L hits.C++ 11 // hits(); 11 // hits(); 12 //******************************************** 12 //***************************************************************************** 13 #include "include/ExP01TrackerHit.hh" 13 #include "include/ExP01TrackerHit.hh" 14 14 15 void hits() 15 void hits() 16 { 16 { 17 TFile fo("hits.root"); 17 TFile fo("hits.root"); 18 18 19 std::vector<ExP01TrackerHit*>* hits; 19 std::vector<ExP01TrackerHit*>* hits; 20 fo.GetListOfKeys()->Print(); 20 fo.GetListOfKeys()->Print(); 21 21 22 TIter next(fo.GetListOfKeys()); 22 TIter next(fo.GetListOfKeys()); 23 TKey *key; 23 TKey *key; 24 double tot_en; 24 double tot_en; 25 while ((key=(TKey*)next())) 25 while ((key=(TKey*)next())) 26 { 26 { 27 fo.GetObject(key->GetName(), hits); 27 fo.GetObject(key->GetName(), hits); 28 28 29 tot_en = 0; 29 tot_en = 0; 30 cout << "Collection: " << key->GetName() < 30 cout << "Collection: " << key->GetName() << endl; 31 cout << "Number of hits: " << hits->size() 31 cout << "Number of hits: " << hits->size() << endl; 32 for (int i=0;i!=hits->size();i++) 32 for (int i=0;i!=hits->size();i++) 33 { 33 { 34 (*hits)[i]->Print(); 34 (*hits)[i]->Print(); 35 } 35 } 36 } 36 } 37 } 37 } 38 38