114 for (Int_t idx = 0; idx <
fgkNParts; idx++) {
117 Info(
"Init",
"Prepare efficiency map and projections for index %d and method %d", idx,
fMethod);
122 for (Int_t j = 0; j <
fEFF[idx]->GetNdimensions(); j++) {
132 if (j < (
fEFF[idx]->GetNdimensions() - 1))
continue;
138 fEFFproj[idx][j]->SetName(Form(
"NOMidx%dj%d", idx, j));
140 TH1* den =
fEFFdenom[idx]->Projection(j,
"E");
141 den->SetName(Form(
"DENidx%dj%d", idx, j));
154 fEFFproj[idx][j]->SetName(Form(
"NOMidx%dj%d12", idx, j));
156 TH1* den =
fEFFdenom[idx]->Projection(j, 1, 2,
"E");
157 den->SetName(Form(
"DENidx%dj%d12", idx, j));
174 Info(
"Init",
"Momentum smearing map found for index %d", idx);
237 Double_t* vals =
new Double_t[4];
238 Int_t* coord =
new Int_t[4];
241 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
245 int pdg = t->GetPdgCode();
249 if (!
fdbPdg->GetParticle(pdg))
continue;
250 if (TMath::Abs(
fdbPdg->GetParticle(pdg)->Charge()) < 3)
continue;
255 vals[1] = t->Theta();
256 vals[2] = TVector2::Phi_0_2pi(t->Phi());
261 if (TMath::Abs(pdg) == 11 && fStack->
GetParticle(t->GetMother(0))
262 && fStack->
GetParticle(t->GetMother(0))->GetPdgCode() == 22) {
271 TLorentzVector p4(t->Px(), t->Py(), t->Pz(), t->Energy());
283 new ((*fFastTracks)[iKeep]) TParticle(pdg, t->GetStatusCode(), iTrack, 0, 0, 0, p4.Px(), p4.Py(), p4.Pz(),
284 p4.Energy(), t->Vx(), t->Vy(), t->Vz(), 0);
294 Info(
"Exec",
"stack size: \t %d \n", fStack->
GetNtrack());
295 Info(
"Exec",
"kept tracks: \t %d \n", iKeep);
296 Info(
"Exec",
"kept converison tracks: \t %d \n", iConv);
366 switch (TMath::Abs(pdg)) {
372 default:
return kFALSE;
376 Double_t tP = p4->P();
377 Double_t tTheta = p4->Theta();
378 Double_t tPhi = TVector2::Phi_0_2pi(p4->Phi());
379 Double_t mass =
fdbPdg->GetParticle(pdg)->Mass();
383 Double_t sTheta = tTheta;
384 Double_t sPhi = tPhi;
387 Double_t sPx = sP * TMath::Sin(sTheta) * TMath::Cos(sPhi);
388 Double_t sPy = sP * TMath::Sin(sTheta) * TMath::Sin(sPhi);
389 Double_t sPz = sP * TMath::Cos(sTheta);
391 Double_t sPt = TMath::Sqrt(sPx * sPx + sPy * sPy);
392 Double_t eta = -TMath::Log(TMath::Tan(sTheta / 2));
396 p4->SetPtEtaPhiM(sPt, eta, sPhi, mass);
411 if (!map)
return refValue;
414 TAxis* xRec = map->GetXaxis();
415 TAxis* yGen = map->GetYaxis();
418 Int_t binGen = yGen->FindBin(refValue);
424 if (binGen < 1 || binGen > yGen->GetNbins()) {
return (
fRand->Gaus(refValue, refValue * 0.02)); }
427 Float_t* arrayh = map->GetArray();
428 Int_t offset = (yGen->GetNbins() + 2) * (binGen) + 1;
431 Float_t r1 =
fRand->Rndm();
432 Int_t binRec = TMath::BinarySearch(xRec->GetNbins() + 2, arrayh + offset - 1, r1);
434 Double_t smearedValue = xRec->GetBinLowEdge(binRec + 1);
435 if (r1 > arrayh[offset - 1 + binRec])
436 smearedValue += xRec->GetBinWidth(binRec + 1) * (r1 - arrayh[offset - 1 + binRec])
437 / (arrayh[offset - 1 + binRec + 1] - arrayh[offset - 1 + binRec]);
452 if (!nom || !denom) Fatal(
"SetLookupEfficiency",
"Either nominator or denominator is NULL ");
468 if( j<(nom->GetNdimensions()-1) ) continue;
474 fEFFproj[part][j] = nom->Projection(j,"E");
475 fEFFproj[part][j]->SetName(Form("NOMidx%dj%d",part,j));
477 TH1 *den=denom->Projection(j,"E");
478 den->SetName(Form("DENidx%dj%d",part,j));
479 fEFFproj[part][j]->Divide( den );
481 // factoring using last dimension!=1 histograms
482 if(fMethod==kFactorize && j>0) fEFFproj[part][j]->Scale( 1./fEFFproj[part][j]->GetBinContent( fEFFproj[part][j]->GetMaximumBin() ) );
489 if(j>0 && j<3) continue;
490 fEFFproj[part][j] = nom->Projection(j,1,2,"E");
491 fEFFproj[part][j]->SetName(Form("NOMidx%dj%d12",part,j));
493 TH1 *den=denom->Projection(j,1,2,"E");
494 den->SetName(Form("DENidx%dj%d12",part,j));
495 fEFFproj[part][j]->Divide( den );
507 // calculate main effiency map
525 for (Int_t j = 10; j >= 0; j--) {
530 if (coord) eff =
fEFFproj[idx][j]->GetBinContent(coord[j]);
542 for (Int_t c = 0; c < 3; c++) {
543 if (coord[c] == 0) coord[c] += 2;
544 if (coord[c] == 1) coord[c] += 1;
545 if (coord[c] ==
fEFF[idx]->GetAxis(c)->GetNbins()) coord[c] -= 2;
546 if (coord[c] ==
fEFF[idx]->GetAxis(c)->GetNbins() - 1) coord[c] -= 1;
548 eff =
fEFFproj[idx][j]->Interpolate(
fEFFproj[idx][j]->GetXaxis()->GetBinCenter(coord[0]),
549 fEFFproj[idx][j]->GetYaxis()->GetBinCenter(coord[1]),
550 fEFFproj[idx][j]->GetZaxis()->GetBinCenter(coord[2]));
553 eff =
fEFFproj[idx][j]->Interpolate(vals[0], vals[1], vals[2]);
558 if (eff < 1.e-10)
return 0.;
563 if (eff < 1.e-10)
return 0.;
572 Error(
"GetEfficiency",
"number of dimensions for idx:%d is zero!", idx);
577 return (meanEff / ndim);