Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:52

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