Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:34:17

0001 void SetUpHistograms(TH1F* h1, TH1F* h2, const char* xtitle, TLegend* leg = 0)
0002 {
0003   float scale1 = -9999.9;
0004   float scale2 = -9999.9;
0005 
0006   if ( h1->Integral() != 0 && h2->Integral() != 0 )
0007     {
0008       scale1 = 1.0/(float)h1->Integral();
0009       scale2 = 1.0/(float)h2->Integral();
0010       
0011       h1->Sumw2();
0012       h2->Sumw2();
0013       h1->Scale(scale1);
0014       h2->Scale(scale2);
0015   
0016       h1->SetLineWidth(2);
0017       h2->SetLineWidth(2);
0018       h1->SetLineColor(2);
0019       h2->SetLineColor(4);
0020       h2->SetLineStyle(2);  
0021     }
0022 
0023   h1->SetXTitle(xtitle);
0024 
0025   if ( leg != 0 )
0026     {
0027       leg->SetBorderSize(0);
0028       leg->AddEntry(h1, "reference  ", "l");
0029       leg->AddEntry(h2, "new release", "l");
0030     }
0031 }
0032 
0033 void SetUpProfileHistograms( TProfile* h1, TProfile* h2, 
0034                  const char* xtitle, const char* ytitle, 
0035                  double ymin, double ymax, 
0036                  TLegend* leg = 0 )
0037 {
0038   h1->SetLineWidth(2);
0039   h2->SetLineWidth(2);
0040   h1->SetLineColor(2);
0041   h2->SetLineColor(4);
0042   h2->SetLineStyle(2);  
0043 
0044   h1->SetXTitle(xtitle);
0045   h1->SetYTitle(ytitle);
0046   h1->SetTitleOffset(2.5, "Y");
0047 
0048   h1->SetMinimum(ymin);
0049   h1->SetMaximum(ymax);
0050 
0051   if ( leg != 0 )
0052     {
0053       leg->SetBorderSize(0);
0054       leg->AddEntry(h1, "reference  ", "l");
0055       leg->AddEntry(h2, "new release", "l");
0056     }
0057 }
0058 
0059 void SiPixelRecoCompare(char* originalName="DQM_V0001_R000000001__CMSSW_3_1_5__RelVal__Validation.root")
0060 {
0061   gROOT ->Reset();
0062     
0063   char*  sfilename = "pixeltrackingrechitshist.root";
0064   char*  rfilename = "../pixeltrackingrechitshist.root";
0065   /// WARNING: in other validation macros, rfilename is "new" and sfilename is "reference", while here is inverted.
0066 
0067   delete gROOT->GetListOfFiles()->FindObject(rfilename);
0068   delete gROOT->GetListOfFiles()->FindObject(sfilename);
0069   
0070   TText* te = new TText();
0071   TFile* rfile = new TFile(rfilename);
0072   TDirectory * rdir=gDirectory; 
0073   TFile * sfile = new TFile(sfilename);
0074   TDirectory * sdir=gDirectory; 
0075   
0076   char path[500];
0077   sprintf(path,"DQMData/Run 1/%s/DQMData/Run 1/RecoTrackV/Run summary/TrackingRecHits/Pixel",originalName);
0078   cout << "path = " << path << endl;
0079 
0080   if(rfile->cd("DQMData/Run 1/RecoTrackV"))rfile->cd("DQMData/Run 1/RecoTrackV/Run summary/TrackingRecHits/Pixel");
0081   else if(rfile->cd("DQMData/Run 1/Tracking/Run summary/TrackingRecHits"))rfile->cd("DQMData/Run 1/Tracking/Run summary/TrackingRecHits/Pixel");
0082   else if (rfile->cd("DQMData/RecoTrackV")) rfile->cd("DQMData/RecoTrackV/TrackingRecHits/Pixel");
0083   else if (rfile->cd(path)) rfile->cd(path);
0084   rdir=gDirectory;
0085 
0086   if(sfile->cd("DQMData/Run 1/RecoTrackV"))sfile->cd("DQMData/Run 1/RecoTrackV/Run summary/TrackingRecHits/Pixel");
0087   else if(sfile->cd("DQMData/Run 1/Tracking/Run summary/TrackingRecHits"))sfile->cd("DQMData/Run 1/Tracking/Run summary/TrackingRecHits/Pixel");
0088   else if (sfile->cd("DQMData/RecoTrackV")) sfile->cd("DQMData/RecoTrackV/TrackingRecHits/Pixel");
0089   else if (sfile->cd(path)) sfile->cd(path);
0090   sdir=gDirectory; 
0091 
0092   Char_t histo[200];
0093     
0094   gROOT->ProcessLine(".x HistoCompare_Pixels.C");
0095   HistoCompare_Pixels* myPV = new HistoCompare_Pixels("RecoTrack_SiPixelRecoCompare.txt");
0096   //myPV->setName("RecoTrack_SiPixelRecoCompare");
0097 
0098   int n_bins = 194;
0099   double  low = 0.5;
0100   double high = (double)n_bins + 0.5;
0101   TH1F* h_pv = new TH1F("h_pv", "#Chi^{2} results for each distribution", n_bins, low, high);
0102   int bin = 0;
0103   double value_pv = -9999.9;
0104 
0105 
0106   if (1) 
0107     {
0108       TCanvas* can_meControl = new TCanvas("can_meControl", "can_meControl", 1000, 500);
0109       can_meControl->Divide(2,1);
0110       
0111   
0112       TH1F* meTracksPerEvent;
0113       TH1F* mePixRecHitsPerTrack;
0114       
0115       TH1F* newmeTracksPerEvent;
0116       TH1F* newmePixRecHitsPerTrack;
0117       
0118       rdir->GetObject("Histograms_all/meTracksPerEvent", meTracksPerEvent);
0119       rdir->GetObject("Histograms_all/mePixRecHitsPerTrack", mePixRecHitsPerTrack );
0120       
0121       sdir->GetObject("Histograms_all/meTracksPerEvent", newmeTracksPerEvent );
0122       sdir->GetObject("Histograms_all/mePixRecHitsPerTrack", newmePixRecHitsPerTrack );
0123       
0124       
0125       TLegend* leg1 = new TLegend(0.6, 0.5, .89, 0.7); 
0126       can_meControl->cd(1);
0127       //gPad->SetLogy();
0128       SetUpHistograms(meTracksPerEvent, newmeTracksPerEvent, "tracks per event", leg1 );
0129       Float_t refMax = 1.15*meTracksPerEvent->GetMaximum();
0130       Float_t newMax = 1.15*newmeTracksPerEvent->GetMaximum();
0131       if refMax > newMax
0132       {    
0133           meTracksPerEvent->SetMaximum(refMax);
0134       }
0135       else
0136       {    
0137           meTracksPerEvent->SetMaximum(newMax);
0138       }
0139       meTracksPerEvent->SetName("Reference");
0140       newmeTracksPerEvent->SetName("New Release");
0141       meTracksPerEvent->Draw("he");      
0142       newmeTracksPerEvent->Draw("hesameS"); 
0143       gPad->Update();      
0144       TPaveStats *s1 = (TPaveStats*)meTracksPerEvent->GetListOfFunctions()->FindObject("stats");
0145       if (s1) {
0146     s1->SetX1NDC (0.55); //new x start position
0147     s1->SetX2NDC (0.75); //new x end position   
0148       }
0149       myPV->PVCompute(meTracksPerEvent, newmeTracksPerEvent, te);
0150       h_pv->SetBinContent(++bin, myPV->getPV());
0151       leg1->Draw();   
0152       
0153       
0154         
0155       can_meControl->cd(2);
0156       //gPad->SetLogy();
0157       SetUpHistograms(mePixRecHitsPerTrack, newmePixRecHitsPerTrack, "pixel hits per track" );     
0158       Float_t refMax = 1.15*mePixRecHitsPerTrack->GetMaximum();
0159       Float_t newMax = 1.15*newmePixRecHitsPerTrack->GetMaximum();
0160       if refMax > newMax
0161       {
0162           mePixRecHitsPerTrack->SetMaximum(refMax);
0163       }
0164       else
0165       {
0166           mePixRecHitsPerTrack->SetMaximum(newMax);
0167       }
0168       mePixRecHitsPerTrack->SetName("Reference");
0169       newmePixRecHitsPerTrack->SetName("New Release");
0170       mePixRecHitsPerTrack->Draw("he");
0171       newmePixRecHitsPerTrack->Draw("hesameS");
0172       gPad->Update();
0173       TPaveStats *s2 = (TPaveStats*)mePixRecHitsPerTrack->GetListOfFunctions()->FindObject("stats");
0174       if (s2) {
0175     s2->SetX1NDC (0.55); //new x start position
0176     s2->SetX2NDC (0.75); //new x end position
0177       }
0178       myPV->PVCompute(mePixRecHitsPerTrack, newmePixRecHitsPerTrack, te, 0.15, 0.8 );
0179       h_pv->SetBinContent(++bin, myPV->getPV());
0180 
0181       can_meControl->SaveAs("meControl_compare.eps");
0182       can_meControl->SaveAs("meControl_compare.gif");
0183 
0184     }
0185 
0186 
0187   if (1) 
0188     {
0189       TCanvas* can_meCharge = new TCanvas("can_meCharge", "can_meCharge", 1200, 800);
0190       can_meCharge->Divide(3,2);
0191       
0192       TH1F* meChargeBarrel;
0193       TH1F* meChargeZmPanel1;
0194       TH1F* meChargeZmPanel2;
0195       TH1F* meChargeZpPanel1;
0196       TH1F* meChargeZpPanel2;
0197       
0198       TH1F* newmeChargeBarrel;
0199       TH1F* newmeChargeZmPanel1;
0200       TH1F* newmeChargeZmPanel2;
0201       TH1F* newmeChargeZpPanel1;
0202       TH1F* newmeChargeZpPanel2;
0203       
0204       rdir->GetObject("Histograms_all/meChargeBarrel"  , meChargeBarrel  );
0205       rdir->GetObject("Histograms_all/meChargeZmPanel1", meChargeZmPanel1);
0206       rdir->GetObject("Histograms_all/meChargeZmPanel2", meChargeZmPanel2);
0207       rdir->GetObject("Histograms_all/meChargeZpPanel1", meChargeZpPanel1);
0208       rdir->GetObject("Histograms_all/meChargeZpPanel2", meChargeZpPanel2);
0209       
0210       sdir->GetObject("Histograms_all/meChargeBarrel"  , newmeChargeBarrel  ); 
0211       sdir->GetObject("Histograms_all/meChargeZmPanel1", newmeChargeZmPanel1);
0212       sdir->GetObject("Histograms_all/meChargeZmPanel2", newmeChargeZmPanel2);
0213       sdir->GetObject("Histograms_all/meChargeZpPanel1", newmeChargeZpPanel1);
0214       sdir->GetObject("Histograms_all/meChargeZpPanel2", newmeChargeZpPanel2);
0215       TLegend* leg2 = new TLegend(0.65, 0.45, 0.89, 0.6);
0216       can_meCharge->cd(1);
0217       //gPad->SetLogy();
0218       SetUpHistograms(meChargeBarrel, newmeChargeBarrel, "barrel, cluster charge (elec) ", leg2 );
0219       
0220       Float_t refMax = 1.2*meChargeBarrel->GetMaximum();
0221       Float_t newMax = 1.2*newmeChargeBarrel->GetMaximum();
0222       if refMax > newMax
0223       {
0224           meChargeBarrel->SetMaximum(refMax);
0225       }
0226       else
0227       {
0228           meChargeBarrel->SetMaximum(newMax);
0229       }
0230       meChargeBarrel->SetName("Reference");
0231       newmeChargeBarrel->SetName("New Release");
0232       meChargeBarrel->Draw("he");
0233       newmeChargeBarrel->Draw("hesameS"); 
0234       myPV->PVCompute(meChargeBarrel, newmeChargeBarrel, te );
0235       h_pv->SetBinContent(++bin, myPV->getPV());
0236       leg2->Draw();
0237       gPad->Update();      
0238       TPaveStats *s3 = (TPaveStats*)meChargeBarrel->GetListOfFunctions()->FindObject("stats");
0239       if (s3) {
0240     s3->SetX1NDC (0.55); //new x start position
0241     s3->SetX2NDC (0.75); //new x end position  
0242       }
0243       
0244       can_meCharge->cd(2);
0245       //gPad->SetLogy();
0246       SetUpHistograms(meChargeZmPanel1, newmeChargeZmPanel1, "panel1, z<0, cluster charge (elec)" );
0247       Float_t refMax = 1.2*meChargeZmPanel1->GetMaximum();
0248       Float_t newMax = 1.2*newmeChargeZmPanel1->GetMaximum();
0249       
0250       if refMax > newMax
0251       {
0252           meChargeZmPanel1->SetMaximum(refMax);
0253       }
0254       else
0255       {
0256           meChargeZmPanel1->SetMaximum(newMax);
0257       }
0258       meChargeZmPanel1->SetName("Reference");
0259       newmeChargeZmPanel1->SetName("New Release");
0260       meChargeZmPanel1->Draw("he");
0261       newmeChargeZmPanel1->Draw("hesameS"); 
0262       myPV->PVCompute(meChargeZmPanel1, newmeChargeZmPanel1, te );
0263       h_pv->SetBinContent(++bin, myPV->getPV());
0264       gPad->Update();      
0265       TPaveStats *s4 = (TPaveStats*)meChargeZmPanel1->GetListOfFunctions()->FindObject("stats");
0266       if (s4) {
0267     s4->SetX1NDC (0.55); //new x start position
0268     s4->SetX2NDC (0.75); //new x end position 
0269       }
0270 
0271       can_meCharge->cd(3);
0272       //gPad->SetLogy();
0273       SetUpHistograms(meChargeZmPanel2, newmeChargeZmPanel2, "panel2, z<0, cluster charge (elec)" );
0274       Float_t refMax = 1.2*meChargeZmPanel2->GetMaximum();
0275       Float_t newMax = 1.2*newmeChargeZmPanel2->GetMaximum();
0276       if refMax > newMax
0277       {
0278           meChargeZmPanel2->SetMaximum(refMax);
0279       }
0280       else
0281       {
0282           meChargeZmPanel2->SetMaximum(newMax);
0283       }
0284       meChargeZmPanel2->SetName("Reference");
0285       newmeChargeZmPanel2->SetName("New Release");
0286       meChargeZmPanel2->Draw("he");
0287       newmeChargeZmPanel2->Draw("hesameS"); 
0288       myPV->PVCompute(meChargeZmPanel2, newmeChargeZmPanel2, te );
0289       h_pv->SetBinContent(++bin, myPV->getPV());
0290       gPad->Update();      
0291       TPaveStats *s5 = (TPaveStats*)meChargeZmPanel2->GetListOfFunctions()->FindObject("stats");
0292       if (s5) {
0293     s5->SetX1NDC (0.55); //new x start position
0294     s5->SetX2NDC (0.75); //new x end position 
0295       }
0296 
0297       can_meCharge->cd(5);
0298       //gPad->SetLogy();
0299       SetUpHistograms(meChargeZpPanel1, newmeChargeZpPanel1, "panel1, z>0, cluster charge (elec)" );
0300       Float_t refMax = 1.2*meChargeZpPanel1->GetMaximum();
0301       Float_t newMax = 1.2*newmeChargeZpPanel1->GetMaximum();
0302       if refMax > newMax
0303       {
0304           meChargeZpPanel1->SetMaximum(refMax);
0305       }
0306       else
0307       {
0308           meChargeZpPanel1->SetMaximum(newMax);
0309       }
0310       meChargeZpPanel1->SetName("Reference");
0311       newmeChargeZpPanel1->SetName("New Release");
0312       meChargeZpPanel1->Draw("he");
0313       newmeChargeZpPanel1->Draw("hesameS"); 
0314       myPV->PVCompute(meChargeZpPanel1, newmeChargeZpPanel1, te );
0315       h_pv->SetBinContent(++bin, myPV->getPV());
0316       gPad->Update();      
0317       TPaveStats *s6 = (TPaveStats*)meChargeZpPanel1->GetListOfFunctions()->FindObject("stats");
0318       if (s6) {
0319     s6->SetX1NDC (0.55); //new x start position
0320     s6->SetX2NDC (0.75); //new x end position 
0321       }
0322 
0323       can_meCharge->cd(6);
0324       //gPad->SetLogy();
0325       SetUpHistograms(meChargeZpPanel2, newmeChargeZpPanel2, "panel2, z>0, cluster charge (elec)" );  
0326       Float_t refMax = 1.2*meChargeZpPanel2->GetMaximum();
0327       Float_t newMax = 1.2*newmeChargeZpPanel2->GetMaximum();
0328       if refMax > newMax
0329       {
0330           meChargeZpPanel2->SetMaximum(refMax);
0331       }
0332       else
0333       {
0334           meChargeZpPanel2->SetMaximum(newMax);
0335       }
0336       meChargeZpPanel2->SetName("Reference");
0337       newmeChargeZpPanel2->SetName("New Release");
0338       meChargeZpPanel2->Draw("he");
0339       newmeChargeZpPanel2->Draw("hesameS"); 
0340       myPV->PVCompute(meChargeZpPanel2, newmeChargeZpPanel2, te );
0341       h_pv->SetBinContent(++bin, myPV->getPV());
0342       gPad->Update();      
0343       TPaveStats *s7 = (TPaveStats*)meChargeZpPanel2->GetListOfFunctions()->FindObject("stats");
0344       if (s7) {
0345     s7->SetX1NDC (0.55); //new x start position
0346     s7->SetX2NDC (0.75); //new x end position 
0347       }
0348       
0349       can_meCharge->SaveAs("meCharge_compare.eps");
0350       can_meCharge->SaveAs("meCharge_compare.gif");
0351     }
0352   
0353   if (1) 
0354     {
0355       TCanvas* can_Errx = new TCanvas("can_Errx", "can_Errx", 1200, 800);
0356       can_Errx->Divide(3,2);
0357       
0358       TH1F* meErrxBarrel;
0359       TH1F* meErrxZmPanel1;
0360       TH1F* meErrxZmPanel2;
0361       TH1F* meErrxZpPanel1;
0362       TH1F* meErrxZpPanel2;
0363       
0364       TH1F* newmeErrxBarrel;
0365       TH1F* newmeErrxZmPanel1;
0366       TH1F* newmeErrxZmPanel2;
0367       TH1F* newmeErrxZpPanel1;
0368       TH1F* newmeErrxZpPanel2;
0369       
0370       rdir->GetObject("Histograms_all/meErrxBarrel"  , meErrxBarrel  );
0371       rdir->GetObject("Histograms_all/meErrxZmPanel1", meErrxZmPanel1);
0372       rdir->GetObject("Histograms_all/meErrxZmPanel2", meErrxZmPanel2);
0373       rdir->GetObject("Histograms_all/meErrxZpPanel1", meErrxZpPanel1);
0374       rdir->GetObject("Histograms_all/meErrxZpPanel2", meErrxZpPanel2);
0375       
0376       sdir->GetObject("Histograms_all/meErrxBarrel"  , newmeErrxBarrel  ); 
0377       sdir->GetObject("Histograms_all/meErrxZmPanel1", newmeErrxZmPanel1);
0378       sdir->GetObject("Histograms_all/meErrxZmPanel2", newmeErrxZmPanel2);
0379       sdir->GetObject("Histograms_all/meErrxZpPanel1", newmeErrxZpPanel1);
0380       sdir->GetObject("Histograms_all/meErrxZpPanel2", newmeErrxZpPanel2);
0381       
0382       TLegend* leg3 = new TLegend(0.65, 0.55, 0.89, 0.7);
0383       can_Errx->cd(1);
0384       //gPad->SetLogy();
0385       SetUpHistograms(meErrxBarrel, newmeErrxBarrel, "barrel, x position error (cm)", leg3 );
0386       Float_t refMax = 1.2*meErrxBarrel->GetMaximum();
0387       Float_t newMax = 1.2*newmeErrxBarrel->GetMaximum();
0388       if refMax > newMax
0389       {
0390           meErrxBarrel->SetMaximum(refMax);
0391       }
0392       else
0393       {
0394           meErrxBarrel->SetMaximum(newMax);
0395       }
0396       meErrxBarrel->SetName("Reference");
0397       newmeErrxBarrel->SetName("New Release");
0398       meErrxBarrel->Draw("he");
0399       newmeErrxBarrel->Draw("hesameS"); 
0400       myPV->PVCompute(meErrxBarrel, newmeErrxBarrel, te );
0401       leg3->Draw();
0402       h_pv->SetBinContent(++bin, myPV->getPV());
0403       gPad->Update();      
0404       TPaveStats *s8 = (TPaveStats*)meErrxBarrel->GetListOfFunctions()->FindObject("stats");
0405       if (s8) {
0406     s8->SetX1NDC (0.55); //new x start position
0407     s8->SetX2NDC (0.75); //new x end position 
0408       }
0409 
0410       can_Errx->cd(2);
0411       //gPad->SetLogy();
0412       SetUpHistograms(meErrxZmPanel1, newmeErrxZmPanel1, "panel1, z<0, x position error (cm)" );
0413       Float_t refMax = 1.2*meErrxZmPanel1->GetMaximum();
0414       Float_t newMax = 1.2*newmeErrxZmPanel1->GetMaximum();
0415       if refMax > newMax
0416       {
0417           meErrxZmPanel1->SetMaximum(refMax);
0418       }
0419       else
0420       {
0421           meErrxZmPanel1->SetMaximum(newMax);
0422       }
0423       meErrxZmPanel1->SetName("Reference");
0424       newmeErrxZmPanel1->SetName("New Release");
0425       meErrxZmPanel1->Draw("he");
0426       newmeErrxZmPanel1->Draw("hesameS"); 
0427       myPV->PVCompute(meErrxZmPanel1, newmeErrxZmPanel1, te );
0428       h_pv->SetBinContent(++bin, myPV->getPV());
0429       gPad->Update();      
0430       TPaveStats *s9 = (TPaveStats*)meErrxZmPanel1->GetListOfFunctions()->FindObject("stats");
0431       if (s9) {
0432     s9->SetX1NDC (0.55); //new x start position
0433     s9->SetX2NDC (0.75); //new x end position 
0434       }
0435 
0436       can_Errx->cd(3);
0437       //gPad->SetLogy();
0438       SetUpHistograms(meErrxZmPanel2, newmeErrxZmPanel2, "panel2, z<0, x position error (cm)" );
0439       Float_t refMax = 1.2*meErrxZmPanel2->GetMaximum();
0440       Float_t newMax = 1.2*newmeErrxZmPanel2->GetMaximum();
0441       if refMax > newMax
0442       {
0443           meErrxZmPanel2->SetMaximum(refMax);
0444       }
0445       else
0446       {
0447           meErrxZmPanel2->SetMaximum(newMax);
0448       }
0449       meErrxZmPanel2->SetName("Reference");
0450       newmeErrxZmPanel2->SetName("New Release");
0451       meErrxZmPanel2->Draw("he");
0452       newmeErrxZmPanel2->Draw("hesameS"); 
0453       myPV->PVCompute(meErrxZmPanel2, newmeErrxZmPanel2, te );
0454       h_pv->SetBinContent(++bin, myPV->getPV());
0455       gPad->Update();      
0456       TPaveStats *s10 = (TPaveStats*)meErrxZmPanel2->GetListOfFunctions()->FindObject("stats");
0457       if (s10) {
0458     s10->SetX1NDC (0.55); //new x start position
0459     s10->SetX2NDC (0.75); //new x end position 
0460       }
0461 
0462       can_Errx->cd(5);
0463       //gPad->SetLogy();
0464       SetUpHistograms(meErrxZpPanel1, newmeErrxZpPanel1, "panel1, z>0, x position error (cm)" );
0465       Float_t refMax = 1.2*meErrxZpPanel1->GetMaximum();
0466       Float_t newMax = 1.2*newmeErrxZpPanel1->GetMaximum();
0467       if refMax > newMax
0468       {
0469           meErrxZpPanel1->SetMaximum(refMax);
0470       }
0471       else
0472       {
0473           meErrxZpPanel1->SetMaximum(newMax);
0474       }
0475       meErrxZpPanel1->SetName("Reference");
0476       newmeErrxZpPanel1->SetName("New Release");
0477       meErrxZpPanel1->Draw("he");
0478       newmeErrxZpPanel1->Draw("hesameS"); 
0479       myPV->PVCompute(meErrxZpPanel1, newmeErrxZpPanel1, te );
0480       h_pv->SetBinContent(++bin, myPV->getPV());
0481       gPad->Update();      
0482       TPaveStats *s11 = (TPaveStats*)meErrxZpPanel1->GetListOfFunctions()->FindObject("stats");
0483       if (s11) {
0484     s11->SetX1NDC (0.55); //new x start position
0485     s11->SetX2NDC (0.75); //new x end position 
0486       }
0487 
0488       can_Errx->cd(6);
0489       //gPad->SetLogy();
0490       SetUpHistograms(meErrxZpPanel2, newmeErrxZpPanel2, "panel2, z>0, x position error (cm)" );
0491       Float_t refMax = 1.2*meErrxZpPanel2->GetMaximum();
0492       Float_t newMax = 1.2*newmeErrxZpPanel2->GetMaximum();
0493       if refMax > newMax
0494       {
0495           meErrxZpPanel2->SetMaximum(refMax);
0496       }
0497       else
0498       {
0499           meErrxZpPanel2->SetMaximum(newMax);
0500       }
0501       meErrxZpPanel2->SetName("Reference");
0502       newmeErrxZpPanel2->SetName("New Release");
0503       meErrxZpPanel2->Draw("he");
0504       newmeErrxZpPanel2->Draw("hesameS"); 
0505       myPV->PVCompute(meErrxZpPanel2, newmeErrxZpPanel2, te );
0506       h_pv->SetBinContent(++bin, myPV->getPV());
0507       gPad->Update();      
0508       TPaveStats *s12 = (TPaveStats*)meErrxZpPanel2->GetListOfFunctions()->FindObject("stats");
0509       if (s12) {
0510     s12->SetX1NDC (0.55); //new x start position
0511     s12->SetX2NDC (0.75); //new x end position 
0512       }
0513 
0514       can_Errx->SaveAs("meErrx_compare.eps");
0515       can_Errx->SaveAs("meErrx_compare.gif");
0516     }
0517     
0518   if (1) 
0519     {
0520       TCanvas* can_Erry = new TCanvas("can_Erry", "can_Erry", 1200, 800);
0521       can_Erry->Divide(3,2);
0522       
0523       TH1F* meErryBarrel;
0524       TH1F* meErryZmPanel1;
0525       TH1F* meErryZmPanel2;
0526       TH1F* meErryZpPanel1;
0527       TH1F* meErryZpPanel2;
0528       
0529       TH1F* newmeErryBarrel;
0530       TH1F* newmeErryZmPanel1;
0531       TH1F* newmeErryZmPanel2;
0532       TH1F* newmeErryZpPanel1;
0533       TH1F* newmeErryZpPanel2;
0534       
0535       rdir->GetObject("Histograms_all/meErryBarrel"  , meErryBarrel  );
0536       rdir->GetObject("Histograms_all/meErryZmPanel1", meErryZmPanel1);
0537       rdir->GetObject("Histograms_all/meErryZmPanel2", meErryZmPanel2);
0538       rdir->GetObject("Histograms_all/meErryZpPanel1", meErryZpPanel1);
0539       rdir->GetObject("Histograms_all/meErryZpPanel2", meErryZpPanel2);
0540       
0541       sdir->GetObject("Histograms_all/meErryBarrel"  , newmeErryBarrel  ); 
0542       sdir->GetObject("Histograms_all/meErryZmPanel1", newmeErryZmPanel1);
0543       sdir->GetObject("Histograms_all/meErryZmPanel2", newmeErryZmPanel2);
0544       sdir->GetObject("Histograms_all/meErryZpPanel1", newmeErryZpPanel1);
0545       sdir->GetObject("Histograms_all/meErryZpPanel2", newmeErryZpPanel2);
0546       
0547       TLegend* leg4 = new TLegend(0.65, 0.5, 0.89, 0.65);
0548       can_Erry->cd(1);
0549       //gPad->SetLogy();
0550       SetUpHistograms(meErryBarrel, newmeErryBarrel, "barrel, y position error (cm)", leg4 );
0551       Float_t refMax = 1.2*meErryBarrel->GetMaximum();
0552       Float_t newMax = 1.2*newmeErryBarrel->GetMaximum();
0553       if refMax > newMax
0554       {
0555           meErryBarrel->SetMaximum(refMax);
0556       }
0557       else
0558       {
0559           meErryBarrel->SetMaximum(newMax);
0560       }
0561       meErryBarrel->SetName("Reference");
0562       newmeErryBarrel->SetName("New Release");
0563       meErryBarrel->Draw("he");
0564       newmeErryBarrel->Draw("hesameS"); 
0565       myPV->PVCompute(meErryBarrel, newmeErryBarrel, te );
0566       leg4->Draw();
0567       h_pv->SetBinContent(++bin, myPV->getPV());
0568       gPad->Update();      
0569       TPaveStats *s13 = (TPaveStats*)meErryBarrel->GetListOfFunctions()->FindObject("stats");
0570       if (s13) {
0571     s13->SetX1NDC (0.55); //new x start position
0572     s13->SetX2NDC (0.75); //new x end position 
0573       }
0574 
0575       can_Erry->cd(2);
0576       //gPad->SetLogy();
0577       SetUpHistograms(meErryZmPanel1, newmeErryZmPanel1, "panel1, z<0, y position error (cm)"  );
0578       Float_t refMax = 1.2*meErryZmPanel1->GetMaximum();
0579       Float_t newMax = 1.2*newmeErryZmPanel1->GetMaximum();
0580       if refMax > newMax
0581       {
0582           meErryZmPanel1->SetMaximum(refMax);
0583       }
0584       else
0585       {
0586           meErryZmPanel1->SetMaximum(newMax);
0587       }
0588       meErryZmPanel1->SetName("Reference");
0589       newmeErryZmPanel1->SetName("New Release");
0590       meErryZmPanel1->Draw("he");
0591       newmeErryZmPanel1->Draw("hesameS"); 
0592       myPV->PVCompute(meErryZmPanel1, newmeErryZmPanel1, te );
0593       h_pv->SetBinContent(++bin, myPV->getPV());
0594       gPad->Update();      
0595       TPaveStats *s14 = (TPaveStats*)meErryZmPanel1->GetListOfFunctions()->FindObject("stats");
0596       if (s14) {
0597     s14->SetX1NDC (0.55); //new x start position
0598     s14->SetX2NDC (0.75); //new x end position 
0599       }
0600 
0601       can_Erry->cd(3);
0602       //gPad->SetLogy();
0603       SetUpHistograms(meErryZmPanel2, newmeErryZmPanel2, "panel2, z<0, y position error (cm)" );
0604       Float_t refMax = 1.2*meErryZmPanel2->GetMaximum();
0605       Float_t newMax = 1.2*newmeErryZmPanel2->GetMaximum();      
0606       if refMax > newMax
0607       {
0608           meErryZmPanel2->SetMaximum(refMax);
0609       }
0610       else
0611       {
0612           meErryZmPanel2->SetMaximum(newMax);
0613       }      
0614       meErryZmPanel2->SetName("Reference");
0615       newmeErryZmPanel2->SetName("New Release");
0616       meErryZmPanel2->Draw("he");
0617       newmeErryZmPanel2->Draw("hesameS"); 
0618       myPV->PVCompute(meErryZmPanel2, newmeErryZmPanel2, te );
0619       h_pv->SetBinContent(++bin, myPV->getPV());      
0620       gPad->Update();      
0621       TPaveStats *s15 = (TPaveStats*)meErryZmPanel2->GetListOfFunctions()->FindObject("stats");
0622       if (s15) {
0623     s15->SetX1NDC (0.55); //new x start position
0624     s15->SetX2NDC (0.75); //new x end position
0625       }
0626 
0627       can_Erry->cd(5);
0628       //gPad->SetLogy();
0629       SetUpHistograms(meErryZpPanel1, newmeErryZpPanel1, "panel1, z>0, y position error (cm)" );
0630       Float_t refMax = 1.2*meErryZpPanel1->GetMaximum();
0631       Float_t newMax = 1.2*newmeErryZpPanel1->GetMaximum();      
0632       if refMax > newMax
0633       {
0634           meErryZpPanel1->SetMaximum(refMax);
0635       }
0636       else
0637       {
0638           meErryZpPanel1->SetMaximum(newMax);
0639       }      
0640       meErryZpPanel1->SetName("Reference");
0641       newmeErryZpPanel1->SetName("New Release");
0642       meErryZpPanel1->Draw("he");
0643       newmeErryZpPanel1->Draw("hesameS"); 
0644       myPV->PVCompute(meErryZpPanel1, newmeErryZpPanel1, te );
0645       h_pv->SetBinContent(++bin, myPV->getPV());
0646       gPad->Update();      
0647       TPaveStats *s16 = (TPaveStats*)meErryZpPanel1->GetListOfFunctions()->FindObject("stats");
0648       if (s16) {
0649     s16->SetX1NDC (0.55); //new x start position
0650     s16->SetX2NDC (0.75); //new x end position
0651       }
0652 
0653       can_Erry->cd(6);
0654       //gPad->SetLogy();
0655       SetUpHistograms(meErryZpPanel2, newmeErryZpPanel2, "panel2, z>0, y position error (cm)" );
0656       Float_t refMax = 1.2*meErryZpPanel2->GetMaximum();
0657       Float_t newMax = 1.2*newmeErryZpPanel2->GetMaximum();
0658       if refMax > newMax
0659       {
0660           meErryZpPanel2->SetMaximum(refMax);
0661       }
0662       else
0663       {
0664           meErryZpPanel2->SetMaximum(newMax);
0665       }
0666       meErryZpPanel2->SetName("Reference");
0667       newmeErryZpPanel2->SetName("New Release");
0668       meErryZpPanel2->Draw("he");
0669       newmeErryZpPanel2->Draw("hesameS"); 
0670       myPV->PVCompute(meErryZpPanel2, newmeErryZpPanel2, te );
0671       h_pv->SetBinContent(++bin, myPV->getPV());
0672       gPad->Update();      
0673       TPaveStats *s17 = (TPaveStats*)meErryZpPanel2->GetListOfFunctions()->FindObject("stats");
0674       if (s17) {
0675     s17->SetX1NDC (0.55); //new x start position
0676     s17->SetX2NDC (0.75); //new x end position
0677       }
0678 
0679       can_Erry->SaveAs("meErry_compare.eps");
0680       can_Erry->SaveAs("meErry_compare.gif");
0681     }
0682   
0683       
0684   if (1) 
0685     {
0686       TCanvas* can_Npix = new TCanvas("can_Npix", "can_Npix", 1200, 800);
0687       can_Npix->Divide(3,2);
0688       
0689       TH1F* meNpixBarrel;
0690       TH1F* meNpixZmPanel1;
0691       TH1F* meNpixZmPanel2;
0692       TH1F* meNpixZpPanel1;
0693       TH1F* meNpixZpPanel2;
0694       
0695       TH1F* newmeNpixBarrel;
0696       TH1F* newmeNpixZmPanel1;
0697       TH1F* newmeNpixZmPanel2;
0698       TH1F* newmeNpixZpPanel1;
0699       TH1F* newmeNpixZpPanel2;
0700       
0701       rdir->GetObject("Histograms_all/meNpixBarrel"  , meNpixBarrel  );
0702       rdir->GetObject("Histograms_all/meNpixZmPanel1", meNpixZmPanel1);
0703       rdir->GetObject("Histograms_all/meNpixZmPanel2", meNpixZmPanel2);
0704       rdir->GetObject("Histograms_all/meNpixZpPanel1", meNpixZpPanel1);
0705       rdir->GetObject("Histograms_all/meNpixZpPanel2", meNpixZpPanel2);
0706       
0707       sdir->GetObject("Histograms_all/meNpixBarrel"  , newmeNpixBarrel  ); 
0708       sdir->GetObject("Histograms_all/meNpixZmPanel1", newmeNpixZmPanel1);
0709       sdir->GetObject("Histograms_all/meNpixZmPanel2", newmeNpixZmPanel2);
0710       sdir->GetObject("Histograms_all/meNpixZpPanel1", newmeNpixZpPanel1);
0711       sdir->GetObject("Histograms_all/meNpixZpPanel2", newmeNpixZpPanel2);
0712       
0713       TLegend* leg5 = new TLegend(0.65, 0.5, 0.89, 0.65);
0714       can_Npix->cd(1);
0715       //gPad->SetLogy();
0716       SetUpHistograms(meNpixBarrel, newmeNpixBarrel, "barrel, cluster size (pixels)", leg5 );
0717       Float_t refMax = 1.2*meNpixBarrel->GetMaximum();
0718       Float_t newMax = 1.2*newmeNpixBarrel->GetMaximum();
0719       if refMax > newMax
0720       {
0721           meNpixBarrel->SetMaximum(refMax);
0722       }
0723       else
0724       {
0725           meNpixBarrel->SetMaximum(newMax);
0726       }
0727       meNpixBarrel->SetName("Reference");
0728       newmeNpixBarrel->SetName("New Release");
0729       meNpixBarrel->Draw("he");
0730       newmeNpixBarrel->Draw("hesameS"); 
0731       myPV->PVCompute(meNpixBarrel, newmeNpixBarrel, te );
0732       leg5->Draw();
0733       h_pv->SetBinContent(++bin, myPV->getPV());
0734       gPad->Update();      
0735       TPaveStats *s18 = (TPaveStats*)meNpixBarrel->GetListOfFunctions()->FindObject("stats");
0736       if (s18) {
0737     s18->SetX1NDC (0.55); //new x start position
0738     s18->SetX2NDC (0.75); //new x end position
0739       }
0740 
0741       can_Npix->cd(2);
0742       //gPad->SetLogy();
0743       SetUpHistograms(meNpixZmPanel1, newmeNpixZmPanel1, "panel1, z<0, cluster size (pixels)"  );
0744       Float_t refMax = 1.2*meNpixZmPanel1->GetMaximum();
0745       Float_t newMax = 1.2*newmeNpixZmPanel1->GetMaximum();
0746       if refMax > newMax
0747       {
0748           meNpixZmPanel1->SetMaximum(refMax);
0749       }
0750       else
0751       {
0752           meNpixZmPanel1->SetMaximum(newMax);
0753       }
0754       meNpixZmPanel1->SetName("Reference");
0755       newmeNpixZmPanel1->SetName("New Release");
0756       meNpixZmPanel1->Draw("he");
0757       newmeNpixZmPanel1->Draw("hesameS"); 
0758       myPV->PVCompute(meNpixZmPanel1, newmeNpixZmPanel1, te );
0759       h_pv->SetBinContent(++bin, myPV->getPV());
0760       gPad->Update();      
0761       TPaveStats *s19 = (TPaveStats*)meNpixZmPanel1->GetListOfFunctions()->FindObject("stats");
0762       if (s19) {
0763     s19->SetX1NDC (0.55); //new x start position
0764     s19->SetX2NDC (0.75); //new x end position
0765       }
0766 
0767       can_Npix->cd(3);
0768       //gPad->SetLogy();
0769       SetUpHistograms(meNpixZmPanel2, newmeNpixZmPanel2, "panel2, z<0, cluster size (pixels)" );
0770       Float_t refMax = 1.2*meNpixZmPanel2->GetMaximum();
0771       Float_t newMax = 1.2*newmeNpixZmPanel2->GetMaximum();
0772       if refMax > newMax
0773       {
0774           meNpixZmPanel2->SetMaximum(refMax);
0775       }
0776       else
0777       {
0778           meNpixZmPanel2->SetMaximum(newMax);
0779       }
0780       meNpixZmPanel2->SetName("Reference");
0781       newmeNpixZmPanel2->SetName("New Release");
0782       meNpixZmPanel2->Draw("he");
0783       newmeNpixZmPanel2->Draw("hesameS"); 
0784       myPV->PVCompute(meNpixZmPanel2, newmeNpixZmPanel2, te );
0785       h_pv->SetBinContent(++bin, myPV->getPV());
0786       gPad->Update();      
0787       TPaveStats *s20 = (TPaveStats*)meNpixZmPanel2->GetListOfFunctions()->FindObject("stats");
0788       if (s20) {
0789     s20->SetX1NDC (0.55); //new x start position
0790     s20->SetX2NDC (0.75); //new x end position
0791       }
0792 
0793       can_Npix->cd(5);
0794       //gPad->SetLogy();
0795       SetUpHistograms(meNpixZpPanel1, newmeNpixZpPanel1, "panel1, z>0, cluster size (pixels)" );
0796       Float_t refMax = 1.2*meNpixZpPanel1->GetMaximum();
0797       Float_t newMax = 1.2*newmeNpixZpPanel1->GetMaximum();
0798       if refMax > newMax
0799       {
0800           meNpixZpPanel1->SetMaximum(refMax);
0801       }
0802       else
0803       {
0804           meNpixZpPanel1->SetMaximum(newMax);
0805       }
0806       meNpixZpPanel1->SetName("Reference");
0807       newmeNpixZpPanel1->SetName("New Release");
0808       meNpixZpPanel1->Draw("he");
0809       newmeNpixZpPanel1->Draw("hesameS"); 
0810       myPV->PVCompute(meNpixZpPanel1, newmeNpixZpPanel1, te );
0811       h_pv->SetBinContent(++bin, myPV->getPV());
0812       gPad->Update();      
0813       TPaveStats *s21 = (TPaveStats*)meNpixZpPanel1->GetListOfFunctions()->FindObject("stats");
0814       if (s21) {
0815     s21->SetX1NDC (0.55); //new x start position
0816     s21->SetX2NDC (0.75); //new x end position
0817       }
0818 
0819       can_Npix->cd(6);
0820       //gPad->SetLogy();
0821       SetUpHistograms(meNpixZpPanel2, newmeNpixZpPanel2, "panel2, z>0, cluster size (pixels)" );
0822       Float_t refMax = 1.2*meNpixZpPanel2->GetMaximum();
0823       Float_t newMax = 1.2*newmeNpixZpPanel2->GetMaximum();
0824       if refMax > newMax
0825       {
0826           meNpixZpPanel2->SetMaximum(refMax);
0827       }
0828       else
0829       {
0830           meNpixZpPanel2->SetMaximum(newMax);
0831       }
0832       meNpixZpPanel2->SetName("Reference");
0833       newmeNpixZpPanel2->SetName("New Release");
0834       meNpixZpPanel2->Draw("he");
0835       newmeNpixZpPanel2->Draw("hesameS"); 
0836       myPV->PVCompute(meNpixZpPanel2, newmeNpixZpPanel2, te );
0837       h_pv->SetBinContent(++bin, myPV->getPV());
0838       gPad->Update();      
0839       TPaveStats *s22 = (TPaveStats*)meNpixZpPanel2->GetListOfFunctions()->FindObject("stats");
0840       if (s22) {
0841     s22->SetX1NDC (0.55); //new x start position
0842     s22->SetX2NDC (0.75); //new x end position
0843       }
0844 
0845       can_Npix->SaveAs("meNpix_compare.eps");
0846       can_Npix->SaveAs("meNpix_compare.gif");
0847     }
0848 
0849   if (1) 
0850     {
0851       TCanvas* can_Nxpix = new TCanvas("can_Nxpix", "can_Nxpix", 1200, 800);
0852       can_Nxpix->Divide(3,2);
0853       
0854       TH1F* meNxpixBarrel;
0855       TH1F* meNxpixZmPanel1;
0856       TH1F* meNxpixZmPanel2;
0857       TH1F* meNxpixZpPanel1;
0858       TH1F* meNxpixZpPanel2;
0859       
0860       TH1F* newmeNxpixBarrel;
0861       TH1F* newmeNxpixZmPanel1;
0862       TH1F* newmeNxpixZmPanel2;
0863       TH1F* newmeNxpixZpPanel1;
0864       TH1F* newmeNxpixZpPanel2;
0865       
0866       rdir->GetObject("Histograms_all/meNxpixBarrel"  , meNxpixBarrel  );
0867       rdir->GetObject("Histograms_all/meNxpixZmPanel1", meNxpixZmPanel1);
0868       rdir->GetObject("Histograms_all/meNxpixZmPanel2", meNxpixZmPanel2);
0869       rdir->GetObject("Histograms_all/meNxpixZpPanel1", meNxpixZpPanel1);
0870       rdir->GetObject("Histograms_all/meNxpixZpPanel2", meNxpixZpPanel2);
0871       
0872       sdir->GetObject("Histograms_all/meNxpixBarrel"  , newmeNxpixBarrel  ); 
0873       sdir->GetObject("Histograms_all/meNxpixZmPanel1", newmeNxpixZmPanel1);
0874       sdir->GetObject("Histograms_all/meNxpixZmPanel2", newmeNxpixZmPanel2);
0875       sdir->GetObject("Histograms_all/meNxpixZpPanel1", newmeNxpixZpPanel1);
0876       sdir->GetObject("Histograms_all/meNxpixZpPanel2", newmeNxpixZpPanel2);
0877       
0878       TLegend* leg6 = new TLegend(0.65, 0.5, 0.89, 0.65);
0879       can_Nxpix->cd(1);
0880       //gPad->SetLogy();
0881       SetUpHistograms(meNxpixBarrel, newmeNxpixBarrel, "barrel, cluster x size (pixels)", leg6 );
0882       Float_t refMax = 1.2*meNxpixBarrel->GetMaximum();
0883       Float_t newMax = 1.2*newmeNxpixBarrel->GetMaximum();
0884       if refMax > newMax
0885       {
0886           meNxpixBarrel->SetMaximum(refMax);
0887       }
0888       else
0889       {
0890           meNxpixBarrel->SetMaximum(newMax);
0891       }
0892       meNxpixBarrel->SetName("Reference");
0893       newmeNxpixBarrel->SetName("New Release");
0894       meNxpixBarrel->Draw("he");
0895       newmeNxpixBarrel->Draw("hesameS"); 
0896       myPV->PVCompute(meNxpixBarrel, newmeNxpixBarrel, te );
0897       leg6->Draw();
0898       h_pv->SetBinContent(++bin, myPV->getPV());
0899       gPad->Update();      
0900       TPaveStats *s23 = (TPaveStats*)meNxpixBarrel->GetListOfFunctions()->FindObject("stats");
0901       if (s23) {
0902     s23->SetX1NDC (0.55); //new x start position
0903     s23->SetX2NDC (0.75); //new x end position
0904       }
0905 
0906       can_Nxpix->cd(2);
0907       //gPad->SetLogy();
0908       SetUpHistograms(meNxpixZmPanel1, newmeNxpixZmPanel1, "panel1, z<0, cluster x size (pixels)" );
0909       Float_t refMax = 1.2*meNxpixZmPanel1->GetMaximum();
0910       Float_t newMax = 1.2*newmeNxpixZmPanel1->GetMaximum();
0911       if refMax > newMax
0912       {
0913           meNxpixZmPanel1->SetMaximum(refMax);
0914       }
0915       else
0916       {
0917           meNxpixZmPanel1->SetMaximum(newMax);
0918       }
0919       meNxpixZmPanel1->SetName("Reference");
0920       newmeNxpixZmPanel1->SetName("New Release");
0921       meNxpixZmPanel1->Draw("he");
0922       newmeNxpixZmPanel1->Draw("hesameS"); 
0923       myPV->PVCompute(meNxpixZmPanel1, newmeNxpixZmPanel1, te );
0924       h_pv->SetBinContent(++bin, myPV->getPV());
0925       gPad->Update();      
0926       TPaveStats *s24 = (TPaveStats*)meNxpixZmPanel1->GetListOfFunctions()->FindObject("stats");
0927       if (s24) {
0928     s24->SetX1NDC (0.55); //new x start position
0929     s24->SetX2NDC (0.75); //new x end position
0930       }
0931 
0932       can_Nxpix->cd(3);
0933       //gPad->SetLogy();
0934       SetUpHistograms(meNxpixZmPanel2, newmeNxpixZmPanel2, "panel2, z<0, cluster x size (pixels)" );
0935       Float_t refMax = 1.2*meNxpixZmPanel2->GetMaximum();
0936       Float_t newMax = 1.2*newmeNxpixZmPanel2->GetMaximum();
0937       if refMax > newMax
0938       {
0939           meNxpixZmPanel2->SetMaximum(refMax);
0940       }
0941       else
0942       {
0943           meNxpixZmPanel2->SetMaximum(newMax);
0944       }
0945       meNxpixZmPanel2->SetName("Reference");
0946       newmeNxpixZmPanel2->SetName("New Release");
0947       meNxpixZmPanel2->Draw("he");
0948       newmeNxpixZmPanel2->Draw("hesameS"); 
0949       myPV->PVCompute(meNxpixZmPanel2, newmeNxpixZmPanel2, te );
0950       h_pv->SetBinContent(++bin, myPV->getPV());
0951       
0952       gPad->Update();      
0953       TPaveStats *s25 = (TPaveStats*)meNxpixZmPanel2->GetListOfFunctions()->FindObject("stats");
0954       if (s25) {
0955     s25->SetX1NDC (0.55); //new x start position
0956     s25->SetX2NDC (0.75); //new x end position
0957       }
0958 
0959       can_Nxpix->cd(5);
0960       //gPad->SetLogy();
0961       SetUpHistograms(meNxpixZpPanel1, newmeNxpixZpPanel1, "panel1, z>0, cluster x size (pixels)" );
0962       Float_t refMax = 1.2*meNxpixZpPanel1->GetMaximum();
0963       Float_t newMax = 1.2*newmeNxpixZpPanel1->GetMaximum();
0964       if refMax > newMax
0965       {
0966           meNxpixZpPanel1->SetMaximum(refMax);
0967       }
0968       else
0969       {
0970           meNxpixZpPanel1->SetMaximum(newMax);
0971       }
0972       meNxpixZpPanel1->SetName("Reference");
0973       newmeNxpixZpPanel1->SetName("New Release");
0974       meNxpixZpPanel1->Draw("he");
0975       newmeNxpixZpPanel1->Draw("hesameS"); 
0976       myPV->PVCompute(meNxpixZpPanel1, newmeNxpixZpPanel1, te );
0977       h_pv->SetBinContent(++bin, myPV->getPV());
0978       
0979       gPad->Update();      
0980       TPaveStats *s26 = (TPaveStats*)meNxpixZpPanel1->GetListOfFunctions()->FindObject("stats");
0981       if (s26) {
0982     s26->SetX1NDC (0.55); //new x start position
0983     s26->SetX2NDC (0.75); //new x end position
0984       }
0985 
0986       can_Nxpix->cd(6);
0987       //gPad->SetLogy();
0988       SetUpHistograms(meNxpixZpPanel2, newmeNxpixZpPanel2, "panel2, z>0, cluster x size (pixels)" );
0989       Float_t refMax = 1.2*meNxpixZpPanel2->GetMaximum();
0990       Float_t newMax = 1.2*newmeNxpixZpPanel2->GetMaximum();
0991       if refMax > newMax
0992       {
0993           meNxpixZpPanel2->SetMaximum(refMax);
0994       }
0995       else
0996       {
0997           meNxpixZpPanel2->SetMaximum(newMax);
0998       }
0999       meNxpixZpPanel2->SetName("Reference");
1000       newmeNxpixZpPanel2->SetName("New Release");
1001       meNxpixZpPanel2->Draw("he");
1002       newmeNxpixZpPanel2->Draw("hesameS"); 
1003       myPV->PVCompute(meNxpixZpPanel2, newmeNxpixZpPanel2, te );
1004       h_pv->SetBinContent(++bin, myPV->getPV());
1005       gPad->Update();      
1006       TPaveStats *s27 = (TPaveStats*)meNxpixZpPanel2->GetListOfFunctions()->FindObject("stats");
1007       if (s27) {
1008     s27->SetX1NDC (0.55); //new x start position
1009     s27->SetX2NDC (0.75); //new x end position
1010       }
1011 
1012       can_Nxpix->SaveAs("meNxpix_compare.eps");
1013       can_Nxpix->SaveAs("meNxpix_compare.gif");
1014     }
1015     
1016 
1017   if (1) 
1018     {
1019       TCanvas* can_Nypix = new TCanvas("can_Nypix", "can_Nypix", 1200, 800);
1020       can_Nypix->Divide(3,2);
1021       
1022       TH1F* meNypixBarrel;
1023       TH1F* meNypixZmPanel1;
1024       TH1F* meNypixZmPanel2;
1025       TH1F* meNypixZpPanel1;
1026       TH1F* meNypixZpPanel2;
1027       
1028       TH1F* newmeNypixBarrel;
1029       TH1F* newmeNypixZmPanel1;
1030       TH1F* newmeNypixZmPanel2;
1031       TH1F* newmeNypixZpPanel1;
1032       TH1F* newmeNypixZpPanel2;
1033       
1034       rdir->GetObject("Histograms_all/meNypixBarrel"  , meNypixBarrel  );
1035       rdir->GetObject("Histograms_all/meNypixZmPanel1", meNypixZmPanel1);
1036       rdir->GetObject("Histograms_all/meNypixZmPanel2", meNypixZmPanel2);
1037       rdir->GetObject("Histograms_all/meNypixZpPanel1", meNypixZpPanel1);
1038       rdir->GetObject("Histograms_all/meNypixZpPanel2", meNypixZpPanel2);
1039       
1040       sdir->GetObject("Histograms_all/meNypixBarrel"  , newmeNypixBarrel  ); 
1041       sdir->GetObject("Histograms_all/meNypixZmPanel1", newmeNypixZmPanel1);
1042       sdir->GetObject("Histograms_all/meNypixZmPanel2", newmeNypixZmPanel2);
1043       sdir->GetObject("Histograms_all/meNypixZpPanel1", newmeNypixZpPanel1);
1044       sdir->GetObject("Histograms_all/meNypixZpPanel2", newmeNypixZpPanel2);
1045       
1046       TLegend* leg7 = new TLegend(0.65, 0.55, 0.89, 0.7);
1047       can_Nypix->cd(1);
1048       //gPad->SetLogy();
1049       SetUpHistograms(meNypixBarrel, newmeNypixBarrel, "barrel, cluster y size (pixels)", leg7 );
1050       Float_t refMax = 1.2*meNypixBarrel->GetMaximum();
1051       Float_t newMax = 1.2*newmeNypixBarrel->GetMaximum();
1052       if refMax > newMax
1053       {
1054           meNypixBarrel->SetMaximum(refMax);
1055       }
1056       else
1057       {
1058           meNypixBarrel->SetMaximum(newMax);
1059       }
1060       meNypixBarrel->SetName("Reference");
1061       newmeNypixBarrel->SetName("New Release");
1062       meNypixBarrel->Draw("he");
1063       newmeNypixBarrel->Draw("hesameS"); 
1064       myPV->PVCompute(meNypixBarrel, newmeNypixBarrel, te );
1065       leg7->Draw();
1066       h_pv->SetBinContent(++bin, myPV->getPV());
1067       gPad->Update();      
1068       TPaveStats *s28 = (TPaveStats*)meNypixBarrel->GetListOfFunctions()->FindObject("stats");
1069       if (s28) {
1070     s28->SetX1NDC (0.55); //new x start position
1071     s28->SetX2NDC (0.75); //new x end position
1072       }
1073 
1074       can_Nypix->cd(2);
1075       //gPad->SetLogy();
1076       SetUpHistograms(meNypixZmPanel1, newmeNypixZmPanel1, "panel1, z<0, cluster y size (pixels)" );
1077       Float_t refMax = 1.2*meNypixZmPanel1->GetMaximum();
1078       Float_t newMax = 1.2*newmeNypixZmPanel1->GetMaximum();
1079       if refMax > newMax
1080       {
1081           meNypixZmPanel1->SetMaximum(refMax);
1082       }
1083       else
1084       {
1085           meNypixZmPanel1->SetMaximum(newMax);
1086       }
1087       meNypixZmPanel1->SetName("Reference");
1088       newmeNypixZmPanel1->SetName("New Release");
1089       meNypixZmPanel1->Draw("he");
1090       newmeNypixZmPanel1->Draw("hesameS"); 
1091       myPV->PVCompute(meNypixZmPanel1, newmeNypixZmPanel1, te );
1092       h_pv->SetBinContent(++bin, myPV->getPV());
1093       gPad->Update();      
1094       TPaveStats *s29 = (TPaveStats*)meNypixZmPanel1->GetListOfFunctions()->FindObject("stats");
1095       if (s29) {
1096     s29->SetX1NDC (0.55); //new x start position
1097     s29->SetX2NDC (0.75); //new x end position
1098       }
1099 
1100       can_Nypix->cd(3);
1101       //gPad->SetLogy();
1102       SetUpHistograms(meNypixZmPanel2, newmeNypixZmPanel2, "panel2, z<0, cluster y size (pixels)" );
1103       Float_t refMax = 1.2*meNypixZmPanel2->GetMaximum();
1104       Float_t newMax = 1.2*newmeNypixZmPanel2->GetMaximum();
1105       if refMax > newMax
1106       {
1107           meNypixZmPanel2->SetMaximum(refMax);
1108       }
1109       else
1110       {
1111           meNypixZmPanel2->SetMaximum(newMax);
1112       }
1113       meNypixZmPanel2->SetName("Reference");
1114       newmeNypixZmPanel2->SetName("New Release");
1115       meNypixZmPanel2->Draw("he");
1116       newmeNypixZmPanel2->Draw("hesameS"); 
1117       myPV->PVCompute(meNypixZmPanel2, newmeNypixZmPanel2, te );
1118       h_pv->SetBinContent(++bin, myPV->getPV());
1119       gPad->Update();      
1120       TPaveStats *s30 = (TPaveStats*)meNypixZmPanel2->GetListOfFunctions()->FindObject("stats");
1121       if (s30) {
1122     s30->SetX1NDC (0.55); //new x start position
1123     s30->SetX2NDC (0.75); //new x end position
1124       }
1125 
1126       can_Nypix->cd(5);
1127       //gPad->SetLogy();
1128       SetUpHistograms(meNypixZpPanel1, newmeNypixZpPanel1, "panel1, z>0, cluster y size (pixels)" );
1129       Float_t refMax = 1.2*meNypixZpPanel1->GetMaximum();
1130       Float_t newMax = 1.2*newmeNypixZpPanel1->GetMaximum();
1131       if refMax > newMax
1132       {
1133           meNypixZpPanel1->SetMaximum(refMax);
1134       }
1135       else
1136       {
1137           meNypixZpPanel1->SetMaximum(newMax);
1138       }
1139       meNypixZpPanel1->SetName("Reference");
1140       newmeNypixZpPanel1->SetName("New Release");
1141       meNypixZpPanel1->Draw("he");
1142       newmeNypixZpPanel1->Draw("hesameS"); 
1143       myPV->PVCompute(meNypixZpPanel1, newmeNypixZpPanel1, te );
1144       h_pv->SetBinContent(++bin, myPV->getPV());
1145       gPad->Update();      
1146       TPaveStats *s31 = (TPaveStats*)meNypixZpPanel1->GetListOfFunctions()->FindObject("stats");
1147       if (s31) {
1148     s31->SetX1NDC (0.55); //new x start position
1149     s31->SetX2NDC (0.75); //new x end position
1150       }
1151 
1152       can_Nypix->cd(6);
1153       //gPad->SetLogy();
1154       SetUpHistograms(meNypixZpPanel2, newmeNypixZpPanel2, "panel2, z>0, cluster y size (pixels)" );
1155       Float_t refMax = 1.2*meNypixZpPanel2->GetMaximum();
1156       Float_t newMax = 1.2*newmeNypixZpPanel2->GetMaximum();
1157       if refMax > newMax
1158       {
1159           meNypixZpPanel2->SetMaximum(refMax);
1160       }
1161       else
1162       {
1163           meNypixZpPanel2->SetMaximum(newMax);
1164       }      
1165       meNypixZpPanel2->SetName("Reference");
1166       newmeNypixZpPanel2->SetName("New Release");
1167       meNypixZpPanel2->Draw("he");
1168       newmeNypixZpPanel2->Draw("hesameS"); 
1169       myPV->PVCompute(meNypixZpPanel2, newmeNypixZpPanel2, te );
1170       h_pv->SetBinContent(++bin, myPV->getPV());      
1171       gPad->Update();      
1172       TPaveStats *s32 = (TPaveStats*)meNypixZpPanel2->GetListOfFunctions()->FindObject("stats");
1173       if (s32) {
1174     s32->SetX1NDC (0.55); //new x start position
1175     s32->SetX2NDC (0.75); //new x end position
1176       }
1177 
1178       can_Nypix->SaveAs("meNypix_compare.eps");
1179       can_Nypix->SaveAs("meNypix_compare.gif");
1180     }
1181   
1182   if (1) 
1183     {
1184       TCanvas* can_Posx = new TCanvas("can_Posx", "can_Posx", 1200, 800);
1185       can_Posx->Divide(3,2);
1186       
1187       TH1F* mePosxBarrel;
1188       TH1F* mePosxZmPanel1;
1189       TH1F* mePosxZmPanel2;
1190       TH1F* mePosxZpPanel1;
1191       TH1F* mePosxZpPanel2;
1192       
1193       TH1F* newmePosxBarrel;
1194       TH1F* newmePosxZmPanel1;
1195       TH1F* newmePosxZmPanel2;
1196       TH1F* newmePosxZpPanel1;
1197       TH1F* newmePosxZpPanel2;
1198       
1199       rdir->GetObject("Histograms_all/mePosxBarrel"  , mePosxBarrel  );
1200       rdir->GetObject("Histograms_all/mePosxZmPanel1", mePosxZmPanel1);
1201       rdir->GetObject("Histograms_all/mePosxZmPanel2", mePosxZmPanel2);
1202       rdir->GetObject("Histograms_all/mePosxZpPanel1", mePosxZpPanel1);
1203       rdir->GetObject("Histograms_all/mePosxZpPanel2", mePosxZpPanel2);
1204       
1205       sdir->GetObject("Histograms_all/mePosxBarrel"  , newmePosxBarrel  ); 
1206       sdir->GetObject("Histograms_all/mePosxZmPanel1", newmePosxZmPanel1);
1207       sdir->GetObject("Histograms_all/mePosxZmPanel2", newmePosxZmPanel2);
1208       sdir->GetObject("Histograms_all/mePosxZpPanel1", newmePosxZpPanel1);
1209       sdir->GetObject("Histograms_all/mePosxZpPanel2", newmePosxZpPanel2);
1210       
1211       TLegend* leg8 = new TLegend(0.3, 0.2, 0.6, 0.4);
1212       can_Posx->cd(1);
1213       //gPad->SetLogy();
1214       SetUpHistograms(mePosxBarrel, newmePosxBarrel, "barrel, x (cm)", leg8 );
1215       Float_t refMax = 1.5*mePosxBarrel->GetMaximum();
1216       Float_t newMax = 1.5*newmePosxBarrel->GetMaximum();
1217       if refMax > newMax
1218       {
1219           mePosxBarrel->SetMaximum(refMax);
1220       }
1221       else
1222       {
1223           mePosxBarrel->SetMaximum(newMax);
1224       }      
1225       mePosxBarrel->SetName("Reference");
1226       newmePosxBarrel->SetName("New Release");
1227       mePosxBarrel->Draw("he");
1228       newmePosxBarrel->Draw("heSameS"); 
1229       myPV->PVCompute(mePosxBarrel, newmePosxBarrel, te, 0.6, 0.75 );
1230       leg8->Draw();
1231       h_pv->SetBinContent(++bin, myPV->getPV());      
1232       gPad->Update();      
1233       TPaveStats *s33 = (TPaveStats*)newmePosxBarrel->GetListOfFunctions()->FindObject("stats");
1234       if (s33) {
1235     s33->SetX1NDC (0.55); //new x start position
1236     s33->SetX2NDC (0.75); //new x end position
1237       }
1238 
1239       can_Posx->cd(2);
1240       //gPad->SetLogy();
1241       SetUpHistograms(mePosxZmPanel1, newmePosxZmPanel1, "panel1, z<0, x (cm)" );
1242       Float_t refMax = 1.5*mePosxZmPanel1->GetMaximum();
1243       Float_t newMax = 1.5*newmePosxZmPanel1->GetMaximum();
1244       if refMax > newMax
1245       {
1246           mePosxZmPanel1->SetMaximum(refMax);
1247       }
1248       else
1249       {
1250           mePosxZmPanel1->SetMaximum(newMax);
1251       }      
1252       mePosxZmPanel1->SetName("Reference");
1253       newmePosxZmPanel1->SetName("New Release");
1254       mePosxZmPanel1->Draw("he");
1255       newmePosxZmPanel1->Draw("hesameS"); 
1256       myPV->PVCompute(mePosxZmPanel1, newmePosxZmPanel1, te, 0.6, 0.75 );
1257       h_pv->SetBinContent(++bin, myPV->getPV());      
1258       gPad->Update();      
1259       TPaveStats *s34 = (TPaveStats*)mePosxZmPanel1->GetListOfFunctions()->FindObject("stats");
1260       if (s34) {
1261     s34->SetX1NDC (0.55); //new x start position
1262     s34->SetX2NDC (0.75); //new x end position
1263       }
1264 
1265       can_Posx->cd(3);
1266       //gPad->SetLogy();
1267       SetUpHistograms(mePosxZmPanel2, newmePosxZmPanel2, "panel2, z>0, x (cm)" );
1268       Float_t refMax = 1.5*mePosxZmPanel2->GetMaximum();
1269       Float_t newMax = 1.5*newmePosxZmPanel2->GetMaximum();
1270       if refMax > newMax
1271       {
1272           mePosxZmPanel2->SetMaximum(refMax);
1273       }
1274       else
1275       {
1276           mePosxZmPanel2->SetMaximum(newMax);
1277       }      
1278       mePosxZmPanel2->SetName("Reference");
1279       newmePosxZmPanel2->SetName("New Release");
1280       mePosxZmPanel2->Draw("he");
1281       newmePosxZmPanel2->Draw("hesameS"); 
1282       myPV->PVCompute(mePosxZmPanel2, newmePosxZmPanel2, te, 0.6, 0.75 );
1283       h_pv->SetBinContent(++bin, myPV->getPV());     
1284       gPad->Update();      
1285       TPaveStats *s35 = (TPaveStats*)mePosxZmPanel2->GetListOfFunctions()->FindObject("stats");
1286       if (s35) {
1287     s35->SetX1NDC (0.55); //new x start position
1288     s35->SetX2NDC (0.75); //new x end position
1289       }
1290 
1291       can_Posx->cd(5);
1292       //gPad->SetLogy();
1293       SetUpHistograms(mePosxZpPanel1, newmePosxZpPanel1, "panel1, z<0, x (cm)" );
1294       Float_t refMax = 1.5*mePosxZpPanel1->GetMaximum();
1295       Float_t newMax = 1.5*newmePosxZpPanel1->GetMaximum();
1296       if refMax > newMax
1297       {
1298           mePosxZpPanel1->SetMaximum(refMax);
1299       }
1300       else
1301       {
1302           mePosxZpPanel1->SetMaximum(newMax);
1303       }
1304       mePosxZpPanel1->SetName("Reference");
1305       newmePosxZpPanel1->SetName("New Release");
1306       mePosxZpPanel1->Draw("he");
1307       newmePosxZpPanel1->Draw("hesameS"); 
1308       myPV->PVCompute(mePosxZpPanel1, newmePosxZpPanel1, te, 0.6, 0.75  );
1309       h_pv->SetBinContent(++bin, myPV->getPV());
1310       gPad->Update();      
1311       TPaveStats *s36 = (TPaveStats*)mePosxZpPanel1->GetListOfFunctions()->FindObject("stats");
1312       if (s36) {
1313     s36->SetX1NDC (0.55); //new x start position
1314     s36->SetX2NDC (0.75); //new x end position
1315       }
1316 
1317       can_Posx->cd(6);
1318       //gPad->SetLogy();
1319       SetUpHistograms(mePosxZpPanel2, newmePosxZpPanel2, "panel2, z>0, x (cm)" );
1320       Float_t refMax = 1.5*mePosxZpPanel2->GetMaximum();
1321       Float_t newMax = 1.5*newmePosxZpPanel2->GetMaximum();
1322       if refMax > newMax
1323       {
1324           mePosxZpPanel2->SetMaximum(refMax);
1325       }
1326       else
1327       {
1328           mePosxZpPanel2->SetMaximum(newMax);
1329       }
1330       mePosxZpPanel2->SetName("Reference");
1331       newmePosxZpPanel2->SetName("New Release");
1332       mePosxZpPanel2->Draw("he");
1333       newmePosxZpPanel2->Draw("hesameS"); 
1334       myPV->PVCompute(mePosxZpPanel2, newmePosxZpPanel2, te, 0.6, 0.75  );
1335       h_pv->SetBinContent(++bin, myPV->getPV());      
1336       gPad->Update();      
1337       TPaveStats *s37 = (TPaveStats*)mePosxZpPanel2->GetListOfFunctions()->FindObject("stats");
1338       if (s37) {
1339     s37->SetX1NDC (0.55); //new x start position
1340     s37->SetX2NDC (0.75); //new x end position
1341       }
1342 
1343       can_Posx->SaveAs("mePosx_compare.eps");
1344       can_Posx->SaveAs("mePosx_compare.gif");
1345   }
1346 
1347   if (1) 
1348     {
1349       TCanvas* can_Posy = new TCanvas("can_Posy", "can_Posy", 1200, 800);
1350       can_Posy->Divide(3,2);
1351       
1352       TH1F* mePosyBarrel;
1353       TH1F* mePosyZmPanel1;
1354       TH1F* mePosyZmPanel2;
1355       TH1F* mePosyZpPanel1;
1356       TH1F* mePosyZpPanel2;
1357       
1358       TH1F* newmePosyBarrel;
1359       TH1F* newmePosyZmPanel1;
1360       TH1F* newmePosyZmPanel2;
1361       TH1F* newmePosyZpPanel1;
1362       TH1F* newmePosyZpPanel2;
1363       
1364       rdir->GetObject("Histograms_all/mePosyBarrel"  , mePosyBarrel  );
1365       rdir->GetObject("Histograms_all/mePosyZmPanel1", mePosyZmPanel1);
1366       rdir->GetObject("Histograms_all/mePosyZmPanel2", mePosyZmPanel2);
1367       rdir->GetObject("Histograms_all/mePosyZpPanel1", mePosyZpPanel1);
1368       rdir->GetObject("Histograms_all/mePosyZpPanel2", mePosyZpPanel2);
1369       
1370       sdir->GetObject("Histograms_all/mePosyBarrel"  , newmePosyBarrel  ); 
1371       sdir->GetObject("Histograms_all/mePosyZmPanel1", newmePosyZmPanel1);
1372       sdir->GetObject("Histograms_all/mePosyZmPanel2", newmePosyZmPanel2);
1373       sdir->GetObject("Histograms_all/mePosyZpPanel1", newmePosyZpPanel1);
1374       sdir->GetObject("Histograms_all/mePosyZpPanel2", newmePosyZpPanel2);
1375       
1376       TLegend* leg9 = new TLegend(0.3, 0.2, 0.6, 0.4);
1377       can_Posy->cd(1);
1378       //gPad->SetLogy();
1379       SetUpHistograms(mePosyBarrel, newmePosyBarrel, "barrel, y (cm)", leg9 );
1380       Float_t refMax = 1.2*mePosyBarrel->GetMaximum();
1381       Float_t newMax = 1.2*newmePosyBarrel->GetMaximum();
1382       if refMax > newMax
1383       {
1384           mePosyBarrel->SetMaximum(refMax);
1385       }
1386       else
1387       {
1388           mePosyBarrel->SetMaximum(newMax);
1389       }      
1390       mePosyBarrel->SetName("Reference");
1391       newmePosyBarrel->SetName("New Release");
1392       mePosyBarrel->Draw("he");
1393       newmePosyBarrel->Draw("heSameS"); 
1394       myPV->PVCompute(mePosyBarrel, newmePosyBarrel, te, 0.3, 0.4 );
1395       leg9->Draw();
1396       h_pv->SetBinContent(++bin, myPV->getPV());
1397       gPad->Update();      
1398       TPaveStats *s38 = (TPaveStats*)mePosyBarrel->GetListOfFunctions()->FindObject("stats");
1399       if (s38) {
1400     s38->SetX1NDC (0.55); //new x start position
1401     s38->SetX2NDC (0.75); //new x end position
1402       }
1403 
1404       can_Posy->cd(2);
1405       //gPad->SetLogy();
1406       SetUpHistograms(mePosyZmPanel1,  newmePosyZmPanel1, "panel1, z<0, y (cm)" );
1407       Float_t refMax = 1.5*mePosyZmPanel1->GetMaximum();
1408       Float_t newMax = 1.5*newmePosyZmPanel1->GetMaximum();
1409       if refMax > newMax
1410       {
1411           mePosyZmPanel1->SetMaximum(refMax);
1412       }
1413       else
1414       {
1415           mePosyZmPanel1->SetMaximum(newMax);
1416       }      
1417       mePosyZmPanel1->SetName("Reference");
1418       newmePosyZmPanel1->SetName("New Release");
1419       mePosyZmPanel1->Draw("he");
1420       newmePosyZmPanel1->Draw("hesameS"); 
1421       myPV->PVCompute(mePosyZmPanel1, newmePosyZmPanel1, te, 0.6, 0.75  );
1422       h_pv->SetBinContent(++bin, myPV->getPV());
1423       gPad->Update();      
1424       TPaveStats *s39 = (TPaveStats*)mePosyZmPanel1->GetListOfFunctions()->FindObject("stats");
1425       if (s39) {
1426     s39->SetX1NDC (0.55); //new x start position
1427     s39->SetX2NDC (0.75); //new x end position
1428       }
1429 
1430       can_Posy->cd(3);
1431       //gPad->SetLogy();
1432       SetUpHistograms(mePosyZmPanel2, newmePosyZmPanel2, "panel2, z<0, y (cm)" );
1433       Float_t refMax = 1.5*mePosyZmPanel2->GetMaximum();
1434       Float_t newMax = 1.5*newmePosyZmPanel2->GetMaximum();
1435       if refMax > newMax
1436       {
1437           mePosyZmPanel2->SetMaximum(refMax);
1438       }
1439       else
1440       {
1441           mePosyZmPanel2->SetMaximum(newMax);
1442       }      
1443       mePosyZmPanel2->SetName("Reference");
1444       newmePosyZmPanel2->SetName("New Release");
1445       mePosyZmPanel2->Draw("he");
1446       newmePosyZmPanel2->Draw("hesameS"); 
1447       myPV->PVCompute(mePosyZmPanel2, newmePosyZmPanel2, te, 0.6, 0.75  );
1448       h_pv->SetBinContent(++bin, myPV->getPV());
1449       gPad->Update();      
1450       TPaveStats *s40 = (TPaveStats*)mePosyZmPanel2->GetListOfFunctions()->FindObject("stats");
1451       if (s40) {
1452     s40->SetX1NDC (0.55); //new x start position
1453     s40->SetX2NDC (0.75); //new x end position
1454       }
1455 
1456       can_Posy->cd(5);
1457       //gPad->SetLogy();
1458       SetUpHistograms(mePosyZpPanel1, newmePosyZpPanel1, "panel1, z>0, y (cm)" );
1459       Float_t refMax = 1.5*mePosyZpPanel1->GetMaximum();
1460       Float_t newMax = 1.5*newmePosyZpPanel1->GetMaximum();
1461       if refMax > newMax
1462       {
1463           mePosyZpPanel1->SetMaximum(refMax);
1464       }
1465       else
1466       {
1467           mePosyZpPanel1->SetMaximum(newMax);
1468       }      
1469       mePosyZpPanel1->SetName("Reference");
1470       newmePosyZpPanel1->SetName("New Release");
1471       mePosyZpPanel1->Draw("he");
1472       newmePosyZpPanel1->Draw("hesameS"); 
1473       myPV->PVCompute(mePosyZpPanel1, newmePosyZpPanel1, te, 0.6, 0.75 );
1474       h_pv->SetBinContent(++bin, myPV->getPV());
1475       gPad->Update();      
1476       TPaveStats *s41 = (TPaveStats*)mePosyZpPanel1->GetListOfFunctions()->FindObject("stats");
1477       if (s41) {
1478     s41->SetX1NDC (0.55); //new x start position
1479     s41->SetX2NDC (0.75); //new x end position
1480       }
1481 
1482       can_Posy->cd(6);
1483       //gPad->SetLogy();
1484       SetUpHistograms(mePosyZpPanel2, newmePosyZpPanel2, "panel2, z>0, y (cm)" );
1485       Float_t refMax = 1.5*mePosyZpPanel2->GetMaximum();
1486       Float_t newMax = 1.5*newmePosyZpPanel2->GetMaximum();
1487       if refMax > newMax
1488       {
1489           mePosyZpPanel2->SetMaximum(refMax);
1490       }
1491       else
1492       {
1493           mePosyZpPanel2->SetMaximum(newMax);
1494       }      
1495       mePosyZpPanel2->SetName("Reference");
1496       newmePosyZpPanel2->SetName("New Release");
1497       mePosyZpPanel2->Draw("he");
1498       newmePosyZpPanel2->Draw("hesameS"); 
1499       myPV->PVCompute(mePosyZpPanel2, newmePosyZpPanel2, te, 0.6, 0.75 );
1500       h_pv->SetBinContent(++bin, myPV->getPV());
1501       gPad->Update();      
1502       TPaveStats *s42 = (TPaveStats*)mePosyZpPanel2->GetListOfFunctions()->FindObject("stats");
1503       if (s42) {
1504     s42->SetX1NDC (0.55); //new x start position
1505     s42->SetX2NDC (0.75); //new x end position
1506       }
1507 
1508       can_Posy->SaveAs("mePosy_compare.eps");
1509       can_Posy->SaveAs("mePosy_compare.gif");
1510     }
1511 
1512   double lpull = -1.0;
1513   double hpull =  1.0;
1514 
1515   double lwpull = 0.0;
1516   double hwpull = 2.0;
1517   
1518   //if (   0   ) 
1519   if (   1   ) 
1520     {
1521       TCanvas* can_PullXvsAlpha = new TCanvas("can_PullXvsAlpha", "can_PullXvsAlpha", 1200, 800);
1522       can_PullXvsAlpha->Divide(3,2);
1523       
1524       TProfile* mePullXvsAlphaBarrel;
1525       TProfile* mePullXvsAlphaZmPanel1;
1526       TProfile* mePullXvsAlphaZmPanel2;
1527       TProfile* mePullXvsAlphaZpPanel1;
1528       TProfile* mePullXvsAlphaZpPanel2;
1529       
1530       TProfile* newmePullXvsAlphaBarrel;
1531       TProfile* newmePullXvsAlphaZmPanel1;
1532       TProfile* newmePullXvsAlphaZmPanel2;
1533       TProfile* newmePullXvsAlphaZpPanel1;
1534       TProfile* newmePullXvsAlphaZpPanel2;
1535       
1536       rdir->GetObject("Histograms_all/mePullXvsAlphaBarrel"  , mePullXvsAlphaBarrel  );
1537       rdir->GetObject("Histograms_all/mePullXvsAlphaZmPanel1", mePullXvsAlphaZmPanel1);
1538       rdir->GetObject("Histograms_all/mePullXvsAlphaZmPanel2", mePullXvsAlphaZmPanel2);
1539       rdir->GetObject("Histograms_all/mePullXvsAlphaZpPanel1", mePullXvsAlphaZpPanel1);
1540       rdir->GetObject("Histograms_all/mePullXvsAlphaZpPanel2", mePullXvsAlphaZpPanel2);
1541       
1542       sdir->GetObject("Histograms_all/mePullXvsAlphaBarrel"  , newmePullXvsAlphaBarrel  ); 
1543       sdir->GetObject("Histograms_all/mePullXvsAlphaZmPanel1", newmePullXvsAlphaZmPanel1);
1544       sdir->GetObject("Histograms_all/mePullXvsAlphaZmPanel2", newmePullXvsAlphaZmPanel2);
1545       sdir->GetObject("Histograms_all/mePullXvsAlphaZpPanel1", newmePullXvsAlphaZpPanel1);
1546       sdir->GetObject("Histograms_all/mePullXvsAlphaZpPanel2", newmePullXvsAlphaZpPanel2);
1547       
1548       TLegend* leg10 = new TLegend(0.3, 0.2, 0.6, 0.4);
1549       can_PullXvsAlpha->cd(1);
1550       //gPad->SetLogy();
1551       SetUpProfileHistograms(mePullXvsAlphaBarrel, newmePullXvsAlphaBarrel, "barrel, |alpha| (deg)", "pull x", lpull, hpull, leg10 );
1552       Float_t refMax = 0.5 + mePullXvsAlphaBarrel->GetMaximum();
1553       Float_t newMax = 0.5 + newmePullXvsAlphaBarrel->GetMaximum();
1554       if refMax > newMax
1555       {
1556           mePullXvsAlphaBarrel->SetMaximum(refMax);
1557       }
1558       else
1559       {
1560           mePullXvsAlphaBarrel->SetMaximum(newMax);
1561       }      
1562       mePullXvsAlphaBarrel->SetName("Reference");
1563       newmePullXvsAlphaBarrel->SetName("New Release");
1564       mePullXvsAlphaBarrel->Draw("e");
1565       newmePullXvsAlphaBarrel->Draw("eSameS"); 
1566       myPV->PVCompute(mePullXvsAlphaBarrel, newmePullXvsAlphaBarrel, te, 0.3, 0.4  );
1567       leg10->Draw();
1568       h_pv->SetBinContent(++bin, myPV->getPV());
1569       gPad->Update();      
1570       TPaveStats *s43 = (TPaveStats*)mePullXvsAlphaBarrel->GetListOfFunctions()->FindObject("stats");
1571       if (s43) {
1572     s43->SetX1NDC (0.55); //new x start position
1573     s43->SetX2NDC (0.75); //new x end position
1574       }
1575 
1576       can_PullXvsAlpha->cd(2);
1577       //gPad->SetLogy();
1578       SetUpProfileHistograms(mePullXvsAlphaZmPanel1, newmePullXvsAlphaZmPanel1, "panel1, z<0, |alpha| (deg)", "pull x", lpull, hpull );
1579       Float_t refMax = 0.5+1.5*mePullXvsAlphaZmPanel1->GetMaximum();
1580       Float_t newMax = 0.5+1.5*newmePullXvsAlphaZmPanel1->GetMaximum();
1581       if refMax > newMax
1582       {
1583           mePullXvsAlphaZmPanel1->SetMaximum(refMax);
1584       }
1585       else
1586       {
1587           mePullXvsAlphaZmPanel1->SetMaximum(newMax);
1588       }      
1589       mePullXvsAlphaZmPanel1->SetName("Reference");
1590       newmePullXvsAlphaZmPanel1->SetName("New Release");
1591       mePullXvsAlphaZmPanel1->Draw("e");
1592       newmePullXvsAlphaZmPanel1->Draw("esameS"); 
1593       myPV->PVCompute(mePullXvsAlphaZmPanel1, newmePullXvsAlphaZmPanel1, te, 0.2, 0.2);
1594       h_pv->SetBinContent(++bin, myPV->getPV());
1595       gPad->Update();      
1596       TPaveStats *s44 = (TPaveStats*)mePullXvsAlphaZmPanel1->GetListOfFunctions()->FindObject("stats");
1597       if (s44) {
1598     s44->SetX1NDC (0.55); //new x start position
1599     s44->SetX2NDC (0.75); //new x end position
1600       }
1601 
1602       can_PullXvsAlpha->cd(3);
1603       //gPad->SetLogy();
1604       SetUpProfileHistograms(mePullXvsAlphaZmPanel2, newmePullXvsAlphaZmPanel2, "panel2, z<0, |alpha| (deg)", "pull x", lpull, hpull );
1605       Float_t refMax = 0.5+1.5*mePullXvsAlphaZmPanel2->GetMaximum();
1606       Float_t newMax = 0.5+1.5*newmePullXvsAlphaZmPanel2->GetMaximum();
1607       if refMax > newMax
1608       {
1609           mePullXvsAlphaZmPanel2->SetMaximum(refMax);
1610       }
1611       else
1612       {
1613           mePullXvsAlphaZmPanel2->SetMaximum(newMax);
1614       }      
1615       mePullXvsAlphaZmPanel2->SetName("Reference");
1616       newmePullXvsAlphaZmPanel2->SetName("New Release");
1617       mePullXvsAlphaZmPanel2->Draw("e");
1618       newmePullXvsAlphaZmPanel2->Draw("esameS"); 
1619       myPV->PVCompute(mePullXvsAlphaZmPanel2, newmePullXvsAlphaZmPanel2, te, 0.2, 0.2);
1620       h_pv->SetBinContent(++bin, myPV->getPV());
1621       gPad->Update();      
1622       TPaveStats *s45 = (TPaveStats*)mePullXvsAlphaZmPanel2->GetListOfFunctions()->FindObject("stats");
1623       if (s45) {
1624     s45->SetX1NDC (0.55); //new x start position
1625     s45->SetX2NDC (0.75); //new x end position
1626       }
1627 
1628       can_PullXvsAlpha->cd(5);
1629       //gPad->SetLogy();
1630       SetUpProfileHistograms(mePullXvsAlphaZpPanel1, newmePullXvsAlphaZpPanel1, "panel1, z>0, |alpha| (deg)", "pull x", lpull, hpull );
1631       Float_t refMax = 0.5+1.5*mePullXvsAlphaZpPanel1->GetMaximum();
1632       Float_t newMax = 0.5+1.5*newmePullXvsAlphaZpPanel1->GetMaximum();
1633       if refMax > newMax
1634       {
1635           mePullXvsAlphaZpPanel1->SetMaximum(refMax);
1636       }
1637       else
1638       {
1639           mePullXvsAlphaZpPanel1->SetMaximum(newMax);
1640       }      
1641       mePullXvsAlphaZpPanel1->SetName("Reference");
1642       newmePullXvsAlphaZpPanel1->SetName("New Release");
1643       mePullXvsAlphaZpPanel1->Draw("e");
1644       newmePullXvsAlphaZpPanel1->Draw("esameS"); 
1645       myPV->PVCompute(mePullXvsAlphaZpPanel1, newmePullXvsAlphaZpPanel1, te, 0.2, 0.2);
1646       h_pv->SetBinContent(++bin, myPV->getPV());
1647       gPad->Update();      
1648       TPaveStats *s46 = (TPaveStats*)mePullXvsAlphaZpPanel1->GetListOfFunctions()->FindObject("stats");
1649       if (s46) {
1650     s46->SetX1NDC (0.55); //new x start position
1651     s46->SetX2NDC (0.75); //new x end position
1652       }
1653 
1654       can_PullXvsAlpha->cd(6);
1655       //gPad->SetLogy();
1656       SetUpProfileHistograms(mePullXvsAlphaZpPanel2, newmePullXvsAlphaZpPanel2, "panel2, z>0, |alpha| (deg)", "pull x", lpull, hpull );
1657       Float_t refMax = 0.5+1.5*mePullXvsAlphaZpPanel2->GetMaximum();
1658       Float_t newMax = 0.5+1.5*newmePullXvsAlphaZpPanel2->GetMaximum();
1659       if refMax > newMax
1660       {
1661           mePullXvsAlphaZpPanel2->SetMaximum(refMax);
1662       }
1663       else
1664       {
1665           mePullXvsAlphaZpPanel2->SetMaximum(newMax);
1666       }      
1667       mePullXvsAlphaZpPanel2->SetName("Reference");
1668       newmePullXvsAlphaZpPanel2->SetName("New Release");
1669       mePullXvsAlphaZpPanel2->Draw("e");
1670       newmePullXvsAlphaZpPanel2->Draw("esameS"); 
1671       myPV->PVCompute(mePullXvsAlphaZpPanel2, newmePullXvsAlphaZpPanel2, te , 0.2, 0.2);
1672       h_pv->SetBinContent(++bin, myPV->getPV());
1673       gPad->Update();      
1674       TPaveStats *s47 = (TPaveStats*)mePullXvsAlphaZpPanel2->GetListOfFunctions()->FindObject("stats");
1675       if (s47) {
1676     s47->SetX1NDC (0.55); //new x start position
1677     s47->SetX2NDC (0.75); //new x end position
1678       }
1679 
1680       can_PullXvsAlpha->SaveAs("mePullXvsAlpha_compare.eps");
1681       can_PullXvsAlpha->SaveAs("mePullXvsAlpha_compare.gif");
1682     }
1683 
1684   //if (   0   ) 
1685   if (   1   ) 
1686     {
1687       TCanvas* can_PullXvsBeta = new TCanvas("can_PullXvsBeta", "can_PullXvsBeta", 1200, 800);
1688       can_PullXvsBeta->Divide(3,2);
1689       
1690       TProfile* mePullXvsBetaBarrel;
1691       TProfile* mePullXvsBetaZmPanel1;
1692       TProfile* mePullXvsBetaZmPanel2;
1693       TProfile* mePullXvsBetaZpPanel1;
1694       TProfile* mePullXvsBetaZpPanel2;
1695       
1696       TProfile* newmePullXvsBetaBarrel;
1697       TProfile* newmePullXvsBetaZmPanel1;
1698       TProfile* newmePullXvsBetaZmPanel2;
1699       TProfile* newmePullXvsBetaZpPanel1;
1700       TProfile* newmePullXvsBetaZpPanel2;
1701       
1702       rdir->GetObject("Histograms_all/mePullXvsBetaBarrel"  , mePullXvsBetaBarrel  );
1703       rdir->GetObject("Histograms_all/mePullXvsBetaZmPanel1", mePullXvsBetaZmPanel1);
1704       rdir->GetObject("Histograms_all/mePullXvsBetaZmPanel2", mePullXvsBetaZmPanel2);
1705       rdir->GetObject("Histograms_all/mePullXvsBetaZpPanel1", mePullXvsBetaZpPanel1);
1706       rdir->GetObject("Histograms_all/mePullXvsBetaZpPanel2", mePullXvsBetaZpPanel2);
1707       
1708       sdir->GetObject("Histograms_all/mePullXvsBetaBarrel"  , newmePullXvsBetaBarrel  ); 
1709       sdir->GetObject("Histograms_all/mePullXvsBetaZmPanel1", newmePullXvsBetaZmPanel1);
1710       sdir->GetObject("Histograms_all/mePullXvsBetaZmPanel2", newmePullXvsBetaZmPanel2);
1711       sdir->GetObject("Histograms_all/mePullXvsBetaZpPanel1", newmePullXvsBetaZpPanel1);
1712       sdir->GetObject("Histograms_all/mePullXvsBetaZpPanel2", newmePullXvsBetaZpPanel2);
1713       
1714       TLegend* leg11 = new TLegend(0.3, 0.2, 0.6, 0.4);
1715       can_PullXvsBeta->cd(1);
1716       //gPad->SetLogy();
1717       SetUpProfileHistograms(mePullXvsBetaBarrel, newmePullXvsBetaBarrel, "barrel, |beta| (deg)", "pull x", lpull, hpull, leg11 );
1718       Float_t refMax = 0.3+1.2*mePullXvsBetaBarrel->GetMaximum();
1719       Float_t newMax = 0.3+1.2*newmePullXvsBetaBarrel->GetMaximum();
1720       if refMax > newMax
1721       {
1722           mePullXvsBetaBarrel->SetMaximum(refMax);
1723       }
1724       else
1725       {
1726           mePullXvsBetaBarrel->SetMaximum(newMax);
1727       }      
1728       mePullXvsBetaBarrel->SetName("Reference");
1729       newmePullXvsBetaBarrel->SetName("New Release");
1730       mePullXvsBetaBarrel->Draw("e");
1731       newmePullXvsBetaBarrel->Draw("eSameS"); 
1732       myPV->PVCompute(mePullXvsBetaBarrel, newmePullXvsBetaBarrel, te, 0.3, 0.4  );
1733       leg11->Draw();
1734       h_pv->SetBinContent(++bin, myPV->getPV());
1735       gPad->Update();      
1736       TPaveStats *s48 = (TPaveStats*)mePullXvsBetaBarrel->GetListOfFunctions()->FindObject("stats");
1737       if (s48) {
1738     s48->SetX1NDC (0.55); //new x start position
1739     s48->SetX2NDC (0.75); //new x end position
1740       }
1741 
1742       can_PullXvsBeta->cd(2);
1743       //gPad->SetLogy();
1744       SetUpProfileHistograms(mePullXvsBetaZmPanel1, newmePullXvsBetaZmPanel1, "panel1, z<0, |beta| (deg)", "pull x", lpull, hpull );
1745       Float_t refMax = 0.5+1.2*mePullXvsBetaZmPanel1->GetMaximum();
1746       Float_t newMax = 0.5+1.2*newmePullXvsBetaZmPanel1->GetMaximum();
1747       if refMax > newMax
1748       {
1749           mePullXvsBetaZmPanel1->SetMaximum(refMax);
1750       }
1751       else
1752       {
1753           mePullXvsBetaZmPanel1->SetMaximum(newMax);
1754       }      
1755       mePullXvsBetaZmPanel1->SetName("Reference");
1756       newmePullXvsBetaZmPanel1->SetName("New Release");
1757       mePullXvsBetaZmPanel1->Draw("e");
1758       newmePullXvsBetaZmPanel1->Draw("esameS"); 
1759       myPV->PVCompute(mePullXvsBetaZmPanel1, newmePullXvsBetaZmPanel1, te, 0.2, 0.2);
1760       h_pv->SetBinContent(++bin, myPV->getPV());
1761       gPad->Update();      
1762       TPaveStats *s49 = (TPaveStats*)mePullXvsBetaZmPanel1->GetListOfFunctions()->FindObject("stats");
1763       if (s49) {
1764     s49->SetX1NDC (0.55); //new x start position
1765     s49->SetX2NDC (0.75); //new x end position
1766       }
1767 
1768       can_PullXvsBeta->cd(3);
1769       //gPad->SetLogy();
1770       SetUpProfileHistograms(mePullXvsBetaZmPanel2, newmePullXvsBetaZmPanel2, "panel2, z<0, |beta| (deg)", "pull x", lpull, hpull );
1771       Float_t refMax = 0.5+1.2*mePullXvsBetaZmPanel2->GetMaximum();
1772       Float_t newMax = 0.5+1.2*newmePullXvsBetaZmPanel2->GetMaximum();
1773       if refMax > newMax
1774       {
1775           mePullXvsBetaZmPanel2->SetMaximum(refMax);
1776       }
1777       else
1778       {
1779           mePullXvsBetaZmPanel2->SetMaximum(newMax);
1780       }      
1781       mePullXvsBetaZmPanel2->SetName("Reference");
1782       newmePullXvsBetaZmPanel2->SetName("New Release");
1783       mePullXvsBetaZmPanel2->Draw("e");
1784       newmePullXvsBetaZmPanel2->Draw("esameS"); 
1785       myPV->PVCompute(mePullXvsBetaZmPanel2, newmePullXvsBetaZmPanel2, te, 0.2, 0.2);
1786       h_pv->SetBinContent(++bin, myPV->getPV());
1787       gPad->Update();      
1788       TPaveStats *s50 = (TPaveStats*)mePullXvsBetaZmPanel2->GetListOfFunctions()->FindObject("stats");
1789       if (s50) {
1790     s50->SetX1NDC (0.55); //new x start position
1791     s50->SetX2NDC (0.75); //new x end position
1792       }
1793 
1794       can_PullXvsBeta->cd(5);
1795       //gPad->SetLogy();
1796       SetUpProfileHistograms(mePullXvsBetaZpPanel1, newmePullXvsBetaZpPanel1, "panel1, z>0, |beta| (deg)", "pull x", lpull, hpull );
1797       Float_t refMax = 0.5+1.2*mePullXvsBetaZpPanel1->GetMaximum();
1798       Float_t newMax = 0.5+1.2*newmePullXvsBetaZpPanel1->GetMaximum();
1799       if refMax > newMax
1800       {
1801           mePullXvsBetaZpPanel1->SetMaximum(refMax);
1802       }
1803       else
1804       {
1805           mePullXvsBetaZpPanel1->SetMaximum(newMax);
1806       }      
1807       mePullXvsBetaZpPanel1->SetName("Reference");
1808       newmePullXvsBetaZpPanel1->SetName("New Release");
1809       mePullXvsBetaZpPanel1->Draw("e");
1810       newmePullXvsBetaZpPanel1->Draw("esameS"); 
1811       myPV->PVCompute(mePullXvsBetaZpPanel1, newmePullXvsBetaZpPanel1, te, 0.2, 0.2 );
1812       h_pv->SetBinContent(++bin, myPV->getPV());
1813       gPad->Update();      
1814       TPaveStats *s51 = (TPaveStats*)mePullXvsBetaZpPanel1->GetListOfFunctions()->FindObject("stats");
1815       if (s51) {
1816     s51->SetX1NDC (0.55); //new x start position
1817     s51->SetX2NDC (0.75); //new x end position
1818       }
1819 
1820       can_PullXvsBeta->cd(6);
1821       //gPad->SetLogy();
1822       SetUpProfileHistograms(mePullXvsBetaZpPanel2, newmePullXvsBetaZpPanel2, "panel2, z>0, |beta| (deg)", "pull x", lpull, hpull );
1823       Float_t refMax = 0.5+1.2*mePullXvsBetaZpPanel2->GetMaximum();
1824       Float_t newMax = 0.5+1.2*newmePullXvsBetaZpPanel2->GetMaximum();
1825       if refMax > newMax
1826       {
1827           mePullXvsBetaZpPanel2->SetMaximum(refMax);
1828       }
1829       else
1830       {
1831           mePullXvsBetaZpPanel2->SetMaximum(newMax);
1832       }      
1833       mePullXvsBetaZpPanel2->SetName("Reference");
1834       newmePullXvsBetaZpPanel2->SetName("New Release");
1835       mePullXvsBetaZpPanel2->Draw("e");
1836       newmePullXvsBetaZpPanel2->Draw("esameS"); 
1837       myPV->PVCompute(mePullXvsBetaZpPanel2, newmePullXvsBetaZpPanel2, te, 0.2, 0.2);
1838       h_pv->SetBinContent(++bin, myPV->getPV());
1839       gPad->Update();      
1840       TPaveStats *s52 = (TPaveStats*)mePullXvsBetaZpPanel2->GetListOfFunctions()->FindObject("stats");
1841       if (s52) {
1842     s52->SetX1NDC (0.55); //new x start position
1843     s52->SetX2NDC (0.75); //new x end position
1844       }
1845 
1846       can_PullXvsBeta->SaveAs("mePullXvsBeta_compare.eps");
1847       can_PullXvsBeta->SaveAs("mePullXvsBeta_compare.gif");
1848     }
1849 
1850   
1851  if (   1   ) 
1852     {
1853       TCanvas* can_WPullXvsAlpha = new TCanvas("can_WPullXvsAlpha", "can_WPullXvsAlpha", 1200, 800);
1854       can_WPullXvsAlpha->Divide(3,2);
1855       
1856       TProfile* meWPullXvsAlphaBarrelNFP;
1857       TProfile* meWPullXvsAlphaBarrelFP;
1858       TProfile* meWPullXvsAlphaZmPanel1;
1859       TProfile* meWPullXvsAlphaZmPanel2;
1860       TProfile* meWPullXvsAlphaZpPanel1;
1861       TProfile* meWPullXvsAlphaZpPanel2;
1862       
1863       TProfile* newmeWPullXvsAlphaBarrelNFP;
1864       TProfile* newmeWPullXvsAlphaBarrelFP;
1865       TProfile* newmeWPullXvsAlphaZmPanel1;
1866       TProfile* newmeWPullXvsAlphaZmPanel2;
1867       TProfile* newmeWPullXvsAlphaZpPanel1;
1868       TProfile* newmeWPullXvsAlphaZpPanel2;
1869       
1870       rdir->GetObject("Histograms_all/meWPullXvsAlphaBarrelNonFlippedLadders", meWPullXvsAlphaBarrelNFP  );
1871       rdir->GetObject("Histograms_all/meWPullXvsAlphaBarrelFlippedLadders"   , meWPullXvsAlphaBarrelFP   );
1872       rdir->GetObject("Histograms_all/meWPullXvsAlphaZmPanel1", meWPullXvsAlphaZmPanel1);
1873       rdir->GetObject("Histograms_all/meWPullXvsAlphaZmPanel2", meWPullXvsAlphaZmPanel2);
1874       rdir->GetObject("Histograms_all/meWPullXvsAlphaZpPanel1", meWPullXvsAlphaZpPanel1);
1875       rdir->GetObject("Histograms_all/meWPullXvsAlphaZpPanel2", meWPullXvsAlphaZpPanel2);
1876       
1877       sdir->GetObject("Histograms_all/meWPullXvsAlphaBarrelNonFlippedLadders", newmeWPullXvsAlphaBarrelNFP  );
1878       sdir->GetObject("Histograms_all/meWPullXvsAlphaBarrelFlippedLadders"   , newmeWPullXvsAlphaBarrelFP   );
1879       sdir->GetObject("Histograms_all/meWPullXvsAlphaZmPanel1", newmeWPullXvsAlphaZmPanel1);
1880       sdir->GetObject("Histograms_all/meWPullXvsAlphaZmPanel2", newmeWPullXvsAlphaZmPanel2);
1881       sdir->GetObject("Histograms_all/meWPullXvsAlphaZpPanel1", newmeWPullXvsAlphaZpPanel1);
1882       sdir->GetObject("Histograms_all/meWPullXvsAlphaZpPanel2", newmeWPullXvsAlphaZpPanel2);
1883       
1884       TLegend* leg10 = new TLegend(0.3, 0.2, 0.6, 0.4);
1885       can_WPullXvsAlpha->cd(1);
1886       //gPad->SetLogy();
1887       SetUpProfileHistograms(meWPullXvsAlphaBarrelNFP, newmeWPullXvsAlphaBarrelNFP, "non-flipped  ladders, barrel, |alpha| (deg)", "< | pull x | >", lwpull, hwpull, leg10 );
1888       Float_t refMax = 0.5+1.2*meWPullXvsAlphaBarrelNFP->GetMaximum();
1889       Float_t newMax = 0.5+1.2*newmeWPullXvsAlphaBarrelNFP->GetMaximum();
1890       if refMax > newMax
1891       {
1892           meWPullXvsAlphaBarrelNFP->SetMaximum(refMax);
1893       }
1894       else
1895       {
1896           meWPullXvsAlphaBarrelNFP->SetMaximum(newMax);
1897       }      
1898       meWPullXvsAlphaBarrelNFP->SetName("Reference");
1899       newmeWPullXvsAlphaBarrelNFP->SetName("New Release");
1900       meWPullXvsAlphaBarrelNFP->Draw("e");
1901       newmeWPullXvsAlphaBarrelNFP->Draw("eSameS"); 
1902       myPV->PVCompute(meWPullXvsAlphaBarrelNFP, newmeWPullXvsAlphaBarrelNFP, te, 0.3, 0.4  );
1903       leg10->Draw();
1904       h_pv->SetBinContent(++bin, myPV->getPV());
1905       gPad->Update();      
1906       TPaveStats *s53 = (TPaveStats*)meWPullXvsAlphaBarrelNFP->GetListOfFunctions()->FindObject("stats");
1907       if (s53) {
1908     s53->SetX1NDC (0.55); //new x start position
1909     s53->SetX2NDC (0.75); //new x end position
1910       }
1911       can_WPullXvsAlpha->cd(2);
1912       //gPad->SetLogy();
1913       SetUpProfileHistograms(meWPullXvsAlphaZmPanel1, newmeWPullXvsAlphaZmPanel1, "panel1, z<0, |alpha| (deg)", "< | pull x | >", lwpull, hwpull );
1914       Float_t refMax = 0.5+1.2*meWPullXvsAlphaZmPanel1->GetMaximum();
1915       Float_t newMax = 0.5+1.2*newmeWPullXvsAlphaZmPanel1->GetMaximum();
1916       if refMax > newMax
1917       {
1918           meWPullXvsAlphaZmPanel1->SetMaximum(refMax);
1919       }
1920       else
1921       {
1922           meWPullXvsAlphaZmPanel1->SetMaximum(newMax);
1923       }      
1924       meWPullXvsAlphaZmPanel1->SetName("Reference");
1925       newmeWPullXvsAlphaZmPanel1->SetName("New Release");
1926       meWPullXvsAlphaZmPanel1->Draw("e");
1927       newmeWPullXvsAlphaZmPanel1->Draw("esameS"); 
1928       myPV->PVCompute(meWPullXvsAlphaZmPanel1, newmeWPullXvsAlphaZmPanel1, te, 0.2, 0.2);
1929       h_pv->SetBinContent(++bin, myPV->getPV());
1930       gPad->Update();      
1931       TPaveStats *s54 = (TPaveStats*)meWPullXvsAlphaZmPanel1->GetListOfFunctions()->FindObject("stats");
1932       if (s54) {
1933     s54->SetX1NDC (0.55); //new x start position
1934     s54->SetX2NDC (0.75); //new x end position
1935       }
1936       can_WPullXvsAlpha->cd(3);
1937       //gPad->SetLogy();
1938       SetUpProfileHistograms(meWPullXvsAlphaZmPanel2, newmeWPullXvsAlphaZmPanel2, "panel2, z<0, |alpha| (deg)", "< | pull x | >", lwpull, hwpull );
1939       Float_t refMax = 0.5+1.2*meWPullXvsAlphaZmPanel2->GetMaximum();
1940       Float_t newMax = 0.5+1.2*newmeWPullXvsAlphaZmPanel2->GetMaximum();
1941       if refMax > newMax
1942       {
1943           meWPullXvsAlphaZmPanel2->SetMaximum(refMax);
1944       }
1945       else
1946       {
1947           meWPullXvsAlphaZmPanel2->SetMaximum(newMax);
1948       }      
1949       meWPullXvsAlphaZmPanel2->SetName("Reference");
1950       newmeWPullXvsAlphaZmPanel2->SetName("New Release");
1951       meWPullXvsAlphaZmPanel2->Draw("e");
1952       newmeWPullXvsAlphaZmPanel2->Draw("esameS"); 
1953       myPV->PVCompute(meWPullXvsAlphaZmPanel2, newmeWPullXvsAlphaZmPanel2, te, 0.2, 0.2);
1954       h_pv->SetBinContent(++bin, myPV->getPV());
1955       gPad->Update();      
1956       TPaveStats *s55 = (TPaveStats*)meWPullXvsAlphaZmPanel2->GetListOfFunctions()->FindObject("stats");
1957       if (s55) {
1958     s55->SetX1NDC (0.55); //new x start position
1959     s55->SetX2NDC (0.75); //new x end position
1960       }
1961       can_WPullXvsAlpha->cd(4);
1962       //gPad->SetLogy();
1963       SetUpProfileHistograms(meWPullXvsAlphaBarrelFP, newmeWPullXvsAlphaBarrelFP, "flipped ladders, barrel, |alpha| (deg)", "< | pull x | >", lwpull, hwpull);
1964       Float_t refMax = 0.5+1.2*meWPullXvsAlphaBarrelFP->GetMaximum();
1965       Float_t newMax = 0.5+1.2*newmeWPullXvsAlphaBarrelFP->GetMaximum();
1966       if refMax > newMax
1967       {
1968           meWPullXvsAlphaBarrelFP->SetMaximum(refMax);
1969       }
1970       else
1971       {
1972           meWPullXvsAlphaBarrelFP->SetMaximum(newMax);
1973       }      
1974       meWPullXvsAlphaBarrelFP->SetName("Reference");
1975       newmeWPullXvsAlphaBarrelFP->SetName("New Release");
1976       meWPullXvsAlphaBarrelFP->Draw("e");
1977       newmeWPullXvsAlphaBarrelFP->Draw("eSameS"); 
1978       myPV->PVCompute(meWPullXvsAlphaBarrelFP, newmeWPullXvsAlphaBarrelFP, te, 0.2, 0.2);
1979       h_pv->SetBinContent(++bin, myPV->getPV());
1980       gPad->Update();      
1981       TPaveStats *s56 = (TPaveStats*)meWPullXvsAlphaBarrelFP->GetListOfFunctions()->FindObject("stats");
1982       if (s56) {
1983     s56->SetX1NDC (0.55); //new x start position
1984     s56->SetX2NDC (0.75); //new x end position
1985       }
1986       can_WPullXvsAlpha->cd(5);
1987       //gPad->SetLogy();
1988       SetUpProfileHistograms(meWPullXvsAlphaZpPanel1, newmeWPullXvsAlphaZpPanel1, "panel1, z>0, |alpha| (deg)", "< | pull x | >", lwpull, hwpull );
1989       Float_t refMax = 0.5+1.2*meWPullXvsAlphaZpPanel1->GetMaximum();
1990       Float_t newMax = 0.5+1.2*newmeWPullXvsAlphaZpPanel1->GetMaximum();
1991       if refMax > newMax
1992       {
1993           meWPullXvsAlphaZpPanel1->SetMaximum(refMax);
1994       }
1995       else
1996       {
1997           meWPullXvsAlphaZpPanel1->SetMaximum(newMax);
1998       }      
1999       meWPullXvsAlphaZpPanel1->SetName("Reference");
2000       newmeWPullXvsAlphaZpPanel1->SetName("New Release");
2001       meWPullXvsAlphaZpPanel1->Draw("e");
2002       newmeWPullXvsAlphaZpPanel1->Draw("esameS"); 
2003       myPV->PVCompute(meWPullXvsAlphaZpPanel1, newmeWPullXvsAlphaZpPanel1, te, 0.2, 0.2);
2004       h_pv->SetBinContent(++bin, myPV->getPV());
2005       gPad->Update();      
2006       TPaveStats *s57 = (TPaveStats*)meWPullXvsAlphaZpPanel1->GetListOfFunctions()->FindObject("stats");
2007       if (s57) {
2008     s57->SetX1NDC (0.55); //new x start position
2009     s57->SetX2NDC (0.75); //new x end position
2010       }
2011       can_WPullXvsAlpha->cd(6);
2012       //gPad->SetLogy();
2013       SetUpProfileHistograms(meWPullXvsAlphaZpPanel2, newmeWPullXvsAlphaZpPanel2, "panel2, z>0, |alpha| (deg)", "< | pull x | >", lwpull, hwpull );
2014       Float_t refMax = 0.5+1.2*meWPullXvsAlphaZpPanel2->GetMaximum();
2015       Float_t newMax = 0.5+1.2*newmeWPullXvsAlphaZpPanel2->GetMaximum();
2016       if refMax > newMax
2017       {
2018           meWPullXvsAlphaZpPanel2->SetMaximum(refMax);
2019       }
2020       else
2021       {
2022           meWPullXvsAlphaZpPanel2->SetMaximum(newMax);
2023       }      
2024       meWPullXvsAlphaZpPanel2->SetName("Reference");
2025       newmeWPullXvsAlphaZpPanel2->SetName("New Release");
2026       meWPullXvsAlphaZpPanel2->Draw("e");
2027       newmeWPullXvsAlphaZpPanel2->Draw("esameS"); 
2028       myPV->PVCompute(meWPullXvsAlphaZpPanel2, newmeWPullXvsAlphaZpPanel2, te, 0.2, 0.2);
2029       h_pv->SetBinContent(++bin, myPV->getPV());
2030       gPad->Update();      
2031       TPaveStats *s58 = (TPaveStats*)meWPullXvsAlphaZpPanel2->GetListOfFunctions()->FindObject("stats");
2032       if (s58) {
2033     s58->SetX1NDC (0.55); //new x start position
2034     s58->SetX2NDC (0.75); //new x end position
2035       }
2036       can_WPullXvsAlpha->SaveAs("meWPullXvsAlpha_compare.eps");
2037       can_WPullXvsAlpha->SaveAs("meWPullXvsAlpha_compare.gif");
2038     }
2039   
2040  //if (   0   ) 
2041  if (1) 
2042  {
2043     TCanvas* can_PullXvsPhi = new TCanvas("can_PullXvsPhi", "can_PullXvsPhi", 1200, 800);
2044     can_PullXvsPhi->Divide(3,2);
2045     
2046     TProfile* mePullXvsPhiBarrel;
2047     TProfile* mePullXvsPhiZmPanel1;
2048     TProfile* mePullXvsPhiZmPanel2;
2049     TProfile* mePullXvsPhiZpPanel1;
2050     TProfile* mePullXvsPhiZpPanel2;
2051     
2052     TProfile* newmePullXvsPhiBarrel;
2053     TProfile* newmePullXvsPhiZmPanel1;
2054     TProfile* newmePullXvsPhiZmPanel2;
2055     TProfile* newmePullXvsPhiZpPanel1;
2056     TProfile* newmePullXvsPhiZpPanel2;
2057 
2058     rdir->GetObject("Histograms_all/mePullXvsPhiBarrel"  , mePullXvsPhiBarrel  );
2059     rdir->GetObject("Histograms_all/mePullXvsPhiZmPanel1", mePullXvsPhiZmPanel1);
2060     rdir->GetObject("Histograms_all/mePullXvsPhiZmPanel2", mePullXvsPhiZmPanel2);
2061     rdir->GetObject("Histograms_all/mePullXvsPhiZpPanel1", mePullXvsPhiZpPanel1);
2062     rdir->GetObject("Histograms_all/mePullXvsPhiZpPanel2", mePullXvsPhiZpPanel2);
2063 
2064     sdir->GetObject("Histograms_all/mePullXvsPhiBarrel"  , newmePullXvsPhiBarrel  ); 
2065     sdir->GetObject("Histograms_all/mePullXvsPhiZmPanel1", newmePullXvsPhiZmPanel1);
2066     sdir->GetObject("Histograms_all/mePullXvsPhiZmPanel2", newmePullXvsPhiZmPanel2);
2067     sdir->GetObject("Histograms_all/mePullXvsPhiZpPanel1", newmePullXvsPhiZpPanel1);
2068     sdir->GetObject("Histograms_all/mePullXvsPhiZpPanel2", newmePullXvsPhiZpPanel2);
2069   
2070     TLegend* leg13 = new TLegend(0.3, 0.2, 0.6, 0.4);
2071     can_PullXvsPhi->cd(1);
2072     //gPad->SetLogy();
2073     SetUpProfileHistograms(mePullXvsPhiBarrel, newmePullXvsPhiBarrel, "barrel, phi (deg)", "pull x", lpull, hpull, leg13 );
2074     Float_t refMax = 0.5+1.2*mePullXvsPhiBarrel->GetMaximum();
2075     Float_t newMax = 0.5+1.2*newmePullXvsPhiBarrel->GetMaximum();
2076     if refMax > newMax
2077     {
2078         mePullXvsPhiBarrel->SetMaximum(refMax);
2079     }
2080     else
2081     {
2082         mePullXvsPhiBarrel->SetMaximum(newMax);
2083     }      
2084     mePullXvsPhiBarrel->SetName("Reference");
2085     newmePullXvsPhiBarrel->SetName("New Release");
2086     mePullXvsPhiBarrel->Draw("e");
2087     newmePullXvsPhiBarrel->Draw("eSameS"); 
2088     myPV->PVCompute(mePullXvsPhiBarrel, newmePullXvsPhiBarrel, te, 0.3, 0.4);
2089     leg13->Draw();
2090     h_pv->SetBinContent(++bin, myPV->getPV());
2091     gPad->Update();      
2092     TPaveStats *s59 = (TPaveStats*)mePullXvsPhiBarrel->GetListOfFunctions()->FindObject("stats");
2093     if (s59) {
2094       s59->SetX1NDC (0.55); //new x start position
2095       s59->SetX2NDC (0.75); //new x end position
2096     }
2097     can_PullXvsPhi->cd(2);
2098     //gPad->SetLogy();
2099     SetUpProfileHistograms(mePullXvsPhiZmPanel1, newmePullXvsPhiZmPanel1, "panel1, z<0, phi (deg)", "pull x", lpull, hpull );
2100     Float_t refMax = 0.5+1.2*mePullXvsPhiZmPanel1->GetMaximum();
2101     Float_t newMax = 0.5+1.2*newmePullXvsPhiZmPanel1->GetMaximum();
2102     if refMax > newMax
2103     {
2104         mePullXvsPhiZmPanel1->SetMaximum(refMax);
2105     }
2106     else
2107     {
2108         mePullXvsPhiZmPanel1->SetMaximum(newMax);
2109     }      
2110     mePullXvsPhiZmPanel1->SetName("Reference");
2111     newmePullXvsPhiZmPanel1->SetName("New Release");
2112     mePullXvsPhiZmPanel1->Draw("e");
2113     newmePullXvsPhiZmPanel1->Draw("esameS"); 
2114     myPV->PVCompute(mePullXvsPhiZmPanel1, newmePullXvsPhiZmPanel1, te, 0.2, 0.2);
2115     h_pv->SetBinContent(++bin, myPV->getPV());
2116     gPad->Update();      
2117     TPaveStats *s60 = (TPaveStats*)mePullXvsPhiZmPanel1->GetListOfFunctions()->FindObject("stats");
2118     if (s60) {
2119       s60->SetX1NDC (0.55); //new x start position
2120       s60->SetX2NDC (0.75); //new x end position
2121     }
2122     can_PullXvsPhi->cd(3);
2123     //gPad->SetLogy();
2124     SetUpProfileHistograms(mePullXvsPhiZmPanel2, newmePullXvsPhiZmPanel2, "panel2, z<0, phi (deg)", "pull x", lpull, hpull );
2125     Float_t refMax = 0.5+1.2*mePullXvsPhiZmPanel2->GetMaximum();
2126     Float_t newMax = 0.5+1.2*newmePullXvsPhiZmPanel2->GetMaximum();
2127     if refMax > newMax
2128     {
2129         mePullXvsPhiZmPanel2->SetMaximum(refMax);
2130     }
2131     else
2132     {
2133         mePullXvsPhiZmPanel2->SetMaximum(newMax);
2134     }      
2135     mePullXvsPhiZmPanel2->SetName("Reference");
2136     newmePullXvsPhiZmPanel2->SetName("New Release");
2137     mePullXvsPhiZmPanel2->Draw("e");
2138     newmePullXvsPhiZmPanel2->Draw("esameS"); 
2139     myPV->PVCompute(mePullXvsPhiZmPanel2, newmePullXvsPhiZmPanel2, te, 0.2, 0.2 );
2140     h_pv->SetBinContent(++bin, myPV->getPV());
2141     gPad->Update();      
2142     TPaveStats *s61 = (TPaveStats*)mePullXvsPhiZmPanel2->GetListOfFunctions()->FindObject("stats");
2143     if (s61) {
2144       s61->SetX1NDC (0.55); //new x start position
2145       s61->SetX2NDC (0.75); //new x end position
2146     }
2147     can_PullXvsPhi->cd(5);
2148     //gPad->SetLogy();
2149     SetUpProfileHistograms(mePullXvsPhiZpPanel1, newmePullXvsPhiZpPanel1, "panel1, z>0, phi (deg)", "pull x", lpull, hpull );
2150     Float_t refMax = 0.5+1.2*mePullXvsPhiZpPanel1->GetMaximum();
2151     Float_t newMax = 0.5+1.2*newmePullXvsPhiZpPanel1->GetMaximum();
2152     if refMax > newMax
2153     {
2154         mePullXvsPhiZpPanel1->SetMaximum(refMax);
2155     }
2156     else
2157     {
2158         mePullXvsPhiZpPanel1->SetMaximum(newMax);
2159     }      
2160     mePullXvsPhiZpPanel1->SetName("Reference");
2161     newmePullXvsPhiZpPanel1->SetName("New Release");
2162     mePullXvsPhiZpPanel1->Draw("e");
2163     newmePullXvsPhiZpPanel1->Draw("esameS"); 
2164     myPV->PVCompute(mePullXvsPhiZpPanel1, newmePullXvsPhiZpPanel1, te, 0.2, 0.2 );
2165     h_pv->SetBinContent(++bin, myPV->getPV());
2166     gPad->Update();      
2167     TPaveStats *s62 = (TPaveStats*)mePullXvsPhiZpPanel1->GetListOfFunctions()->FindObject("stats");
2168     if (s62) {
2169       s62->SetX1NDC (0.55); //new x start position
2170       s62->SetX2NDC (0.75); //new x end position
2171     }
2172     can_PullXvsPhi->cd(6);
2173     //gPad->SetLogy();
2174     SetUpProfileHistograms(mePullXvsPhiZpPanel2, newmePullXvsPhiZpPanel2, "panel2, z>0, phi (deg)", "pull x" , lpull, hpull);
2175     Float_t refMax = 0.5+1.2*mePullXvsPhiZpPanel2->GetMaximum();
2176     Float_t newMax = 0.5+1.2*newmePullXvsPhiZpPanel2->GetMaximum();
2177     if refMax > newMax
2178     {
2179         mePullXvsPhiZpPanel2->SetMaximum(refMax);
2180     }
2181     else
2182     {
2183         mePullXvsPhiZpPanel2->SetMaximum(newMax);
2184     }      
2185     mePullXvsPhiZpPanel2->SetName("Reference");
2186     newmePullXvsPhiZpPanel2->SetName("New Release");
2187     mePullXvsPhiZpPanel2->Draw("e");
2188     newmePullXvsPhiZpPanel2->Draw("esameS"); 
2189     myPV->PVCompute(mePullXvsPhiZpPanel2, newmePullXvsPhiZpPanel2, te, 0.2, 0.2 );
2190     h_pv->SetBinContent(++bin, myPV->getPV());
2191     gPad->Update();      
2192     TPaveStats *s63 = (TPaveStats*)mePullXvsPhiZpPanel2->GetListOfFunctions()->FindObject("stats");
2193     if (s63) {
2194       s63->SetX1NDC (0.55); //new x start position
2195       s63->SetX2NDC (0.75); //new x end position
2196     }
2197     can_PullXvsPhi->SaveAs("mePullXvsPhi_compare.eps");
2198     can_PullXvsPhi->SaveAs("mePullXvsPhi_compare.gif");
2199   }
2200 
2201  //if (   0   ) 
2202  if (1) 
2203  {
2204     TCanvas* can_PullYvsAlpha = new TCanvas("can_PullYvsAlpha", "can_PullYvsAlpha", 1200, 800);
2205     can_PullYvsAlpha->Divide(3,2);
2206     
2207     TProfile* mePullYvsAlphaBarrel;
2208     TProfile* mePullYvsAlphaZmPanel1;
2209     TProfile* mePullYvsAlphaZmPanel2;
2210     TProfile* mePullYvsAlphaZpPanel1;
2211     TProfile* mePullYvsAlphaZpPanel2;
2212     
2213     TProfile* newmePullYvsAlphaBarrel;
2214     TProfile* newmePullYvsAlphaZmPanel1;
2215     TProfile* newmePullYvsAlphaZmPanel2;
2216     TProfile* newmePullYvsAlphaZpPanel1;
2217     TProfile* newmePullYvsAlphaZpPanel2;
2218 
2219     rdir->GetObject("Histograms_all/mePullYvsAlphaBarrel"  , mePullYvsAlphaBarrel  );
2220     rdir->GetObject("Histograms_all/mePullYvsAlphaZmPanel1", mePullYvsAlphaZmPanel1);
2221     rdir->GetObject("Histograms_all/mePullYvsAlphaZmPanel2", mePullYvsAlphaZmPanel2);
2222     rdir->GetObject("Histograms_all/mePullYvsAlphaZpPanel1", mePullYvsAlphaZpPanel1);
2223     rdir->GetObject("Histograms_all/mePullYvsAlphaZpPanel2", mePullYvsAlphaZpPanel2);
2224 
2225     sdir->GetObject("Histograms_all/mePullYvsAlphaBarrel"  , newmePullYvsAlphaBarrel  ); 
2226     sdir->GetObject("Histograms_all/mePullYvsAlphaZmPanel1", newmePullYvsAlphaZmPanel1);
2227     sdir->GetObject("Histograms_all/mePullYvsAlphaZmPanel2", newmePullYvsAlphaZmPanel2);
2228     sdir->GetObject("Histograms_all/mePullYvsAlphaZpPanel1", newmePullYvsAlphaZpPanel1);
2229     sdir->GetObject("Histograms_all/mePullYvsAlphaZpPanel2", newmePullYvsAlphaZpPanel2);
2230   
2231     TLegend* leg14 = new TLegend(0.3, 0.2, 0.6, 0.4);
2232     can_PullYvsAlpha->cd(1);
2233     //gPad->SetLogy();
2234     SetUpProfileHistograms(mePullYvsAlphaBarrel, newmePullYvsAlphaBarrel, "barrel, |alpha| (deg)", "pull y", lpull, hpull, leg14 );
2235     Float_t refMax = 1.4*(0.5+mePullYvsAlphaBarrel->GetMaximum());
2236     Float_t newMax = 1.4*(0.5+newmePullYvsAlphaBarrel->GetMaximum());
2237     if refMax > newMax
2238     {
2239         mePullYvsAlphaBarrel->SetMaximum(refMax);
2240     }
2241     else
2242     {
2243         mePullYvsAlphaBarrel->SetMaximum(newMax);
2244     }      
2245     mePullYvsAlphaBarrel->SetName("Reference");
2246     newmePullYvsAlphaBarrel->SetName("New Release");
2247     mePullYvsAlphaBarrel->Draw("e");
2248     newmePullYvsAlphaBarrel->Draw("eSameS"); 
2249     myPV->PVCompute(mePullYvsAlphaBarrel, newmePullYvsAlphaBarrel, te, 0.3, 0.4 );
2250     leg14->Draw();
2251     h_pv->SetBinContent(++bin, myPV->getPV());
2252     gPad->Update();      
2253     TPaveStats *s64 = (TPaveStats*)mePullYvsAlphaBarrel->GetListOfFunctions()->FindObject("stats");
2254     if (s64) {
2255       s64->SetX1NDC (0.55); //new x start position
2256       s64->SetX2NDC (0.75); //new x end position
2257     }
2258     can_PullYvsAlpha->cd(2);
2259     //gPad->SetLogy();
2260     SetUpProfileHistograms(mePullYvsAlphaZmPanel1, newmePullYvsAlphaZmPanel1, "panel1, z<0, |alpha| (deg)", "pull y", lpull, hpull );
2261     Float_t refMax = 1.4*(0.5+mePullYvsAlphaZmPanel1->GetMaximum());
2262     Float_t newMax = 1.4*(0.5+newmePullYvsAlphaZmPanel1->GetMaximum());
2263     if refMax > newMax
2264     {
2265         mePullYvsAlphaZmPanel1->SetMaximum(refMax);
2266     }
2267     else
2268     {
2269         mePullYvsAlphaZmPanel1->SetMaximum(newMax);
2270     }      
2271     mePullYvsAlphaZmPanel1->SetName("Reference");
2272     newmePullYvsAlphaZmPanel1->SetName("New Release");
2273     mePullYvsAlphaZmPanel1->Draw("e");
2274     newmePullYvsAlphaZmPanel1->Draw("esameS"); 
2275     myPV->PVCompute(mePullYvsAlphaZmPanel1, newmePullYvsAlphaZmPanel1, te, 0.2, 0.2);
2276     h_pv->SetBinContent(++bin, myPV->getPV());
2277     gPad->Update();      
2278     TPaveStats *s138 = (TPaveStats*)mePullYvsAlphaZmPanel1->GetListOfFunctions()->FindObject("stats");
2279     if (s138) {
2280         s138->SetX1NDC (0.55); //new x start position
2281         s138->SetX2NDC (0.75); //new x end position
2282     }
2283     can_PullYvsAlpha->cd(3);
2284     //gPad->SetLogy();
2285     SetUpProfileHistograms(mePullYvsAlphaZmPanel2, newmePullYvsAlphaZmPanel2, "panel2, z<0, |alpha| (deg)", "pull y", lpull, hpull );
2286     Float_t refMax = 1.4*(0.5+mePullYvsAlphaZmPanel2->GetMaximum());
2287     Float_t newMax = 1.4*(0.5+newmePullYvsAlphaZmPanel2->GetMaximum());
2288     if refMax > newMax
2289     {
2290         mePullYvsAlphaZmPanel2->SetMaximum(refMax);
2291     }
2292     else
2293     {
2294         mePullYvsAlphaZmPanel2->SetMaximum(newMax);
2295     }      
2296     mePullYvsAlphaZmPanel2->SetName("Reference");
2297     newmePullYvsAlphaZmPanel2->SetName("New Release");
2298     mePullYvsAlphaZmPanel2->Draw("e");
2299     newmePullYvsAlphaZmPanel2->Draw("esameS"); 
2300     myPV->PVCompute(mePullYvsAlphaZmPanel2, newmePullYvsAlphaZmPanel2, te, 0.2, 0.2 );
2301     h_pv->SetBinContent(++bin, myPV->getPV());
2302     gPad->Update();      
2303     TPaveStats *s65 = (TPaveStats*)mePullYvsAlphaZmPanel2->GetListOfFunctions()->FindObject("stats");
2304     if (s65) {
2305       s65->SetX1NDC (0.55); //new x start position
2306       s65->SetX2NDC (0.75); //new x end position
2307     }
2308     can_PullYvsAlpha->cd(5);
2309     //gPad->SetLogy();
2310     SetUpProfileHistograms(mePullYvsAlphaZpPanel1, newmePullYvsAlphaZpPanel1, "panel1, z>0, |alpha| (deg)", "pull y", lpull, hpull );
2311     Float_t refMax = 1.4*(0.5+mePullYvsAlphaZpPanel1->GetMaximum());
2312     Float_t newMax = 1.4*(0.5+newmePullYvsAlphaZpPanel1->GetMaximum());
2313     if refMax > newMax
2314     {
2315         mePullYvsAlphaZpPanel1->SetMaximum(refMax);
2316     }
2317     else
2318     {
2319         mePullYvsAlphaZpPanel1->SetMaximum(newMax);
2320     }      
2321     mePullYvsAlphaZpPanel1->SetName("Reference");
2322     newmePullYvsAlphaZpPanel1->SetName("New Release");
2323     mePullYvsAlphaZpPanel1->Draw("e");
2324     newmePullYvsAlphaZpPanel1->Draw("esameS"); 
2325     myPV->PVCompute(mePullYvsAlphaZpPanel1, newmePullYvsAlphaZpPanel1, te, 0.2, 0.2 );
2326     h_pv->SetBinContent(++bin, myPV->getPV());
2327     gPad->Update();      
2328     TPaveStats *s66 = (TPaveStats*)mePullYvsAlphaZpPanel1->GetListOfFunctions()->FindObject("stats");
2329     if (s66) {
2330       s66->SetX1NDC (0.55); //new x start position
2331       s66->SetX2NDC (0.75); //new x end position
2332     }
2333     can_PullYvsAlpha->cd(6);
2334     //gPad->SetLogy();
2335     SetUpProfileHistograms(mePullYvsAlphaZpPanel2, newmePullYvsAlphaZpPanel2, "panel2, z>0, |alpha| (deg)", "pull y" , lpull, hpull);
2336     Float_t refMax = 1.4*(0.5+mePullYvsAlphaZpPanel2->GetMaximum());
2337     Float_t newMax = 1.4*(0.5+newmePullYvsAlphaZpPanel2->GetMaximum());
2338     if refMax > newMax
2339     {
2340         mePullYvsAlphaZpPanel2->SetMaximum(refMax);
2341     }
2342     else
2343     {
2344         mePullYvsAlphaZpPanel2->SetMaximum(newMax);
2345     }      
2346     mePullYvsAlphaZpPanel2->SetName("Reference");
2347     newmePullYvsAlphaZpPanel2->SetName("New Release");
2348     mePullYvsAlphaZpPanel2->Draw("e");
2349     newmePullYvsAlphaZpPanel2->Draw("esameS"); 
2350     myPV->PVCompute(mePullYvsAlphaZpPanel2, newmePullYvsAlphaZpPanel2, te, 0.2, 0.2 );
2351     h_pv->SetBinContent(++bin, myPV->getPV());
2352     gPad->Update();      
2353     TPaveStats *s67 = (TPaveStats*)mePullYvsAlphaZpPanel2->GetListOfFunctions()->FindObject("stats");
2354     if (s67) {
2355       s67->SetX1NDC (0.55); //new x start position
2356       s67->SetX2NDC (0.75); //new x end position
2357     }
2358     can_PullYvsAlpha->SaveAs("mePullYvsAlpha_compare.eps");
2359     can_PullYvsAlpha->SaveAs("mePullYvsAlpha_compare.gif");
2360   }
2361 
2362 //if (   0   ) 
2363  if (   1   ) 
2364    {
2365     TCanvas* can_PullYvsBeta = new TCanvas("can_PullYvsBeta", "can_PullYvsBeta", 1200, 800);
2366     can_PullYvsBeta->Divide(3,2);
2367     
2368     TProfile* mePullYvsBetaBarrel;
2369     TProfile* mePullYvsBetaZmPanel1;
2370     TProfile* mePullYvsBetaZmPanel2;
2371     TProfile* mePullYvsBetaZpPanel1;
2372     TProfile* mePullYvsBetaZpPanel2;
2373     
2374     TProfile* newmePullYvsBetaBarrel;
2375     TProfile* newmePullYvsBetaZmPanel1;
2376     TProfile* newmePullYvsBetaZmPanel2;
2377     TProfile* newmePullYvsBetaZpPanel1;
2378     TProfile* newmePullYvsBetaZpPanel2;
2379 
2380     rdir->GetObject("Histograms_all/mePullYvsBetaBarrel"  , mePullYvsBetaBarrel  );
2381     rdir->GetObject("Histograms_all/mePullYvsBetaZmPanel1", mePullYvsBetaZmPanel1);
2382     rdir->GetObject("Histograms_all/mePullYvsBetaZmPanel2", mePullYvsBetaZmPanel2);
2383     rdir->GetObject("Histograms_all/mePullYvsBetaZpPanel1", mePullYvsBetaZpPanel1);
2384     rdir->GetObject("Histograms_all/mePullYvsBetaZpPanel2", mePullYvsBetaZpPanel2);
2385 
2386     sdir->GetObject("Histograms_all/mePullYvsBetaBarrel"  , newmePullYvsBetaBarrel  ); 
2387     sdir->GetObject("Histograms_all/mePullYvsBetaZmPanel1", newmePullYvsBetaZmPanel1);
2388     sdir->GetObject("Histograms_all/mePullYvsBetaZmPanel2", newmePullYvsBetaZmPanel2);
2389     sdir->GetObject("Histograms_all/mePullYvsBetaZpPanel1", newmePullYvsBetaZpPanel1);
2390     sdir->GetObject("Histograms_all/mePullYvsBetaZpPanel2", newmePullYvsBetaZpPanel2);
2391   
2392     TLegend* leg15 = new TLegend(0.3, 0.2, 0.6, 0.4);
2393     can_PullYvsBeta->cd(1);
2394     //gPad->SetLogy();
2395     SetUpProfileHistograms(mePullYvsBetaBarrel, newmePullYvsBetaBarrel, "barrel, |beta| (deg)", "pull y", lpull, hpull, leg15 );
2396     Float_t refMax = 0.5+1.2*mePullYvsBetaBarrel->GetMaximum();
2397     Float_t newMax = 0.5+1.2*newmePullYvsBetaBarrel->GetMaximum();
2398     if refMax > newMax
2399     {
2400         mePullYvsBetaBarrel->SetMaximum(refMax);
2401     }
2402     else
2403     {
2404         mePullYvsBetaBarrel->SetMaximum(newMax);
2405     }      
2406     mePullYvsBetaBarrel->SetName("Reference");
2407     newmePullYvsBetaBarrel->SetName("New Release");
2408     mePullYvsBetaBarrel->Draw("e");
2409     newmePullYvsBetaBarrel->Draw("esameS"); 
2410     myPV->PVCompute(mePullYvsBetaBarrel, newmePullYvsBetaBarrel, te, 0.3, 0.4);
2411     leg15->Draw();
2412     h_pv->SetBinContent(++bin, myPV->getPV());
2413     gPad->Update();      
2414     TPaveStats *s68 = (TPaveStats*)mePullYvsBetaBarrel->GetListOfFunctions()->FindObject("stats");
2415     if (s68) {
2416       s68->SetX1NDC (0.55); //new x start position
2417       s68->SetX2NDC (0.75); //new x end position
2418     }
2419     can_PullYvsBeta->cd(2);
2420     //gPad->SetLogy();
2421     SetUpProfileHistograms(mePullYvsBetaZmPanel1, newmePullYvsBetaZmPanel1, "panel1, z<0, |beta| (deg)", "pull y", lpull, hpull );
2422     Float_t refMax = 0.5+1.2*mePullYvsBetaZmPanel1->GetMaximum();
2423     Float_t newMax = 0.5+1.2*newmePullYvsBetaZmPanel1->GetMaximum();
2424     if refMax > newMax
2425     {
2426         mePullYvsBetaZmPanel1->SetMaximum(refMax);
2427     }
2428     else
2429     {
2430         mePullYvsBetaZmPanel1->SetMaximum(newMax);
2431     }      
2432     mePullYvsBetaZmPanel1->SetName("Reference");
2433     newmePullYvsBetaZmPanel1->SetName("New Release");
2434     mePullYvsBetaZmPanel1->Draw("e");
2435     newmePullYvsBetaZmPanel1->Draw("esameS"); 
2436     myPV->PVCompute(mePullYvsBetaZmPanel1, newmePullYvsBetaZmPanel1, te, 0.2, 0.2 );
2437     h_pv->SetBinContent(++bin, myPV->getPV());
2438     gPad->Update();      
2439     TPaveStats *s69 = (TPaveStats*)mePullYvsBetaZmPanel1->GetListOfFunctions()->FindObject("stats");
2440     if (s69) {
2441       s69->SetX1NDC (0.55); //new x start position
2442       s69->SetX2NDC (0.75); //new x end position
2443     }
2444     can_PullYvsBeta->cd(3);
2445     //gPad->SetLogy();
2446     SetUpProfileHistograms(mePullYvsBetaZmPanel2, newmePullYvsBetaZmPanel2, "panel2, z<0, |beta| (deg)", "pull y", lpull, hpull );
2447     Float_t refMax = 0.5+1.2*mePullYvsBetaZmPanel2->GetMaximum();
2448     Float_t newMax = 0.5+1.2*newmePullYvsBetaZmPanel2->GetMaximum();
2449     if refMax > newMax
2450     {
2451         mePullYvsBetaZmPanel2->SetMaximum(refMax);
2452     }
2453     else
2454     {
2455         mePullYvsBetaZmPanel2->SetMaximum(newMax);
2456     }      
2457     mePullYvsBetaZmPanel2->SetName("Reference");
2458     newmePullYvsBetaZmPanel2->SetName("New Release");
2459     mePullYvsBetaZmPanel2->Draw("e");
2460     newmePullYvsBetaZmPanel2->Draw("esameS"); 
2461     myPV->PVCompute(mePullYvsBetaZmPanel2, newmePullYvsBetaZmPanel2, te, 0.2, 0.2 );
2462     h_pv->SetBinContent(++bin, myPV->getPV());
2463     gPad->Update();      
2464     TPaveStats *s70 = (TPaveStats*)mePullYvsBetaZmPanel2->GetListOfFunctions()->FindObject("stats");
2465     if (s70) {
2466       s70->SetX1NDC (0.55); //new x start position
2467       s70->SetX2NDC (0.75); //new x end position
2468     }
2469     can_PullYvsBeta->cd(5);
2470     //gPad->SetLogy();
2471     SetUpProfileHistograms(mePullYvsBetaZpPanel1, newmePullYvsBetaZpPanel1, "panel1, z>0, |beta| (deg)", "pull y", lpull, hpull );
2472     Float_t refMax = 0.5+1.2*mePullYvsBetaZpPanel1->GetMaximum();
2473     Float_t newMax = 0.5+1.2*newmePullYvsBetaZpPanel1->GetMaximum();
2474     if refMax > newMax
2475     {
2476         mePullYvsBetaZpPanel1->SetMaximum(refMax);
2477     }
2478     else
2479     {
2480         mePullYvsBetaZpPanel1->SetMaximum(newMax);
2481     }      
2482     mePullYvsBetaZpPanel1->SetName("Reference");
2483     newmePullYvsBetaZpPanel1->SetName("New Release");
2484     mePullYvsBetaZpPanel1->Draw("e");
2485     newmePullYvsBetaZpPanel1->Draw("esameS"); 
2486     myPV->PVCompute(mePullYvsBetaZpPanel1, newmePullYvsBetaZpPanel1, te, 0.2, 0.2 );
2487     h_pv->SetBinContent(++bin, myPV->getPV());
2488     gPad->Update();      
2489     TPaveStats *s71 = (TPaveStats*)mePullYvsBetaZpPanel1->GetListOfFunctions()->FindObject("stats");
2490     if (s71) {
2491       s71->SetX1NDC (0.55); //new x start position
2492       s71->SetX2NDC (0.75); //new x end position
2493     }
2494     can_PullYvsBeta->cd(6);
2495     //gPad->SetLogy();
2496     SetUpProfileHistograms(mePullYvsBetaZpPanel2, newmePullYvsBetaZpPanel2, "panel2, z>0, |beta| (deg)", "pull y", lpull, hpull );
2497     Float_t refMax = 0.5+1.2*mePullYvsBetaZpPanel2->GetMaximum();
2498     Float_t newMax = 0.5+1.2*newmePullYvsBetaZpPanel2->GetMaximum();
2499     if refMax > newMax
2500     {
2501         mePullYvsBetaZpPanel2->SetMaximum(refMax);
2502     }
2503     else
2504     {
2505         mePullYvsBetaZpPanel2->SetMaximum(newMax);
2506     }      
2507     mePullYvsBetaZpPanel2->SetName("Reference");
2508     newmePullYvsBetaZpPanel2->SetName("New Release");
2509     mePullYvsBetaZpPanel2->Draw("e");
2510     newmePullYvsBetaZpPanel2->Draw("esameS"); 
2511     myPV->PVCompute(mePullYvsBetaZpPanel2, newmePullYvsBetaZpPanel2, te, 0.2, 0.2 );
2512     h_pv->SetBinContent(++bin, myPV->getPV());
2513     gPad->Update();      
2514     TPaveStats *s72 = (TPaveStats*)mePullYvsBetaZpPanel2->GetListOfFunctions()->FindObject("stats");
2515     if (s72) {
2516       s72->SetX1NDC (0.55); //new x start position
2517       s72->SetX2NDC (0.75); //new x end position
2518     }
2519     can_PullYvsBeta->SaveAs("mePullYvsBeta_compare.eps");
2520     can_PullYvsBeta->SaveAs("mePullYvsBeta_compare.gif");
2521   }
2522 
2523 
2524 if (   1   ) 
2525   {
2526     TCanvas* can_WPullYvsBeta = new TCanvas("can_WPullYvsBeta", "can_WPullYvsBeta", 1200, 800);
2527     can_WPullYvsBeta->Divide(3,2);
2528     
2529     TProfile* meWPullYvsBetaBarrelNFP;
2530     TProfile* meWPullYvsBetaBarrelFP;
2531     TProfile* meWPullYvsBetaZmPanel1;
2532     TProfile* meWPullYvsBetaZmPanel2;
2533     TProfile* meWPullYvsBetaZpPanel1;
2534     TProfile* meWPullYvsBetaZpPanel2;
2535     
2536     TProfile* newmeWPullYvsBetaBarrelNFP;
2537     TProfile* newmeWPullYvsBetaBarrelFP;
2538     TProfile* newmeWPullYvsBetaBarrel;
2539     TProfile* newmeWPullYvsBetaZmPanel1;
2540     TProfile* newmeWPullYvsBetaZmPanel2;
2541     TProfile* newmeWPullYvsBetaZpPanel1;
2542     TProfile* newmeWPullYvsBetaZpPanel2;
2543 
2544     rdir->GetObject("Histograms_all/meWPullYvsBetaBarrelNonFlippedLadders", meWPullYvsBetaBarrelNFP  );
2545     rdir->GetObject("Histograms_all/meWPullYvsBetaBarrelFlippedLadders"   , meWPullYvsBetaBarrelFP  );
2546     rdir->GetObject("Histograms_all/meWPullYvsBetaZmPanel1", meWPullYvsBetaZmPanel1);
2547     rdir->GetObject("Histograms_all/meWPullYvsBetaZmPanel2", meWPullYvsBetaZmPanel2);
2548     rdir->GetObject("Histograms_all/meWPullYvsBetaZpPanel1", meWPullYvsBetaZpPanel1);
2549     rdir->GetObject("Histograms_all/meWPullYvsBetaZpPanel2", meWPullYvsBetaZpPanel2);
2550 
2551     sdir->GetObject("Histograms_all/meWPullYvsBetaBarrelNonFlippedLadders", newmeWPullYvsBetaBarrelNFP  );
2552     sdir->GetObject("Histograms_all/meWPullYvsBetaBarrelFlippedLadders"   , newmeWPullYvsBetaBarrelFP  );
2553     sdir->GetObject("Histograms_all/meWPullYvsBetaZmPanel1", newmeWPullYvsBetaZmPanel1);
2554     sdir->GetObject("Histograms_all/meWPullYvsBetaZmPanel2", newmeWPullYvsBetaZmPanel2);
2555     sdir->GetObject("Histograms_all/meWPullYvsBetaZpPanel1", newmeWPullYvsBetaZpPanel1);
2556     sdir->GetObject("Histograms_all/meWPullYvsBetaZpPanel2", newmeWPullYvsBetaZpPanel2);
2557   
2558     TLegend* leg15 = new TLegend(0.3, 0.2, 0.6, 0.4);
2559     can_WPullYvsBeta->cd(1);
2560     //gPad->SetLogy();
2561     SetUpProfileHistograms(meWPullYvsBetaBarrelNFP, newmeWPullYvsBetaBarrelNFP, "non-flipped ladders, barrel, |beta| (deg)", "< | pull y | > ", lwpull, hwpull, leg15 );
2562     Float_t refMax = 0.5+1.2*meWPullYvsBetaBarrelNFP->GetMaximum();
2563     Float_t newMax = 0.5+1.2*newmeWPullYvsBetaBarrelNFP->GetMaximum();
2564     if refMax > newMax
2565     {
2566         meWPullYvsBetaBarrelNFP->SetMaximum(refMax);
2567     }
2568     else
2569     {
2570         meWPullYvsBetaBarrelNFP->SetMaximum(newMax);
2571     }      
2572     meWPullYvsBetaBarrelNFP->SetName("Reference");
2573     newmeWPullYvsBetaBarrelNFP->SetName("New Release");
2574     meWPullYvsBetaBarrelNFP->Draw("e");
2575     newmeWPullYvsBetaBarrelNFP->Draw("eSameS"); 
2576     myPV->PVCompute(meWPullYvsBetaBarrelNFP, newmeWPullYvsBetaBarrelNFP, te );
2577     leg15->Draw();
2578     h_pv->SetBinContent(++bin, myPV->getPV());
2579     gPad->Update();    
2580     TPaveStats *s73 = (TPaveStats*)meWPullYvsBetaBarrelNFP->GetListOfFunctions()->FindObject("stats");
2581     if (s73) {
2582       s73->SetX1NDC (0.55); //new x start position
2583       s73->SetX2NDC (0.75); //new x end position
2584     }
2585     can_WPullYvsBeta->cd(2);
2586     //gPad->SetLogy();
2587     SetUpProfileHistograms(meWPullYvsBetaZmPanel1, newmeWPullYvsBetaZmPanel1, "panel1, z<0, |beta| (deg)", "< | pull y | > ", lwpull, hwpull );
2588     Float_t refMax = 0.5+1.2*meWPullYvsBetaZmPanel1->GetMaximum();
2589     Float_t newMax = 0.5+1.2*newmeWPullYvsBetaZmPanel1->GetMaximum();
2590     if refMax > newMax
2591     {
2592         meWPullYvsBetaZmPanel1->SetMaximum(refMax);
2593     }
2594     else
2595     {
2596         meWPullYvsBetaZmPanel1->SetMaximum(newMax);
2597     }      
2598     meWPullYvsBetaZmPanel1->SetName("Reference");
2599     newmeWPullYvsBetaZmPanel1->SetName("New Release");
2600     meWPullYvsBetaZmPanel1->Draw("e");
2601     newmeWPullYvsBetaZmPanel1->Draw("esameS"); 
2602     myPV->PVCompute(meWPullYvsBetaZmPanel1, newmeWPullYvsBetaZmPanel1, te, 0.2, 0.2 );
2603     h_pv->SetBinContent(++bin, myPV->getPV());
2604     gPad->Update();    
2605     TPaveStats *s74 = (TPaveStats*)meWPullYvsBetaZmPanel1->GetListOfFunctions()->FindObject("stats");
2606     if (s74) {
2607       s74->SetX1NDC (0.55); //new x start position
2608       s74->SetX2NDC (0.75); //new x end position
2609     }
2610     can_WPullYvsBeta->cd(3);
2611     //gPad->SetLogy();
2612     SetUpProfileHistograms(meWPullYvsBetaZmPanel2, newmeWPullYvsBetaZmPanel2, "panel2, z<0, |beta| (deg)", "< | pull y | > ", lwpull, hwpull );
2613     Float_t refMax = 0.5+1.2*meWPullYvsBetaZmPanel2->GetMaximum();
2614     Float_t newMax = 0.5+1.2*newmeWPullYvsBetaZmPanel2->GetMaximum();
2615     if refMax > newMax
2616     {
2617         meWPullYvsBetaZmPanel2->SetMaximum(refMax);
2618     }
2619     else
2620     {
2621         meWPullYvsBetaZmPanel2->SetMaximum(newMax);
2622     }      
2623     meWPullYvsBetaZmPanel2->SetName("Reference");
2624     newmeWPullYvsBetaZmPanel2->SetName("New Release");
2625     meWPullYvsBetaZmPanel2->Draw("e");
2626     newmeWPullYvsBetaZmPanel2->Draw("esameS"); 
2627     myPV->PVCompute(meWPullYvsBetaZmPanel2, newmeWPullYvsBetaZmPanel2, te, 0.2, 0.2 );
2628     h_pv->SetBinContent(++bin, myPV->getPV());
2629     gPad->Update();    
2630     TPaveStats *s75 = (TPaveStats*)meWPullYvsBetaZmPanel2->GetListOfFunctions()->FindObject("stats");
2631     if (s75) {
2632       s75->SetX1NDC (0.55); //new x start position
2633       s75->SetX2NDC (0.75); //new x end position
2634     }
2635     can_WPullYvsBeta->cd(4);
2636     //gPad->SetLogy();
2637     SetUpProfileHistograms(meWPullYvsBetaBarrelFP, newmeWPullYvsBetaBarrelFP, "flipped ladders, barrel, |beta| (deg)", "< | pull y | > ", lwpull, hwpull);
2638     Float_t refMax = 0.5+1.2*meWPullYvsBetaBarrelFP->GetMaximum();
2639     Float_t newMax = 0.5+1.2*newmeWPullYvsBetaBarrelFP->GetMaximum();
2640     if refMax > newMax
2641     {
2642         meWPullYvsBetaBarrelFP->SetMaximum(refMax);
2643     }
2644     else
2645     {
2646         meWPullYvsBetaBarrelFP->SetMaximum(newMax);
2647     }      
2648     meWPullYvsBetaBarrelFP->SetName("Reference");
2649     newmeWPullYvsBetaBarrelFP->SetName("New Release");
2650     meWPullYvsBetaBarrelFP->Draw("e");
2651     newmeWPullYvsBetaBarrelFP->Draw("eSameS"); 
2652     myPV->PVCompute(meWPullYvsBetaBarrelFP, newmeWPullYvsBetaBarrelFP, te );
2653     h_pv->SetBinContent(++bin, myPV->getPV());
2654     gPad->Update();    
2655     TPaveStats *s76 = (TPaveStats*)meWPullYvsBetaBarrelFP->GetListOfFunctions()->FindObject("stats");
2656     if (s76) {
2657       s76->SetX1NDC (0.55); //new x start position
2658       s76->SetX2NDC (0.75); //new x end position
2659     }
2660     can_WPullYvsBeta->cd(5);
2661     //gPad->SetLogy();
2662     SetUpProfileHistograms(meWPullYvsBetaZpPanel1, newmeWPullYvsBetaZpPanel1, "panel1, z>0, |beta| (deg)", "< | pull y | > ", lwpull, hwpull );
2663     Float_t refMax = 0.5+1.2*meWPullYvsBetaZpPanel1->GetMaximum();
2664     Float_t newMax = 0.5+1.2*newmeWPullYvsBetaZpPanel1->GetMaximum();
2665     if refMax > newMax
2666     {
2667         meWPullYvsBetaZpPanel1->SetMaximum(refMax);
2668     }
2669     else
2670     {
2671         meWPullYvsBetaZpPanel1->SetMaximum(newMax);
2672     }      
2673     meWPullYvsBetaZpPanel1->SetName("Reference");
2674     newmeWPullYvsBetaZpPanel1->SetName("New Release");
2675     meWPullYvsBetaZpPanel1->Draw("e");
2676     newmeWPullYvsBetaZpPanel1->Draw("esameS"); 
2677     myPV->PVCompute(meWPullYvsBetaZpPanel1, newmeWPullYvsBetaZpPanel1, te, 0.2, 0.2 );
2678     h_pv->SetBinContent(++bin, myPV->getPV());
2679     gPad->Update();    
2680     TPaveStats *s77 = (TPaveStats*)meWPullYvsBetaZpPanel1->GetListOfFunctions()->FindObject("stats");
2681     if (s77) {
2682       s77->SetX1NDC (0.55); //new x start position
2683       s77->SetX2NDC (0.75); //new x end position
2684     }
2685     can_WPullYvsBeta->cd(6);
2686     //gPad->SetLogy();
2687     SetUpProfileHistograms(meWPullYvsBetaZpPanel2, newmeWPullYvsBetaZpPanel2, "panel2, z>0, |beta| (deg)", "< | pull y | > ", lwpull, hwpull );
2688     Float_t refMax = 0.5+1.2*meWPullYvsBetaZpPanel2->GetMaximum();
2689     Float_t newMax = 0.5+1.2*newmeWPullYvsBetaZpPanel2->GetMaximum();
2690     if refMax > newMax
2691     {
2692         meWPullYvsBetaZpPanel2->SetMaximum(refMax);
2693     }
2694     else
2695     {
2696         meWPullYvsBetaZpPanel2->SetMaximum(newMax);
2697     }      
2698     meWPullYvsBetaZpPanel2->SetName("Reference");
2699     newmeWPullYvsBetaZpPanel2->SetName("New Release");
2700     meWPullYvsBetaZpPanel2->Draw("e");
2701     newmeWPullYvsBetaZpPanel2->Draw("esameS"); 
2702     myPV->PVCompute(meWPullYvsBetaZpPanel2, newmeWPullYvsBetaZpPanel2, te, 0.2, 0.2 );
2703     h_pv->SetBinContent(++bin, myPV->getPV());
2704     gPad->Update();
2705     TPaveStats *s78 = (TPaveStats*)meWPullYvsBetaZpPanel2->GetListOfFunctions()->FindObject("stats");
2706     if (s78) {
2707       s78->SetX1NDC (0.55); //new x start position
2708       s78->SetX2NDC (0.75); //new x end position
2709     }
2710     can_WPullYvsBeta->SaveAs("meWPullYvsBeta_compare.eps");
2711     can_WPullYvsBeta->SaveAs("meWPullYvsBeta_compare.gif");
2712   }
2713 
2714 
2715 
2716 //if (   0   ) 
2717  if (1) 
2718    {
2719     TCanvas* can_PullYvsEta = new TCanvas("can_PullYvsEta", "can_PullYvsEta", 1200, 800);
2720     can_PullYvsEta->Divide(3,2);
2721     
2722     TProfile* mePullYvsEtaBarrel;
2723     TProfile* mePullYvsEtaZmPanel1;
2724     TProfile* mePullYvsEtaZmPanel2;
2725     TProfile* mePullYvsEtaZpPanel1;
2726     TProfile* mePullYvsEtaZpPanel2;
2727     
2728     TProfile* newmePullYvsEtaBarrel;
2729     TProfile* newmePullYvsEtaZmPanel1;
2730     TProfile* newmePullYvsEtaZmPanel2;
2731     TProfile* newmePullYvsEtaZpPanel1;
2732     TProfile* newmePullYvsEtaZpPanel2;
2733 
2734     rdir->GetObject("Histograms_all/mePullYvsEtaBarrel"  , mePullYvsEtaBarrel  );
2735     rdir->GetObject("Histograms_all/mePullYvsEtaZmPanel1", mePullYvsEtaZmPanel1);
2736     rdir->GetObject("Histograms_all/mePullYvsEtaZmPanel2", mePullYvsEtaZmPanel2);
2737     rdir->GetObject("Histograms_all/mePullYvsEtaZpPanel1", mePullYvsEtaZpPanel1);
2738     rdir->GetObject("Histograms_all/mePullYvsEtaZpPanel2", mePullYvsEtaZpPanel2);
2739 
2740     sdir->GetObject("Histograms_all/mePullYvsEtaBarrel"  , newmePullYvsEtaBarrel  ); 
2741     sdir->GetObject("Histograms_all/mePullYvsEtaZmPanel1", newmePullYvsEtaZmPanel1);
2742     sdir->GetObject("Histograms_all/mePullYvsEtaZmPanel2", newmePullYvsEtaZmPanel2);
2743     sdir->GetObject("Histograms_all/mePullYvsEtaZpPanel1", newmePullYvsEtaZpPanel1);
2744     sdir->GetObject("Histograms_all/mePullYvsEtaZpPanel2", newmePullYvsEtaZpPanel2);
2745   
2746     TLegend* leg16 = new TLegend(0.3, 0.2, 0.6, 0.4);
2747     can_PullYvsEta->cd(1);
2748     //gPad->SetLogy();
2749     SetUpProfileHistograms(mePullYvsEtaBarrel, newmePullYvsEtaBarrel, "barrel, eta", "pull y", lpull, hpull, leg16 );
2750     Float_t refMax = 0.5+1.4*mePullYvsEtaBarrel->GetMaximum();
2751     Float_t newMax = 0.5+1.4*newmePullYvsEtaBarrel->GetMaximum();
2752     if refMax > newMax
2753     {
2754         mePullYvsEtaBarrel->SetMaximum(refMax);
2755     }
2756     else
2757     {
2758         mePullYvsEtaBarrel->SetMaximum(newMax);
2759     }      
2760     mePullYvsEtaBarrel->SetName("Reference");
2761     newmePullYvsEtaBarrel->SetName("New Release");
2762     mePullYvsEtaBarrel->Draw("e");
2763     newmePullYvsEtaBarrel->Draw("eSameS"); 
2764     myPV->PVCompute(mePullYvsEtaBarrel, newmePullYvsEtaBarrel, te, 0.3, 0.4 );
2765     leg16->Draw();
2766     h_pv->SetBinContent(++bin, myPV->getPV());
2767     gPad->Update();
2768     TPaveStats *s79 = (TPaveStats*)mePullYvsEtaBarrel->GetListOfFunctions()->FindObject("stats");
2769     if (s79) {
2770       s79->SetX1NDC (0.55); //new x start position
2771       s79->SetX2NDC (0.75); //new x end position
2772     }
2773     can_PullYvsEta->cd(2);
2774     //gPad->SetLogy();
2775     SetUpProfileHistograms(mePullYvsEtaZmPanel1, newmePullYvsEtaZmPanel1, "panel1, z<0, eta", "pull y" , lpull, hpull);
2776     Float_t refMax = 0.5+1.4*mePullYvsEtaZmPanel1->GetMaximum();
2777     Float_t newMax = 0.5+1.4*newmePullYvsEtaZmPanel1->GetMaximum();
2778     if refMax > newMax
2779     {
2780         mePullYvsEtaZmPanel1->SetMaximum(refMax);
2781     }
2782     else
2783     {
2784         mePullYvsEtaZmPanel1->SetMaximum(newMax);
2785     }      
2786     mePullYvsEtaZmPanel1->SetName("Reference");
2787     newmePullYvsEtaZmPanel1->SetName("New Release");
2788     mePullYvsEtaZmPanel1->Draw("e");
2789     newmePullYvsEtaZmPanel1->Draw("esameS"); 
2790     myPV->PVCompute(mePullYvsEtaZmPanel1, newmePullYvsEtaZmPanel1, te, 0.2, 0.2 );
2791     h_pv->SetBinContent(++bin, myPV->getPV());
2792     gPad->Update();
2793     TPaveStats *s80 = (TPaveStats*)mePullYvsEtaZmPanel1->GetListOfFunctions()->FindObject("stats");
2794     if (s80) {
2795       s80->SetX1NDC (0.55); //new x start position
2796       s80->SetX2NDC (0.75); //new x end position
2797     }
2798     can_PullYvsEta->cd(3);
2799     //gPad->SetLogy();
2800     SetUpProfileHistograms(mePullYvsEtaZmPanel2, newmePullYvsEtaZmPanel2, "panel2, z<0, eta", "pull y", lpull, hpull );
2801     Float_t refMax = 0.5+1.2*mePullYvsEtaZmPanel2->GetMaximum();
2802     Float_t newMax = 0.5+1.2*newmePullYvsEtaZmPanel2->GetMaximum();
2803     if refMax > newMax
2804     {
2805         mePullYvsEtaZmPanel2->SetMaximum(refMax);
2806     }
2807     else
2808     {
2809         mePullYvsEtaZmPanel2->SetMaximum(newMax);
2810     }      
2811     mePullYvsEtaZmPanel2->SetName("Reference");
2812     newmePullYvsEtaZmPanel2->SetName("New Release");
2813     mePullYvsEtaZmPanel2->Draw("e");
2814     newmePullYvsEtaZmPanel2->Draw("esameS"); 
2815     myPV->PVCompute(mePullYvsEtaZmPanel2, newmePullYvsEtaZmPanel2, te, 0.2, 0.2 );
2816     h_pv->SetBinContent(++bin, myPV->getPV());
2817     gPad->Update();
2818     TPaveStats *s81 = (TPaveStats*)mePullYvsEtaZmPanel2->GetListOfFunctions()->FindObject("stats");
2819     if (s81) {
2820       s81->SetX1NDC (0.55); //new x start position
2821       s81->SetX2NDC (0.75); //new x end position
2822     }
2823     can_PullYvsEta->cd(5);
2824     //gPad->SetLogy();
2825     SetUpProfileHistograms(mePullYvsEtaZpPanel1, newmePullYvsEtaZpPanel1, "panel1, z>0, eta", "pull y", lpull, hpull );
2826     Float_t refMax = 0.5+1.4*mePullYvsEtaZpPanel1->GetMaximum();
2827     Float_t newMax = 0.5+1.4*newmePullYvsEtaZpPanel1->GetMaximum();
2828     if refMax > newMax
2829     {
2830         mePullYvsEtaZpPanel1->SetMaximum(refMax);
2831     }
2832     else
2833     {
2834         mePullYvsEtaZpPanel1->SetMaximum(newMax);
2835     }      
2836     mePullYvsEtaZpPanel1->SetName("Reference");
2837     newmePullYvsEtaZpPanel1->SetName("New Release");
2838     mePullYvsEtaZpPanel1->Draw("e");
2839     newmePullYvsEtaZpPanel1->Draw("esameS"); 
2840     myPV->PVCompute(mePullYvsEtaZpPanel1, newmePullYvsEtaZpPanel1, te, 0.2, 0.2 );
2841     h_pv->SetBinContent(++bin, myPV->getPV());
2842     gPad->Update();
2843     TPaveStats *s82 = (TPaveStats*)mePullYvsEtaZpPanel1->GetListOfFunctions()->FindObject("stats");
2844     if (s82) {
2845       s82->SetX1NDC (0.55); //new x start position
2846       s82->SetX2NDC (0.75); //new x end position
2847     }
2848     can_PullYvsEta->cd(6);
2849     //gPad->SetLogy();
2850     SetUpProfileHistograms(mePullYvsEtaZpPanel2, newmePullYvsEtaZpPanel2, "panel2, z>0, eta", "pull y", lpull, hpull );
2851     Float_t refMax = 0.5+1.4*mePullYvsEtaZpPanel2->GetMaximum();
2852     Float_t newMax = 0.5+1.4*newmePullYvsEtaZpPanel2->GetMaximum();
2853     if refMax > newMax
2854     {
2855         mePullYvsEtaZpPanel2->SetMaximum(refMax);
2856     }
2857     else
2858     {
2859         mePullYvsEtaZpPanel2->SetMaximum(newMax);
2860     }      
2861     mePullYvsEtaZpPanel2->SetName("Reference");
2862     newmePullYvsEtaZpPanel2->SetName("New Release");
2863     mePullYvsEtaZpPanel2->Draw("e");
2864     newmePullYvsEtaZpPanel2->Draw("esameS"); 
2865     myPV->PVCompute(mePullYvsEtaZpPanel2, newmePullYvsEtaZpPanel2, te, 0.2, 0.2 );
2866     h_pv->SetBinContent(++bin, myPV->getPV());
2867     gPad->Update();
2868     TPaveStats *s83 = (TPaveStats*)mePullYvsEtaZpPanel2->GetListOfFunctions()->FindObject("stats");
2869     if (s83) {
2870       s83->SetX1NDC (0.55); //new x start position
2871       s83->SetX2NDC (0.75); //new x end position
2872     }
2873     can_PullYvsEta->SaveAs("mePullYvsEta_compare.eps");
2874     can_PullYvsEta->SaveAs("mePullYvsEta_compare.gif");
2875   }
2876 
2877  //if (   0   ) 
2878  if (1) 
2879  {
2880     TCanvas* can_PullYvsPhi = new TCanvas("can_PullYvsPhi", "can_PullYvsPhi", 1200, 800);
2881     can_PullYvsPhi->Divide(3,2);
2882     
2883     TProfile* mePullYvsPhiBarrel;
2884     TProfile* mePullYvsPhiZmPanel1;
2885     TProfile* mePullYvsPhiZmPanel2;
2886     TProfile* mePullYvsPhiZpPanel1;
2887     TProfile* mePullYvsPhiZpPanel2;
2888     
2889     TProfile* newmePullYvsPhiBarrel;
2890     TProfile* newmePullYvsPhiZmPanel1;
2891     TProfile* newmePullYvsPhiZmPanel2;
2892     TProfile* newmePullYvsPhiZpPanel1;
2893     TProfile* newmePullYvsPhiZpPanel2;
2894 
2895     rdir->GetObject("Histograms_all/mePullYvsPhiBarrel"  , mePullYvsPhiBarrel  );
2896     rdir->GetObject("Histograms_all/mePullYvsPhiZmPanel1", mePullYvsPhiZmPanel1);
2897     rdir->GetObject("Histograms_all/mePullYvsPhiZmPanel2", mePullYvsPhiZmPanel2);
2898     rdir->GetObject("Histograms_all/mePullYvsPhiZpPanel1", mePullYvsPhiZpPanel1);
2899     rdir->GetObject("Histograms_all/mePullYvsPhiZpPanel2", mePullYvsPhiZpPanel2);
2900 
2901     sdir->GetObject("Histograms_all/mePullYvsPhiBarrel"  , newmePullYvsPhiBarrel  ); 
2902     sdir->GetObject("Histograms_all/mePullYvsPhiZmPanel1", newmePullYvsPhiZmPanel1);
2903     sdir->GetObject("Histograms_all/mePullYvsPhiZmPanel2", newmePullYvsPhiZmPanel2);
2904     sdir->GetObject("Histograms_all/mePullYvsPhiZpPanel1", newmePullYvsPhiZpPanel1);
2905     sdir->GetObject("Histograms_all/mePullYvsPhiZpPanel2", newmePullYvsPhiZpPanel2);
2906   
2907     TLegend* leg17 = new TLegend(0.3, 0.2, 0.6, 0.4);
2908     can_PullYvsPhi->cd(1);
2909     //gPad->SetLogy();
2910     SetUpProfileHistograms(mePullYvsPhiBarrel, newmePullYvsPhiBarrel, "barrel, phi (deg)", "pull y", lpull, hpull, leg17 );
2911     Float_t refMax = 0.5+1.2*mePullYvsPhiBarrel->GetMaximum();
2912     Float_t newMax = 0.5+1.2*newmePullYvsPhiBarrel->GetMaximum();
2913     if refMax > newMax
2914     {
2915         mePullYvsPhiBarrel->SetMaximum(refMax);
2916     }
2917     else
2918     {
2919         mePullYvsPhiBarrel->SetMaximum(newMax);
2920     }      
2921     mePullYvsPhiBarrel->SetName("Reference");
2922     newmePullYvsPhiBarrel->SetName("New Release");
2923     mePullYvsPhiBarrel->Draw("e");
2924     newmePullYvsPhiBarrel->Draw("eSameS"); 
2925     myPV->PVCompute(mePullYvsPhiBarrel, newmePullYvsPhiBarrel, te, 0.3, 0.4 );
2926     leg17->Draw();
2927     h_pv->SetBinContent(++bin, myPV->getPV());
2928     gPad->Update();
2929     TPaveStats *s84 = (TPaveStats*)mePullYvsPhiBarrel->GetListOfFunctions()->FindObject("stats");
2930     if (s84) {
2931       s84->SetX1NDC (0.55); //new x start position
2932       s84->SetX2NDC (0.75); //new x end position
2933     }
2934     can_PullYvsPhi->cd(2);
2935     //gPad->SetLogy();
2936     SetUpProfileHistograms(mePullYvsPhiZmPanel1, newmePullYvsPhiZmPanel1, "panel1, z<0, phi (deg)", "pull y" , lpull, hpull);
2937     Float_t refMax = 0.5+1.2*mePullYvsPhiZmPanel1->GetMaximum();
2938     Float_t newMax = 0.5+1.2*newmePullYvsPhiZmPanel1->GetMaximum();
2939     if refMax > newMax
2940     {
2941         mePullYvsPhiZmPanel1->SetMaximum(refMax);
2942     }
2943     else
2944     {
2945         mePullYvsPhiZmPanel1->SetMaximum(newMax);
2946     }      
2947     mePullYvsPhiZmPanel1->SetName("Reference");
2948     newmePullYvsPhiZmPanel1->SetName("New Release");
2949     mePullYvsPhiZmPanel1->Draw("e");
2950     newmePullYvsPhiZmPanel1->Draw("esameS"); 
2951     myPV->PVCompute(mePullYvsPhiZmPanel1, newmePullYvsPhiZmPanel1, te, 0.2, 0.2);
2952     h_pv->SetBinContent(++bin, myPV->getPV());
2953     gPad->Update();
2954     TPaveStats *s85 = (TPaveStats*)mePullYvsPhiZmPanel1->GetListOfFunctions()->FindObject("stats");
2955     if (s85) {
2956       s85->SetX1NDC (0.55); //new x start position
2957       s85->SetX2NDC (0.75); //new x end position
2958     }
2959     can_PullYvsPhi->cd(3);
2960     //gPad->SetLogy();
2961     SetUpProfileHistograms(mePullYvsPhiZmPanel2, newmePullYvsPhiZmPanel2, "panel2, z<0, phi (deg)", "pull y" , lpull, hpull);
2962     Float_t refMax = 0.5+1.2*mePullYvsPhiZmPanel2->GetMaximum();
2963     Float_t newMax = 0.5+1.2*newmePullYvsPhiZmPanel2->GetMaximum();
2964     if refMax > newMax
2965     {
2966         mePullYvsPhiZmPanel2->SetMaximum(refMax);
2967     }
2968     else
2969     {
2970         mePullYvsPhiZmPanel2->SetMaximum(newMax);
2971     }      
2972     mePullYvsPhiZmPanel2->SetName("Reference");
2973     newmePullYvsPhiZmPanel2->SetName("New Release");
2974     mePullYvsPhiZmPanel2->Draw("e");
2975     newmePullYvsPhiZmPanel2->Draw("esameS"); 
2976     myPV->PVCompute(mePullYvsPhiZmPanel2, newmePullYvsPhiZmPanel2, te, 0.2, 0.2);
2977     h_pv->SetBinContent(++bin, myPV->getPV());
2978     gPad->Update();
2979     TPaveStats *s86 = (TPaveStats*)mePullYvsPhiZmPanel2->GetListOfFunctions()->FindObject("stats");
2980     if (s86) {
2981       s86->SetX1NDC (0.55); //new x start position
2982       s86->SetX2NDC (0.75); //new x end position
2983     }
2984     can_PullYvsPhi->cd(5);
2985     //gPad->SetLogy();
2986     SetUpProfileHistograms(mePullYvsPhiZpPanel1, newmePullYvsPhiZpPanel1, "panel1, z>0, phi (deg)", "pull y", lpull, hpull );
2987     Float_t refMax = 0.5+1.2*mePullYvsPhiZpPanel1->GetMaximum();
2988     Float_t newMax = 0.5+1.2*newmePullYvsPhiZpPanel1->GetMaximum();
2989     if refMax > newMax
2990     {
2991         mePullYvsPhiZpPanel1->SetMaximum(refMax);
2992     }
2993     else
2994     {
2995         mePullYvsPhiZpPanel1->SetMaximum(newMax);
2996     }      
2997     mePullYvsPhiZpPanel1->SetName("Reference");
2998     newmePullYvsPhiZpPanel1->SetName("New Release");
2999     mePullYvsPhiZpPanel1->Draw("e");
3000     newmePullYvsPhiZpPanel1->Draw("esameS"); 
3001     myPV->PVCompute(mePullYvsPhiZpPanel1, newmePullYvsPhiZpPanel1, te, 0.2, 0.2 );
3002     h_pv->SetBinContent(++bin, myPV->getPV());
3003     gPad->Update();
3004     TPaveStats *s87 = (TPaveStats*)mePullYvsPhiZpPanel1->GetListOfFunctions()->FindObject("stats");
3005     if (s87) {
3006       s87->SetX1NDC (0.55); //new x start position
3007       s87->SetX2NDC (0.75); //new x end position
3008     }
3009     can_PullYvsPhi->cd(6);
3010     //gPad->SetLogy();
3011     SetUpProfileHistograms(mePullYvsPhiZpPanel2, newmePullYvsPhiZpPanel2, "panel2, z>0, phi (deg)", "pull y", lpull, hpull );
3012     Float_t refMax = 0.5+1.2*mePullYvsPhiZpPanel2->GetMaximum();
3013     Float_t newMax = 0.5+1.2*newmePullYvsPhiZpPanel2->GetMaximum();
3014     if refMax > newMax
3015     {
3016         mePullYvsPhiZpPanel2->SetMaximum(refMax);
3017     }
3018     else
3019     {
3020         mePullYvsPhiZpPanel2->SetMaximum(newMax);
3021     }      
3022     mePullYvsPhiZpPanel2->SetName("Reference");
3023     newmePullYvsPhiZpPanel2->SetName("New Release");
3024     mePullYvsPhiZpPanel2->Draw("e");
3025     newmePullYvsPhiZpPanel2->Draw("esameS"); 
3026     myPV->PVCompute(mePullYvsPhiZpPanel2, newmePullYvsPhiZpPanel2, te, 0.2, 0.2 );
3027     h_pv->SetBinContent(++bin, myPV->getPV());
3028     gPad->Update();
3029     TPaveStats *s88 = (TPaveStats*)mePullYvsPhiZpPanel2->GetListOfFunctions()->FindObject("stats");
3030     if (s88) {
3031       s88->SetX1NDC (0.55); //new x start position
3032       s88->SetX2NDC (0.75); //new x end position
3033     }
3034     can_PullYvsPhi->SaveAs("mePullYvsPhi_compare.eps");
3035     can_PullYvsPhi->SaveAs("mePullYvsPhi_compare.gif");
3036   }
3037 
3038 if (1) 
3039   {
3040     TCanvas* can_mePullx = new TCanvas("can_mePullx", "can_mePullx", 1200, 800);
3041     can_mePullx->Divide(3,2);
3042     
3043     TH1F* mePullxBarrel;
3044     TH1F* mePullxZmPanel1;
3045     TH1F* mePullxZmPanel2;
3046     TH1F* mePullxZpPanel1;
3047     TH1F* mePullxZpPanel2;
3048     
3049     TH1F* newmePullxBarrel;
3050     TH1F* newmePullxZmPanel1;
3051     TH1F* newmePullxZmPanel2;
3052     TH1F* newmePullxZpPanel1;
3053     TH1F* newmePullxZpPanel2;
3054 
3055     rdir->GetObject("Histograms_all/mePullxBarrel"  , mePullxBarrel  );
3056     rdir->GetObject("Histograms_all/mePullxZmPanel1", mePullxZmPanel1);
3057     rdir->GetObject("Histograms_all/mePullxZmPanel2", mePullxZmPanel2);
3058     rdir->GetObject("Histograms_all/mePullxZpPanel1", mePullxZpPanel1);
3059     rdir->GetObject("Histograms_all/mePullxZpPanel2", mePullxZpPanel2);
3060 
3061     sdir->GetObject("Histograms_all/mePullxBarrel"  , newmePullxBarrel  ); 
3062     sdir->GetObject("Histograms_all/mePullxZmPanel1", newmePullxZmPanel1);
3063     sdir->GetObject("Histograms_all/mePullxZmPanel2", newmePullxZmPanel2);
3064     sdir->GetObject("Histograms_all/mePullxZpPanel1", newmePullxZpPanel1);
3065     sdir->GetObject("Histograms_all/mePullxZpPanel2", newmePullxZpPanel2);
3066   
3067     TLegend* leg18 = new TLegend(0.15, 0.67, 0.45, 0.87);
3068     can_mePullx->cd(1);
3069     //gPad->SetLogy();
3070     SetUpHistograms(mePullxBarrel, newmePullxBarrel, "barrel, pull x", leg18);
3071     Float_t refMax = 1.2*mePullxBarrel->GetMaximum();
3072     Float_t newMax = 1.2*newmePullxBarrel->GetMaximum();
3073     if refMax > newMax
3074     {
3075         mePullxBarrel->SetMaximum(refMax);
3076     }
3077     else
3078     {
3079         mePullxBarrel->SetMaximum(newMax);
3080     }      
3081     mePullxBarrel->SetName("Reference");
3082     newmePullxBarrel->SetName("New Release");
3083     mePullxBarrel->Draw("he");
3084     newmePullxBarrel->Draw("heSameS"); 
3085     myPV->PVCompute(mePullxBarrel, newmePullxBarrel, te);
3086     leg18->Draw();
3087     h_pv->SetBinContent(++bin, myPV->getPV());
3088     gPad->Update();
3089     TPaveStats *s89 = (TPaveStats*)mePullxBarrel->GetListOfFunctions()->FindObject("stats");
3090     if (s89) {
3091       s89->SetX1NDC (0.55); //new x start position
3092       s89->SetX2NDC (0.75); //new x end position
3093     }
3094     can_mePullx->cd(2);
3095     //gPad->SetLogy();
3096     SetUpHistograms(mePullxZmPanel1, newmePullxZmPanel1, "panel1, z<0, pull x" );
3097     Float_t refMax = 1.2*mePullxZmPanel1->GetMaximum();
3098     Float_t newMax = 1.2*newmePullxZmPanel1->GetMaximum();
3099     if refMax > newMax
3100     {
3101         mePullxZmPanel1->SetMaximum(refMax);
3102     }
3103     else
3104     {
3105         mePullxZmPanel1->SetMaximum(newMax);
3106     }      
3107     mePullxZmPanel1->SetName("Reference");
3108     newmePullxZmPanel1->SetName("New Release");
3109     mePullxZmPanel1->Draw("he");
3110     newmePullxZmPanel1->Draw("hesameS"); 
3111     myPV->PVCompute(mePullxZmPanel1, newmePullxZmPanel1, te );
3112     h_pv->SetBinContent(++bin, myPV->getPV());
3113     gPad->Update();
3114     TPaveStats *s90 = (TPaveStats*)mePullxZmPanel1->GetListOfFunctions()->FindObject("stats");
3115     if (s90) {
3116       s90->SetX1NDC (0.55); //new x start position
3117       s90->SetX2NDC (0.75); //new x end position
3118     }
3119     can_mePullx->cd(3);
3120     //gPad->SetLogy();
3121     SetUpHistograms(mePullxZmPanel2, newmePullxZmPanel2, "panel2, z<0, pull x" );
3122     Float_t refMax = 1.2*mePullxZmPanel2->GetMaximum();
3123     Float_t newMax = 1.2*newmePullxZmPanel2->GetMaximum();
3124     if refMax > newMax
3125     {
3126         mePullxZmPanel2->SetMaximum(refMax);
3127     }
3128     else
3129     {
3130         mePullxZmPanel2->SetMaximum(newMax);
3131     }      
3132     mePullxZmPanel2->SetName("Reference");
3133     newmePullxZmPanel2->SetName("New Release");
3134     mePullxZmPanel2->Draw("he"); 
3135     newmePullxZmPanel2->Draw("hesameS"); 
3136     myPV->PVCompute(mePullxZmPanel2, newmePullxZmPanel2, te );
3137     h_pv->SetBinContent(++bin, myPV->getPV());
3138     gPad->Update();
3139     TPaveStats *s91 = (TPaveStats*)mePullxZmPanel2->GetListOfFunctions()->FindObject("stats");
3140     if (s91) {
3141       s91->SetX1NDC (0.55); //new x start position
3142       s91->SetX2NDC (0.75); //new x end position
3143     }
3144     can_mePullx->cd(5);
3145     //gPad->SetLogy();
3146     SetUpHistograms(mePullxZpPanel1, newmePullxZpPanel1, "panel2, z>0, pull x" );
3147     Float_t refMax = 1.3*mePullxZpPanel1->GetMaximum();
3148     Float_t newMax = 1.3*newmePullxZpPanel1->GetMaximum();
3149     if refMax > newMax
3150     {
3151         mePullxZpPanel1->SetMaximum(refMax);
3152     }
3153     else
3154     {
3155         mePullxZpPanel1->SetMaximum(newMax);
3156     }      
3157     mePullxZpPanel1->SetName("Reference");
3158     newmePullxZpPanel1->SetName("New Release");
3159     mePullxZpPanel1->Draw("he");
3160     newmePullxZpPanel1->Draw("hesameS"); 
3161     myPV->PVCompute(mePullxZpPanel1, newmePullxZpPanel1, te);
3162     h_pv->SetBinContent(++bin, myPV->getPV());
3163     gPad->Update();
3164     TPaveStats *s92 = (TPaveStats*)mePullxZpPanel1->GetListOfFunctions()->FindObject("stats");
3165     if (s92) {
3166       s92->SetX1NDC (0.55); //new x start position
3167       s92->SetX2NDC (0.75); //new x end position
3168     }
3169     can_mePullx->cd(6);
3170     //gPad->SetLogy();
3171     SetUpHistograms(mePullxZpPanel2, newmePullxZpPanel2, "panel1, z>0, pull x" );
3172     Float_t refMax = 1.2*mePullxZpPanel2->GetMaximum();
3173     Float_t newMax = 1.2*newmePullxZpPanel2->GetMaximum();
3174     if refMax > newMax
3175     {
3176         mePullxZpPanel2->SetMaximum(refMax);
3177     }
3178     else
3179     {
3180         mePullxZpPanel2->SetMaximum(newMax);
3181     }      
3182     mePullxZpPanel2->SetName("Reference");
3183     newmePullxZpPanel2->SetName("New Release");
3184     mePullxZpPanel2->Draw("he");
3185     newmePullxZpPanel2->Draw("hesameS"); 
3186     myPV->PVCompute(mePullxZpPanel2, newmePullxZpPanel2, te );
3187     h_pv->SetBinContent(++bin, myPV->getPV());
3188     gPad->Update();
3189     TPaveStats *s93 = (TPaveStats*)mePullxZpPanel2->GetListOfFunctions()->FindObject("stats");
3190     if (s93) {
3191       s93->SetX1NDC (0.55); //new x start position
3192       s93->SetX2NDC (0.75); //new x end position
3193     }
3194     can_mePullx->SaveAs("mePullx_compare.eps");
3195     can_mePullx->SaveAs("mePullx_compare.gif");
3196   }
3197 
3198 if (1) 
3199   {
3200     TCanvas* can_mePully = new TCanvas("can_mePully", "can_mePully", 1200, 800);
3201     can_mePully->Divide(3,2);
3202     
3203     TH1F* mePullyBarrel;
3204     TH1F* mePullyZmPanel1;
3205     TH1F* mePullyZmPanel2;
3206     TH1F* mePullyZpPanel1;
3207     TH1F* mePullyZpPanel2;
3208     
3209     TH1F* newmePullyBarrel;
3210     TH1F* newmePullyZmPanel1;
3211     TH1F* newmePullyZmPanel2;
3212     TH1F* newmePullyZpPanel1;
3213     TH1F* newmePullyZpPanel2;
3214 
3215     rdir->GetObject("Histograms_all/mePullyBarrel"  , mePullyBarrel  );
3216     rdir->GetObject("Histograms_all/mePullyZmPanel1", mePullyZmPanel1);
3217     rdir->GetObject("Histograms_all/mePullyZmPanel2", mePullyZmPanel2);
3218     rdir->GetObject("Histograms_all/mePullyZpPanel1", mePullyZpPanel1);
3219     rdir->GetObject("Histograms_all/mePullyZpPanel2", mePullyZpPanel2);
3220 
3221     sdir->GetObject("Histograms_all/mePullyBarrel"  , newmePullyBarrel  ); 
3222     sdir->GetObject("Histograms_all/mePullyZmPanel1", newmePullyZmPanel1);
3223     sdir->GetObject("Histograms_all/mePullyZmPanel2", newmePullyZmPanel2);
3224     sdir->GetObject("Histograms_all/mePullyZpPanel1", newmePullyZpPanel1);
3225     sdir->GetObject("Histograms_all/mePullyZpPanel2", newmePullyZpPanel2);
3226   
3227     TLegend* leg19 = new TLegend(0.15, 0.67, 0.45, 0.87);
3228     can_mePully->cd(1);
3229     //gPad->SetLogy();
3230     SetUpHistograms(mePullyBarrel, newmePullyBarrel, "barrel, pull y", leg19 );
3231     Float_t refMax = 1.2*mePullyBarrel->GetMaximum();
3232     Float_t newMax = 1.2*newmePullyBarrel->GetMaximum();
3233     if refMax > newMax
3234     {
3235         mePullyBarrel->SetMaximum(refMax);
3236     }
3237     else
3238     {
3239         mePullyBarrel->SetMaximum(newMax);
3240     }      
3241     mePullyBarrel->SetName("Reference");
3242     newmePullyBarrel->SetName("New Release");
3243     mePullyBarrel->Draw("he");
3244     newmePullyBarrel->Draw("heSameS"); 
3245     myPV->PVCompute(mePullyBarrel, newmePullyBarrel, te);
3246     leg19->Draw();
3247     h_pv->SetBinContent(++bin, myPV->getPV());
3248     gPad->Update();
3249     TPaveStats *s94 = (TPaveStats*)mePullyBarrel->GetListOfFunctions()->FindObject("stats");
3250     if (s94) {
3251       s94->SetX1NDC (0.55); //new x start position
3252       s94->SetX2NDC (0.75); //new x end position
3253     }
3254 
3255     can_mePully->cd(2);
3256     //gPad->SetLogy();
3257     SetUpHistograms(mePullyZmPanel1, newmePullyZmPanel1, "panel1, z<0, pull y" );
3258     Float_t refMax = 1.2*mePullyZmPanel1->GetMaximum();
3259     Float_t newMax = 1.2*newmePullyZmPanel1->GetMaximum();
3260     if refMax > newMax
3261     {
3262         mePullyZmPanel1->SetMaximum(refMax);
3263     }
3264     else
3265     {
3266         mePullyZmPanel1->SetMaximum(newMax);
3267     }      
3268     mePullyZmPanel1->SetName("Reference");
3269     newmePullyZmPanel1->SetName("New Release");
3270     mePullyZmPanel1->Draw("he");
3271     newmePullyZmPanel1->Draw("hesameS"); 
3272     myPV->PVCompute(mePullyZmPanel1, newmePullyZmPanel1, te);
3273     h_pv->SetBinContent(++bin, myPV->getPV());
3274     gPad->Update();
3275     TPaveStats *s139 = (TPaveStats*)mePullyZmPanel1->GetListOfFunctions()->FindObject("stats");
3276     if (s139) {
3277         s139->SetX1NDC (0.55); //new x start position
3278         s139->SetX2NDC (0.75); //new x end position
3279     }
3280     can_mePully->cd(3);
3281     //gPad->SetLogy();
3282     SetUpHistograms(mePullyZmPanel2, newmePullyZmPanel2, "panel2, z<0, pull y" );
3283     Float_t refMax = 1.2*mePullyZmPanel2->GetMaximum();
3284     Float_t newMax = 1.2*newmePullyZmPanel2->GetMaximum();
3285     if refMax > newMax
3286     {
3287         mePullyZmPanel2->SetMaximum(refMax);
3288     }
3289     else
3290     {
3291         mePullyZmPanel2->SetMaximum(newMax);
3292     }      
3293     mePullyZmPanel2->SetName("Reference");
3294     newmePullyZmPanel2->SetName("New Release");
3295     mePullyZmPanel2->Draw("he");
3296     newmePullyZmPanel2->Draw("hesameS"); 
3297     myPV->PVCompute(mePullyZmPanel2, newmePullyZmPanel2, te);
3298     h_pv->SetBinContent(++bin, myPV->getPV());
3299     gPad->Update();
3300     TPaveStats *s95 = (TPaveStats*)mePullyZmPanel2->GetListOfFunctions()->FindObject("stats");
3301     if (s95) {
3302       s95->SetX1NDC (0.55); //new x start position
3303       s95->SetX2NDC (0.75); //new x end position
3304     }
3305 
3306     can_mePully->cd(5);
3307     //gPad->SetLogy();
3308     SetUpHistograms(mePullyZpPanel1, newmePullyZpPanel1, "panel1, z>0, pull y" );
3309     Float_t refMax = 1.2*mePullyZpPanel1->GetMaximum();
3310     Float_t newMax = 1.2*newmePullyZpPanel1->GetMaximum();
3311     if refMax > newMax
3312     {
3313         mePullyZpPanel1->SetMaximum(refMax);
3314     }
3315     else
3316     {
3317         mePullyZpPanel1->SetMaximum(newMax);
3318     }      
3319     mePullyZpPanel1->SetName("Reference");
3320     newmePullyZpPanel1->SetName("New Release");
3321     mePullyZpPanel1->Draw("he");
3322     newmePullyZpPanel1->Draw("hesameS"); 
3323     myPV->PVCompute(mePullyZpPanel1, newmePullyZpPanel1, te);
3324     h_pv->SetBinContent(++bin, myPV->getPV());
3325     gPad->Update();
3326     TPaveStats *s96 = (TPaveStats*)mePullyZpPanel1->GetListOfFunctions()->FindObject("stats");
3327     if (s96) {
3328       s96->SetX1NDC (0.55); //new x start position
3329       s96->SetX2NDC (0.75); //new x end position
3330     }
3331 
3332     can_mePully->cd(6);
3333     //gPad->SetLogy();
3334     SetUpHistograms(mePullyZpPanel2, newmePullyZpPanel2, "panel2, z>0, pull y" );
3335     Float_t refMax = 1.2*mePullyZpPanel2->GetMaximum();
3336     Float_t newMax = 1.2*newmePullyZpPanel2->GetMaximum();
3337     if refMax > newMax
3338     {
3339         mePullyZpPanel2->SetMaximum(refMax);
3340     }
3341     else
3342     {
3343         mePullyZpPanel2->SetMaximum(newMax);
3344     }      
3345     mePullyZpPanel2->SetName("Reference");
3346     newmePullyZpPanel2->SetName("New Release");
3347     mePullyZpPanel2->Draw("he");
3348     newmePullyZpPanel2->Draw("hesameS"); 
3349     myPV->PVCompute(mePullyZpPanel2, newmePullyZpPanel2, te);
3350     h_pv->SetBinContent(++bin, myPV->getPV());
3351     gPad->Update();
3352     TPaveStats *s97 = (TPaveStats*)mePullyZpPanel2->GetListOfFunctions()->FindObject("stats");
3353     if (s97) {
3354       s97->SetX1NDC (0.55); //new x start position
3355       s97->SetX2NDC (0.75); //new x end position
3356     }
3357 
3358     can_mePully->SaveAs("mePully_compare.eps");
3359     can_mePully->SaveAs("mePully_compare.gif");
3360   }
3361 
3362  double xmin = 0.0000;
3363  double xmax = 0.0020;
3364 
3365 if (1) 
3366   {
3367     TCanvas* can_ResXvsAlpha = new TCanvas("can_ResXvsAlpha", "can_ResXvsAlpha", 1200, 800);
3368     can_ResXvsAlpha->Divide(3,2);
3369     
3370     TProfile* meResXvsAlphaBarrelFlippedLadders;
3371     TProfile* meResXvsAlphaBarrelNonFlippedLadders;
3372     TProfile* meResXvsAlphaZmPanel1;
3373     TProfile* meResXvsAlphaZmPanel2;
3374     TProfile* meResXvsAlphaZpPanel1;
3375     TProfile* meResXvsAlphaZpPanel2;
3376     
3377     TProfile* newmeResXvsAlphaBarrelFlippedLadders;
3378     TProfile* newmeResXvsAlphaBarrelNonFlippedLadders;
3379     TProfile* newmeResXvsAlphaZmPanel1;
3380     TProfile* newmeResXvsAlphaZmPanel2;
3381     TProfile* newmeResXvsAlphaZpPanel1;
3382     TProfile* newmeResXvsAlphaZpPanel2;
3383 
3384     rdir->GetObject("Histograms_all/meResXvsAlphaBarrelFlippedLadders"     , meResXvsAlphaBarrelFlippedLadders     );
3385     rdir->GetObject("Histograms_all/meResXvsAlphaBarrelNonFlippedLadders"  , meResXvsAlphaBarrelNonFlippedLadders  );
3386 
3387     rdir->GetObject("Histograms_all/meResXvsAlphaZmPanel1", meResXvsAlphaZmPanel1);
3388     rdir->GetObject("Histograms_all/meResXvsAlphaZmPanel2", meResXvsAlphaZmPanel2);
3389     rdir->GetObject("Histograms_all/meResXvsAlphaZpPanel1", meResXvsAlphaZpPanel1);
3390     rdir->GetObject("Histograms_all/meResXvsAlphaZpPanel2", meResXvsAlphaZpPanel2);
3391 
3392     sdir->GetObject("Histograms_all/meResXvsAlphaBarrelFlippedLadders"   , 
3393              newmeResXvsAlphaBarrelFlippedLadders     );
3394     sdir->GetObject("Histograms_all/meResXvsAlphaBarrelNonFlippedLadders", 
3395              newmeResXvsAlphaBarrelNonFlippedLadders  );
3396  
3397     sdir->GetObject("Histograms_all/meResXvsAlphaZmPanel1", newmeResXvsAlphaZmPanel1);
3398     sdir->GetObject("Histograms_all/meResXvsAlphaZmPanel2", newmeResXvsAlphaZmPanel2);
3399     sdir->GetObject("Histograms_all/meResXvsAlphaZpPanel1", newmeResXvsAlphaZpPanel1);
3400     sdir->GetObject("Histograms_all/meResXvsAlphaZpPanel2", newmeResXvsAlphaZpPanel2);
3401   
3402     TLegend* leg20 = new TLegend(0.3, 0.2, 0.6, 0.4);
3403     can_ResXvsAlpha->cd(1);
3404     //gPad->SetLogy();
3405     SetUpProfileHistograms(meResXvsAlphaBarrelFlippedLadders, newmeResXvsAlphaBarrelFlippedLadders, "barrel, non-flipped ladders, |alpha| (deg)", "<|x residual|> (cm)", xmin, xmax, leg20 );
3406     Float_t refMax = 1.5*meResXvsAlphaBarrelFlippedLadders->GetMaximum();
3407     Float_t newMax = 1.5*newmeResXvsAlphaBarrelFlippedLadders->GetMaximum();
3408     if refMax > newMax
3409     {
3410         meResXvsAlphaBarrelFlippedLadders->SetMaximum(refMax);
3411     }
3412     else
3413     {
3414         meResXvsAlphaBarrelFlippedLadders->SetMaximum(newMax);
3415     }      
3416     meResXvsAlphaBarrelFlippedLadders->SetName("Reference");
3417     newmeResXvsAlphaBarrelFlippedLadders->SetName("New Release");
3418     meResXvsAlphaBarrelFlippedLadders->Draw("e");
3419     newmeResXvsAlphaBarrelFlippedLadders->Draw("eSameS"); 
3420     myPV->PVCompute(meResXvsAlphaBarrelFlippedLadders, newmeResXvsAlphaBarrelFlippedLadders, te, 0.3, 0.4 );
3421     leg20->Draw();
3422     h_pv->SetBinContent(++bin, myPV->getPV());
3423     gPad->Update();
3424     TPaveStats *s98 = (TPaveStats*)meResXvsAlphaBarrelFlippedLadders->GetListOfFunctions()->FindObject("stats");
3425     if (s98) {
3426       s98->SetX1NDC (0.55); //new x start position
3427       s98->SetX2NDC (0.75); //new x end position
3428     }
3429     can_ResXvsAlpha->cd(2);
3430     //gPad->SetLogy();
3431     SetUpProfileHistograms(meResXvsAlphaZmPanel1, newmeResXvsAlphaZmPanel1, 
3432                "panel1, z<0, |alpha| (deg)", "<|x residual|> (cm)", xmin, xmax );
3433     Float_t refMax = 1.2*meResXvsAlphaZmPanel1->GetMaximum();
3434     Float_t newMax = 1.2*newmeResXvsAlphaZmPanel1->GetMaximum();
3435     if refMax > newMax
3436     {
3437         meResXvsAlphaZmPanel1->SetMaximum(refMax);
3438     }
3439     else
3440     {
3441         meResXvsAlphaZmPanel1->SetMaximum(newMax);
3442     }      
3443     meResXvsAlphaZmPanel1->SetName("Reference");
3444     newmeResXvsAlphaZmPanel1->SetName("New Release");
3445     meResXvsAlphaZmPanel1->SetMinimum(xmin);
3446     meResXvsAlphaZmPanel1->SetMaximum(xmax);
3447     meResXvsAlphaZmPanel1->Draw("e");
3448     newmeResXvsAlphaZmPanel1->Draw("esameS"); 
3449     myPV->PVCompute(meResXvsAlphaZmPanel1, newmeResXvsAlphaZmPanel1, te );
3450     h_pv->SetBinContent(++bin, myPV->getPV());
3451     gPad->Update();
3452     TPaveStats *s99 = (TPaveStats*)meResXvsAlphaZmPanel1->GetListOfFunctions()->FindObject("stats");
3453     if (s99) {
3454       s99->SetX1NDC (0.55); //new x start position
3455       s99->SetX2NDC (0.75); //new x end position
3456     }
3457     can_ResXvsAlpha->cd(3);
3458     //gPad->SetLogy();
3459     SetUpProfileHistograms(meResXvsAlphaZmPanel2, newmeResXvsAlphaZmPanel2, "panel2, z<0, |alpha| (deg)", "<|x residual|> (cm)", xmin, xmax );
3460     Float_t refMax = 1.2*meResXvsAlphaZmPanel2->GetMaximum();
3461     Float_t newMax = 1.2*newmeResXvsAlphaZmPanel2->GetMaximum();
3462     if refMax > newMax
3463     {
3464         meResXvsAlphaZmPanel2->SetMaximum(refMax);
3465     }
3466     else
3467     {
3468         meResXvsAlphaZmPanel2->SetMaximum(newMax);
3469     }      
3470     meResXvsAlphaZmPanel2->SetName("Reference");
3471     newmeResXvsAlphaZmPanel2->SetName("New Release");
3472     meResXvsAlphaZmPanel2->SetMinimum(xmin);
3473     meResXvsAlphaZmPanel2->SetMaximum(xmax);
3474     meResXvsAlphaZmPanel2->Draw("e");
3475     newmeResXvsAlphaZmPanel2->Draw("esameS"); 
3476     myPV->PVCompute(meResXvsAlphaZmPanel2, newmeResXvsAlphaZmPanel2, te );
3477     h_pv->SetBinContent(++bin, myPV->getPV());
3478     gPad->Update();
3479     TPaveStats *s100 = (TPaveStats*)meResXvsAlphaZmPanel2->GetListOfFunctions()->FindObject("stats");
3480     if (s100) {
3481       s100->SetX1NDC (0.55); //new x start position
3482       s100->SetX2NDC (0.75); //new x end position
3483     }
3484     can_ResXvsAlpha->cd(4);
3485     //gPad->SetLogy();
3486     SetUpProfileHistograms(meResXvsAlphaBarrelNonFlippedLadders, newmeResXvsAlphaBarrelNonFlippedLadders, "barrel, flipped ladders, |alpha| (deg)", "<|x residual|> (cm)", xmin, xmax );
3487     Float_t refMax = 1.2*meResXvsAlphaBarrelNonFlippedLadders->GetMaximum();
3488     Float_t newMax = 1.2*newmeResXvsAlphaBarrelNonFlippedLadders->GetMaximum();
3489     if refMax > newMax
3490     {
3491         meResXvsAlphaBarrelNonFlippedLadders->SetMaximum(refMax);
3492     }
3493     else
3494     {
3495         meResXvsAlphaBarrelNonFlippedLadders->SetMaximum(newMax);
3496     }      
3497     meResXvsAlphaBarrelNonFlippedLadders->SetName("Reference");
3498     newmeResXvsAlphaBarrelNonFlippedLadders->SetName("New Release");
3499     meResXvsAlphaBarrelNonFlippedLadders->SetMinimum(xmin);
3500     meResXvsAlphaBarrelNonFlippedLadders->SetMaximum(xmax);
3501     meResXvsAlphaBarrelNonFlippedLadders->Draw("e");
3502     newmeResXvsAlphaBarrelNonFlippedLadders->Draw("eSameS"); 
3503     myPV->PVCompute(meResXvsAlphaBarrelNonFlippedLadders, newmeResXvsAlphaBarrelNonFlippedLadders, te );
3504     h_pv->SetBinContent(++bin, myPV->getPV());
3505     gPad->Update();
3506     TPaveStats *s101 = (TPaveStats*)meResXvsAlphaBarrelNonFlippedLadders->GetListOfFunctions()->FindObject("stats");
3507     if (s101) {
3508       s101->SetX1NDC (0.55); //new x start position
3509       s101->SetX2NDC (0.75); //new x end position
3510     }
3511     can_ResXvsAlpha->cd(5);
3512     //gPad->SetLogy();
3513     SetUpProfileHistograms(meResXvsAlphaZpPanel1, newmeResXvsAlphaZpPanel1, 
3514                "panel1, z>0, |alpha| (deg)", "<|x residual|> (cm)", xmin, xmax );
3515     Float_t refMax = 1.2*meResXvsAlphaZpPanel1->GetMaximum();
3516     Float_t newMax = 1.2*newmeResXvsAlphaZpPanel1->GetMaximum();
3517     if refMax > newMax
3518     {
3519         meResXvsAlphaZpPanel1->SetMaximum(refMax);
3520     }
3521     else
3522     {
3523         meResXvsAlphaZpPanel1->SetMaximum(newMax);
3524     }      
3525     meResXvsAlphaZpPanel1->SetName("Reference");
3526     newmeResXvsAlphaZpPanel1->SetName("New Release");
3527     meResXvsAlphaZpPanel1->SetMinimum(xmin);
3528     meResXvsAlphaZpPanel1->SetMaximum(xmax);
3529     meResXvsAlphaZpPanel1->Draw("e");
3530     newmeResXvsAlphaZpPanel1->Draw("esameS"); 
3531     myPV->PVCompute(meResXvsAlphaZpPanel1, newmeResXvsAlphaZpPanel1, te, 0.2 , 0.2 );
3532     h_pv->SetBinContent(++bin, myPV->getPV());
3533     gPad->Update();
3534     TPaveStats *s102 = (TPaveStats*)meResXvsAlphaZpPanel1->GetListOfFunctions()->FindObject("stats");
3535     if (s102) {
3536       s102->SetX1NDC (0.55); //new x start position
3537       s102->SetX2NDC (0.75); //new x end position
3538     }
3539     can_ResXvsAlpha->cd(6);
3540     //gPad->SetLogy();
3541     SetUpProfileHistograms(meResXvsAlphaZpPanel2, newmeResXvsAlphaZpPanel2, "panel2, z>0, |alpha| (deg)", "<|x residual|> (cm)", xmin, xmax );
3542     Float_t refMax = 1.2*meResXvsAlphaZpPanel2->GetMaximum();
3543     Float_t newMax = 1.2*newmeResXvsAlphaZpPanel2->GetMaximum();
3544     if refMax > newMax
3545     {
3546         meResXvsAlphaZpPanel2->SetMaximum(refMax);
3547     }
3548     else
3549     {
3550         meResXvsAlphaZpPanel2->SetMaximum(newMax);
3551     }      
3552     meResXvsAlphaZpPanel2->SetName("Reference");
3553     newmeResXvsAlphaZpPanel2->SetName("New Release");
3554     meResXvsAlphaZpPanel2->SetMinimum(xmin);
3555     meResXvsAlphaZpPanel2->SetMaximum(xmax);
3556     meResXvsAlphaZpPanel2->Draw("e");
3557     newmeResXvsAlphaZpPanel2->Draw("esameS"); 
3558     myPV->PVCompute(meResXvsAlphaZpPanel2, newmeResXvsAlphaZpPanel2, te );
3559     h_pv->SetBinContent(++bin, myPV->getPV());
3560     gPad->Update();
3561     TPaveStats *s103 = (TPaveStats*)meResXvsAlphaZpPanel2->GetListOfFunctions()->FindObject("stats");
3562     if (s103) {
3563       s103->SetX1NDC (0.55); //new x start position
3564       s103->SetX2NDC (0.75); //new x end position
3565     }
3566     can_ResXvsAlpha->SaveAs("meResXvsAlpha_compare.eps");
3567     can_ResXvsAlpha->SaveAs("meResXvsAlpha_compare.gif");
3568   }
3569     
3570 if (1) 
3571   {
3572     TCanvas* can_ResXvsBeta = new TCanvas("can_ResXvsBeta", "can_ResXvsBeta", 1200, 800);
3573     can_ResXvsBeta->Divide(3,2);
3574     
3575     TProfile* meResXvsBetaBarrel;
3576     TProfile* meResXvsBetaZmPanel1;
3577     TProfile* meResXvsBetaZmPanel2;
3578     TProfile* meResXvsBetaZpPanel1;
3579     TProfile* meResXvsBetaZpPanel2;
3580     
3581     TProfile* newmeResXvsBetaBarrel;
3582     TProfile* newmeResXvsBetaZmPanel1;
3583     TProfile* newmeResXvsBetaZmPanel2;
3584     TProfile* newmeResXvsBetaZpPanel1;
3585     TProfile* newmeResXvsBetaZpPanel2;
3586 
3587     rdir->GetObject("Histograms_all/meResXvsBetaBarrel"  , meResXvsBetaBarrel  );
3588     rdir->GetObject("Histograms_all/meResXvsBetaZmPanel1", meResXvsBetaZmPanel1);
3589     rdir->GetObject("Histograms_all/meResXvsBetaZmPanel2", meResXvsBetaZmPanel2);
3590     rdir->GetObject("Histograms_all/meResXvsBetaZpPanel1", meResXvsBetaZpPanel1);
3591     rdir->GetObject("Histograms_all/meResXvsBetaZpPanel2", meResXvsBetaZpPanel2);
3592 
3593     sdir->GetObject("Histograms_all/meResXvsBetaBarrel"  , newmeResXvsBetaBarrel  ); 
3594     sdir->GetObject("Histograms_all/meResXvsBetaZmPanel1", newmeResXvsBetaZmPanel1);
3595     sdir->GetObject("Histograms_all/meResXvsBetaZmPanel2", newmeResXvsBetaZmPanel2);
3596     sdir->GetObject("Histograms_all/meResXvsBetaZpPanel1", newmeResXvsBetaZpPanel1);
3597     sdir->GetObject("Histograms_all/meResXvsBetaZpPanel2", newmeResXvsBetaZpPanel2);
3598   
3599     TLegend* leg21 = new TLegend(0.3, 0.2, 0.6, 0.4);
3600     can_ResXvsBeta->cd(1);
3601     //gPad->SetLogy();
3602     SetUpProfileHistograms(meResXvsBetaBarrel, newmeResXvsBetaBarrel,"barrel, |beta| (deg)", "<|x residual|> (cm)", xmin, xmax, leg21 );
3603     Float_t refMax = 1.5*meResXvsBetaBarrel->GetMaximum();
3604     Float_t newMax = 1.5*newmeResXvsBetaBarrel->GetMaximum();
3605     if refMax > newMax
3606     {
3607         meResXvsBetaBarrel->SetMaximum(refMax);
3608     }
3609     else
3610     {
3611         meResXvsBetaBarrel->SetMaximum(newMax);
3612     }      
3613     meResXvsBetaBarrel->SetName("Reference");
3614     newmeResXvsBetaBarrel->SetName("New Release");
3615     meResXvsBetaBarrel->Draw("e");
3616     newmeResXvsBetaBarrel->Draw("eSameS"); 
3617     myPV->PVCompute(meResXvsBetaBarrel, newmeResXvsBetaBarrel, te, 0.3, 0.4 );
3618     leg21->Draw();
3619     h_pv->SetBinContent(++bin, myPV->getPV());
3620     gPad->Update();
3621     TPaveStats *s104 = (TPaveStats*)meResXvsBetaBarrel->GetListOfFunctions()->FindObject("stats");
3622     if (s104) {
3623       s104->SetX1NDC (0.55); //new x start position
3624       s104->SetX2NDC (0.75); //new x end position
3625     }
3626     can_ResXvsBeta->cd(2);
3627     //gPad->SetLogy();
3628     SetUpProfileHistograms(meResXvsBetaZmPanel1, newmeResXvsBetaZmPanel1, "panel1, z<0, |beta| (deg)", "<|x residual|> (cm)", xmin, xmax );
3629     Float_t refMax = 1.5*meResXvsBetaZmPanel1->GetMaximum();
3630     Float_t newMax = 1.5*newmeResXvsBetaZmPanel1->GetMaximum();
3631     if refMax > newMax
3632     {
3633         meResXvsBetaZmPanel1->SetMaximum(refMax);
3634     }
3635     else
3636     {
3637         meResXvsBetaZmPanel1->SetMaximum(newMax);
3638     }      
3639     meResXvsBetaZmPanel1->SetName("Reference");
3640     newmeResXvsBetaZmPanel1->SetName("New Release");
3641     meResXvsBetaZmPanel1->Draw("e");
3642     newmeResXvsBetaZmPanel1->Draw("esameS"); 
3643     myPV->PVCompute(meResXvsBetaZmPanel1, newmeResXvsBetaZmPanel1, te, 0.2, 0.2 );
3644     h_pv->SetBinContent(++bin, myPV->getPV());
3645     gPad->Update();
3646     TPaveStats *s105 = (TPaveStats*)meResXvsBetaZmPanel1->GetListOfFunctions()->FindObject("stats");
3647     if (s105) {
3648       s105->SetX1NDC (0.55); //new x start position
3649       s105->SetX2NDC (0.75); //new x end position
3650     }
3651     can_ResXvsBeta->cd(3);
3652     //gPad->SetLogy();
3653     SetUpProfileHistograms(meResXvsBetaZmPanel2, newmeResXvsBetaZmPanel2, "panel2, z<0, |beta| (deg)", "<|x residual|> (cm)", xmin, xmax ); 
3654     Float_t refMax = 1.5*meResXvsBetaZmPanel2->GetMaximum();
3655     Float_t newMax = 1.5*newmeResXvsBetaZmPanel2->GetMaximum();
3656     if refMax > newMax
3657     {
3658         meResXvsBetaZmPanel2->SetMaximum(refMax);
3659     }
3660     else
3661     {
3662         meResXvsBetaZmPanel2->SetMaximum(newMax);
3663     }      
3664     meResXvsBetaZmPanel2->SetName("Reference");
3665     newmeResXvsBetaZmPanel2->SetName("New Release");
3666     meResXvsBetaZmPanel2->Draw("e");
3667     newmeResXvsBetaZmPanel2->Draw("esameS"); 
3668     myPV->PVCompute(meResXvsBetaZmPanel2, newmeResXvsBetaZmPanel2, te, 0.2, 0.2 );
3669     h_pv->SetBinContent(++bin, myPV->getPV());
3670     gPad->Update();
3671     TPaveStats *s106 = (TPaveStats*)meResXvsBetaZmPanel2->GetListOfFunctions()->FindObject("stats");
3672     if (s106) {
3673       s106->SetX1NDC (0.55); //new x start position
3674       s106->SetX2NDC (0.75); //new x end position
3675     }
3676     can_ResXvsBeta->cd(5);
3677     //gPad->SetLogy();
3678     SetUpProfileHistograms(meResXvsBetaZpPanel1, newmeResXvsBetaZpPanel1, "panel1, z>0, |beta| (deg)", "<|x residual|> (cm)", xmin, xmax );
3679     Float_t refMax = 1.5*meResXvsBetaZpPanel1->GetMaximum();
3680     Float_t newMax = 1.5*newmeResXvsBetaZpPanel1->GetMaximum();
3681     if refMax > newMax
3682     {
3683         meResXvsBetaZpPanel1->SetMaximum(refMax);
3684     }
3685     else
3686     {
3687         meResXvsBetaZpPanel1->SetMaximum(newMax);
3688     }      
3689     meResXvsBetaZpPanel1->SetName("Reference");
3690     newmeResXvsBetaZpPanel1->SetName("New Release");
3691     meResXvsBetaZpPanel1->Draw("e");
3692     newmeResXvsBetaZpPanel1->Draw("esameS"); 
3693     myPV->PVCompute(meResXvsBetaZpPanel1, newmeResXvsBetaZpPanel1, te, 0.2, 0.2 );
3694     h_pv->SetBinContent(++bin, myPV->getPV());
3695     gPad->Update();
3696     TPaveStats *s107 = (TPaveStats*)meResXvsBetaZpPanel1->GetListOfFunctions()->FindObject("stats");
3697     if (s107) {
3698       s107->SetX1NDC (0.55); //new x start position
3699       s107->SetX2NDC (0.75); //new x end position
3700     }
3701     can_ResXvsBeta->cd(6);
3702     //gPad->SetLogy();
3703     SetUpProfileHistograms(meResXvsBetaZpPanel2, newmeResXvsBetaZpPanel2, "panel2, z>0, |beta| (deg)", "<|x residual|> (cm)", xmin, xmax );
3704     Float_t refMax = 1.5*meResXvsBetaZpPanel2->GetMaximum();
3705     Float_t newMax = 1.5*newmeResXvsBetaZpPanel2->GetMaximum();
3706     if refMax > newMax
3707     {
3708         meResXvsBetaZpPanel2->SetMaximum(refMax);
3709     }
3710     else
3711     {
3712         meResXvsBetaZpPanel2->SetMaximum(newMax);
3713     }      
3714     meResXvsBetaZpPanel2->SetName("Reference");
3715     newmeResXvsBetaZpPanel2->SetName("New Release");
3716     meResXvsBetaZpPanel2->Draw("e");
3717     newmeResXvsBetaZpPanel2->Draw("esameS"); 
3718     myPV->PVCompute(meResXvsBetaZpPanel2, newmeResXvsBetaZpPanel2, te, 0.2, 0.2 );
3719     h_pv->SetBinContent(++bin, myPV->getPV());
3720     gPad->Update();
3721     TPaveStats *s108 = (TPaveStats*)meResXvsBetaZpPanel2->GetListOfFunctions()->FindObject("stats");
3722     if (s108) {
3723       s108->SetX1NDC (0.55); //new x start position
3724       s108->SetX2NDC (0.75); //new x end position
3725     }
3726     can_ResXvsBeta->SaveAs("meResXvsBeta_compare.eps");
3727     can_ResXvsBeta->SaveAs("meResXvsBeta_compare.gif");
3728   }
3729 
3730  ymin = 0.0005;
3731  ymax = 0.0030;
3732 
3733 if (1) 
3734   {
3735     TCanvas* can_ResYvsAlpha = new TCanvas("can_ResYvsAlpha", "can_ResYvsAlpha", 1200, 800);
3736     can_ResYvsAlpha->Divide(3,2);
3737     
3738     TProfile* meResYvsAlphaBarrel;
3739     TProfile* meResYvsAlphaZmPanel1;
3740     TProfile* meResYvsAlphaZmPanel2;
3741     TProfile* meResYvsAlphaZpPanel1;
3742     TProfile* meResYvsAlphaZpPanel2;
3743     
3744     TProfile* newmeResYvsAlphaBarrel;
3745     TProfile* newmeResYvsAlphaZmPanel1;
3746     TProfile* newmeResYvsAlphaZmPanel2;
3747     TProfile* newmeResYvsAlphaZpPanel1;
3748     TProfile* newmeResYvsAlphaZpPanel2;
3749 
3750     rdir->GetObject("Histograms_all/meResYvsAlphaBarrel"  , meResYvsAlphaBarrel  );
3751     rdir->GetObject("Histograms_all/meResYvsAlphaZmPanel1", meResYvsAlphaZmPanel1);
3752     rdir->GetObject("Histograms_all/meResYvsAlphaZmPanel2", meResYvsAlphaZmPanel2);
3753     rdir->GetObject("Histograms_all/meResYvsAlphaZpPanel1", meResYvsAlphaZpPanel1);
3754     rdir->GetObject("Histograms_all/meResYvsAlphaZpPanel2", meResYvsAlphaZpPanel2);
3755 
3756     sdir->GetObject("Histograms_all/meResYvsAlphaBarrel"  , newmeResYvsAlphaBarrel  ); 
3757     sdir->GetObject("Histograms_all/meResYvsAlphaZmPanel1", newmeResYvsAlphaZmPanel1);
3758     sdir->GetObject("Histograms_all/meResYvsAlphaZmPanel2", newmeResYvsAlphaZmPanel2);
3759     sdir->GetObject("Histograms_all/meResYvsAlphaZpPanel1", newmeResYvsAlphaZpPanel1);
3760     sdir->GetObject("Histograms_all/meResYvsAlphaZpPanel2", newmeResYvsAlphaZpPanel2);
3761   
3762     TLegend* leg22 = new TLegend(0.55, 0.15, 0.85, 0.35);
3763     can_ResYvsAlpha->cd(1);
3764     //gPad->SetLogy();
3765     SetUpProfileHistograms(meResYvsAlphaBarrel, newmeResYvsAlphaBarrel, "barrel, |alpha| (deg)", "<|y residual|> (cm)", ymin+0.0010, ymax+0.0010, leg22 );
3766     Float_t refMax = 1.2*meResYvsAlphaBarrel->GetMaximum();
3767     Float_t newMax = 1.2*newmeResYvsAlphaBarrel->GetMaximum();
3768     if refMax > newMax
3769     {
3770         meResYvsAlphaBarrel->SetMaximum(refMax);
3771     }
3772     else
3773     {
3774         meResYvsAlphaBarrel->SetMaximum(newMax);
3775     }      
3776     meResYvsAlphaBarrel->SetName("Reference");
3777     newmeResYvsAlphaBarrel->SetName("New Release");
3778     meResYvsAlphaBarrel->Draw("e");
3779     newmeResYvsAlphaBarrel->Draw("eSameS"); 
3780     myPV->PVCompute(meResYvsAlphaBarrel, newmeResYvsAlphaBarrel, te, 0.2, 0.2 );
3781     leg22->Draw();
3782     h_pv->SetBinContent(++bin, myPV->getPV());
3783     gPad->Update();
3784     TPaveStats *s109 = (TPaveStats*)meResYvsAlphaBarrel->GetListOfFunctions()->FindObject("stats");
3785     if (s109) {
3786       s109->SetX1NDC (0.55); //new x start position
3787       s109->SetX2NDC (0.75); //new x end position
3788     }
3789     can_ResYvsAlpha->cd(2);
3790     //gPad->SetLogy();
3791     SetUpProfileHistograms(meResYvsAlphaZmPanel1, newmeResYvsAlphaZmPanel1, "panel1, z<0, |alpha| (deg)", "<|y residual|> (cm)", ymin, ymax );
3792     Float_t refMax = 1.2*meResYvsAlphaZmPanel1->GetMaximum();
3793     Float_t newMax = 1.2*newmeResYvsAlphaZmPanel1->GetMaximum();
3794     if refMax > newMax
3795     {
3796         meResYvsAlphaZmPanel1->SetMaximum(refMax);
3797     }
3798     else
3799     {
3800         meResYvsAlphaZmPanel1->SetMaximum(newMax);
3801     }      
3802     meResYvsAlphaZmPanel1->SetName("Reference");
3803     newmeResYvsAlphaZmPanel1->SetName("New Release");
3804     meResYvsAlphaZmPanel1->Draw("e");
3805     newmeResYvsAlphaZmPanel1->Draw("esameS"); 
3806     myPV->PVCompute(meResYvsAlphaZmPanel1, newmeResYvsAlphaZmPanel1, te, 0.2, 0.2 );
3807     h_pv->SetBinContent(++bin, myPV->getPV());
3808     gPad->Update();
3809     TPaveStats *s110 = (TPaveStats*)meResYvsAlphaZmPanel1->GetListOfFunctions()->FindObject("stats");
3810     if (s110) {
3811       s110->SetX1NDC (0.55); //new x start position
3812       s110->SetX2NDC (0.75); //new x end position
3813     }
3814     can_ResYvsAlpha->cd(3);
3815     //gPad->SetLogy();
3816     SetUpProfileHistograms(meResYvsAlphaZmPanel2, newmeResYvsAlphaZmPanel2, "panel2, z<0, |alpha| (deg)", "<|y residual|> (cm)", ymin, ymax );
3817     Float_t refMax = 1.2*meResYvsAlphaZmPanel2->GetMaximum();
3818     Float_t newMax = 1.2*newmeResYvsAlphaZmPanel2->GetMaximum();
3819     if refMax > newMax
3820     {
3821         meResYvsAlphaZmPanel2->SetMaximum(refMax);
3822     }
3823     else
3824     {
3825         meResYvsAlphaZmPanel2->SetMaximum(newMax);
3826     }      
3827     meResYvsAlphaZmPanel2->SetName("Reference");
3828     newmeResYvsAlphaZmPanel2->SetName("New Release");
3829     meResYvsAlphaZmPanel2->Draw("e");
3830     newmeResYvsAlphaZmPanel2->Draw("esameS"); 
3831     myPV->PVCompute(meResYvsAlphaZmPanel2, newmeResYvsAlphaZmPanel2, te, 0.2, 0.2 );
3832     h_pv->SetBinContent(++bin, myPV->getPV());
3833     gPad->Update();
3834     TPaveStats *s111 = (TPaveStats*)meResYvsAlphaZmPanel2->GetListOfFunctions()->FindObject("stats");
3835     if (s111) {
3836       s111->SetX1NDC (0.55); //new x start position
3837       s111->SetX2NDC (0.75); //new x end position
3838     }
3839     can_ResYvsAlpha->cd(5);
3840     //gPad->SetLogy();
3841     SetUpProfileHistograms(meResYvsAlphaZpPanel1, newmeResYvsAlphaZpPanel1, "panel1, z>0, |alpha| (deg)", "<|y residual|> (cm)" , ymin, ymax);
3842     Float_t refMax = 1.2*meResYvsAlphaZpPanel1->GetMaximum();
3843     Float_t newMax = 1.2*newmeResYvsAlphaZpPanel1->GetMaximum();
3844     if refMax > newMax
3845     {
3846         meResYvsAlphaZpPanel1->SetMaximum(refMax);
3847     }
3848     else
3849     {
3850         meResYvsAlphaZpPanel1->SetMaximum(newMax);
3851     }      
3852     meResYvsAlphaZpPanel1->SetName("Reference");
3853     newmeResYvsAlphaZpPanel1->SetName("New Release");
3854     meResYvsAlphaZpPanel1->Draw("e");
3855     newmeResYvsAlphaZpPanel1->Draw("esameS"); 
3856     myPV->PVCompute(meResYvsAlphaZpPanel1, newmeResYvsAlphaZpPanel1, te, 0.2, 0.2 );
3857     h_pv->SetBinContent(++bin, myPV->getPV());
3858     gPad->Update();
3859     TPaveStats *s112 = (TPaveStats*)meResYvsAlphaZpPanel1->GetListOfFunctions()->FindObject("stats");
3860     if (s112) {
3861       s112->SetX1NDC (0.55); //new x start position
3862       s112->SetX2NDC (0.75); //new x end position
3863     }
3864     can_ResYvsAlpha->cd(6);
3865     //gPad->SetLogy();
3866     SetUpProfileHistograms(meResYvsAlphaZpPanel2, newmeResYvsAlphaZpPanel2, "panel2, z>0, |alpha| (deg)", "<|y residual|> (cm)", ymin, ymax );
3867     Float_t refMax = 1.2*meResYvsAlphaZpPanel2->GetMaximum();
3868     Float_t newMax = 1.2*newmeResYvsAlphaZpPanel2->GetMaximum();
3869     if refMax > newMax
3870     {
3871         meResYvsAlphaZpPanel2->SetMaximum(refMax);
3872     }
3873     else
3874     {
3875         meResYvsAlphaZpPanel2->SetMaximum(newMax);
3876     }      
3877     meResYvsAlphaZpPanel2->SetName("Reference");
3878     newmeResYvsAlphaZpPanel2->SetName("New Release");
3879     meResYvsAlphaZpPanel2->Draw("e");
3880     newmeResYvsAlphaZpPanel2->Draw("esameS"); 
3881     myPV->PVCompute(meResYvsAlphaZpPanel2, newmeResYvsAlphaZpPanel2, te, 0.2, 0.2 );
3882     h_pv->SetBinContent(++bin, myPV->getPV());
3883     gPad->Update();
3884     TPaveStats *s113 = (TPaveStats*)meResYvsAlphaZpPanel2->GetListOfFunctions()->FindObject("stats");
3885     if (s113) {
3886       s113->SetX1NDC (0.55); //new x start position
3887       s113->SetX2NDC (0.75); //new x end position
3888     }
3889     can_ResYvsAlpha->SaveAs("meResYvsAlpha_compare.eps");
3890     can_ResYvsAlpha->SaveAs("meResYvsAlpha_compare.gif");
3891   }
3892 
3893 if (1) 
3894   {
3895     TCanvas* can_ResYvsBeta = new TCanvas("can_ResYvsBeta", "can_ResYvsBeta", 1200, 800);
3896     can_ResYvsBeta->Divide(3,2);
3897     
3898     TProfile* meResYvsBetaBarrel;
3899     TProfile* meResYvsBetaZmPanel1;
3900     TProfile* meResYvsBetaZmPanel2;
3901     TProfile* meResYvsBetaZpPanel1;
3902     TProfile* meResYvsBetaZpPanel2;
3903     
3904     TProfile* newmeResYvsBetaBarrel;
3905     TProfile* newmeResYvsBetaZmPanel1;
3906     TProfile* newmeResYvsBetaZmPanel2;
3907     TProfile* newmeResYvsBetaZpPanel1;
3908     TProfile* newmeResYvsBetaZpPanel2;
3909 
3910     rdir->GetObject("Histograms_all/meResYvsBetaBarrel"  , meResYvsBetaBarrel  );
3911     rdir->GetObject("Histograms_all/meResYvsBetaZmPanel1", meResYvsBetaZmPanel1);
3912     rdir->GetObject("Histograms_all/meResYvsBetaZmPanel2", meResYvsBetaZmPanel2);
3913     rdir->GetObject("Histograms_all/meResYvsBetaZpPanel1", meResYvsBetaZpPanel1);
3914     rdir->GetObject("Histograms_all/meResYvsBetaZpPanel2", meResYvsBetaZpPanel2);
3915 
3916     sdir->GetObject("Histograms_all/meResYvsBetaBarrel"  , newmeResYvsBetaBarrel  ); 
3917     sdir->GetObject("Histograms_all/meResYvsBetaZmPanel1", newmeResYvsBetaZmPanel1);
3918     sdir->GetObject("Histograms_all/meResYvsBetaZmPanel2", newmeResYvsBetaZmPanel2);
3919     sdir->GetObject("Histograms_all/meResYvsBetaZpPanel1", newmeResYvsBetaZpPanel1);
3920     sdir->GetObject("Histograms_all/meResYvsBetaZpPanel2", newmeResYvsBetaZpPanel2);
3921   
3922     TLegend* leg23 = new TLegend(0.35, 0.15, 0.65, 0.3);
3923     can_ResYvsBeta->cd(1);
3924     //gPad->SetLogy();
3925     SetUpProfileHistograms(meResYvsBetaBarrel, newmeResYvsBetaBarrel, "barrel, |beta| (deg)", "<|y residual|> (cm)", 0.0000, 0.0060, leg23 );
3926     Float_t refMax = 1.5*meResYvsBetaBarrel->GetMaximum();
3927     Float_t newMax = 1.5*newmeResYvsBetaBarrel->GetMaximum();
3928     if refMax > newMax
3929     {
3930         meResYvsBetaBarrel->SetMaximum(refMax);
3931     }
3932     else
3933     {
3934         meResYvsBetaBarrel->SetMaximum(newMax);
3935     }      
3936     meResYvsBetaBarrel->SetName("Reference");
3937     newmeResYvsBetaBarrel->SetName("New Release");
3938     meResYvsBetaBarrel->Draw("e");
3939     newmeResYvsBetaBarrel->Draw("eSameS"); 
3940     myPV->PVCompute(meResYvsBetaBarrel, newmeResYvsBetaBarrel, te );
3941     leg23->Draw();
3942     h_pv->SetBinContent(++bin, myPV->getPV());
3943     gPad->Update();
3944     TPaveStats *s114 = (TPaveStats*)meResYvsBetaBarrel->GetListOfFunctions()->FindObject("stats");
3945     if (s114) {
3946       s114->SetX1NDC (0.55); //new x start position
3947       s114->SetX2NDC (0.75); //new x end position
3948     }
3949     can_ResYvsBeta->cd(2);
3950     //gPad->SetLogy();
3951     SetUpProfileHistograms(meResYvsBetaZmPanel1, newmeResYvsBetaZmPanel1, "panel1, z<0, |beta| (deg)", "<|y residual|> (cm)", ymin, ymax );
3952     Float_t refMax = 1.5*meResYvsBetaZmPanel1->GetMaximum();
3953     Float_t newMax = 1.5*newmeResYvsBetaZmPanel1->GetMaximum();
3954     if refMax > newMax
3955     {
3956         meResYvsBetaZmPanel1->SetMaximum(refMax);
3957     }
3958     else
3959     {
3960         meResYvsBetaZmPanel1->SetMaximum(newMax);
3961     }      
3962     meResYvsBetaZmPanel1->SetName("Reference");
3963     newmeResYvsBetaZmPanel1->SetName("New Release");
3964     meResYvsBetaZmPanel1->Draw("e");
3965     newmeResYvsBetaZmPanel1->Draw("esameS"); 
3966     myPV->PVCompute(meResYvsBetaZmPanel1, newmeResYvsBetaZmPanel1, te, 0.2, 0.2 );
3967     h_pv->SetBinContent(++bin, myPV->getPV());
3968     gPad->Update();
3969     TPaveStats *s115 = (TPaveStats*)meResYvsBetaZmPanel1->GetListOfFunctions()->FindObject("stats");
3970     if (s115) {
3971       s115->SetX1NDC (0.55); //new x start position
3972       s115->SetX2NDC (0.75); //new x end position
3973     }
3974     can_ResYvsBeta->cd(3);
3975     //gPad->SetLogy();
3976     SetUpProfileHistograms(meResYvsBetaZmPanel2, newmeResYvsBetaZmPanel2, "panel2, z<0, |beta| (deg)", "<|y residual|> (cm)", ymin, ymax );
3977     Float_t refMax = 1.5*meResYvsBetaZmPanel2->GetMaximum();
3978     Float_t newMax = 1.5*newmeResYvsBetaZmPanel2->GetMaximum();
3979     if refMax > newMax
3980     {
3981         meResYvsBetaZmPanel2->SetMaximum(refMax);
3982     }
3983     else
3984     {
3985         meResYvsBetaZmPanel2->SetMaximum(newMax);
3986     }      
3987     meResYvsBetaZmPanel2->SetName("Reference");
3988     newmeResYvsBetaZmPanel2->SetName("New Release");
3989     meResYvsBetaZmPanel2->Draw("e");
3990     newmeResYvsBetaZmPanel2->Draw("esameS"); 
3991     myPV->PVCompute(meResYvsBetaZmPanel2, newmeResYvsBetaZmPanel2, te, 0.2, 0.2 );
3992     h_pv->SetBinContent(++bin, myPV->getPV());
3993     gPad->Update();
3994     TPaveStats *s116 = (TPaveStats*)meResYvsBetaZmPanel2->GetListOfFunctions()->FindObject("stats");
3995     if (s116) {
3996       s116->SetX1NDC (0.55); //new x start position
3997       s116->SetX2NDC (0.75); //new x end position
3998     }
3999     can_ResYvsBeta->cd(5);
4000     //gPad->SetLogy();
4001     SetUpProfileHistograms(meResYvsBetaZpPanel1, newmeResYvsBetaZpPanel1, "panel1, z>0, |beta| (deg)", "<|y residual|> (cm)", ymin, ymax );
4002     Float_t refMax = 1.5*meResYvsBetaZpPanel1->GetMaximum();
4003     Float_t newMax = 1.5*newmeResYvsBetaZpPanel1->GetMaximum();
4004     if refMax > newMax
4005     {
4006         meResYvsBetaZpPanel1->SetMaximum(refMax);
4007     }
4008     else
4009     {
4010         meResYvsBetaZpPanel1->SetMaximum(newMax);
4011     }      
4012     meResYvsBetaZpPanel1->SetName("Reference");
4013     newmeResYvsBetaZpPanel1->SetName("New Release");
4014     meResYvsBetaZpPanel1->Draw("e");
4015     newmeResYvsBetaZpPanel1->Draw("esameS"); 
4016     myPV->PVCompute(meResYvsBetaZpPanel1, newmeResYvsBetaZpPanel1, te, 0.3, 0.7 );
4017     h_pv->SetBinContent(++bin, myPV->getPV());
4018     gPad->Update();
4019     TPaveStats *s117 = (TPaveStats*)meResYvsBetaZpPanel1->GetListOfFunctions()->FindObject("stats");
4020     if (s117) {
4021       s117->SetX1NDC (0.55); //new x start position
4022       s117->SetX2NDC (0.75); //new x end position
4023     }
4024     can_ResYvsBeta->cd(6);
4025     //gPad->SetLogy();
4026     SetUpProfileHistograms(meResYvsBetaZpPanel2, newmeResYvsBetaZpPanel2, "panel2, z>0, |beta| (deg)", "<|y residual|> (cm)", ymin, ymax );
4027     Float_t refMax = 1.5*meResYvsBetaZpPanel2->GetMaximum();
4028     Float_t newMax = 1.5*newmeResYvsBetaZpPanel2->GetMaximum();
4029     if refMax > newMax
4030     {
4031         meResYvsBetaZpPanel2->SetMaximum(refMax);
4032     }
4033     else
4034     {
4035         meResYvsBetaZpPanel2->SetMaximum(newMax);
4036     }      
4037     meResYvsBetaZpPanel2->SetName("Reference");
4038     newmeResYvsBetaZpPanel2->SetName("New Release");
4039     meResYvsBetaZpPanel2->Draw("e");
4040     newmeResYvsBetaZpPanel2->Draw("esameS"); 
4041     myPV->PVCompute(meResYvsBetaZpPanel2, newmeResYvsBetaZpPanel2, te, 0.2, 0.2 );
4042     h_pv->SetBinContent(++bin, myPV->getPV());
4043     gPad->Update();
4044     TPaveStats *s118 = (TPaveStats*)meResYvsBetaZpPanel2->GetListOfFunctions()->FindObject("stats");
4045     if (s118) {
4046       s118->SetX1NDC (0.55); //new x start position
4047       s118->SetX2NDC (0.75); //new x end position
4048     }
4049     can_ResYvsBeta->SaveAs("meResYvsBeta_compare.eps");
4050     can_ResYvsBeta->SaveAs("meResYvsBeta_compare.gif");
4051   }
4052 
4053 if (1) 
4054   {
4055     TCanvas* can_meResx = new TCanvas("can_meResx", "can_meResx", 1200, 800);
4056     can_meResx->Divide(3,2);
4057     
4058     TH1F* meResxBarrel;
4059     TH1F* meResxZmPanel1;
4060     TH1F* meResxZmPanel2;
4061     TH1F* meResxZpPanel1;
4062     TH1F* meResxZpPanel2;
4063     
4064     TH1F* newmeResxBarrel;
4065     TH1F* newmeResxZmPanel1;
4066     TH1F* newmeResxZmPanel2;
4067     TH1F* newmeResxZpPanel1;
4068     TH1F* newmeResxZpPanel2;
4069 
4070     rdir->GetObject("Histograms_all/meResxBarrel"  , meResxBarrel  );
4071     rdir->GetObject("Histograms_all/meResxZmPanel1", meResxZmPanel1);
4072     rdir->GetObject("Histograms_all/meResxZmPanel2", meResxZmPanel2);
4073     rdir->GetObject("Histograms_all/meResxZpPanel1", meResxZpPanel1);
4074     rdir->GetObject("Histograms_all/meResxZpPanel2", meResxZpPanel2);
4075 
4076     sdir->GetObject("Histograms_all/meResxBarrel"  , newmeResxBarrel  ); 
4077     sdir->GetObject("Histograms_all/meResxZmPanel1", newmeResxZmPanel1);
4078     sdir->GetObject("Histograms_all/meResxZmPanel2", newmeResxZmPanel2);
4079     sdir->GetObject("Histograms_all/meResxZpPanel1", newmeResxZpPanel1);
4080     sdir->GetObject("Histograms_all/meResxZpPanel2", newmeResxZpPanel2);
4081   
4082     TLegend* leg24 = new TLegend(0.15, 0.72, 0.42, 0.87);
4083     can_meResx->cd(1);
4084     gPad->SetLogy();
4085     SetUpHistograms(meResxBarrel, newmeResxBarrel, "barrel, x residual (cm)", leg24 );
4086     Float_t refMax = 1.2*meResxBarrel->GetMaximum();
4087     Float_t newMax = 1.2*newmeResxBarrel->GetMaximum();
4088     if refMax > newMax
4089     {
4090         meResxBarrel->SetMaximum(refMax);
4091     }
4092     else
4093     {
4094         meResxBarrel->SetMaximum(newMax);
4095     }      
4096     meResxBarrel->SetName("Reference");
4097     newmeResxBarrel->SetName("New Release");
4098     meResxBarrel->Draw("he");
4099     newmeResxBarrel->Draw("heSameS"); 
4100     myPV->PVCompute(meResxBarrel, newmeResxBarrel, te );
4101     leg24->Draw();
4102     h_pv->SetBinContent(++bin, myPV->getPV());
4103     gPad->Update();
4104     TPaveStats *s119 = (TPaveStats*)meResxBarrel->GetListOfFunctions()->FindObject("stats");
4105     if (s119) {
4106       s119->SetX1NDC (0.55); //new x start position
4107       s119->SetX2NDC (0.75); //new x end position
4108     }
4109     can_meResx->cd(2);
4110     gPad->SetLogy();
4111     SetUpHistograms(meResxZmPanel1, newmeResxZmPanel1, "panel1, z<0, x residual (cm)" );
4112     Float_t refMax = 1.2*meResxZmPanel1->GetMaximum();
4113     Float_t newMax = 1.2*newmeResxZmPanel1->GetMaximum();
4114     if refMax > newMax
4115     {
4116         meResxZmPanel1->SetMaximum(refMax);
4117     }
4118     else
4119     {
4120         meResxZmPanel1->SetMaximum(newMax);
4121     }      
4122     meResxZmPanel1->SetName("Reference");
4123     newmeResxZmPanel1->SetName("New Release");
4124     meResxZmPanel1->Draw("he");
4125     newmeResxZmPanel1->Draw("hesameS"); 
4126     myPV->PVCompute(meResxZmPanel1, newmeResxZmPanel1, te );
4127     h_pv->SetBinContent(++bin, myPV->getPV());
4128     gPad->Update();
4129     TPaveStats *s120 = (TPaveStats*)meResxZmPanel1->GetListOfFunctions()->FindObject("stats");
4130     if (s120) {
4131       s120->SetX1NDC (0.55); //new x start position
4132       s120->SetX2NDC (0.75); //new x end position
4133     }
4134     can_meResx->cd(3);
4135     gPad->SetLogy();
4136     SetUpHistograms(meResxZmPanel2,  newmeResxZmPanel2, "panel2, z<0, x residual (cm)");
4137     Float_t refMax = 1.2*meResxZmPanel2->GetMaximum();
4138     Float_t newMax = 1.2*newmeResxZmPanel2->GetMaximum();
4139     if refMax > newMax
4140     {
4141         meResxZmPanel2->SetMaximum(refMax);
4142     }
4143     else
4144     {
4145         meResxZmPanel2->SetMaximum(newMax);
4146     }      
4147     meResxZmPanel2->SetName("Reference");
4148     newmeResxZmPanel2->SetName("New Release");
4149     meResxZmPanel2->Draw("he");
4150     newmeResxZmPanel2->Draw("hesameS"); 
4151     myPV->PVCompute(meResxZmPanel2, newmeResxZmPanel2, te );
4152     h_pv->SetBinContent(++bin, myPV->getPV());
4153     gPad->Update();
4154     TPaveStats *s121 = (TPaveStats*)meResxZmPanel2->GetListOfFunctions()->FindObject("stats");
4155     if (s121) {
4156       s121->SetX1NDC (0.55); //new x start position
4157       s121->SetX2NDC (0.75); //new x end position
4158     }
4159     can_meResx->cd(5);
4160     gPad->SetLogy();
4161     SetUpHistograms(meResxZpPanel1, newmeResxZpPanel1, "panel1, z>0, x residual (cm)" );
4162     Float_t refMax = 1.2*meResxZpPanel1->GetMaximum();
4163     Float_t newMax = 1.2*newmeResxZpPanel1->GetMaximum();
4164     if refMax > newMax
4165     {
4166         meResxZpPanel1->SetMaximum(refMax);
4167     }
4168     else
4169     {
4170         meResxZpPanel1->SetMaximum(newMax);
4171     }      
4172     meResxZpPanel1->SetName("Reference");
4173     newmeResxZpPanel1->SetName("New Release");
4174     meResxZpPanel1->Draw("he");
4175     newmeResxZpPanel1->Draw("hesameS"); 
4176     myPV->PVCompute(meResxZpPanel1, newmeResxZpPanel1, te );
4177     h_pv->SetBinContent(++bin, myPV->getPV());
4178     gPad->Update();
4179     TPaveStats *s122 = (TPaveStats*)meResxZpPanel1->GetListOfFunctions()->FindObject("stats");
4180     if (s122) {
4181       s122->SetX1NDC (0.55); //new x start position
4182       s122->SetX2NDC (0.75); //new x end position
4183     }
4184     can_meResx->cd(6);
4185     gPad->SetLogy();
4186     SetUpHistograms(meResxZpPanel2, newmeResxZpPanel2, "panel2, z>0, x residual (cm)" );
4187     Float_t refMax = 1.2*meResxZpPanel2->GetMaximum();
4188     Float_t newMax = 1.2*newmeResxZpPanel2->GetMaximum();
4189     if refMax > newMax
4190     {
4191         meResxZpPanel2->SetMaximum(refMax);
4192     }
4193     else
4194     {
4195         meResxZpPanel2->SetMaximum(newMax);
4196     }      
4197     meResxZpPanel2->SetName("Reference");
4198     newmeResxZpPanel2->SetName("New Release");
4199     meResxZpPanel2->Draw("he");
4200     newmeResxZpPanel2->Draw("hesameS"); 
4201     myPV->PVCompute(meResxZpPanel2, newmeResxZpPanel2, te );
4202     h_pv->SetBinContent(++bin, myPV->getPV());
4203     gPad->Update();
4204     TPaveStats *s123 = (TPaveStats*)meResxZpPanel2->GetListOfFunctions()->FindObject("stats");
4205     if (s123) {
4206       s123->SetX1NDC (0.55); //new x start position
4207       s123->SetX2NDC (0.75); //new x end position
4208     }
4209     can_meResx->SaveAs("meResx_compare.eps");
4210     can_meResx->SaveAs("meResx_compare.gif");
4211   }
4212 
4213  if (1) 
4214   {
4215     TCanvas* can_meResy = new TCanvas("can_meResy", "can_meResy", 1200, 800);
4216     can_meResy->Divide(3,2);
4217     
4218     TH1F* meResyBarrel;
4219     TH1F* meResyZmPanel1;
4220     TH1F* meResyZmPanel2;
4221     TH1F* meResyZpPanel1;
4222     TH1F* meResyZpPanel2;
4223     
4224     TH1F* newmeResyBarrel;
4225     TH1F* newmeResyZmPanel1;
4226     TH1F* newmeResyZmPanel2;
4227     TH1F* newmeResyZpPanel1;
4228     TH1F* newmeResyZpPanel2;
4229 
4230     rdir->GetObject("Histograms_all/meResyBarrel"  , meResyBarrel  );
4231     rdir->GetObject("Histograms_all/meResyZmPanel1", meResyZmPanel1);
4232     rdir->GetObject("Histograms_all/meResyZmPanel2", meResyZmPanel2);
4233     rdir->GetObject("Histograms_all/meResyZpPanel1", meResyZpPanel1);
4234     rdir->GetObject("Histograms_all/meResyZpPanel2", meResyZpPanel2);
4235 
4236     sdir->GetObject("Histograms_all/meResyBarrel"  , newmeResyBarrel  ); 
4237     sdir->GetObject("Histograms_all/meResyZmPanel1", newmeResyZmPanel1);
4238     sdir->GetObject("Histograms_all/meResyZmPanel2", newmeResyZmPanel2);
4239     sdir->GetObject("Histograms_all/meResyZpPanel1", newmeResyZpPanel1);
4240     sdir->GetObject("Histograms_all/meResyZpPanel2", newmeResyZpPanel2);
4241   
4242     TLegend* leg25 = new TLegend(0.15, 0.72, 0.42, 0.87);
4243     can_meResy->cd(1);
4244     gPad->SetLogy();
4245     SetUpHistograms(meResyBarrel, newmeResyBarrel, "barrel, y residual (cm)", leg25 );
4246     Float_t refMax = 1.2*meResyBarrel->GetMaximum();
4247     Float_t newMax = 1.2*newmeResyBarrel->GetMaximum();
4248     if refMax > newMax
4249     {
4250         meResyBarrel->SetMaximum(refMax);
4251     }
4252     else
4253     {
4254         meResyBarrel->SetMaximum(newMax);
4255     }      
4256     meResyBarrel->SetName("Reference");
4257     newmeResyBarrel->SetName("New Release");
4258     meResyBarrel->Draw("he");
4259     newmeResyBarrel->Draw("heSameS"); 
4260     myPV->PVCompute(meResyBarrel, newmeResyBarrel, te );
4261     leg25->Draw();
4262     h_pv->SetBinContent(++bin, myPV->getPV());
4263     gPad->Update();
4264     TPaveStats *s124 = (TPaveStats*)meResyBarrel->GetListOfFunctions()->FindObject("stats");
4265     if (s124) {
4266       s124->SetX1NDC (0.55); //new x start position
4267       s124->SetX2NDC (0.75); //new x end position
4268     }
4269     can_meResy->cd(2);
4270     gPad->SetLogy();
4271     SetUpHistograms(meResyZmPanel1, newmeResyZmPanel1, "panel1, z<0, y residual (cm)" );
4272     Float_t refMax = 1.2*meResyZmPanel1->GetMaximum();
4273     Float_t newMax = 1.2*newmeResyZmPanel1->GetMaximum();
4274     if refMax > newMax
4275     {
4276         meResyZmPanel1->SetMaximum(refMax);
4277     }
4278     else
4279     {
4280         meResyZmPanel1->SetMaximum(newMax);
4281     }      
4282     meResyZmPanel1->SetName("Reference");
4283     newmeResyZmPanel1->SetName("New Release");
4284     meResyZmPanel1->Draw("he");
4285     newmeResyZmPanel1->Draw("hesameS"); 
4286     myPV->PVCompute(meResyZmPanel1, newmeResyZmPanel1, te );
4287     h_pv->SetBinContent(++bin, myPV->getPV());
4288     gPad->Update();
4289     TPaveStats *s125 = (TPaveStats*)meResyZmPanel1->GetListOfFunctions()->FindObject("stats");
4290     if (s125) {
4291       s125->SetX1NDC (0.55); //new x start position
4292       s125->SetX2NDC (0.75); //new x end position
4293     }
4294     can_meResy->cd(3);
4295     gPad->SetLogy();
4296     SetUpHistograms(meResyZmPanel2, newmeResyZmPanel2, "panel2, z<0, y residual (cm) " );
4297     Float_t refMax = 1.2*meResyZmPanel2->GetMaximum();
4298     Float_t newMax = 1.2*newmeResyZmPanel2->GetMaximum();
4299     if refMax > newMax
4300     {
4301         meResyZmPanel2->SetMaximum(refMax);
4302     }
4303     else
4304     {
4305         meResyZmPanel2->SetMaximum(newMax);
4306     }      
4307     meResyZmPanel2->SetName("Reference");
4308     newmeResyZmPanel2->SetName("New Release");
4309     meResyZmPanel2->Draw("he");
4310     newmeResyZmPanel2->Draw("hesameS"); 
4311     myPV->PVCompute(meResyZmPanel2, newmeResyZmPanel2, te );
4312     h_pv->SetBinContent(++bin, myPV->getPV());
4313     gPad->Update();
4314     TPaveStats *s126 = (TPaveStats*)meResyZmPanel2->GetListOfFunctions()->FindObject("stats");
4315     if (s126) {
4316       s126->SetX1NDC (0.55); //new x start position
4317       s126->SetX2NDC (0.75); //new x end position
4318     }
4319     can_meResy->cd(5);
4320     gPad->SetLogy();
4321     SetUpHistograms(meResyZpPanel1, newmeResyZpPanel1, "panel1, z>0, y residual (cm)" );
4322     Float_t refMax = 1.2*meResyZpPanel1->GetMaximum();
4323     Float_t newMax = 1.2*newmeResyZpPanel1->GetMaximum();
4324     if refMax > newMax
4325     {
4326         meResyZpPanel1->SetMaximum(refMax);
4327     }
4328     else
4329     {
4330         meResyZpPanel1->SetMaximum(newMax);
4331     }      
4332     meResyZpPanel1->SetName("Reference");
4333     newmeResyZpPanel1->SetName("New Release");
4334     meResyZpPanel1->Draw("he");
4335     newmeResyZpPanel1->Draw("hesameS"); 
4336     myPV->PVCompute(meResyZpPanel1, newmeResyZpPanel1, te );
4337     h_pv->SetBinContent(++bin, myPV->getPV());
4338     gPad->Update();
4339     TPaveStats *s127 = (TPaveStats*)meResyZpPanel1->GetListOfFunctions()->FindObject("stats");
4340     if (s127) {
4341       s127->SetX1NDC (0.55); //new x start position
4342       s127->SetX2NDC (0.75); //new x end position
4343     }
4344     can_meResy->cd(6);
4345     gPad->SetLogy();
4346     SetUpHistograms(meResyZpPanel2, newmeResyZpPanel2, "panel2, z>0, y residual (cm)" );
4347     Float_t refMax = 1.2*meResyZpPanel2->GetMaximum();
4348     Float_t newMax = 1.2*newmeResyZpPanel2->GetMaximum();
4349     if refMax > newMax
4350     {
4351         meResyZpPanel2->SetMaximum(refMax);
4352     }
4353     else
4354     {
4355         meResyZpPanel2->SetMaximum(newMax);
4356     }      
4357     meResyZpPanel2->SetName("Reference");
4358     newmeResyZpPanel2->SetName("New Release");
4359     meResyZpPanel2->Draw("he");
4360     newmeResyZpPanel2->Draw("hesameS"); 
4361     myPV->PVCompute(meResyZpPanel2, newmeResyZpPanel2, te );
4362     h_pv->SetBinContent(++bin, myPV->getPV());
4363     gPad->Update();
4364     TPaveStats *s128 = (TPaveStats*)meResyZpPanel2->GetListOfFunctions()->FindObject("stats");
4365     if (s128) {
4366       s128->SetX1NDC (0.55); //new x start position
4367       s128->SetX2NDC (0.75); //new x end position
4368     }
4369     can_meResy->SaveAs("meResy_compare.eps");
4370     can_meResy->SaveAs("meResy_compare.gif");
4371   }
4372 
4373  // Look at the charge distribution on each module 
4374 
4375  rfile->cd("Histograms_per_ring-layer_or_disk-plaquette");
4376  sfile->cd("Histograms_per_ring-layer_or_disk-plaquette");
4377  
4378  Char_t histo[200];
4379 
4380  TCanvas* can_meChargeRingLayer = new TCanvas("can_meChargeRingLayer", "can_meChargeRingLayer", 1200, 800);
4381  can_meChargeRingLayer->Divide(8,3);
4382  
4383  TH1F* meChargeLayerModule[3][8]; 
4384  TH1F* newmeChargeLayerModule[3][8];
4385  
4386  for (Int_t i=0; i<3; i++) // loop ovel layers
4387    for (Int_t j=0; j<8; j++) // loop ovel rings
4388      {
4389        sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meChargeBarrelLayerModule_%d_%d", 
4390            i+1, j+1);
4391        rdir->GetObject(histo, meChargeLayerModule[i][j]);
4392 
4393        sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meChargeBarrelLayerModule_%d_%d", 
4394            i+1, j+1);
4395        sdir->GetObject(histo, newmeChargeLayerModule[i][j]); 
4396        SetUpHistograms(meChargeLayerModule[i][j], newmeChargeLayerModule[i][j], "barrel, charge (elec)" );
4397        can_meChargeRingLayer->cd(8*i + j + 1);
4398        //gPad->SetLogy();
4399        Float_t refMax = 1.2*meChargeLayerModule[i][j]->GetMaximum();
4400        Float_t newMax = 1.2*newmeChargeLayerModule[i][j]->GetMaximum();
4401        if refMax > newMax
4402        {
4403            meChargeLayerModule[i][j]->SetMaximum(refMax);
4404        }
4405        else
4406        {
4407            meChargeLayerModule[i][j]->SetMaximum(newMax);
4408        }      
4409        meChargeLayerModule[i][j]->SetName("Reference");
4410        newmeChargeLayerModule[i][j]->SetName("New Release");
4411        meChargeLayerModule[i][j]->Draw("he");
4412        newmeChargeLayerModule[i][j]->Draw("hesameS"); 
4413        myPV->PVCompute(meChargeLayerModule[i][j], newmeChargeLayerModule[i][j], te );
4414        h_pv->SetBinContent(++bin, myPV->getPV());
4415        gPad->Update();
4416        TPaveStats *s129 = (TPaveStats*)meChargeLayerModule[i][j]->GetListOfFunctions()->FindObject("stats");
4417        if (s129) {
4418      s129->SetX1NDC (0.55); //new x start position
4419      s129->SetX2NDC (0.75); //new x end position
4420        }
4421      }
4422  TLegend* leg26 = new TLegend(0.45, 0.45, 0.75, 0.65);
4423  leg26->SetBorderSize(0);
4424  leg26->AddEntry(   meChargeLayerModule[0][0], "reference  ", "l");
4425  leg26->AddEntry(newmeChargeLayerModule[0][0], "new release", "l");
4426  leg26->Draw();
4427 
4428  can_meChargeRingLayer->SaveAs("meChargeBarrelLayerModule_compare.eps");
4429  can_meChargeRingLayer->SaveAs("meChargeBarrelLayerModule_compare.gif");
4430 
4431 
4432  TCanvas* can_meChargeZmPanel1DiskPlaq = new TCanvas("can_meChargeZmPanel1DiskPlaq", "can_meChargeZmPanel1DiskPlaq", 600, 800);
4433  can_meChargeZmPanel1DiskPlaq->Divide(2,4);
4434  
4435  TH1F* meChargeZmPanel1DiskPlaq[2][4];
4436  TH1F* newmeChargeZmPanel1DiskPlaq[2][4];
4437 
4438  for (Int_t i=0; i<2; i++) // loop over disks
4439    for (Int_t j=0; j<4; j++) // loop over plaquetes
4440      {
4441        sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meChargeZmPanel1DiskPlaq_%d_%d", i+1, j+1);
4442        rdir->GetObject(histo, meChargeZmPanel1DiskPlaq[i][j]);
4443        sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meChargeZmPanel1DiskPlaq_%d_%d", i+1, j+1);
4444        sdir->GetObject(histo, newmeChargeZmPanel1DiskPlaq[i][j]); 
4445        
4446        can_meChargeZmPanel1DiskPlaq->cd(4*i + j + 1);
4447        //gPad->SetLogy();
4448        SetUpHistograms(meChargeZmPanel1DiskPlaq[i][j], newmeChargeZmPanel1DiskPlaq[i][j], "panel1, z<0, charge (elec)" );
4449        Float_t refMax = 1.2*meChargeZmPanel1DiskPlaq[i][j]->GetMaximum();
4450        Float_t newMax = 1.2*newmeChargeZmPanel1DiskPlaq[i][j]->GetMaximum();
4451        if refMax > newMax
4452        {
4453            meChargeZmPanel1DiskPlaq[i][j]->SetMaximum(refMax);
4454        }
4455        else
4456        {
4457            meChargeZmPanel1DiskPlaq[i][j]->SetMaximum(newMax);
4458        }      
4459        meChargeZmPanel1DiskPlaq[i][j]->SetName("Reference");
4460        newmeChargeZmPanel1DiskPlaq[i][j]->SetName("New Release");
4461        meChargeZmPanel1DiskPlaq[i][j]->Draw("he");
4462        newmeChargeZmPanel1DiskPlaq[i][j]->Draw("hesameS"); 
4463        myPV->PVCompute(meChargeZmPanel1DiskPlaq[i][j], newmeChargeZmPanel1DiskPlaq[i][j], te );
4464        h_pv->SetBinContent(++bin, myPV->getPV());
4465        gPad->Update();
4466        TPaveStats *s130 = (TPaveStats*)meChargeZmPanel1DiskPlaq[i][j]->GetListOfFunctions()->FindObject("stats");
4467        if (s130) {
4468      s130->SetX1NDC (0.55); //new x start position
4469      s130->SetX2NDC (0.75); //new x end position
4470        }
4471      }
4472  TLegend* leg27 = new TLegend(0.5, 0.4, 0.8, 0.6);
4473  leg27->SetBorderSize(0);
4474  leg27->AddEntry(   meChargeZmPanel1DiskPlaq[0][0], "reference  ", "l");
4475  leg27->AddEntry(newmeChargeZmPanel1DiskPlaq[0][0], "new release", "l");
4476  leg27->Draw();
4477  
4478  can_meChargeZmPanel1DiskPlaq->SaveAs("meChargeZmPanel1DiskPlaq_compare.eps");
4479  can_meChargeZmPanel1DiskPlaq->SaveAs("meChargeZmPanel1DiskPlaq_compare.gif");
4480 
4481 
4482  TCanvas* can_meChargeZmPanel2DiskPlaq = new TCanvas("can_meChargeZmPanel2DiskPlaq", "can_meChargeZmPanel2DiskPlaq", 600, 800);
4483  can_meChargeZmPanel2DiskPlaq->Divide(2,3);
4484  
4485  TH1F* meChargeZmPanel2DiskPlaq[2][3];
4486  TH1F* newmeChargeZmPanel2DiskPlaq[2][3];
4487  
4488  for (Int_t i=0; i<2; i++) // loop ovel disks
4489    for (Int_t j=0; j<3; j++) // loop ovel plaguetes
4490      {
4491        sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meChargeZmPanel2DiskPlaq_%d_%d", i+1, j+1);
4492        rdir->GetObject(histo, meChargeZmPanel2DiskPlaq[i][j]);
4493        sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meChargeZmPanel2DiskPlaq_%d_%d", i+1, j+1);
4494        sdir->GetObject(histo, newmeChargeZmPanel2DiskPlaq[i][j]); 
4495        
4496        can_meChargeZmPanel2DiskPlaq->cd(3*i + j + 1);
4497        //gPad->SetLogy();
4498        SetUpHistograms(meChargeZmPanel2DiskPlaq[i][j], newmeChargeZmPanel2DiskPlaq[i][j], "panel2, z<0, charge (elec)" );
4499        Float_t refMax = 1.2*meChargeZmPanel2DiskPlaq[i][j]->GetMaximum();
4500        Float_t newMax = 1.2*newmeChargeZmPanel2DiskPlaq[i][j]->GetMaximum();
4501        if refMax > newMax
4502        {
4503            meChargeZmPanel2DiskPlaq[i][j]->SetMaximum(refMax);
4504        }
4505        else
4506        {
4507            meChargeZmPanel2DiskPlaq[i][j]->SetMaximum(newMax);
4508        }      
4509        meChargeZmPanel2DiskPlaq[i][j]->SetName("Reference");
4510        newmeChargeZmPanel2DiskPlaq[i][j]->SetName("New Release");
4511        meChargeZmPanel2DiskPlaq[i][j]->Draw("he");
4512        newmeChargeZmPanel2DiskPlaq[i][j]->Draw("hesameS"); 
4513        myPV->PVCompute(meChargeZmPanel2DiskPlaq[i][j], newmeChargeZmPanel2DiskPlaq[i][j], te );
4514        h_pv->SetBinContent(++bin, myPV->getPV());
4515        gPad->Update();
4516        TPaveStats *s131 = (TPaveStats*)meChargeZmPanel2DiskPlaq[i][j]->GetListOfFunctions()->FindObject("stats");
4517        if (s131) {
4518      s131->SetX1NDC (0.55); //new x start position
4519      s131->SetX2NDC (0.75); //new x end position
4520        }
4521      }
4522  TLegend* leg28 = new TLegend(0.5, 0.4, 0.8, 0.6);
4523  leg28->SetBorderSize(0);
4524  leg28->AddEntry(   meChargeZmPanel2DiskPlaq[0][0], "reference  ", "l");
4525  leg28->AddEntry(newmeChargeZmPanel2DiskPlaq[0][0], "new release", "l");
4526  leg28->Draw();
4527 
4528  can_meChargeZmPanel2DiskPlaq->SaveAs("meChargeZmPanel2DiskPlaq_compare.eps");
4529  can_meChargeZmPanel2DiskPlaq->SaveAs("meChargeZmPanel2DiskPlaq_compare.gif");
4530 
4531 
4532  TCanvas* can_meChargeZpPanel1DiskPlaq = new TCanvas("can_meChargeZpPanel1DiskPlaq", "can_meChargeZpPanel1DiskPlaq", 600, 800);
4533  can_meChargeZpPanel1DiskPlaq->Divide(2,4);
4534  
4535  TH1F* meChargeZpPanel1DiskPlaq[2][4];
4536  TH1F* newmeChargeZpPanel1DiskPlaq[2][4];
4537  
4538  for (Int_t i=0; i<2; i++) // loop ovel disks
4539    for (Int_t j=0; j<4; j++) // loop ovel plaguetes
4540      {
4541        sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meChargeZpPanel1DiskPlaq_%d_%d", i+1, j+1);
4542        rdir->GetObject(histo, meChargeZpPanel1DiskPlaq[i][j]);
4543        sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meChargeZpPanel1DiskPlaq_%d_%d", i+1, j+1);
4544        sdir->GetObject(histo, newmeChargeZpPanel1DiskPlaq[i][j]); 
4545        
4546        can_meChargeZpPanel1DiskPlaq->cd(4*i + j + 1);
4547        //gPad->SetLogy();
4548        SetUpHistograms(meChargeZpPanel1DiskPlaq[i][j], newmeChargeZpPanel1DiskPlaq[i][j], "panel1, z>0, charge (elec)");
4549        Float_t refMax = 1.2*meChargeZpPanel1DiskPlaq[i][j]->GetMaximum();
4550        Float_t newMax = 1.2*newmeChargeZpPanel1DiskPlaq[i][j]->GetMaximum();
4551        if refMax > newMax
4552        {
4553            meChargeZpPanel1DiskPlaq[i][j]->SetMaximum(refMax);
4554        }
4555        else
4556        {
4557            meChargeZpPanel1DiskPlaq[i][j]->SetMaximum(newMax);
4558        }      
4559        meChargeZpPanel1DiskPlaq[i][j]->SetName("Reference");
4560        newmeChargeZpPanel1DiskPlaq[i][j]->SetName("New Release");
4561        meChargeZpPanel1DiskPlaq[i][j]->Draw("he");
4562        newmeChargeZpPanel1DiskPlaq[i][j]->Draw("hesameS"); 
4563        myPV->PVCompute(meChargeZpPanel1DiskPlaq[i][j], newmeChargeZpPanel1DiskPlaq[i][j], te );
4564        h_pv->SetBinContent(++bin, myPV->getPV());
4565        gPad->Update();
4566        TPaveStats *s132 = (TPaveStats*)meChargeZpPanel1DiskPlaq[i][j]->GetListOfFunctions()->FindObject("stats");
4567        if (s132) {
4568      s132->SetX1NDC (0.55); //new x start position
4569      s132->SetX2NDC (0.75); //new x end position
4570        }
4571      }
4572  TLegend* leg29 = new TLegend(0.5, 0.4, 0.8, 0.6);
4573  leg29->SetBorderSize(0);
4574  leg29->AddEntry(   meChargeZmPanel1DiskPlaq[0][0], "reference  ", "l");
4575  leg29->AddEntry(newmeChargeZmPanel1DiskPlaq[0][0], "new release", "l");
4576  leg29->Draw();
4577  
4578  can_meChargeZpPanel1DiskPlaq->SaveAs("meChargeZpPanel1DiskPlaq_compare.eps");
4579  can_meChargeZpPanel1DiskPlaq->SaveAs("meChargeZpPanel1DiskPlaq_compare.gif");
4580 
4581 
4582  TCanvas* can_meChargeZpPanel2DiskPlaq = new TCanvas("can_meChargeZpPanel2DiskPlaq", "can_meChargeZpPanel2DiskPlaq", 600, 800);
4583  can_meChargeZpPanel2DiskPlaq->Divide(2,3);
4584  
4585  TH1F* meChargeZpPanel2DiskPlaq[2][3];
4586  TH1F* newmeChargeZpPanel2DiskPlaq[2][3];
4587   
4588  for (Int_t i=0; i<2; i++) // loop ovel disks
4589    for (Int_t j=0; j<3; j++) // loop ovel plaguetes
4590      {
4591        sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meChargeZpPanel2DiskPlaq_%d_%d", i+1, j+1);
4592        rdir->GetObject(histo, meChargeZpPanel2DiskPlaq[i][j]);
4593        sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meChargeZpPanel2DiskPlaq_%d_%d", i+1, j+1);
4594        sdir->GetObject(histo, newmeChargeZpPanel2DiskPlaq[i][j]); 
4595        
4596        can_meChargeZpPanel2DiskPlaq->cd(3*i + j + 1);
4597        //gPad->SetLogy();
4598        SetUpHistograms(meChargeZpPanel2DiskPlaq[i][j], newmeChargeZpPanel2DiskPlaq[i][j], "panel2, z>0, charge (elec)" );
4599        Float_t refMax = 1.2*meChargeZpPanel2DiskPlaq[i][j]->GetMaximum();
4600        Float_t newMax = 1.2*newmeChargeZpPanel2DiskPlaq[i][j]->GetMaximum();
4601        if refMax > newMax
4602        {
4603            meChargeZpPanel2DiskPlaq[i][j]->SetMaximum(refMax);
4604        }
4605        else
4606        {
4607            meChargeZpPanel2DiskPlaq[i][j]->SetMaximum(newMax);
4608        }      
4609        meChargeZpPanel2DiskPlaq[i][j]->SetName("Reference");
4610        newmeChargeZpPanel2DiskPlaq[i][j]->SetName("New Release");
4611        meChargeZpPanel2DiskPlaq[i][j]->Draw("he");
4612        newmeChargeZpPanel2DiskPlaq[i][j]->Draw("hesameS"); 
4613        myPV->PVCompute(meChargeZpPanel2DiskPlaq[i][j], newmeChargeZpPanel2DiskPlaq[i][j], te );
4614        h_pv->SetBinContent(++bin, myPV->getPV());
4615        gPad->Update();
4616        TPaveStats *s133 = (TPaveStats*)meChargeZpPanel2DiskPlaq[i][j]->GetListOfFunctions()->FindObject("stats");
4617        if (s133) {
4618      s133->SetX1NDC (0.55); //new x start position
4619      s133->SetX2NDC (0.75); //new x end position
4620        }
4621      }
4622  TLegend* leg30 = new TLegend(0.5, 0.4, 0.8, 0.6);
4623  leg30->SetBorderSize(0);
4624  leg30->AddEntry(   meChargeZmPanel2DiskPlaq[0][0], "reference  ", "l");
4625  leg30->AddEntry(newmeChargeZmPanel2DiskPlaq[0][0], "new release", "l");
4626  leg30->Draw();
4627 
4628  can_meChargeZpPanel2DiskPlaq->SaveAs("meChargeZpPanel2DiskPlaq_compare.eps");
4629  can_meChargeZpPanel2DiskPlaq->SaveAs("meChargeZpPanel2DiskPlaq_compare.gif");
4630 
4631 
4632  TCanvas* can_meResLayers = new TCanvas("can_meResLayers", "can_meResLayers", 1200, 800);
4633  can_meResLayers->Divide(3,2);
4634  
4635  TH1F* meResxBarrelLayer[3];
4636  TH1F* newmeResxBarrelLayer[3];
4637   
4638  Char_t xtitle[100];
4639 
4640  for (Int_t i=0; i<3; i++) // loop layers
4641    {
4642      sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meResxBarrelLayer_%d", i+1);
4643      rdir->GetObject(histo, meResxBarrelLayer[i]);
4644      sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meResxBarrelLayer_%d", i+1);
4645      sdir->GetObject(histo, newmeResxBarrelLayer[i]); 
4646      
4647      can_meResLayers->cd(i+1);
4648      gPad->SetLogy();
4649      sprintf(xtitle, "barrel, layer %d, res x", i+1);
4650      SetUpHistograms(meResxBarrelLayer[i], newmeResxBarrelLayer[i], xtitle );
4651      Float_t refMax = 1.2*meResxBarrelLayer[i]->GetMaximum();
4652      Float_t newMax = 1.2*newmeResxBarrelLayer[i]->GetMaximum();
4653      if refMax > newMax
4654      {
4655          meResxBarrelLayer[i]->SetMaximum(refMax);
4656      }
4657      else
4658      {
4659          meResxBarrelLayer[i]->SetMaximum(newMax);
4660      }      
4661      meResxBarrelLayer[i]->SetName("Reference");
4662      newmeResxBarrelLayer[i]->SetName("New Release");
4663      meResxBarrelLayer[i]->Draw("he");
4664      newmeResxBarrelLayer[i]->Draw("hesameS"); 
4665      myPV->PVCompute(meResxBarrelLayer[i], newmeResxBarrelLayer[i], te );
4666      h_pv->SetBinContent(++bin, myPV->getPV());
4667      gPad->Update();
4668      TPaveStats *s134 = (TPaveStats*)meResxBarrelLayer[i]->GetListOfFunctions()->FindObject("stats");
4669      if (s134) {
4670        s134->SetX1NDC (0.55); //new x start position
4671        s134->SetX2NDC (0.75); //new x end position
4672      }
4673    }
4674  TLegend* leg31 = new TLegend(0.15, 0.65, 0.45, 0.85);
4675  leg31->SetBorderSize(0);
4676  leg31->AddEntry(   meResxBarrelLayer[0], "reference  ", "l");
4677  leg31->AddEntry(newmeResxBarrelLayer[0], "new release", "l");
4678  leg31->Draw();
4679 
4680  TH1F* meResyBarrelLayer[3];
4681  TH1F* newmeResyBarrelLayer[3];
4682   
4683  for (Int_t i=0; i<3; i++) // loop layers
4684    {
4685      sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meResyBarrelLayer_%d", i+1);
4686      rdir->GetObject(histo, meResyBarrelLayer[i]);
4687      sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/meResyBarrelLayer_%d", i+1);
4688      sdir->GetObject(histo, newmeResyBarrelLayer[i]); 
4689        
4690      can_meResLayers->cd(3+i+1);
4691      gPad->SetLogy();
4692      sprintf(xtitle, "barrel, layer %d, res y", i+1);
4693      SetUpHistograms(meResyBarrelLayer[i], newmeResyBarrelLayer[i], xtitle );
4694      Float_t refMax = 1.2*meResyBarrelLayer[i]->GetMaximum();
4695      Float_t newMax = 1.2*newmeResyBarrelLayer[i]->GetMaximum();
4696      if refMax > newMax
4697      {
4698          meResyBarrelLayer[i]->SetMaximum(refMax);
4699      }
4700      else
4701      {
4702          meResyBarrelLayer[i]->SetMaximum(newMax);
4703      }      
4704      meResyBarrelLayer[i]->SetName("Reference");
4705      newmeResyBarrelLayer[i]->SetName("New Release");
4706      meResyBarrelLayer[i]->Draw("he");
4707      newmeResyBarrelLayer[i]->Draw("hesameS"); 
4708      myPV->PVCompute(meResyBarrelLayer[i], newmeResyBarrelLayer[i], te );
4709      h_pv->SetBinContent(++bin, myPV->getPV());
4710      gPad->Update();
4711      TPaveStats *s135 = (TPaveStats*)meResyBarrelLayer[i]->GetListOfFunctions()->FindObject("stats");
4712      if (s135) {
4713        s135->SetX1NDC (0.55); //new x start position
4714        s135->SetX2NDC (0.75); //new x end position
4715      }
4716    }
4717  
4718  can_meResLayers->SaveAs("meResBarrelLayers_compare.eps");
4719  can_meResLayers->SaveAs("meResBarrelLayers_compare.gif");
4720 
4721 
4722 
4723  TCanvas* can_mePullLayers = new TCanvas("can_mePullLayers", "can_mePullLayers", 1200, 800);
4724  can_mePullLayers->Divide(3,2);
4725  
4726  TH1F* mePullxBarrelLayer[3];
4727  TH1F* newmePullxBarrelLayer[3];
4728   
4729  Char_t xtitle[100];
4730 
4731  for (Int_t i=0; i<3; i++) // loop layers
4732    {
4733      sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/mePullxBarrelLayer_%d", i+1);
4734      rdir->GetObject(histo, mePullxBarrelLayer[i]);
4735      sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/mePullxBarrelLayer_%d", i+1);
4736      sdir->GetObject(histo, newmePullxBarrelLayer[i]); 
4737      
4738      can_mePullLayers->cd(i+1);
4739      //gPad->SetLogy();
4740      sprintf(xtitle, "barrel, layer %d, pull x", i+1);
4741      SetUpHistograms(mePullxBarrelLayer[i], newmePullxBarrelLayer[i], xtitle );
4742      Float_t refMax = 1.2*mePullxBarrelLayer[i]->GetMaximum();
4743      Float_t newMax = 1.2*newmePullxBarrelLayer[i]->GetMaximum();
4744      if refMax > newMax
4745      {
4746          mePullxBarrelLayer[i]->SetMaximum(refMax);
4747      }
4748      else
4749      {
4750          mePullxBarrelLayer[i]->SetMaximum(newMax);
4751      }      
4752      mePullxBarrelLayer[i]->SetName("Reference");
4753      newmePullxBarrelLayer[i]->SetName("New Release");
4754      mePullxBarrelLayer[i]->Draw("he");
4755      newmePullxBarrelLayer[i]->Draw("hesameS"); 
4756      myPV->PVCompute(mePullxBarrelLayer[i], newmePullxBarrelLayer[i], te );
4757      h_pv->SetBinContent(++bin, myPV->getPV());
4758      gPad->Update();
4759      TPaveStats *s136 = (TPaveStats*)mePullxBarrelLayer[i]->GetListOfFunctions()->FindObject("stats");
4760      if (s136) {
4761        s136->SetX1NDC (0.55); //new x start position
4762        s136->SetX2NDC (0.75); //new x end position
4763      }
4764    }
4765  TLegend* leg32 = new TLegend(0.15, 0.65, 0.45, 0.85);
4766  leg32->SetBorderSize(0);
4767  leg32->AddEntry(   mePullxBarrelLayer[0], "reference  ", "l");
4768  leg32->AddEntry(newmePullxBarrelLayer[0], "new release", "l");
4769  leg32->Draw();
4770 
4771  TH1F* mePullyBarrelLayer[3];
4772  TH1F* newmePullyBarrelLayer[3];
4773   
4774  for (Int_t i=0; i<3; i++) // loop layers
4775    {
4776      sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/mePullyBarrelLayer_%d", i+1);
4777      rdir->GetObject(histo, mePullyBarrelLayer[i]);
4778      sprintf(histo, "Histograms_per_ring-layer_or_disk-plaquette/mePullyBarrelLayer_%d", i+1);
4779      sdir->GetObject(histo, newmePullyBarrelLayer[i]); 
4780        
4781      can_mePullLayers->cd(3+i+1);
4782      //gPad->SetLogy();
4783      sprintf(xtitle, "barrel, layer %d, pull y", i+1);
4784      SetUpHistograms(mePullyBarrelLayer[i], newmePullyBarrelLayer[i], xtitle );
4785      Float_t refMax = 1.2*mePullyBarrelLayer[i]->GetMaximum();
4786      Float_t newMax = 1.2*newmePullyBarrelLayer[i]->GetMaximum();
4787      if refMax > newMax
4788      {
4789          mePullyBarrelLayer[i]->SetMaximum(refMax);
4790      }
4791      else
4792      {
4793          mePullyBarrelLayer[i]->SetMaximum(newMax);
4794      }      
4795      mePullyBarrelLayer[i]->SetName("Reference");
4796      newmePullyBarrelLayer[i]->SetName("New Release");
4797      mePullyBarrelLayer[i]->Draw("he");
4798      newmePullyBarrelLayer[i]->Draw("hesameS"); 
4799      myPV->PVCompute(mePullyBarrelLayer[i], newmePullyBarrelLayer[i], te );
4800      h_pv->SetBinContent(++bin, myPV->getPV());
4801      gPad->Update();
4802      TPaveStats *s137 = (TPaveStats*)mePullyBarrelLayer[i]->GetListOfFunctions()->FindObject("stats");
4803      if (s137) {
4804        s137->SetX1NDC (0.55); //new x start position
4805        s137->SetX2NDC (0.75); //new x end position
4806      }
4807    }
4808  
4809  can_mePullLayers->SaveAs("mePullBarrelLayers_compare.eps");
4810  can_mePullLayers->SaveAs("mePullBarrelLayers_compare.gif");
4811 
4812 
4813  
4814  TCanvas* can_pv = new TCanvas("can_pv", "can_mepv", 1200, 500);
4815  gPad->SetLogy();
4816  h_pv->SetXTitle("histogram number");
4817  h_pv->SetYTitle("Probability");
4818  h_pv->SetTitleOffset(0.7, "Y");
4819  h_pv->Draw();
4820 
4821  can_pv->SaveAs("summary_pv.eps");
4822  can_pv->SaveAs("summary_pv.gif");
4823 
4824  if ( n_bins != bin )
4825    cout << "   We have " << bin << " histograms but " << n_bins << " bins in the probability summary plots. " << endl 
4826     << "   Please update n_bins to equal " << bin << "." << " Thank you !" << endl; 
4827  
4828  delete myPV;
4829 
4830 }
4831