67 #include "StFgtSimpleClusterAlgo.h"
68 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
70 #include "StRoot/StEvent/StFgtStripCollection.h"
71 #include "StRoot/StEvent/StFgtStrip.h"
72 #include "StRoot/StEvent/StFgtHitCollection.h"
73 #include "StRoot/StEvent/StFgtHit.h"
77 StFgtSimpleClusterAlgo::StFgtSimpleClusterAlgo()
82 Int_t StFgtSimpleClusterAlgo::Init()
101 strips.sortByGeoId();
103 Float_t defaultError = 0.001;
104 Short_t disc, quadrant,prvDisc,prvQuad;
105 Char_t layer,prvLayer,noLayer=
'z';
106 Double_t ordinate, lowerSpan, upperSpan, prvOrdinate;
108 Double_t accuCharge=0;
109 Double_t accuChargeError=0;
110 Double_t meanOrdinate=0;
111 Double_t meanSqOrdinate=0;
118 Double_t meanGeoId=0;
122 for( StSPtrVecFgtStripIterator it=strips.getStripVec().begin();it!=strips.getStripVec().end();++it)
124 StFgtGeom::getPhysicalCoordinate((*it)->getGeoId(),disc,quadrant,layer,ordinate,lowerSpan,upperSpan);
126 if((layer==
'R')&& ordinate < kFgtRmid)
134 for( StSPtrVecFgtStripIterator it=strips.getStripVec().begin();it!=strips.getStripVec().end();++it)
136 StFgtGeom::getPhysicalCoordinate((*it)->getGeoId(),disc,quadrant,layer,ordinate,lowerSpan,upperSpan);
139 if(prvLayer==noLayer)
141 newCluster=
new StFgtHit(clusters.getHitVec().size(),meanGeoId,accuCharge, disc, quadrant, layer, ordinate, defaultError,ordinate, defaultError,0.0,0.0);
142 stripWeightMap_t &stripWeightMap = newCluster->getStripWeightMap();
143 stripWeightMap[ *it ] = 1;
146 accuCharge=(*it)->getCharge();
147 accuChargeError=(*it)->getChargeUncert();
148 meanGeoId=(*it)->getCharge()*(*it)->getGeoId();
151 meanOrdinate=ordinate;
152 meanSqOrdinate=ordinate*ordinate;
154 prvGeoId=(*it)->getGeoId();
156 prvOrdinate=ordinate;
163 bool adjacentStrips=((abs(prvGeoId-(*it)->getGeoId())<2)|| (( abs(prvGeoId-(*it)->getGeoId())==2) && stepTwo && isPhi && (prvGeoId%2==0)));
166 if((layer==prvLayer && adjacentStrips)&& prvLayer!=noLayer)
171 accuCharge+=(*it)->getCharge();
172 accuChargeError+=(*it)->getChargeUncert();
173 meanOrdinate+=ordinate;
174 meanGeoId+=(*it)->getCharge()*(*it)->getGeoId();
178 meanSqOrdinate+=ordinate*ordinate;
181 stripWeightMap_t &stripWeightMap = newCluster->getStripWeightMap();
182 stripWeightMap[ *it ] = 1;
184 prvGeoId=(*it)->getGeoId();
185 prvOrdinate=ordinate;
195 newCluster->setCharge(accuCharge);
196 numStrips > 1 ? newCluster->setChargeUncert(sqrt(accuChargeError/((
float)numStrips-1))) : newCluster->setChargeUncert(sqrt(accuChargeError/((
float)numStrips)));
198 meanOrdinate /= (float)numStrips;
200 meanGeoId /= accuCharge;
204 meanSqOrdinate /= (float)numStrips;
205 meanSqOrdinate -= meanOrdinate*meanOrdinate;
206 if( meanSqOrdinate > 0 )
207 meanSqOrdinate = sqrt(meanSqOrdinate);
210 Double_t pitch = ( layer ==
'R' ? StFgtGeom::radStrip_pitch() : StFgtGeom::phiStrip_pitch() );
211 if( meanSqOrdinate < 2*pitch )
212 meanSqOrdinate = 2*pitch;
216 newCluster->setPositionR(meanOrdinate );
217 newCluster->setErrorR(meanSqOrdinate);
221 newCluster->setPositionPhi(meanOrdinate );
222 newCluster->setErrorPhi(meanSqOrdinate);
224 newCluster->setCentralStripGeoId(floor(meanGeoId+0.5));
225 if(numStrips<=kFgtMaxClusterSize && newCluster->getCentralStripGeoId() > 0)
226 clusters.getHitVec().push_back(newCluster);
231 accuCharge=(*it)->getCharge();
232 accuChargeError=(*it)->getChargeUncert();
233 meanOrdinate=ordinate;
234 meanGeoId=(*it)->getCharge()*(*it)->getGeoId();
236 meanSqOrdinate=ordinate*ordinate;
241 newCluster=
new StFgtHit(clusters.getHitVec().size(),meanGeoId,accuCharge, disc, quadrant, layer, ordinate, defaultError,ordinate, defaultError,0.0,0.0);
243 stripWeightMap_t &stripWeightMap = newCluster->getStripWeightMap();
244 stripWeightMap[ *it ] = 1;
246 prvGeoId=(*it)->getGeoId();
249 prvOrdinate=ordinate;
258 meanOrdinate /= (float)numStrips;
260 meanGeoId/=accuCharge;
263 newCluster->setCharge(accuCharge);
264 numStrips > 1 ? newCluster->setChargeUncert(sqrt(accuChargeError/((
float)numStrips-1))) : newCluster->setChargeUncert(sqrt(accuChargeError/((
float)numStrips)));
266 meanSqOrdinate /= (float)numStrips;
267 meanSqOrdinate -= meanOrdinate*meanOrdinate;
268 if( meanSqOrdinate > 0 )
269 meanSqOrdinate = sqrt(meanSqOrdinate);
274 Double_t pitch = ( layer ==
'R' ? StFgtGeom::radStrip_pitch() : StFgtGeom::phiStrip_pitch() );
275 if( meanSqOrdinate < 2*pitch )
276 meanSqOrdinate = 2*pitch;
279 newCluster->setPositionR(meanOrdinate );
280 newCluster->setErrorR(meanSqOrdinate);
284 newCluster->setPositionPhi(meanOrdinate );
285 newCluster->setErrorPhi(meanSqOrdinate);
290 newCluster->setCentralStripGeoId(floor(meanGeoId+0.5));
291 if(numStrips<=kFgtMaxClusterSize && newCluster->getCentralStripGeoId() > 0)
292 clusters.getHitVec().push_back(newCluster);
300 StFgtSimpleClusterAlgo::~StFgtSimpleClusterAlgo()
virtual Int_t doClustering(const StFgtCollection &fgtCollection, StFgtStripCollection &strips, StFgtHitCollection &clusters)
the main function, using a collection of strips tht fired to build clusters of neighbouring strips ...