Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:56

0001 // Commands executed in a GLOBAL scope, e.g. created hitograms aren't erased...
0002 #include "TH1.h"
0003 #include "TH2.h"
0004 #include "TLegend.h"
0005 #include "TCanvas.h"
0006 #include "TProfile.h"
0007 #include "TPaveStats.h"
0008 #include "TFile.h"
0009 #include "TString.h"
0010 #include "TList.h"
0011 #include "TStyle.h"
0012 #include "TClass.h"
0013 #include "TKey.h"
0014 #include "TDirectory.h"
0015 
0016 #include <cstdio>
0017 #include <string>
0018 #include <iostream>
0019 
0020 #include "rootlogon.h"
0021 
0022 TDirectory *fileDirectory(TDirectory *target, std::string s);
0023 void SinglePi(const TString ref_vers = "330pre6", const TString val_vers = "330pre6", bool fastsim = false);
0024 
0025 int main(int argn, char **argv) {
0026   if (argn == 3)
0027     SinglePi(argv[1], argv[2]);
0028   else if (argn == 4)
0029     SinglePi(argv[1], argv[2], strcmp(argv[3], "fastsim") == 0);
0030   else
0031     printf("Usage: ./SinglePi.exe ref_ver val_ver [fastsim]\n");
0032 }
0033 
0034 void SinglePi(const TString ref_vers, const TString val_vers, bool fastsim) {
0035   //Warning!!! This rootlogon hacks the root color pallate
0036   setColors();
0037 
0038   TString ref_file = "pi50scan" + ref_vers + "_ECALHCAL_CaloTowers.root";
0039   TString val_file = "pi50scan" + val_vers + "_ECALHCAL_CaloTowers.root";
0040 
0041   TFile f1(ref_file);
0042   TFile f2(val_file);
0043 
0044   // service variables
0045   //
0046   //Profiles
0047   const int Nprof = 24;
0048 
0049   TProfile *f1_prof[Nprof];
0050   TProfile *f2_prof[Nprof];
0051 
0052   char labelp[Nprof][64];
0053 
0054   //1D Histos
0055   const int Nhist1 = 25;
0056 
0057   TH1 *f1_hist1[Nhist1];
0058   TH1 *f2_hist1[Nhist1];
0059 
0060   char label1[Nhist1][64];
0061 
0062   //Labels
0063   //Profiles
0064   sprintf(labelp[0], "CaloTowersTask_emean_vs_ieta_E1.gif");
0065   sprintf(labelp[1], "CaloTowersTask_emean_vs_ieta_H1.gif");
0066   sprintf(labelp[2], "CaloTowersTask_emean_vs_ieta_EH1.gif");
0067 
0068   sprintf(labelp[3], "RecHitsTask_emean_vs_ieta_E.gif");
0069   sprintf(labelp[4], "RecHitsTask_emean_vs_ieta_H.gif");
0070   sprintf(labelp[5], "RecHitsTask_emean_vs_ieta_EH.gif");
0071   if (!fastsim) {
0072     sprintf(labelp[6], "SimHitsTask_emean_vs_ieta_E.gif");
0073     sprintf(labelp[7], "SimHitsTask_emean_vs_ieta_H.gif");
0074     sprintf(labelp[8], "SimHitsTask_emean_vs_ieta_EH.gif");
0075   }
0076   sprintf(labelp[9], "RecHitsTask_timing_vs_energy_profile_HB.gif");
0077   sprintf(labelp[10], "RecHitsTask_timing_vs_energy_profile_HE.gif");
0078   sprintf(labelp[11], "RecHitsTask_timing_vs_energy_profile_HF.gif");
0079 
0080   sprintf(labelp[12], "RecHitsTask_Chi2_vs_energy_HE.gif");
0081   sprintf(labelp[13], "RecHitsTask_Chi2_vs_energy_HB.gif");
0082 
0083   sprintf(labelp[14], "CaloTowersTask_emean_vs_ieta_E.gif");
0084   sprintf(labelp[15], "CaloTowersTask_emean_vs_ieta_H.gif");
0085   sprintf(labelp[16], "CaloTowersTask_emean_vs_ieta_EH.gif");
0086 
0087   sprintf(labelp[17], "PFClustersTask_emean_vs_eta_E.gif");
0088   sprintf(labelp[18], "PFClustersTask_emean_vs_eta_H.gif");
0089   sprintf(labelp[19], "PFClustersTask_emean_vs_eta_EH.gif");
0090   sprintf(labelp[20], "PFClustersTask_emean_vs_eta_HF.gif");
0091   sprintf(labelp[21], "PFClustersTask_emean_vs_eta_HO.gif");
0092   sprintf(labelp[22], "PFClustersTask_emean_vs_eta_EHF.gif");
0093   sprintf(labelp[23], "PFClustersTask_emean_vs_eta_EHFO.gif");
0094 
0095   //1D Histos
0096   sprintf(label1[0], "N_calotowers_HB.gif");
0097   sprintf(label1[1], "N_calotowers_HE.gif");
0098   sprintf(label1[2], "N_calotowers_HF.gif");
0099 
0100   sprintf(label1[3], "RecHits_energy_HB.gif");
0101   sprintf(label1[4], "RecHits_energy_HE.gif");
0102   sprintf(label1[5], "RecHits_energy_HO.gif");
0103   sprintf(label1[6], "RecHits_energy_HF.gif");
0104 
0105   sprintf(label1[7], "Ndigis_HB.gif");
0106   sprintf(label1[8], "Ndigis_HE.gif");
0107   sprintf(label1[9], "Ndigis_HO.gif");
0108   sprintf(label1[10], "Ndigis_HF.gif");
0109 
0110   sprintf(label1[11], "RecHits_Chi2_HE.gif");
0111   sprintf(label1[12], "RecHits_Chi2_HB.gif");
0112 
0113   sprintf(label1[13], "Ratio_Esummed_ECAL_HCAL_0.gif");
0114   sprintf(label1[14], "Ratio_Esummed_ECAL_HCAL_HO_0.gif");
0115   sprintf(label1[15], "Ratio_Esummed_ECAL_HCAL_1.gif");
0116   sprintf(label1[16], "Ratio_Esummed_ECAL_HCAL_HO_1.gif");
0117   sprintf(label1[17], "Ratio_Esummed_ECAL_HCAL_2.gif");
0118   sprintf(label1[18], "Ratio_Esummed_ECAL_HCAL_HO_2.gif");
0119   sprintf(label1[19], "Ratio_Esummed_ECAL_HCAL_3.gif");
0120   sprintf(label1[20], "Ratio_Esummed_ECAL_HCAL_HO_3.gif");
0121   sprintf(label1[21], "Ratio_Esummed_ECAL_HCAL_4.gif");
0122   sprintf(label1[22], "Ratio_Esummed_ECAL_HCAL_HO_4.gif");
0123 
0124   sprintf(label1[23], "Ratio_Esummed_HF_5.gif");
0125   sprintf(label1[24], "Ratio_Esummed_HF_6.gif");
0126 
0127   // REFERENCE FILE
0128 
0129   TDirectory *td = fileDirectory(&f1, "CaloTowersTask");
0130   //f1.cd("DQMData/CaloTowersV/CaloTowersTask");
0131   //gDirectory->pwd();
0132   td->pwd();
0133   f1_prof[0] = (TProfile *)td->Get("emean_vs_ieta_E1");
0134   f1_prof[1] = (TProfile *)td->Get("emean_vs_ieta_H1");
0135   f1_prof[2] = (TProfile *)td->Get("emean_vs_ieta_EH1");
0136 
0137   f1_prof[14] = (TProfile *)td->Get("emean_vs_ieta_E");
0138   f1_prof[15] = (TProfile *)td->Get("emean_vs_ieta_H");
0139   f1_prof[16] = (TProfile *)td->Get("emean_vs_ieta_EH");
0140 
0141   f1_hist1[0] = (TH1 *)td->Get("CaloTowersTask_number_of_fired_towers_HB");
0142   f1_hist1[1] = (TH1 *)td->Get("CaloTowersTask_number_of_fired_towers_HE");
0143   f1_hist1[2] = (TH1 *)td->Get("CaloTowersTask_number_of_fired_towers_HF");
0144 
0145   td = fileDirectory(&f1, "PFClusterV");
0146   f1_prof[17] = (TProfile *)td->Get("emean_vs_eta_E");
0147   f1_prof[18] = (TProfile *)td->Get("emean_vs_eta_H");
0148   f1_prof[19] = (TProfile *)td->Get("emean_vs_eta_EH");
0149   f1_prof[20] = (TProfile *)td->Get("emean_vs_eta_HF");
0150   f1_prof[21] = (TProfile *)td->Get("emean_vs_eta_HO");
0151   f1_prof[22] = (TProfile *)td->Get("emean_vs_eta_EHF");
0152   f1_prof[23] = (TProfile *)td->Get("emean_vs_eta_EHFO");
0153 
0154   f1_hist1[13] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_0");
0155   f1_hist1[14] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_HO_0");
0156   f1_hist1[15] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_1");
0157   f1_hist1[16] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_HO_1");
0158   f1_hist1[17] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_2");
0159   f1_hist1[18] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_HO_2");
0160   f1_hist1[19] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_3");
0161   f1_hist1[20] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_HO_3");
0162   f1_hist1[21] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_4");
0163   f1_hist1[22] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_HO_4");
0164 
0165   f1_hist1[23] = (TH1 *)td->Get("Ratio_Esummed_HF_5");
0166   f1_hist1[24] = (TH1 *)td->Get("Ratio_Esummed_HF_6");
0167 
0168   td = fileDirectory(&f1, "HcalRecHitTask");
0169   //f1.cd("DQMData/HcalRecHitsV/HcalRecHitTask");
0170   f1_prof[3] = (TProfile *)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_E");
0171   f1_prof[4] = (TProfile *)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths");
0172   f1_prof[5] = (TProfile *)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_EH");
0173 
0174   f1_prof[9] = (TProfile *)td->Get("HcalRecHitTask_timing_vs_energy_profile_HB");
0175   f1_prof[10] = (TProfile *)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HE");
0176   f1_prof[11] = (TProfile *)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HF");
0177 
0178   f1_prof[12] = (TProfile *)td->Get("HcalRecHitTask_Log10Chi2_vs_energy_profile_HE");
0179   f1_prof[13] = (TProfile *)td->Get("HcalRecHitTask_Log10Chi2_vs_energy_profile_HB");
0180 
0181   f1_hist1[3] = (TH1 *)td->Get("HcalRecHitTask_energy_of_rechits_HB");
0182   f1_hist1[4] = (TH1 *)td->Get("HcalRecHitTask_energy_of_rechits_HE");
0183   f1_hist1[5] = (TH1 *)td->Get("HcalRecHitTask_energy_of_rechits_HO");
0184   f1_hist1[6] = (TH1 *)td->Get("HcalRecHitTask_energy_of_rechits_HF");
0185 
0186   f1_hist1[11] = (TH1 *)td->Get("HcalRecHitTask_M2Log10Chi2_of_rechits_HE");
0187   f1_hist1[12] = (TH1 *)td->Get("HcalRecHitTask_M2Log10Chi2_of_rechits_HB");
0188 
0189   td = fileDirectory(&f1, "HcalDigiTask");
0190   f1_hist1[7] = (TH1 *)td->Get("HcalDigiTask_Ndigis_HB");
0191   f1_hist1[8] = (TH1 *)td->Get("HcalDigiTask_Ndigis_HE");
0192   f1_hist1[9] = (TH1 *)td->Get("HcalDigiTask_Ndigis_HO");
0193   f1_hist1[10] = (TH1 *)td->Get("HcalDigiTask_Ndigis_HF");
0194 
0195   if (!fastsim) {
0196     td = fileDirectory(&f1, "HcalSimHitTask");
0197     //f1.cd("DQMData/HcalSimHitsV/HcalSimHitTask");
0198     f1_prof[6] = (TProfile *)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_E");
0199     f1_prof[7] = (TProfile *)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths");
0200     f1_prof[8] = (TProfile *)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_EH");
0201   }
0202 
0203   //   NEW FILE
0204 
0205   td = fileDirectory(&f2, "CaloTowersTask");
0206   //f2.cd("DQMData/CaloTowersV/CaloTowersTask");
0207   //gDirectory->pwd();
0208   td->pwd();
0209   f2_prof[0] = (TProfile *)td->Get("emean_vs_ieta_E1");
0210   f2_prof[1] = (TProfile *)td->Get("emean_vs_ieta_H1");
0211   f2_prof[2] = (TProfile *)td->Get("emean_vs_ieta_EH1");
0212 
0213   f2_prof[14] = (TProfile *)td->Get("emean_vs_ieta_E");
0214   f2_prof[15] = (TProfile *)td->Get("emean_vs_ieta_H");
0215   f2_prof[16] = (TProfile *)td->Get("emean_vs_ieta_EH");
0216 
0217   f2_hist1[0] = (TH1 *)td->Get("CaloTowersTask_number_of_fired_towers_HB");
0218   f2_hist1[1] = (TH1 *)td->Get("CaloTowersTask_number_of_fired_towers_HE");
0219   f2_hist1[2] = (TH1 *)td->Get("CaloTowersTask_number_of_fired_towers_HF");
0220 
0221   td = fileDirectory(&f2, "PFClusterV");
0222   f2_prof[17] = (TProfile *)td->Get("emean_vs_eta_E");
0223   f2_prof[18] = (TProfile *)td->Get("emean_vs_eta_H");
0224   f2_prof[19] = (TProfile *)td->Get("emean_vs_eta_EH");
0225   f2_prof[20] = (TProfile *)td->Get("emean_vs_eta_HF");
0226   f2_prof[21] = (TProfile *)td->Get("emean_vs_eta_HO");
0227   f2_prof[22] = (TProfile *)td->Get("emean_vs_eta_EHF");
0228   f2_prof[23] = (TProfile *)td->Get("emean_vs_eta_EHFO");
0229 
0230   f2_hist1[13] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_0");
0231   f2_hist1[14] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_HO_0");
0232   f2_hist1[15] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_1");
0233   f2_hist1[16] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_HO_1");
0234   f2_hist1[17] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_2");
0235   f2_hist1[18] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_HO_2");
0236   f2_hist1[19] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_3");
0237   f2_hist1[20] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_HO_3");
0238   f2_hist1[21] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_4");
0239   f2_hist1[22] = (TH1 *)td->Get("Ratio_Esummed_ECAL_HCAL_HO_4");
0240 
0241   f2_hist1[23] = (TH1 *)td->Get("Ratio_Esummed_HF_5");
0242   f2_hist1[24] = (TH1 *)td->Get("Ratio_Esummed_HF_6");
0243 
0244   td = fileDirectory(&f2, "HcalRecHitTask");
0245   //f2.cd("DQMData/HcalRecHitsV/HcalRecHitTask");
0246   f2_prof[3] = (TProfile *)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_E");
0247   f2_prof[4] = (TProfile *)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths");
0248   f2_prof[5] = (TProfile *)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_EH");
0249 
0250   f2_prof[9] = (TProfile *)td->Get("HcalRecHitTask_timing_vs_energy_profile_HB");
0251   f2_prof[10] = (TProfile *)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HE");
0252   f2_prof[11] = (TProfile *)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HF");
0253 
0254   f2_prof[12] = (TProfile *)td->Get("HcalRecHitTask_Log10Chi2_vs_energy_profile_HE");
0255   f2_prof[13] = (TProfile *)td->Get("HcalRecHitTask_Log10Chi2_vs_energy_profile_HB");
0256 
0257   f2_hist1[3] = (TH1 *)td->Get("HcalRecHitTask_energy_of_rechits_HB");
0258   f2_hist1[4] = (TH1 *)td->Get("HcalRecHitTask_energy_of_rechits_HE");
0259   f2_hist1[5] = (TH1 *)td->Get("HcalRecHitTask_energy_of_rechits_HO");
0260   f2_hist1[6] = (TH1 *)td->Get("HcalRecHitTask_energy_of_rechits_HF");
0261 
0262   f2_hist1[11] = (TH1 *)td->Get("HcalRecHitTask_M2Log10Chi2_of_rechits_HE");
0263   f2_hist1[12] = (TH1 *)td->Get("HcalRecHitTask_M2Log10Chi2_of_rechits_HB");
0264 
0265   td = fileDirectory(&f2, "HcalDigiTask");
0266   f2_hist1[7] = (TH1 *)td->Get("HcalDigiTask_Ndigis_HB");
0267   f2_hist1[8] = (TH1 *)td->Get("HcalDigiTask_Ndigis_HE");
0268   f2_hist1[9] = (TH1 *)td->Get("HcalDigiTask_Ndigis_HO");
0269   f2_hist1[10] = (TH1 *)td->Get("HcalDigiTask_Ndigis_HF");
0270 
0271   if (!fastsim) {
0272     td = fileDirectory(&f2, "HcalSimHitTask");
0273     //f2.cd("DQMData/HcalSimHitsV/HcalSimHitTask");
0274     f2_prof[6] = (TProfile *)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_E");
0275     f2_prof[7] = (TProfile *)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths");
0276     f2_prof[8] = (TProfile *)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_EH");
0277   }
0278 
0279   //Profiles  titles
0280   f1_prof[0]->GetXaxis()->SetTitle("CaloTowers eE (GeV) vs ieta 1 Tower");
0281   f1_prof[1]->GetXaxis()->SetTitle("CaloTowers hE (GeV) vs ieta 1 Tower");
0282   f1_prof[2]->GetXaxis()->SetTitle("CaloTowers eE+hE (GeV) vs ieta 1 Tower");
0283 
0284   f1_prof[3]->GetXaxis()->SetTitle("RecHits eE (GeV) vs ieta R = 0.3 Cone");
0285   f1_prof[4]->GetXaxis()->SetTitle("RecHits hE (GeV) vs ieta R = 0.3 Cone");
0286   f1_prof[5]->GetXaxis()->SetTitle("RecHits eE+hE (GeV) vs ieta R = 0.3 Cone");
0287 
0288   if (!fastsim) {
0289     f1_prof[6]->GetXaxis()->SetTitle("SimHits eE (GeV) vs ieta R = 0.3 Cone");
0290     f1_prof[7]->GetXaxis()->SetTitle("SimHits hE (GeV) vs ieta R = 0.3 Cone");
0291     f1_prof[8]->GetXaxis()->SetTitle("SimHits eE+hE (GeV) vs ieta R = 0.3 Cone");
0292   }
0293 
0294   f1_prof[9]->GetXaxis()->SetTitle("HB RecHits timing (ns) vs Energy (GeV)");
0295   f1_prof[10]->GetXaxis()->SetTitle("HE RecHits timing (ns) vs Energy (GeV)");
0296   f1_prof[11]->GetXaxis()->SetTitle("HF RecHits timing (ns) vs Energy (GeV)");
0297 
0298   f1_prof[12]->GetXaxis()->SetTitle("HE log_10(Chi2) vs Energy (GeV)");
0299   f1_prof[13]->GetXaxis()->SetTitle("HB log_10(Chi2) vs Energy (GeV)");
0300 
0301   f1_prof[14]->GetXaxis()->SetTitle("CaloTowers eE Rcone sum (GeV) vs ieta");
0302   f1_prof[15]->GetXaxis()->SetTitle("CaloTowers hE Rcone sum (GeV) vs ieta");
0303   f1_prof[16]->GetXaxis()->SetTitle("CaloTowers eE+hE Rcone sum (GeV) vs ieta ");
0304 
0305   f1_prof[17]->GetXaxis()->SetTitle("PFClusters eE (GeV) vs eta");
0306   f1_prof[18]->GetXaxis()->SetTitle("PFClusters hE (GeV) vs eta");
0307   f1_prof[19]->GetXaxis()->SetTitle("PFClusters eE+hE (GeV) vs eta");
0308   f1_prof[20]->GetXaxis()->SetTitle("PFClusters hfE (GeV) vs eta");
0309   f1_prof[21]->GetXaxis()->SetTitle("PFClusters hoE (GeV) vs eta");
0310   f1_prof[22]->GetXaxis()->SetTitle("PFClusters eE+hE+hfE (GeV) vs eta");
0311   f1_prof[23]->GetXaxis()->SetTitle("PFClusters eE+hE+hfE+hoE (GeV) vs eta");
0312 
0313   //1D Histos titles
0314   f1_hist1[0]->GetXaxis()->SetTitle("Number of HB CaloTowers");
0315   f1_hist1[1]->GetXaxis()->SetTitle("Number of HE CaloTowers");
0316   f1_hist1[2]->GetXaxis()->SetTitle("Number of HF CaloTowers");
0317 
0318   f1_hist1[3]->GetXaxis()->SetTitle("HB RecHits energy (GeV)");
0319   f1_hist1[4]->GetXaxis()->SetTitle("HE RecHits energy (GeV)");
0320   f1_hist1[5]->GetXaxis()->SetTitle("HO RecHits energy (GeV)");
0321   f1_hist1[6]->GetXaxis()->SetTitle("HF RecHits energy (GeV)");
0322 
0323   f1_hist1[7]->GetXaxis()->SetTitle("N_HB Digis");
0324   f1_hist1[8]->GetXaxis()->SetTitle("N_HE Digis");
0325   f1_hist1[9]->GetXaxis()->SetTitle("N_H0 Digis");
0326   f1_hist1[10]->GetXaxis()->SetTitle("N_HF Digis");
0327 
0328   f1_hist1[11]->GetXaxis()->SetTitle("HE log_10(Chi2)");
0329   f1_hist1[12]->GetXaxis()->SetTitle("HB log_10(Chi2)");
0330 
0331   f1_hist1[13]->GetXaxis()->SetTitle("Esummed/Egen_ECAL+HCAL_0");
0332   f1_hist1[14]->GetXaxis()->SetTitle("Esummed/Egen_ECAL+HCAL+HO_0");
0333   f1_hist1[15]->GetXaxis()->SetTitle("Esummed/Egen_ECAL+HCAL_1");
0334   f1_hist1[16]->GetXaxis()->SetTitle("Esummed/Egen_ECAL+HCAL+HO_1");
0335   f1_hist1[17]->GetXaxis()->SetTitle("Esummed/Egen_ECAL+HCAL_2");
0336   f1_hist1[18]->GetXaxis()->SetTitle("Esummed/Egen_ECAL+HCAL+HO_2");
0337   f1_hist1[19]->GetXaxis()->SetTitle("Esummed/Egen_ECAL+HCAL_3");
0338   f1_hist1[20]->GetXaxis()->SetTitle("Esummed/Egen_ECAL+HCAL+HO_3");
0339   f1_hist1[21]->GetXaxis()->SetTitle("Esummed/Egen_ECAL+HCAL_4");
0340   f1_hist1[22]->GetXaxis()->SetTitle("Esummed/Egen_ECAL+HCAL+HO_4");
0341 
0342   f1_hist1[23]->GetXaxis()->SetTitle("Esummed/Egen_HF_5");
0343   f1_hist1[24]->GetXaxis()->SetTitle("Esummed/Egen_HF_6");
0344 
0345   // CaloTowers 1
0346   f1_prof[0]->SetMaximum(20.);
0347   f1_prof[1]->SetMaximum(40.);
0348   f1_prof[2]->SetMaximum(40.);
0349   f1_prof[0]->SetMinimum(0.);  // idem
0350   f1_prof[1]->SetMinimum(0.);
0351   f1_prof[2]->SetMinimum(0.);
0352 
0353   //  RecHits R==0.3
0354   f1_prof[3]->SetMaximum(30.);  // 60 for Phase2, 30 for Run3
0355   f1_prof[4]->SetMaximum(60.);
0356   f1_prof[5]->SetMaximum(80.);  //  100 for Phase2
0357   f1_prof[3]->SetMinimum(0.);
0358   f1_prof[4]->SetMinimum(0.);
0359   f1_prof[5]->SetMinimum(0.);
0360 
0361   if (!fastsim) {  // SimHits R=0.3
0362     f1_prof[6]->SetMinimum(0.);
0363     f1_prof[7]->SetMinimum(0.);
0364     f1_prof[8]->SetMinimum(0.);
0365     f1_prof[6]->SetMaximum(20.);
0366     f1_prof[7]->SetMaximum(50.);
0367     f1_prof[8]->SetMaximum(60.);
0368   }
0369 
0370   f1_prof[9]->SetMinimum(-25.);  // RecHits Timing
0371   f1_prof[10]->SetMinimum(-25.);
0372   f1_prof[11]->SetMinimum(-25.);
0373   f1_prof[9]->SetMaximum(25.);
0374   f1_prof[10]->SetMaximum(25.);
0375   f1_prof[11]->SetMaximum(25.);
0376 
0377   // CaloTowers R=0.3 added
0378   f1_prof[14]->SetMaximum(50.);  // 50 for Phase2
0379   f1_prof[15]->SetMaximum(60.);
0380   f1_prof[16]->SetMaximum(80.);  // 80 for Phase2
0381   f1_prof[14]->SetMinimum(0.);
0382   f1_prof[15]->SetMinimum(0.);
0383   f1_prof[16]->SetMinimum(0.);
0384 
0385   f1_prof[9]->GetXaxis()->SetRangeUser(0., 75.);
0386   f1_prof[10]->GetXaxis()->SetRangeUser(0., 75.);
0387   f1_prof[11]->GetXaxis()->SetRangeUser(0., 75.);
0388 
0389   f1_prof[12]->GetXaxis()->SetRangeUser(0., 50.);  // Chi2
0390   f1_prof[12]->SetMinimum(-1.0);
0391   f1_prof[12]->SetMaximum(1.0);
0392 
0393   f1_prof[13]->GetXaxis()->SetRangeUser(0., 50.);  // Chi2
0394   f1_prof[13]->SetMinimum(-1.0);
0395   f1_prof[13]->SetMaximum(1.0);
0396 
0397   f1_prof[17]->SetMaximum(20.);  // PFClusters 1
0398   f1_prof[18]->SetMaximum(55.);
0399   f1_prof[19]->SetMaximum(55.);
0400   f1_prof[17]->SetMinimum(0.);  // idem
0401   f1_prof[18]->SetMinimum(0.);
0402   f1_prof[19]->SetMinimum(0.);
0403 
0404   f1_prof[20]->SetMaximum(55.);  // PFClusters 2
0405   f1_prof[21]->SetMaximum(1.);
0406   f1_prof[22]->SetMaximum(55.);
0407   f1_prof[23]->SetMaximum(55.);
0408   f1_prof[20]->SetMinimum(0.);  // idem
0409   f1_prof[21]->SetMinimum(0.);
0410   f1_prof[22]->SetMinimum(0.);
0411   f1_prof[23]->SetMaximum(70.);
0412   f1_prof[23]->SetMinimum(0.);
0413 
0414   //   1D HISTOS
0415 
0416   f1_hist1[0]->GetXaxis()->SetRangeUser(0., 2000.);  // N_CaloTowers
0417   f2_hist1[0]->GetXaxis()->SetRangeUser(0., 2000.);
0418 
0419   f1_hist1[1]->GetXaxis()->SetRangeUser(0., 500.);
0420   f2_hist1[1]->GetXaxis()->SetRangeUser(0., 500.);
0421 
0422   f1_hist1[2]->GetXaxis()->SetRangeUser(0., 500.);
0423   f2_hist1[2]->GetXaxis()->SetRangeUser(0., 500.);
0424 
0425   f1_hist1[3]->GetXaxis()->SetRangeUser(0., 100.);  // RecHits spectra
0426   f2_hist1[3]->GetXaxis()->SetRangeUser(0., 100.);
0427 
0428   f1_hist1[4]->GetXaxis()->SetRangeUser(0., 100.);
0429   f2_hist1[4]->GetXaxis()->SetRangeUser(0., 100.);
0430 
0431   f1_hist1[5]->GetXaxis()->SetRangeUser(0., 100.);
0432   f2_hist1[5]->GetXaxis()->SetRangeUser(0., 100.);
0433 
0434   f1_hist1[6]->GetXaxis()->SetRangeUser(0., 100.);
0435   f2_hist1[6]->GetXaxis()->SetRangeUser(0., 100.);
0436 
0437   f1_hist1[3]->SetMaximum(1.e9);
0438   f2_hist1[3]->SetMaximum(1.e9);
0439   f1_hist1[4]->SetMaximum(1.e9);
0440   f2_hist1[4]->SetMaximum(1.e9);
0441   f1_hist1[5]->SetMaximum(1.e8);
0442   f1_hist1[6]->SetMaximum(1.e8);
0443 
0444   f1_hist1[7]->GetXaxis()->SetRangeUser(0., 1000);  // N_Digis
0445   f2_hist1[7]->GetXaxis()->SetRangeUser(0., 1000);
0446 
0447   f1_hist1[8]->GetXaxis()->SetRangeUser(0., 200);
0448   f2_hist1[8]->GetXaxis()->SetRangeUser(0., 200);
0449 
0450   f1_hist1[9]->GetXaxis()->SetRangeUser(0., 100);
0451   f2_hist1[9]->GetXaxis()->SetRangeUser(0., 100);
0452 
0453   f1_hist1[10]->GetXaxis()->SetRangeUser(0., 3500);
0454   f2_hist1[10]->GetXaxis()->SetRangeUser(0., 3500);
0455 
0456   //   gStyle->SetErrorX(0);
0457 
0458   //  1D-histo
0459 
0460   for (int i = 0; i < Nhist1; i++) {
0461     TCanvas *myc = new TCanvas("myc", "", 800, 600);
0462     gStyle->SetOptStat(1111);
0463 
0464     if ((i > 2 && i < 7) || (i >= 11 && i <= 12))
0465       myc->SetLogy();
0466 
0467     f1_hist1[i]->SetStats(kTRUE);  // stat box
0468     f2_hist1[i]->SetStats(kTRUE);
0469 
0470     f1_hist1[i]->SetTitle("");
0471     f2_hist1[i]->SetTitle("");
0472 
0473     f1_hist1[i]->SetLineWidth(2);
0474     f2_hist1[i]->SetLineWidth(2);
0475 
0476     // diffferent histo colors and styles
0477     f1_hist1[i]->SetLineColor(41);
0478     f1_hist1[i]->SetLineStyle(1);
0479 
0480     f2_hist1[i]->SetLineColor(43);
0481     f2_hist1[i]->SetLineStyle(2);
0482 
0483     //Set maximum to the larger of the two
0484     if (f1_hist1[i]->GetMaximum() < f2_hist1[i]->GetMaximum())
0485       f1_hist1[i]->SetMaximum(1.05 * f2_hist1[i]->GetMaximum());
0486 
0487     TLegend *leg = new TLegend(0.2, 0.91, 0.6, 0.99, "", "brNDC");
0488 
0489     leg->SetBorderSize(2);
0490     //  leg->SetFillColor(51); // see new color definition above
0491     leg->SetFillStyle(1001);  //
0492     leg->AddEntry(f1_hist1[i], "CMSSW_" + ref_vers, "l");
0493     leg->AddEntry(f2_hist1[i], "CMSSW_" + val_vers, "l");
0494 
0495     TPaveStats *ptstats = new TPaveStats(0.85, 0.86, 0.98, 0.98, "brNDC");
0496     ptstats->SetTextColor(41);
0497     f1_hist1[i]->GetListOfFunctions()->Add(ptstats);
0498     ptstats->SetParent(f1_hist1[i]->GetListOfFunctions());
0499     TPaveStats *ptstats2 = new TPaveStats(0.85, 0.74, 0.98, 0.86, "brNDC");
0500     ptstats2->SetTextColor(43);
0501     f2_hist1[i]->GetListOfFunctions()->Add(ptstats2);
0502     ptstats2->SetParent(f2_hist1[i]->GetListOfFunctions());
0503 
0504     f1_hist1[i]->Draw("");  // "stat"
0505     f2_hist1[i]->Draw("hist sames");
0506 
0507     leg->Draw();
0508 
0509     myc->SaveAs(label1[i]);
0510 
0511     if (myc)
0512       delete myc;
0513 
0514     std::cout << "1D histos " << i << " produced" << std::endl;
0515   }
0516 
0517   //  Profiles
0518   for (int i = 0; i < Nprof; i++) {
0519     TCanvas *myc = new TCanvas("myc", "", 800, 600);
0520 
0521     bool skipHisto = false;
0522     if (fastsim && i >= 6 && i <= 8)
0523       skipHisto = true;  // SimHits to exclude
0524 
0525     if (!skipHisto) {
0526       f1_prof[i]->SetStats(kFALSE);
0527       f2_prof[i]->SetStats(kFALSE);
0528 
0529       f1_prof[i]->SetTitle("");
0530       f2_prof[i]->SetTitle("");
0531 
0532       f1_prof[i]->SetLineColor(41);
0533       f1_prof[i]->SetLineStyle(1);
0534       f1_prof[i]->SetLineWidth(1);
0535       f1_prof[i]->SetMarkerColor(41);
0536       f1_prof[i]->SetMarkerStyle(21);
0537       f1_prof[i]->SetMarkerSize(1.0);
0538 
0539       f2_prof[i]->SetLineColor(43);
0540       f2_prof[i]->SetLineStyle(1);
0541       f2_prof[i]->SetLineWidth(1);
0542       f2_prof[i]->SetMarkerColor(43);
0543       f2_prof[i]->SetMarkerStyle(20);
0544       f2_prof[i]->SetMarkerSize(0.8);
0545 
0546       if (i > 8 && i < 12) {  // Timing
0547         f1_prof[i]->SetMarkerSize(0.1);
0548         f2_prof[i]->SetMarkerSize(0.3);
0549       }
0550 
0551       myc->SetGrid();
0552 
0553       if (i <= 8 || i >= 12) {  // Other than RecHits timing
0554         f1_prof[i]->Draw("histpl ");
0555         f2_prof[i]->Draw("histplsame");  //
0556       } else {
0557         f1_prof[i]->Draw("pl");       // RecHits Timing
0558         f2_prof[i]->Draw("pl same");  //
0559       }
0560 
0561       f1_prof[i]->GetOption();
0562       f2_prof[i]->GetOption();
0563 
0564       TLegend *leg = new TLegend(0.40, 0.91, 0.74, 0.99, "", "brNDC");
0565       leg->SetBorderSize(2);
0566       leg->SetFillStyle(1001);
0567       leg->AddEntry(f1_prof[i], "CMSSW_" + ref_vers, "pl");
0568       leg->AddEntry(f2_prof[i], "CMSSW_" + val_vers, "pl");
0569 
0570       leg->Draw("");
0571 
0572       myc->SaveAs(labelp[i]);
0573     }
0574     if (myc)
0575       delete myc;
0576 
0577     std::cout << "Profile " << i << " produced" << std::endl;
0578   }
0579 
0580   // RATIO CaloTower 1
0581 
0582   TCanvas *myc1 = new TCanvas("myc1", "", 800, 600);
0583 
0584   TProfile *ratio1 = (TProfile *)f2_prof[2]->Clone();
0585   ratio1->Divide(f1_prof[2]);
0586   ratio1->SetMaximum(1.5);
0587   ratio1->SetMinimum(0.5);
0588   myc1->SetGrid();
0589   ratio1->Draw("hist pl");
0590 
0591   TLegend *leg1 = new TLegend(0.20, 0.91, 0.70, 0.99, "", "brNDC");
0592   leg1->SetBorderSize(2);
0593   leg1->SetFillStyle(1001);
0594   leg1->AddEntry(ratio1, "CaloTowers scale (pi50) ratio " + val_vers + "/" + ref_vers + " vs ieta", "pl");
0595   leg1->Draw("");
0596 
0597   myc1->SaveAs("Ratio.gif");
0598 
0599   //  RATIO HCAL RecHits in R=0.3
0600 
0601   TCanvas *myc2 = new TCanvas("myc2", "", 800, 600);
0602 
0603   TProfile *ratio2 = (TProfile *)f2_prof[4]->Clone();
0604   ratio2->Divide(f1_prof[4]);
0605   ratio2->SetMaximum(1.5);
0606   ratio2->SetMinimum(0.5);
0607   myc2->SetGrid();
0608   ratio2->Draw("hist pl");
0609 
0610   TLegend *leg2 = new TLegend(0.10, 0.91, 0.80, 0.99, "", "brNDC");
0611   leg2->SetBorderSize(2);
0612   leg2->SetFillStyle(1001);
0613   leg2->AddEntry(ratio2, "HCAL sum ratio " + val_vers + "/" + ref_vers + " vs ieta", "pl");
0614   leg2->Draw("");
0615 
0616   myc2->SaveAs("Ratio_Hcone.gif");
0617 
0618   // RATIO CaloTowers H sum in R=0.3
0619 
0620   TCanvas *myc3 = new TCanvas("myc3", "", 800, 600);
0621 
0622   TProfile *ratio3 = (TProfile *)f2_prof[15]->Clone();
0623   ratio3->Divide(f1_prof[15]);
0624   ratio3->SetMaximum(1.5);
0625   ratio3->SetMinimum(0.5);
0626   myc3->SetGrid();
0627   ratio3->Draw("hist pl");
0628 
0629   TLegend *leg3 = new TLegend(0.10, 0.91, 0.80, 0.99, "", "brNDC");
0630   leg3->SetBorderSize(2);
0631   leg3->SetFillStyle(1001);
0632   leg3->AddEntry(ratio3, "CaloTowers HAD in R=0.3 ratio " + val_vers + "/" + ref_vers + " vs ieta", "pl");
0633   leg3->Draw("");
0634   myc3->SaveAs("Ratio_CaloTowers_Hcone.gif");
0635 
0636   // close ROOT files ===========================================
0637   //
0638   f1.Close();
0639   f2.Close();
0640 
0641   return;
0642 }
0643 
0644 TDirectory *fileDirectory(TDirectory *target, std::string s) {
0645   TDirectory *retval = 0;
0646 
0647   // loop over all keys in this directory
0648   TIter nextkey(target->GetListOfKeys());
0649   TKey *key, *oldkey = 0;
0650   while ((key = (TKey *)nextkey())) {
0651     //keep only the highest cycle number for each key
0652     if (oldkey && !strcmp(oldkey->GetName(), key->GetName()))
0653       continue;
0654 
0655     // read object from file
0656     target->cd();
0657     TObject *obj = key->ReadObj();
0658 
0659     if (obj->IsA()->InheritsFrom(TDirectory::Class())) {
0660       // it's a subdirectory
0661       //cout << "Found subdirectory " << obj->GetName() << endl;
0662       if (strcmp(s.c_str(), obj->GetName()) == 0)
0663         return (TDirectory *)obj;
0664 
0665       if ((retval = fileDirectory((TDirectory *)obj, s)))
0666         break;
0667 
0668     } else
0669       break;
0670   }
0671   return retval;
0672 }