Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KFParticleFinder.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file KFParticleFinder.h
1 /*
2  * This file is part of KFParticle package
3  * Copyright (C) 2007-2019 FIAS Frankfurt Institute for Advanced Studies
4  * 2007-2019 Goethe University of Frankfurt
5  * 2007-2019 Ivan Kisel <I.Kisel@compeng.uni-frankfurt.de>
6  * 2007-2019 Maksym Zyzak
7  *
8  * KFParticle is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * KFParticle is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 
23 #ifndef KFParticleFinder_h
24 #define KFParticleFinder_h
25 
26 #include "KFParticle.h"
27 #include "KFParticleSIMD.h"
28 #include "KFPTrackVector.h"
29 
30 #include <vector>
31 #include <map>
32 
33 class KFPEmcCluster;
34 
48 {
49  public:
50 
53 
54  void Init(int nPV);
55  void SetNThreads(short int n) { fNThreads = n;}
56 
57  void FindParticles(KFPTrackVector* vRTracks, kfvector_float* ChiToPrimVtx,
58  std::vector<KFParticle>& Particles, std::vector<KFParticleSIMD, KFPSimdAllocator<KFParticleSIMD> >& PrimVtx, int nPV);
59 
60  void ExtrapolateToPV(std::vector<KFParticle>& vParticles, KFParticleSIMD& PrimVtx);
61 
62  inline void ConstructV0(KFPTrackVector* vTracks,
63  int iTrTypePos,
64  int iTrTypeNeg,
65  uint_v& idPosDaughters,
66  uint_v& idNegDaughters,
67  int_v& daughterPosPDG,
68  int_v& daughterNegPDG,
69  KFParticleSIMD& mother,
70  KFParticle& mother_temp,
71  const unsigned short NTracks,
72  kfvector_floatv& l,
73  kfvector_floatv& dl,
74  std::vector<KFParticle>& Particles,
75  std::vector<KFParticleSIMD, KFPSimdAllocator<KFParticleSIMD> >& PrimVtx,
76  const float* cuts,
77  const int_v& pvIndex,
78  const float* secCuts,
79  const float_v& massMotherPDG,
80  const float_v& massMotherPDGSigma,
81  KFParticleSIMD& motherPrimSecCand,
82  int& nPrimSecCand,
83  std::vector< std::vector<KFParticle> >* vMotherPrim = 0,
84  std::vector<KFParticle>* vMotherSec = 0
85  ) __attribute__((always_inline));
86 
87  void SaveV0PrimSecCand(KFParticleSIMD& mother,
88  int& NParticles,
89  KFParticle& mother_temp,
90  std::vector<KFParticleSIMD, KFPSimdAllocator<KFParticleSIMD> >& PrimVtx,
91  const float* secCuts,
92  std::vector< std::vector<KFParticle> >* vMotherPrim,
93  std::vector<KFParticle>* vMotherSec);
94 
96  uint_v& idTracks,
97  int_v& trackPDG,
98  KFParticle* vV0[],
99  KFParticleSIMD& mother,
100  std::vector<KFParticleSIMD, KFPSimdAllocator<KFParticleSIMD> >& motherTopo,
101  KFParticle& mother_temp,
102  const unsigned short nElements,
103  kfvector_floatv& l,
104  kfvector_floatv& dl,
105  std::vector<KFParticle>& Particles,
106  std::vector<KFParticleSIMD, KFPSimdAllocator<KFParticleSIMD> >& PrimVtx,
107  const float_v* cuts,
108  const int_v& pvIndex,
109  const float_v& massMotherPDG,
110  const float_v& massMotherPDGSigma,
111  std::vector< std::vector<KFParticle> >* vMotherPrim,
112  std::vector<KFParticle>* vMotherSec);
113 
114  void Find2DaughterDecay(KFPTrackVector* vTracks, kfvector_float* ChiToPrimVtx,
115  std::vector<KFParticle>& Particles,
116  std::vector<KFParticleSIMD, KFPSimdAllocator<KFParticleSIMD> >& PrimVtx,
117  const float* cuts,
118  const float* secCuts,
119  std::vector< std::vector<KFParticle> >* vMotherPrim,
120  std::vector<KFParticle>* vMotherSec );
121 
122  void ConstructPrimaryBG(KFPTrackVector* vTracks,
123  std::vector<KFParticle>& Particles,
124  std::vector<KFParticleSIMD, KFPSimdAllocator<KFParticleSIMD> >& PrimVtx,
125  const float* cuts,
126  const float* secCuts,
127  std::vector< std::vector<KFParticle> >* vMotherPrim,
128  std::vector<KFParticle>* vMotherSec );
129 
130  void NeutralDaughterDecay(KFPTrackVector* vTracks, std::vector<KFParticle>& Particles);
131 
132  void FindTrackV0Decay(std::vector<KFParticle>& vV0,
133  const int V0PDG,
134  KFPTrackVector& vTracks,
135  const int q,
136  const int firstTrack,
137  const int lastTrack,
138  std::vector<KFParticle>& Particles,
139  std::vector<KFParticleSIMD, KFPSimdAllocator<KFParticleSIMD> >& PrimVtx,
140  int v0PVIndex = -1,
141  kfvector_float* ChiToPrimVtx = 0,
142  std::vector< std::vector<KFParticle> >* vMotherPrim = 0,
143  std::vector<KFParticle>* vMotherSec = 0);
144 
145  void SelectParticles(std::vector<KFParticle>& Particles,
146  std::vector<KFParticle>& vCandidates,
147  std::vector<KFParticleSIMD, KFPSimdAllocator<KFParticleSIMD> >& PrimVtx,
148  const float& cutChi2Topo,
149  const float& cutLdL,
150  const float& mass,
151  const float& massErr,
152  const float& massCut);
153 
154  void CombinePartPart(std::vector<KFParticle>& particles1,
155  std::vector<KFParticle>& particles2,
156  std::vector<KFParticle>& Particles,
157  std::vector<KFParticleSIMD, KFPSimdAllocator<KFParticleSIMD> >& PrimVtx,
158  const float* cuts,
159  int iPV,
160  const int MotherPDG,
161  bool isSameInputPart = 0,
162  bool saveOnlyPrimary = 1,
163  std::vector< std::vector<KFParticle> >* vMotherPrim = 0,
164  std::vector<KFParticle>* vMotherSec = 0,
165  float massMotherPDG = 0.f,
166  float massMotherPDGSigma = 0.f);
167 
168  //Set Emc clusters containing gammas
170 
171  // Mixed Event Analysis
173 
174  //Get secondary particles with the mass constraint
176  static int GetNSecondarySets() { return fNSecCandidatesSets; }
178  const std::vector<KFParticle>* GetSecondaryCandidates() const { return fSecCandidates; }
180  const std::vector<KFParticle>& GetSecondaryK0() const { return fSecCandidates[0]; }
182  const std::vector<KFParticle>& GetSecondaryLambda() const { return fSecCandidates[1]; }
184  const std::vector<KFParticle>& GetSecondaryAntiLambda() const { return fSecCandidates[2]; }
186  const std::vector<KFParticle>& GetSecondaryGamma() const { return fSecCandidates[3]; }
188  const std::vector<KFParticle>& GetSecondaryPi0() const { return fSecCandidates[4]; }
189 
190  //Get primary particles with the mass constraint
192  static int GetNPrimarySets() { return fNPrimCandidatesTopoSets; }
194  const std::vector< std::vector<KFParticle> >* GetPrimaryCandidates() const { return fPrimCandidates; }
196  const std::vector< std::vector<KFParticle> >& GetPrimaryK0() const { return fPrimCandidates[0]; }
198  const std::vector< std::vector<KFParticle> >& GetPrimaryLambda() const { return fPrimCandidates[1]; }
200  const std::vector< std::vector<KFParticle> >& GetPrimaryAntiLambda() const { return fPrimCandidates[2]; }
202  const std::vector< std::vector<KFParticle> >& GetPrimaryGamma() const { return fPrimCandidates[3]; }
204  const std::vector< std::vector<KFParticle> >& GetPrimaryPi0() const { return fPrimCandidates[4]; }
206  const std::vector< std::vector<KFParticle> >& GetPrimaryXi() const { return fPrimCandidates[5]; }
208  const std::vector< std::vector<KFParticle> >& GetPrimaryAntiXi() const { return fPrimCandidates[6]; }
210  const std::vector< std::vector<KFParticle> >& GetPrimaryOmega() const { return fPrimCandidates[7]; }
212  const std::vector< std::vector<KFParticle> >& GetPrimaryAntiOmega() const { return fPrimCandidates[8]; }
213 
214  //Get primary particles with the topologigal constraint
216  const std::vector< std::vector<KFParticle> >* GetPrimaryTopoCandidates() const { return fPrimCandidatesTopo; }
219  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoK0() const { return fPrimCandidatesTopo[0]; }
222  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoLambda() const { return fPrimCandidatesTopo[1]; }
225  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoAntiLambda() const { return fPrimCandidatesTopo[2]; }
228  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoGamma() const { return fPrimCandidatesTopo[3]; }
231  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoPi0() const { return fPrimCandidatesTopo[4]; }
234  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoXi() const { return fPrimCandidatesTopo[5]; }
237  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoAntiXi() const { return fPrimCandidatesTopo[6]; }
240  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoOmega() const { return fPrimCandidatesTopo[7]; }
243  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoAntiOmega() const { return fPrimCandidatesTopo[8]; }
244 
245  //Get primary particles with the topologigal and mass constraint
247  const std::vector< std::vector<KFParticle> >* GetPrimaryTopoMassCandidates() const { return fPrimCandidatesTopoMass; }
250  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoMassK0() const { return fPrimCandidatesTopoMass[0]; }
253  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoMassLambda() const { return fPrimCandidatesTopoMass[1]; }
256  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoMassAntiLambda() const { return fPrimCandidatesTopoMass[2]; }
259  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoMassGamma() const { return fPrimCandidatesTopoMass[3]; }
262  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoMassPi0() const { return fPrimCandidatesTopoMass[4]; }
265  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoMassXi() const { return fPrimCandidatesTopoMass[5]; }
268  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoMassAntiXi() const { return fPrimCandidatesTopoMass[6]; }
271  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoMassOmega() const { return fPrimCandidatesTopoMass[7]; }
274  const std::vector< std::vector<KFParticle> >& GetPrimaryTopoMassAntiOmega() const { return fPrimCandidatesTopoMass[8]; }
275 
276  void AddCandidate(const KFParticle& candidate, int iPV = -1);
277  void SetNPV(int nPV);
278 
279  //Functionality to change cuts, all cuts have default values set in the constructor
281  void SetLCut(float cut) { fLCut = cut; }
282 
283  void SetChiPrimaryCut2D(float cut) { fCuts2D[0] = cut; }
284  void SetChi2Cut2D(float cut) { fCuts2D[1] = cut; }
285  void SetLdLCut2D(float cut) { fCuts2D[2] = cut; }
286 
288  void SetSecondaryCuts(const float sigmaMass = 3.f, const float chi2Topo = 5.f, const float ldl = 10.f) {
289  fSecCuts[0] = sigmaMass;
290  fSecCuts[1] = chi2Topo;
291  fSecCuts[2] = ldl;
292  }
293 
294  void SetLdLCutXiOmega(float cut) { fCutsTrackV0[0][0] = cut; }
295  void SetChi2TopoCutXiOmega(float cut) { fCutsTrackV0[0][1] = cut; }
296  void SetChi2CutXiOmega(float cut) { fCutsTrackV0[0][2] = cut; }
297 
298  void SetChi2TopoCutResonances(float cut) { fCutsTrackV0[2][1] = cut; }
299  void SetChi2CutResonances(float cut) { fCutsTrackV0[2][2] = cut; }
300 
301  void SetPtCutLMVM(float cut) { fCutLVMPt = cut; }
302  void SetPCutLMVM(float cut) { fCutLVMP = cut; }
303  void SetPtCutJPsi(float cut) { fCutJPsiPt = cut; }
304 
305  void SetPtCutCharm(float cut) { fCutCharmPt = cut; }
306  void SetChiPrimaryCutCharm(float cut) { fCutCharmChiPrim = cut; }
307  void SetLdLCutCharmManybodyDecays(float cut) { fCutsTrackV0[1][0] = cut; }
308  void SetChi2TopoCutCharmManybodyDecays(float cut) { fCutsTrackV0[1][1] = cut; }
309  void SetChi2CutCharmManybodyDecays(float cut) { fCutsTrackV0[1][2] = cut; }
310 
311  void SetLdLCutCharm2D(float cut) { fCutsCharm[1] = cut; }
312  void SetChi2TopoCutCharm2D(float cut) { fCutsCharm[2] = cut; }
313  void SetChi2CutCharm2D(float cut) { fCutsCharm[0] = cut; }
314 
315  void CopyCuts(const KFParticleFinder* finder)
316  {
320  fDistanceCut = finder->fDistanceCut;
321  fLCut = finder->fLCut;
322  for(int iCut=0; iCut<3; iCut++)
323  fCuts2D[iCut] = finder->fCuts2D[iCut];
324  for(int iCut=0; iCut<3; iCut++)
325  fSecCuts[iCut] = finder->fSecCuts[iCut];
326  for(int iCut=0; iCut<3; iCut++)
327  for(int jCut=0; jCut<3; jCut++)
328  fCutsTrackV0[iCut][jCut] = finder->fCutsTrackV0[iCut][jCut];
329  for(int iCut=0; iCut<2; iCut++)
330  for(int jCut=0; jCut<3; jCut++)
331  fCutsPartPart[iCut][jCut] = finder->fCutsPartPart[iCut][jCut];
332  fCutCharmPt = finder->fCutCharmPt;
334  for(int iCut=0; iCut<3; iCut++)
335  fCutsCharm[iCut] = finder->fCutsCharm[iCut];
336  fCutLVMPt = finder->fCutLVMPt;
337  fCutLVMP = finder->fCutLVMP;
338  fCutJPsiPt = finder->fCutJPsiPt;
339  }
340 
341  //Functionality to check the cuts
342  const float GetMaxDistanceBetweenParticlesCut() const { return fDistanceCut; }
343  const float GetLCut() const { return fLCut; }
344 
345  const float GetChiPrimaryCut2D() const { return fCuts2D[0]; }
346  const float GetChi2Cut2D() const { return fCuts2D[1]; }
347  const float GetLdLCut2D() const { return fCuts2D[2]; }
348 
349  const float GetSecondarySigmaMassCut() const { return fSecCuts[0]; }
350  const float GetSecondaryChi2TopoCut() const { return fSecCuts[1]; }
351  const float GetSecondaryLdLCut() const { return fSecCuts[2]; }
352 
353  const float GetLdLCutXiOmega() const { return fCutsTrackV0[0][0]; }
354  const float GetChi2TopoCutXiOmega() const { return fCutsTrackV0[0][1]; }
355  const float GetChi2CutXiOmega() const { return fCutsTrackV0[0][2]; }
356 
357  const float GetChi2TopoCutResonances() const { return fCutsTrackV0[2][1]; }
358  const float GetChi2CutResonances() const { return fCutsTrackV0[2][2]; }
359 
360  const float GetPtCutLMVM() const { return fCutLVMPt; }
361  const float GetPCutLMVM() const { return fCutLVMP; }
362  const float GetPtCutJPsi() const { return fCutJPsiPt; }
363 
364  const float GetPtCutCharm() const { return fCutCharmPt; }
365  const float GetChiPrimaryCutCharm() const { return fCutCharmChiPrim; }
366  const float GetLdLCutCharmManybodyDecays() const { return fCutsTrackV0[1][0]; }
367  const float GetChi2TopoCutCharmManybodyDecays() const { return fCutsTrackV0[1][1]; }
368  const float GetChi2CutCharmManybodyDecays() const { return fCutsTrackV0[1][2]; }
369 
370  const float GetLdLCutCharm2D() const { return fCutsCharm[1]; }
371  const float GetChi2TopoCutCharm2D() const { return fCutsCharm[2]; }
372  const float GetChi2CutCharm2D() const { return fCutsCharm[0]; }
373 
379  const std::map<int,bool> GetReconstructionList() const { return fDecayReconstructionList; }
380  void SetReconstructionList(const std::map<int,bool>& decays) { fDecayReconstructionList = decays; }
381 
382  private:
383 
384  short int fNPV;
385  short int fNThreads;
386 
387  float fDistanceCut;
388  float fLCut;
389 
390  float fCuts2D[3];
391  float fSecCuts[3];
392 
394  float fCutsTrackV0[3][3];
397  float fCutsPartPart[2][3];
398 
399  //cuts on open charm particles with 2 daughters
400  float fCutCharmPt;
402  float fCutsCharm[3];
403 
404  //cuts on LVM
405  float fCutLVMPt;
406  float fCutLVMP;
407 
408  //cuts on J/Psi
409  float fCutJPsiPt;
410 
411  //vectors with temporary particles for charm reconstruction
412  std::vector<KFParticle> fD0;
413  std::vector<KFParticle> fD0bar;
414  std::vector<KFParticle> fD04;
415  std::vector<KFParticle> fD04bar;
416  std::vector<KFParticle> fD0KK;
417  std::vector<KFParticle> fD0pipi;
418  std::vector<KFParticle> fDPlus;
419  std::vector<KFParticle> fDMinus;
420  std::vector<KFParticle> fDPlus3Pi;
421  std::vector<KFParticle> fDMinus3Pi;
422  std::vector<KFParticle> fDsPlusK2Pi;
423  std::vector<KFParticle> fDsMinusK2Pi;
424  std::vector<KFParticle> fLcPlusP2Pi;
425  std::vector<KFParticle> fLcMinusP2Pi;
426 
427  //vectors with temporary particles for H0
428  std::vector<KFParticle> fLPi;
429  std::vector<int> fLPiPIndex;
430  std::vector<KFParticle> fHe3Pi;
431  std::vector<KFParticle> fHe3PiBar;
432  std::vector<KFParticle> fHe4Pi;
433  std::vector<KFParticle> fHe4PiBar;
434  std::vector<KFParticle> fHe4L;
435  std::vector<KFParticle> fHe5L;
436  std::vector<KFParticle> fLLn;
437  std::vector<KFParticle> fH5LL;
438 
439  //vectors of candidates with the mass constraint
440  static const int fNSecCandidatesSets = 5;
441 
442  std::vector<KFParticle> fSecCandidates[fNSecCandidatesSets];
443  static const int fNPrimCandidatesSets = 11;
444 
447  std::vector< std::vector<KFParticle> > fPrimCandidates[fNPrimCandidatesSets]; //
448  static const int fNPrimCandidatesTopoSets = 9;
449 
452  std::vector< std::vector<KFParticle> > fPrimCandidatesTopo[fNPrimCandidatesTopoSets];
456  std::vector< std::vector<KFParticle> > fPrimCandidatesTopoMass[fNPrimCandidatesTopoSets];
457 
459 
461 
463  std::map<int,bool> fDecayReconstructionList;
464 
467 };
468 
469 #endif /* !KFParticleFinder_h */
470