FairRoot/PandaRoot
PndPidMlAssociatorTask.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 #include <iostream>
9 
10 
11 //___________________________________________________________
13  //
14  FairRootManager *fManager =FairRootManager::Instance();
15  fManager->Write();
16 }
17 
18 //___________________________________________________________
20  //---
21  if (inFile->IsZombie() || inFile==nullptr){
22  std::cout<<" Error opening Probability file. "<<std::endl;
23  exit(-1);
24  }
25  else{
26  fPidChargedProb = new TClonesArray("PndPidProbability");
27  inTree = (TTree*)inFile->Get("cbmsim");
28  inTree->GetBranch("PidAlgoMl")->SetAutoDelete(kFALSE);
29  inTree->SetBranchAddress("PidAlgoMl",&fPidAlgoMl);
30  i = 0;
31  }
32 }
33 
34 //___________________________________________________________
35 PndPidMlAssociatorTask::PndPidMlAssociatorTask(const char *name, const char *title):FairTask(name)
36 {
37  //---
38  fPidChargedProb = new TClonesArray("PndPidProbability");
39  SetTitle(title);
40 }
41 
42 //___________________________________________________________
44 
45  std::cout << "InitStatus PndPidMlAssociatorTask::Init()" << std::endl;
46 
47 
48 
49  FairRootManager *fManager =FairRootManager::Instance();
50 
51  fPidChargedCand = (TClonesArray *)fManager->GetObject("PidChargedCand");
52  if ( ! fPidChargedCand) {
53  std::cout << "-I- PndPidMlAssociatorTask::Init: No PndPidCandidate array PidChargedCand there!" << std::endl;
54  return kERROR;
55  }
56 
57  Register();
58 
59  std::cout << "-I- PndPidMlAssociatorTask::Init: Success!" << std::endl;
60 
61  return kSUCCESS;
62 }
63 
64 //______________________________________________________
66  //--
67 }
68 //______________________________________________________
69 void PndPidMlAssociatorTask::Exec(Option_t *) {
70  if (fPidChargedProb->GetEntriesFast() != 0) fPidChargedProb->Clear();
71  if(fVerbose>1) std::cout << "-I- Start PndPidMlAssociatorTask. "<<std::endl;
72 
73  inTree->GetEntry(i);
74  i++;
75 
76  // Get the Candidates
77  for(Int_t j=0; j<fPidChargedCand->GetEntriesFast(); j++)
78  {
80  TClonesArray& pidRef = *fPidChargedProb;
81  PndPidProbability* prob = new(pidRef[j]) PndPidProbability();// initializes with zeros
82  prob->SetIndex(j);
83  prob->SetElectronPdf(procand->GetElectronPdf());
84  prob->SetMuonPdf(procand->GetMuonPdf());
85  prob->SetPionPdf(procand->GetPionPdf());
86  prob->SetKaonPdf(procand->GetKaonPdf());
87  prob->SetProtonPdf(procand->GetProtonPdf());
88  }
89 }
90 
91 //_________________________________________________________________
93  //---
94  FairRootManager::Instance()->
95  Register("PidAlgoMl","Pid", fPidChargedProb, kTRUE);
96 }
97 
98 //_________________________________________________________________
100 }
101 
102 //_________________________________________________________________
104  //---
105 }
106 
107 
int fVerbose
Definition: poormantracks.C:24
Int_t i
Input Tree for Ml outputs.
void SetPionPdf(Double_t val)
exit(0)
TClonesArray * fPidChargedProb
PndPidProbability TCA for charged particles.
void SetKaonPdf(Double_t val)
Double_t GetKaonPdf() const
TString inFile
Definition: hit_dirc.C:8
void SetElectronPdf(Double_t val)
void SetMuonPdf(Double_t val)
Double_t GetElectronPdf() const
h_MC_angle SetTitle("MC truth: opening angle of #pi^{0}")
TClonesArray * fPidAlgoMl
PndPidCandidate TCA for charged particles.
virtual void Exec(Option_t *option)
Tree Index.
PndPidMlAssociatorTask(const char *name, const char *title="Pnd Task")
TString name
void SetProtonPdf(Double_t val)
TTree * inTree
PndPidProbability TCA for charged particles.
Double_t GetMuonPdf() const
Double_t GetProtonPdf() const
ClassImp(PndAnaContFact)
Double_t GetPionPdf() const
void SetIndex(Int_t idx)