-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPndPidMlAssociatorTask.cxx
108 lines (87 loc) · 3.19 KB
/
PndPidMlAssociatorTask.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "PndPidMlAssociatorTask.h"
#include "PndPidCandidate.h"
#include "PndPidProbability.h"
#include "FairRootManager.h"
#include "TMath.h"
#include "TF1.h"
#include "Riostream.h"
#include <iostream>
//___________________________________________________________
PndPidMlAssociatorTask::~PndPidMlAssociatorTask() {
//
FairRootManager *fManager =FairRootManager::Instance();
fManager->Write();
}
//___________________________________________________________
PndPidMlAssociatorTask::PndPidMlAssociatorTask(TFile *inFile) {
//---
if (inFile->IsZombie() || inFile==nullptr){
std::cout<<" Error opening Probability file. "<<std::endl;
exit(-1);
}
else{
fPidChargedProb = new TClonesArray("PndPidProbability");
inTree = (TTree*)inFile->Get("cbmsim");
inTree->GetBranch("PidAlgoMl")->SetAutoDelete(kFALSE);
inTree->SetBranchAddress("PidAlgoMl",&fPidAlgoMl);
i = 0;
}
}
//___________________________________________________________
PndPidMlAssociatorTask::PndPidMlAssociatorTask(const char *name, const char *title):FairTask(name)
{
//---
fPidChargedProb = new TClonesArray("PndPidProbability");
SetTitle(title);
}
//___________________________________________________________
InitStatus PndPidMlAssociatorTask::Init() {
std::cout << "InitStatus PndPidMlAssociatorTask::Init()" << std::endl;
FairRootManager *fManager =FairRootManager::Instance();
fPidChargedCand = (TClonesArray *)fManager->GetObject("PidChargedCand");
if ( ! fPidChargedCand) {
std::cout << "-I- PndPidMlAssociatorTask::Init: No PndPidCandidate array PidChargedCand there!" << std::endl;
return kERROR;
}
Register();
std::cout << "-I- PndPidMlAssociatorTask::Init: Success!" << std::endl;
return kSUCCESS;
}
//______________________________________________________
void PndPidMlAssociatorTask::SetParContainers() {
//--
}
//______________________________________________________
void PndPidMlAssociatorTask::Exec(Option_t *) {
if (fPidChargedProb->GetEntriesFast() != 0) fPidChargedProb->Clear();
if(fVerbose>1) std::cout << "-I- Start PndPidMlAssociatorTask. "<<std::endl;
inTree->GetEntry(i);
i++;
// Get the Candidates
for(Int_t j=0; j<fPidChargedCand->GetEntriesFast(); j++)
{
PndPidProbability* procand = (PndPidProbability*)fPidAlgoMl->At(j);
TClonesArray& pidRef = *fPidChargedProb;
PndPidProbability* prob = new(pidRef[j]) PndPidProbability();// initializes with zeros
prob->SetIndex(j);
prob->SetElectronPdf(procand->GetElectronPdf());
prob->SetMuonPdf(procand->GetMuonPdf());
prob->SetPionPdf(procand->GetPionPdf());
prob->SetKaonPdf(procand->GetKaonPdf());
prob->SetProtonPdf(procand->GetProtonPdf());
}
}
//_________________________________________________________________
void PndPidMlAssociatorTask::Register() {
//---
FairRootManager::Instance()->
Register("PidAlgoMl","Pid", fPidChargedProb, kTRUE);
}
//_________________________________________________________________
void PndPidMlAssociatorTask::Finish() {
}
//_________________________________________________________________
void PndPidMlAssociatorTask::Reset() {
//---
}
ClassImp(PndPidMlAssociatorTask)