26 #include "StEEmcIUPointMaker.h"
27 #include "StEEmcPool/StEEmcA2EMaker/StEEmcA2EMaker.h"
28 #include "StEEmcIUClusterMaker.h"
29 #include "StEEmcIUCluster.h"
30 #include "StEEmcIUSmdCluster.h"
31 #include "StEEmcUtil/EEmcGeom/EEmcGeomDefs.h"
32 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
33 #include "StEEmcUtil/StEEmcSmd/EEmcSmdGeom.h"
40 #include "StEEmcPool/StEEmcPointMaker/eeTowerFunction.h"
43 #include "StEvent/StEvent.h"
44 #include "StEvent/StEmcCollection.h"
45 #include "StEvent/StEmcPoint.h"
57 std::cout <<
"StEEmcIUPointMaker("<<name<<
")" << std::endl;
63 mEEsmd=EEmcSmdGeom::instance();
64 mEEmap=EEmcSmdMap::instance();
83 hZEratio=
new TH1F(
"smdezratio",
"energy Zratio between smd clusters",10,0.,1.);
84 pointet=
new TH1F(
"pointet",
"transverse energy of every point candidate",40,0,10);
85 pointgeo=
new TH2F(
"pointgeo",
"Reconstructed Point Geometry; phi / deg; Eta",360,-180.,180,20,1.,2.);
86 return StMaker::Init();
101 for ( Int_t sector=0; sector<12; sector++ )
109 std::sort( uclusters.begin(), uclusters.end(), inner );
110 std::sort( vclusters.begin(), vclusters.end(), inner );
123 for ( UInt_t i=0;i<
mPoints.size();i++ )
128 TVector3 pointpos=
mPoints[i].position();
129 pointpos=pointpos.Unit();
130 Float_t pet = (
mPoints[i].energy()*pointpos).Perp();
132 pointgeo->Fill(
mPoints[i].position().Phi()/3.1416*180,
mPoints[i].position().Eta());
138 StEEmcIUPointVec_t orgpoints=
mPoints;
173 StEEmcIUSmdClusterVec_t &u,
174 StEEmcIUSmdClusterVec_t &v )
177 StEEmcIUPointVec_t
points;
179 for ( UInt_t i=0; i<u.size(); i++ )
184 Float_t xu=uc.
mean();
187 for ( UInt_t j=0;j<v.size(); j++ )
192 Float_t xv=vc.
mean();
222 for ( Int_t layer=1;layer<=3;layer++ )
283 StEEmcIUSmdClusterVec_t uclusters,
284 StEEmcIUSmdClusterVec_t vclusters,
285 StEEmcIUPointVec_t &points )
290 StEEmcIUPointVec_t Tmypoints;
291 StEEmcIUPointVec_t mypoints;
293 std::sort( uclusters.begin(), uclusters.end(), inner );
294 std::sort( vclusters.begin(), vclusters.end(), inner );
297 StEEmcIUPointVec_t smdpoints =
buildSmdPoints( sector, uclusters, vclusters );
301 if ( smdpoints.size() < 1 )
return false;
304 std::sort( smdpoints.begin(), smdpoints.end(), chiSquare );
310 std::map< Int_t, std::vector<Int_t> > u2p, v2p;
311 for ( UInt_t i=0; i<smdpoints.size(); i++ )
313 u2p[ smdpoints[i].cluster(0).key() ].push_back( i );
314 v2p[ smdpoints[i].cluster(1).key() ].push_back( i );
321 StEEmcIUSmdClusterVec_t::iterator uiter=uclusters.begin();
322 StEEmcIUSmdClusterVec_t::iterator viter=vclusters.begin();
334 while ( uiter<uclusters.end() || viter<vclusters.end() )
340 if ( uiter<uclusters.end() ) ucl=(*uiter);
341 if ( viter<vclusters.end() ) vcl=(*viter);
345 else if ( vcl.
key()<0 )
347 else if ( (*uiter).mean() < (*viter).mean() )
356 std::vector<Int_t> matched=(iUV==0)?
364 if ( matched.size()==0 || matched.size() >1 )
366 if ( iUV==0 ) uiter++;
367 if ( iUV==1 ) viter++;
382 Tmypoints.push_back(p);
384 if ( iUV==0 ) {uiter++;iii++;}
385 if ( iUV==1 ) {viter++;jjj++;}
391 std::sort( Tmypoints.begin(), Tmypoints.end(), chiSquare );
393 if(Tmypoints.size()>=2)
396 for ( UInt_t i=0; i<Tmypoints.size(); i++ )
403 for ( UInt_t j=i+1; j<Tmypoints.size(); j++ )
425 float u1energy=uone.
energy()*vratio1;
426 float u2energy=uone.
energy()*vratio2;
432 Tmypoints[i].energy(p1energy);
434 Tmypoints[j].energy(p2energy);
435 Tmypoints[i].cluster(uone,0);
436 Tmypoints[j].cluster(utwo,0);
445 points.push_back(p1);
448 points.push_back(p2);
451 findPoints(sector, uclusters, vclusters, points );
471 float v1energy=vone.
energy()*uratio1;
472 float v2energy=vone.
energy()*uratio2;
478 Tmypoints[i].energy(p1energy);
480 Tmypoints[j].energy(p2energy);
481 Tmypoints[i].cluster(vone,1);
482 Tmypoints[j].cluster(vtwo,1);
491 points.push_back(p1);
494 points.push_back(p2);
497 findPoints(sector, uclusters, vclusters, points );
508 for ( UInt_t i=0; i<Tmypoints.size(); i++ )
511 mypoints.push_back(p);
522 for ( UInt_t i=0; i<Tmypoints.size(); i++ )
525 mypoints.push_back(pp);
530 for ( UInt_t i=0; i<Tmypoints.size(); i++ )
533 mypoints.push_back(p);
540 for ( UInt_t i=0; i<mypoints.size(); i++ )
542 Float_t eu=mypoints[i].cluster(0).energy();
543 Float_t ev=mypoints[i].cluster(1).energy();
544 Float_t x2=fabs((eu-ev)/(eu+ev));
565 findPoints(sector, uclusters, vclusters, points );
583 uiter=uclusters.begin();
584 viter=vclusters.begin();
585 while ( uiter!=uclusters.end() || viter!=vclusters.end() )
591 if ( uiter!=uclusters.end() ) ucl=(*uiter);
592 if ( viter!=vclusters.end() ) vcl=(*viter);
596 else if ( vcl.
key()<0 )
598 else if ( (*uiter).mean() < (*viter).mean() )
607 std::vector<Int_t> matched=(iUV==0)?
613 if ( matched.size()==0 || matched.size()==1 )
615 if ( iUV==0 ) uiter++;
616 if ( iUV==1 ) viter++;
625 mypoints.push_back(p);
628 if ( iUV==0 ) uiter++;
629 if ( iUV==1 ) viter++;
638 for ( UInt_t i=0; i<mypoints.size(); i++ )
641 Float_t eu=mypoints[i].cluster(0).energy();
642 Float_t ev=mypoints[i].cluster(1).energy();
643 Float_t x2=fabs((eu-ev)/(eu+ev));
652 for ( UInt_t i=0; i<mypoints.size(); i++ )
658 Float_t eu=mypoints[i].cluster(0).energy();
659 Float_t ev=mypoints[i].cluster(1).energy();
660 Float_t x22=(eu-ev)*(eu-ev);
661 if ( x22 < chisq2 ) {
682 points.push_back(p1);
684 findPoints(sector, uclusters, vclusters, points );
709 StEEmcIUSmdClusterVec_t::iterator iter=clusters.begin();
710 while ( iter != clusters.end() )
712 if ( (*iter).key() == k ) {
713 clusters.erase(iter);
732 Int_t nrow=(Int_t)
mPoints.size();
733 Int_t ncol=(Int_t)
mPoints.size();
734 if ( nrow < 1 )
return;
736 std::vector<Float_t> Ef(nrow,0.);
738 TMatrixF fractions(nrow,ncol);
748 for ( UInt_t i=0; i<
mPoints.size(); i++ )
754 if ( fi<=0. )
continue;
757 Ef[i] += fi * tower.
energy();
759 for ( UInt_t j=0; j<
mPoints.size(); j++ )
765 if (fi*fj<=0.)
continue;
767 fractions[i][j] += fi*fj;
779 TMatrixF invert= fractions;
784 TMatrixF test= fractions * invert;
791 std::vector<Float_t> epoints(nrow,0.);
793 for ( Int_t i=0; i<nrow; i++ )
795 for ( Int_t j=0; j<ncol; j++ )
797 epoints[i] += invert[i][j] * Ef[j];
825 Float_t xeta=(Float_t)t.
etabin();
826 Float_t xphi=(Float_t)t.
phibin();
827 Double_t X[]={xphi,xeta};
830 Float_t xeta0=(Float_t)p.
tower(0).etabin();
831 Float_t xphi0=(Float_t)p.
tower(0).phibin();
842 Float_t xetap=xeta0+deta;
843 Float_t xphip=xphi0+dphi;
844 Double_t P[]={xphip,xetap,1.0};
846 return eeTowerFunction( X, P );
858 while ( count++ < limit )
864 for (Int_t i=0;i<720;i++) sumw[i]=0.;
868 for ( UInt_t i=0;i<
mPoints.size();i++ )
890 for ( UInt_t i=0;i<
mPoints.size();i++ )
898 if ( !tower.
fail() && !tower.
stat() && sumw[tower.
index()]>0. )
901 epoint += tower.
energy() * frac;
908 if ( neighbor.
stat() || neighbor.
fail() || sumw[neighbor.
index()]<=0. )
continue;
910 epoint += frac * neighbor.
energy();
924 std::vector<Bool_t> seen(720,
false);
925 for ( UInt_t i=0;i<
mPoints.size();i++ )
930 seen[ tow.
index() ] =
true;
936 seen[ nei.
index() ] =
true;
959 Warning(
"fillStEvent",
"called, but no StEvent to be found");
965 for ( UInt_t i=0; i<
mPoints.size(); i++ )
969 stevent->emcCollection()->addEndcapPoint( point );
984 Float_t emc_sum_points = 0.;
985 Float_t eemc_sum_points = 0.;
989 Warning(
"verifyStEvent",
"called, but no StEvent to be found");
993 StSPtrVecEmcPoint& emcpts = stevent->emcCollection()->endcapPoints();
994 for ( UInt_t i=0;i<emcpts.size();i++ )
999 emc_sum_points += p->energy();
1003 for ( UInt_t i=0;i<
mPoints.size();i++ )
1007 eemc_sum_points += p.
energy();
1011 std::cout <<
"StEEmcIUPointMaker point checksum: ";
1012 if ( emc_sum_points == eemc_sum_points )
1014 std::cout <<
"passed";
1017 std::cout <<
"FAILED";
1018 std::cout << std::endl;
1030 for ( Int_t i=0;i<720;i++ ) npoints[i]=0;
1032 for ( UInt_t i=0;i<
mPoints.size();i++ )
1033 npoints[
mPoints[i].tower(0).index() ]++;
1036 for ( UInt_t i=0;i<
mPoints.size();i++ )
1042 Int_t nrel=npoints[ tower.
index() ] - 1;
1045 for ( Int_t j=0;j<nn;j++ )
1048 nrel+=npoints[ t2.
index() ];
1051 mPoints[i].numberOfRelatives(nrel);
1067 Float_t sumw[720];
for ( Int_t i=0;i<720;i++ )sumw[i]=0.;
1068 Float_t sumw1[720];
for ( Int_t i=0;i<720;i++ )sumw1[i]=0.;
1070 for ( UInt_t ipoint=0;ipoint<
mPoints.size();ipoint++ )
1081 Int_t index=t.
index();
1083 sumw[index]+=point.
energy();
1092 for ( UInt_t ipoint=0;ipoint<
mPoints.size();ipoint++ )
1101 Float_t epoint = 0.;
1106 Int_t index = tower.
index();
1107 epoint += tower.
energy() * point.
energy() / sumw[index];
1110 epre1 += pre1.
energy() * point.
energy() / sumw1[index];
1111 epre2 += pre2.
energy() * point.
energy() / sumw1[index];
1132 mPoints[ipoint].energy(epoint);
1133 mPoints[ipoint].energy(epre1,1);
1134 mPoints[ipoint].energy(epre2,2);
1135 mPoints[ipoint].energy(epost,3);
Bool_t findPoints(Int_t sector, StEEmcIUSmdClusterVec_t u, StEEmcIUSmdClusterVec_t v, StEEmcIUPointVec_t &p)
find points in the endcap
Int_t numberOfNeighbors() const
get the number of neighboring towers
EEmc ADC –> energy maker.
Int_t key()
Return a unique key assigned by the cluster maker.
void stat(unsigned s)
Set a status bit for this element.
Bool_t isNeighbor(const StEEmcTower &t) const
void shareEnergySimple()
Divide energy of eemc towers between identified smd points (doesn't work as well as smd algo) ...
StEEmcTower & hittower(Int_t hit, Int_t layer)
void Clear(Option_t *opts="")
Clear old points.
StEEmcIUPointVec_t mSmdPoints
SMD only points.
Float_t mEseen
Energy seen by the algorithm.
void neighbor(StEEmcTower *n)
add a tower to list of neighbors
void energy(Float_t e, Int_t layer=0)
Set the energy of this point.
StEEmcIUSmdClusterVec_t smdclusters(Int_t sec, Int_t plane)
Return a vector of smd clusters.
Bool_t mFillStEvent
Option to fill StEvent.
void position(TVector3 p)
Set the position of this point at the SMD plane.
StEEmcIUPointVec_t points()
Return a unique key assigned by the cluster maker.
EEmcSmdMap * mEEmap
Tower to smd map.
std::map< StEmcPoint *, StEEmcIUPoint > mEtoEE
Map connecting StEEmcIUPoint to StEmcPoint.
StEEmcIUPointVec_t buildSmdPoints(Int_t sector, StEEmcIUSmdClusterVec_t &u, StEEmcIUSmdClusterVec_t &v)
build smd points and associations between smd points and clusters
Class for building points from smd clusters.
void fillStEvent()
Fills the StEmcPoint collection.
A cluster maker for the EEMC.
void removeCluster(StEEmcIUSmdClusterVec_t &clusters, Int_t key)
Remove a cluster from the list of clusters.
Int_t numberOfHitTowers(Int_t layer) const
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.
void verifyStEvent()
Checks that StEvent is properly saved.
Int_t Make()
Build points for this event.
void cluster(StEEmcIUSmdCluster c, Int_t plane)
Add an smd cluster to this point.
Int_t mEnergyMode
Option for dividing energy.
Base class for representing tower, preshower and postshower elements.
void shareEnergySmd()
Divide energy of eemc towers between identified smd points in proportion to the smd energy...
StEEmcA2EMaker * mEEanalysis
ADC2E.
StEEmcIUPointMaker(const Char_t *name)
Float_t mean()
Return the mean strip number of this cluster.
StEEmcIUPoint point(Int_t ipoint)
Return a specified point.
Int_t mLimit
How many iterations for the tower energy sharing mode.
A base class for representing clusters of EEMC smd strips.
Base class for representing EEMC points.
EEmcSmdGeom * mEEsmd
Smd geometry.
Int_t phibin() const
Returns the phibin of this tower.
TVector3 getIntersection(Int_t iSec, Int_t iUStrip, Int_t iVStrip, const TVector3 &vertex) const
EEmcGeomSimple * mEEtow
Tower geometry.
void tower(StEEmcTower t, Float_t w=1.)
Add a tower with specified weight to the point.
StEEmcTower & tower(Int_t index, Int_t layer=0)
StEEmcIUPointVec_t mPoints
All fully reconstructed points.
Float_t fracp2t(StEEmcIUPoint &p, StEEmcTower &t)
bool getTower(const TVector3 &r, int &sec, int &sub, int &etabin, Float_t &dphi, Float_t &deta) const
void energy(Float_t e)
Set the energy (adc-ped+0.5)/gain for this element.
void shareEnergy()
Divide energy of eemc towers between identified smd points using fit (doesn't work) ...
StEEmcIUClusterMaker * mEEclusters
Clusters.
Float_t energy()
Return the energy of this cluster.
void countRelatives()
Determine the number of points which share tower energy with another point.