48 #include "StEEmcClusterMaker.h"
56 #include "StEvent/StEvent.h"
57 #include "StEvent/StEmcCollection.h"
58 #include "StEvent/StEmcDetector.h"
59 #include "StEvent/StEmcModule.h"
60 #include "StEvent/StEmcClusterCollection.h"
61 #include "StEvent/StEmcCluster.h"
85 const Float_t eseeds[] = { 0.6, 1.0/1000, 1.0/1000, 1.0/1000., 0.3/1000., 0.3/1000. };
86 for ( Int_t i = 0; i < 6; i++ )
seedEnergy( eseeds[i], i );
104 StEEmcClusterVec_t t;
105 std::vector< StEEmcClusterVec_t > layers;
106 for ( Int_t i = 0; i < 4; i++ ) layers.push_back(t);
107 for ( Int_t i = 0; i < 12; i++ )
mTowerClusters.push_back(layers);
109 StEEmcSmdClusterVec_t s;
110 std::vector< StEEmcSmdClusterVec_t > planes;
113 for ( Int_t i = 0; i < 12; i++ )
mSmdClusters.push_back(planes);
115 StEEmcTowerVec_t tow;
116 std::vector< StEEmcTowerVec_t > lay;
117 for ( Int_t i = 0; i < 4; i++ ) lay.push_back(tow);
118 for ( Int_t i = 0; i < 12; i++ )
mSeedTowers.push_back(lay);
121 mEEsmd=EEmcSmdGeom::instance();
122 mEEmap=EEmcSmdMap::instance();
134 return StMaker::Init();
152 if ( !
verifyStEvent() ) Warning(
"Make",
"StEvent not properly copied");
162 for ( Int_t sector=0; sector<12; sector++ ) {
163 for ( Int_t layer=0; layer<4; layer++ )
165 for ( Int_t plane=0; plane<2; plane++ )
187 for ( Int_t layer=0;layer<4;layer++)
192 Float_t weights[720];
for ( Int_t i=0;i<720;i++ ) weights[i]=0.;
195 StEEmcClusterVec_t myClusters;
199 StEEmcTowerVec_t towers =
mEEanalysis -> towers( layer );
204 std::sort(towers.begin(),towers.end());
206 std::reverse(towers.begin(),towers.end());
211 StEEmcTowerVec_t::iterator last = towers.begin();
212 while ( last != towers.end() ) {
214 if ( (*last).energy() <
mSeedEnergy[layer] )
break;
221 std::cout <<
"-- Seed tower ----------------------" << std::endl;
227 StEEmcTowerVec_t::iterator iter = towers.begin();
228 while ( iter != towers.end() ) {
231 if ( iter==last )
break;
240 if ( weights[ (*iter).index() ] > 0. ) {
247 for ( Int_t in=0; in < (*iter).numberOfNeighbors(); in++ ) {
249 weights[ t.
index() ] += (*iter).energy();
260 while ( iter != towers.end() ) {
263 if ( iter==last )
break;
268 if ( weights[ (*iter).index() ] > 0. ) {
276 std::cout <<
"--- Clustering ----------------" << std::endl;
281 cluster.
add(seed,1.0);
283 sec=(UInt_t)seed.
sector();
285 eta=(UInt_t)seed.
etabin();
287 momentum += ( seed.
energy() * d );
295 Float_t weight = seed.
energy() / weights[ t.
index() ];
296 momentum += ( t.
energy() * d * weight );
297 cluster.
add(t, weight);
299 std::cout <<
"adding " << t.
name() <<
" E=" << t.
energy() <<
" W=" << weight << std::endl;
332 for ( Int_t sector=0; sector<12; sector++ )
334 for ( Int_t plane=0; plane<2; plane++ ) {
337 Float_t floor[288];
for ( Int_t i=0; i<288; i++ ) floor[i]=0.;
341 StEEmcStripVec_t seeds;
343 std::sort(strips.begin(),strips.end());
345 std::reverse(strips.begin(),strips.end());
348 std::vector<Bool_t> seed_flags( strips.size(), false );
354 StEEmcStripVec_t::iterator istrip=strips.begin();
355 while ( istrip!=strips.end() ) {
357 Int_t index=(*istrip).index();
358 Float_t eseed=(*istrip).energy();
361 if ( index <= 3 || index >= 283 ) {
369 if ( (*istrip).fail() ) {
385 seeds.push_back( (*istrip) );
396 for ( Int_t i=0; i < 288; i++ ) {
398 Int_t dx=TMath::Abs(index-i);
401 if ( eseed > floor[i] ) floor[i]=eseed;
404 if ( 0.20 * eseed > floor[i] ) floor[i] = 0.2 * eseed;
407 if ( 0.10 * eseed > floor[i] ) floor[i] = 0.1 * eseed;
410 if ( 0.20*eseed > floor[i] ) floor[i] = 0.05 * eseed;
413 for ( Int_t i=0; i < 288; i++ ) {
416 Int_t dx=TMath::Abs(index-i);
420 if ( 0.05 * eseed > floor[i] ) floor[i] = 0.05 * eseed;
433 Bool_t owned[288];
for (Int_t i=0;i<288;i++) owned[i]=
false;
434 Bool_t xseed[288];
for (Int_t i=0;i<288;i++) xseed[i]=
false;
436 StEEmcStripVec_t::iterator iseed=seeds.begin();
437 while ( iseed != seeds.end() ) {
440 Int_t index=(*iseed).index();
441 if ( owned[index] || (
mSuppress&&xseed[index]) ) {
452 cluster.add( (*iseed) );
454 Int_t ind_max = TMath::Min(287,index+max_extent);
455 Int_t ind_min = TMath::Max(0, index-max_extent);
459 for ( Int_t i=index+1; i<=ind_max; i++ ) {
467 if ( strip.
energy()<=0. )
break;
471 owned[ strip.
index() ] =
true;
472 xseed[ strip.
index() ] =
true;
476 for ( Int_t i=index-1; i>=ind_min; i-- ) {
484 if (strip.
energy()<=0.)
break;
488 owned[ strip.
index() ] =
true;
489 xseed[ strip.
index() ] =
true;
502 Int_t ns=cluster.numberOfStrips();
503 Int_t left=999,right=-999;
504 for ( Int_t is=0;is<ns;is++ )
518 if ( left-ii>=0 ) xseed[left-ii] =
true;
519 if ( right+ii<288 ) xseed[right+ii]=
true;
543 Warning(
"fillStEvent",
"called, but no StEvent to be found");
547 std::cout <<
"Adding tower clusters to StEvent at " << stevent << std::endl;
552 StEmcDetector *detector=stevent->emcCollection()->detector(kEndcapEmcTowerId);
555 Warning(
"fillStEvent",
"detector == NULL, MAJOR StEvent problem, continuing");
581 detector->setCluster( collect );
585 collect->setDetector( kEndcapEmcTowerId );
586 collect->setClusterFinderId( 123 );
587 collect->setClusterFinderParamVersion( 123 );
590 for ( Int_t isector=0; isector<12; isector++ )
594 for ( UInt_t iclust=0; iclust<
mTowerClusters[isector][0].size(); iclust++ )
603 emccluster->setEta( cl.
momentum().Eta() );
604 emccluster->setPhi( cl.
momentum().Phi() );
605 emccluster->setSigmaEta(-1.);
606 emccluster->setSigmaPhi(-1.);
607 emccluster->setEnergy( cl.
energy() );
608 emccluster->SetUniqueID( cl.key() );
614 emccluster->addHit( hit );
618 collect->addCluster( emccluster );
622 mEtoEE[ emccluster ] = cl;
623 cl.
stemc( emccluster );
634 detector->setCluster( NULL );
647 detector=stevent->emcCollection()->detector(kEndcapEmcPreShowerId);
650 Warning(
"fillStEvent",
"detector == NULL for pre/post, no clusters for you");
662 detector->setCluster( pqr );
665 pqr -> setDetector( kEndcapEmcPreShowerId );
666 pqr -> setClusterFinderId( 123 );
667 pqr -> setClusterFinderParamVersion( 321 );
670 for ( Int_t isector=0; isector<12; isector++ )
673 for ( Int_t ilayer=1; ilayer<4; ilayer++ )
676 for ( UInt_t iclust=0; iclust<
mTowerClusters[isector][ilayer].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 );
701 pqr->addCluster( emccluster );
703 mEtoEE[ emccluster ] = cl;
704 cl.
stemc( emccluster );
712 detector->setCluster( NULL );
720 StDetectorId ids[]={ kEndcapSmdUStripId, kEndcapSmdVStripId };
723 for ( Int_t iplane=0; iplane<2; iplane++ )
726 detector=stevent->emcCollection()->detector(ids[iplane]);
729 Warning(
"fillStEvent",
"detector == NULL for smd plane, no clusters for you");
739 detector->setCluster( smdc );
742 smdc->setDetector( ids[iplane] );
743 smdc->setClusterFinderId( 123 );
744 smdc->setClusterFinderParamVersion( 321 );
747 for ( Int_t isector=0; isector<12; isector++ )
750 for ( UInt_t iclust=0; iclust<
mSmdClusters[isector][iplane].size(); iclust++ )
757 emccluster->setEta( cl.mean() );
758 emccluster->setPhi( (Float_t)iplane );
759 emccluster->setSigmaEta(-1.);
760 emccluster->setSigmaPhi(-1.);
761 emccluster->setEnergy( cl.energy() );
762 emccluster->SetUniqueID( cl.
key() );
763 for ( Int_t i=0; i< cl.numberOfStrips(); i++ )
767 emccluster->addHit( hit );
769 smdc->addCluster( emccluster );
772 cl.
stemc( emccluster );
783 detector -> setCluster( NULL );
802 Warning(
"verifyStEvent",
"No StEvent found.");
809 const StEmcDetector *detector=stevent->emcCollection()->detector(kEndcapEmcTowerId);
812 Warning(
"verifyStEvent",
"detector == NULL for towers");
827 Float_t emc_sum_towers = 0.;
828 Float_t eemc_sum_towers = 0.;
830 const StSPtrVecEmcCluster &emcClusters=cc->clusters();
831 for ( UInt_t i=0; i<emcClusters.size(); i++ )
835 emc_sum_towers += cl->energy();
838 for ( Int_t sec=0; sec<12; sec++ )
845 std::cout <<
"StEEmcClusterMaker tower checksum: ";
846 if ( emc_sum_towers == eemc_sum_towers ) {
847 std::cout <<
"passed";
850 std::cout <<
"FAILED"; go=
false;
852 std::cout << std::endl;
857 std::cout <<
"StEEmcClusterMaker tower checksum: NULL collection, nclust=" <<
mNumberOfClusters[0] << std::endl;
866 Float_t emc_sum_smdu = 0.;
867 Float_t eemc_sum_smdu = 0.;
869 detector=stevent->emcCollection()->detector(kEndcapSmdUStripId);
872 Warning(
"verifyStEvent",
"detector == NULL for smdu");
876 cc=detector->cluster();
880 const StSPtrVecEmcCluster &smduClusters=cc->clusters();
882 for ( UInt_t i=0; i<smduClusters.size(); i++ )
886 emc_sum_smdu += cl->energy();
890 for ( Int_t sec=0; sec<12; sec++ )
896 eemc_sum_smdu +=
smdcluster(sec,0,i).energy();
902 std::cout <<
"StEEmcClusterMaker smdu checksum: ";
903 if ( emc_sum_smdu == eemc_sum_smdu ) {
904 std::cout <<
"passed";
907 std::cout <<
"FAILED"; go=
false;
909 std::cout << std::endl;
914 std::cout <<
"StEEmcClusterMaker smdu checksum: NULL collection, nclust=" <<
mNumberOfClusters[4] << std::endl;
921 Float_t emc_sum_smdv = 0.;
922 Float_t eemc_sum_smdv = 0.;
924 detector=stevent->emcCollection()->detector(kEndcapSmdVStripId);
927 Warning(
"verifyStEvent",
"detector == NULL for smdv");
931 cc=detector->cluster();
936 const StSPtrVecEmcCluster &smdvClusters=cc->clusters();
938 for ( UInt_t i=0; i<smdvClusters.size(); i++ )
942 emc_sum_smdv += cl->energy();
946 for ( Int_t sec=0; sec<12; sec++ )
952 eemc_sum_smdv +=
smdcluster(sec,1,i).energy();
958 std::cout <<
"StEEmcClusterMaker smdv checksum: ";
959 if ( emc_sum_smdv == eemc_sum_smdv ) {
960 std::cout <<
"passed";
963 std::cout <<
"FAILED"; go=
false;
965 std::cout << std::endl;
970 std::cout <<
"StEEmcClusterMaker smdv checksum: NULL collection, nclust=" <<
mNumberOfClusters[5] << std::endl;
985 std::cout <<
"StEEmcClusterMaker::print()" << std::endl;
986 const Char_t *names[] = {
"tower",
"pre1",
"pre2",
"post",
"smdu",
"smdv" };
987 for ( Int_t i=0;i<6;i++ )
990 std::cout <<
"Number of " << names[i]
996 std::cout <<
"printout of tower clusters follows:" << std::endl;
997 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.
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
Int_t mMinStrips
Minimum number of smd strips to form seed.
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
virtual void Clear(Option_t *option="")
User defined functions.
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.
Bool_t mLoose
Loose cuts option.
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.
Bool_t mSkip
Skip strips if failbit set.
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
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.