CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CompHist.cc
Go to the documentation of this file.
4 
5 
6 using namespace std;
7 
8 void
9 CompHist::readLabels(std::string s, std::vector<std::string>& vec)
10 {
11  //-----------------------------------------------
12  // fill vector of std::string's from a single
13  // std::string s; the process starts as soon as
14  // leading " are found and starts a new substr
15  // as soon as a "; is encountered
16  //-----------------------------------------------
17  std::stringstream stream( s );
18  std::string buffer, label;
19  while (!stream.eof()) {
20  stream >> buffer;
21  if(buffer.find("\"", 0)==0){
22  //start new label if leading " are found
23  label=buffer;
24  }
25  else{
26  //concatenate buffer to label else
27  label+=" ";
28  label+=buffer;
29  }
30 
31  //push_back label if it starts with " and ends with ";
32  if(buffer.find("\"", buffer.size()-2)==buffer.size()-2 &&
33  buffer.find(";", buffer.size()-2)==buffer.size()-1){
34  vec.push_back( label.substr(1, label.size()-3) );
35  }
36  }
37 }
38 
39 void
41 {
42  //-----------------------------------------------
43  // read all configurables defined in CompHisto-
44  // grams from config file. Throw human readable
45  // exception when misspellings occure
46  //-----------------------------------------------
47  try{
48  //-----------------------------------------------
49  // input/output files
50  //-----------------------------------------------
51  histFile_ = cfg.read<std::string>( "histInput" );
52  readVector ( cfg.read<std::string>( "rootInput" ), fileNameList_ );
53  readVector ( cfg.read<std::string>( "inputDirs" ), dirNameList_ );
54  filterOpt_ = cfg.read<std::string>( "filterOption" );
55  readVector ( cfg.read<std::string>( "histFilter" ), histFilterList_ );
56  readVector ( cfg.read<std::string>( "plotFilter" ), plotFilterList_ );
57  writeTo_ = cfg.read<std::string>( "writePlotsTo" );
58  writeAs_ = cfg.read<std::string>( "writePlotsAs" );
59  rootOutDir_= cfg.read<std::string>( "outputDir" );
60  output_ = cfg.read<std::string>( "rootOutput" );
61  readVector ( cfg.read<std::string>( "outputLabels" ), outputLabelList_ );
62  }
63  catch(...){
64  std::cerr << "ERROR during reading of config file" << std::endl;
65  std::cerr << " misspelled variables in cfg ?" << std::endl;
66  std::cerr << " [--called in configBlockIO--]" << std::endl;
67  std::exit(1);
68  }
69 }
70 
71 void
73 {
74  //-----------------------------------------------
75  // read all configurables defined in CompHisto-
76  // grams from config file. Throw human readable
77  // exception when misspellings occure
78  //-----------------------------------------------
79  try{
80  //-----------------------------------------------
81  // canvas steering
82  //-----------------------------------------------
83  readVector( cfg.read<std::string>( "xLog" ), logX_ );
84  readVector( cfg.read<std::string>( "yLog" ), logY_ );
85  readVector( cfg.read<std::string>( "xGrid" ), gridX_);
86  readVector( cfg.read<std::string>( "yGrid" ), gridY_);
87 
88  //-----------------------------------------------
89  // histogram steering
90  //-----------------------------------------------
91  readVector( cfg.read<std::string>( "histErrors" ), errors_);
92  readVector( cfg.read<std::string>( "histScale" ), scale_ );
93  readVector( cfg.read<std::string>( "histMinimum"), min_ );
94  readVector( cfg.read<std::string>( "histMaximum"), max_ );
95  readVector( cfg.read<std::string>( "histType" ), histStyle_ );
96  readVector( cfg.read<std::string>( "histStyle" ), commonStyle_ );
97  readVector( cfg.read<std::string>( "histColor" ), histColor_ );
98  readVector( cfg.read<std::string>( "lineWidth" ), commonWidth_ );
99  readVector( cfg.read<std::string>( "markerStyle" ), markerStyle_ );
100  readVector( cfg.read<std::string>( "markerSize" ), markerSize_ );
101  readLabels( cfg.read<std::string>( "xAxes" ), xAxes_ );
102  readLabels( cfg.read<std::string>( "yAxes" ), yAxes_ );
103 
104  //-----------------------------------------------
105  // legend steering
106  //-----------------------------------------------
107  readLabels( cfg.read<std::string>( "legEntries"), legendEntries_);
108  legXLeft_ = cfg.read<double>( "legXLeft" );
109  legXRight_= cfg.read<double>( "legXRight" );
110  legYLower_= cfg.read<double>( "legYLower" );
111  legYUpper_= cfg.read<double>( "legYUpper" );
112  }
113  catch(...){
114  std::cerr << "ERROR during reading of config file" << std::endl;
115  std::cerr << " misspelled variables in cfg ?" << std::endl;
116  std::cerr << " [--called in configBlockHist--]" << std::endl;
117  std::exit(1);
118  }
119 }
120 
121 void
123 {
124  //-----------------------------------------------
125  // fill the list histList_ with all requested
126  // histogram names; the names are recieved from
127  // a .hist file; jump out if the reading takes
128  // too long
129  //-----------------------------------------------
130  ifstream histFile( histFile_.c_str() );
131 
132  int count=0;
133  while( !histFile.eof() ){
134  std::string buffer;
135  histFile >> buffer;
136  if( buffer.size()>0 ){
137  TString cmp(buffer);
138  if( histFilter(cmp, histFilterList_) )
139  histList_.push_back(buffer);
140  else{
141  if(verbose_){
142  std::cout << " histogram is filtered out according"
143  << " to settings in cfg file; filterOpt: "
144  << filterOpt_ << std::endl;
145  }
146  }
147  }
148  if( count>999 ){
149  std::cerr << "ERROR caught in slope for histogram" << std::endl;
150  std::cerr << " names. Misspelled file name ?" << std::endl;
151  std::cerr << histFile_.c_str() << std::endl;
152  break;
153  }
154  ++count;
155  }
156 }
157 
158 void
159 CompHist::loadHistograms(std::vector<std::string>& histList, std::vector<TObjArray>& sampleList)
160 {
161  //fill vector of root files if not already done
162  if( fileList_.empty() ){
163  std::vector<std::string>::const_iterator name;
164  for(name = fileNameList_.begin(); name!=fileNameList_.end(); ++name){
165  fileList_.push_back( new TFile( name->c_str() ) );
166  }
167  }
168  //fill vector of histogram arrays
169  std::vector<TFile*>::const_iterator file = fileList_.begin();
170  for(int jdx=0 ; file!=fileList_.end(); ++file, ++jdx){
171  std::vector<std::string>::const_iterator rootDir;
172  for(rootDir = dirNameList_.begin(); rootDir!=dirNameList_.end(); ++rootDir){
173  TH1F *dummy;
174  TObjArray hist;
175  for( int idx=0; idx<(int)histList.size(); ++idx ){
176  TString directory( *rootDir );
177  directory+="/";
178  directory+=histList[idx];
179 
180  if(verbose_){
181  std::cout << "load from: " << (*file)->GetName() << " "
182  << "directory: " << directory << std::endl;
183  }
184  dummy = (TH1F*)(*file)->Get( directory );
185  if( !dummy ){
186  std::cerr << "WARNING:"
187  << " Didn't find indicated hist"
188  << " [" << directory << "]"
189  << " in file"
190  << " [" << (*file)->GetName() << "]"
191  << std::endl;
192  return;
193  }
194 
195  // prepare unambiguous histogram name
196  TString outname( fileNameList_[jdx] );
197  outname.Remove(outname.Last('.'), outname.Length());
198  outname += ":";
199  outname += *rootDir;
200  outname +="/";
201  outname +=dummy->GetName();
202  dummy->SetName( outname );
203 
204  // add histogram to list
205  hist.Add( dummy );
206  if(verbose_){
207  std::cout << "added to list as: " << dummy->GetName() << std::endl;
208  }
209  } // end of histogram name list
210  sampleList.push_back( hist );
211  } // end of root directory list
212  } // end of root file list
213 }
214 
215 void
217 {
218  //-----------------------------------------------
219  // fill histograms listed in histList_ into a
220  // TObjectArray for each sample given in the
221  // list fileNameList_ and its directories; Each
222  // TObjectArray is then pushed into the vector
223  // sampleList_ which keeps all TObjectArrays of
224  // histograms for each sample
225  //-----------------------------------------------
226 
227  //fill histogram list
228  if( !histFile_.empty() )
229  readHistogramList();
230  else{
231  if( histFilterList_.size()>0 ){
232  if( !filterOpt_.compare("contains") )
233  cout << "WARNING: missing hist file in cfg file; will use list of histogram" << std::endl
234  << " names given in histFilter instead, requires filterOption " << std::endl
235  << " 'optains'; will move filterOption to 'optain' to go on..." << std::endl;
236  filterOpt_="contains";
237  histList_ =histFilterList_;
238  }
239  }
240  loadHistograms(histList_, sampleList_);
241 }
242 
243 bool
244 CompHist::histFilter(TString& cmp, std::vector<std::string>& ref)
245 {
246  bool contained=true;
247  if(!filterOpt_.empty()){
248  contained=false;
249  if(!filterOpt_.compare("begins")){
250  contained = histFilter(cmp, ref, kBeginsWith);
251  }
252  else if(!filterOpt_.compare("ends")){
253  contained = histFilter(cmp, ref, kEndsWith);
254  }
255  else if(!filterOpt_.compare("contains")){
256  contained = histFilter(cmp, ref, kContains);
257  }
258  else{
259  std::cerr << "ERROR during histogram filtering " << std::endl;
260  std::cerr << " filter option is not properly" << std::endl;
261  std::cerr << " specified : " << filterOpt_ << std::endl;
262  }
263  }
264  return contained;
265 }
266 
267 bool
268 CompHist::histFilter(TString& cmp, std::vector<std::string>& ref, CompHist::HistFilter option)
269 {
270  bool contained=true;
271  if(ref.size()>0){
272  contained=false;
273  for(unsigned int idx=0; idx<ref.size(); ++idx){
274  TString buffer(ref[idx]);
275  if( !option==kContains ) buffer+="_";
276  if( option==kBeginsWith && cmp.BeginsWith(buffer) ){
277  contained=true;
278  break;
279  }
280  if( option==kEndsWith && cmp.EndsWith(buffer) ){
281  contained=true;
282  break;
283  }
284  if( option==kContains && cmp.Contains(buffer) ){
285  contained=true;
286  break;
287  }
288  }
289  }
290  return contained;
291 }
292 
293 void
294 CompHist::draw(TCanvas& canv, TLegend& leg, int& idx, int& jdx)
295 {
296  //-----------------------------------------------
297  // loop all samples via the list sampleList_, which
298  // containas the histograms of each sample as
299  // TObjects in TObjectArrays
300  //-----------------------------------------------
301  TH1F hfirst; //draw first histogram on top of others
302  //after all histograms have been drawn
303  std::vector<TObjArray>::const_iterator hist = sampleList_.begin();
304  for(int kdx=0; hist!=sampleList_.end(); ++hist, ++kdx){
305  TH1F& hcmp = *((TH1F*)(*hist)[idx]); //recieve histogram
306  setCanvLog( canv, jdx );
307  setCanvGrid( canv, jdx );
308  setHistStyles( hcmp, jdx, kdx );
309  // for the first histogram just draw
310  // for the following ones draw same
311  if(kdx==0){
312  hfirst = hcmp; // buffer first histogram to redraw it after all
313  if(errors_[kdx])
314  hcmp.Draw("e");
315  else
316  hcmp.Draw( );
317  }
318  else{
319  if(errors_[kdx])
320  hcmp.Draw("samee");
321  else
322  hcmp.Draw("same" );
323  }
324  // add legend entry in appropriate format
325  switch( histStyle_[kdx]){
326  case HistStyle::Line:
327  leg.AddEntry( &hcmp, legend(kdx).c_str(), "L" );
328  break;
329 
330  case HistStyle::Marker:
331  leg.AddEntry( &hcmp, legend(kdx).c_str(), "PL" );
332  break;
333 
334  case HistStyle::Filled:
335  leg.AddEntry( &hcmp, legend(kdx).c_str(), "FL" );
336  break;
337  }
338  }
339  if(errors_[0]){
340  hfirst.Draw("esame");
341  }
342  else{
343  hfirst.Draw( "same");
344  }
345  leg.Draw( "same" );
346  canv.RedrawAxis( );
347  canv.Update( );
348 }
349 
350 void
352 {
353  //-----------------------------------------------
354  // define canvas
355  //-----------------------------------------------
356  TCanvas *canv = new TCanvas("canv", "histograms", 600, 600);
357  setCanvasStyle( *canv );
358 
359  //-----------------------------------------------
360  // open output file
361  //-----------------------------------------------
362  TString output( writeTo_.c_str() );
363  output += "/";
364  output += "inspect";
365  output += ".";
366  output += writeAs_;
367  TPostScript psFile( output, 111); //112 for portrait
368 
369  //-----------------------------------------------
370  // loop histograms via the list of histogram
371  // names stored in histList_, open a new page
372  // for each histogram & plot each sample in
373  // the same canvas
374  //-----------------------------------------------
375  for(int idx=0, jdx=0; idx<(int)histList_.size(); ++idx){
376  // prepare compare string for plot filtering
377  TString cmp( histList_[idx] );
378  if( !histFilter(cmp, plotFilterList_) ){
379  if(verbose_){
380  cout << " event is filtered out according to"
381  << " settings in cfg file; filterOpt: "
382  << filterOpt_
383  << " hist: " << cmp << std::endl;
384  }
385  continue;
386  }
387  psFile.NewPage();
388  //-----------------------------------------------
389  // on each page the legend needs to be redeclared
390  //-----------------------------------------------
391  TLegend* leg = new TLegend(legXLeft_,legYLower_,legXRight_,legYUpper_);
392  setLegendStyle( *leg );
393  draw(*canv, *leg, idx, jdx);
394  if(idx == (int)histList_.size()-1){
395  psFile.Close();
396  }
397  ++jdx; delete leg;
398  }
399  canv->Close();
400  delete canv;
401 }
402 
403 void
405 {
406  //-----------------------------------------------
407  // define canvas
408  //-----------------------------------------------
409  TCanvas *canv = new TCanvas("canv", "histograms", 600, 600);
410  setCanvasStyle( *canv );
411 
412  //-----------------------------------------------
413  // loop histograms via the list of histogram
414  // names stored in histList_, open a new page
415  // for each histogram & plot each sample in
416  // the same canvas
417  //-----------------------------------------------
418  for(int idx=0, jdx=0; idx<(int)histList_.size(); ++idx){
419  //-----------------------------------------------
420  // prepare compare string for plot filtering
421  //-----------------------------------------------
422  TString cmp( histList_[idx] );
423  if( !histFilter(cmp, plotFilterList_) ){
424  if(verbose_){
425  cout << " event is filtered out according to"
426  << " settings in cfg file; filterOpt: "
427  << filterOpt_
428  << " hist: " << cmp << std::endl;
429  }
430  continue;
431  }
432  //-----------------------------------------------
433  // open output files
434  //-----------------------------------------------
435  TString output( writeTo_.c_str() );
436  output += "/";
437  output += histList_[ idx ];
438  output += ".";
439  output += writeAs_;
440 
441  TPostScript psFile( output, 113);
442  psFile.NewPage();
443  //-----------------------------------------------
444  // on each page the legend needs to be redeclared
445  //-----------------------------------------------
446  TLegend* leg = new TLegend(legXLeft_,legYLower_,legXRight_,legYUpper_);
447  setLegendStyle( *leg );
448  draw(*canv, *leg, idx, jdx);
449  psFile.Close();
450  ++jdx; delete leg;
451  }
452  canv->Close();
453  delete canv;
454 }
455 
456 std::string
458 {
459  char buffer[100];
460  sprintf(buffer, "undefined sample %i", idx);
461  if( legendEntries_.size()>=sampleList_.size() ){
462  return legendEntries_[idx];
463  }
464  return buffer;
465 }
466 
467 double
469 {
470  double max=-1.;
471  for(std::vector<TObjArray>::const_iterator hist = sampleList_.begin();
472  hist!=sampleList_.end(); ++hist){
473  TH1F& hcmp = *((TH1F*)(*hist)[idx]); //recieve histogram
474  if( max<0 || hcmp.GetMaximum()>max ) max=hcmp.GetMaximum();
475  }
476  return max;
477 }
478 
479 void
481 {
482  leg.SetFillStyle ( 0 );
483  leg.SetFillColor ( 0 );
484  leg.SetBorderSize( 0 );
485 }
486 
487 void
489 {
490  canv.SetFillStyle ( 4000 );
491  canv.SetLeftMargin ( 0.20 );
492  canv.SetRightMargin ( 0.05 );
493  canv.SetBottomMargin( 0.15 );
494  canv.SetTopMargin ( 0.05 );
495 }
496 
497 void
498 CompHist::setCanvLog(TCanvas& canv, int idx)
499 {
500  if( idx<((int)logX_.size()-1) && idx<((int)logY_.size()-1) ){
501  canv.SetLogx ( logX_[idx] );
502  canv.SetLogy ( logY_[idx] );
503  }
504  else if( idx<((int)logY_.size()-1) ){
505  canv.SetLogx ( 0 );
506  canv.SetLogy ( logY_[idx] );
507  }
508  else{
509  canv.SetLogx ( 0 );
510  canv.SetLogy ( 0 );
511  }
512 }
513 
514 void
515 CompHist::setCanvGrid(TCanvas& canv, int idx)
516 {
517  if( idx<((int)gridX_.size()-1) && idx<((int)gridY_.size()-1) ){
518  canv.SetGridx ( gridX_[idx] );
519  canv.SetGridy ( gridY_[idx] );
520  }
521  else if( idx<((int)gridY_.size()-1) ){
522  canv.SetGridx ( 0 );
523  canv.SetGridy ( gridY_[idx] );
524  }
525  else{
526  canv.SetGridx ( 0 );
527  canv.SetGridy ( 0 );
528  }
529 }
530 
531 void
532 CompHist::setAxesStyle( TH1& hist, const char* titleX, const char* titleY )
533 {
534  hist.SetTitle( "" );
535 
536  hist.GetXaxis()->SetTitle( titleX );
537  hist.GetXaxis()->SetTitleSize ( 0.06 );
538  hist.GetXaxis()->SetTitleColor ( 1 );
539  hist.GetXaxis()->SetTitleOffset( 1.0 );
540  hist.GetXaxis()->SetTitleFont ( 62 );
541  hist.GetXaxis()->SetLabelSize ( 0.05 );
542  hist.GetXaxis()->SetLabelFont ( 62 );
543  hist.GetXaxis()->CenterTitle ( );
544  hist.GetXaxis()->SetNdivisions ( 505 );
545 
546  hist.GetYaxis()->SetTitle( titleY );
547  hist.GetYaxis()->SetTitleSize ( 0.07 );
548  hist.GetYaxis()->SetTitleColor ( 1 );
549  hist.GetYaxis()->SetTitleOffset( 1.3 );
550  hist.GetYaxis()->SetTitleFont ( 62 );
551  hist.GetYaxis()->SetLabelSize ( 0.05 );
552  hist.GetYaxis()->SetLabelFont ( 62 );
553 }
554 
555 void
556 CompHist::setHistStyles( TH1F& hist, int idx, int jdx )
557 {
558  //-----------------------------------------------
559  // check hist style; throw exception if style
560  // is not competible with specifications; set
561  // default line[0] if vector is too short
562  //-----------------------------------------------
563  int histType=0;
564  if( jdx<((int)histStyle_.size()) ){
565  if(HistStyle::Line<=histStyle_[jdx] && histStyle_[jdx]<=HistStyle::Filled){
566  histType=histStyle_[jdx];
567  }
568  else{
569  throw "Histogram Type cannot be specified ";
570  }
571  }
572 
573  //define histogram styles
574  setHistLabels( hist, idx );
575  setHistScale ( hist, idx );
576  setHistMax ( hist, idx );
577  setHistMin ( hist, idx );
578 
579  switch( histType ){
580  case HistStyle::Line:
581  setLineWidth( hist, jdx );
582  setLineColor( hist, jdx );
583  setLineStyle( hist, jdx );
584  break;
585 
586  case HistStyle::Marker:
587  setLineWidth ( hist, jdx );
588  setLineColor ( hist, jdx );
589  setMarkerColor( hist, jdx );
590  setMarkerStyle( hist, jdx );
591  setMarkerSize ( hist, jdx );
592  break;
593 
594  case HistStyle::Filled:
595  setLineWidth( hist, jdx );
596  setLineColor( hist, jdx );
597  setFillColor( hist, jdx );
598  setFillStyle( hist, jdx );
599  break;
600  }
601 }
602 
603 void
605 {
606  if( idx<((int)xAxes_.size()) && idx<((int)yAxes_.size()) ){
607  setAxesStyle( hist, xAxes_[idx].c_str(), yAxes_[idx].c_str() );
608  }
609  else if( idx<((int)xAxes_.size()) ){
610  setAxesStyle( hist, xAxes_[idx].c_str(), "events" );
611  }
612  else{
613  if( strcmp(hist.GetTitle(),"") == 0 ){
614  setAxesStyle( hist, hist.GetXaxis()->GetTitle(), "events" );
615  }
616  else{
617  setAxesStyle( hist, hist.GetTitle(), "events" );
618  }
619  }
620 }
621 
622 void
624 {
625  if( idx<((int)scale_.size()) ){
626  if( scale_[idx]>0 ) hist.Scale(scale_[idx]/hist.Integral());
627  }
628 }
629 
630 void
631 CompHist::setHistMax(TH1F& hist, int idx)
632 {
633  if( ((int)max_.size()>0) && (idx<(int)max_.size()) ){
634  hist.SetMaximum(max_[idx]);
635  }
636  else{
637  hist.SetMaximum(1.5*findMaximum(idx));
638  }
639 }
640 
641 void
642 CompHist::setHistMin(TH1F& hist, int idx)
643 {
644  if( ((int)min_.size()>0) && (idx<(int)min_.size()) ){
645  hist.SetMinimum(min_[idx]);
646  }
647  else{
648  hist.SetMinimum(0.);
649  }
650 }
651 
652 void
654 {
655  hist.SetLineWidth( 5 );
656  if( jdx<((int)commonWidth_.size()) ){
657  hist.SetLineWidth(commonWidth_[jdx]);
658  }
659 }
660 
661 void
663 {
664  hist.SetLineStyle( 1 );
665  if( jdx<((int)commonStyle_.size()) ){
666  hist.SetLineStyle(commonStyle_[jdx]);
667  }
668 }
669 
670 void
672 {
673  hist.SetLineColor( 1 );
674  if( jdx<((int)histColor_.size()) ){
675  hist.SetLineColor(histColor_[jdx]);
676  }
677 }
678 
679 void
681 {
682  hist.SetFillStyle( 3005 );
683  if( jdx<((int)commonStyle_.size()) ){
684  hist.SetFillStyle(commonStyle_[jdx]);
685  }
686 }
687 
688 void
690 {
691  hist.SetFillColor( 1 );
692  if( jdx<((int)histColor_.size()) ){
693  hist.SetFillColor(histColor_[jdx]);
694  }
695 }
696 
697 void
699 {
700  hist.SetMarkerStyle( 23 );
701  if( jdx<((int)markerStyle_.size()) ){
702  hist.SetMarkerStyle(markerStyle_[jdx]);
703  }
704 }
705 
706 void
708 {
709  hist.SetMarkerColor( 1 );
710  if( jdx<((int)histColor_.size()) ){
711  hist.SetMarkerColor(histColor_[jdx]);
712  }
713 }
714 
715 void
717 {
718  hist.SetMarkerSize( 2.3 );
719  if( jdx<((int)markerSize_.size()) ){
720  hist.SetMarkerSize(markerSize_[jdx]);
721  }
722 }
723 
724 void
726 {
727  //---------------------------------------------
728  // write filled target histogram to output file
729  // if specified
730  //---------------------------------------------
731  if( isOutputRequested() ){
732  //-----------------------------------------------
733  // open hist file for book keeping of hist names
734  //-----------------------------------------------
735  TString name( output_ );
736  name.Remove(name.Last('.'), name.Length());
737  name+=".hist"; //replace .root by .hist
738  ofstream histFile(name, std::ios::out);
739 
740  //-----------------------------------------------
741  // open root output file and create directory
742  // if necessary
743  //-----------------------------------------------
744  TFile file( output_.c_str(), "update" );
745  if( !file.GetDirectory(rootOutDir_.c_str()) )
746  // create new directory if it does not yet exist
747  file.mkdir( rootOutDir_.c_str(), rootOutDir_.c_str() );
748  else
749  // clean-up directory if it was existing already
750  (file.GetDirectory(rootOutDir_.c_str()))->Delete("*;*");
751  file.cd(rootOutDir_.c_str());
752 
753  //-----------------------------------------------
754  // loop and write out histograms
755  //-----------------------------------------------
756  if( option==kAll ){
757  std::vector<TObjArray>::const_iterator hist = sampleList_.begin();
758  for( ;hist!=sampleList_.end(); ++hist){
759  for(unsigned int idx=0; idx<histList_.size(); ++idx){
760  histFile << ((TH1F*)(*hist)[idx])->GetName() << "\n";
761  ((TH1F*)(*hist)[idx])->Write();
762  }
763  }
764  }
765  else{
766  for(unsigned int idx=0; idx<histList_.size(); ++idx){
767  // write first/last histograms in the sample list only
768  histFile << (TH1F*)((sampleList_.back())[idx])->GetName() << "\n";
769  switch( option ){
770  case kFirstOnly:
771  ((TH1F*)((*sampleList_.begin())[idx]))->Write();
772  break;
773  case kLastOnly:
774  ((TH1F*)((sampleList_.back())[idx]))->Write();
775  break;
776  default:
777  std::cerr << "WARNING:"
778  << " Wrong option indicated for writeOutput" << " [" << option
779  << "]" << " while only " << kFirstOnly << " up to " << kAll
780  << " are available" << std::endl;
781  break;
782  }
783  }
784  }
785  file.Close();
786  }
787 }
static const int Line
Definition: CompHist.h:17
void setFillColor(TH1F &, int)
Definition: CompHist.cc:689
void configBlockHist(ConfigFile &)
Definition: CompHist.cc:72
void setLegendStyle(TLegend &)
Definition: CompHist.cc:480
const std::string & label
Definition: MVAComputer.cc:186
T read(const std::string &key) const
Definition: ConfigFile.h:173
void draw(TCanvas &, TLegend &, int &, int &)
Definition: CompHist.cc:294
static const int Marker
Definition: CompHist.h:18
void setAxesStyle(TH1 &, const char *, const char *)
Definition: CompHist.cc:532
list file
Definition: dbtoweb.py:253
void configBlockIO(ConfigFile &)
Definition: CompHist.cc:40
void setHistLabels(TH1F &, int)
Definition: CompHist.cc:604
void setMarkerStyle(TH1F &, int)
Definition: CompHist.cc:698
void readHistogramList()
Definition: CompHist.cc:122
bool histFilter(TString &, std::vector< std::string > &)
Definition: CompHist.cc:244
void readVector(std::string s, std::vector< T > &vec)
Definition: CompHist.h:23
void setCanvGrid(TCanvas &, int)
Definition: CompHist.cc:515
std::string legend(int)
Definition: CompHist.cc:457
void setLineColor(TH1F &, int)
Definition: CompHist.cc:671
void setHistMin(TH1F &, int)
Definition: CompHist.cc:642
RootOutput
Definition: CompHist.h:39
static const int Filled
Definition: CompHist.h:19
void setHistMax(TH1F &, int)
Definition: CompHist.cc:631
const T & max(const T &a, const T &b)
void setLineWidth(TH1F &, int)
Definition: CompHist.cc:653
void readLabels(std::string, std::vector< std::string > &)
Definition: CompHist.cc:9
void setFillStyle(TH1F &, int)
Definition: CompHist.cc:680
void writeOutput()
Definition: CompHist.h:61
HistFilter
Definition: CompHist.h:40
void setHistStyles(TH1F &, int, int)
Definition: CompHist.cc:556
void setCanvasStyle(TCanvas &)
Definition: CompHist.cc:488
tuple out
Definition: dbtoconf.py:99
void setLineStyle(TH1F &, int)
Definition: CompHist.cc:662
void drawPs()
Definition: CompHist.cc:351
void setMarkerSize(TH1F &, int)
Definition: CompHist.cc:716
double findMaximum(int)
Definition: CompHist.cc:468
void setHistScale(TH1F &, int)
Definition: CompHist.cc:623
tuple cout
Definition: gather_cfg.py:41
string s
Definition: asciidump.py:422
void loadHistograms()
Definition: CompHist.cc:216
void setCanvLog(TCanvas &, int)
Definition: CompHist.cc:498
void setMarkerColor(TH1F &, int)
Definition: CompHist.cc:707
void drawEps()
Definition: CompHist.cc:404