FairRoot/PandaRoot
PndPidSciTAssociatorTask.cxx
Go to the documentation of this file.
2 #include "PndPidCandidate.h"
3 #include "PndPidProbability.h"
4 #include "FairRootManager.h"
5 #include "TMath.h"
6 #include "TF1.h"
7 #include "Riostream.h"
8 
9 //___________________________________________________________
11  //
12  FairRootManager *fManager =FairRootManager::Instance();
13  fManager->Write();
14 }
15 
16 //___________________________________________________________
18  //---
19  fPidChargedProb = new TClonesArray("PndPidProbability");
21 }
22 
23 //___________________________________________________________
24 PndPidSciTAssociatorTask::PndPidSciTAssociatorTask(const char *name, const char *title):FairTask(name)
25 {
26  //---
27  fPidChargedProb = new TClonesArray("PndPidProbability");
29  SetTitle(title);
30 }
31 
32 //___________________________________________________________
34 
35  std::cout << "InitStatus PndPidSciTAssociatorTask::Init()" << std::endl;
36 
37  FairRootManager *fManager =FairRootManager::Instance();
38 
39  fPidChargedCand = (TClonesArray *)fManager->GetObject("PidChargedCand"+fTrackBranchNamePidHypo);
40  if ( ! fPidChargedCand) {
41  std::cout << "-I- PndPidSciTAssociatorTask::Init: No PndPidCandidate array PidChargedCand there!" << std::endl;
42  return kERROR;
43  }
44 
45  Register();
46 
47  std::cout << "-I- PndPidSciTAssociatorTask::Init: Success!" << std::endl;
48 
49  return kSUCCESS;
50 }
51 
52 //______________________________________________________
54  //--
55 }
56 //______________________________________________________
58  if (fPidChargedProb->GetEntriesFast() != 0) fPidChargedProb->Clear();
59  if(fVerbose>1) std::cout << "-I- Start PndPidSciTAssociatorTask. "<<std::endl;
60 
61  PndPidCandidate *pidcand;
62  PndPidProbability *prob;
63 
64  // Get the Candidates
65  for(Int_t i=0; i<fPidChargedCand->GetEntriesFast(); i++)
66  {
67  pidcand = (PndPidCandidate*)fPidChargedCand->At(i);
68  prob = new((*fPidChargedProb)[i]) PndPidProbability(0.2,0.2,0.2,0.2,0.2,i);// initializes with equal probability
69  if (pidcand->GetTofIndex()==-1) continue;
70  if ((pidcand->GetMomentum().Theta()*TMath::RadToDeg())<20.) continue; // pid runs only in the scitil region, with theta >20°
71  DoPidMatch(pidcand,prob);
72  }
73 }
74 
76 {
77  //parametrizise the sigma e.g. in dependenc of the transvers momentum
78  Double_t sigma=0.08;
79 
80  TF1 *tofResolution = new TF1("tofResolution","[0]/x**4+[1]");
81 
82  Double_t mass = 0.140; // mass in GeV/c. Pion Mass as start Value
83 
84  Double_t mom =pidcand->GetMomentum().Perp();// transverse momentum!
85  Double_t length = pidcand->GetTofTrackLength();
86  Double_t tof = pidcand->GetTofStopTime();
87 
88 
89  // electron
90  mass = 0.000511;
91  tofResolution->SetParameters(0.0000153,0.0765);
92  sigma = tofResolution->Eval(mom);
93  prob->SetElectronPdf(GetPdf(mom,length,tof,mass,sigma));
94 
95  // muon
96  mass = 0.106;
97  tofResolution->SetParameters(0.0000222,0.0768);
98  sigma = tofResolution->Eval(mom);
99  prob->SetMuonPdf(GetPdf(mom,length,tof,mass,sigma));
100 
101  // pion
102  mass = 0.140;
103  tofResolution->SetParameters(0.0000225,0.0764);
104  sigma = tofResolution->Eval(mom);
105  prob->SetPionPdf(GetPdf(mom,length,tof,mass,sigma));
106 
107  // kaon
108  mass = 0.494;
109  tofResolution->SetParameters(0.0003,0.0767);
110  sigma = tofResolution->Eval(mom);
111  prob->SetKaonPdf(GetPdf(mom,length,tof,mass,sigma));
112 
113  // proton
114  mass = 0.938;
115  tofResolution->SetParameters(0.00124,0.0787);
116  sigma = tofResolution->Eval(mom);
117  prob->SetProtonPdf(GetPdf(mom,length,tof,mass,sigma));
118 
119 
120  delete tofResolution;
121 }
122 
124 {
125  // if ( ) only treat possible particles? e.g. with a minimum tranverse momentum?
126  Double_t tofCalc = length/(TMath::C()*100/1000000000)*sqrt(mass*mass/mom/mom+1);
127 
128  TF1 *gausPdf = new TF1("gausPdf","gausn",0,1);
129  gausPdf->SetParameter(0,1);
130  gausPdf->SetParameter(1,tofCalc);
131  gausPdf->SetParameter(2,sigma);
132  Double_t val = gausPdf->Eval(tof);
133  delete gausPdf;
134  return val;
135 }
136 
137 //_________________________________________________________________
139  //---
140  FairRootManager::Instance()->
141  Register("PidAlgoSciT"+fTrackBranchNamePidHypo,"Pid", fPidChargedProb, kTRUE);
142 }
143 
144 //_________________________________________________________________
146 }
147 
148 //_________________________________________________________________
150  //---
151 }
152 
153 
int fVerbose
Definition: poormantracks.C:24
Float_t GetTofStopTime() const
Int_t i
Definition: run_full.C:25
void SetPionPdf(Double_t val)
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
void SetKaonPdf(Double_t val)
Double_t sigma[nsteps]
Definition: dedx_bands.C:65
Double_t mom
Definition: plot_dirc.C:14
void SetElectronPdf(Double_t val)
virtual void Exec(Option_t *option)
void SetMuonPdf(Double_t val)
int Pic_FED Eff_lEE C()
Float_t GetTofTrackLength() const
h_MC_angle SetTitle("MC truth: opening angle of #pi^{0}")
Int_t GetTofIndex() const
TString fTrackBranchNamePidHypo
PndPidProbability TCA for charged particles.
Double_t
void DoPidMatch(PndPidCandidate *pidcand, PndPidProbability *prob)
TString name
Double_t GetPdf(Double_t mom, Double_t length, Double_t tof, Double_t mass, Double_t sigma)
void SetProtonPdf(Double_t val)
TClonesArray * fPidChargedProb
PndPidCandidate TCA for charged particles.
ClassImp(PndAnaContFact)
TVector3 GetMomentum() const