File indexing completed on 2024-04-06 12:18:50
0001 {
0002 #include <strstream.h>
0003 #include <iomanip.h>
0004
0005 TH1F::SetDefaultSumw2();
0006
0007
0008 Double_t MCEtCut = 0.;
0009 Double_t EtCut = 15.;
0010 Double_t IHcalCut = 3.;
0011 Double_t pixMatchCut = 1;
0012 Double_t EoverpBarrelCut = 1.5;
0013 Double_t EoverpEndcapCut = 2.45;
0014 Double_t ItrackCut = 0.06;
0015
0016
0017 TString MCEtPTCutString = "ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcEt > ";
0018 MCEtPTCutString += MCEtCut;
0019 TString l1MatchPTCutString = "ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.l1Match";
0020 TString EtPTCutString = "ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.Et > ";
0021 EtPTCutString += EtCut;
0022 TString IHcalPTCutString = "ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.IHcal < ";
0023 IHcalPTCutString += IHcalCut;
0024 TString pixMatchPTCutString = "ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.pixMatch >= ";
0025 pixMatchPTCutString += pixMatchCut;
0026
0027 TString MCEtCutString = "ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.mcEt > ";
0028 MCEtCutString += MCEtCut;
0029 TString l1MatchCutString = "ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.l1Match";
0030 TString EtCutString = "ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.Et > ";
0031 EtCutString += EtCut;
0032 TString IHcalCutString = "ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.IHcal < ";
0033 IHcalCutString += IHcalCut;
0034 TString pixMatchCutString = "ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.pixMatch >= ";
0035 pixMatchCutString += pixMatchCut;
0036 TString EoverpCutString = "(ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.Eoverp < ";
0037 EoverpCutString += EoverpBarrelCut;
0038 EoverpCutString += " && fabs(ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.eta) < 1.5) || (ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.Eoverp < ";
0039 EoverpCutString += EoverpEndcapCut;
0040 EoverpCutString += " && fabs(ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.eta) > 1.5 && fabs(ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.eta) < 2.5)";
0041 TString ItrackCutString = "ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.Itrack < ";
0042 ItrackCutString += ItrackCut;
0043
0044 TString l1MatchCutPathString = "(" + l1MatchPTCutString + ")";
0045 TString EtCutPathString = "(" + l1MatchCutPathString + ")&&(" + EtPTCutString + ")";
0046 TString IHcalCutPathString = "(" + EtCutPathString + ")&&(" + IHcalPTCutString + ")";
0047 TString pixMatchCutPathString = "(" + IHcalCutPathString + ")&&(" + pixMatchPTCutString + ")";
0048 TString EoverpCutPathString = "(" + l1MatchCutString + ")&&(" + EtCutString + ")&&(" + IHcalCutString + ")&&(" + pixMatchCutString + ")&&(" + EoverpCutString + ")";
0049 TString ItrackCutPathString = "(" + EoverpCutPathString + ")&&(" + ItrackCutString + ")";
0050
0051 TString l1MatchCutPathMCString = "(" + l1MatchCutString + ")&&(" + MCEtPTCutString + ")";
0052 TString EtCutPathMCString = "(" + EtCutPathString + ")&&(" + MCEtPTCutString + ")";
0053 TString IHcalCutPathMCString = "(" + IHcalCutPathString + ")&&(" + MCEtPTCutString + ")";
0054 TString pixMatchCutPathMCString = "(" + pixMatchCutPathString + ")&&(" + MCEtPTCutString + ")";
0055 TString EoverpCutPathMCString = "(" + EoverpCutPathString + ")&&(" + MCEtCutString + ")";
0056 TString ItrackCutPathMCString = "(" + ItrackCutPathString + ")&&(" + MCEtCutString + ")";
0057
0058 TFile *file = new TFile("../test/ZEE-HLTEgamma.root");
0059 TTree *allEvents = Events->CloneTree();
0060
0061 TH1F *l1NumEt = new TH1F("l1NumEt", "Efficiency vs. Et", 100, 0, 150);
0062 allEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcEt>>l1NumEt",MCEtPTCutString);
0063 TH1F *l1NumEta = new TH1F("l1NumEta", "Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0064 allEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcEta>>l1NumEta",MCEtPTCutString);
0065 TH1F *l1NumPhi = new TH1F("l1NumPhi", "Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0066 allEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcPhi>>l1NumPhi",MCEtPTCutString);
0067 Long64_t total = allEvents->GetEntries();
0068 Long64_t pass0 = allEvents->GetEntries("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.Et > -999.");
0069
0070
0071 TTree *l1MatchEvents = allEvents->CopyTree(l1MatchCutPathString);
0072
0073 TH1F *l1MatchNumEt = new TH1F("l1MatchNumEt", "L1 Match Efficiency vs. Et", 100, 0, 150);
0074 l1MatchEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcEt>>l1MatchNumEt",l1MatchCutPathMCString);
0075 TH1F *l1MatchHistEt = new TH1F("l1MatchHistEt", "L1 Match Efficiency vs. Et;Et (GeV);Eff.", 100, 0, 150);
0076 l1MatchHistEt->Divide(l1MatchNumEt, l1NumEt, 1, 1, "B");
0077
0078 TH1F *l1MatchNumEta = new TH1F("l1MatchNumEta", "L1 Match Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0079 l1MatchEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcEta>>l1MatchNumEta",l1MatchCutPathMCString);
0080 TH1F *l1MatchHistEta = new TH1F("l1MatchHistEta", "L1 Match Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0081 l1MatchHistEta->Divide(l1MatchNumEta, l1NumEta, 1, 1, "B");
0082
0083 TH1F *l1MatchNumPhi = new TH1F("l1MatchNumPhi", "L1 Match Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0084 l1MatchEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcPhi>>l1MatchNumPhi",l1MatchCutPathMCString);
0085 TH1F *l1MatchHistPhi = new TH1F("l1MatchHistPhi", "L1 Match Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0086 l1MatchHistPhi->Divide(l1MatchNumPhi, l1NumPhi, 1, 1, "B");
0087 Long64_t pass1 = l1MatchEvents->GetEntries();
0088
0089
0090 TTree *EtEvents = allEvents->CopyTree(EtCutPathString);
0091
0092 TH1F *EtNumEt = new TH1F("EtNumEt", "Et Cut Efficiency vs. Et;Et (GeV);Eff.", 100, 0, 150);
0093 EtEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcEt>>EtNumEt",EtCutPathMCString);
0094 TH1F *EtHistEt = new TH1F("EtHistEt", "Et Cut Efficiency vs. Et;Et (GeV);Eff.", 100, 0, 150);
0095 EtHistEt->Divide(EtNumEt, l1MatchNumEt, 1, 1, "B");
0096
0097 TH1F *EtNumEta = new TH1F("EtNumEta", "Et Cut Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0098 EtEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcEta>>EtNumEta",EtCutPathMCString);
0099 TH1F *EtHistEta = new TH1F("EtHistEta", "Et Cut Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0100 EtHistEta->Divide(EtNumEta, l1MatchNumEta, 1, 1, "B");
0101
0102 TH1F *EtNumPhi = new TH1F("EtNumPhi", "Et Cut Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0103 EtEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcPhi>>EtNumPhi",EtCutPathMCString);
0104 TH1F *EtHistPhi = new TH1F("EtHistPhi", "Et Cut Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0105 EtHistPhi->Divide(EtNumPhi, l1MatchNumPhi, 1, 1, "B");
0106 Long64_t pass2 = EtEvents->GetEntries();
0107
0108
0109 TTree *IHcalEvents = allEvents->CopyTree(IHcalCutPathString);
0110
0111 TH1F *IHcalNumEt = new TH1F("IHcalNumEt", "Hcal Isolation Efficiency vs. Et;Et (GeV);Eff.", 100, 0, 150);
0112 IHcalEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcEt>>IHcalNumEt",IHcalCutPathMCString);
0113 TH1F *IHcalHistEt = new TH1F("IHcalHistEt", "Hcal Isolation Efficiency vs. Et;Et (GeV);Eff.", 100, 0, 150);
0114 IHcalHistEt->Divide(IHcalNumEt, EtNumEt, 1, 1, "B");
0115
0116 TH1F *IHcalNumEta = new TH1F("IHcalNumEta", "Hcal Isolation Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0117 IHcalEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcEta>>IHcalNumEta",IHcalCutPathMCString);
0118 TH1F *IHcalHistEta = new TH1F("IHcalHistEta", "Hcal Isolation Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0119 IHcalHistEta->Divide(IHcalNumEta, EtNumEta, 1, 1, "B");
0120
0121 TH1F *IHcalNumPhi = new TH1F("IHcalNumPhi", "Hcal Isolation Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0122 IHcalEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcPhi>>IHcalNumPhi",IHcalCutPathMCString);
0123 TH1F *IHcalHistPhi = new TH1F("IHcalHistPhi", "Hcal Isolation Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0124 IHcalHistPhi->Divide(IHcalNumPhi, EtNumPhi, 1, 1, "B");
0125 Long64_t pass3 = IHcalEvents->GetEntries();
0126
0127
0128 TTree *PixMatchEvents = allEvents->CopyTree(pixMatchCutPathString);
0129
0130 TH1F *PixMatchNumEt = new TH1F("PixMatchNumEt", "Pixel Match Efficiency vs. Et;Et (GeV);Eff.", 100, 0, 150);
0131 PixMatchEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcEt>>PixMatchNumEt",pixMatchCutPathMCString);
0132 TH1F *PixMatchHistEt = new TH1F("PixMatchHistEt", "Pixel Match Efficiency vs. Et;Et (GeV);Eff.", 100, 0, 150);
0133 PixMatchHistEt->Divide(PixMatchNumEt, IHcalNumEt, 1, 1, "B");
0134
0135 TH1F *PixMatchNumEta = new TH1F("PixMatchNumEta", "Pixel Match Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0136 PixMatchEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcEta>>PixMatchNumEta",pixMatchCutPathMCString);
0137 TH1F *PixMatchHistEta = new TH1F("PixMatchHistEta", "Pixel Match Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0138 PixMatchHistEta->Divide(PixMatchNumEta, IHcalNumEta, 1, 1, "B");
0139
0140 TH1F *PixMatchNumPhi = new TH1F("PixMatchNumPhi", "Pixel Match Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0141 PixMatchEvents->Draw("ElecHLTCutVarsPreTracks_hltCutVars_SingleElecsPT_EGAMMAHLT.obj.mcPhi>>PixMatchNumPhi",pixMatchCutPathMCString);
0142 TH1F *PixMatchHistPhi = new TH1F("PixMatchHistPhi", "Pixel Match Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0143 PixMatchHistPhi->Divide(PixMatchNumPhi, IHcalNumPhi, 1, 1, "B");
0144 Long64_t pass4 = PixMatchEvents->GetEntries();
0145
0146
0147 TTree *EoverpEvents = allEvents->CopyTree(EoverpCutPathString);
0148
0149 TH1F *EoverpNumEt = new TH1F("EoverpNumEt", "E/p Cut Efficiency vs. Et;Et (GeV);Eff.", 100, 0, 150);
0150 EoverpEvents->Draw("ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.mcEt>>EoverpNumEt",EoverpCutPathMCString);
0151 TH1F *EoverpHistEt = new TH1F("EoverpHistEt", "E/p Cut Efficiency vs. Et;Et (GeV);Eff.", 100, 0, 150);
0152 EoverpHistEt->Divide(EoverpNumEt, PixMatchNumEt, 1, 1, "B");
0153
0154 TH1F *EoverpNumEta = new TH1F("EoverpNumEta", "E/p Cut Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0155 EoverpEvents->Draw("ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.mcEta>>EoverpNumEta",EoverpCutPathMCString);
0156 TH1F *EoverpHistEta = new TH1F("EoverpHistEta", "E/p Cut Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0157 EoverpHistEta->Divide(EoverpNumEta, PixMatchNumEta, 1, 1, "B");
0158
0159 TH1F *EoverpNumPhi = new TH1F("EoverpNumPhi", "E/p Cut Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0160 EoverpEvents->Draw("ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.mcPhi>>EoverpNumPhi",EoverpCutPathMCString);
0161 TH1F *EoverpHistPhi = new TH1F("EoverpHistPhi", "E/p Cut Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0162 EoverpHistPhi->Divide(EoverpNumPhi, PixMatchNumPhi, 1, 1, "B");
0163 Long64_t pass5 = EoverpEvents->GetEntries();
0164
0165
0166 TTree *HLTEvents = allEvents->CopyTree(ItrackCutPathString);
0167
0168 TH1F *ItrackNumEt = new TH1F("ItrackNumEt", "Track Isolation Efficiency vs. Et;Et (GeV);Eff.", 100, 0, 150);
0169 HLTEvents->Draw("ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.mcEt>>ItrackNumEt",ItrackCutPathMCString);
0170 TH1F *ItrackHistEt = new TH1F("ItrackHistEt", "Track Isolation Efficiency vs. Et;Et (GeV);Eff.", 100, 0, 150);
0171 ItrackHistEt->Divide(ItrackNumEt, EoverpNumEt, 1, 1, "B");
0172
0173 TH1F *ItrackNumEta = new TH1F("ItrackNumEta", "Track Isolation Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0174 HLTEvents->Draw("ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.mcEta>>ItrackNumEta",ItrackCutPathMCString);
0175 TH1F *ItrackHistEta = new TH1F("ItrackHistEta", "Track Isolation Efficiency vs. eta;eta;Eff.", 100, -2.5, 2.5);
0176 ItrackHistEta->Divide(ItrackNumEta, EoverpNumEta, 1, 1, "B");
0177
0178 TH1F *ItrackNumPhi = new TH1F("ItrackNumPhi", "Track Isolation Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0179 HLTEvents->Draw("ElecHLTCutVarss_hltCutVars_SingleElecs_EGAMMAHLT.obj.mcPhi>>ItrackNumPhi",ItrackCutPathMCString);
0180 TH1F *ItrackHistPhi = new TH1F("ItrackHistPhi", "Track Isolation Efficiency vs. phi;phi;Eff.", 100, 0, 6.2832);
0181 ItrackHistPhi->Divide(ItrackNumPhi, EoverpNumPhi, 1, 1, "B");
0182 Long64_t pass6 = HLTEvents->GetEntries();
0183
0184 Double_t eff0 = (Double_t)pass0 / (Double_t)total;
0185 Double_t eff1 = (Double_t)pass1 / (Double_t)pass0;
0186 Double_t eff2 = (Double_t)pass2 / (Double_t)pass1;
0187 Double_t eff3 = (Double_t)pass3 / (Double_t)pass2;
0188 Double_t eff4 = (Double_t)pass4 / (Double_t)pass3;
0189 Double_t eff5 = (Double_t)pass5 / (Double_t)pass4;
0190 Double_t eff6 = (Double_t)pass6 / (Double_t)pass5;
0191 Double_t eff = (Double_t)pass6 / (Double_t)pass0;
0192 cout.setf(ios::left);
0193 cout<<setw(25)<<"L1 Pass: "<<setw(15)<<pass0<<setw(25)<<"MC eta + L1 Efficiency: "<<eff0<<endl;
0194 cout<<setw(25)<<"L1 Match Pass: "<<setw(15)<<pass1<<setw(25)<<"L1 Match Efficiency: "<<eff1<<endl;
0195 cout<<setw(25)<<"Et Pass: "<<setw(15)<<pass2<<setw(25)<<"Et Efficiency: "<<setw(15)<<eff2<<endl;
0196 cout<<setw(25)<<"IHcal Pass: "<<setw(15)<<pass3<<setw(25)<<"IHcal Efficiency: "<<setw(15)<<eff3<<endl;
0197 cout<<setw(25)<<"Pixel Match Pass: "<<setw(15)<<pass4<<setw(25)<<"Pixel Match Efficiency: "<<setw(15)<<eff4<<endl;
0198 cout<<setw(25)<<"E / p Pass: "<<setw(15)<<pass5<<setw(25)<<"E / p Efficiency: "<<setw(15)<<eff5<<endl;
0199 cout<<setw(25)<<"Itrack Pass: "<<setw(15)<<pass6<<setw(25)<<"Itrack Efficiency: "<<setw(15)<<eff6<<endl;
0200 cout<<"--"<<endl;
0201 cout<<"HLT Efficiency: "<<eff<<endl;
0202
0203 TCanvas *myCanvas = new TCanvas("myCanvas", "Single Electron Efficiencies vs. Et", 1500, 1000);
0204 myCanvas->Divide(3,2);
0205 myCanvas->cd(1);
0206 l1MatchHistEt->Draw("e");
0207 myCanvas->cd(2);
0208 EtHistEt->Draw("e");
0209 myCanvas->cd(3);
0210 IHcalHistEt->Draw("e");
0211 myCanvas->cd(4);
0212 PixMatchHistEt->Draw("e");
0213 myCanvas->cd(5);
0214 EoverpHistEt->Draw("e");
0215 myCanvas->cd(6);
0216 ItrackHistEt->Draw("e");
0217 myCanvas->Print("images/EffVEtSE.gif");
0218 myCanvas->cd(1);
0219 l1MatchHistEta->Draw("e");
0220 myCanvas->cd(2);
0221 EtHistEta->Draw("e");
0222 myCanvas->cd(3);
0223 IHcalHistEta->Draw("e");
0224 myCanvas->cd(4);
0225 PixMatchHistEta->Draw("e");
0226 myCanvas->cd(5);
0227 EoverpHistEta->Draw("e");
0228 myCanvas->cd(6);
0229 ItrackHistEta->Draw("e");
0230 myCanvas->Print("images/EffVEtaSE.gif");
0231 myCanvas->cd(1);
0232 l1MatchHistPhi->Draw("e");
0233 myCanvas->cd(2);
0234 EtHistPhi->Draw("e");
0235 myCanvas->cd(3);
0236 IHcalHistPhi->Draw("e");
0237 myCanvas->cd(4);
0238 PixMatchHistPhi->Draw("e");
0239 myCanvas->cd(5);
0240 EoverpHistPhi->Draw("e");
0241 myCanvas->cd(6);
0242 ItrackHistPhi->Draw("e");
0243 myCanvas->Print("images/EffVPhiSE.gif");
0244
0245 file->Close();
0246 gROOT->Reset();
0247 }