StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcHitMakerSimple.cxx
1 
10 #include "StRoot/St_base/Stypes.h"
12 #include "StRoot/St_base/StMessMgr.h"
13 #include "StRoot/StEEmcPool/./EEmcTreeContainers/EEmcEnergy.h"
14 
16 #include "StEEmcHitMakerSimple.h"
17 #include "StEEmcTowerClusterFinder.h"
18 #include "StEEmcStripClusterFinder.h"
19 #include "StEEmcPointFinder.h"
20 #include "StEEmcEnergyApportioner.h"
21 
22 StEEmcHitMakerSimple_t::StEEmcHitMakerSimple_t( const Char_t *myName, // name of this maker
23  const Char_t *inputMakerName, // maker from which to get input data
24  StEEmcTowerClusterFinder_t* towerClusterFinder,
25  StEEmcStripClusterFinder_t* stripClusterFinder,
26  StEEmcPointFinder_t *pointFinder,
27  StEEmcEnergyApportioner_t *energyApportioner ) :
28  StEEmcHitMaker_t( myName, inputMakerName ),
29  mTowerClusterFinder( towerClusterFinder ),
30  mStripClusterFinder( stripClusterFinder ),
31  mPointFinder( pointFinder ),
32  mEnergyApportioner( energyApportioner ),
33  mClusterStripsFirst( 0 ) {
34 
35  // will check all input pointers during Init()
36 };
37 
39  /* nothing to do */
40 };
41 
42 
44  Int_t ierr = kStOK;
45 
46  // check parent
47  ierr = StEEmcHitMaker_t::Init();
48 
49  if( !ierr && !mTowerClusterFinder && ( mDoClusterTower[ TOWER ] || mDoClusterTower[ PRESHOWER1 ] || mDoClusterTower[ PRESHOWER2 ] || mDoClusterTower[ POSTSHOWER ] ) ){
50  LOG_FATAL << "StEEmcHitMakerSimple_t passed null pointer for TowerClusterFinder" << endm;
51  ierr = kStFatal;
52  };
53 
54  if( !ierr && !mStripClusterFinder && mDoClusterSMDStrips ){
55  LOG_FATAL << "StEEmcHitMakerSimple_t passed null pointer for StripClusterFinder" << endm;
56  ierr = kStFatal;
57  };
58 
59  if( !ierr && !mPointFinder ){
60  LOG_FATAL << "StEEmcHitMakerSimple_t passed null pointer for PointFinder" << endm;
61  ierr = kStFatal;
62  };
63 
64  if( !ierr && !mEnergyApportioner ){
65  LOG_FATAL << "StEEmcHitMakerSimple_t passed null pointer for EneryApportioner" << endm;
66  ierr = kStFatal;
67  };
68 
69  if( ierr )
70  return ierr;
71 
72  // check readiness
74  LOG_FATAL << "sub-system TowerClusterFinder is not ready" << endm;
75  ierr = kStFatal;
76  };
77 
78  if( mStripClusterFinder && !mStripClusterFinder->isReady() ){
79  LOG_FATAL << "sub-system StripClusterFinder is not ready" << endm;
80  ierr = kStFatal;
81  };
82 
83  if( !mPointFinder->isReady() ){
84  LOG_FATAL << "sub-system PointFinder is not ready" << endm;
85  ierr = kStFatal;
86  };
87 
88  if( !mEnergyApportioner->isReady() ){
89  LOG_FATAL << "sub-system EnergyApportioner is not ready" << endm;
90  ierr = kStFatal;
91  };
92 
93  if( ierr )
94  LOG_FATAL << "StEEmcHitMakerSimple_t cannot initialize" << endm;
95 
96  // initialize finer event number
97  StFinderAlg_t::setEventNum( -1 );
98 
99  return ierr;
100 };
101 
102 
106  //LOG_INFO << "==========> " << ClassName() << "::Make(), Event " << GetEventNumber() << endm;
107 
108  Int_t evNum = GetEventNumber();
109  if( evNum == -1 ){
110  evNum = StFinderAlg_t::getEventNum();
111  ++evNum;
112  };
113  StFinderAlg_t::setEventNum( evNum );
114 
115  // ----------> LOAD DATA <----------
116  Int_t ierr = StEEmcHitMaker_t::Make();
117 
118  if( !ierr ){
119  // ----------> CLUSTERING <----------
120 
121  //LOG_INFO << "----------> Clustering <----------" << endm;
122 
123  if( mClusterStripsFirst ){
124  if( !ierr && mDoClusterSMDStrips )
125  ierr = clusterStrips();
126 
127  if( !ierr )
128  ierr = clusterTowers();
129  } else {
130  if( !ierr )
131  ierr = clusterTowers();
132 
133  if( !ierr && mDoClusterSMDStrips )
134  ierr = clusterStrips();
135  };
136 
137  // ----------> POINT FINDING <----------
138 
139  //LOG_INFO << "----------> Point Finding <----------" << endm;
140 
141  if( !ierr )
142  ierr = mPointFinder->find( *mEEmcEnergy, mTowerClusterVec[ TOWER ], mESMDClusterVec, mSmdEuEvRatio, mHitVec );
143 
144  //LOG_INFO << "-----> Found " << mHitVec.size() << " points" << endm;
145 
146  // ----------> ENERGY APPORTIONING (SHARING) <----------
147 
148  //LOG_INFO << "----------> Energy Apportioning <----------" << endm;
149 
150  if( !ierr )
151  mEnergyApportioner->find( mEEmcEnergy, mTowerClusterVec[ TOWER ], mESMDClusterVec, mHitVec );
152 
153 
154  // ----------> OUTPUT <----------
155 
156  if( ierr ){
157  LOG_WARN << "StEEmcHitMakerSimple_t::find() returning error code of '" << ierr << "'" << endm;
158  };
159  };
160 
161  //static_cast< StEEmcHitMaker_t* >( this )->getHitVecSize();
162  //LOG_INFO << "==========> Make done, mHitVec.size() = " << mHitVec.size() << endm;
163 
164  return ierr;
165 };
166 
168 void StEEmcHitMakerSimple_t::Clear( Option_t* opts ){
169 
170  // Clear all classes. Clear regardless of whether clustering, just
171  // in case someone changes the "do cluster" options
172  if( mTowerClusterFinder )
174  if( mStripClusterFinder )
175  mStripClusterFinder->clear();
176  if( mPointFinder )
177  mPointFinder->clear();
178  if( mEnergyApportioner )
179  mEnergyApportioner->clear();
180 
181  // clear the parent
182  StEEmcHitMaker_t::Clear( opts );
183 };
184 
185 Int_t StEEmcHitMakerSimple_t::clusterTowers(){
186  Int_t ierr = kStOK;
187 
188  if( !ierr && mDoClusterTower[ TOWER ] )
189  ierr = mTowerClusterFinder->find( mEEmcEnergy->eTow, mTowerClusterVec[ TOWER ] );
190 
191  if( !ierr && mDoClusterTower[ PRESHOWER1 ] )
192  ierr = mTowerClusterFinder->find( mEEmcEnergy->ePre1, mTowerClusterVec[ PRESHOWER1 ] );
193 
194  if( !ierr && mDoClusterTower[ PRESHOWER2 ] )
195  ierr = mTowerClusterFinder->find( mEEmcEnergy->ePre2, mTowerClusterVec[ PRESHOWER2 ] );
196 
197  if( !ierr && mDoClusterTower[ POSTSHOWER ] )
198  ierr = mTowerClusterFinder->find( mEEmcEnergy->ePost, mTowerClusterVec[ POSTSHOWER ] );
199 
200  return ierr;
201 };
202 
203 Int_t StEEmcHitMakerSimple_t::clusterStrips(){
204  Int_t ierr = kStOK;
205 
206  mStripClusterFinder->resetClusterCount();
207  for( Int_t sector = 0; sector < kEEmcNumSectors && !ierr; ++sector ){
208 
209  //LOG_INFO << "sector = " << sector << ", hit strips = " << mHitUStripPtr[ sector ]->size() << ", " << mHitVStripPtr[ sector ]->size() << endm;
210 
211  // set current sector
212  mStripClusterFinder->setCurrentSector( sector );
213 
214  ESmdEnergy_t& eSMD = mEEmcEnergy->eSmd;
215 
216  mSmdEuEvRatio[sector] = 1;
217 
218  // make sure there are at least some hit strips in this sector
219  if( mEEmcEnergy->nStrips ){
220  // add a new element for clusters from this sector
221  mESMDClusterVec.push_back( StESMDClustersPerSector_t( sector ) );
222 
223  // get references, to make code easier to read
224  StSimpleClusterVec_t &uClusVec = mESMDClusterVec.back().getClusterVecU();
225  StSimpleClusterVec_t &vClusVec = mESMDClusterVec.back().getClusterVecV();
226 
227  // U layer
228  mStripClusterFinder->setCurrentLayer( StEEmcStripClusterFinder_t::U_LAYER );
229  ierr = mStripClusterFinder->find( eSMD.sec[sector].layer[0], uClusVec );
230 
231  //LOG_INFO << "-----> found " << uClusVec.size() << " u clusters." << endm;
232 
233  // V layer
234  mStripClusterFinder->clear();
235  mStripClusterFinder->setCurrentLayer( StEEmcStripClusterFinder_t::V_LAYER );
236  ierr = mStripClusterFinder->find( eSMD.sec[sector].layer[1], vClusVec );
237 
238  //LOG_INFO << "-----> found " << vClusVec.size() << " v clusters." << endm;
239  //LOG_INFO << "zzz\tSec " << sector << ": uSMD clus = " << uClusVec.size() << ", vSMD clus = " << vClusVec.size() << endm;
240 
241  if( uClusVec.empty() && vClusVec.empty() ){
242  // delete the last element if there were no clusters found in either layer
243  mESMDClusterVec.pop_back();
244  } else {
245 
246  Double_t E[2] = { 0, 0 };
247 
248  // compute total energy in each layer
249  for( Int_t layer = 0; layer < 2; ++layer ){
250  ESmdLayer_t &smdLayer = eSMD.sec[sector].layer[layer];
251 
252  for( Int_t strip=0; strip<288; ++strip ){
253  EEmcElement_t& elem = smdLayer.strip[strip];
254 
255  if( !elem.fail )
256  E[layer] += elem.energy;
257  };
258  };
259 
260  mSmdEuEvRatio[sector] = ( E[1] != 0 ? E[0] / E[1] : 1e50 );
261  };
262  };
263  };
264 
265  return ierr;
266 };
267 
268 ClassImp( StEEmcHitMakerSimple_t );
269 
270 /*
271  * $Id: StEEmcHitMakerSimple.cxx,v 1.2 2013/02/21 22:00:44 sgliske Exp $
272  * $Log: StEEmcHitMakerSimple.cxx,v $
273  * Revision 1.2 2013/02/21 22:00:44 sgliske
274  * general update
275  *
276  * Revision 1.1 2012/11/26 19:05:54 sgliske
277  * moved from offline/users/sgliske/StRoot/StEEmcPool/StEEmcHitMaker to StRoot/StEEmcPool/StEEmcHitMaker
278  *
279  *
280  */
virtual Int_t find(const EEmcEnergy_t &eemcEnergy, const StSimpleClusterVec_t &towerClusterVec, const StESMDClustersVec_t &smdClusterVec, const Double_t *smdEuEvRatio, StEEmcHitVec_t &hitVec)=0
find some some points
virtual Int_t find(ETowEnergy_t &towEnergy, StSimpleClusterVec_t &cluster)=0
find some clusters
void setCurrentLayer(LayerOfSMD_t layer)
Set current layer and sector.
StESMDClustersVec_t mESMDClusterVec
Int_t Make()
Make (loads data, for children classes to use)
StEEmcHitVec_t mHitVec
Container for hits.
virtual Int_t find(const ESmdLayer_t &smdLayer, StSimpleClusterVec_t &cluster)=0
find some clusters
Int_t Make()
Find all the hits.
void Clear(Option_t *opts="")
Clear for next event.
StEEmcHitMakerSimple_t(const Char_t *myName, const Char_t *inputMakerName, StEEmcTowerClusterFinder_t *towerClusterFinder, StEEmcStripClusterFinder_t *stripClusterFinder, StEEmcPointFinder_t *pointFinder, StEEmcEnergyApportioner_t *energyApportioner)
Construtor.
StSimpleClusterVec_t mTowerClusterVec[NUM_TOW_LAYERS]
Containers for cluster from each tower layer.
virtual void clear()
clear things before doing the finding for the next sector or layer
virtual void clear()=0
clear things before doing the finding for the next event
virtual void clear()=0
clear things before doing the finding for the next event
Definition: Stypes.h:40
Int_t Init()
Initialize.
void resetClusterCount()
reset the count
void Clear(Option_t *opts="")
Clear for next event.
virtual Int_t find(EEmcEnergy_t *eemcEnergyPtr, const StSimpleClusterVec_t &towerClusterVec, const StESMDClustersVec_t &smdClusterVec, StEEmcHitVec_t &hitVec)=0
find some some points
Bool_t isReady() const
Check if status is ready for hit finding.
Definition: StFinderAlg.h:24
virtual void clear()=0
clear things before doing the finding for the next event
StEEmcTowerClusterFinder_t * mTowerClusterFinder
pointers to finders for subtasks
virtual ~StEEmcHitMakerSimple_t()
Deconstructor.
Bool_t mDoClusterTower[NUM_TOW_LAYERS]
boolean flags
Include StRoot headers.
Definition: dbStruct.hh:78