12 #include "StRoot/St_base/StMessMgr.h"
14 #include "StEEmcUtil/EEmcGeom/EEmcGeomDefs.h"
16 #include "StRoot/StEEmcPool/./EEmcTreeContainers/EEmcEnergy.h"
17 #include "StRoot/StEEmcPool/StEEmcGeoId/StEEmcGeoId.h"
19 #include "StEEmcPointFinderIU.h"
20 #include "StFinderAlg.h"
21 #include "StSimpleCluster.h"
22 #include "StEEmcHit.h"
23 #include "StEEmcStripClusterFinder.h"
24 #include "StESMDClustersPerSector.h"
33 mTowerThreshold( 0.0 )
35 mEEmcSmdGeom = EEmcSmdGeom::instance();
36 mEEmcSmdMap = EEmcSmdMap::instance();
39 LOG_FATAL <<
"StEEmcPointFinderIU_t(...) CANNOT GET POINTER TO EEmcSmdGeom" << endm;
44 LOG_FATAL <<
"StEEmcPointFinderIU_t(...) CANNOT GET POINTER TO EEmcSmdMap" << endm;
57 const StSimpleClusterVec_t &towerClusterVec,
58 const StESMDClustersVec_t &smdClusterVec,
59 const Double_t* smdEuEvRatio,
60 StEEmcHitVec_t& hitVec ){
69 StClusterPool_t uClusterPool, vClusterPool;
72 StESMDClustersVec_t::const_iterator smdClusterVecIter;
73 StSimpleClusterVec_t::const_iterator clusterIter;
79 for( smdClusterVecIter = smdClusterVec.begin(); smdClusterVecIter != smdClusterVec.end(); ++smdClusterVecIter ){
80 mSector = smdClusterVecIter->getSector();
89 const StSimpleClusterVec_t &uClusVec = smdClusterVecIter->getClusterVecU();
90 const StSimpleClusterVec_t &vClusVec = smdClusterVecIter->getClusterVecV();
95 for( clusterIter = uClusVec.begin(); clusterIter != uClusVec.end(); ++clusterIter )
96 uClusterPool.insert( &(*clusterIter) );
99 for( clusterIter = vClusVec.begin(); clusterIter != vClusVec.end(); ++clusterIter )
100 vClusterPool.insert( &(*clusterIter) );
107 ierr =
findPoints( eemcEnergy, uClusterPool, vClusterPool, hitVec );
119 StClusterPool_t &uClusterPool,
120 StClusterPool_t &vClusterPool,
121 StEEmcHitVec_t& hitVec ) {
133 StEEmcHitVec_t hitsSMDstage0;
138 std::vector< Int_t > hitIdxStage1;
141 std::vector< Int_t > hitIdxStage2;
146 StClusterPool_t::const_iterator uClusIter;
147 StClusterPool_t::const_iterator vClusIter;
162 for( uClusIter = uClusterPool.begin(); uClusIter != uClusterPool.end() && !ierr; ++uClusIter ){
163 for( vClusIter = vClusterPool.begin(); vClusIter != vClusterPool.end() && !ierr; ++vClusIter ){
170 Float_t uSeedMean = (*uClusIter)->getMeanX();
171 Float_t vSeedMean = (*vClusIter)->getMeanX();
173 assert( uSeedMean >= 0 && vSeedMean >= 0 && uSeedMean < kEEmcNumStrips && vSeedMean < kEEmcNumStrips );
179 TVector3 direct = mEEmcSmdGeom->
getIntersection( mSector, uSeedMean, vSeedMean );
181 if( mEEmcGeomSimple.
getTower(direct,sec,sub,eta) ){
183 isValid = ( sec == mSector );
192 Int_t hitTowerIdx = StEEmcGeoId_t::encodeTow( sec, sub, eta );
193 const EEmcElement_t& tower = eemcEnergy.eTow.getByIdx( hitTowerIdx );
204 if ( tower.energy > mTowerThreshold ) {
206 }
else if ( tower.fail ) {
207 isValid = ( eemcEnergy.ePre1.getByIdx( hitTowerIdx ).energy > 0 ||
208 eemcEnergy.ePre2.getByIdx( hitTowerIdx ).energy > 0 ||
209 eemcEnergy.ePost.getByIdx( hitTowerIdx ).energy > 0 );
215 uE = (*uClusIter)->getEnergy();
216 vE = (*vClusIter)->getEnergy();
220 isValid &= uE > mMinUVratio*vE;
221 isValid &= vE > mMinUVratio*uE;
230 hitsSMDstage0.push_back(
StEEmcHit_t(++mLastSMDhitID) );
236 hit.setEnergyU( uE );
237 hit.setEnergyV( vE );
238 hit.setClusIDu( (*uClusIter)->getID() );
239 hit.setClusIDv( (*vClusIter)->getID() );
240 hit.setTowerIdx( hitTowerIdx );
241 hit.setSector( mSector );
249 hit.setX( direct.X() );
250 hit.setY( direct.Y() );
251 hit.setZ( direct.Z() );
261 if( direct.Z() < -998 ){
263 hitsSMDstage0.pop_back();
283 if( hitsSMDstage0.size() < 1 || ierr )
288 std::sort( hitsSMDstage0.begin(), hitsSMDstage0.end(), hitTtest2LessThan );
293 std::map< Int_t, std::vector<Int_t> > uClusID2hitIdx, vClusID2hitIdx;
296 std::map< Int_t, const StSimpleCluster_t* > uClusID2ptr, vClusID2ptr;
297 for( uClusIter = uClusterPool.begin(); uClusIter != uClusterPool.end(); ++uClusIter )
298 uClusID2ptr[ (*uClusIter)->getID() ] = (*uClusIter);
300 for( vClusIter = vClusterPool.begin(); vClusIter != vClusterPool.end(); ++vClusIter )
301 vClusID2ptr[ (*vClusIter)->getID() ] = (*vClusIter);
304 for( UInt_t i=0; i < hitsSMDstage0.size(); i++ ) {
325 uClusID2hitIdx[ hitsSMDstage0[i].getClusIDu() ].push_back( i );
326 vClusID2hitIdx[ hitsSMDstage0[i].getClusIDv() ].push_back( i );
335 for( uClusIter = uClusterPool.begin(); uClusIter != uClusterPool.end(); ){
338 if( uClusID2hitIdx[ clusPtr->getID() ].empty() ){
343 uClusterPool.erase( clusPtr );
349 for( vClusIter = vClusterPool.begin(); vClusIter != vClusterPool.end(); ){
352 if( vClusID2hitIdx[ clusPtr->getID() ].empty() ){
357 vClusterPool.erase( clusPtr );
375 for( uClusIter = uClusterPool.begin(); uClusIter != uClusterPool.end(); ++uClusIter ){
380 std::vector<Int_t>& hitIdxVec = uClusID2hitIdx[ (*uClusIter)->getID() ];
386 if( !hitIdxVec.empty() ){
387 if( hitIdxVec.size() == 1 ){
389 hitIdxStage1.push_back( hitIdxVec.front() );
396 hitIdxStage2.push_back( hitIdxVec.front() );
402 for( vClusIter = vClusterPool.begin(); vClusIter != vClusterPool.end(); ++vClusIter ){
407 std::vector<Int_t>& hitIdxVec = vClusID2hitIdx[ (*vClusIter)->getID() ];
413 if( !hitIdxVec.empty() ){
414 if( hitIdxVec.size() == 1 ){
416 hitIdxStage1.push_back( hitIdxVec.front() );
424 hitIdxStage2.push_back( hitIdxVec.front() );
433 std::sort( hitIdxStage1.begin(), hitIdxStage1.end() );
456 if( hitIdxStage1.size() > 1 ){
457 std::vector< Int_t >::iterator hitIter_1, hitIter_2;
459 for( hitIter_1 = hitIdxStage1.begin(); hitIter_1 != hitIdxStage1.end(); ++hitIter_1 ){
464 hitIter_2 = hitIter_1;
469 while( (*hitIter_2) == (*hitIter_1) && hitIter_2 != hitIdxStage1.end())
473 for( ; hitIter_2 != hitIdxStage1.end(); ++hitIter_2 ){
488 Bool_t oneU = ( Uclus1 == Uclus2 );
489 Bool_t oneV = ( Vclus1 == Vclus2 );
494 Bool_t isBelowThres = 0;
495 Float_t uZratio, vZratio, uWeight1, uWeight2, vWeight1, vWeight2;
504 uZratio = TMath::Abs(
505 ( Uclus1->getEnergy() - Vclus1->getEnergy() - Vclus2->getEnergy() )/
506 ( Uclus1->getEnergy() + Vclus1->getEnergy() + Vclus2->getEnergy() ) );
510 isBelowThres = ( uZratio < mZratioThres );
512 uWeight1 = Vclus1->getEnergy()/(Vclus1->getEnergy()+Vclus2->getEnergy());
513 uWeight2 = 1 - uWeight1;
520 vZratio = TMath::Abs(
521 ( Vclus1->getEnergy() - Uclus1->getEnergy() - Uclus2->getEnergy() )/
522 ( Vclus1->getEnergy() + Uclus1->getEnergy() + Uclus2->getEnergy() ) );
525 isBelowThres = ( vZratio < mZratioThres );
530 vWeight1 = Uclus1->getEnergy()/(Uclus1->getEnergy()+Uclus2->getEnergy());
531 vWeight2 = 1 - vWeight1;
542 hitVec.push_back( hit1 );
545 hitVec.push_back( hit2 );
549 saved_hit1.setWeightU( uWeight1 );
550 saved_hit1.setWeightV( vWeight1 );
551 saved_hit2.setWeightU( uWeight2 );
552 saved_hit2.setWeightV( vWeight2 );
557 uClusterPool.erase( Uclus1 );
558 vClusterPool.erase( Vclus1 );
560 uClusterPool.erase( Uclus2 );
562 vClusterPool.erase( Vclus2 );
574 return findPoints( eemcEnergy, uClusterPool, vClusterPool, hitVec );
604 if( !hitIdxStage1.empty() ){
624 if( hit.getTtest2() < mTtestThres ){
626 hitVec.push_back( hit );
629 uClusterPool.erase( uClus );
630 vClusterPool.erase( vClus );
644 return findPoints( eemcEnergy, uClusterPool, vClusterPool, hitVec );
664 if( !hitIdxStage2.empty() ){
667 Int_t idx = *(std::min_element( hitIdxStage2.begin(), hitIdxStage2.end() ));
684 if( hit.getTtest2() < mTtestThres ){
686 hitVec.push_back( hit );
689 uClusterPool.erase( uClus );
690 vClusterPool.erase( vClus );
701 return findPoints( eemcEnergy, uClusterPool, vClusterPool, hitVec );
Int_t findPoints(const EEmcEnergy_t &eemcEnergy, StClusterPool_t &uClusterVec, StClusterPool_t &vClusterVec, StEEmcHitVec_t &hitVec)
virtual Int_t find(const EEmcEnergy_t &eemcEnergy, const StSimpleClusterVec_t &towerClusterVec, const StESMDClustersVec_t &smdClusterVec, const Double_t *smdEuEvRatio, StEEmcHitVec_t &hitVec)
find some some points
TVector3 getIntersection(Int_t iSec, Int_t iUStrip, Int_t iVStrip, const TVector3 &vertex) const
bool getTower(const TVector3 &r, int &sec, int &sub, int &etabin, Float_t &dphi, Float_t &deta) const