Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:32:12

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