StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
makeEEmcTreePart2and3_TSIU.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 TSIU 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 StEEmcStripClusterFinderTSIU_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_TSIU( 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 StEEmcStripClusterFinderTSIU_t();
82 
83  // parameter set d
84 
85  stripClusterFinderPtr->setNumSmoothIters( 10 );
86  stripClusterFinderPtr->setNumStripsPerSide( 3 );
87  stripClusterFinderPtr->setMinStripsPerCluster( 5 );
88  stripClusterFinderPtr->setSeedAbsThres( 0.002 );
89  stripClusterFinderPtr->setSeedRelThres( 0.0 );
90  stripClusterFinderPtr->setMinEnergyPerCluster( 0.003 );
91 
92  // point finder
93  pointFinderPtr = new StEEmcPointFinderIU_t();
94 
95  // energy apportioner
96  energyApportionerPtr = new StEEmcEnergyApportionerIU_t();
97  energyApportionerPtr->setCheckTowerBits(0);
98 
99  // Hit maker
100  hitMakerPtr = new StEEmcHitMakerSimple_t ( "hitMaker",
101  "EEmcTreeReader",
102  towerClusterFinderPtr,
103  stripClusterFinderPtr,
104  pointFinderPtr,
105  energyApportionerPtr
106  );
107  hitMakerPtr->doClusterTowers( 0 );
108  hitMakerPtr->doClusterPreShower1( 0 );
109  hitMakerPtr->doClusterPreShower2( 0 );
110  hitMakerPtr->doClusterPostShower( 0 );
111  hitMakerPtr->doClusterSMDStrips( 1 );
112 
113  //
114  // Extra things if MC
115  //
116 
117  // Associate hits with tracks, if it is MC data
118  // if( isMC )
119  // mcHitMakerPtr = new StMcEEmcHitMakerStrips_t( "mcHitMaker", "responseTreeReader", "hitMaker" );
120 
121  //
122  // TREE MAKER FOR WRITING
123  //
124  treeWriterPtr = new StEEmcTreeMaker_t( "EEmcTreeWriter" );
125  treeWriterPtr->setTreeStatus( StEEmcTreeMaker_t::PART_1, StEEmcTreeMaker_t::IGNORE, "" );
126  treeWriterPtr->setTreeStatus( StEEmcTreeMaker_t::PART_2, StEEmcTreeMaker_t::WRITE, eemcTreePart2FileName );
127  treeWriterPtr->setTreeStatus( StEEmcTreeMaker_t::PART_3, StEEmcTreeMaker_t::WRITE, eemcTreePart3FileName );
128  treeWriterPtr->doSpinInfoIO( 0 );
129  treeWriterPtr->doEvtHddrIO( 0 );
130  treeWriterPtr->doMakePairs( 1 );
131  treeWriterPtr->setEEmcTreeReader( treeReaderPtr );
132  treeWriterPtr->setEEmcHitMkr( hitMakerPtr );
133 
134  // debugging info
135  std::cout << "***** Done instanciating all the classes *****" << endl;
136  //analysisChain->ls(3);
137 
138  //
139  // INITIALIZE ALL MAKERS
140  //
141 
142  std::cout << "***** Initializing all makers in the analysis chain *****" << std::endl;
143 
144  analysisChain->Init();
145 
146  std::cout << "***** Initialization done *****" << std::endl;
147 
148  //
149  // FINALLY READY TO LOOP OVER THE EVENTS
150  //
151 
152  Int_t ierr = kStOK; // err flag
153  Int_t nIn = -1;
154  if( neventsIn < 0 )
155  neventsIn = 1<<30;
156 
157  Int_t nhits = 0;
158 
159  for( nIn = 0; nIn < neventsIn && !ierr; ++nIn ){
160 
161  // clear
162  analysisChain->Clear();
163 
164  // make
165  ierr = analysisChain->Make();
166 
167  // number of hits
168  nhits += hitMakerPtr->getHitVecSize();
169 
170  // Print every so many events
171  if( (nIn+1) % displayFreq == 0 )
172  std::cout << "***** Entries read " << nIn+1 << ", total hits = " << nhits << endl;
173  };
174 
175  std::cout << "***** Entries read " << nIn+1 << ", total hits = " << nhits << endl;
176 
177  if( ierr && ierr != 2 )
178  std::cout << "***** ERROR FLAG " << ierr << endl;
179 
180  //---------------------------------------------------------------
181  //
182  // Calls the ::Finish() method on all makers (done automatically)
183  //
184  // analysisChain->Finish();
185 
186  //
187  // Delete the chain (done automatically)
188  //
189  //analysisChain->Delete();
190  //delete analysisChain;
191 
192  return;
193 };
194 
195 void loadEEmcTreeLibs(){
196  // commong shared libraries
197  gROOT->Macro("loadMuDst.C");
198 
199  // and a few others
200  gSystem->Load("StSpinDbMaker");
201  gSystem->Load("StEEmcUtil");
202 
203  gSystem->Load("libSpectrum");
204  gSystem->Load("libMinuit");
205 
206  gSystem->Load("StEEmcPoolEEmcTreeContainers");
207  gSystem->Load("StEEmcHitMaker");
208  gSystem->Load("StEEmcPointMap");
209  gSystem->Load("StEEmcTreeMaker");
210 };
211 
212 /*
213  * $Id: makeEEmcTreePart2and3_TSIU.C,v 1.2 2013/02/21 21:59:03 sgliske Exp $
214  * $Log: makeEEmcTreePart2and3_TSIU.C,v $
215  * Revision 1.2 2013/02/21 21:59:03 sgliske
216  * general update
217  *
218  * Revision 1.1 2012/12/17 20:01:38 sgliske
219  * moved from offline/users/sgliske/StRoot/StEEmcPool/StEEmcTreeMaker/macros
220  *
221  *
222  */
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.