Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KFParticleTopoReconstructor.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file KFParticleTopoReconstructor.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 #ifndef KFParticleTopoReconstructor_H
23 #define KFParticleTopoReconstructor_H
24 
26 #include "KFParticleFinder.h"
27 
28 #include <vector>
29 #include <string>
30 
31 #include "KFPTrackVector.h"
32 #include "KFParticleSIMD.h"
33 
34 #ifdef USE_TIMERS
35 #ifndef HLTCA_STANDALONE
36 #include "TStopwatch.h"
37 typedef TStopwatch Stopwatch;
38 #else
39 #include "Stopwatch.h"
40 #endif
41 #endif
42 
43 #ifdef KFPWITHTRACKER
44 class AliHLTTPCCAGBTracker;
45 #endif
46 
47 #ifdef WITHSCIF
48 #include <scif.h>
49 #endif
50 
65  public:
67 #ifdef USE_TIMERS
68  ,fTime(0.),timer()
69 #endif
70  {
72 #ifdef USE_TIMERS
73  for ( int i = 0; i < fNTimers; i++ ) fStatTime[i] = 0;
74 #endif
76 
79  }
81 
82 #ifdef KFPWITHTRACKER
83 
91  void Init(AliHLTTPCCAGBTracker* tracker, std::vector<int>* pdg=0); // init array of particles
92 #endif
93 
104  void Init(std::vector<KFParticle> &particles, std::vector<int>* pdg=0, std::vector<int>* nPixelHits=0);
114  void Init(const KFPTrackVector *particles, const std::vector<KFParticle>& pv);
121  void Init(KFPTrackVector &tracks, KFPTrackVector &tracksAtLastPoint);
122 
126 
127  void DeInit() { fTracks = NULL; }
128 
129  void Clear() { fParticles.clear(); fPV.clear(); fKFParticlePVReconstructor->CleanPV(); }
130 
131  void ReconstructPrimVertex(bool isHeavySystem = 1); // find primary vertex
132  void SortTracks(); //sort tracks according to the pdg hypothesis and pv index
133  void ReconstructParticles(); //find short-lived particles
134  void SelectParticleCandidates(); //clean particle candidates: track can belong to only one particle
135 #ifdef WITHSCIF
136  void SendDataToXeonPhi( int iHLT, scif_epd_t& endpoint, void* buffer, off_t& offsetServer, off_t& offsetSender, float Bz);
137 #endif
141 
142  std::vector<int>& GetPVTrackIndexArray(int iPV=0) const { return fKFParticlePVReconstructor->GetPVTrackIndexArray(iPV); }
143 
144  std::vector<KFParticle> const &GetParticles() const { return fParticles; }
145 
146  void RemoveParticle(const int iParticle) { if(iParticle>=0 && iParticle<int(fParticles.size())) fParticles[iParticle].SetPDG(-1); }
147  const KFPTrackVector* GetTracks() const { return fTracks; }
148  const kfvector_float* GetChiPrim() const { return fChiToPrimVtx; }
149 
152 
153  void CleanPV() {
156  }
157  void AddPV(const KFVertex &pv, const std::vector<int> &tracks) {
163  fKFParticlePVReconstructor->AddPV(pv,tracks);
164  KFParticle pvPart=pv;
165  fPV.push_back(pvPart);
166  fKFParticleFinder->SetNPV(fPV.size());
167  }
168  void AddPV(const KFVertex &pv) {
173  KFParticle pvPart=pv;
174  fPV.push_back(pvPart);
175  fKFParticleFinder->SetNPV(fPV.size());
176  }
178  {
181  if(fTracks)
182  for(int iPV=0; iPV<NPrimaryVertices(); iPV++)
183  for(unsigned int iPVTrack=0; iPVTrack<GetPVTrackIndexArray(iPV).size(); iPVTrack++)
184  fTracks[0].SetPVIndex(iPV,GetPVTrackIndexArray(iPV)[iPVTrack]);
185  }
187  void AddParticle(const KFParticle& particle) { fParticles.push_back(particle); }
189  void AddCandidate(const KFParticle& candidate, int iPV = -1) { fKFParticleFinder->AddCandidate(candidate, iPV); }
190 
192 #ifdef HomogeneousField
193  void SetField(double b);
194 #endif
195 
196  //speed measurements
197 #ifdef USE_TIMERS
198  void SetTime(double d) { fTime = d; }
199  double Time() const { return fTime; }
200 
206  double StatTime( int iTimer ) const { return fStatTime[iTimer]; }
207  int NTimers() const { return fNTimers; }
208 #endif
209 
210  void SaveInputParticles(const std::string prefix = "KFPData", bool onlySecondary = 0);
211  void SetNThreads(short int n) { fNThreads=n; }
212 
213  void SetChi2PrimaryCut(float chi) {
217  }
218 
219  void GetListOfDaughterTracks(const KFParticle& particle, std::vector<int>& daughters);
221 
223  {
226  fKFParticleFinder = 0;
227  fTracks = 0;
228 
229  fNThreads = a.fNThreads;
230 
231  return *this;
232  }
233 
236 #ifdef USE_TIMERS
237  ,fTime(0.),timer()
238 #endif
239  {
240  }
241 
244  private:
245 
246  void GetChiToPrimVertex(KFParticleSIMD* pv, const int nPV);
248 
251 
266  std::vector<KFParticle> fParticles;
267  std::vector<KFParticleSIMD, KFPSimdAllocator<KFParticleSIMD> > fPV;
268 
269  short int fNThreads;
270 
271  //speed measurements
272 #ifdef USE_TIMERS
273  double fTime;
274  static const int fNTimers = 4;
275 
277  double fStatTime[fNTimers];
278  Stopwatch timer;
279 #endif // USE_TIMERS
280 
281 }__attribute__((aligned(sizeof(float_v)))); // class KFParticleTopoReconstructor
282 
284 
285 #endif // KFParticleTopoReconstructor_H
286