FairRoot/PandaRoot
PndPidEmcInfo.cxx
Go to the documentation of this file.
1 #include "PndPidCorrelator.h"
3 #include <cmath>
4 
5 //_________________________________________________________________
6 Bool_t PndPidCorrelator::GetEmcInfo(FairTrackParH* helix,
7  PndPidCandidate* pidCand) {
8  if (!helix) {
9  std::cerr
10  << "<Error> PndPidCorrelator EMCINFO: FairTrackParH NULL pointer parameter."
11  << std::endl;
12  return kFALSE;
13  }
14  if (!pidCand) {
15  std::cerr
16  << "<Error> PndPidCorrelator EMCINFO: pidCand NULL pointer parameter."
17  << std::endl;
18  return kFALSE;
19  }
20  //---
21  //Float_t trackTheta = helix->GetMomentum().Theta() * TMath::RadToDeg(); //[R.K. 01/2017] unused variable
22 
23  Int_t emcEntries = fEmcCluster->GetEntriesFast();
24  Int_t emcIndex = -1, emcModuleCorr = -1, emcNCrystals = -1, emcNBumps = -1;
25  Float_t emcEloss = 0., emcElossCorr = 0., emcGLength = -1000;
26  Float_t emcQuality = 1000000;
27  //Float_t chi2 = 0; //[R.K. 01/2017] unused variable
28  TVector3 vertex(0., 0., 0.);
29  TVector3 emcPos(0., 0., 0.); // TVector3 momentum(0., 0., 0.);
30  Double_t emcTimeStamp(-1.);
31 
32  // Cluster zenike moments
33  Double_t Z20 = 0.0, Z53 = 0.0, secLatM = 0.00, E1 = 0., E9 = 0., E25 = 0.;
34 
35  for (Int_t ee = 0; ee < emcEntries; ee++) {
36  PndEmcCluster *emcHit = (PndEmcCluster*) fEmcCluster->At(ee);
37 
38  if (fIdeal) {
39  std::vector<Int_t> mclist = emcHit->GetMcList();
40  if (mclist.size() == 0)
41  continue;
42  if (mclist[0] != pidCand->GetMcIndex())
43  continue;
44  }
45 
46  if (emcHit->energy() < fCorrPar->GetEmc12Thr())
47  continue;
48  Int_t emcModule = emcHit->GetModule();
49 
50  if (emcModule > 4)
51  continue; // skip FSC
52  if ((emcModule < 3) && (helix->GetZ() > 150.))
53  continue; // not consider tracks after emc barrel for BARREL
54  if ((emcModule == 3) && (helix->GetZ() < 165.))
55  continue; // consider tracks only from last gem plane for FWD
56  if ((emcModule == 4) && (helix->GetZ() > -30.))
57  continue; // consider tracks only ending at the back of STT for BKW
58 
59  emcTimeStamp = emcHit->GetTimeStamp(); //Do we need to correct the time stamp measured by the emc by the flight path?
60 
61  emcPos = emcHit->where();
62  if (fGeanePro) { // Overwrites vertex if Geane is used
63  fGeanePropagator->SetPoint(emcPos);
64  fGeanePropagator->PropagateToPCA(1, 1);
65  vertex.SetXYZ(-10000, -10000, -10000); // reset vertex
66  FairTrackParH *fRes = new FairTrackParH();
67  Bool_t rc = fGeanePropagator->Propagate(helix, fRes,
68  fPidHyp * pidCand->GetCharge()); // First propagation at module
69  if (!rc)
70  continue;
71 
72  emcGLength = fGeanePropagator->GetLengthAtPCA();
73  vertex.SetXYZ(fRes->GetX(), fRes->GetY(), fRes->GetZ());
74  //std::map<PndEmcTwoCoordIndex*, PndEmcXtal*> tciXtalMap=PndEmcStructure::Instance()->GetTciXtalMap();
75  //PndEmcDigi *lDigi= (PndEmcDigi*)emcHit->Maxima();
76  //PndEmcXtal* xtal = tciXtalMap[lDigi->GetTCI()];
77  //emcPos = xtal->frontCentre();
78  }
79 
80  Float_t dist = (emcPos - vertex).Mag2();
81  if (emcQuality > dist) {
82  emcIndex = ee;
83  emcQuality = dist;
84  emcEloss = emcHit->energy();
85  emcElossCorr = fEmcCalibrator->Energy(emcHit);
86  emcModuleCorr = emcModule;
87  emcNCrystals = emcHit->NumberOfDigis();
88  emcNBumps = emcHit->NBumps();
89  Z20 = emcHit->Z20(); // Z_{n = 2}^{m = 0}
90  Z53 = emcHit->Z53(); // Z_{n = 5}^{m = 3}
91  secLatM = emcHit->LatMom();
92  if (fEmcDigi) {
93  PndEmcClusterEnergySums esum(*emcHit, fEmcDigi);
94  E1 = esum.E1();
95  E9 = esum.E9();
96  E25 = esum.E25();
97  }
98  }
99 
100  if ((fClusterQ[ee] < 0) || (dist < fClusterQ[ee]))
101  // If the track-emc distance is less than the previous stored value (or still not initialized)
102  {
103  fClusterQ[ee] = dist; // update the param
104  }
105 
106  if (fDebugMode) {
107  Float_t ntuple[] = { static_cast<Float_t>(vertex.X()),
108  static_cast<Float_t>(vertex.Y()),
109  static_cast<Float_t>(vertex.Z()),
110  static_cast<Float_t>(vertex.Phi()),
111  static_cast<Float_t>(helix->GetMomentum().Mag()),
112  static_cast<Float_t>(helix->GetQ()),
113  static_cast<Float_t>(helix->GetMomentum().Theta()),
114  static_cast<Float_t>(helix->GetZ()),
115  static_cast<Float_t>(emcPos.X()),
116  static_cast<Float_t>(emcPos.Y()),
117  static_cast<Float_t>(emcPos.Z()),
118  static_cast<Float_t>(emcPos.Phi()), dist,
119  static_cast<Float_t>(vertex.DeltaPhi(emcPos)),
120  static_cast<Float_t>(emcHit->energy()), emcGLength,
121  static_cast<Float_t>(emcModule),
122  static_cast<Float_t>(emcTimeStamp)
123  };
124  // Float_t ntuple[] = {vertex.X(), vertex.Y(), vertex.Z(), vertex.Phi(),
125  // helix->GetMomentum().Mag(), helix->GetQ(), helix->GetMomentum().Theta(), helix->GetZ(),
126  // emcPos.X(), emcPos.Y(), emcPos.Z(), emcPos.Phi(),
127  // dist, vertex.DeltaPhi(emcPos), emcHit->energy(), emcGLength, emcModule};
128  emcCorr->Fill(ntuple);
129  }
130  } // End for(ee = 0;)
131 
132  if ((emcQuality < fCorrPar->GetEmc12Cut()) || (fIdeal && emcIndex != -1)) {
133  fClusterList[emcIndex] = kTRUE;
134  pidCand->SetEmcQuality(emcQuality);
135  pidCand->SetEmcRawEnergy(emcEloss);
136  pidCand->SetEmcCalEnergy(emcElossCorr);
137  pidCand->SetEmcIndex(emcIndex);
138  pidCand->SetEmcModule(emcModuleCorr);
139  pidCand->SetEmcNumberOfCrystals(emcNCrystals);
140  pidCand->SetEmcNumberOfBumps(emcNBumps);
141  pidCand->SetEmcTimeStamp(emcTimeStamp);
142  //=======
143  pidCand->SetEmcClusterZ20(Z20);
144  pidCand->SetEmcClusterZ53(Z53);
145  pidCand->SetEmcClusterLat(secLatM);
146  pidCand->SetEmcClusterE1(E1);
147  pidCand->SetEmcClusterE9(E9);
148  pidCand->SetEmcClusterE25(E25);
149  //=====
150  pidCand->AddLink(FairLink(-1, FairRootManager::Instance()->GetEntryNr(), "EmcCluster", emcIndex));
151  }
152 
153  return kTRUE;
154 }
155 
void SetEmcNumberOfCrystals(Int_t val)
CandList mclist
Int_t GetCharge() const
TVector3 where() const
void SetEmcNumberOfBumps(Int_t val)
Short_t GetModule() const
void SetEmcModule(Int_t val)
void SetEmcClusterE1(Double_t val)
void SetEmcCalEnergy(Double_t val)
PndPidCorrPar * fCorrPar
PndRichHit TCA.
void SetEmcQuality(Double_t val)
virtual Double_t Energy(PndEmcCluster *clust, Int_t pid=22)=0
map< Int_t, Bool_t > fClusterList
const std::vector< Int_t > & GetMcList() const
Int_t GetMcIndex() const
PndEmcAbsClusterCalibrator * fEmcCalibrator
FTS geometry parameters.
virtual Double_t E1() const
Double_t Z53() const
Definition: PndEmcCluster.h:69
Double_t Z20() const
Definition: PndEmcCluster.h:67
Double_t
void SetEmcClusterE9(Double_t val)
void SetEmcIndex(Int_t val)
Double_t LatMom() const
Definition: PndEmcCluster.h:71
a cluster (group of neighboring crystals) of hit emc crystals
Definition: PndEmcCluster.h:29
map< Int_t, Double_t > fClusterQ
TClonesArray * fEmcDigi
PndEmcBump TCA.
FairGeanePro * fGeanePropagator
Refitter for MDT tracks.
void SetEmcClusterE25(Double_t val)
Int_t NumberOfDigis() const
void SetEmcClusterLat(Double_t val)
Int_t NBumps() const
virtual Double_t E25() const
Float_t GetEmc12Thr()
Definition: PndPidCorrPar.h:13
virtual Double_t energy() const
void SetEmcTimeStamp(Double_t val)
ClassImp(PndAnaContFact)
virtual Double_t E9() const
void SetEmcClusterZ20(Double_t val)
void SetEmcClusterZ53(Double_t val)
void SetEmcRawEnergy(Double_t val)
Bool_t GetEmcInfo(FairTrackParH *helix, PndPidCandidate *pid)
TClonesArray * fEmcCluster
PndFtofPoint TCA.