PandaRoot
PndGFRecoTask.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
21 #pragma once
22 
23 #include "PndPersistencyTask.h"
24 #include "PndTrack.h"
25 #include "PndGFRecoFit.h"
26 #include "FairLogger.h"
27 
28 #include "TString.h"
29 #include "TClonesArray.h"
30 #include "TMath.h"
31 
32 #include <vector>
33 //#include "eventDisplay/include/EventDisplay.h"
34 
35 class TClonesArray;
36 class MeasurementFactory;
37 class TDatabasePDG;
38 
39 struct PndGFPidHypo {
40 
42  PndGFPidHypo(int pdgvalue)
43  {
44  switch (TMath::Abs(pdgvalue)) {
45  case 11:
46  fPdgNumber = -11;
47  fParticleName = "Electron";
48  break;
49  case 13:
50  fPdgNumber = -13;
51  fParticleName = "Muon";
52  break;
53  case 211:
54  fPdgNumber = 211;
55  fParticleName = "Pion";
56  break;
57  case 321:
58  fPdgNumber = 321;
59  fParticleName = "Kaon";
60  break;
61  case 2212:
62  fPdgNumber = 2212;
63  fParticleName = "Proton";
64  break;
65  default: LOG(error) << "Wrong particle ID given: " << pdgvalue; LOG(error) << "Allowed values are: 11, 13, 211, 321, 2212";
66  }
67  };
68  int fPdgNumber = 0;
69  TString fParticleName;
70  TClonesArray *fArray = nullptr;
71 };
72 
74  public:
75  // Constructors/Destructors ---------
76  PndGFRecoTask(const char *name = "Genfit", Int_t iVerbose = 0);
77  ~PndGFRecoTask();
78 
84  void AddParticleHypo(int pdgCode);
85 
90  void SetMultiPID();
91 
97  void UseIdealPID(bool val = true, Int_t defaultPID = 211)
98  {
99  fIdealPID = val;
100  fDefaultPID = defaultPID;
101  }
102 
107  void SetTrackInBranchName(TString name) { fInputBranchName = name; }
108 
112  void SetTrackOutBranchName(TString name) { fOutputBranchName = name; }
113 
117  void SetFitter(genfit::AbsKalmanFitter *fitter);
118 
122  void SetNBusyCut(int val) { fNBusyCut = val; }
123 
124  void UseEventDisplay(bool val = true) { fUseEventDisplay = val; }
125 
126  // Operations ----------------------
127  virtual InitStatus Init();
128  void SetParContainers();
129  virtual void Exec(Option_t *opt);
130  virtual void FinishTask() {}
131 
132  protected:
133  int GetIdealPdgCode(PndTrack *track);
135  {
136  for (auto &track : fPidHypothesis) {
137  track.fArray->Delete();
138  }
139  }
140 
141  private:
142  TClonesArray *fPrefitTrack = nullptr; //< Input from track finder
143  TClonesArray *fMCTrack = nullptr; //< MC tracks needed for ideal PID
144  std::vector<PndGFPidHypo> fPidHypothesis; //< Pid Hypothesis to fit with. Can be more than one.
145  TString fInputBranchName = ""; //< Name of branch with prefit track data
146  TString fOutputBranchName = ""; //< Name of output branch with fitted track data
147  bool fIdealPID = false; //< Flag to use ideal PID instead of PID hypothesis
148  bool fMultiPID = true; //< Flag
149  int fDefaultPID = 211; //< PID assumption if no PID hypothesis is given
150  TDatabasePDG *fPdg = nullptr; //< Needed by GetIdealPdgCode
151  int fNBusyCut = 50; //< Events with tracks above NBusyCut are ignored
152  bool fUseEventDisplay = false; //< Enables genfit2 event display for PndGFRecoFit
153  PndGFRecoFit fFit;
154 
155  ClassDef(PndGFRecoTask, 2);
156 };
void UseIdealPID(bool val=true, Int_t defaultPID=211)
Flag to use ideal PID from MC tracks instead of particle hypothesis.
Definition: PndGFRecoTask.h:97
PndGFPidHypo(int pdgvalue)
Definition: PndGFRecoTask.h:42
Abstract base class for Kalman fitter and derived fitting algorithms.
static T Abs(const T &x)
Definition: PndCAMath.h:68
TClonesArray * fArray
Definition: PndGFRecoTask.h:70
void DeleteOldTracks()
Class to perform a kalman fit via genfit2 within PandaRoot.
Definition: PndGFRecoFit.h:33
TString fParticleName
Definition: PndGFRecoTask.h:69
void SetNBusyCut(int val)
Cut to suppress events with too many tracks.
virtual void FinishTask()
Task to perform kalman tracking via genfit2.
Definition: PndGFRecoTask.h:73
void SetTrackOutBranchName(TString name)
Name of the output branch containing the fitted PndTracks.
void SetTrackInBranchName(TString name)
Set the name of the input branch Set the name of the input branch with the prefit PndTracks...
void UseEventDisplay(bool val=true)