Geant4  10.02.p03
readHits.cc File Reference

Main program of the persistency/P01 example. More...

#include "TROOT.h"
#include "TFile.h"
#include "TSystem.h"
#include "TKey.h"
#include "include/ExP01TrackerHit.hh"
Include dependency graph for readHits.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the persistency/P01 example.

Definition in file readHits.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 40 of file readHits.cc.

41 {
42  // initialize ROOT
43  TSystem ts;
44  gSystem->Load("libExP01ClassesDict");
45  if(argc<2) G4cout << "Missing name of the file to read!" << G4endl;
46 
47  TFile fo(argv[1]);
48 
49  std::vector<ExP01TrackerHit*>* hits;
50  fo.GetListOfKeys()->Print();
51 
52  TIter next(fo.GetListOfKeys());
53  TKey *key;
54  //double tot_en;
55  while ((key=(TKey*)next()))
56  {
57  fo.GetObject(key->GetName(), hits);
58 
59  //tot_en = 0;
60  G4cout << "Collection: " << key->GetName() << G4endl;
61  G4cout << "Number of hits: " << hits->size() << G4endl;
62  for (size_t i=0;i!=hits->size();i++)
63  {
64  (*hits)[i]->Print();
65  }
66  }
67 }
void hits()
Definition: readHits.C:15
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function: