-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotTurnOn_detect100Efficency.C
87 lines (76 loc) · 2.59 KB
/
plotTurnOn_detect100Efficency.C
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
/*
* find L1_THRESHOLD pt for which turn-on curve becomes 100% at pT = 60 GeV
*
* Alex : For the single region, 2x2, and 3x3 seeds, we should show the turn-on curve that reaches 100% efficiency at photon pt = 60 GeV all on the same plot and state the rates. I can make the combo plot and I h
* */
#include <TFile.h>
#include <TGraphAsymmErrors.h>
#include <iostream>
#include <stdlib.h> /* atof */
void plotTurnOn_detect100Efficency(TString inFileName, double pt_photon = 60);
/*
* find the first (highest) L1_THRESHOLD pt for which the efficiency becomes at or before "pt_photon"
* */
void plotTurnOn_detect100Efficency(TString inFileName, double pt_photon /* = 60 */)
{
std::cout << "inFileName = " << inFileName << std::endl;
std::cout << "pt_photon = " << pt_photon << std::endl;
TFile *inFile = TFile::Open(inFileName);
Int_t THRESHOLDS = 80;
// an ugly way to determine the number of "THRESHOLDS".
// usually histogram files for MC samples have 60 thresholds. see "makeTurnOn_fromSameFile_photons.C"
// usually histogram files for data samples have 80 thresholds. see "makeTurnOn_fromSameFile_photons.C"
if(inFileName.Contains("HydjetMB") ||
inFileName.Contains("AllQCDPhoton30") ||
inFileName.Contains("PyquenUnquenched") )
{
THRESHOLDS=60;
}
TGraphAsymmErrors *asymm[THRESHOLDS];//[2];
int fNpoints;
int first_threshold = 0;
bool first_threshold_FOUND = false;
for(int i = THRESHOLDS-1; i >=0 ; i--) // we want the highest threshold value possible.
{
if(first_threshold_FOUND) break;
asymm[i] = (TGraphAsymmErrors*)inFile->Get(Form("asymm_pt_%d_0",i));
fNpoints = asymm[i]->GetN();
double* fX = asymm[i]->GetX();
double* fY = asymm[i]->GetY();
for(int j=fNpoints -1 ; j >= 0; j--)
{
if(fX[j] <= pt_photon) // we passed the bin where fX[bin]=pt_photon
{
if (fY[j] >= 1) // 100% efficieny at pt_photon
{
// this is the highest possible L1_THRESHOLD where efficiency is still 100% at or below pt_photon (60 GeV)
// keep index "i"
first_threshold = i;
first_threshold_FOUND = true;
std::cout << "j =" << j <<std::endl;
std::cout << "fX[j] =" << fX[j] <<std::endl;
}
break;
}
}
}
std::cout << "first_threshold = " << first_threshold << std::endl;
}
int main(int argc, char **argv)
{
if(argc == 2)
{
plotTurnOn_detect100Efficency(argv[1]);
return 0;
}
else if(argc == 3)
{
plotTurnOn_detect100Efficency(argv[1], atof(argv[2]));
return 0;
}
else
{
std::cout << "wrong usage" << std::endl;
return 1;
}
}