69 FairParamList* parlist =
new FairParamList();
71 FairParamObj* filenamepar = parlist->find(
"RepoPid");
72 fFileName.Form(
"%s/%s", getenv(
"VMCWORKDIR"), filenamepar->getParamValue());
80 TFile* oldFile = gFile;
81 TDirectory* oldDir = gDirectory;
84 TFile* histFile =
new TFile(
fFileName,
"READ");
85 if (!histFile || !histFile->IsOpen()) {
86 LOG(error) <<
"Could not open input file: " <<
fFileName;
90 LOG(info) <<
"Input file " <<
fFileName <<
" open";
96 TObjArray* inArr =
nullptr;
100 std::vector<TString> histnames{
"MC_electron_p_eloss",
"MC_pion_p_eloss",
"MC_kaon_p_eloss",
"MC_proton_p_eloss",
102 inArr =
new TObjArray(histnames.size());
103 for (
size_t i = 0; i < histnames.size(); i++) {
104 h[i] = histFile->Get<TH2F>(histnames[i]);
106 LOG(info) <<
"No input histogram " << histnames[i].Data();
111 h[i]->SetNameTitle(histnames[i], histnames[i]);
114 for (Int_t
x = 1;
x <=
h[i]->GetNbinsX();
x++) {
116 for (Int_t
y = 1;
y <=
h[i]->GetNbinsY();
y++)
117 sum +=
h[i]->GetBinContent(
x,
y);
118 for (Int_t
y = 1;
y <=
h[i]->GetNbinsY();
y++)
119 if (sum > 0)
h[i]->SetBinContent(
x,
y,
h[i]->GetBinContent(
x,
y) / sum);
126 std::vector<TString> histnames{
"MC_electron_eloss",
"MC_pion_eloss",
"MC_kaon_eloss",
"MC_proton_eloss",
128 inArr =
new TObjArray(histnames.size());
129 for (
size_t i = 0; i < histnames.size(); i++) {
130 h[i] = histFile->Get<TH1F>(histnames[i]);
132 LOG(info) <<
"No input histogram " << histnames[i].Data();
137 h[i]->SetNameTitle(histnames[i], histnames[i]);
140 h[i]->Scale(1. /
h[i]->Integral());
148 std::vector<TString> histnames{
"ELE_electron_p_eloss",
"PIO_pion_p_eloss",
"ELE_kaon_p_eloss",
149 "ELE_proton_p_eloss",
"ELE_muon_p_eloss"};
150 inArr =
new TObjArray(histnames.size());
151 for (
size_t i = 0; i < histnames.size(); i++) {
152 h[i] = histFile->Get<TH2F>(histnames[i]);
153 h[i]->SetNameTitle(histnames[i], histnames[i]);
155 LOG(info) <<
"No input histogram " << histnames[i].Data();
160 h[i]->SetNameTitle(histnames[i], histnames[i]);
163 for (Int_t
x = 1;
x <=
h[i]->GetNbinsX();
x++) {
165 for (Int_t
y = 1;
y <=
h[i]->GetNbinsY();
y++)
166 sum +=
h[i]->GetBinContent(
x,
y);
167 for (Int_t
y = 1;
y <=
h[i]->GetNbinsY();
y++)
168 if (sum > 0)
h[i]->SetBinContent(
x,
y,
h[i]->GetBinContent(
x,
y) / sum);
175 std::vector<TString> histnames{
"ELE_electron_eloss",
"PIO_pion_eloss",
"ELE_kaon_eloss",
"ELE_proton_eloss",
177 inArr =
new TObjArray(histnames.size());
178 for (
size_t i = 0; i < histnames.size(); i++) {
179 h[i] = histFile->Get<TH1F>(histnames[i]);
181 LOG(info) <<
"No input histogram " << histnames[i].Data();
186 h[i]->SetNameTitle(histnames[i], histnames[i]);
189 h[i]->Scale(1. /
h[i]->Integral());
197 for (Int_t i = 0; i < inArr->GetEntriesFast(); i++) {
199 TH1* hist = (TH1*) inArr->At(i)->Clone();
200 TString name = hist->GetTitle();
202 LOG_IF(info, hist->GetEntries() < 1000) <<
"Input histogram is almost empty for" << name.Data();
205 if (name.Contains(
"electron"))
207 else if (name.Contains(
"pion"))
209 else if (name.Contains(
"kaon"))
211 else if (name.Contains(
"proton"))
213 else if (name.Contains(
"muon"))
219 LOG(info) <<
"Particle histogram " << name.Data() <<
" added to array at " << particle;
297 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
302 if (trdTrackIndex == -1) {
310 Warning(
"Exec",
"No Trd track pointer");
322 for (Int_t iSpecies = 0; iSpecies <
fgkNParts; iSpecies++) {
323 prob[iSpecies] = 1.0;
328 momentum = TMath::Abs(1. / (pTrack->
GetParamFirst()->GetQp()));
330 else if (TMath::Abs(pTrack->
GetParamLast()->GetQp()) > 0.) {
331 momentum = TMath::Abs(1. / (pTrack->
GetParamLast()->GetQp()));
334 Warning(
"Exec",
"Could not assign any momentum to the track, use p=0.");
343 for (Int_t iTRD = 0; iTRD < pTrack->
GetNofHits(); iTRD++) {
346 if (trdHit->
GetELoss() < 0.)
continue;
348 dEsum += trdHit->
GetELoss() * 1.e+6;
350 for (Int_t iSpecies = 0; iSpecies <
fgkNParts; iSpecies++) {
358 for (Int_t iSpecies = 0; iSpecies <
fgkNParts; iSpecies++) {
359 if (prob[iSpecies] >= 0. && prob[iSpecies] <= 1.) probTotal += prob[iSpecies];
363 for (Int_t iSpecies = 0; iSpecies <
fgkNParts; iSpecies++) {
366 prob[iSpecies] /= probTotal;
369 prob[iSpecies] = -1.5;
410 if (hist->GetEntries() < 1000.) {
414 Int_t ndim = hist->GetDimension();
416 Float_t maxY = hist->GetYaxis()->GetXmax();
417 Float_t maxX = hist->GetXaxis()->GetXmax();
420 Bool_t overflowY = (dedx > maxY);
421 Bool_t overflowX = (ndim == 1 ? (dedx > maxX) : (mom > maxX));
424 Float_t binwidthY = (ndim == 1 ? 0. : hist->GetYaxis()->GetBinWidth(hist->GetNbinsY()));
425 Float_t binwidthX = hist->GetXaxis()->GetBinWidth(hist->GetNbinsX());
430 hist->FindBin((overflowX ? maxX - binwidthX : dedx));
433 hist->FindBin((overflowX ? maxX - binwidthX : mom), (overflowY ? maxY - binwidthY : dedx));
437 if (TMath::Abs(hist->GetBinContent(bin)) < 1.e-15) {
438 Double_t con = -999.;
440 con = hist->Interpolate((overflowX ? maxX - binwidthX : dedx));
443 con = ((TH2*) hist)->Interpolate((overflowX ? maxX - binwidthX : mom), (overflowY ? maxY - binwidthY : dedx));
448 return hist->GetBinContent(bin);