92 #include "StPointCollection.h"
93 #include "StPi0Candidate.h"
97 #include "StEmcUtil/geometry/StEmcGeom.h"
98 #include "StEmcUtil/projection/StEmcPosition.h"
100 #include "StEventTypes.h"
101 #include "StarCallf77.h"
105 #define assndx F77_NAME(assndx,ASSNDX)
108 void type_of_call assndx ( Int_t &, Float_t *, Int_t &, Int_t &,
109 Int_t &, Int_t *, Float_t &,Int_t*,Int_t &);
114 const TString detname[] =
115 {
"Bemc",
"Bsmde",
"Bsmdp"
118 StMatchVecClus matchlist_bemc_clus[Epc::nModule][Epc::nPhiBin];
119 StMatchVecClus matchlist_bprs_clus[Epc::nModule][Epc::nPhiBin];
120 StMatchVecClus matchlist_bsmde_clus[Epc::nModule][Epc::nPhiBin];
121 StMatchVecClus matchlist_bsmdp_clus[Epc::nModule][Epc::nPhiBin];
123 FloatVector HitTrackEta;
124 FloatVector HitTrackPhi;
125 FloatVector HitTrackMom;
128 StPointCollection::StPointCollection():
TDataSet(
"Default")
130 SetTitle(
"EmcPoints");
138 StPointCollection::StPointCollection(
const Char_t *Name):
TDataSet(Name)
140 SetTitle(
"EmcPoints");
148 StPointCollection::~StPointCollection()
163 Int_t StPointCollection::makeEmcPoints(
StEvent* event)
165 LOG_DEBUG <<
"Finding EMC Points ..." << endm;
173 StSPtrVecEmcPoint& points = emc->barrelPoints();
179 for(Int_t i = 0;i<4;i++)
181 StDetectorId EmcId =
static_cast<StDetectorId
>(i+kBarrelEmcTowerId);
185 cluster[i] = EmcDet->cluster();
190 findMatchedClusters(cluster[0],cluster[1],cluster[2],cluster[3]);
193 LOG_DEBUG <<
"Making points for non-matched clusters ..." <<endm;
194 ClusterSort(cluster[0],cluster[1],cluster[2],cluster[3]);
197 for(Int_t im=0;im<Epc::nModule;im++)
199 for(Int_t is=0;is<Epc::nPhiBin;is++)
201 if(matchlist_bemc_clus[im][is].size()>0)
203 matchClusters(matchlist_bemc_clus[im][is],
204 matchlist_bprs_clus[im][is],
205 matchlist_bsmde_clus[im][is],
206 matchlist_bsmdp_clus[im][is]);
212 matchToTracks(event);
221 LOG_DEBUG <<
"Making points for already matched clusters ..." <<endm;
224 Int_t Ncluster0=Bemccluster->numberOfClusters();
227 const StSPtrVecEmcCluster& emcclusters= Bemccluster->clusters();
228 for(UInt_t i=0;i<emcclusters.size();i++)
231 UInt_t matchId = btow->GetUniqueID();
239 const StSPtrVecEmcCluster& clusters= Bprscluster->clusters();
240 for(UInt_t i=0;i<clusters.size();i++)
241 if( ((
StEmcCluster*)clusters[i])->GetUniqueID() == matchId)
249 const StSPtrVecEmcCluster& clusters= Bsmdecluster->clusters();
250 for(UInt_t i=0;i<clusters.size();i++)
251 if( ((
StEmcCluster*)clusters[i])->GetUniqueID() == matchId)
259 const StSPtrVecEmcCluster& clusters= Bsmdpcluster->clusters();
260 for(UInt_t i=0;i<clusters.size();i++)
261 if( ((
StEmcCluster*)clusters[i])->GetUniqueID() == matchId)
268 makePoint(btow,bprs,bsmde,bsmdp);
280 LOG_DEBUG <<
"Making point"<< endm;
284 Category = Category | 1;
286 Category = Category | 2;
288 Category = Category | 4;
290 Category = Category | 8;
292 Float_t en[4] = {0,0,0,0};
293 Float_t si[4] = {0,0,0,0};
295 Float_t eta = btow->eta();
296 Float_t phi = btow->phi();
301 Float_t energy = btow->energy()*fraction;
303 energy = fabs(fraction);
304 Float_t sigEta = btow->sigmaEta();
305 Float_t sigPhi = btow->sigmaPhi();
306 en[0] = btow->energy();
307 si[0] = sqrt(eta*eta+phi*phi);
311 en[1] = bprs->energy();
312 si[1] = sqrt(bprs->sigmaEta()*bprs->sigmaEta()+bprs->sigmaPhi()*bprs->sigmaPhi());
318 sigEta = bsmde->sigmaEta();
319 en[2] = bsmde->energy();
320 si[2] = sqrt(bsmde->sigmaEta()*bsmde->sigmaEta()+bsmde->sigmaPhi()*bsmde->sigmaPhi());
326 sigPhi = bsmdp->sigmaPhi();
327 en[3] = bsmdp->energy();
328 si[3] = sqrt(bsmdp->sigmaEta()*bsmdp->sigmaEta()+bsmdp->sigmaPhi()*bsmdp->sigmaPhi());
334 xp=(StEpcCut::RAD_SMD_E())*cos(phi);
335 yp=(StEpcCut::RAD_SMD_E())*sin(phi);
336 zp=(StEpcCut::RAD_SMD_E())*sinh(eta);
337 StThreeVectorF PointPosition(xp*centimeter, yp*centimeter, zp*centimeter);
340 xp=(StEpcCut::RAD_SMD_E())*(cos(phi+sigPhi)-cos(phi-sigPhi))/2;
341 yp=(StEpcCut::RAD_SMD_E())*(sin(phi+sigPhi)-sin(phi-sigPhi))/2;
342 zp=(StEpcCut::RAD_SMD_E())*(sinh(eta+sigEta)-sinh(eta-sigEta))/2;
343 StThreeVectorF ErrorPosition(xp*centimeter, yp*centimeter, zp*centimeter);
348 Float_t ChiSquare = 0.0;
352 point->setQuality(Category);
353 point->setPosition(PointPosition);
354 point->setPositionError(ErrorPosition);
355 point->setSize(size);
356 point->setChiSquare(ChiSquare);
357 point->setEnergy(energy);
358 point->setDeltaEta(9999);
359 point->setDeltaPhi(9999);
360 for(Int_t i=0;i<4;i++)
362 StDetectorId
id=
static_cast<StDetectorId
>(i+kBarrelEmcTowerId);
363 point->setEnergyInDetector(
id,en[i]);
364 point->setSizeAtDetector(
id,si[i]);
366 point->addCluster(
id,btow);
368 point->addCluster(
id,NULL);
370 point->addCluster(
id,bprs);
372 point->addCluster(
id,NULL);
374 point->addCluster(
id,bsmde);
376 point->addCluster(
id,NULL);
378 point->addCluster(
id,bsmdp);
380 point->addCluster(
id,NULL);
383 mPointsReal.Add(point);
390 Int_t StPointCollection::matchClusters(
const StMatchVecClus mvec,
391 const StMatchVecClus prsvec,
392 const StMatchVecClus evec,
393 const StMatchVecClus pvec)
396 Int_t na=evec.size();
397 Int_t ma=pvec.size();
403 Int_t idw =Epc::nMaxNoOfClinBin;
404 Int_t ida =Epc::nMaxNoOfClinBin;
405 Float_t ep[Epc::nMaxNoOfClinBin][Epc::nMaxNoOfClinBin];
406 Int_t iw[Epc::nMaxNoOfClinBin][Epc::nMaxNoOfClinBin];
407 Int_t k[Epc::nMaxNoOfClinBin];
410 for (Int_t iF=0;iF<Epc::nMaxNoOfClinBin;iF++)
413 for (Int_t iL=0;iL<Epc::nMaxNoOfClinBin;iL++)
419 if(evec.size()==0 && pvec.size()==0)
425 if(evec.size()>0 && pvec.size()==0)
431 if(evec.size()==0 && pvec.size()>0)
437 if(evec.size()>0 && pvec.size()>0)
447 for (UInt_t ims=0;ims<mvec.size();ims++)
451 Float_t emen=cl0->energy();
457 for(Int_t ie=0;ie<na;ie++)
460 for(Int_t ip=0;ip<ma;ip++)
484 Float_t diff=TMath::Abs((cl1->energy())-(cl2->energy()));
485 Float_t summ= (cl1->energy())+(cl2->energy());
486 ep[ip][ie]=diff/summ;
491 assndx(mode,ep[0],na,ma,ida,k,smin,iw[0],idw);
503 Float_t avg_en = cl1->energy();
515 Float_t avg_en = cl1->energy();
527 Float_t avg_en = cl1->energy();
541 Float_t avg_en = 0.5*(cl1->energy()+cl2->energy());
555 Float_t fraction = 1;
577 fraction = EmcTot/totAvg;
587 fraction = EmcTot/totAvg;
595 fraction = -fabs(EmcTot*0.5*(bsmde->energy()+bsmdp->energy())/totAvg);
598 Float_t delta = 999999;
599 for (UInt_t ims=0;ims<mvec.size();ims++)
602 Float_t de = sqrt((eta-cl0->eta())*(eta-cl0->eta()) +
603 (phi-cl0->phi())*(phi-cl0->phi()));
616 Float_t delta = 999999;
617 for (UInt_t ims=0;ims<prsvec.size();ims++)
620 Float_t de = sqrt((eta-cl0->eta())*(eta-cl0->eta()) +
621 (phi-cl0->phi())*(phi-cl0->phi()));
629 makePoint(btow,bprs,bsmde,bsmdp,fraction);
645 const Int_t eta_shift_fix=1;
646 LOG_DEBUG <<
" I am inside PointCalc***"<<endm;
647 for(Int_t i1=0;i1<Epc::nModule;i1++)
649 for(Int_t i2=0;i2<Epc::nPhiBin;i2++)
651 matchlist_bemc_clus[i1][i2].clear();
652 matchlist_bprs_clus[i1][i2].clear();
653 matchlist_bsmde_clus[i1][i2].clear();
654 matchlist_bsmdp_clus[i1][i2].clear();
658 StEmcGeom* GeomIn = StEmcGeom::getEmcGeom(
"bemc");
663 Int_t Ncluster0=Bemccluster->numberOfClusters();
666 const StSPtrVecEmcCluster& emcclusters= Bemccluster->clusters();
667 for(UInt_t i=0;i<emcclusters.size();i++)
670 LOG_DEBUG <<
"BEMC cluster UniqueId = "<<cl1->GetUniqueID()<<endm;
671 if(cl1->GetUniqueID()==0)
673 Float_t eta_emc=cl1->eta();
674 Float_t phi_emc=cl1->phi();
678 Int_t & imd =emc_module;
679 Int_t testb=GeomIn->
getBin(phi_emc,eta_emc,imd,ebin,pbin);
684 Int_t emc_phi_bin=Int_t(TMath::Abs(eta_emc*10));
687 if(!eta_shift_fix && emc_phi_bin>0)
689 if((TMath::Abs(eta_emc*10)-Float_t(emc_phi_bin))<0.2)
699 matchlist_bemc_clus[emc_module-1][emc_phi_bin].push_back(cl1);
709 Int_t Ncluster1=Bprscluster->numberOfClusters();
712 const StSPtrVecEmcCluster& emcclusters= Bprscluster->clusters();
713 for(UInt_t i=0;i<emcclusters.size();i++)
716 if(cl2->GetUniqueID()==0)
718 Float_t eta_emc=cl2->eta();
719 Float_t phi_emc=cl2->phi();
724 Int_t & imd =emc_module;
725 Int_t testb=GeomIn->
getBin(phi_emc,eta_emc,imd,ebin,pbin);
730 emc_phi_bin=Int_t(TMath::Abs(eta_emc*10));
732 if(!eta_shift_fix && emc_phi_bin>0)
734 if((TMath::Abs(eta_emc*10)-Float_t(emc_phi_bin))<0.2)
744 matchlist_bprs_clus[emc_module-1][emc_phi_bin].push_back(cl2);
754 Int_t Ncluster2=Bsmdecluster->numberOfClusters();
757 const StSPtrVecEmcCluster& emcclusters= Bsmdecluster->clusters();
758 for(UInt_t i=0;i<emcclusters.size();i++)
761 if(cl3->GetUniqueID()==0)
763 Float_t eta_emc=cl3->eta();
764 Float_t phi_emc=cl3->phi();
769 Int_t & imd =emc_module;
770 Int_t testb=GeomIn->
getBin(phi_emc,eta_emc,imd,ebin,pbin);
775 emc_phi_bin=Int_t(TMath::Abs(eta_emc*10));
777 if(!eta_shift_fix && emc_phi_bin>0)
779 if((TMath::Abs(eta_emc*10)-Float_t(emc_phi_bin))<.2)
789 matchlist_bsmde_clus[emc_module-1][emc_phi_bin].push_back(cl3);
799 Int_t Ncluster3=Bsmdpcluster->numberOfClusters();
802 const StSPtrVecEmcCluster& emcclusters= Bsmdpcluster->clusters();
803 for(UInt_t i=0;i<emcclusters.size();i++)
806 if(cl4->GetUniqueID()==0)
808 Float_t eta_emc=cl4->eta();
809 Float_t phi_emc=cl4->phi();
813 Int_t & imd =emc_module;
814 Int_t testb=GeomIn->
getBin(phi_emc,eta_emc,imd,ebin,pbin);
819 Int_t emc_phi_bin=Int_t(TMath::Abs(eta_emc*10));
821 if(!eta_shift_fix && emc_phi_bin>0)
823 if((TMath::Abs(eta_emc*10)-Float_t(emc_phi_bin))<=0.01)
833 matchlist_bsmdp_clus[emc_module-1][emc_phi_bin].push_back(cl4);
841 Int_t StPointCollection::matchToTracks(
StEvent* event)
849 field = evtSummary->magneticField()/10;
851 Int_t nR = NPointsReal();
852 StEmcGeom* geom = StEmcGeom::instance(
"bemc");
855 LOG_DEBUG <<
"Matching to tracks... NP = " << nR << endm;
856 StSPtrVecTrackNode& tracks=
event->trackNodes();
857 Int_t nTracks = tracks.size();
859 for(Int_t t=0;t<nTracks;t++)
864 if(track->geometry())
866 Bool_t tok = mPosition->
trackOnEmc(&position,&momentum,
867 track,(Double_t)field,
868 (Double_t)geom->Radius());
871 Float_t eta = position.pseudoRapidity();
872 Float_t phi = position.phi();
875 TIter next(PointsReal());
878 for(Int_t i=0; i<nR; i++)
884 Float_t etaP = pos.pseudoRapidity();
885 Float_t phiP = pos.phi();
886 Float_t D = sqrt(cl->deltaEta()*cl->deltaEta()+cl->deltaPhi()*cl->deltaPhi());
887 Float_t d = sqrt((eta-etaP)*(eta-etaP)+(phi-phiP)*(phi-phiP));
890 cl->setDeltaEta(eta-etaP);
891 cl->setDeltaPhi(phi-phiP);
895 Float_t etaE = err.pseudoRapidity();
896 Float_t phiE = err.phi();
898 Float_t dPhi = fabs(phi-phiP);
899 if (dPhi>TMath::Pi())
900 dPhi=2*TMath::Pi()-dPhi;
902 if(fabs(eta-etaP)<fabs(etaE) && dPhi<fabs(phiE))
904 Int_t Category = cl->quality();
905 Category = Category | 16;
906 cl->setQuality(Category);
Bool_t trackOnEmc(StThreeVectorD *position, StThreeVectorD *momentum, const StTrack *const track, Double_t magField, Double_t emcRadius=225.405) const
Track projection utility.
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const