File indexing completed on 2024-04-06 12:18:59
0001
0002 #include <string>
0003 #include <vector>
0004 #include <map>
0005 #include <iostream>
0006
0007 using namespace std;
0008
0009
0010 #include <TH1D.h>
0011 #include <TFile.h>
0012 #include <TCanvas.h>
0013 #include <TStyle.h>
0014 #include <TError.h>
0015
0016
0017 #include "EffPullCalculator.cc"
0018 #include "CompHisto1D.cc"
0019 #include "JetMETComp.cc"
0020
0021 void printhelp() {
0022 cout << "triggerComparison inputs:" << endl;
0023 cout << " -File1 -> Name of first root file" << endl;
0024 cout << " -File2 -> Name of second root file" << endl;
0025 cout << " -OutputFile -> Name of the output root file" << endl;
0026 cout << " (default trigger_validation.root)" << endl;
0027 cout << " --correlated -> Use 100% correlated error for efficiency difference" << endl;
0028 cout << " --oldL1names -> Use A_ rather than L1_ for L1 paths" << endl;
0029 cout << " --useL1objets -> Use L1 objects for shape comparison" << endl;
0030 cout << " --help -> Print this output" << endl;
0031 cout << "Example: ./triggerComparison.x -File1=fil1.root -File2=file2.root" << endl;
0032 }
0033
0034 void WriteEffEps(vector<TH1D*> effhistos, string label1, string label2) {
0035 TCanvas* c1 = new TCanvas("c1","c1",300,300);
0036 c1->SetLeftMargin(0.25);
0037 c1->SetRightMargin(0.20);
0038 c1->SetFillColor(0);
0039 c1->SetHighLightColor(0);
0040 c1->SetBorderMode(0);
0041 for(int i=0; i< int(effhistos.size())/2; i++) {
0042 effhistos[i]->SetMaximum(1.);
0043 effhistos[i]->Draw("hbar2");
0044 effhistos[i+effhistos.size()/2]->Draw("hbar2same");
0045 TLegend* legend = new TLegend(0.81,0.75,0.99,0.95);
0046 legend->AddEntry(effhistos[i],label1.c_str(),"f");
0047 legend->AddEntry(effhistos[i+effhistos.size()/2],label2.c_str(),"f");
0048 legend->Draw();
0049 c1->SaveAs((string(effhistos[i]->GetName())+".eps").c_str());
0050 }
0051 }
0052
0053 void WriteEffEps(TH1D* pullhisto, TH1D* reshisto) {
0054 TCanvas* c1 = new TCanvas("c1","c1",300,300);
0055 c1->SetLeftMargin(0.20);
0056 c1->SetFillColor(0);
0057 c1->SetHighLightColor(0);
0058 c1->SetBorderMode(0);
0059 c1->SetBottomMargin(0.25);
0060 pullhisto->Draw();
0061 c1->SaveAs((string(pullhisto->GetName())+".eps").c_str());
0062
0063 c1 = new TCanvas("c1","c1",900,300);
0064 c1->SetLeftMargin(0.20);
0065 c1->SetFillColor(0);
0066 c1->SetHighLightColor(0);
0067 c1->SetBorderMode(0);
0068 c1->SetBottomMargin(0.35);
0069 reshisto->Draw();
0070 c1->SaveAs((string(reshisto->GetName())+".eps").c_str());
0071 }
0072
0073 int main(int argc, char *argv[]){
0074 if (argc<3) {
0075 printhelp();
0076 return 0;
0077 }
0078
0079 gErrorIgnoreLevel = 2001;
0080
0081 cout << "aaaaaaaaaaaaaaaaaaaa" << endl;
0082
0083 string file1name, file2name;
0084 string outputfilename("trigger_validation.root");
0085 char inputstr[256];
0086 bool oldl1name = false;
0087 bool usel1obj = false;
0088 string error = "uncorrelated";
0089 for (int i=1;i<argc;i++){
0090 if (strncmp(argv[i],"-",1)==0){
0091 if (strncmp(argv[i],"--correlated",12)==0) error = "correlated";
0092 if (strncmp(argv[i],"--useL1objets",13)==0) usel1obj = true;
0093 if (strncmp(argv[i],"--oldL1names",12)==0) oldl1name = true;
0094 if (strncmp(argv[i],"-help",4)==0) {printhelp(); return 0;}
0095 if (strncmp(argv[i],"-File1",6)==0) {
0096 sscanf(argv[i],"-File1=%s",inputstr);
0097 file1name = string(inputstr,strlen(argv[i]));
0098 }
0099 if (strncmp(argv[i],"-File2",6)==0) {
0100 sscanf(argv[i],"-File2=%s",inputstr);
0101 file2name = string(inputstr,strlen(argv[i]));
0102 }
0103 if (strncmp(argv[i],"-OutputFile",11)==0) {
0104 sscanf(argv[i],"-OutputFile=%s",inputstr);
0105 outputfilename = string(inputstr,strlen(argv[i]));
0106 }
0107 }
0108 }
0109
0110 cout << "bbbbbbbbbbbbbbbbbbbbbbb" << endl;
0111 vector<TFile*> files;
0112 files.push_back(new TFile(file1name.c_str()));
0113 files.push_back(new TFile(file2name.c_str()));
0114
0115 TH1D* L1effhisto1;
0116 TH1D* L1effhisto2;
0117 TH1D* L1pullhisto;
0118 TH1D* L1reshisto;
0119
0120 TH1D* HLTeffhisto1;
0121 TH1D* HLTeffhisto2;
0122 TH1D* HLTpullhisto;
0123 TH1D* HLTreshisto;
0124
0125 vector<TH1D*> L1effhistos;
0126 vector<TH1D*> HLTeffhistos;
0127
0128 string label1 = file1name.erase(file1name.find("/"),file1name.size()-file1name.find("/"));
0129 string label2 = file2name.erase(file2name.find("/"),file2name.size()-file2name.find("/"));
0130
0131 cout << "cccccccccccccccc" << endl;
0132 for (int i=1;i<argc;i++){
0133 if (strncmp(argv[i],"-",1)==0){
0134 if (strncmp(argv[i],"-label1",7)==0) {
0135 sscanf(argv[i],"-label1=%s",inputstr);
0136 label1 = string(inputstr,strlen(argv[i]));
0137 }
0138 if (strncmp(argv[i],"-label2",7)==0) {
0139 sscanf(argv[i],"-label2=%s",inputstr);
0140 label2 = string(inputstr,strlen(argv[i]));
0141 }
0142 }
0143 }
0144
0145 cout << "ddddddddddddddddddddd" << endl;
0146
0147 L1effhisto1 = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1Paths");
0148 L1effhisto2 = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1Paths");
0149 HLTeffhisto1 = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/HltPaths");
0150 HLTeffhisto2 = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/HltPaths");
0151
0152 vector<TH1D*> L1sortedhistos1; L1sortedhistos1.resize(7);
0153 vector<TH1D*> L1sortedhistos2; L1sortedhistos2.resize(7);
0154 vector<TH1D*> Hltsortedhistos1; Hltsortedhistos1.resize(8);
0155 vector<TH1D*> Hltsortedhistos2; Hltsortedhistos2.resize(8);
0156 L1sortedhistos1[0] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_Mu");
0157 L1sortedhistos1[1] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_EG");
0158 L1sortedhistos1[2] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_Jet");
0159 L1sortedhistos1[3] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_ETM_ETT_HTT");
0160 L1sortedhistos1[4] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_TauJet");
0161 L1sortedhistos1[5] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_XTrigger");
0162 L1sortedhistos1[6] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_Overflow");
0163 L1sortedhistos2[0] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_Mu");
0164 L1sortedhistos2[1] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_EG");
0165 L1sortedhistos2[2] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_Jet");
0166 L1sortedhistos2[3] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_ETM_ETT_HTT");
0167 L1sortedhistos2[4] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_TauJet");
0168 L1sortedhistos2[5] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_XTrigger");
0169 L1sortedhistos2[6] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/L1_Overflow");
0170 Hltsortedhistos1[0] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Mu");
0171 Hltsortedhistos1[1] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Ele");
0172 Hltsortedhistos1[2] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Jet");
0173 Hltsortedhistos1[3] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Photon");
0174 Hltsortedhistos1[4] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_MET_HT");
0175 Hltsortedhistos1[5] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Tau_BTag");
0176 Hltsortedhistos1[6] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_XTrigger");
0177 Hltsortedhistos1[7] = (TH1D*) files[0]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Overflow");
0178 Hltsortedhistos2[0] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Mu");
0179 Hltsortedhistos2[1] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Ele");
0180 Hltsortedhistos2[2] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Jet");
0181 Hltsortedhistos2[3] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Photon");
0182 Hltsortedhistos2[4] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_MET_HT");
0183 Hltsortedhistos2[5] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Tau_BTag");
0184 Hltsortedhistos2[6] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_XTrigger");
0185 Hltsortedhistos2[7] = (TH1D*) files[1]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/TriggerBits/Hlt_Overflow");
0186
0187 cout << "eeeeeeeeeeeeeeeee" << endl;
0188
0189 EffPullcalculator* HLTpullcal = new EffPullcalculator(HLTeffhisto1,HLTeffhisto2,Hltsortedhistos1,Hltsortedhistos2,error);
0190 HLTpullcal->CalculatePulls();cout<<"!!!!!\n";
0191 HLTpullhisto = HLTpullcal->GetPullHisto();
0192 HLTreshisto = HLTpullcal->GetResidualHisto();
0193 HLTeffhistos = HLTpullcal->GetEffHistos();
0194 HLTpullcal->WriteLogFile("HLTcomparison.log");
0195
0196 cout << "ffffffffffffffff" << endl;
0197 EffPullcalculator* L1pullcal = new EffPullcalculator(L1effhisto1,L1effhisto2,L1sortedhistos1,L1sortedhistos2,error);
0198 L1pullcal->CalculatePulls();
0199 L1pullhisto = L1pullcal->GetPullHisto();
0200 L1reshisto = L1pullcal->GetResidualHisto();
0201 L1effhistos = L1pullcal->GetEffHistos();
0202
0203 cout << "ggggggggggggggg" << endl;
0204 L1pullcal->WriteLogFile("L1comparison.log");
0205
0206
0207
0208
0209 TFile* outfile = new TFile(outputfilename.c_str(),"recreate");
0210
0211
0212
0213
0214
0215 L1pullhisto->Write();
0216 L1reshisto->Write();
0217 HLTpullhisto->Write();
0218 HLTreshisto->Write();
0219 cout << "hhhhhhhhhhhhhhhhhhh" << endl;
0220
0221 for(int ih=0; ih<int(L1effhistos.size()); ih++)
0222 L1effhistos[ih]->Write();
0223 for(int ih=0; ih<int(HLTeffhistos.size()); ih++)
0224 HLTeffhistos[ih]->Write();
0225
0226
0227
0228
0229 cout << "iiiiiiiiiiiiiiiii" << endl;
0230 WriteEffEps(L1effhistos,label1,label2);
0231 WriteEffEps(HLTeffhistos,label1,label2);
0232
0233
0234 outfile->Close();
0235
0236 cout << "lllllllllllllllllll" << endl;
0237
0238
0239
0240
0241
0242 vector<TH1D*> inputhisto;
0243 vector<TCanvas*> compcanvas;
0244 map<string,double> compatibility;
0245
0246 string obj = "Reco";
0247 if(usel1obj == true) obj = "L1";
0248
0249 cout << "mmmmmmmmmmmmmmmmmmmmm" << endl;
0250 for(int ifile=0; ifile<2; ifile++) {
0251
0252 if(usel1obj == false) {
0253 inputhisto.push_back((TH1D*) files[ifile]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/RecoJets/General/JetMult"));
0254 inputhisto.push_back((TH1D*) files[ifile]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/RecoMuons/General/MuonMult"));
0255 inputhisto.push_back((TH1D*) files[ifile]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/RecoElectrons/General/ElecMult"));
0256 inputhisto.push_back((TH1D*) files[ifile]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/RecoPhotons/General/PhotonMult"));
0257 inputhisto.push_back((TH1D*) files[ifile]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/RecoMET/General/MET"));
0258 } else {
0259 inputhisto.push_back((TH1D*) files[ifile]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/L1Jets/General/JetMult"));
0260 inputhisto.push_back((TH1D*) files[ifile]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/L1Muons/General/MuonMult"));
0261 inputhisto.push_back((TH1D*) files[ifile]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/L1Em/General/ElecMult"));
0262 inputhisto.push_back((TH1D*) files[ifile]->Get("DQMData/Run 1/HLT/Run summary/SusyExo/L1MET/General/MET"));
0263 }
0264
0265 cout << "nnnnnnnnnnnnnnnnnnnnnn" << endl;
0266
0267 TAxis* axis = L1reshisto->GetXaxis();
0268 for(int i=1; i<L1reshisto->GetNbinsX(); i++) {
0269 string label = axis->GetBinLabel(i);
0270
0271 if(L1pullcal->GetEff(label,0) > 0.3 &&
0272 L1pullcal->GetEff(label,1) > 0.3) {
0273 if(usel1obj == false) {
0274 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/RecoJets/L1/JetMult_"+label).c_str()));
0275 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/RecoMuons/L1/MuonMult_"+label).c_str()));
0276 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/RecoElectrons/L1/ElecMult_"+label).c_str()));
0277 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/RecoPhotons/L1/PhotonMult_"+label).c_str()));
0278 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/RecoMET/L1/MET_"+label).c_str()));
0279 } else {
0280 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/L1Jets/L1/JetMult_"+label).c_str()));
0281 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/L1Muons/L1/MuonMult_"+label).c_str()));
0282 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/L1Em/L1/ElecMult_"+label).c_str()));
0283 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/L1MET/L1/MET_"+label).c_str()));
0284 }
0285 }
0286 }
0287
0288 cout << "ooooooooooooooooooooooo" << endl;
0289
0290 axis = HLTreshisto->GetXaxis();
0291 for(int i=1; i<HLTreshisto->GetNbinsX(); i++) {
0292 string label = axis->GetBinLabel(i);
0293
0294 if(HLTpullcal->GetEff(label,0) > 0.3 &&
0295 HLTpullcal->GetEff(label,1) > 0.3) {
0296 if(usel1obj == false) {
0297 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/RecoJets/HLT/JetMult_"+label).c_str()));
0298 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/RecoMuons/HLT/MuonMult_"+label).c_str()));
0299 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/RecoElectrons/HLT/ElecMult_"+label).c_str()));
0300 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/RecoPhotons/HLT/PhotonMult_"+label).c_str()));
0301 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/RecoMET/HLT/MET_"+label).c_str()));
0302 } else {
0303 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/L1Jets/HLT/JetMult_"+label).c_str()));
0304 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/L1Muons/HLT/MuonMult_"+label).c_str()));
0305 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/L1Em/HLT/ElecMult_"+label).c_str()));
0306 inputhisto.push_back((TH1D*) files[ifile]->Get(("DQMData/Run 1/HLT/Run summary/SusyExo/L1MET/HLT/MET_"+label).c_str()));
0307 }
0308 }
0309 }
0310 }
0311
0312 cout << "pppppppppppppppppp" << endl;
0313 for(int i=0; i<int(inputhisto.size()/2); i++) {
0314 cout << "loop CompHisto 1" << endl;
0315 CompHisto1D* compare = new CompHisto1D(inputhisto[i],inputhisto[i+inputhisto.size()/2]);
0316 cout << "loop CompHisto 2" << endl;
0317 compare->SetLabel1(label1);
0318 cout << "loop CompHisto 3" << endl;
0319 compare->SetLabel2(label2);
0320 cout << "loop CompHisto 4" << endl;
0321 cout << "inputhisto[i]->GetName() = " << endl;
0322 cout << "inputhisto[i]->GetName() = " << inputhisto[i]->GetName() << endl;
0323 compatibility.insert(std::make_pair(string(inputhisto[i]->GetName()),compare->Compare()));
0324 cout << "loop CompHisto 5" << endl;
0325 compare->SaveAsEps();
0326 cout << "loop CompHisto 6" << endl;
0327 }
0328
0329 cout << "qqqqqqqqqqqqqqqqqqqq" << endl;
0330
0331 JetMETComp* jetmetcomp = new JetMETComp(compatibility);
0332
0333 if (oldl1name == true) {
0334 jetmetcomp->MakePlot("ElecMult_A");
0335 jetmetcomp->MakePlot("MuonMult_A");
0336 jetmetcomp->MakePlot("PhotonMult_A");
0337 jetmetcomp->MakePlot("JetMult_A");
0338 jetmetcomp->MakePlot("MET_A");
0339 } else {
0340 jetmetcomp->MakePlot("ElecMult_L1");
0341 jetmetcomp->MakePlot("MuonMult_L1");
0342 jetmetcomp->MakePlot("PhotonMult_L1");
0343 jetmetcomp->MakePlot("JetMult_L1");
0344 jetmetcomp->MakePlot("MET_L1");
0345 }
0346
0347 jetmetcomp->MakePlot("ElecMult_HLT");
0348 jetmetcomp->MakePlot("MuonMult_HLT");
0349 jetmetcomp->MakePlot("PhotonMult_HLT");
0350 jetmetcomp->MakePlot("JetMult_HLT");
0351 jetmetcomp->MakePlot("MET_HLT");
0352 jetmetcomp->WriteFile();
0353 cout << "rrrrrrrrrrrrrrrrrr" << endl;
0354
0355 }