BmnRoot
Loading...
Searching...
No Matches
BmnEfficiencyProbability.cxx
Go to the documentation of this file.
2
4 : fFile(nullptr)
5 , hHisto(nullptr)
6 , fDet("")
7 , fStat(-1)
8 , fMod(-1)
9 , fZone("")
10{
11 fFile = new TFile(f.Data(), "read");
12
13 if (!fFile->IsOpen() || fFile->IsZombie())
14 return;
15}
16
18{
19 TString ele = "";
20
21 if (fDet.Contains("GEM")) {
22 Int_t idxZone = fZone.Contains("hot") ? 0 : fZone.Contains("big") ? 1 : -1;
23 if (idxZone == -1) {
24 cout << "Zone is not defined!!! Exiting ..." << endl;
25 throw;
26 } else
27 ele = TString::Format("Detector# %s, Station# %d, Module# %d, Zone# %d", fDet.Data(), fStat, fMod, idxZone);
28 }
29
30 else if (fDet.Contains("SILICON"))
31 ele = TString::Format("Detector# %s, Station# %d, Module# %d", fDet.Data(), fStat, fMod);
32
33 hHisto = (TH1F*)fFile->Get(ele.Data());
34
35 if (TMath::Abs(hHisto->Integral() - 1.) > FLT_EPSILON)
36 throw;
37
38 Double_t x = -1., y = -1., content = -1.;
39
40 do {
41 x = gRandom->Rndm();
42 // y = hHisto->GetBinContent(hHisto->GetMaximumBin()) * gRandom->Rndm();
43 y = 1. * gRandom->Rndm();
44
45 // cout << x << " -- " << y << endl;
46
47 // Looking for a bin corresponding to x ...
48 Int_t bin = hHisto->FindBin(x);
49 // cout << bin << endl;
50 content = hHisto->GetBinContent(bin);
51 // cout << content << endl;
52 } while (y > content);
53
54 // cout << "Eff# " << x << endl;
55 return x;
56}
float f
Definition P4_F32vec4.h:21