1 #include "StEEmcClusterMaker.h"
10 #include "StEvent/StEvent.h"
11 #include "StEvent/StEmcCollection.h"
12 #include "StEvent/StEmcDetector.h"
13 #include "StEvent/StEmcModule.h"
14 #include "StEvent/StEmcClusterCollection.h"
15 #include "StEvent/StEmcCluster.h"
18 #define FIXED_SMD_SEED
42 const Float_t eseeds[] = { 0.6, 1.0/1000, 1.0/1000, 1.0/1000., 0.3/1000., 0.3/1000. };
43 for ( Int_t i = 0; i < 6; i++ )
seedEnergy( eseeds[i], i );
62 std::vector< StEEmcClusterVec_t > layers;
63 for ( Int_t i = 0; i < 4; i++ ) layers.push_back(t);
66 StEEmcSmdClusterVec_t s;
67 std::vector< StEEmcSmdClusterVec_t > planes;
70 for ( Int_t i = 0; i < 12; i++ )
mSmdClusters.push_back(planes);
73 std::vector< StEEmcTowerVec_t > lay;
74 for ( Int_t i = 0; i < 4; i++ ) lay.push_back(tow);
75 for ( Int_t i = 0; i < 12; i++ )
mSeedTowers.push_back(lay);
78 mEEsmd=EEmcSmdGeom::instance();
79 mEEmap=EEmcSmdMap::instance();
89 return StMaker::Init();
107 if ( !
verifyStEvent() ) Warning(
"Make",
"StEvent not properly copied");
117 for ( Int_t sector=0; sector<12; sector++ ) {
118 for ( Int_t layer=0; layer<4; layer++ )
120 for ( Int_t plane=0; plane<2; plane++ )
142 for ( Int_t layer=0;layer<4;layer++)
147 Float_t weights[720];
for ( Int_t i=0;i<720;i++ ) weights[i]=0.;
150 StEEmcClusterVec_t myClusters;
154 StEEmcTowerVec_t towers =
mEEanalysis -> towers( layer );
159 std::sort(towers.begin(),towers.end());
161 std::reverse(towers.begin(),towers.end());
166 StEEmcTowerVec_t::iterator last = towers.begin();
167 while ( last != towers.end() ) {
169 if ( (*last).energy() <
mSeedEnergy[layer] )
break;
176 std::cout <<
"-- Seed tower ----------------------" << std::endl;
182 StEEmcTowerVec_t::iterator iter = towers.begin();
183 while ( iter != towers.end() ) {
186 if ( iter==last )
break;
195 if ( weights[ (*iter).index() ] > 0. ) {
202 for ( Int_t in=0; in < (*iter).numberOfNeighbors(); in++ ) {
204 weights[ t.
index() ] += (*iter).energy();
215 while ( iter != towers.end() ) {
218 if ( iter==last )
break;
223 if ( weights[ (*iter).index() ] > 0. ) {
231 std::cout <<
"--- Clustering ----------------" << std::endl;
236 cluster.
add(seed,1.0);
238 sec=(UInt_t)seed.
sector();
240 eta=(UInt_t)seed.
etabin();
242 momentum += ( seed.
energy() * d );
250 Float_t weight = seed.
energy() / weights[ t.
index() ];
251 momentum += ( t.
energy() * d * weight );
252 cluster.
add(t, weight);
254 std::cout <<
"adding " << t.
name() <<
" E=" << t.
energy() <<
" W=" << weight << std::endl;
281 #ifdef FIXED_SMD_SEED
289 for ( Int_t sector=0; sector<12; sector++ )
291 for ( Int_t plane=0; plane<2; plane++ ) {
294 Float_t floor[288];
for ( Int_t i=0; i<288; i++ ) floor[i]=0.;
298 StEEmcStripVec_t seeds;
300 std::sort(strips.begin(),strips.end());
302 std::reverse(strips.begin(),strips.end());
305 std::vector<Bool_t> seed_flags( strips.size(), false );
310 StEEmcStripVec_t::iterator istrip=strips.begin();
311 while ( istrip!=strips.end() ) {
313 Int_t index=(*istrip).index();
314 Float_t eseed=(*istrip).energy();
317 if ( index <= 3 || index >= 283 ) {
325 if ( (*istrip).fail() || (*istrip).stat() ) {
341 seeds.push_back( (*istrip) );
346 for ( Int_t i=0; i < 288; i++ ) {
349 Int_t dx=TMath::Abs(index-i);
353 if ( eseed > floor[i] ) floor[i]=eseed;
357 if ( 0.20 * eseed > floor[i] ) floor[i] = 0.2 * eseed;
361 if ( 0.10 * eseed > floor[i] ) floor[i] = 0.1 * eseed;
365 if ( 0.20*eseed > floor[i] ) floor[i] = 0.05 * eseed;
369 for ( Int_t i=0; i < 288; i++ ) {
372 Int_t dx=TMath::Abs(index-i);
376 if ( 0.05 * eseed > floor[i] ) floor[i] = 0.05 * eseed;
391 Bool_t owned[288];
for (Int_t i=0;i<288;i++) owned[i]=
false;
392 Bool_t xseed[288];
for (Int_t i=0;i<288;i++) xseed[i]=
false;
394 StEEmcStripVec_t::iterator iseed=seeds.begin();
395 while ( iseed != seeds.end() ) {
398 Int_t index=(*iseed).index();
399 if ( owned[index] || (
mSuppress&&xseed[index]) ) {
410 cluster.add( (*iseed) );
414 for ( Int_t i=index+1; i<=index+max_extent; i++ ) {
421 if ( strip.
energy()<=0. )
break;
423 owned[ strip.
index() ] =
true;
425 xseed[ strip.
index() ] =
true;
429 for ( Int_t i=index-1; i>=index-max_extent; i-- ) {
436 if (strip.
energy()<=0.)
break;
438 owned[ strip.
index() ] =
true;
440 xseed[ strip.
index() ] =
true;
446 if ( cluster.size() >= 3 ) {
453 Int_t ns=cluster.numberOfStrips();
454 Int_t left=999,right=-999;
455 for ( Int_t is=0;is<ns;is++ )
479 #ifdef DYNAMIC_SMD_SEED
488 for ( Int_t sector=0; sector<12; sector++ )
492 StEEmcClusterVec_t clist =
clusters(sector,0);
495 StEEmcStripVec_t seeds;
498 for ( UInt_t iuv=0; iuv<2; iuv++ )
502 StEEmcStripVec_t seeds;
505 std::vector<Int_t> used(288,0);
508 std::vector<Float_t> floor(288,0.);
512 for ( UInt_t ic=0; ic<clist.size(); ic++ )
523 Float_t esmd = cluster.
energy() * 0.0056;
527 Float_t ethresh = esmd * 0.1;
532 Int_t smin[2], smax[2];
533 mEEmap->getRangeU(sec,sub,eta, smin[0], smax[0] );
534 mEEmap->getRangeV(sec,sub,eta, smin[1], smax[1] );
535 smin[0]=TMath::Max(smin[0]-20,4);
536 smax[0]=TMath::Min(smax[0]+20,284);
537 smin[1]=TMath::Max(smin[1]-20,4);
538 smax[1]=TMath::Min(smax[1]+20,284);
543 for ( Int_t istrip=smin[iuv]; istrip<smax[iuv]; istrip++ )
553 Float_t mythresh=TMath::Max(ethresh, floor[istrip]);
557 if ( strip.
energy() > mythresh && !used[istrip] ) {
559 seeds.push_back( strip );
561 floor[istrip] = strip.
energy();
562 for ( Int_t i=0; i<20; i++ ) {
563 if ( istrip+i<288 ) floor[istrip+i]+=0.10*strip.
energy();
564 if ( istrip-i>0 ) floor[istrip-i]+=0.10*strip.
energy();
571 for ( Int_t i=0; i<max_extent; i++ ) {
599 if ( smdc.numberOfStrips() > 2 )
625 Warning(
"fillStEvent",
"called, but no StEvent to be found");
629 std::cout <<
"Adding tower clusters to StEvent at " << stevent << std::endl;
634 StEmcDetector *detector=stevent->emcCollection()->detector(kEndcapEmcTowerId);
637 Warning(
"fillStEvent",
"detector == NULL, MAJOR StEvent problem, continuing");
663 detector->setCluster( collect );
667 collect->setDetector( kEndcapEmcTowerId );
668 collect->setClusterFinderId( 123 );
669 collect->setClusterFinderParamVersion( 123 );
672 for ( Int_t isector=0; isector<12; isector++ )
676 for ( UInt_t iclust=0; iclust<
mTowerClusters[isector][0].size(); iclust++ )
685 emccluster->setEta( cl.
momentum().Eta() );
686 emccluster->setPhi( cl.
momentum().Phi() );
687 emccluster->setSigmaEta(-1.);
688 emccluster->setSigmaPhi(-1.);
689 emccluster->setEnergy( cl.
energy() );
690 emccluster->SetUniqueID( cl.key() );
696 emccluster->addHit( hit );
700 collect->addCluster( emccluster );
704 mEtoEE[ emccluster ] = cl;
705 cl.
stemc( emccluster );
716 detector->setCluster( NULL );
729 detector=stevent->emcCollection()->detector(kEndcapEmcPreShowerId);
732 Warning(
"fillStEvent",
"detector == NULL for pre/post, no clusters for you");
744 detector->setCluster( pqr );
747 pqr -> setDetector( kEndcapEmcPreShowerId );
748 pqr -> setClusterFinderId( 123 );
749 pqr -> setClusterFinderParamVersion( 321 );
752 for ( Int_t isector=0; isector<12; isector++ )
755 for ( Int_t ilayer=1; ilayer<4; ilayer++ )
758 for ( UInt_t iclust=0; iclust<
mTowerClusters[isector][ilayer].size(); iclust++ )
767 emccluster->setEta( cl.
momentum().Eta() );
768 emccluster->setPhi( cl.
momentum().Phi() );
769 emccluster->setSigmaEta(-1.);
770 emccluster->setSigmaPhi(-1.);
771 emccluster->setEnergy( cl.
energy() );
772 emccluster->SetUniqueID( cl.key() );
778 emccluster->addHit( hit );
783 pqr->addCluster( emccluster );
785 mEtoEE[ emccluster ] = cl;
786 cl.
stemc( emccluster );
794 detector->setCluster( NULL );
802 StDetectorId ids[]={ kEndcapSmdUStripId, kEndcapSmdVStripId };
805 for ( Int_t iplane=0; iplane<2; iplane++ )
808 detector=stevent->emcCollection()->detector(ids[iplane]);
811 Warning(
"fillStEvent",
"detector == NULL for smd plane, no clusters for you");
821 detector->setCluster( smdc );
824 smdc->setDetector( ids[iplane] );
825 smdc->setClusterFinderId( 123 );
826 smdc->setClusterFinderParamVersion( 321 );
829 for ( Int_t isector=0; isector<12; isector++ )
832 for ( UInt_t iclust=0; iclust<
mSmdClusters[isector][iplane].size(); iclust++ )
839 emccluster->setEta( cl.mean() );
840 emccluster->setPhi( (Float_t)iplane );
841 emccluster->setSigmaEta(-1.);
842 emccluster->setSigmaPhi(-1.);
843 emccluster->setEnergy( cl.energy() );
844 emccluster->SetUniqueID( cl.
key() );
845 for ( Int_t i=0; i< cl.numberOfStrips(); i++ )
849 emccluster->addHit( hit );
851 smdc->addCluster( emccluster );
854 cl.
stemc( emccluster );
865 detector -> setCluster( NULL );
884 Warning(
"verifyStEvent",
"No StEvent found.");
891 StEmcDetector *detector=stevent->emcCollection()->detector(kEndcapEmcTowerId);
894 Warning(
"verifyStEvent",
"detector == NULL for towers");
909 Float_t emc_sum_towers = 0.;
910 Float_t eemc_sum_towers = 0.;
912 StSPtrVecEmcCluster &emcClusters=cc->clusters();
913 for ( UInt_t i=0; i<emcClusters.size(); i++ )
917 emc_sum_towers += cl->energy();
920 for ( Int_t sec=0; sec<12; sec++ )
927 std::cout <<
"StEEmcClusterMaker tower checksum: ";
928 if ( emc_sum_towers == eemc_sum_towers ) {
929 std::cout <<
"passed";
932 std::cout <<
"FAILED"; go=
false;
934 std::cout << std::endl;
939 std::cout <<
"StEEmcClusterMaker tower checksum: NULL collection, nclust=" <<
mNumberOfClusters[0] << std::endl;
948 Float_t emc_sum_smdu = 0.;
949 Float_t eemc_sum_smdu = 0.;
951 detector=stevent->emcCollection()->detector(kEndcapSmdUStripId);
954 Warning(
"verifyStEvent",
"detector == NULL for smdu");
958 cc=detector->cluster();
962 StSPtrVecEmcCluster &smduClusters=cc->clusters();
964 for ( UInt_t i=0; i<smduClusters.size(); i++ )
968 emc_sum_smdu += cl->energy();
972 for ( Int_t sec=0; sec<12; sec++ )
978 eemc_sum_smdu +=
smdcluster(sec,0,i).energy();
984 std::cout <<
"StEEmcClusterMaker smdu checksum: ";
985 if ( emc_sum_smdu == eemc_sum_smdu ) {
986 std::cout <<
"passed";
989 std::cout <<
"FAILED"; go=
false;
991 std::cout << std::endl;
996 std::cout <<
"StEEmcClusterMaker smdu checksum: NULL collection, nclust=" <<
mNumberOfClusters[4] << std::endl;
1003 Float_t emc_sum_smdv = 0.;
1004 Float_t eemc_sum_smdv = 0.;
1006 detector=stevent->emcCollection()->detector(kEndcapSmdVStripId);
1009 Warning(
"verifyStEvent",
"detector == NULL for smdv");
1013 cc=detector->cluster();
1018 StSPtrVecEmcCluster &smdvClusters=cc->clusters();
1020 for ( UInt_t i=0; i<smdvClusters.size(); i++ )
1024 emc_sum_smdv += cl->energy();
1028 for ( Int_t sec=0; sec<12; sec++ )
1034 eemc_sum_smdv +=
smdcluster(sec,1,i).energy();
1040 std::cout <<
"StEEmcClusterMaker smdv checksum: ";
1041 if ( emc_sum_smdv == eemc_sum_smdv ) {
1042 std::cout <<
"passed";
1045 std::cout <<
"FAILED"; go=
false;
1047 std::cout << std::endl;
1052 std::cout <<
"StEEmcClusterMaker smdv checksum: NULL collection, nclust=" <<
mNumberOfClusters[5] << std::endl;
1067 std::cout <<
"StEEmcClusterMaker::print()" << std::endl;
1068 const Char_t *names[] = {
"tower",
"pre1",
"pre2",
"post",
"smdu",
"smdv" };
1069 for ( Int_t i=0;i<6;i++ )
1072 std::cout <<
"Number of " << names[i]
1078 std::cout <<
"printout of tower clusters follows:" << std::endl;
1079 for ( Int_t sec=0;sec<12;sec++)
TVector3 momentum() const
const StEEmcA2EMaker * mEEanalysis
ADC–>E maker.
TVector3 getTowerCenter(const UInt_t sec, const UInt_t sub, const UInt_t etabin) const
Int_t mSuppress
Supress seeds adjacent to clusters.
virtual void Clear(Option_t *opts="")
Clear clusters for next event.
StEEmcTower & tower(Int_t t)
Get the specified tower within the cluster.
Int_t numberOfNeighbors() const
get the number of neighboring towers
EEmc ADC –> energy maker.
void stat(unsigned s)
Set a status bit for this element.
StEEmcClusterMaker(const Char_t *name="mEEclusters")
Int_t numberOfClusters(Int_t sec, Int_t layer) const
Return number of clusters for a given sector, layer.
void add(const StEEmcTower &t, Float_t weight=1.0)
std::vector< std::vector< StEEmcSmdClusterVec_t > > mSmdClusters
StEEmcCluster & cluster(Int_t sec, Int_t layer, Int_t index)
Return a specific cluster from a given sector, layer.
const EEmcSmdMap * mEEmap
const EEmcGeomSimple * mEEtow
Int_t numberOfSmdClusters(Int_t sec, Int_t plane) const
Return number of smd clusters for a given sector, plane.
const EEmcSmdGeom * mEEsmd
Int_t mNumberOfClusters[6]
Counts clusters for full eemc, 0=T, 1=P, 2=Q, 3=R, 4=U, 5=V.
void neighbor(StEEmcTower *n)
add a tower to list of neighbors
StEEmcStrip & strip(Int_t sector, Int_t plane, Int_t strip)
std::vector< std::vector< StEEmcClusterVec_t > > mTowerClusters
std::vector< std::vector< StEEmcTowerVec_t > > mSeedTowers
Float_t mSeedFloor
blah...
Bool_t mFillStEvent
Option to fill StEvent.
void name(const Char_t *n)
Set the name for this element.
void print() const
Prints cluster data.
Int_t etabin() const
Returns the etabin of this tower, pre- or postshower element.
void fail(unsigned f)
Set a fail bit for this element.
TString mAnalysisName
ADC–>E maker name.
Int_t subsector() const
Returns subsector of this tower, pre- or postshower element.
virtual Bool_t buildSmdClusters()
Constructs smd clusters.
virtual Bool_t buildTowerClusters()
Constructs tower clusters.
StEEmcStripVec_t & strips(Int_t sec, Int_t pln)
Returns a vector of hit strips, given the sector and plane.
void print() const
Print a summary of this tower.
void index(Int_t i)
Sets the index for this SMD strip, 0..287.
Base class for representing tower, preshower and postshower elements.
virtual Int_t Init()
Initialize.
Float_t mSeedEnergy[6]
Seed energy for 0=T, 1=P, 2=Q, 3=R, 4=U, 5=V.
Int_t sector() const
Returns sector of this tower, pre- or postshower element.
Int_t mMaxExtent
Maximum distance from SMD seed strips.
Int_t key()
Return a unique key assigned by the cluster maker.
Int_t numberOfTowers() const
Get the number of towers in cluster.
A base class for representing clusters of EEMC smd strips.
virtual Int_t Make()
Make clusters for this event.
Float_t energy() const
Get energy of this cluster.
void print() const
Event summary.
std::map< const StEmcCluster *, StEEmcCluster > mEtoEE
Map StEEmcClusters to StEmcClusters.
Bool_t verifyStEvent() const
A base class for describing clusters of EEMC towers.
std::map< const StEmcCluster *, StEEmcSmdCluster > mEtoEEsmd
... and for smd clusters
void seedEnergy(Float_t energy, Int_t layer=0)
void stemc(StEmcRawHit *h)
Sets pointer to the StEmcRawHit when processing an StEvent file.
StEEmcSmdCluster & smdcluster(Int_t sec, Int_t plane, Int_t index)
return a specific cluster from a given sector, plane
StEEmcClusterVec_t & clusters(Int_t sec, Int_t layer)
Return a vector of tower clusters.
void fillStEvent()
Fills StEvent cluster collections if the option is selected.
void energy(Float_t e)
Set the energy (adc-ped+0.5)/gain for this element.
StEEmcStrip & strip(Int_t s)
Returns the specified smd strip w/in the cluster.
Base class for describing an endcap SMD strip.
Int_t mClusterId
Keep track of clusters.
A cluster maker for the EEMC.