Double_t BrFdstMainSelector::GetDetectorEfficiency(const TString& detector, const Float_t& x, const Float_t& y, const Float_t& z) { // Return detector efficiency for the specified detector. // For each detector there are three parameters that determine the efficiency. For the RICH // x, y and z correspond to centrality, gamma and x slope, respectively. For the other detectors, // they correspond to centrality, x position and x slope, respectively. // Define local variables. TH3F *hEff, *hRef; TString det = detector; det.ToUpper(); Double_t histX = x; Double_t histY = y; Double_t histZ = z; // Special setting which needs extra care. TRegexp specialSetting("12_.1692"); // Determine which detector and assign the right histograms to work with. Int_t minRefCont = 5; if (det == "T1") { hEff = fHEffT1; hRef = fHRefT1; } else if (det == "T2") { hEff = fHEffT2; hRef = fHRefT2; } else if (det == "T3") { hEff = fHEffT3; hRef = fHRefT3; } else if (det == "T4") { hEff = fHEffT4; hRef = fHRefT4; if (fSetting.Contains(specialSetting)) minRefCont = 4; } else if (det == "T5") { hEff = fHEffT5; hRef = fHRefT5; if (fSetting.Contains(specialSetting)) minRefCont = 4; } else if (det == "H1") { hEff = fHEffH1; hRef = fHRefH1; } else if (det == "H2") { hEff = fHEffH2; hRef = fHRefH2; } else if (det == "RICH") { hEff = fHEffRich; hRef = fHRefRich; histY = TMath::Min(histY, 100.); // Assign maximum gamma for RICH. minRefCont = 10; } else { Error("GetDetectorEfficiency", "Unknown detector %s.", detector.Data()); return 0.; } // Find which histogram bin corresponds to the specified parameters, and // the ref histogram content for this bin. const Int_t currBin = hRef->FindBin(histX, histY, histZ); Int_t currRefCont = (Int_t) hRef->GetBinContent(currBin); // Define efficiency. Double_t eff = 0.; // Return efficiency if the it is defined for this bin if (currRefCont > minRefCont) return (Double_t) hEff->GetBinContent(currBin); // Efficiency is not defined for this bin so we should find the closest bin with // defined value. Int_t xBin = hRef->GetXaxis()->FindBin(histX); Int_t yBin = hRef->GetYaxis()->FindBin(histY); Int_t zBin = hRef->GetZaxis()->FindBin(histZ); Int_t iR = 0; // Current radius, starting at 0. do { iR++; // Loop over all y bins within current radius. for (Int_t iY = yBin - iR; iY <= yBin + iR; iY++) { if (iY < 1 || iY > hRef->GetNbinsY()) continue; // Outside axis' range. // Loop over all z bins within current radius. for (Int_t iZ = zBin - iR; iZ <= zBin + iR; iZ++) { if (iZ < 1 || iZ > hRef->GetNbinsZ()) continue; // Outside axis' range. Float_t radius = TMath::Sqrt((Float_t)((iY - yBin) * (iY - yBin) + (iZ - zBin) * (iZ - zBin))); if (Float_t(iR) > radius) currRefCont = (Int_t) hRef->GetBinContent(xBin, iY, iZ); if (currRefCont > minRefCont) eff = (Double_t) hEff->GetBinContent(xBin, iY, iZ); if (eff) break; } if (eff) break; } } while (!eff && (iR < hRef->GetNbinsY()) && (iR < hRef->GetNbinsZ())); // Send warning if no efficiency was found. if (!eff) if (det == "RICH") Warning("GetDetectorEfficiency", "Could not find efficiency in %s:\tcentrality = %f,\tgamma = %f,\tx slope = %f", hEff->GetName(), x, y, z); else Warning("GetDetectorEfficiency", "Could not find efficiency in %s:\tcentrality = %f,\tx position = %f,\tx slope = %f", hEff->GetName(), x, y, z); return eff; }