HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hshowergeantreader.cc
Go to the documentation of this file.
1 using namespace std;
2 #include "hshowergeantreader.h"
3 #include "hgeantshower.h"
4 #include "hgeantmaxtrk.h"
5 #include "showerdef.h"
6 #include "hdebug.h"
7 #include "hades.h"
8 #include "hevent.h"
9 #include "hcategory.h"
10 #include "hdatasource.h"
11 #include "TDirectory.h"
12 #include <iostream>
13 #include <iomanip>
14 
15 //*-- Author : R. Holzmann
16 //*-- Modified: 05/12/2008 by I. Koenig
17 
18 //_HADES_CLASS_DESCRIPTION
19 /////////////////////////////////////////////////////
20 // HShowerGeantReader for HGeant Root SHOWER branch
21 //
22 /////////////////////////////////////////////////////
23 
25 
27  fEventId = 0;
28 }
29 
31 }
32 
33 
35 // Set up categories and HGeant input tree
36 // (this still needs splitlevel=2 on input file)
37 //
38  fGeantShowCat = (HMatrixCategory*)(gHades->getCurrentEvent()
40  if (!fGeantShowCat) {
41  if (!fInputFile) {
42  t = NULL;
43  return kFALSE; // no category, no input file !
44  }
45  if (fInputFile->cd("dirSimul")) { // change dir, read category definition
46  fGeantShowCat = (HMatrixCategory*)(gDirectory->Get("HGeantShower"));
47  fInputFile->cd(".."); // go back up one level
48  } else {
49  Int_t ini[2] = {6,MAXTRKSHOW}; // use old default definition
50  fGeantShowCat = new HMatrixCategory("HGeantShower",2,ini,1.0);
51  }
53  addCategory(catShowerGeantRaw,fGeantShowCat,"Simul");
54 
55  printf("\n%s(%d,%d) matrix category created for HGeant input\n",
56  fGeantShowCat->getClassName(),
57  fGeantShowCat->getSize(0), fGeantShowCat->getSize(1));
58 
59  }
60  if (!fInputFile) {
61  t = NULL;
62  return kTRUE; // category exists, but no input file (called from HGeant)
63  }
64 
65  if ((t=(TTree*)fInputFile->Get("T")) == NULL) return kFALSE;
66 
67  t->SetBranchAddress("HGeantShower",&fGeantShowCat); // connect SHOWER category
68  t->SetBranchStatus("HGeantShower",kTRUE);
69  fGeantShowCat->activateBranch(t,2);
70 
71  if (gHades->getOutputFile() != NULL) gHades->getOutputFile()->cd(); // !!!
72  return kTRUE;
73 }
74 
75 
77 // Read one entry from tree
78 //
79  if(t) { // input tree does exist
80  if(t->GetEntry(fEventId)==0) return kFALSE; // read 1 entry from tree
81  }
82 
83  fEventId++;
84 
85  return kTRUE; // return type is Bool_t
86 }
87 
88 
89 
TFile * getOutputFile()
Definition: hades.h:150
HEvent *& getCurrentEvent(void)
Definition: hades.cc:422
#define MAXTRKSHOW
Definition: hgeantmaxtrk.h:6
ClassImp(HShowerGeantReader) HShowerGeantReader
Hades * gHades
Definition: hades.cc:1213
virtual HCategory * getCategory(Cat_t aCat)=0
const Cat_t catShowerGeantRaw
Definition: hgeantdef.h:11