StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtClusterMaker.cxx
1 //\class StFgtClusterMaker
2 //\author Anselm Vossen (avossen@indiana.edu)
3 //
4 //
5 // $Id: StFgtClusterMaker.cxx,v 1.37 2013/02/20 23:33:28 avossen Exp $
6 
7 #include "StFgtClusterMaker.h"
8 #include "StRoot/StEvent/StEvent.h"
9 #include "StRoot/StEvent/StFgtCollection.h"
10 #include "StFgtIClusterAlgo.h"
11 #include "StEvent/StFgtHit.h"
12 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
13 #include "StFgtSeededClusterAlgo.h"
14 #include "StRoot/StFgtDbMaker/StFgtDbMaker.h"
15 #include "StRoot/StFgtDbMaker/StFgtDb.h"
16 
17 /*void StFgtClusterMaker::Clear(Option_t *opts)
18 {
19 
20 };*/
21 
22 
23 StFgtClusterMaker::StFgtClusterMaker( const Char_t* name ) : StMaker(name),mClusterAlgoPtr(0), mDb(0)
24 {
25  // noop
26 };
27 
28 StFgtClusterMaker::~StFgtClusterMaker()
29 {
30  // noop
31 };
32 
33 
35 {
36  Int_t ierr = kStOk;
37  // cout <<"cluster maker " <<endl;
38  StEvent* eventPtr = 0;
39  eventPtr = (StEvent*)GetInputDS("StEvent");
40 
41  if( !eventPtr ) {
42  LOG_ERROR << "Error getting pointer to StEvent from '" << ClassName() << "'" << endm;
43  ierr = kStErr;
44  }
45 
46  StFgtCollection* fgtCollectionPtr = 0;
47 
48  if( eventPtr ) {
49  fgtCollectionPtr=eventPtr->fgtCollection();
50  }
51 
52  if( !fgtCollectionPtr) {
53  LOG_ERROR << "Error getting pointer to StFgtCollection from '" << ClassName() << "'" << endm;
54  ierr = kStErr;
55  }
56 
57  if( !ierr ){
58  for( UInt_t discIdx=0; discIdx<fgtCollectionPtr->getNumDiscs(); ++discIdx ){
59  //LOG_INFO << "disc: " << discIdx << " has strips: " << fgtCollectionPtr->getNumStrips(discIdx) << endm;
60 
61  StFgtStripCollection *stripCollectionPtr = fgtCollectionPtr->getStripCollection( discIdx );
62  StFgtHitCollection *hitCollectionPtr = fgtCollectionPtr->getHitCollection( discIdx );
63 
64  if( stripCollectionPtr && hitCollectionPtr ){
65  // cout <<"doing clustering ..." <<endl;
66  Int_t loc_ierr = mClusterAlgoPtr->doClustering(*fgtCollectionPtr, *stripCollectionPtr, *hitCollectionPtr );
67  // cout <<"done ..." <<endl;
68  if(loc_ierr!=kStOk) {
69  LOG_WARN <<"StClusterMaker::Make(): clustering for disc " << discIdx << " returned " << loc_ierr <<endm;
70  if(loc_ierr>ierr)
71  ierr=loc_ierr;
72  }
73  }
75  for( StSPtrVecFgtHitIterator it=fgtCollectionPtr->getHitCollection(discIdx)->getHitVec().begin();it!=fgtCollectionPtr->getHitCollection(discIdx)->getHitVec().end();++it)
76  {
77  Int_t centralStripGeoId=(*it)->getCentralStripGeoId();
78  Short_t disc, quad;
79  Char_t layer;
80  Double_t ordinate, lowerSpan, upperSpan;
81  Float_t mR=0.0;
82  Float_t mPhi=0.0;
83  Float_t mErrR=0.0;
84  Float_t mErrPhi=0.0;
85 
86  StFgtGeom::getPhysicalCoordinate( centralStripGeoId, disc, quad, layer, ordinate, lowerSpan, upperSpan );
87  if( layer == 'R' ){
88  mR = (*it)->getPositionR();
89 
90  mErrR = (*it)->getErrorR();
91  // mid point of the strip
92  mPhi = 0.5*(upperSpan + lowerSpan);
93  mErrPhi = upperSpan - lowerSpan; // length of the strip
94  } else {
95  mPhi = (*it)->getPositionPhi();
96  mErrPhi = (*it)->getErrorPhi();
97  mR = 0.5*(upperSpan + lowerSpan); // mid point of the strip
98  mErrR = upperSpan - lowerSpan; // length of the strip
99  };
100  // cout <<"r pos is: " << mR << " phi : " << mPhi <<endl;
101  mPhi+=StFgtGeom::phiQuadXaxis(quad);
102  if(mPhi>TMath::Pi())
103  mPhi-=(2*TMath::Pi());
104  if(mPhi<((-1)*TMath::Pi()))
105  mPhi+=(2*TMath::Pi());
106 
107  (*it)->setPositionR(mR);
108  (*it)->setErrorR(mErrR);
109  (*it)->setPositionPhi(mPhi);
110  (*it)->setErrorPhi(mErrPhi);
111 
112  (*it)->setPositionZ(StFgtGeom::getDiscZ(disc));
113  (*it)->setErrorZ(0.2); // the thickens of sensitive volume (2mm), Jan
114 
115  //printf("CLM: ev= %6d centStrgeoId= %5d, disc=%d at phi=%f and Z=%f Z2=%f, phi1=%f phi2=%f\n",GetEventNumber(), centralStripGeoId,disc,StFgtGeom::phiQuadXaxis(quad), StFgtGeom::getDiscZ(disc),(*it)->getPositionZ(),mPhi,(*it)->getPositionPhi());
116 
117  }
119 
120  }
121  }
122  LOG_DEBUG << "End of fgt-clust-maker, print all strips & clusters: " << endm;
123  LOG_DEBUG <<" fgtCollnumDisc=" << fgtCollectionPtr->getNumDiscs()<<", tot strip=" <<fgtCollectionPtr->getNumStrips()<<" totClust=" << fgtCollectionPtr->getNumHits() <<endm;
124  for(int iDisc=0; iDisc <(int)fgtCollectionPtr->getNumDiscs(); iDisc++) {
125 
126  LOG_DEBUG <<" content: iDisc="<<iDisc<< " # of : strips="<<fgtCollectionPtr->getNumStrips(iDisc) <<" hits=" <<fgtCollectionPtr-> getNumHits( iDisc)<<endm;
127 
128  // ..... print all strips ....
129  StFgtStripCollection *stripPtr= fgtCollectionPtr->getStripCollection(iDisc);
130  StSPtrVecFgtStrip &stripVec = stripPtr->getStripVec();
131  int ih=0;
132  for( StSPtrVecFgtStripIterator it=stripVec.begin();it!=stripVec.end();++it, ih++) {
133  // details of strip localization, use output variables ending w/ X
134  Short_t discX, quadrantX, stripX; Char_t layerX;
135  StFgtGeom::decodeGeoId(((*it))->getGeoId(),discX,quadrantX, layerX, stripX);
136  int octX=1; if (stripX<300) octX=0;
137  LOG_DEBUG << "iDisc="<<iDisc<<" ih=" <<ih <<" strip: geoId=" <<((*it))->getGeoId()<< " ADC=" <<((*it))->getAdc()<<" charge=" << ((*it))->getCharge()<< " 1f decode0: strip=" <<stripX << " quad="<<quadrantX << " oct=" <<octX << " plane="<<layerX<<" disc="<<discX<<endm;
138  }
139 
140  // ..... print all 1D clusters (aka FGT HITs) ....
141  StFgtHitCollection *clustPtr= fgtCollectionPtr->getHitCollection(iDisc);
142  StSPtrVecFgtHit &clustVec = clustPtr->getHitVec();
143  ih=0;
144  for( StSPtrVecFgtHitIterator it=clustVec.begin();it!=clustVec.end();++it, ih++) {
145  // details of central strip localization, use output variables ending w/ X
146  Short_t discX, quadrantX, stripX; Char_t layerX;
147  StFgtGeom::decodeGeoId(((*it))->getCentralStripGeoId(),discX,quadrantX, layerX, stripX);
148  int octX=1; if (stripX<300) octX=0;
149 
150  LOG_DEBUG <<"iDisc="<<iDisc<<" ih="<<ih<<" clust quad="<<((*it))->getQuad()<<", layer="<<((*it))->getLayer()<<" totCharge="<<(*it)->charge()<< " R/cm="<<(*it)->getPositionR() <<" +/-"<<(*it)->getErrorR() <<" Phi/rad="<<(*it)->getPositionPhi()<<" +/- " << (*it)->getErrorPhi()<< " Z/cm= " << (*it)->getPositionZ() <<" +/- "<<(*it)->getErrorZ()<<" centStripId=" << (*it)->getCentralStripGeoId() <<"decode0: strip= " << stripX <<" quad="<<quadrantX <<" oct="<<octX <<"plane="<< layerX<<" disc=" <<discX <<endm;
151  }
152 
153 
154  }
155 
156  return ierr;
157 
158 }
159 
160 
162 {
163  mClusterAlgoPtr=algo;
164  return kStOk;
165 }
166 
167 Int_t StFgtClusterMaker::InitRun(Int_t runnumber)
168 {
169  Int_t ierr = kStOk;
170  if( !mClusterAlgoPtr ){
171  LOG_INFO << "No fgt cluster algorithm specified, using default seededAlgo" << endm;
172  mClusterAlgoPtr=new StFgtSeededClusterAlgo();
173  }
174 
175  if( !ierr )
176  {
177  LOG_INFO << "StFgtClusterMaker::InitRun for " << runnumber << endm;
178  if( !mDb ){
179  LOG_INFO << "No fgtDb yet, trying to get a hold" << endm;
180  //StFgtDbMaker *fgtDbMkr = static_cast< StFgtDbMaker* >( GetMakerInheritsFrom( "StFgtDbMaker" ) );
181  StFgtDbMaker *fgtDbMkr = static_cast<StFgtDbMaker * >( GetMaker("fgtDb"));
182  if( !fgtDbMkr ){
183  LOG_FATAL << "StFgtDb not provided and error finding StFgtDbMaker" << endm;
184  ierr = kStFatal;
185 
186  } else {
187  mDb = fgtDbMkr->getDbTables();
188 
189  if( !mDb ){
190  LOG_FATAL << "StFgtDb not provided and error retrieving pointer from StFgtDbMaker '"
191  << fgtDbMkr->GetName() << endm;
192  ierr = kStFatal;
193  } else {
194  LOG_INFO << "Got on hold on fgtDb, all OK" << endm;
195  }
196  }
197  }
198  }
199  mClusterAlgoPtr->setDb(mDb);
200  return ierr;
201 }
203 {
204  // cout <<"cluster init " <<endl;
205  Int_t ierr = kStOk;
206 
207  //
208  // Please, conside the Maker's SetMode() method (setting m_Mode but you can get
209  // the value using Getmode() as well ... to switch between cluster agos.
210  // Extrenal setting a-la fgtClusMkr->setClusterAlgo( seededClusAlgo ); is
211  // not appropriate for a chain mades maker.
212  //
213  if( !mClusterAlgoPtr ){
214  LOG_INFO << "No fgt cluster algorithm specified, using default seededAlgo" << endm;
215  mClusterAlgoPtr=new StFgtSeededClusterAlgo();
216  }
217 
218  if( !ierr )
219  ierr = mClusterAlgoPtr->Init();
220 
221 
222  if( !ierr )
223  {
224  LOG_INFO << "StFgtClusterMaker::Init " << endm;
225  if( !mDb ){
226  LOG_INFO << "No fgtDb yet, trying to get a hold" << endm;
227  //StFgtDbMaker *fgtDbMkr = static_cast< StFgtDbMaker* >( GetMakerInheritsFrom( "StFgtDbMaker" ) );
228  StFgtDbMaker *fgtDbMkr = static_cast<StFgtDbMaker * >( GetMaker("fgtDb"));
229  if( !fgtDbMkr ){
230  LOG_FATAL << "StFgtDb not provided and error finding StFgtDbMaker" << endm;
231  ierr = kStFatal;
232 
233  } else {
234  mDb = fgtDbMkr->getDbTables();
235 
236  if( !mDb ){
237  LOG_FATAL << "StFgtDb not provided and error retrieving pointer from StFgtDbMaker '"
238  << fgtDbMkr->GetName() << endm;
239  ierr = kStFatal;
240  } else {
241  LOG_INFO << "Got on hold on fgtDb, all OK" << endm;
242  }
243  }
244  }
245  }
246  mClusterAlgoPtr->setDb(mDb);
247 
248  return ierr;
249 }
250 
251 
253 {
254  cout <<"cluster maker finish!" << endl;
255  Int_t ierr=kStOk;
256  if( mClusterAlgoPtr ){
257  ierr = mClusterAlgoPtr->Finish();
258  }
259  return ierr;
260 }
261 
262 
263 
264 
265 ClassImp(StFgtClusterMaker);
266 
267 
268 // $Log: StFgtClusterMaker.cxx,v $
269 // Revision 1.37 2013/02/20 23:33:28 avossen
270 // add strips on both sides of the cluster
271 //
272 // Revision 1.36 2013/02/20 01:32:27 avossen
273 // added n strips before and after cluster
274 //
275 // Revision 1.35 2013/02/19 18:24:04 avossen
276 // *** empty log message ***
277 //
278 // Revision 1.34 2012/12/10 23:18:00 avossen
279 // merged cluster finder
280 //
281 // Revision 1.33 2012/07/31 21:45:25 jeromel
282 // Misc reshapes
283 //
284 // Revision 1.32 2012/04/13 18:43:13 sgliske
285 // Commented out a LOG_INFO that should have been a LOG_DEBUG
286 // but isn't really needed
287 //
288 // Revision 1.31 2012/03/08 17:43:40 avossen
289 // added default cluster algo, made StFgtIClusterAlgo destructor =0
290 //
291 // Revision 1.30 2012/03/07 22:08:15 avossen
292 // added default cluster algo
293 //
294 // Revision 1.29 2012/03/07 03:57:22 avossen
295 // various updates
296 //
297 // Revision 1.28 2012/02/28 19:32:25 avossen
298 // many changes to enable new clustering algo: New strip fields, identification of seed strips, passing neighboring strips, new order in strip collections
299 //
300 // Revision 1.27 2012/01/06 17:56:07 sgliske
301 // oops--didn't intend to commit the last one.
302 // this commit undoes that.
303 //
304 // Revision 1.25 2011/11/09 17:50:10 balewski
305 // more printout
306 //
307 // Revision 1.24 2011/11/04 19:31:53 balewski
308 // fixed Z problem, by circumventing the bug in the set methods
309 //
310 // Revision 1.23 2011/11/04 19:00:22 avossen
311 // changed phi from local to global phi
312 //
313 // Revision 1.22 2011/11/04 17:38:12 balewski
314 // more printouts
315 //
316 // Revision 1.21 2011/11/04 17:01:19 balewski
317 // *** empty log message ***
318 //
319 // Revision 1.20 2011/11/03 21:18:28 balewski
320 // more printout
321 //
322 // Revision 1.19 2011/11/03 20:04:17 avossen
323 // updated clustering makers and algos to reflect new containers
324 //
325 // Revision 1.18 2011/11/02 20:53:30 balewski
326 // lot of printouts
327 //
328 // Revision 1.17 2011/11/02 16:03:56 balewski
329 // fix indexing of printout
330 //
331 // Revision 1.16 2011/11/01 18:46:30 sgliske
332 // Updated to correspond with StEvent containers, take 2.
333 //
334 // Revision 1.15 2011/10/28 14:29:43 sgliske
335 // fixed CVS tags
336 //
337 // Revision 1.14 2011/10/28 14:28:26 sgliske
338 // Cleaned up prepareEnvironment (no functional change).
339 // Removed old methods of getting data pointer.
340 // Also pClusterAlgo changed to mClusterAlgoPtr to conform with STAR guidelines.
341 //
342 // Revision 1.13 2011/10/26 20:56:50 avossen
343 // use geoIds to determine if two strips are adjacent
344 //
345 // Revision 1.12 2011/10/26 19:32:31 balewski
346 // now fgt-geom is owned by fgtDb-maker
347 //
348 // Revision 1.11 2011/10/26 17:02:04 balewski
349 // get fgt event the proper way
350 //
351 // Revision 1.10 2011/10/20 17:30:37 balewski
352 // revert
353 //
354 // Revision 1.7 2011/10/17 21:42:02 balewski
355 // added tmp interface to fgt-simu-maker
356 //
357 // Revision 1.6 2011/10/10 20:35:08 avossen
358 // fixed strip-cluster association in MaxCluster algo, made other files cvs compliant
359 //
360 //
361 //
Int_t setClusterAlgo(StFgtIClusterAlgo *)
clear function is empty at the moment
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
virtual Int_t doClustering(const StFgtCollection &fgtCollection, StFgtStripCollection &, StFgtHitCollection &)=0
virtual Int_t Init()
Init function. Checks if there is a cluster algo and initializes the same.
Definition: Stypes.h:44
virtual Int_t Finish()
Definition: Stypes.h:41