StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
makeEEmcTreePart2and3_IU.C
1 /*
2  * Created May 2012, by S. Gliske
3  *
4  * Macro to read in "Part 1" of the EEmcTree and write out "Part 2"
5  * and "Part 3" using the IU algorithm.
6  *
7  */
8 
9 // forward declarations
10 class StChain;
11 
12 // algos
15 //class StEEmcTowerClusterFinderMinesweeper_t;
22 
23 // other
24 class StEEmcTreeMaker_t;
25 
26 //
27 // some variables that tend to be made global
28 //
29 StChain *analysisChain = 0;
30 StEEmcTowerClusterFinder_t *towerClusterFinderPtr = 0;
31 StEEmcStripClusterFinderIU_t *stripClusterFinderPtr = 0;
32 StEEmcPointFinderIU_t *pointFinderPtr = 0;
33 StEEmcEnergyApportionerIU_t *energyApportionerPtr = 0;
34 StEEmcHitMakerSimple_t *hitMakerPtr = 0;
35 StEEmcTreeMaker_t *treeReaderPtr = 0;
36 StEEmcTreeMaker_t *treeWriterPtr = 0;
37 
38 //
39 // the main routine
40 //
41 void makeEEmcTreePart2and3_IU( const Char_t *eemcTreePart1FileName = "eemcTreeP1.root",
42  const Char_t *eemcTreePart2FileName = "eemcTreeP2.root",
43  const Char_t *eemcTreePart3FileName = "eemcTreeP3.root",
44  Int_t neventsIn = -1,
45  Bool_t isMC = 0,
46  Int_t displayFreq = 100 ){
47 
48  // load the shared libraries
49  std::cout << "***** Loading libraries *****" << endl;
50  loadEEmcTreeLibs();
51 
52  std::cout << "***** Done loading libraries *****" << endl;
53  std::cout << "***** Instanciating all the classes *****" << endl;
54 
55  //
56  // CREATE THE ANALYSIS CHAIN
57  //
58  analysisChain = new StChain("eemcAnalysisChain");
59 
60  //
61  // TREE MAKER FOR READING
62  //
63  treeReaderPtr = new StEEmcTreeMaker_t( "EEmcTreeReader" );
64  treeReaderPtr->setTreeStatus( StEEmcTreeMaker_t::PART_1, StEEmcTreeMaker_t::READ, eemcTreePart1FileName );
65  treeReaderPtr->setTreeStatus( StEEmcTreeMaker_t::PART_2, StEEmcTreeMaker_t::IGNORE, "" );
66  treeReaderPtr->setTreeStatus( StEEmcTreeMaker_t::PART_3, StEEmcTreeMaker_t::IGNORE, "" );
67  treeReaderPtr->doSpinInfoIO( !isMC );
68  treeReaderPtr->doEvtHddrIO( 1 );
69  treeReaderPtr->setMaxNumEvents( neventsIn );
70 
71 
72  //
73  // CREATE ALL THE FINDERS AND THE HIT MAKER
74  //
75 
76  // tower cluster finder
77 // towerClusterFinderPtr = new StEEmcTowerClusterFinderMinesweeper_t();
78 // towerClusterFinderPtr->setSeedEnergyThreshold( 2.0 );
79 
80  // strip cluster finder
81  stripClusterFinderPtr = new StEEmcStripClusterFinderIU_t();
82  stripClusterFinderPtr->setSeedFloorConst(1);
83 
84  // point finder
85  pointFinderPtr = new StEEmcPointFinderIU_t();
86 
87  // energy apportioner
88  energyApportionerPtr = new StEEmcEnergyApportionerIU_t();
89  energyApportionerPtr->setCheckTowerBits(0);
90 
91  // Hit maker
92  hitMakerPtr = new StEEmcHitMakerSimple_t ( "hitMaker",
93  "EEmcTreeReader",
94  towerClusterFinderPtr,
95  stripClusterFinderPtr,
96  pointFinderPtr,
97  energyApportionerPtr
98  );
99  hitMakerPtr->doClusterTowers( 0 );
100  hitMakerPtr->doClusterPreShower1( 0 );
101  hitMakerPtr->doClusterPreShower2( 0 );
102  hitMakerPtr->doClusterPostShower( 0 );
103  hitMakerPtr->doClusterSMDStrips( 1 );
104 
105  //
106  // Extra things if MC
107  //
108 
109  // Associate hits with tracks, if it is MC data
110  // if( isMC )
111  // mcHitMakerPtr = new StMcEEmcHitMakerStrips_t( "mcHitMaker", "responseTreeReader", "hitMaker" );
112 
113  //
114  // TREE MAKER FOR WRITING
115  //
116  treeWriterPtr = new StEEmcTreeMaker_t( "EEmcTreeWriter" );
117  treeWriterPtr->setTreeStatus( StEEmcTreeMaker_t::PART_1, StEEmcTreeMaker_t::IGNORE, "" );
118  treeWriterPtr->setTreeStatus( StEEmcTreeMaker_t::PART_2, StEEmcTreeMaker_t::WRITE, eemcTreePart2FileName );
119  treeWriterPtr->setTreeStatus( StEEmcTreeMaker_t::PART_3, StEEmcTreeMaker_t::WRITE, eemcTreePart3FileName );
120  treeWriterPtr->doSpinInfoIO( 0 );
121  treeWriterPtr->doEvtHddrIO( 0 );
122  treeWriterPtr->doMakePairs( 1 );
123  treeWriterPtr->setEEmcTreeReader( treeReaderPtr );
124  treeWriterPtr->setEEmcHitMkr( hitMakerPtr );
125 
126  // debugging info
127  std::cout << "***** Done instanciating all the classes *****" << endl;
128  //analysisChain->ls(3);
129 
130  //
131  // INITIALIZE ALL MAKERS
132  //
133 
134  std::cout << "***** Initializing all makers in the analysis chain *****" << std::endl;
135 
136  analysisChain->Init();
137 
138  std::cout << "***** Initialization done *****" << std::endl;
139 
140  //
141  // FINALLY READY TO LOOP OVER THE EVENTS
142  //
143 
144  Int_t ierr = kStOK; // err flag
145  Long_t nIn = -1;
146  if( neventsIn < 0 )
147  neventsIn = 1<<30;
148 
149  Int_t nhits = 0;
150 
151  for( nIn = 0; nIn < neventsIn && !ierr; ++nIn ){
152 
153  // clear
154  analysisChain->Clear();
155 
156  // make
157  ierr = analysisChain->Make();
158 
159  // number of hits
160  nhits += hitMakerPtr->getHitVecSize();
161 
162  // Print every so many events
163  if( (nIn+1) % displayFreq == 0 )
164  std::cout << "***** Entries read " << nIn+1 << ", total hits = " << nhits << endl;
165  };
166 
167  std::cout << "***** Entries read " << nIn+1 << ", total hits = " << nhits << endl;
168 
169  if( ierr && ierr != 2 )
170  std::cout << "***** ERROR FLAG " << ierr << endl;
171 
172  //---------------------------------------------------------------
173  //
174  // Calls the ::Finish() method on all makers (done automatically)
175  //
176  // analysisChain->Finish();
177 
178  //
179  // Delete the chain (done automatically)
180  //
181  //analysisChain->Delete();
182  //delete analysisChain;
183 
184  return;
185 };
186 
187 
188 void loadEEmcTreeLibs(){
189  // commong shared libraries
190  gROOT->Macro("loadMuDst.C");
191 
192  // and a few others
193  gSystem->Load("StSpinDbMaker");
194  gSystem->Load("StEEmcUtil");
195 
196  gSystem->Load("libSpectrum");
197  gSystem->Load("libMinuit");
198 
199  gSystem->Load("StEEmcPoolEEmcTreeContainers");
200  gSystem->Load("StEEmcHitMaker");
201  gSystem->Load("StEEmcPointMap");
202  gSystem->Load("StEEmcTreeMaker");
203 };
204 
205 /*
206  * $Id: makeEEmcTreePart2and3_IU.C,v 1.1 2012/12/17 20:01:31 sgliske Exp $
207  * $Log: makeEEmcTreePart2and3_IU.C,v $
208  * Revision 1.1 2012/12/17 20:01:31 sgliske
209  * moved from offline/users/sgliske/StRoot/StEEmcPool/StEEmcTreeMaker/macros
210  *
211  *
212  */
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void setTreeStatus(treeTypeEnum_t type, iostatus_t iostatus, const Char_t *fileName)
modifiers
void doClusterSMDStrips(Bool_t flag=1)
Set whether to cluster SMD strips.
void doClusterTowers(Bool_t flag=1)
modifiers
StEEmcTreeMaker_t(const Char_t *myName)
constructor
virtual Int_t Make()
Definition: StChain.cxx:110
Definition: Stypes.h:40
Include StRoot headers.