Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:06

0001 void DoCompare( char* Energy ){
0002 
0003  const int NHisto = 47;
0004  const int NHisto2 = 4;
0005  const int NHisto3 = 2;
0006 
0007  TText* te = new TText();
0008  te->SetTextSize(0.1);
0009  
0010  gROOT->ProcessLine(".x HistoCompare.C");
0011  HistoCompare * myPV = new HistoCompare();
0012 
0013  char*  reffilename  = "${REFFILE}";//"../data/EcalSimHitHisto_30GeV.root";
0014  char*  curfilename  = "${CURFILE}";//"../data/EcalSimHitHisto_30GeV.root";
0015 
0016  TFile * reffile = new TFile(reffilename);
0017  TFile * curfile = new TFile(curfilename);
0018 
0019  //1-Dimension Histogram
0020  char* label[NHisto];
0021  label[0] = "Barrel_E1x1";
0022  label[1] = "Barrel_E2x2";
0023  label[2] = "Barrel_E3x3";
0024  label[3] = "Barrel_E4x4";
0025  label[4] = "Barrel_E5x5";
0026  label[5] = "Barrel_E1OverE4";
0027  label[6] = "Barrel_E4OverE9";
0028  label[7] = "Barrel_E9OverE16";
0029  label[8] = "Barrel_E16OverE25";
0030  label[9] = "Barrel_E1OverE25";
0031  label[10] = "Barrel_E9OverE25";
0032  label[11] = "Ecal_EBOverETotal";
0033  label[12] = "Ecal_EEOverETotal";
0034  label[13] = "Ecal_EPOverETotal";
0035  label[14] = "Ecal_EBEEEPOverETotal";
0036  label[15] = "PreShower_EHit_L1zp";
0037  label[16] = "PreShower_EHit_L2zp";
0038  label[17] = "Preshower_NHit_L1zp";
0039  label[18] = "Preshower_NHit_L2zp";
0040  label[19] = "Endcap_E1x1";
0041  label[20] = "Endcap_E2x2";
0042  label[21] = "Endcap_E3x3";
0043  label[22] = "Endcap_E4x4";
0044  label[23] = "Endcap_E5x5";
0045  label[24] = "Endcap_E1OverE4";
0046  label[25] = "Endcap_E4OverE9";
0047  label[26] = "Endcap_E9OverE16";
0048  label[27] = "Endcap_E16OverE25";
0049  label[28] = "Endcap_E1OverE25";
0050  label[29] = "Endcap_E9OverE25";
0051  label[30] = "PreShower_EHit_L1zm";
0052  label[31] = "PreShower_EHit_L2zm";
0053  label[32] = "Preshower_NHit_L1zm";
0054  label[33] = "Preshower_NHit_L2zm";
0055  label[34] = "Preshower_E1alphaE2_zm";
0056  label[35] = "Preshower_E1alphaE2_zp";
0057  label[36] = "Preshower_E2OverE1_zm";
0058  label[37] = "Preshower_E2OverE1_zp";
0059  label[38] = "Barrel_HitMultiplicity";
0060  label[39] = "Barrel_HitEnergy";
0061  label[40] = "Barrel_CryMultiplicity";
0062  label[41] = "EndcapZPlus_HitMultiplicity";
0063  label[42] = "EndcapZPlus_HitEnergy";
0064  label[43] = "EndcapZPlus_CryMultiplicity";
0065  label[44] = "EndcapZMinus_HitMultiplicity";
0066  label[45] = "EndcapZMinus_HitEnergy";
0067  label[46] = "EndcapZMinus_CryMultiplicity";
0068 
0069 
0070  TH1F* htemp1[NHisto];
0071  TH1F* htemp2[NHisto];
0072  for ( int i = 0; i< NHisto ; i++ ) {
0073    char title[50];
0074    TCanvas c1;
0075    htemp1[i]  = dynamic_cast<TH1F*>(reffile->Get(label[i]));
0076    htemp2[i]  = dynamic_cast<TH1F*>(curfile->Get(label[i]));
0077    if( htemp1[i] == 0 || htemp2[i] == 0) continue;
0078    htemp1[i]->SetLineColor(2);
0079    htemp2[i]->SetLineColor(4);
0080    htemp1[i]->SetLineStyle(3);
0081    htemp2[i]->SetLineStyle(5);
0082    TLegend leg(0.1, 0.15, 0.2, 0.25);
0083    leg.AddEntry(htemp1[i], "Reference", "l");
0084    leg.AddEntry(htemp2[i], "New ", "l");
0085    if (i>14 && i<19 || i>29 && i< 34 || i == 13 || i>37 ) c1.SetLogy();
0086 
0087    htemp1[i]->Draw();
0088    htemp2[i]->Draw("Same"); 
0089    leg.Draw();
0090    myPV->PVCompute(htemp1[i],htemp2[i], te);
0091    sprintf(title,"%s%s%s", Energy, label[i],".eps");
0092    c1.Print(title);
0093  }
0094 
0095  
0096  //2-Dimention Histograms
0097  char* label2[NHisto2];
0098  label2[0] = "Barrel_Longitudinal";
0099  label2[1] = "Barrel_Occupancy";
0100  label2[2] = "Endcap_Longitudinal";
0101  label2[3] = "Endcap_Occupancy";
0102 
0103  TH2F* h2temp1[NHisto2];
0104  TH2F* h2temp2[NHisto2];
0105 
0106  for ( int i = 0; i< NHisto2 ; i++ ) {
0107    char title[50];
0108    TCanvas c1;
0109 
0110    h2temp1[i]  = dynamic_cast<TH2F*>(reffile->Get(label2[i]));
0111    h2temp2[i]  = dynamic_cast<TH2F*>(curfile->Get(label2[i]));
0112    if( h2temp1[i] == 0 || h2temp2[i] == 0) continue; 
0113    if ( i==1 || i==3 ) {
0114       c1.Divide(2,1);
0115       c1.cd(1);
0116       h2temp1[i]->SetMarkerColor(2);
0117       h2temp1[i]->SetMarkerStyle(7);
0118       h2temp1[i]->Draw("COLZ");
0119    
0120       c1.cd(2);
0121       h2temp2[i]->SetMarkerColor(4);
0122       h2temp2[i]->SetMarkerStyle(7);
0123       h2temp2[i]->Draw("COLZ");
0124       myPV->PVCompute(h2temp1[i],h2temp2[i], te);
0125       sprintf(title,"%s%s%s", Energy, label2[i],".eps");
0126       c1.Print(title);
0127     }else {
0128 
0129       h2temp1[i]->SetMarkerColor(2);
0130       h2temp1[i]->SetMarkerStyle(22);
0131       h2temp1[i]->Draw();
0132       h2temp2[i]->SetMarkerColor(4);
0133       h2temp2[i]->SetMarkerStyle(23);
0134       h2temp2[i]->Draw("same");
0135       TLegend leg(0.65, 0.75, 0.75, 0.85);
0136       leg.AddEntry(h2temp1[i], "Reference", "p");
0137       leg.AddEntry(h2temp2[i], "New ", "p");
0138       leg.Draw();
0139       myPV->PVCompute(h2temp1[i],h2temp2[i], te);
0140       sprintf(title,"%s%s%s", Energy, label2[i],".eps");
0141       c1.Print(title);
0142 
0143 
0144 
0145    }
0146 
0147  }
0148 
0149 
0150 
0151 
0152  //TProfiles
0153   char* label3[NHisto3];
0154   label3[0] = "Preshower_EEOverES_zp";
0155   label3[1] = "Preshower_EEOverES_zm";
0156 
0157  TProfile* hpro1[NHisto3];
0158  TProfile* hpro2[NHisto3];
0159 
0160  for ( int i = 0; i< NHisto3 ; i++ ) {
0161    char title[50];
0162    TCanvas c1;
0163    c1.Divide(2,1);
0164 
0165    hpro1[i]  = dynamic_cast<TProfile*>(reffile->Get(label3[i]));
0166    hpro2[i]  = dynamic_cast<TProfile*>(curfile->Get(label3[i]));
0167    if (hpro1[i] == 0 || hpro2[i] == 0) continue ;
0168    TF1 *f1 = new TF1("f1","pol1");
0169    c1.cd(1);
0170    hpro1[i]->Fit(f1,"Q","",0.0, 200);
0171    hpro1[i]->SetLineColor(2);
0172    hpro1[i]->Draw();
0173    double gradient_ref = f1->GetParameter(1);
0174    std::strstream buf_ref;
0175    std::string value_ref;
0176    buf_ref<<"Gradient="<<gradient_ref<<std::endl;
0177    buf_ref>>value_ref;
0178    te->DrawTextNDC(0.1,0.2, value_ref.c_str());  
0179    c1.cd(2);
0180    hpro2[i]->Fit(f1,"Q","", 0.0, 200);
0181    hpro2[i]->SetLineColor(4);
0182    hpro2[i]->Draw();
0183    double gradient_cur = f1->GetParameter(1);
0184    std::strstream buf_cur;
0185    std::string value_cur;
0186    buf_cur<<"Gradient="<<gradient_cur<<std::endl;
0187    buf_cur>>value_cur;
0188    te->DrawTextNDC(0.1,0.2, value_cur.c_str());
0189    //myPV->PVCompute(hpro1[i],hpro2[i], te);
0190    sprintf(title,"%s%s%s", Energy, label3[i],".eps");
0191    c1.Print(title);
0192  }
0193 
0194 }
0195 
0196