Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:38

0001 #include <sstream>
0002 #include <TObjArray.h>
0003 #include <string>
0004 
0005 using namespace std;
0006 
0007 TH1F * DivideHistos
0008  ( TFile * f,
0009    TH1 * h_proto,
0010    const TString & num_name,
0011    const TString & denom_name )
0012  {
0013   TH1F * h_num = (TH1F *)f->Get(num_name) ;
0014   TH1F * h_denom = (TH1F *)f->Get(denom_name) ;
0015 //  std::cout
0016 //   <<"DIVIDING "<<num_name<<" ("<<h_num->GetEntries()<<" entries)"
0017 //   <<" by "<<denom_name<<" ("<<h_denom->GetEntries()<<" entries)"
0018 //   <<std::endl ;
0019   TH1F * h_res = (TH1F*)h_proto->Clone();
0020   h_res->Divide(h_num,h_denom,1,1,"b") ;
0021 //  h_res->GetXaxis()->SetTitle(h_proto->GetXaxis()->GetTitle()) ;
0022 //  h_res->GetYaxis()->SetTitle(h_proto->GetYaxis()->GetTitle()) ;
0023 ////  h_res->SetName(h_proto->GetName()) ;
0024 //  h_res->SetTitle(h_proto->GetTitle()) ;
0025   return h_res ;
0026  }
0027 
0028 // ( const TObjArray * tokens, TString & common ) // const with ROOT5
0029 void Join
0030  ( TObjArray * tokens, TString & common )
0031  {
0032   tokens->Compress() ; // if const is used with TObjArray, must be commented with ROOT6
0033   if (tokens->GetEntries()==0)
0034    { common = "" ; return ; }
0035   else
0036    { common = ((TObjString *)(tokens->At(0)))->GetString() ; }
0037   if (tokens->GetEntries()==1)
0038    { return ; }
0039   TObjString * token_obj ;
0040   Int_t token, max_token = tokens->GetEntries() ;
0041   for ( token=1 ; token<max_token ; ++token )
0042    {
0043     common += "_" ;
0044     token_obj = (TObjString *)(tokens->At(token)) ;
0045     common += token_obj->GetString() ;
0046    }
0047  }
0048 
0049 void CompareHistoNames
0050  ( const TString & h1_name,
0051    const TString & h2_name,
0052    TString &  common,
0053    TString &  h1_specific,
0054    TString &  h2_specific )
0055  {
0056   TObjArray * h1_tokens = h1_name.Tokenize("_") ;
0057   TObjArray * h2_tokens = h2_name.Tokenize("_") ;
0058   TObjArray * common_tokens = new TObjArray ;
0059   Int_t h1_nb_tokens = h1_tokens->GetEntries() ;
0060   Int_t h2_nb_tokens = h2_tokens->GetEntries() ;
0061   Int_t token, max_token = (h1_nb_tokens<h2_nb_tokens?h1_nb_tokens:h2_nb_tokens) ;
0062   for ( token=0 ; token<max_token ; ++token )
0063    {
0064     if (h1_tokens->At(token)->IsEqual(h2_tokens->At(token))==kFALSE) break ;
0065     common_tokens->Add(h1_tokens->At(token)) ;
0066     h1_tokens->RemoveAt(token) ;
0067     h2_tokens->RemoveAt(token) ;
0068    }
0069   Join(common_tokens,common) ;
0070   Join(h1_tokens,h1_specific) ;
0071   Join(h2_tokens,h2_specific) ;
0072  }
0073 
0074 void RenderHisto( TObject * obj, TCanvas * canvas )
0075  {
0076   assert(obj->InheritsFrom("TH1")) ;
0077   TH1 * histo = dynamic_cast<TH1*>(obj) ;
0078   assert(histo) ;
0079 
0080   TString histo_option = ((TH1 *)obj)->GetOption() ;
0081   if ((histo_option.Contains("ELE_LOGY")==kTRUE)&&(histo->GetMaximum()>0))
0082    { canvas->SetLogy(1) ; }
0083 
0084   int histo_name_flag = 1 ; // use 0 to switch off
0085   if ( obj->InheritsFrom("TH2") )
0086    {
0087     gStyle->SetPalette(1) ;
0088     gStyle->SetOptStat(110+histo_name_flag) ;
0089    }
0090   else if ( obj->InheritsFrom("TProfile") )
0091    { gStyle->SetOptStat(110+histo_name_flag) ; }
0092   else // TH1
0093    { gStyle->SetOptStat(111110+histo_name_flag) ; }
0094  }
0095 
0096 
0097 int electronCompare()
0098  {
0099   TString CMP_DIR          = gSystem->Getenv( "CMP_DIR"          ) ;
0100   TString CMP_URL          = gSystem->Getenv( "CMP_URL"          ) ;
0101   TString CMP_TITLE        = gSystem->Getenv( "CMP_TITLE"        ) ;
0102   TString CMP_RED_FILE     = gSystem->Getenv( "CMP_RED_FILE"     ) ;
0103   TString CMP_BLUE_FILE    = gSystem->Getenv( "CMP_BLUE_FILE"    ) ;
0104   TString CMP_RED_NAME     = gSystem->Getenv( "CMP_RED_NAME"     ) ;
0105   TString CMP_BLUE_NAME    = gSystem->Getenv( "CMP_BLUE_NAME"    ) ;
0106   TString CMP_RED_COMMENT  = gSystem->Getenv( "CMP_RED_COMMENT"  ) ;
0107   TString CMP_BLUE_COMMENT = gSystem->Getenv( "CMP_BLUE_COMMENT" ) ;
0108   TString CMP_CONFIG       = gSystem->Getenv( "CMP_CONFIG"       ) ;
0109   TString CMP_RED_RELEASE  = gSystem->Getenv( "CMP_RED_RELEASE"  ) ;
0110   TString CMP_BLUE_RELEASE = gSystem->Getenv( "CMP_BLUE_RELEASE" ) ;
0111 
0112 //-----
0113 // AC
0114 //  std::cout << "red_file : C : " << CMP_RED_FILE << std::endl;
0115 //  std::cout << "blue_file : C : " << CMP_BLUE_FILE << std::endl;
0116   std::cout << "red_release : C : " << CMP_RED_RELEASE << std::endl;
0117   std::cout << "blue_release : C : " << CMP_BLUE_RELEASE << std::endl;
0118   std::cout << "CMP_RED_NAME : " << CMP_RED_NAME << std::endl;
0119   std::cout << "CMP_BLUE_NAME : " << CMP_BLUE_NAME << std::endl;
0120 //-----
0121   
0122 // style:
0123   TStyle *eleStyle = new TStyle("eleStyle","Style for electron validation");
0124   eleStyle->SetCanvasBorderMode(0);
0125   eleStyle->SetCanvasColor(kWhite);
0126   eleStyle->SetCanvasDefH(600);
0127   eleStyle->SetCanvasDefW(800);
0128   eleStyle->SetCanvasDefX(0);
0129   eleStyle->SetCanvasDefY(0);
0130   eleStyle->SetPadBorderMode(0);
0131   eleStyle->SetPadColor(kWhite);
0132   eleStyle->SetPadGridX(false);
0133   eleStyle->SetPadGridY(false);
0134   eleStyle->SetGridColor(0);
0135   eleStyle->SetGridStyle(3);
0136   eleStyle->SetGridWidth(1);
0137   eleStyle->SetOptStat(1);
0138   eleStyle->SetPadTickX(1);
0139   eleStyle->SetPadTickY(1);
0140   eleStyle->SetHistLineColor(1);
0141   eleStyle->SetHistLineStyle(0);
0142   eleStyle->SetHistLineWidth(2);
0143   eleStyle->SetEndErrorSize(2);
0144   eleStyle->SetErrorX(0.);
0145   eleStyle->SetOptStat(1);
0146   eleStyle->SetTitleColor(1, "XYZ");
0147   eleStyle->SetTitleFont(42, "XYZ");
0148   eleStyle->SetTitleXOffset(1.0);
0149   eleStyle->SetTitleYOffset(1.0);
0150   eleStyle->SetLabelOffset(0.005, "XYZ");
0151   eleStyle->SetTitleSize(0.05, "XYZ");
0152   eleStyle->SetTitleFont(22,"X");
0153   eleStyle->SetTitleFont(22,"Y");
0154   eleStyle->SetHistLineWidth(2);
0155   eleStyle->SetPadBottomMargin(0.13);
0156   eleStyle->SetPadLeftMargin(0.15);
0157   eleStyle->SetMarkerStyle(21);
0158   eleStyle->SetMarkerSize(0.8);
0159   //-- AC --
0160   eleStyle->SetPadRightMargin(0.2) ; 
0161 
0162   eleStyle->cd();
0163 
0164   gROOT->ForceStyle();
0165 
0166   TString internal_path("DQMData/Run 1/EgammaV/Run summary/") ;
0167   TString old_internal_path("DQMData/EgammaV/") ;
0168 //  TString new_internal_path("DQMData/Run 1/EgammaV/Run summary/") ;
0169 
0170   TString file_ref_dir ;
0171   TFile * file_ref = 0 ;
0172   if ( CMP_BLUE_FILE != "" )
0173    {
0174     file_ref = TFile::Open(CMP_BLUE_FILE) ;
0175     if (file_ref!=0)
0176      {
0177       std::cout<<"open ref : "<<CMP_BLUE_FILE<<std::endl ;
0178       if (file_ref->cd(internal_path)==kTRUE)
0179        {
0180         std::cerr<<"cd "<<internal_path<<std::endl ;
0181         file_ref_dir = internal_path ;
0182         file_ref->cd() ;
0183        }
0184       else if (file_ref->cd(old_internal_path)==kTRUE)
0185        {
0186         std::cerr<<"cd "<<old_internal_path<<std::endl ;
0187         file_ref_dir = old_internal_path ;
0188         file_ref->cd() ;
0189        }
0190       else
0191        {
0192         std::cerr<<"Failed move to: "<<internal_path<<" and "<<old_internal_path<<std::endl ;
0193         file_ref_dir = "" ;
0194        }
0195      }
0196     else
0197      { std::cerr<<"Failed to open: "<<CMP_BLUE_FILE<<std::endl ; }
0198    }
0199 
0200   TString file_new_dir = internal_path  ;
0201   TFile * file_new = 0 ;
0202   if ( CMP_RED_FILE != "" )
0203    {
0204     file_new = TFile::Open(CMP_RED_FILE) ;
0205     if (file_new!=0)
0206      {
0207       std::cout<<"open new : "<<CMP_RED_FILE<<std::endl ;
0208       if (file_new->cd(internal_path)==kTRUE)
0209        {
0210         std::cerr<<"cd "<<internal_path<<std::endl ;
0211         file_new_dir = internal_path ;
0212         file_new->cd() ;
0213        }
0214       else if (file_new->cd(old_internal_path)==kTRUE)
0215        {
0216         std::cerr<<"cd "<<old_internal_path<<std::endl ;
0217         file_new_dir = old_internal_path ;
0218         file_new->cd() ;
0219        }
0220       else
0221        {
0222         std::cerr<<"Failed move to: "<<internal_path<<" and "<<old_internal_path<<std::endl ;
0223         file_new_dir = "" ;
0224        }
0225      }
0226     else
0227      { std::cerr<<"Failed to open: "<<CMP_RED_FILE<<std::endl ; }
0228    }
0229 
0230   TCanvas * canvas ;
0231   TH1 * histo_ref, * histo_new ;
0232   TPaveStats * st_ref, * st_new ;
0233 
0234   std::ofstream web_page(CMP_DIR+"/index.html") ;
0235 
0236   web_page
0237     <<"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n"
0238     <<"<html>\n"
0239     <<"<head>\n"
0240     <<"<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />\n"
0241     <<"<title>"<<CMP_TITLE<<"</title>\n"
0242     <<"</head>\n"
0243     <<"<h1><a href=\"../\"><img border=0 width=\"22\" height=\"22\" src=\"../../../../img/up.gif\" alt=\"Up\"/></a>&nbsp;"<<CMP_TITLE<<"</h1>\n" ;
0244 
0245   if (file_ref==0)
0246    {
0247     web_page
0248      <<"<p>In all plots below"
0249      <<", there was no reference histograms to compare with"
0250      <<", and the "<<CMP_RED_NAME<<" histograms are in red." ;
0251    }
0252   else
0253    {
0254 /*    web_page
0255      <<"<p>In all plots below"
0256      <<", the "<<CMP_RED_NAME<<" histograms are in red"
0257      <<", and the "<<CMP_BLUE_NAME<<" histograms are in blue." ;*/
0258     web_page
0259      <<"<p>In all plots below"
0260      <<", the <b><font color='red'>"<<CMP_RED_RELEASE<<"</font></b> histograms are in red"
0261      <<", and the <b><font color='blue'>"<<CMP_BLUE_RELEASE<<"</font></b> histograms are in blue." ;
0262 /*  std::cout <<"<p>In all plots below "
0263      <<", the "<<CMP_RED_RELEASE<<" histograms are in red"
0264      <<", and the "<<CMP_BLUE_RELEASE<<" histograms are in blue." << std::endl ;*/
0265    }
0266 
0267   std::ifstream red_comment_file(CMP_RED_COMMENT) ;
0268   std::string red_comment ;
0269   std::getline(red_comment_file,red_comment) ;
0270   red_comment_file.close() ;
0271 
0272   std::ifstream blue_comment_file(CMP_BLUE_COMMENT) ;
0273   std::string blue_comment ;
0274   std::getline(blue_comment_file,blue_comment) ;
0275   blue_comment_file.close() ;
0276 
0277   web_page<<" "<<red_comment<<" "<<blue_comment
0278     <<" Some more details"
0279     <<": <a href=\"electronCompare.C\">script</a> used to make the plots"
0280     <<", <a href=\""<<CMP_CONFIG<<"\">specification</a> of histograms"
0281     <<", <a href=\"gifs/\">images</a> of histograms"
0282     <<"." ;
0283   web_page<<"</p>\n" ;
0284 
0285   // canvas_name std::string => TString
0286   TString canvas_name, histo_name, histo_name_recomp, histo_full_path, gif_name, gif_path ;
0287   TString Pt1000_path_extension ; Pt1000_path_extension = "ElectronMcSignalValidator/" ; // needed for comparison between new >= 740pre8 and old < 740pre8 for Pt1000
0288   TString histo_full_path_Pt1000 ;
0289   TString short_histo_name ;
0290   TString first_short_histo_name, first_histo_name ;
0291   TString dl_short_histo_name, dl_histo_name ;
0292   TString num_ref, denom_ref, num_full, denom_full ;
0293   Int_t n_ele_charge ;
0294   int scaled, err ;
0295   int divide;
0296   std::string cat, line, histo_path, num, denom ;
0297   int eol ; // end of line
0298   int eoc ; // enf of category
0299   double rescale_factor = 0. ;
0300 
0301   std::ifstream histo_file1(CMP_CONFIG) ;
0302 
0303   web_page
0304     <<"<br><table border=\"1\" cellpadding=\"5\" width=\"100%\">"
0305     <<"<tr valign=\"top\"><td width=\"20%\">\n" ;
0306   int cat_num = 0 ;
0307 
0308   cat = "" ;
0309   do
0310    {
0311     std::getline(histo_file1,cat) ;
0312    } while (cat.find_first_not_of(" \t")==std::string::npos) ;
0313 
0314   web_page<<"<b>"<<cat<<"</b><br><br>" ;
0315 
0316   while (std::getline(histo_file1,line))
0317    {
0318     if (line.empty()) continue ;
0319     std::size_t first = line.find_first_not_of(" \t") ;
0320     if (first==std::string::npos) continue ;
0321     if (line[first]=='#') continue ;
0322 
0323     std::istringstream linestream(line) ;
0324     divide = 0 ; num = denom = "" ;
0325     linestream >> histo_path >> scaled >> err >> eol >> eoc >> divide >> num >> denom ;
0326 
0327     histo_name = histo_path ;
0328     Ssiz_t pos = histo_name.Last('/') ;
0329     if (pos!=kNPOS) histo_name.Remove(0,pos+1) ;
0330     short_histo_name = histo_name ;
0331     short_histo_name.Remove(0,2) ;
0332     if (short_histo_name.BeginsWith("ele_"))
0333      { short_histo_name.Remove(0,4) ; }
0334 
0335     if (first_histo_name.IsNull())
0336      {
0337       first_short_histo_name = short_histo_name ;
0338       first_histo_name = histo_name ;
0339       dl_short_histo_name = short_histo_name ;
0340       dl_histo_name = histo_name ;
0341      }
0342     else
0343      {
0344       TString common ;
0345       TString first_specific ;
0346       TString second_specific ;
0347       CompareHistoNames(first_short_histo_name,short_histo_name,common,first_specific,second_specific) ;
0348       if (!dl_histo_name.IsNull())
0349        {
0350         if (first_specific.IsNull())
0351          { web_page<<"<a href=\"#"<<first_histo_name<<"\">"<<first_short_histo_name<<"</a>" ; }
0352         else
0353          { web_page<<common<<"&nbsp;|&nbsp;<a href=\"#"<<first_histo_name<<"\">"<<first_specific<<"</a>" ; }
0354         dl_short_histo_name = dl_histo_name = "" ;
0355        }
0356       web_page<<"&nbsp;|&nbsp;<a href=\"#"<<histo_name<<"\">"<<second_specific<<"</a>" ;
0357      }
0358 
0359     if ((eol)||(eoc))
0360      {
0361       if (!dl_histo_name.IsNull())
0362        { web_page<<"<a href=\"#"<<dl_histo_name<<"\">"<<dl_short_histo_name<<"</a>" ; }
0363       web_page<<"<br>\n" ;
0364       first_histo_name = first_short_histo_name = "" ;
0365      }
0366 
0367     if (eoc)
0368      {
0369       cat_num++ ;
0370       if ((cat_num%5)==0)
0371        { web_page<<"<br></td></tr>\n<tr valign=\"top\"><td width=\"20%\">" ; }
0372       else
0373        { web_page<<"<br></td><td width=\"20%\">\n" ; }
0374       cat = "" ;
0375       do
0376        {
0377         std::getline(histo_file1,cat) ;
0378        } while (cat.find_first_not_of(" \t")==std::string::npos) ;
0379       web_page<<"<b>"<<cat<<"</b><br><br>" ;
0380      }
0381    }
0382   web_page<<"<br></td></tr></table>\n" ;
0383   histo_file1.close() ;
0384 
0385   web_page<<"<br><br><table cellpadding=\"5\"><tr valign=\"top\"><td><a href=\""<<CMP_URL<<"/\"><img width=\"18\" height=\"18\" border=\"0\" align=\"middle\" src=\"../../../../img/up.gif\" alt=\"Top\"/></a></td><td>\n" ;
0386   std::ifstream histo_file2(CMP_CONFIG) ;
0387 
0388   n_ele_charge = 0 ;
0389   cat = "" ;
0390   do
0391    {
0392     std::getline(histo_file2,cat) ;
0393    } while (cat.empty()) ;
0394 
0395   while (std::getline(histo_file2,line))
0396    {
0397     if (line.empty()) continue ;
0398     std::size_t first = line.find_first_not_of(" \t") ;
0399     if (first==std::string::npos) continue ;
0400     if (line[first]=='#') continue ;
0401 
0402 //    std::istrstream linestream(line) ;
0403 //    istringstream linestream(line) ;
0404     std::basic_istringstream<char> linestream(line) ;
0405     divide = 0 ; num = denom = "" ;
0406     linestream >> histo_path >> scaled >> err >> eol >> eoc >> divide >> num >> denom ;
0407 
0408     histo_name = histo_path.c_str() ;
0409     histo_name_recomp = histo_name ;
0410     histo_ref = 0 ;
0411     histo_new = 0 ;
0412     st_ref = 0 ;
0413     st_new = 0 ;
0414 
0415     Ssiz_t pos = histo_name.Last('/') ;
0416     if (pos!=kNPOS) histo_name.Remove(0,pos+1) ;
0417     short_histo_name = histo_name ;
0418     short_histo_name.Remove(0,2) ;
0419 
0420     gif_name = "gifs/" ; gif_name += histo_name ; gif_name += ".gif" ;
0421     gif_path = CMP_DIR ; gif_path += "/" ; gif_path += gif_name ;
0422     canvas_name = "c" ; canvas_name += histo_name ;
0423     canvas = new TCanvas(canvas_name) ;
0424     canvas->SetFillColor(10) ;
0425 
0426     web_page<<"<a id=\""<<histo_name<<"\" name=\""<<short_histo_name<<"\"></a>" ;
0427 
0428     if (strstr(short_histo_name, "_recomp") != NULL) { // then we have to compare new histo recomp with new histo
0429         Ssiz_t pos2 = histo_name_recomp.Index("_recomp");
0430         histo_name_recomp.Remove(pos2,7) ;
0431         histo_full_path = file_new_dir ; histo_full_path += histo_name_recomp ;
0432         histo_ref = (TH1 *)file_new->Get(histo_full_path) ;
0433         std::cout << "histo ref : " << histo_full_path << std::endl;
0434     }
0435     else { // then we have to compare new histo with ref histo
0436 
0437         // search histo_ref
0438         if ( file_ref != 0 ) {
0439             TString histo_reduced_path = histo_path.c_str();
0440             if (file_ref_dir.IsNull()) {
0441                 histo_full_path = histo_name ; /*std::cout << "file_ref_dir.IsNull()" << std::endl ;*/ 
0442             }
0443             else { 
0444                 if (histo_reduced_path.BeginsWith("ElectronMcSignalValidatorMiniAOD"))
0445                 { 
0446                     histo_reduced_path.Remove(25,7); /*std::cout << "OK !!" << histo_reduced_path << std::endl;*/ 
0447                     histo_full_path = file_ref_dir ; histo_full_path += histo_reduced_path ; /*std::cout << "file_ref_dir.NotNull()" << std::endl ;*/ 
0448                 }
0449                 else {
0450                     histo_full_path = file_ref_dir ; histo_full_path += histo_path.c_str() ; /*std::cout << "file_ref_dir.NotNull()" << std::endl ;*/ 
0451                 }
0452             }
0453             std::cout << "histo ref : " << histo_full_path << std::endl;
0454  
0455             // WARNING
0456             // the line below have to be unmasked if the reference release is prior to 740pre8 and for Pt1000
0457             // before 740pre8 : DQMData/Run 1/EgammaV/Run summary/ ElectronMcSignalValidator/ histo name (same as Pt35, Pt10, ....)
0458             // after 740pre8  : DQMData/Run 1/EgammaV/Run summary/ ElectronMcSignalValidatorPt1000/ histo name
0459             histo_full_path_Pt1000 = file_ref_dir ; histo_full_path_Pt1000 += Pt1000_path_extension; histo_full_path_Pt1000 += histo_name ; // for Pt1000 
0460             // END WARNING
0461 
0462             histo_ref = (TH1 *)file_ref->Get(histo_full_path) ;
0463 
0464             if (histo_ref!=0) {
0465             // renaming those histograms avoid very strange bugs because they
0466             // have the same names as the ones loaded from the new file
0467                 histo_ref->SetName(TString(histo_ref->GetName())+"_ref") ;
0468             }
0469             else { // no histo
0470                 histo_ref = (TH1 *)file_ref->Get(histo_full_path_Pt1000) ;
0471                 if (histo_ref!=0) {
0472                     // renaming those histograms avoid very strange bugs because they
0473                     // have the same names as the ones loaded from the new file
0474                     histo_ref->SetName(TString(histo_ref->GetName())+"_ref") ;
0475                 }
0476                 else {
0477                     web_page<<"No <b>"<<histo_path<<"</b> for "<<CMP_BLUE_NAME<<".<br>" ;
0478                 }
0479             }
0480         }
0481    }
0482 
0483    // search histo_new
0484     histo_full_path = file_new_dir ; histo_full_path += histo_path.c_str() ;
0485     std::cout <<  "histo new : " << histo_full_path << std::endl;
0486     histo_new = (TH1 *)file_new->Get(histo_full_path) ;
0487 
0488     // special treatments
0489     if ((scaled==1)&&(histo_new!=0)&&(histo_ref!=0)&&(histo_ref->GetEntries()!=0))
0490      {
0491       Int_t new_entries = histo_new->GetEntries() ;
0492       if (new_entries==0) { new_entries = n_ele_charge ; }
0493       if (new_entries==0)
0494        { std::cerr<<"DO NOT KNOW HOW TO RESCALE "<<histo_name<<std::endl ; }
0495       else
0496        {
0497         // we want to reuse the rescale factor of the first histogram
0498         // for all the subsequent histograms.
0499         if (rescale_factor==0.) { rescale_factor = new_entries/histo_ref->GetEntries() ; }
0500         histo_ref->Scale(rescale_factor) ;
0501        }
0502      }
0503     if ((histo_new!=0)&&(histo_ref!=0)&&(histo_ref->GetMaximum()>histo_new->GetMaximum()))
0504      { histo_new->SetMaximum(histo_ref->GetMaximum()*1.1) ; }
0505 
0506     if (histo_new==0)
0507      {
0508       web_page<<"No <b>"<<histo_path<<"</b> for "<<CMP_RED_NAME<<".<br>" ;
0509      }
0510     else
0511      {
0512       // catch n_ele_charge
0513       if (histo_name=="h_ele_charge")
0514        { n_ele_charge = histo_new->GetEntries() ; }
0515 
0516       // draw histo_new
0517       TString newDrawOptions(err==1?"E1 P":"hist") ;
0518       gErrorIgnoreLevel = kWarning ;
0519       if (divide!=0)
0520        {
0521         num_full = file_new_dir ; num_full += num.c_str() ;
0522         denom_full = file_new_dir ; denom_full += denom.c_str() ;
0523         histo_new = DivideHistos(file_new,histo_new,num_full,denom_full) ;
0524        }
0525       histo_new->SetLineColor(kRed) ;
0526       histo_new->SetMarkerColor(2) ;
0527       histo_new->SetLineWidth(3) ;
0528       RenderHisto(histo_new,canvas) ;
0529       histo_new->Draw(newDrawOptions) ;
0530 //    std::cout << "SIZE : " << canvas->GetWw() << std::endl ; // 796 default
0531 //    std::cout << "SIZE : " << canvas->GetWh() << std::endl ; // 572 default
0532       canvas->SetCanvasSize(960, 600);
0533       canvas->Update() ;
0534       st_new = (TPaveStats*)histo_new->FindObject("stats");
0535       st_new->SetTextColor(kRed) ;
0536 
0537       // draw histo_ref
0538       if (histo_ref!=0)
0539        {
0540         if (divide!=0)
0541          {
0542           num_ref = num ;
0543           denom_ref = denom ;
0544           if (file_ref_dir.IsNull())
0545            {
0546             pos = num_ref.Last('/') ;
0547             if (pos!=kNPOS) num_ref.Remove(0,pos+1) ;
0548             pos = denom_ref.Last('/') ;
0549             if (pos!=kNPOS) denom_ref.Remove(0,pos+1) ;
0550            }
0551           histo_ref = DivideHistos(file_ref,histo_ref,file_ref_dir+num_ref,file_ref_dir+denom_ref) ;
0552          }
0553         RenderHisto(histo_ref,canvas) ;
0554         histo_ref->SetLineColor(kBlue) ;
0555         histo_ref->SetLineWidth(3) ;
0556         histo_ref->Draw("sames hist") ;
0557         canvas->Update() ;
0558         st_ref = (TPaveStats*)histo_ref->FindObject("stats");
0559         st_ref->SetTextColor(kBlue) ;
0560         Double_t y1 = st_ref->GetY1NDC() ;
0561         Double_t y2 = st_ref->GetY2NDC() ;
0562         st_ref->SetY1NDC(2*y1-y2) ;
0563         st_ref->SetY2NDC(y1) ;
0564         //Double_t x1 = st_ref->GetX1NDC() ;
0565         //Double_t x2 = st_ref->GetX2NDC() ;
0566         //std::cout << "position s x1 = " << x1 << std::endl ; // 0.78 par defaut
0567         //std::cout << "position s x2 = " << x2 << std::endl ; // 0.98 par defaut
0568         //std::cout << "position s y1 = " << y1 << std::endl ; // 0.755 ou 0.835 par defaut
0569         //std::cout << "position s y2 = " << y2 << std::endl ; // 0.995 par defaut
0570        }
0571 
0572       // Redraws
0573       newDrawOptions = "sames " ;
0574       newDrawOptions += (err==1?"E1 P":"hist") ;
0575       histo_new->Draw(newDrawOptions) ;
0576       if (st_ref!=0) st_ref->Draw() ;
0577       if (st_new!=0) st_new->Draw() ;
0578 
0579       // eventual log scale
0580       //if ( (log==1) && ( (histo_new->GetEntries()>0) || ( (histo_ref!=0) && (histo_ref->GetEntries()!=0) ) ) )
0581       // { canvas->SetLogy(1) ; }
0582 
0583 
0584 // ne pas oublier de decommenter les 4 lignes suivantes
0585 
0586 //      std::cout << "histo_new get Min : " << histo_new->GetMinimum() << " - histo_new get Max : " << histo_new->GetMaximum() << std::endl ; // 
0587 //      std::cout << histo_name << " getEffectiveEntries : " << histo_new->GetEffectiveEntries() << std::endl ;
0588 /*      std::cout << histo_name << " GetMean : " << histo_new->GetMean() << std::endl ;*/
0589       std::cout<<histo_name
0590         <<" has "<<histo_new->GetEffectiveEntries()<<" entries"
0591 //        <<" of mean value "<<histo_new->GetMean()
0592         <<std::endl ; 
0593       canvas->SaveAs(gif_path.Data()) ;
0594       web_page<<"<a href=\""<<gif_name<<"\"><img border=\"0\" class=\"image\" width=\"440\" src=\""<<gif_name<<"\"></a><br>" ;
0595      }
0596 
0597 //    else if ((file_ref!=0)&&(histo_ref!=0))
0598 //     {
0599 //      std::cout<<histo_path<<" NOT FOUND"<<std::endl ;
0600 //      web_page<<"<br>(no such histo)" ;
0601 //      canvas->SaveAs(gif_path.Data()) ;
0602 //      web_page<<"<a href=\""<<gif_name<<"\"><img border=\"0\" class=\"image\" width=\"440\" src=\""<<gif_name<<"\"></a><br>" ;
0603 //     }
0604 
0605     if (eol)
0606      { web_page<<"</td></tr>\n<tr valign=\"top\"><td><a href=\""<<CMP_URL<<"/\"><img width=\"18\" height=\"18\" border=\"0\" align=\"middle\" src=\"../../../../img/up.gif\" alt=\"Top\"/></a></td><td>" ; }
0607     else
0608      { web_page<<"</td><td>" ; }
0609     if (eoc)
0610      {
0611       cat = "" ;
0612       do
0613        {
0614         std::getline(histo_file2,cat) ;
0615        } while (cat.empty()) ;
0616      }
0617    }
0618 //  std::cout << "on ferme le fichier : " << histo_file2 << std::endl;
0619   histo_file2.close() ;
0620   web_page<<"</td></tr></table>\n" ;
0621 
0622   web_page<<"\n</html>"<<std::endl ;
0623   std::cout << "on ferme la page" << std::endl;
0624   web_page.close() ;
0625   std::cout << "page fermee" << std::endl;
0626 return 0;
0627 
0628  }