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