ATLAS Offline Software
Loading...
Searching...
No Matches
comparitor.cxx File Reference
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <regex>
#include "TrigInDetAnalysis/Efficiency1D.h"
#include "ReadCards.h"
#include "Resplot/Resplot.h"
#include "utils.h"
#include "label.h"
#include "DrawLabel.h"
#include "TFile.h"
#include "TTree.h"
#include "TString.h"
#include "TH2F.h"
#include "TH1D.h"
#include "TPad.h"
#include "TCanvas.h"
#include "TLegend.h"
#include "TStyle.h"
#include "TF1.h"
#include "TPave.h"
#include "TPaveStats.h"
#include "TEfficiency.h"
#include "TColor.h"
#include "computils.h"
#include "AtlasStyle.h"
#include "AtlasLabels.h"
#include "default_panels.h"
#include "TError.h"

Go to the source code of this file.

Classes

class  bands

Typedefs

typedef std::map< std::string, std::string > chainmap_t
 global typedef here is ok, since this is a standalone executable, including a main().

Functions

void normaliseBinWidth (TH1 *h)
void testfit (TH1 *htest, const std::string &s)
double total_eff (TH1 *hn, TH1 *hd)
std::string eround (double x, int decfigs=4)
void arsaway (std::string &s, const std::string &pattern, const std::string &rep)
TH1F * trans (TH1F *h, bool t=false)
void SetZeros (TH2D *h)
void Scale (TH1 *h, double d=1)
TH1F * Rebin (TH1F *h, double f)
TH1F * rebin_log (TH1F *h, bool low=false)
template<typename T = TH1F>
T * Get (TFile &f, const std::string &n, const std::string &dir="", const chainmap_t *chainmap=0, std::vector< std::string > *saved=0)
 get a histogram given a path, and an optional initial directory if histogram is not found, then check for dir/name, allows optional remapping of the reference chain information
template<typename T>
bool isTEfficiency (T *h)
TH1F * d0rebin (TH1F *h)
int usage (const std::string &name, int status, const std::string &err_msg="")
void binwidth (TH1F *h)
void ascale (TH1F *h, double s_)
std::string fullreplace (std::string s, const std::string &s2, const std::string &s3)
void print_pad (const std::string &s)
TH1F * makeplot (TObject *hreft)
void zero (TH2 *h)
 zero the contents of a 2d histogram
void normy (TH2 *h)
 zero the contents of a 2d histogram
void autox (TH2 *h, bool t=false)
 get the auto x range of a 2d histogram
void autoy (TH2 *h)
 get the auto y range of a 2d histogram
double chi2 (TH1 *h0, TH1 *h1)
void ifdbg (const std::string &)
void d0fit (const HistDetails &histo, TH1 *ht, const std::string &chain="")
int main (int argc, char **argv)

Variables

const std::string reset = "\033[0m"
const std::string black = "\033[0;30m"
const std::string red = "\033[0;31m"
const std::string green = "\033[0;32m"
const std::string blue = "\033[0;34m"
bool fulldbg = false
bool LINEF
bool LINES
bool EPS = false
int colours [6]
int markers [6]
TCanvas * fitcanvas = 0
TCanvas * fitcanvas_rec = 0

Detailed Description

Author
mark sutton
Date
Fri 12 Oct 2012 13:39:05 BST

Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration

Definition in file comparitor.cxx.

Typedef Documentation

◆ chainmap_t

typedef std::map<std::string,std::string> chainmap_t

global typedef here is ok, since this is a standalone executable, including a main().

As such it does not need to be in a namespace at this point as it won't in any case be visible outside this translation unit

Definition at line 343 of file comparitor.cxx.

Function Documentation

◆ arsaway()

void arsaway ( std::string & s,
const std::string & pattern,
const std::string & rep )

Definition at line 191 of file comparitor.cxx.

191 {
192 std::regex regexPattern(pattern);
193 s = std::regex_replace( s, regexPattern, rep );
194}

◆ ascale()

void ascale ( TH1F * h,
double s_ )

Definition at line 630 of file comparitor.cxx.

630 {
631 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
632 h->SetBinContent( i, h->GetBinContent(i)*s_ );
633 h->SetBinError( i, h->GetBinError(i)*s_ );
634 }
635}
Header file for AthHistogramAlgorithm.

◆ autox()

void autox ( TH2 * h,
bool t = false )

get the auto x range of a 2d histogram

Definition at line 725 of file comparitor.cxx.

725 {
726
727 int Nx = h->GetNbinsX();
728 int Ny = h->GetNbinsY();
729
730 double xhi = h->GetXaxis()->GetBinLowEdge(1);
731 double xlo = h->GetXaxis()->GetBinLowEdge( h->GetXaxis()->GetNbins() );
732
733 for ( int i=1 ; i<=Nx ; i++ ) {
734 double x = h->GetXaxis()->GetBinLowEdge(i);
735 for ( int j=1 ; j<=Ny ; j++ ) {
736 double n = h->GetBinContent(i,j);
737 if ( n!=0 ) {
738 if ( x<xlo ) {
739 if ( i>1 ) xlo = h->GetXaxis()->GetBinLowEdge(i-1);
740 else xlo = x;
741 }
742 if ( x>xhi ) {
743 if ( i<h->GetXaxis()->GetNbins() ) xhi = h->GetXaxis()->GetBinLowEdge(i+1);
744 else xhi = x;
745 }
746 }
747 }
748 }
749
750 if ( t ) {
751 xlo -= 5.4;
752 xhi -= 5.4;
753 }
754
755 h->GetXaxis()->SetRangeUser( xlo, xhi );
756}
#define x
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ autoy()

void autoy ( TH2 * h)

get the auto y range of a 2d histogram

Definition at line 760 of file comparitor.cxx.

760 {
761
762 int Nx = h->GetNbinsX();
763 int Ny = h->GetNbinsY();
764
765 double yhi = h->GetYaxis()->GetBinLowEdge(1);
766 double ylo = h->GetYaxis()->GetBinLowEdge( h->GetYaxis()->GetNbins() );
767
768 for ( int i=1 ; i<=Ny ; i++ ) {
769 double y = h->GetYaxis()->GetBinLowEdge(i);
770 for ( int j=1 ; j<=Nx ; j++ ) {
771 double n = h->GetBinContent(j,i);
772 if ( n!=0 ) {
773 if ( y<ylo ) {
774 if ( i>1 ) ylo = h->GetYaxis()->GetBinLowEdge(i-1);
775 else ylo = y;
776 }
777 if ( y>yhi ) {
778 if ( i<h->GetYaxis()->GetNbins() ) yhi = h->GetYaxis()->GetBinLowEdge(i+1);
779 else yhi = y;
780 }
781 }
782 }
783 }
784
785 h->GetYaxis()->SetRangeUser( ylo, yhi );
786}
#define y

◆ binwidth()

void binwidth ( TH1F * h)

Definition at line 622 of file comparitor.cxx.

622 {
623 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
624 double w = h->GetBinLowEdge(i+1) - h->GetBinLowEdge(i);
625 h->SetBinContent( i, h->GetBinContent(i)/w );
626 h->SetBinError( i, h->GetBinError(i)/w );
627 }
628}

◆ chi2()

double chi2 ( TH1 * h0,
TH1 * h1 )

Definition at line 790 of file comparitor.cxx.

790 {
791
792 std::cout << "chi2" << std::endl;
793
794 double c2 = 0;
795
796 std::cout << "h: " << h0 << " " << h1 << std::endl;
797
798 if ( h0==0 || h1==0 ) {
799 std::cerr << "histogram not found: h0: " << h0 << "\th1: " << h1 << std::endl;
800 return 999;
801 }
802
803 std::cout << "h: " << h0->GetName() << std::endl;
804 std::cout << "h: " << h1->GetName() << std::endl;
805
806 std::cout << "h0->GetNbinsX() " << h0->GetNbinsX() << std::endl;
807 std::cout << "h0->GetNbinsX() " << h1->GetNbinsX() << std::endl;
808
809 for ( int i=0 ; i<h0->GetNbinsX() ; i++ ) {
810
811 double d0 = h0->GetBinContent(i+1);
812 double d1 = h1->GetBinContent(i+1);
813
814 double e0 = h0->GetBinError(i+1);
815 double e1 = h1->GetBinError(i+1);
816
817 double e2 = e0*e0+e1*e1;
818
819 if ( e2>0 ) c2 += (d0-d1)*(d0-d1)/e2;
820
821 }
822
823 return c2;
824}
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
double e0(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in pre-sampler
double e1(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 1st sampling

◆ d0fit()

void d0fit ( const HistDetails & histo,
TH1 * ht,
const std::string & chain = "" )

do we need these ? - keep for the time being ...

Definition at line 842 of file comparitor.cxx.

842 {
843
844 TH1* hf = ht;
845
846 std::cout << green << "\n\nd0fit :: beam fitting !!" << histo.name() << reset << std::endl;
847
848 TVirtualPad* old = gPad;
849
850 std::cout << "old canvas: " << gPad << std::endl;
851
852 std::cout << "dbg histo name: " << histo.name() << std::endl;
853
854 bool first = false;
855
856 TCanvas* tc = 0;
857
858 if ( histo.name().find("_rec")!=std::string::npos ) {
859 // if ( fitcanvas_rec == 0 ) {
860 fitcanvas_rec = new TCanvas( "fit_rec", "", 700, 600 );
861 first = true;
862 // }
864 }
865
866 if ( histo.name().find("_rec")==std::string::npos ) {
867 //if ( fitcanvas == 0 ) {
868 fitcanvas = new TCanvas( "fit", "", 700, 600 );
869 first = true;
870 //}
871 tc = fitcanvas;
872 }
873
874 TVirtualPad* tp = gPad;
875
876 if ( tc ) tc->cd();
877
879 // TH1D* hf = (TH1D*)rtest.Mean()->Clone("cck");
880 // TH1D* hf = rtest.Mean();
881
882 if ( histo.name().find("_rec")!=std::string::npos ) hf->SetTitle(";Trigger #phi;Trigger d_{0} [mm]");
883 else hf->SetTitle(";Offline #phi;Offline d_{0} [mm]");
884
885 TF1* tf = new TF1( "sinus", "[0]*sin(x+[1])+[2]" );
886
887 tf->SetLineWidth(1);
888
889 hf->GetYaxis()->SetTitleOffset( hf->GetYaxis()->GetTitleOffset()*1.1 );
890
891 {
892 TCanvas* tfc = new TCanvas( "tmp", "", 700, 600 );
893 tfc->cd();
894 hf->Fit( tf );
895 delete tfc;
896 }
897
898 double phi0 = tf->GetParameter(1);
899 // double x = 0.0001*int(tf->GetParameter(0)*cos(phi0)*10000);
900 // double y = 0.0001*int(tf->GetParameter(0)*sin(phi0)*10000);
901 double x = tf->GetParameter(0)*cos(phi0);
902 double y = tf->GetParameter(0)*sin(phi0);
903 double off = tf->GetParameter(2);
904
905 std::cout << "\tx = " << x << std::endl;
906 std::cout << "\ty = " << y << std::endl;
907 std::cout << "\toffset = " << off << std::endl;
908
909 std::string cckstr = chain;
910
911 cckstr = cckstr.substr( cckstr.find("HLT_IDTrack") );
912
913 std::string vstr = chain;
914
915 vstr.resize(vstr.find("_boffperf"));
916 vstr.resize(vstr.find("_L1"));
917
918 hf->SetMinimum( -0.03 );
919 hf->SetMaximum( 0.03 );
920
921 tc->cd();
922
923 if ( first ) hf->DrawCopy();
924
925 hf->DrawCopy("same");
926 hf->DrawCopy("samee");
927
928
929 // DrawLabel( 0.2, 0.89, cckstr );
930 // DrawLabel( 0.2, 0.85, vstr );
931
932 DrawLabel( 0.2, 0.81, "x = " + eround(x) + " mm" );
933 DrawLabel( 0.2, 0.77, "y = " + eround(y) + " mm" );
934 DrawLabel( 0.2, 0.73, "offset = " + eround(off) + " mm" );
935
936 std::string sht = chain+"-"+histo.name()+"-fit.pdf";
937
938 size_t p = sht.find("/");
939
940 while ( p!=std::string::npos ) {
941 sht.erase( p, 1 );
942 p = sht.find("/");
943 }
944
945
946 gPad->Print( sht.c_str() );
947 gPad->Print( "sht.pdf" );
948
949 delete tf;
950
951 tp->cd();
952
953 gPad = old;
954
955}
int DrawLabel(float xstart, float ystart, string label)
static Double_t tc
const std::string reset
TCanvas * fitcanvas
TCanvas * fitcanvas_rec
std::string eround(double x, int decfigs=4)
bool first
Definition DeMoScan.py:534

◆ d0rebin()

TH1F * d0rebin ( TH1F * h)

Definition at line 481 of file comparitor.cxx.

481 {
482
483 return h;
484
485 std::vector<double> limits;
486
487 for ( int i=1 ; i<h->GetNbinsX() ; i++ ) {
488 limits.push_back( h->GetBinLowEdge(i) );
489 }
490
491 std::vector<double> alimits;
492 std::vector<double> nlimits;
493
494 double x = 0;
495
496 // for ( int i=0 ; x<20 ; i++ ) {
497 while ( x<20 ) {
498
499 alimits.push_back(x);
500
501#if 0
502 if ( x<0.5 ) x+=0.2;
503 else if ( x<1.0 ) x+=0.2;
504 else if ( x<1.5 ) x+=0.3;
505 else if ( x<2.0 ) x+=0.4;
506 else if ( x<2.5 ) x+=0.5;
507 else x+=0.6;
508#else
509 if ( x<0.5 ) x+=0.1;
510 else if ( x<1.0 ) x+=0.2;
511 else if ( x<1.5 ) x+=0.2;
512 else if ( x<2.0 ) x+=0.2;
513 else if ( x<2.5 ) x+=0.2;
514 else if ( x<3.0 ) x+=0.3;
515 else x+=0.3;
516#endif
517
518 }
519
520 for ( size_t i=alimits.size() ; i-- ; ) {
521 if ( alimits[i]<=15 ) nlimits.push_back( -alimits[i] );
522 }
523
524 for ( size_t i=1 ; i<alimits.size() ; i++ ) {
525 if ( alimits[i]<=15 ) nlimits.push_back( alimits[i] );
526 }
527
528 std::cout << "limits: " << limits.size() << " " << nlimits.size() << std::endl;
529
530 TH1F* hnew = new TH1F( "h", h->GetTitle(), nlimits.size()-1, &nlimits[0] );
531
532 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
533 double d = h->GetBinCenter(i);
534 int j = hnew->FindBin( d );
535 hnew->SetBinContent( j, hnew->GetBinContent(j)+h->GetBinContent(i) );
536 }
537
538 return hnew;
539}
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)

◆ eround()

std::string eround ( double x,
int decfigs = 4 )

Definition at line 183 of file comparitor.cxx.

183 {
184 char ss[1024];
185 std::string s= "%" + std::to_string(decfigs+2) + "." + std::to_string(decfigs) + "lf";
186 std::sprintf( ss, s.c_str(), x );
187 return ss;
188}
static Double_t ss

◆ fullreplace()

std::string fullreplace ( std::string s,
const std::string & s2,
const std::string & s3 )

cowardly, don't replace string by itself

Definition at line 640 of file comparitor.cxx.

640 {
641 if ( s2=="" || s2==s3 ) return s;
642 std::string::size_type pos;
643 while ( (pos=s.find(s2)) != std::string::npos ) s.replace(pos, s2.size(), s3);
644 return s;
645}

◆ Get()

template<typename T = TH1F>
T * Get ( TFile & f,
const std::string & n,
const std::string & dir = "",
const chainmap_t * chainmap = 0,
std::vector< std::string > * saved = 0 )

get a histogram given a path, and an optional initial directory if histogram is not found, then check for dir/name, allows optional remapping of the reference chain information

Definition at line 351 of file comparitor.cxx.

352 {
353
354 std::cout << "\n\nGet: " << n << "\tdir: " << dir << "\tchainmap: " << chainmap << std::endl;
355
356 std::string name;
357
358 size_t pos = n.find('+');
359 if ( pos!=std::string::npos ) name = n.substr( 0, pos );
360 else name = n;
361
362 std::cout << "name: " << name << "\t(file: " << f.GetName() << ")" << std::endl;
363
364 T* h = (T*)f.Get( name.c_str() );
365
366 bool printed = false;
367
368 if ( h || dir.empty() || name.find(dir)!=std::string::npos ) {
369 std::cout << "Get() name 0 " << name << " :: " << h << std::endl;
370 printed = true;
371 }
372 else {
373 std::string fname = dir+'/'+name;
374 h = (T*)f.Get( fname.c_str() );
375 // std::cout << "Get() name 1 " << name << " :: " << h << std::endl;
376 }
377
378 if ( h == 0 ) {
379 if ( chainmap && chainmap->size()!=0 ) {
380 for ( chainmap_t::const_iterator itr=chainmap->begin() ; itr!=chainmap->end() ; itr++ ) { //cppcheck-suppress postfixOperator
381 if ( contains( name, itr->first ) ) {
382
383 std::cout << "\tmatch: " << itr->first << " -> " << itr->second << std::endl;
384
385 name.replace( name.find(itr->first), itr->first.size(), itr->second );
386
387 h = (T*)f.Get( name.c_str() );
388
389 if ( h==0 ) {
390 if ( name.find(dir)==std::string::npos ) name = dir + "/" + name;
391
392 h = (T*)f.Get( name.c_str() );
393 }
394
395 break;
396 }
397 }
398 }
399 }
400
401
402 if ( ! printed ) {
403 std::cout << "Get() name 1 " << name << " :: " << h << std::endl;
404 }
405
406
407 if ( saved ) saved->push_back( name );
408
409
410 if ( h && std::string(h->ClassName()).find("TEfficiency")==std::string::npos ) {
411 std::cout << "TH " << h->GetName() << std::endl;
412 if ( h ) h->SetDirectory(0);
413 }
414
415
416 return h;
417}
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116

◆ ifdbg()

void ifdbg ( const std::string & )

Definition at line 826 of file comparitor.cxx.

826 {
827 // std::cout << "if dbg: " << s << std::endl;
828}

◆ isTEfficiency()

template<typename T>
bool isTEfficiency ( T * h)

Definition at line 421 of file comparitor.cxx.

421 {
422 if ( h && std::string(h->ClassName()).find("TEfficiency")!=std::string::npos ) return true;
423 return false;
424}

◆ main()

int main ( int argc,
char ** argv )

control stuff

control flags and labels

leave this commented here - now instead of bombing out if we don't specify the reference file, just carry on as if it was not specified at all, so as this changes the external behaviour of the code we want this retained

don't fail anymore if can't open the reference file, now continue without plotting the refereces, instead printing a warning on the plots

get release data

we divide the resolutions by these values if we have an "entries" histogram to tell us how many events there are overall

get from Chains?

set up the correct reference chain names ...

get the actual chain name and track collection from

the Chain histogram if present

reference chains

set up the plot panels

read config in from a file if requested ...

read the histos - 1 panel per histo

read in the panel descriptions

use the default values as single histogram panels

use the default panels

a better colour palette than the egregious root default

pointless root data types ...

Fixme: add the 2D histogram processing here ??

words can not express the sheer unpleasantness in trying to do anything serious with subpanels

  • if any margins between pads are set to 0, root messes up the pad margins so they are 0 with seemingly no way to prevent it - have to use a very small (but non 0) value, but then the margins don't size properly.
  • Once you cd() to one of the child pads, if you ask for the child GetWh() or GetWw() you don't get the parameters of the child pad, but the main pad etc

How are you supposed to get the paremeters of the actual pad ? It is insane.

histos within the panel

leave this code commented here for the time being ... if ( histo.name()=="pT" || histo.name()=="pT_rec" ) ypos = 0.19;

calculate all the postions for the items in the legend

legends ....

leave these comments here for testing ...

get the actual chain name and track collection from the Chain histogram if present

refit the resplots - get the 2d histogram and refit

get the test histogram

do we need these ? - keep for the time being ...

Actually DO refit the references - if we are adding together many resplots, then the means etc may not even have been calculated

leave this code commented here since we want to know where to change this in the future it was added for a reason, so is useful to keep for now

useful test for debugging ...

everything else

do we still need to prevent the x transaltion ? need to check ...

leave this code commented here since we want to know where to change this in the future it was added for a reason, so useful to keep for now

debugging ...

rebin if requested ...

now recalculate reference

leave for documentation purposes ...

again, this changes the external behaviour so we want to leave this "continue" in place, but commented

only set the plot name once )

replace the "/" in the filename so we don't try to make plots in subdirectories by accident

calculate and set axis limits

resolutions

calculate power

try to localise all axis range setting, log, lin scales etc to this one place

sort out the range settings for the xaxis ...

this stuff is tricky to get right - leave this here until we know it will no loner be needed

calculate the log range

keep the original equation by way of documentation ...

leave this code commented here since we want to know where to change this in the future it was added for a reason, so it is useful to keep for now
std::exit(-1);

calculate the required range such that the histogram labels won't crowd the points

actually draw the plot here ...

loop over histograms in panel

NB: now, we no longer print the individual plots - only the "panels" individual plots can still be printed by creating a "panel" which contains only that plots - in fast the "histos" item that before provided details of the separate plots is now interpreted as a list of single plot panels so this is done for you

loop over panels

if deleting all non-used reference histograms

make sure we are not using the same reference as test file

clean up reference file

copy the release tree

debugging ...

close files

now actually overwrite the old reference file

Definition at line 973 of file comparitor.cxx.

973 {
974
976
977 std::cout << black;
978 std::cout << "\n---------------------------------\n";
979 std::cout << "\n comparitor is off ...\n";
980
981 if ( argc<4 ) return usage(argv[0], -1, "too few arguments");
982
984
985 std::string tag = "";
986 std::string key = "";
987
988 std::string dir = "";
989
990 std::string ftestname = "";
991 std::string frefname = "";
992
993 TFile* ftest_ = 0;
994 TFile* fref_ = 0;
995
996 bool effset = false;
997 double effmin = 90;
998 double effmax = 102;
999
1000 std::string defreflabel = "";
1001
1003
1004 std::vector<std::string> usrlabels;
1005 bool uselabels = false;
1006 bool addinglabels = false;
1007
1008 std::vector<std::string> taglabels;
1009 std::vector<std::string> taglabels2;
1010 bool addingtags = false;
1011 bool addingtags2 = false;
1012
1013 bool lumiref_trans = false;
1014 bool lumitest_trans = false;
1015
1016 bool make_efficiencies = true;
1017
1018 bool make_ref_efficiencies = false;
1019 bool refit_resplots = false;
1020 bool refitref_resplots = false;
1021 bool bayes = true;
1022 bool nostats = false;
1023 bool nomeans = false;
1024 bool means = false;
1025 bool noref = false;
1026 bool atlasstyle = false;
1027 bool deleteref = false;
1028 bool nowatermark = false;
1029 bool noplots = false;
1030 bool nopng = false;
1031 bool nopdf = false;
1032 bool Cfile = false;
1033 bool notitle = true;
1034 bool dochi2 = false;
1035 bool normref = false;
1036 bool scalepix = false;
1037 bool oldrms = false;
1038 bool addchains = false;
1039 bool usechainref = false;
1040 bool quiet = false;
1041
1042 bool RANGEMAP = false;
1043 bool ALLRANGEMAP = false;
1044
1045 double xerror = 0;
1046
1047 std::string atlaslabel_tmp = "Internal";
1048
1049
1050 double scale_eff = -1;
1051 double scale_eff_ref = -1;
1052
1053 std::string configfile = "";
1054
1055 double xoffset = 0;
1056
1057
1058 double ypos_in = 0;
1059
1060 std::string pattern = "";
1061 std::string regex = "";
1062
1063 std::string patternr = "";
1064 std::string regexr = "";
1065
1066 std::string patternt = "";
1067 std::string regext = "";
1068
1069 std::string basedir = "";
1070
1071 std::string xpattern = "";
1072 std::string xregex = "";
1073
1074 std::vector<std::string> chains;
1075 std::vector<std::string> refchains;
1076
1077 bool addingrefchains = false;
1078
1079 std::string mapfile = "";
1080
1081 std::vector<std::string> chainfiles;
1082
1083 int ncols = 2;
1084
1085 std::string runnumber = "";
1086
1087 bool refbands = false;
1088
1089 for(int i=1; i<argc; i++){
1090 std::string arg = argv[i];
1091
1092 ifdbg( "\ncnt: " + arg );
1093
1094
1095 if ( arg.find('-')!=0 && addinglabels ) {
1096 std::string label = arg;
1097 fullreplace( label, "__", " " );
1098 replace( label, '#', ' ' );
1099 usrlabels.push_back( label );
1100 continue;
1101 }
1102 else addinglabels = false;
1103
1104 if ( arg.find('-')!=0 && addingrefchains ) {
1105 refchains.push_back( arg );
1106 continue;
1107 }
1108 else addingrefchains = false;
1109
1110 if ( arg.find('-')!=0 && addingtags ) {
1111 taglabels.push_back( fullreplace( arg, "__", " " ) );
1112 std::cout << "\tadding tag label: " << taglabels.back() << std::endl;
1113 continue;
1114 }
1115 else addingtags = false;
1116
1117 if ( arg.find('-')!=0 && addingtags2 ) {
1118 taglabels2.push_back( fullreplace( arg, "__", " " ) );
1119 std::cout << "\tadding tag label: " << taglabels2.back() << std::endl;
1120 continue;
1121 }
1122 else addingtags2 = false;
1123
1124 ifdbg( "starting if cascade: "+arg );
1125
1126 if ( arg=="-h" || arg=="--help" ) {
1127 return usage(argv[0], 0);
1128 }
1129 else if ( arg=="-c" || arg=="--config" ) {
1130 if ( ++i<argc ) configfile=argv[i];
1131 else return usage(argv[0], -1, "no config file provided");
1132 ifdbg("-c");
1133 }
1134 else if ( arg=="--jl" ) {
1135 JLflag = true;
1136 ifdbg("--jl");
1137 }
1138 else if ( arg=="--eps" ) {
1139 EPS = true;
1140 ifdbg("--eps");
1141 }
1142 else if ( arg=="-t" || arg=="--tag" ) {
1143 if ( ++i<argc ) tag=std::string("-")+argv[i];
1144 else return usage(argv[0], -1, "no tag provided");
1145 ifdbg("--tag");
1146 }
1147 else if ( arg=="-l" || arg=="--labels" ) {
1148 addinglabels = true;
1149 ifdbg("--labels");
1150 }
1151 else if ( arg=="-el" ) {
1152 LINES = true;
1153 ifdbg("-el");
1154 }
1155 else if ( arg=="-k" || arg=="--key" ) {
1156 if ( ++i<argc ) key=argv[i];
1157 else return usage(argv[0], -1, "no key provided");
1158 ifdbg("--key");
1159 }
1160 else if ( arg=="--run" ) {
1161 if ( ++i<argc ) runnumber=argv[i];
1162 else return usage(argv[0], -1, "no run number provided");
1163 ifdbg("--run");
1164 }
1165 else if ( arg=="-m" || arg=="--mapfile" ) {
1166 if ( ++i<argc ) mapfile=argv[i];
1167 else return usage(argv[0], -1, "no mapfile provided");
1168 ifdbg("--mapfile");
1169 }
1170 else if ( arg=="-d" || arg=="--dir" ) {
1171 if ( ++i<argc ) dir=argv[i];
1172 else return usage(argv[0], -1, "no directory provided");
1173 ifdbg("--dir");
1174 }
1175 else if ( arg=="--lumi" ) {
1176 lumitest_trans = true;
1177 lumiref_trans = true;
1178 ifdbg("--lumi");
1179 }
1180 else if ( arg=="--lumitest" ) {
1181 lumitest_trans = true;
1182 ifdbg("--lumitest");
1183 }
1184 else if ( arg=="--lumiref" ) {
1185 lumiref_trans = true;
1186 ifdbg("--lumiref");
1187 }
1188 else if ( arg=="-rb" || arg=="--refbands" ) {
1189 refbands = true;
1190 ifdbg("--refbands");
1191 }
1192 else if ( arg=="-b" || arg=="--bdir" ) {
1193 if ( ++i<argc ) basedir=argv[i];
1194 else return usage(argv[0], -1, "no directory provided");
1195 ifdbg("--bdir");
1196 }
1197 else if ( arg=="--taglabels" ) {
1198 addingtags = true;
1199 ifdbg("--taglabels");
1200 }
1201 else if ( arg=="--taglabels2" ) {
1202 addingtags2 = true;
1203 ifdbg("--taglabels2");
1204 }
1205 else if ( arg=="--unscalepix" ) {
1206 scalepix = false;
1207 ifdbg("--unscalepix");
1208 }
1209 else if ( arg=="--scalepix" ) {
1210 scalepix = true;
1211 ifdbg("--scalepix");
1212 }
1213 else if ( arg=="-ac" || arg=="--addchains" ) {
1214 addchains = true;
1215 ifdbg("--sddchains");
1216 }
1217 else if ( arg=="-yrange" ) {
1218 effset = true;
1219 if ( ++i<argc ) effmin=std::atof(argv[i]);
1220 else return usage(argv[0], -1, "no range specified");
1221 if ( ++i<argc ) effmax=std::atof(argv[i]);
1222 else return usage(argv[0], -1, "no upper y limit specified");
1223 ifdbg("-yrange");
1224 }
1225 else if ( arg=="-e" || arg=="--efficiencies" ) {
1226 make_ref_efficiencies = true;
1227 ifdbg("--efficiencies");
1228 }
1229 else if ( arg=="-r" || arg=="--refit" ) {
1230 refit_resplots = true;
1231 ifdbg("--refit");
1232 }
1233 else if ( arg=="-rr" || arg=="--refitref" ) {
1234 refitref_resplots = true;
1235 ifdbg("--refitref");
1236 }
1237 else if ( arg=="--oldrms" ) {
1238 oldrms = true;
1239 ifdbg("--oldrms");
1240 }
1241 else if ( arg=="-nw" || arg=="--nowatermark" ) {
1242 nowatermark = true;
1243 Plots::setwatermark(!nowatermark);
1244 ifdbg("--nowatermark");
1245 }
1246 else if ( arg=="--chi2" ) {
1247 dochi2 = true;
1248 ifdbg("--chi2");
1249 }
1250 else if ( arg=="-ns" || arg=="--nostats" ) {
1251 nostats = true;
1252 ifdbg("--nostats");
1253 }
1254 else if ( arg=="-nm" || arg=="--nomeans" ) {
1255 nomeans = true;
1256 ifdbg("--nomeans");
1257 }
1258 else if ( arg=="--means" ) {
1259 means = true;
1260 ifdbg("--means");
1261 }
1262 else if ( arg=="-nt" || arg=="--notitle" ) {
1263 notitle = true;
1264 ifdbg("--notitle");
1265 }
1266 else if ( arg=="-nr" || arg=="--noref" ) {
1267 Plotter::setplotref(false);
1268 noref = true;
1269 ifdbg("--noref");
1270 }
1271 else if ( arg=="--normref" ) {
1272 normref = true;
1273 ifdbg("--normref");
1274 }
1275 else if ( arg=="-rc" || arg=="--refchains" ) {
1276 addingrefchains = true;
1277 ifdbg("--refchains");
1278 }
1279 else if ( arg=="-uc" || arg=="--usechainref" ) {
1280 usechainref = true;
1281 ifdbg("--usechainref");
1282 }
1283 else if ( arg=="-nb" || arg=="--nobayes" ) {
1284 bayes = false;
1285 ifdbg("--nobayes");
1286 }
1287 else if ( arg=="-es" || arg=="--effscale" ) {
1288 if ( ++i<argc ) scale_eff=std::atof(argv[i]);
1289 else return usage(argv[0], -1, "no efficiency scale provided");
1290 ifdbg("--effscale");
1291 }
1292 else if ( arg=="-er" || arg=="--effscaleref" ) {
1293 if ( ++i<argc ) scale_eff_ref=std::atof(argv[i]);
1294 else return usage(argv[0], -1, "no efficiency scale for the reference histograms provided");
1295 ifdbg("--effscaleref");
1296 }
1297 else if ( arg=="--ncols" ) {
1298 if ( ++i<argc ) ncols=std::atoi(argv[i]);
1299 else return usage(argv[0], -1, "no number of columns provided");
1300 ifdbg("--ncols");
1301 }
1302 else if ( arg=="-np" || arg=="--noplots" ) {
1303 noplots = true;
1304 ifdbg("--noplots");
1305 }
1306 else if ( arg=="-C" || arg=="--Cfiles" ) {
1307 Cfile = true;
1308 ifdbg("--Cfiles");
1309 }
1310 else if ( arg=="--deleteref" ) {
1311 deleteref = true;
1312 ifdbg("--deleteref");
1313 }
1314 else if ( arg=="--nopng" ) {
1315 nopng = true;
1316 ifdbg("--nopng");
1317 }
1318 else if ( arg=="--nopdf" ) {
1319 nopdf = true;
1320 ifdbg("--nopdf");
1321 }
1322 else if ( arg=="-as" || arg=="--atlasstyle" ) {
1323 atlasstyle = true;
1324 // std::cout << "atlas style" << std::endl;
1325 ifdbg("--atlasstyle");
1326 }
1327 else if ( arg=="--tp" ) {
1328 make_efficiencies = false;
1329 ifdbg("--tp");
1330 }
1331 else if ( arg=="-q" || arg=="--quiet" ) {
1332 quiet = true;
1333 ifdbg("--quiet");
1334 }
1335 else if ( arg=="-al" || arg=="--atlaslabel" ) {
1336 if ( ++i<argc ) atlaslabel_tmp=argv[i];
1337 else return usage(argv[0], -1, "no label provided");
1338 ifdbg("--atlaslabel");
1339 }
1340 else if ( arg=="-xo" || arg=="--xoffset" ) {
1341 if ( ++i<argc ) xoffset=std::atof(argv[i]);
1342 else return usage(argv[0], -1, "no xoffset provided");
1343 ifdbg("--xoffset");
1344 }
1345 else if ( arg=="-yp" || arg=="--ypos" ) {
1346 if ( ++i<argc ) ypos_in=std::atof(argv[i]);
1347 else return usage(argv[0], -1, "no y position provided");
1348 ifdbg("--ypos");
1349 }
1350 else if ( arg=="-xe" || arg=="--xerror" ) {
1351 if ( ++i<argc ) xerror=std::atof(argv[i]);
1352 else return usage(argv[0], -1, "no x error provided");
1353 ifdbg("--xerror");
1354 }
1355 else if ( arg=="-s" || arg=="--swap" ) {
1356 if ( ++i<argc ) pattern=argv[i];
1357 else return usage(argv[0], -1, "no patterns provided");
1358 if ( ++i<argc ) regex=argv[i];
1359 else return usage(argv[0], -1, "no target pattern provided");
1360 ifdbg("--swap");
1361 }
1362 else if ( arg=="--swapt" ) {
1363 if ( ++i<argc ) patternt=argv[i];
1364 else return usage(argv[0], -1, "no patterns provided");
1365 if ( ++i<argc ) regext=argv[i];
1366 else return usage(argv[0], -1, "no target pattern provided");
1367 ifdbg("--swapt");
1368 }
1369 else if ( arg=="--swapr" ) {
1370 if ( ++i<argc ) patternr=argv[i];
1371 else return usage(argv[0], -1, "no patterns provided");
1372 if ( ++i<argc ) regexr=argv[i];
1373 else return usage(argv[0], -1, "no target pattern provided");
1374 ifdbg("--swapr");
1375 }
1376 else if ( arg=="-sx" || arg=="--swapaxtitles" ) {
1377 if ( ++i<argc ) xregex=argv[i];
1378 else return usage(argv[0], -1, "no target pattern provided");
1379 if ( ++i<argc ) xpattern=argv[i];
1380 else return usage(argv[0], -1, "no patterns provided");
1381 ifdbg("--swapxtitles");
1382 }
1383 else if ( arg.find('-')==0 ) {
1384 std::cerr << "unknown option: " << arg << "\n" << std::endl;
1385 return usage(argv[0], -4);
1386 }
1387 else {
1388 ifdbg("arg: + "+arg);
1389 if ( ftestname=="" ) ftestname = arg;
1390 else if ( frefname=="" ) frefname = arg;
1391 else {
1392 std::string file = "";
1393
1394 if ( arg.find(":file:")!=std::string::npos ) {
1395 file = arg.substr( 0, arg.find(":file:") );
1396 chainfiles.push_back( file );
1397 arg = arg.substr(arg.find(":file:")+6,arg.size());
1398 }
1399
1400 std::string chain = arg;
1401
1402 replace ( chain, ':', '_' );
1403 replace ( chain, ';', '_' );
1404 chains.push_back(chain);
1405
1406 std::cout << "file: " << file << "\tchain: " << chain << std::endl;
1407
1408 }
1409 }
1410 }
1411
1412 if ( ftestname.empty() ) {
1413 std::cerr << "main(): test file not specified " << std::endl;
1414 return -1;
1415 }
1416
1417 if ( !exists(ftestname) ) {
1418 std::cerr << "main(): test file " << ftestname << " does not exist" << std::endl;
1419 return -1;
1420 }
1421
1422 std::vector<TFile*> chainTFiles;
1423
1424 if ( chainfiles.size()==0 ) ftest_ = TFile::Open( ftestname.c_str() );
1425 else {
1426 noref=true;
1427 chainTFiles.resize(chainfiles.size());
1428 for ( size_t i=0 ; i<chainfiles.size() ; i++ ) {
1429 chainTFiles[i] = TFile::Open( chainfiles[i].c_str() );
1430 if ( chainTFiles[i] == 0 ) {
1431 std::cerr << "\tfile: " << chainfiles[i] << " could not be opened" << std::endl;
1432 return -1;
1433 }
1434 else std::cout << "\tchainfiles: " << chainfiles[i] << " " << chainTFiles[i] << std::endl;
1435 }
1436 }
1437
1438
1439 if ( noref==false ) {
1440 if ( frefname.empty() ) {
1441 std::cerr << "main(): ref file not specified " << std::endl;
1442 Plotter::setplotref(false);
1443 noref = true;
1448 // return -1;
1449 }
1450
1451 if ( frefname==ftestname ) fref_ = ftest_;
1452 else if ( exists(frefname) ) fref_ = TFile::Open( frefname.c_str() );
1453 else {
1454 std::cerr << "main(): ref file " << frefname << " does not exist" << std::endl;
1455 // return -1;
1456 Plotter::setplotref(false);
1457 noref=true;
1458 }
1459 }
1460 else fref_ = ftest_;
1461
1462 if ( chainfiles.size()==0 ) {
1463 if ( ftest_==0 ) {
1464 std::cerr << "could not open test file " << ftestname << std::endl;
1465 return -1;
1466 }
1467
1468 if ( noref==false && fref_==0 ) {
1469 std::cerr << "could not open files " << std::endl;
1473 noref=true;
1474 fref_=ftest_;
1475 defreflabel = "failed to open reference file";
1476 }
1477
1478 }
1479
1480 if ( scale_eff == -1 ) scale_eff = 100;
1481 if ( scale_eff_ref == -1 ) scale_eff_ref = scale_eff;
1482
1483
1484 bool noreftmp = noref;
1485
1486 if ( chains.size()==0 ) return usage(argv[0], -1, "no chains specified");
1487
1488
1489 if ( basedir.size()>0 ) {
1490 if ( basedir[basedir.size()-1]!='/' ) basedir += "/";
1491 for ( size_t ic=chains.size() ; ic-- ; ) chains[ic] = basedir+chains[ic];
1492 }
1493
1494 if ( refchains.size()>0 && refchains.size()!=chains.size() ) return usage(argv[0], -1, "not enough chains specified");
1495
1496 if ( refchains.size()==0 ) refchains = chains;
1497
1498 std::vector<std::string> chainref(chains.size(),"");
1499 std::vector<std::string> chain_name(chains.size(),"");
1500
1501 std::vector<std::string> refchain(chainref.size(),"");
1502
1503
1504
1505 std::cout << argv[0] << " options:" << std::endl;
1506 std::cout << "\tATLAS style: " << ( atlasstyle ? "true" : "false" ) << std::endl;
1507 std::cout << "\tBayesian uncertainties: " << ( bayes ? "true" : "false" ) << std::endl;
1508 std::cout << "\trefit resplot uncertainties: " << ( refit_resplots ? "true" : "false" ) << std::endl;
1509 std::cout << "\tsuppress mean and rms stats: " << ( nostats ? "true" : "false" ) << std::endl;
1510 if ( !nostats ) std::cout << "\tsuppress meanstats: " << ( nomeans ? "true" : "false" ) << std::endl;
1511 std::cout << "\tsuppress png output: " << ( nopng ? "true" : "false" ) << std::endl;
1512 std::cout << "\tsuppress pdf output: " << ( nopdf ? "true" : "false" ) << std::endl;
1513 std::cout << "\tsuppress reference output: " << ( noref ? "true" : "false" ) << std::endl;
1514 std::cout << "\tuse chain references: " << ( usechainref ? "true" : "false" ) << std::endl;
1515 std::cout << "\tpanel ncols: " << ncols << std::endl;
1516
1517 if ( usrlabels.size()>0 ) std::cout << "\tlabels: " << usrlabels.size() << std::endl;
1518 if ( taglabels.size()>0 ) std::cout << "\textra text: " << taglabels << std::endl;
1519 if ( taglabels2.size()>0 ) std::cout << "\textra text: " << taglabels2 << std::endl;
1520
1521
1522 for ( size_t il=0 ; il<usrlabels.size() ; il++ ) {
1523 std::cout << "usr label[" << il << "] : " << usrlabels[il] << std::endl;
1524 }
1525
1526 std::cout << "atlas style : " << atlasstyle << std::endl;
1527
1528 if ( atlasstyle ) {
1529 SetAtlasStyle();
1530 gStyle = AtlasStyle();
1531 gStyle->cd();
1532 }
1533 else {
1534 gROOT->SetStyle("Plain");
1535 gStyle->cd();
1536 gStyle->SetLineScalePS(1);
1537 xoffset += 0.02;
1538 }
1539
1540 gStyle->SetErrorX(xerror);
1541
1542 gStyle->SetPadLeftMargin(0.15);
1543 gStyle->SetPadBottomMargin(0.15);
1544
1545 gStyle->SetPadRightMargin(0.02);
1546 gStyle->SetPadTopMargin(0.05);
1547
1548 std::cout << "Chains: " << std::endl;
1549 for ( unsigned ic=0 ; ic<chains.size() ; ic++ ) std::cout << "\t" << chains[ic] << std::endl;
1550
1551 if ( usrlabels.size()>0 ) std::cout << "labels: " << usrlabels << std::endl;
1552
1553 if ( usrlabels.size()>0 && usrlabels.size()==chains.size() ) uselabels = true;
1554
1556
1557 TTree* dataTree = 0;
1558 TString* releaseData = new TString("");
1559 std::vector<std::string> release_data;
1560
1561
1562 if ( !nowatermark && ftest_ ) {
1563
1564 dataTree = (TTree*)ftest_->Get("dataTree");
1565
1566 if ( dataTree ) {
1567 dataTree->SetBranchAddress( "ReleaseMetaData", &releaseData);
1568
1569 for (unsigned int i=0; i<dataTree->GetEntries() ; i++ ) {
1570 dataTree->GetEntry(i);
1571 release_data.push_back( releaseData->Data() );
1572 std::cout << "main() release data: " << release_data.back() << " : " << *releaseData << std::endl;
1573 }
1574 }
1575
1576 std::cout << "release data size " << release_data.size() << std::endl;
1577
1578 if ( release_data.size()>0 ) {
1579 if ( release_data.size()>1 ) std::cerr << "main() more than one release - using only the first" << std::endl;
1580
1581 // std::cout << "release: " << chop(release_data[0], " " ) << std::endl;
1582
1583 std::string rd = release_data[0];
1584
1585 while ( rd.size()>0 ) {
1586
1587 std::string nightly = chop(rd, " " );
1588
1589 if ( contains(nightly,"private" ) ) {
1590 for ( int ic=0 ; ic<4 ; ic++ ) chop(release_data[0], " " );
1591 release += " (" + release_data[0]+")";
1592 break;
1593 }
1594 else {
1595
1596 if ( contains(nightly,"nightly") ) {
1597 chop( nightly,"/" );
1598 release += " ( " + chop( nightly,"/");
1599 release += " " + chop(nightly, "/" ) + " )";
1600 break;
1601 }
1602
1603 }
1604 }
1605 }
1606 }
1607
1608 std::cout << "release: " << release << std::endl;
1609
1610
1611 // Make output directory
1612 if (!dir.empty()) {
1613
1614 gDirectory->pwd();
1615
1616 std::cout << "trying to make directory" << std::endl;
1617 dir += '/';
1618 if ( !quiet && !noplots && !exists(dir) ) {
1619 if ( mkdir( dir.c_str(), 0777 ) ) std::cerr << "main() couldn't create directory " << dir << std::endl;
1620 else std::cout << "main() output will be sent to directory " << dir << std::endl;
1621 }
1622 }
1623
1624 if ( ftest_==0 && chainTFiles.size()>0 ) fref_ = ftest_ = chainTFiles[0];
1625
1626 TFile* ftest = ftest_;
1627 TFile* fref = fref_;
1628
1629 std::string testrun = findrun( ftest );
1630
1631 std::string rawrefrun = "";
1632 std::string refrun = "";
1633
1634 if ( fref_ ) refrun = rawrefrun = findrun( fref );
1635
1636 std::cout << "testrun: " << testrun << "\nrefrun: " << refrun << std::endl;
1637
1638 if ( !testrun.empty() && refrun != testrun ) {
1639 if ( pattern.empty() ) {
1640 pattern = testrun;
1641 regex = refrun;
1642 }
1643
1644 }
1645
1646 if ( !refrun.empty() ) {
1647
1648 std::string newtag = "Reference: ";
1649
1650 std::cout << "refrun: " << refrun << std::endl;
1651
1652 size_t pos;
1653 while ( (pos=refrun.find('_'))!=std::string::npos ) refrun.replace( pos, 1, " " );
1654 newtag += refrun;
1655
1656 std::string rawrun = refrun.erase( refrun.find("run"), 4 );
1657
1658 if ( contains(frefname, rawrun) ) {
1659
1660 std::string release = frefname;
1661
1662 release.erase( 0, release.find(rawrun) );
1663
1664 if ( contains(release,"HIST") ) release.erase( 0, release.find("HIST")+5 );
1665 while ( contains(release,".") ) release.erase( release.find('.'), release.size() );
1666 while ( contains(release,"-") ) release.erase( release.find('-'), release.size() );
1667 while ( contains(release,"_p") ) release.erase( release.find("_p"), release.size() );
1668 while ( contains(release,"_t") ) release.erase( release.find("_t"), release.size() );
1669
1670 newtag += " ";
1671 newtag += release;
1672
1673 }
1674
1675 taglabels.push_back( newtag );
1676
1677 std::cout << "tag labels: " << taglabels << std::endl;
1678
1679 }
1680
1685 int NeventTest = 1;
1686 int NeventRef = 1;
1687
1688
1689 std::vector<std::string> savedhistos;
1690
1691
1692 if ( !nowatermark ) {
1693
1694
1695 TH1D* htestev = (TH1D*)ftest->Get("event") ;
1696 TH1D* hrefev = (TH1D*)fref->Get("event") ;
1697
1698
1699
1700 std::cout << "htestev " << htestev << " " << hrefev << std::endl;
1701
1702 if ( htestev ) NeventTest = htestev->GetEntries();
1703 if ( hrefev ) NeventRef = hrefev->GetEntries();
1704
1705 savedhistos.push_back("event");
1706 }
1707 else {
1708 NeventTest = 1;
1709 NeventRef = 1;
1710 }
1711
1712
1713 if ( NeventTest>1 ) std::cout << "Nevents Test: " << NeventTest << std::endl;
1714 if ( NeventRef>1 ) std::cout << "Nevents Ref: " << NeventRef << std::endl;
1715
1716 chainmap_t* chainmap = nullptr;
1717
1718 if ( mapfile.empty() ) mapfile = configfile;
1719
1720
1721 std::cout << "mapfile: " << mapfile << std::endl;
1722
1723 if ( !mapfile.empty() ) {
1724
1725 ReadCards m( mapfile );
1726
1727 if ( m.isTagDefined( "ChainMap" ) ) {
1728
1729 std::vector<std::string> chains = m.GetStringVector( "ChainMap" );
1730
1731 for ( size_t i=0 ; i<chains.size() ; i+=2 ) std::cout << "map: " << chains[i] << " -> " << chains[i+1] << std::endl;
1732
1733 chainmap = new chainmap_t();
1734
1735 for ( size_t i=0 ; i<chains.size() ; i+=2 ) {
1736 chainmap->insert( chainmap_t::value_type( chains[i], chains[i+1] ) );
1737 }
1738
1739 std::cout << "\nusing chain map:" << std::endl;
1740
1741 for ( chainmap_t::iterator itr=chainmap->begin() ; itr!=chainmap->end() ; itr++ ) { //cppcheck-suppress postfixOperator
1742 std::cout << "\t" << itr->first << "\t" << itr->second << std::endl;
1743 }
1744 }
1745 }
1746
1748
1749 std::cout << "\ncreating chain and reference information ..." << std::endl;
1750
1751 for ( size_t j=0; j<chains.size(); j++) {
1752
1753 if ( !regex.empty() ) chains[j] = fullreplace( chains[j], pattern, regex );
1754 if ( !regext.empty() ) chains[j] = fullreplace( chains[j], patternt, regext );
1755
1757
1759 std::cout << "chain: " << chains[j] << "\taddchains: " << addchains << std::endl;
1760
1761 if ( addchains && ( contains(chains[j],"Shifter") || ( !contains(chains[j],"HLT_") && !contains(chains[j], "Fullscan" ) ) ) ) {
1762
1763 TFile* fftest = ftest;
1764
1765 if ( chainfiles.size()>0 && chainfiles.size()>j ) fftest = chainTFiles[j];
1766
1767 TH1F* hchain = Get( *fftest, chains[j]+"/Chain", testrun );
1768
1769 if ( hchain ) {
1770
1771 std::string name = hchain->GetTitle();
1772
1773 if ( usechainref && !contains(chains[j],"Purity") ) {
1774
1775 chainref[j] = name;
1776
1777 std::cout << "new chainref: " << chainref[j] << std::endl;
1778
1779 std::string::size_type pos = chainref[j].find(":for");
1780 if ( pos!=std::string::npos ) chainref[j].replace( pos, 4, "_for" );
1781 std::replace( chainref[j].begin(), chainref[j].end(), ':', '/');
1782 std::string newchain = dirname( dirname( chains[j]) ) + "/Expert/" + chainref[j];
1783 chainref[j] = newchain;
1784
1785 std::cout << "final chainref: " << chainref[j] << std::endl;
1786
1787 }
1788
1789 std::cout << "chainref: " << chainref[j] << std::endl;
1790
1791 while ( contains( name, "HLT_" ) ) name = name.erase( name.find("HLT_"), 4 );
1792
1793 std::cout << "name: " << name << std::endl;
1794
1795 if ( contains( name, ":" ) ) chain_name[j] = name.substr( 0, name.find(':') ) + " : ";
1796 else chain_name[j] = name;
1797
1798 if ( chain_name[j] == " : " ) chain_name[j] = "";
1799
1800 std::cout << "chain_name: " << chain_name[j] << std::endl;
1801 }
1802 }
1803 }
1804
1805 std::cout << "chainref size: " << chainref.size() << " " << refchains.size() << std::endl;
1806
1807 for ( size_t j=0 ; j<chainref.size() ; j++ ) {
1808 std::cout << "chainref: " << chainref[j] << " :: " << refchains[j] << std::endl;
1809
1811 if ( chainref[j]!="" ) refchain[j] = fullreplace( chainref[j], pattern, regex );
1812 else refchain[j] = fullreplace( refchains[j], pattern, regex );
1813
1814 if ( !patternr.empty() ) {
1815 if ( chainref[j]!="" ) refchain[j] = fullreplace( chainref[j], patternr, regexr );
1816 else refchain[j] = fullreplace( refchains[j], patternr, regexr );
1817 }
1818
1819 std::cout << "refchain: " << refchain[j] << std::endl;
1820 }
1821
1822 std::cout << "done chains" << std::endl;
1823
1825
1826 std::vector<Panel> panels;
1827
1829
1830 bands bnd;
1831
1832
1833 std::vector<int> ccolours;
1834 std::vector<int> cstyles;
1835
1836 std::vector<std::string> ctags;
1837 std::vector<std::string> ctaglabels;
1838
1839
1840 std::cout << "\n" << argv[0] << "\tconfigfile: " << configfile << std::endl;
1841
1842 bool use_file_config = false;
1843
1844 if ( !configfile.empty() ) {
1845
1846 if ( exists(configfile) ) {
1847
1848 std::cout << argv[0] << ":\treading configuration file " << configfile << std::endl;
1849
1850 ReadCards rc(configfile);
1851
1853
1854 std::cout << "searching for panels" << std::endl;
1855
1857
1858 if ( rc.isTagDefined( "panels" ) ) {
1859
1860 std::cout << argv[0] << ":\treading histogram panel configuration from file " << configfile << std::endl;
1861
1862 use_file_config = true;
1863
1864 std::vector<std::string> panel_config = rc.GetStringVector( "panels" );
1865
1866 std::vector<string> panel_columns;
1867
1868 if ( rc.isTagDefined("panel_columns") ) {
1869 panel_columns = rc.GetStringVector( "panel_columns" );
1870 if ( panel_columns.size()%2 ) return usage( argv[0], -1, "incorrect panel settings" );
1871 }
1872
1873
1874 for ( size_t ipanel=panel_config.size() ; ipanel-- ; ) {
1875
1876 std::vector<std::string> raw_input = rc.GetStringVector( panel_config[ipanel] );
1877
1878 int tncols = ncols;
1879
1880 if ( panel_columns.size() ) {
1881 std::vector<string>::iterator itr = find( panel_columns.begin(), panel_columns.end(), panel_config[ipanel] );
1882 if ( itr!=panel_columns.end() ) tncols = std::atoi( (++itr)->c_str() );
1883 }
1884
1885 Panel p( panel_config[ipanel], tncols );
1886
1887 if ( raw_input.empty() ) {
1888 std::cerr << "no plots provided" << std::endl;
1889 return 1;
1890 }
1891
1892 for ( size_t iraw=0 ; iraw+6<=raw_input.size() ; iraw += 6 ) p.push_back( raw_input.begin()+iraw, raw_input.begin()+iraw+6 );
1893
1894 panels.push_back( p );
1895
1896 }
1897
1898 }
1899 else if ( rc.isTagDefined( "histos" ) ) {
1900
1901 std::cout << argv[0] << ":\treading histogram configuration from file " << configfile << std::endl;
1902
1903 use_file_config = true;
1904
1905 std::vector<std::string> raw_input = rc.GetStringVector( "histos" );
1906
1907 for ( size_t iraw=0 ; iraw+6<=raw_input.size() ; iraw += 6) {
1908 HistDetails h( raw_input.begin()+iraw, raw_input.begin()+iraw+6 );
1909 Panel p( h.name(), 1 );
1910 p.push_back( h );
1911 panels.push_back( p );
1912 }
1913
1914 }
1915
1916 if ( rc.isTagDefined( "Bands" ) && rc.isTagDefined( "Labels" ) ) {
1917 bnd = bands( rc.GetVector( "Bands"), rc.GetStringVector( "Labels" ) );
1918 }
1919
1920
1921 if ( rc.isTagDefined("Colours") ) {
1922
1923 std::vector<int> ccolours = rc.GetIntVector("Colours");
1924
1925 std::cout << "remap colours: " << ccolours << std::endl;
1926
1927 int new_colours[6];
1928
1929 for ( size_t i=6 ; i-- ; ) new_colours[i] = colours[i];
1930
1931 for ( size_t i=0 ; i<ccolours.size() && i<6 ; i++ ) {
1932 if ( ccolours[i]<6 ) new_colours[i] = colours[ccolours[i]];
1933 }
1934
1935 for ( size_t i=6 ; i-- ; ) colours[i] = new_colours[i];
1936
1937 }
1938
1939
1940 if ( rc.isTagDefined("Styles") ) {
1941
1942 std::vector<int> cstyles = rc.GetIntVector("Styles");
1943
1944 std::cout << "remap markers: " << cstyles << std::endl;
1945
1946 int new_markers[6];
1947
1948 for ( size_t i=6 ; i-- ; ) new_markers[i] = markers[i];
1949
1950 for ( size_t i=0 ; i<cstyles.size() && i<6 ; i++ ) {
1951 if ( cstyles[i]<6 ) new_markers[i] = markers[cstyles[i]];
1952 }
1953
1954 for ( size_t i=6 ; i-- ; ) markers[i] = new_markers[i];
1955
1956 }
1957
1958 if ( fulldbg ) {
1959 for ( int i=6 ; i-- ; ) std::cout << "\tcolours[" << i << "] = " << colours[i] << std::endl;
1960 for ( int i=6 ; i-- ; ) std::cout << "\tmarkers[" << i << "] = " << markers[i] << std::endl;
1961 }
1962
1963 if ( rc.isTagDefined("Tags") ) ctags = rc.GetStringVector("Tags");
1964 if ( rc.isTagDefined("TagLabels") ) ctaglabels = rc.GetStringVector("TagLabels");
1965 if ( rc.isTagDefined("TagLabels") ) usrlabels = rc.GetStringVector("TagLabels");
1966
1967
1968 if ( rc.isTagDefined("Styles") ) {
1969 for ( size_t is=0 ; is<cstyles.size() && is<6 ; is++ ) {
1970 markers[is] = cstyles[is];
1971 }
1972 }
1973
1974
1975 uselabels = true;
1976
1977
1978 std::cout << argv[0] << "\tuserlabels :" << usrlabels << ":" << std::endl;
1979
1980 if ( rc.isTagDefined("RANGEMAP") ) RANGEMAP = true;
1981 if ( rc.isTagDefined("ALLRANGEMAP") ) ALLRANGEMAP = true;
1982
1983 std::cout << "Extra: " << rc.isTagDefined("Extra") << std::endl;
1984
1985 if ( rc.isTagDefined("Extra") ) taglabels.push_back( fullreplace( rc.GetString("Extra"), "__", " " ) );
1986
1987
1988 }
1989 else {
1990 std::cerr << argv[0] << ":\t config file not found: " << configfile << std::endl;
1991 return -1;
1992 }
1993
1994 }
1995
1996 if ( !use_file_config ) {
1997
1998 std::cout << "using default panels" << std::endl;
1999
2001
2002 // for ( size_t iraw=0 ; iraw<histos_default.size() ; iraw++ ) {
2003 // Panel p( histos_default[iraw][0], 1 );
2004 // p.push_back( histos_default[iraw] );
2005 // panels.push_back( p );
2006 // }
2007
2008 // default panel efficiencies plotted from 0 to 100,
2009 // so scale efficiencies no matter what
2010
2011 scale_eff = 1;
2012 scale_eff_ref = 1;
2013
2015
2016 std::vector<panel_type> inpanels = { eff_panel, res_panel, diff_panel };
2017
2018 std::string pnames[3] = { "eff", "res", "diff" };
2019
2020 for ( size_t ip=0 ; ip<inpanels.size() ; ip++ ) {
2021 Panel p( pnames[ip]+"_panel", 2 );
2022 for ( size_t ih=0 ; ih<inpanels[ip].size() ; ih++ ) p.push_back( inpanels[ip][ih] );
2023 panels.push_back( p );
2024 }
2025
2026 }
2027
2028
2029 std::cout << "taglabels" << std::endl;
2030
2031 for ( size_t it=0 ; it<taglabels.size() ; it++ ) std::cout << taglabels[it] << std::endl;
2032 for ( size_t it=0 ; it<taglabels2.size() ; it++ ) std::cout << taglabels2[it] << std::endl;
2033
2034
2035 std::cout << "\npanels: " << panels.size() << std::endl;
2036
2037 if ( panels.size()==0 ) return usage(argv[0], -1, "no panels to plot");
2038
2039 for ( size_t ip=0 ; ip<panels.size() ; ip++ ) std::cout << panels[ip] << std::endl;
2040
2041
2043 if ( true ) {
2044 gStyle->SetPadRightMargin(0.05);
2045 gStyle->SetPadTopMargin(0.05);
2046
2048 const Int_t Number = 3;
2049 Double_t Red[Number] = { 0.00, 0.00, 1.00 };
2050 Double_t Green[Number] = { 0.00, 5.00, 1.00 };
2051 Double_t Blue[Number] = { 0.00, 0.50, 0.00 };
2052 Double_t Length[Number] = { 0.00, 0.50, 1.00 };
2053 Int_t nb = 50;
2054 TColor::CreateGradientColorTable( Number, Length, Red, Green, Blue, nb );
2055 }
2056 else gStyle->SetPalette(1);
2057
2058 if ( fulldbg ) std::cout << __LINE__ << std::endl;
2059
2060 double rightmargin = gStyle->GetPadRightMargin();
2061 gStyle->SetPadRightMargin(0.1);
2062
2064
2065 gStyle->SetPadRightMargin(rightmargin);
2066
2067 // gStyle->SetLineScalePS(1);
2068
2069 for ( size_t ipanel=0 ; ipanel<panels.size() ; ipanel++ ) {
2070
2071 Panel& panel = panels[ipanel];
2072
2073 std::cout << blue << "\n\n---------------------------------------------\n" << reset;
2074
2075 std::cout << panel << "\n" << std::endl;
2076
2077 int ncolsp = panel.ncols();
2078 int nrowsp = panel.nrows();
2079
2080 double extraw = 1;
2081
2082 std::cout << "\nncols: " << ncolsp << "\tnrows: " << nrowsp << std::endl;
2083
2084 bool multipanel = ( panel.size() > 1 );
2085
2086 if ( panel.size()==0 ) {
2087 std::cout << "panel empty: " << panel.name() << std::endl;
2088 continue;
2089 }
2090
2091 gStyle->cd();
2092
2093 if ( panel.size()>4 ) gStyle->SetLineScalePS(0.5);
2094
2095 if ( multipanel ) extraw = 1.05;
2096
2097 TCanvas* tc = new TCanvas( "tc", "", extraw*ncolsp*800, nrowsp*600 );
2098
2099 tc->cd();
2100
2101 const std::string& atlaslabel = atlaslabel_tmp;
2102
2103 if ( multipanel ) {
2104
2105 gStyle->SetLineScalePS(1);
2106
2109
2117
2120
2121 tc->Divide( ncolsp, nrowsp, 0.0001, 0.0003 );
2122 // atlaslabel = " " + atlaslabel_tmp;
2123 }
2124
2126
2127 std::string plotname = "";
2128
2129 for ( size_t i=0 ; i<panel.size() ; i++ ) {
2130
2131 HistDetails histo = panel[i];
2132
2133 bool drawmeans = false;
2134 bool drawresiduals = true;
2135
2136 // if ( contains(histo.detail(), "+mean" ) || means ) drawmeans = true;
2137 if ( contains(histo.detail(), "+mean" ) ) drawmeans = true;
2138 if ( contains(histo.detail(), "-residual") ) drawresiduals = false;
2139
2140 std::string xaxis = histo.xtitle();
2141 std::string yaxis = histo.ytitle();
2142
2143 if ( !xregex.empty() ) {
2144 size_t pos = xaxis.find(xregex);
2145 if ( pos!=std::string::npos ) xaxis.replace( pos, xregex.size(), xpattern );
2146 pos = yaxis.find(xregex);
2147 if ( pos!=std::string::npos ) yaxis.replace( pos, xregex.size(), xpattern );
2148 }
2149
2150 const AxisInfo& xinfo = histo.xaxis();
2151 const AxisInfo& yinfo = histo.yaxis();
2152
2153 // AxisInfo xinfo = histo.xaxis();
2154 // AxisInfo yinfo = histo.yaxis();
2155
2156 std::string hname = histo.name();
2157 std::string detail = histo.detail();
2158
2159 bool translate_x = false;
2160
2161 if ( ( lumiref_trans || lumitest_trans ) && contains(histo.xtitle(), "Pile-up" ) ) translate_x = true;
2162
2163#if 0
2165 if ( translate_x ) {
2166 xinfo.lo( xinfo.lo()*(1-0.054) );
2167 xinfo.lo(10);
2168 xinfo.hi( xinfo.hi()*(1-0.054) );
2169 }
2170#endif
2171
2172 double rebin = 1;
2173
2174#ifdef D0REBIN
2175 bool d0rebin_flag = false;
2176
2177 if ( contains( detail, "+d0rebin" ) ) d0rebin_flag = true;
2178#endif
2179
2180 if ( contains( detail, "+Rebin" ) ) {
2181 rebin = std::atof( detail.substr( detail.find("+Rebin")+6, detail.size() ).c_str() );
2182 }
2183
2184 if ( contains( detail, "+rebin" ) ) {
2185 rebin = std::atof( detail.substr( detail.find("+rebin")+6, detail.size() ).c_str() );
2186 }
2187
2188 int labelcolour = kBlack;
2189
2190 int npanel = nrowsp*(i/nrowsp) + i%nrowsp + 1 ;
2191
2192 std::cout << "panel: panel: " << panel.name() << "\tsubpanel: " << npanel << std::endl;
2193
2194 if ( multipanel ) tc->cd( npanel );
2195
2196 SetAtlasStyle();
2197
2198 noreftmp = noref;
2199
2200 Plotter::setplotref(!noreftmp);
2201
2202 if ( fulldbg ) std::cout << __LINE__ << std::endl;
2203
2204 std::cout << "main() processing histo[" << i << "] " << (i<10 ? " " : "" ) << histo.name() << "\t" << histo.xaxis() << std::endl;
2205
2206 Plots plots_eff( "", yinfo.trim() );
2207 plots_eff.clear();
2208
2209 Plots plots( "", yinfo.trim() );
2210 plots.clear();
2211
2212 std::string noreflabel=defreflabel;
2213
2214 double xpos = 0.18;
2215 double ypos = 0.91;
2216
2217 if ( contains(histo.name(),"eff") || contains(histo.name(),"Eff_") ) ypos = 0.19;
2218
2219 // ypos = 0.19;
2220
2223
2224 if ( atlasstyle ) {
2225 xpos = 0.18;
2226 if ( ypos>0.5 ) ypos = 0.85;
2227 else ypos = 0.18;
2228 }
2229
2230 if ( ypos_in!=0 ) ypos = ypos_in;
2231
2232 double xpos_original = xpos;
2233
2234 xpos += xoffset;
2235
2236 if ( xinfo.offset() != 0 ) {
2237
2238 std::cout << "HA ! xinfo.offset: " << xinfo.offset() << std::endl;
2239
2240 xpos = xinfo.offset();
2241
2242 }
2243
2244
2245 if ( yinfo.offset() != 0 ) {
2246
2247 std::cout << "HA ! yinfo.offset: " << yinfo.offset() << std::endl;
2248
2249 ypos = yinfo.offset();
2250
2251 }
2252
2253
2254
2256
2257 size_t Nrows = chains.size();
2258
2259 if ( ALLRANGEMAP || (RANGEMAP && xaxis.find("p_{T}")!=std::string::npos && ccolours.size() ) ) {
2260 Nrows = ( Nrows < ccolours.size() ? Nrows : ccolours.size() );
2261 }
2262
2263 int Nlines = Nrows + taglabels.size();
2264
2265 std::vector<double> ypositions;
2266 std::vector<double> ypositions2;
2267
2268 double deltay = (Nrows*0.055-0.005)/Nrows;
2269
2270 double ylo = ypos;
2271 double yhi = ypos-0.01;
2272
2273 if ( ypos>0.5 ) ylo -= Nlines*deltay;
2274 else yhi += Nlines*deltay;
2275
2276 ypositions.reserve(Nlines);
2277 for ( int ilines=0 ; ilines<Nlines ; ilines++ ) {
2278 ypositions.push_back( yhi - deltay*(ilines+0.5) );
2279 ypositions2.push_back( yhi - deltay*(ilines-0.5) );
2280 }
2281
2282 // specify different legends for efficiencies or residuals?
2283
2285
2286 if ( JLflag ) {
2287 ylo -= 0.02;
2288 }
2289 else {
2290 if ( !contains(histo.name(),"eff") && !contains(histo.name(),"Eff_") ) ylo -= 0.02;
2291 }
2292
2293 Legend legend( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
2294 Legend legend_eff( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
2295
2296
2297 std::vector<std::string> Mean;
2298 std::vector<std::string> MeanLF;
2299 std::vector<std::string> RMS;
2300
2301 Mean.clear();
2302 MeanLF.clear();
2303 RMS.clear();
2304
2305 std::vector<std::string> Chi2;
2306 std::vector<std::string> MeanRef;
2307 std::vector<std::string> RMSRef;
2308
2309 // int colours[6] = { 1, 2, 4, 6, 7, 8 };
2310
2311 Chi2.clear();
2312 MeanRef.clear();
2313 RMSRef.clear();
2314
2315 int mean_power = 0;
2316 int rms_power = 0;
2317 bool power_set = false;
2318
2319 LINEF = true;
2320
2322 // bool uselogx = xinfo.log();
2323 // bool uselogy = yinfo.log();
2324
2325 for ( unsigned int j=0; j<chains.size(); j++) {
2326
2327 bool d0mod = false;
2328
2329 TFile* fftest = ftest;
2330 TFile* ffref = fref;
2331
2332 std::string cc = ftest->GetName();
2333 std::string cr = "";
2334
2335 if ( fref ) cr = fref->GetName();
2336
2337 if ( chainfiles.size()>0 && chainfiles.size()>j ) ffref = fftest = chainTFiles[j];
2338
2341
2342 std::cout << "chain: " << chains[j] << "\taddchains: " << addchains << std::endl;
2343 std::cout << "chainref: " << chainref[j] << std::endl;
2344
2345 noreftmp = noref;
2346 Plotter::setplotref(!noreftmp);
2347
2348 TH1F* htest = 0;
2349 TH1F* href = 0;
2350
2351 TH1F* htestnum = 0;
2352 TH1F* htestden = 0;
2353 TH1F* hrefnum = 0;
2354
2355 TH2D* h2test = 0;
2356
2357 TGraphAsymmErrors* tgtest = 0;
2358
2359 std::cout << "refchain.size() " << refchain.size() << std::endl;
2360
2361 std::cout << "refchain: " << refchain[j] << std::endl;
2362
2364
2365 gPad->SetRightMargin(0.03);
2366
2367 bool do2D = false;
2368
2369 labelcolour = kBlack;
2370
2371
2372 if ( contains(histo.name(),"/2d") ) {
2373
2374 do2D = true;
2375 labelcolour = kWhite;
2376
2377 gPad->SetRightMargin(0.13);
2378
2379 std::cout << "\n\nsee! it is a 2d histograms !!! " << histo.name() << "\n\n" << std::endl;
2380
2381 h2test = Get<TH2D>( *fftest, chains[j]+"/"+histo.name(), testrun, 0, &savedhistos );
2382
2383 std::cout << "\t2d: " << h2test << std::endl;
2384
2385 DrawLabel( 0.5, 0.5, "a test" );
2386
2387 h2test->GetYaxis()->SetTitleOffset(1.55);
2388 h2test->GetXaxis()->SetTitleOffset(1.5);
2389 h2test->GetXaxis()->SetTitle(xaxis.c_str());
2390 h2test->GetYaxis()->SetTitle(yaxis.c_str());
2391
2392 const AxisInfo& xinfo = histo.xaxis();
2393 const AxisInfo& yinfo = histo.yaxis();
2394
2395 std::cout << xinfo << std::endl;
2396 std::cout << yinfo << std::endl;
2397
2398 if ( yinfo.rangeset() ) {
2399 h2test->GetYaxis()->SetRangeUser( yinfo.lo(), yinfo.hi() );
2400 }
2401
2402 if ( yinfo.normset() ) normy( h2test );
2403
2404 if ( xinfo.rangeset() ) {
2405 h2test->GetXaxis()->SetRangeUser( xinfo.lo(), xinfo.hi() );
2406 }
2407
2408 if ( xinfo.autoset() ) autox( h2test );
2409 if ( yinfo.autoset() ) autoy( h2test );
2410
2411 SetZeros( h2test );
2412
2413 h2test->DrawCopy("colz");
2414
2415 if ( histo.detail().find("logz")!=std::string::npos ) gPad->SetLogz(true);
2416 else gPad->SetLogz(false);
2417
2418
2419 }
2420 else if ( refit_resplots && ( contains(histo.name(),"/sigma") || contains(histo.name(),"/mean") ) ) {
2421
2422 Resplot::setoldrms95(oldrms);
2424
2425 std::cout << red << "fetch 2d: " << histo.name() << reset << std::endl;
2426
2427 bool bsigma = false;
2428 if ( contains(histo.name(),"/sigma") ) bsigma = true;
2429
2430 bool bmean = false;
2431 if ( contains(histo.name(),"/mean") ) bmean = true;
2432
2433 std::string tmp_ = histo.name();
2434 std::string base;
2435
2436 if ( bsigma ) base = chop( tmp_, "/sigma" );
2437 if ( bmean ) base = chop( tmp_, "/mean" );
2438
2439 std::cout << "refitting: " << histo.name() << "\tbase: " << base << "\tbsigma: " << bsigma << "\tbmean: " << bmean << std::endl;
2440
2441 TH2D* htest2d = Get<TH2D>( *fftest, chains[j]+"/"+base+"/2d", testrun, 0, &savedhistos );
2442
2443 if ( htest2d==0 ) htest2d = Get<TH2D>( *fftest, chains[j]+"/"+base+"/2D", testrun, 0, &savedhistos );
2444
2445
2446 TH2D* href2d = 0;
2447
2448 if ( ffref ) href2d = Get<TH2D>( *ffref, chains[j]+"/"+base+"/2d", testrun, chainmap );
2449
2450 if ( href2d==0 ) href2d = Get<TH2D>( *ffref, chains[j]+"/"+base+"/2D", testrun, chainmap );
2451
2452 if ( htest2d==0 ) continue;
2453 if ( !noreftmp && href2d==0 ) noreftmp = true;
2454
2455 std::cout << "href2d : " << href2d << std::endl;
2456
2457 Plotter::setplotref(!noreftmp);
2458
2459 std::cout << "plotter" << std::endl;
2460
2462
2463 Resplot::Resplot rtest("tmp", htest2d );
2464
2465 std::cout << "Resplot rtest\t" << rtest.finalised() << std::endl;
2466
2467 if ( rtest.finalised() ) {
2468 std::cout << "refitting ..." << std::endl;
2469 if ( contains(histo.name(),"npix") || contains(histo.name(),"nsct") || contains(histo.name(),"nsi") || contains(histo.name(),"nbl") ) rtest.Refit(Resplot::FitNull);
2470 else rtest.Refit(Resplot::FitNull95);
2471 }
2472 else {
2473 std::cout << "refitting (finalising) ..." << std::endl;
2474 if ( contains(histo.name(),"npix") || contains(histo.name(),"nsct") || contains(histo.name(),"nsi") || contains(histo.name(),"nbl") ) rtest.Finalise(Resplot::FitNull);
2475 else rtest.Finalise(Resplot::FitNull95);
2476
2477 rtest.Mean()->DrawCopy();
2478 gPad->Print("Duff.pdf");
2479 }
2480
2481 std::cout << "bsigma: " << bsigma << std::endl;
2482 std::cout << "bmean: " << bmean << std::endl;
2483
2484 if ( bsigma ) { htest = (TH1F*)rtest.Sigma()->Clone("rtest_sigma"); htest->SetDirectory(0); }
2485 if ( bmean ) { htest = (TH1F*)rtest.Mean()->Clone("rtest_mean"); htest->SetDirectory(0); }
2486
2487 std::cout << reset << std::endl;
2488
2489 if ( htest==0 ) {
2490 std::cerr << red << "missing test histogram: " << (refchain[j]+" / "+histo.name()) << " " << htest
2491 << "(test)" << reset << std::endl;
2492 continue;
2493 }
2494 else {
2495 std::cout << green << "htest: " << htest->GetName() << reset << std::endl;
2496 }
2497
2498 std::cout << "\nhisto.name(): " << histo.name() << std::endl;
2499
2500 std::cout << reset << std::endl;
2501
2502 if ( !d0mod && histo.name().find("d0_vs_phi")!=std::string::npos ) {
2503
2504 d0mod = true;
2505
2506 std::cout << green << "\n\nbeam fitting !!" << histo.name() << reset << std::endl;
2507
2508 TVirtualPad* old = gPad;
2509
2510 std::cout << "old canvas: " << gPad << std::endl;
2511
2512 std::cout << "dbg histo name: " << histo.name() << std::endl;
2513
2514 bool first = false;
2515
2516 TCanvas* tc = 0;
2517
2518 if ( histo.name().find("_rec")!=std::string::npos ) {
2519 //if ( fitcanvas_rec == 0 ) {
2520 fitcanvas_rec = new TCanvas( "fit_rec", "", 700, 600 );
2521 first = true;
2522 // }
2523 tc = fitcanvas_rec;
2524 }
2525
2526 if ( histo.name().find("_rec")==std::string::npos ) {
2527 //if ( fitcanvas == 0 ) {
2528 fitcanvas = new TCanvas( "fit", "", 700, 600 );
2529 first = true;
2530 //}
2531 tc = fitcanvas;
2532 }
2533
2534 TVirtualPad* tp = gPad;
2535
2536 if ( tc ) tc->cd();
2537
2539 // TH1D* hf = (TH1D*)rtest.Mean()->Clone("cck");
2540 // TH1D* hf = rtest.Mean();
2541
2542 rtest.Mean()->SetDirectory(0);
2543
2544 TH1* hf = htest;
2545
2546 if ( histo.name().find("_rec")!=std::string::npos ) hf->SetTitle(";Trigger #phi;Trigger d_{0} [mm]");
2547 else hf->SetTitle(";Offline #phi;Offline d_{0} [mm]");
2548
2549 TF1* tf = new TF1( "sinus", "[0]*sin(x+[1])+[2]" );
2550
2551 tf->SetLineWidth(1);
2552
2553 hf->GetYaxis()->SetTitleOffset( hf->GetYaxis()->GetTitleOffset()*1.1 );
2554
2555 {
2556 TCanvas* tfc = new TCanvas( "tmp", "", 700, 600 );
2557 tfc->cd();
2558 hf->Fit( tf );
2559 delete tfc;
2560 }
2561
2562 double phi0 = tf->GetParameter(1);
2563 // double x = 0.0001*int(tf->GetParameter(0)*cos(phi0)*10000);
2564 // double y = 0.0001*int(tf->GetParameter(0)*sin(phi0)*10000);
2565 double x = tf->GetParameter(0)*cos(phi0);
2566 double y = tf->GetParameter(0)*sin(phi0);
2567 double off = tf->GetParameter(2);
2568
2569 std::cout << "\tx = " << x << std::endl;
2570 std::cout << "\ty = " << y << std::endl;
2571 std::cout << "\toffset = " << off << std::endl;
2572
2573 std::string cckstr = chains[j];
2574
2575 cckstr = cckstr.substr( cckstr.find("HLT_IDTrack") );
2576
2577 std::string vstr = chains[j];
2578
2579 vstr.resize(vstr.find("_boffperf"));
2580 vstr.resize(vstr.find("_L1"));
2581
2582 hf->SetMinimum( -0.03 );
2583 hf->SetMaximum( 0.03 );
2584
2585 tc->cd();
2586
2587 if ( first ) hf->DrawCopy();
2588
2589 hf->DrawCopy("same");
2590 hf->DrawCopy("samee");
2591
2592
2593 DrawLabel( 0.2, 0.89, cckstr );
2594 DrawLabel( 0.2, 0.85, vstr );
2595
2596 DrawLabel( 0.2, 0.81, "x = " + eround(x) + " mm" );
2597 DrawLabel( 0.2, 0.77, "y = " + eround(y) + " mm" );
2598 DrawLabel( 0.2, 0.73, "offset = " + eround(off) + " mm" );
2599
2600 std::string sht = chains[j]+"-"+histo.name()+"-fit.pdf";
2601
2602 size_t p = sht.find("/");
2603
2604 while ( p!=std::string::npos ) {
2605 sht.erase( p, 1 );
2606 p = sht.find("/");
2607 }
2608
2609
2610 gPad->Print( sht.c_str() );
2611 gPad->Print( "sht.pdf" );
2612
2613 std::cout << "CNT !!!" << std::endl;
2614
2615 delete tf;
2616
2617 tp->cd();
2618
2619 gPad = old;
2620
2621 }
2622
2623
2626
2627 TH1F* hreft = 0;
2628
2629 std::cout << "Resplot noreftmp " << noreftmp << " ... " << std::endl;
2630
2631 if ( !noreftmp ) {
2632 if ( refitref_resplots ) {
2633
2634 std::cout << "Resplot rref: " << href2d << std::endl;
2635
2636 Resplot::Resplot rref("tmp", href2d );
2637
2638 std::cout << "Resplot rref: " << href2d << " (2)" << std::endl;
2639
2640 if ( rref.finalised() ) {
2641 std::cout << "refitting (2) ..." << std::endl;
2642 if ( contains(histo.name(),"npix") || contains(histo.name(),"nsct") ) rref.Refit(Resplot::FitNull);
2643 else rref.Refit(Resplot::FitNull95);
2644 }
2645 else {
2646 std::cout << "refitting (2 - finalising) ..." << std::endl;
2647 if ( contains(histo.name(),"npix") || contains(histo.name(),"nsct") ) rref.Finalise(Resplot::FitNull);
2648 else rref.Finalise(Resplot::FitNull95);
2649 }
2650
2651 std::cout << "Resplot rref: " << href2d << " (3)" << std::endl;
2652
2653 if ( bsigma ) { hreft = (TH1F*)rref.Sigma()->Clone("rref_sigma"); hreft->SetDirectory(0); }
2654 if ( bmean ) { hreft = (TH1F*)rref.Mean()->Clone("rref_mean"); hreft->SetDirectory(0); }
2655
2656 std::cout << "Resplot rref: " << href2d << " (4)" << std::endl;
2657
2658 }
2659 else {
2660
2661 std::cout << "Resplot rref: " << href2d << " (5)" << reset << std::endl;
2662
2663 hreft = Get( *ffref, refchain[j]+"/"+histo.name(), rawrefrun, chainmap );
2664 if ( hreft==0 ) {
2665 std::cerr << "ERROR: could not find " << (refchain[j]+"/"+histo.name()) << std::endl;
2666 }
2667
2668
2669 }
2670 }
2671
2672 std::cout << "Resplot rref: " << href2d << " (6)" << std::endl;
2673
2674
2675 if ( !noreftmp && hreft==0 ) {
2676
2677 std::cerr << "missing ref histogram: " << (refchain[j]+" / "+histo.name()) << " " << htest << "(ref)" << std::endl;
2678
2679 noreftmp = true;
2680 Plotter::setplotref(!noreftmp);
2681 noreflabel="reference not found";
2684 // std::exit(-1);
2685 }
2686
2687 if ( !noreftmp ) {
2688
2689 std::cout << "Resplot rref: " << href2d << " (7)" << std::endl;
2690
2691 href = (TH1F*)hreft->Clone();
2692 href->SetDirectory(0);
2693
2694 std::cout << "Resplot href: " << href << " (7a)" << std::endl;
2695
2696 }
2697
2698 std::cout << "Resplot rref: " << href2d << " (8)" << std::endl;
2699
2700
2702 // std::cout << "\tget " << (refchain[j]+"/"+histos[i]) << "\t" << href << std::endl;
2703
2704 savedhistos.push_back( refchain[j]+"/"+histo.name() );
2705
2706 std::cout << "Resplot rref: " << href2d << " (9)" << std::endl;
2707
2708 }
2709 else {
2710
2712
2713 std::string reghist = histo.name();
2714
2715 std::cout << "hist: " << (chains[j]+"/"+reghist) << "\tftest " << ftest << std::endl;
2716
2717
2718
2719 htest = Get( *fftest, chains[j]+"/"+reghist, testrun, 0, &savedhistos );
2720
2721 std::cout << "\nhist: " << htest << std::endl;
2722
2723 std::cout << "fftest: " << fftest->GetName() << std::endl;
2724
2726 // if ( contains( fftest->GetName(), "-mc" ) ) translate_x = false;
2727
2728 if ( lumitest_trans && translate_x && !contains( cc, "-mc" ) ) htest = trans( htest, translate_x );
2729
2730 std::cout << xaxis << std::endl;
2731
2732 if ( htest==0 ) {
2733 std::cerr << "missing test histogram: " << (chains[j]+" / "+reghist) << " " << htest<< std::endl;
2734 continue;
2735 }
2736
2737 testfit( htest, htest->GetName() );
2738
2739 TH1F* hreft = 0;
2740
2741 if ( ffref ) hreft = Get( *ffref, refchain[j]+"/"+reghist, rawrefrun, chainmap );
2742 else noreftmp = true;
2743
2744 if ( hreft && lumiref_trans && translate_x && !contains( cr, "-mc" ) ) hreft = trans( hreft, translate_x );
2745
2746 std::cout << "hreft: " << hreft << std::endl;
2747
2748 if ( std::string(htest->ClassName()).find("TH2")!=std::string::npos ) {
2749 std::cout << "Class TH2: " << htest->GetName() << std::endl;
2750 continue;
2751 }
2752
2753
2754 if ( std::string(htest->ClassName()).find("TH1")!=std::string::npos ) {
2755 std::cout << "Class TH1: " << htest->GetName() << std::endl;
2756 }
2757 else if ( std::string(htest->ClassName()).find("TProfile")!=std::string::npos ) {
2758 std::cout << "Class TProf: " << htest->GetName() << std::endl;
2759 }
2760 else if ( std::string(htest->ClassName()).find("TEfficiency")!=std::string::npos ) {
2761 std::cout << "Class TEff: " << htest->GetName() << std::endl;
2762 }
2763
2764
2765 std::cout << "Resplot hreft: " << hreft << " (10)" << " " << noreftmp << std::endl;
2766
2767 if ( !noreftmp && hreft==0 ) {
2768 std::cerr << "missing ref histogram: " << (refchain[j]+" / "+reghist)
2769 << " " << hreft << std::endl;
2770
2771 noreftmp = true;
2772 Plotter::setplotref(false);
2773 noreflabel="reference not found";
2776 // std::exit(-1);
2777
2778 }
2779
2780 std::cout << "Resplot hreft: " << hreft << " (10)" << std::endl;
2781
2782 if ( hreft!=0 ) {
2783
2784 std::cout << "Resplot hreft: " << hreft->ClassName() << " (11)" << std::endl;
2785
2786 if ( std::string(hreft->ClassName()).find("TH1")!=std::string::npos ) {
2787 href = (TH1F*)hreft->Clone();
2788 href->SetDirectory(0);
2789 }
2790 else if ( isTEfficiency(hreft) ) {
2791 href = makeplot( hreft );
2792 }
2793 }
2794 else {
2795 noreftmp = true;
2796 href = 0;
2797 }
2798
2799 std::cout << " \tget " << (chains[j]+"/"+reghist) << "\thtest " << htest << std::endl;
2800 std::cout << " \tget " << (refchain[j]+"/"+reghist) << "\thref " << href << std::endl;
2801
2802 if ( htest==0 ) continue;
2803
2804 if ( !noreftmp && href==0 ) {
2805 noreftmp = true;
2806 Plotter::setplotref(!noreftmp);
2807 }
2808
2809 if ( fulldbg ) std::cout << __LINE__ << std::endl;
2810
2811
2812 if ( rebin!=1 ) {
2813 std::cout << "rebin: " << hname << "\t" << rebin << std::endl;
2814 if ( htest ) htest->Rebin(rebin);
2815 if ( href ) href->Rebin(rebin);
2816 for ( int ip=0 ; ip<10 ; ip++ ) std::cout << std::endl;
2817 }
2818
2819#if 0
2821 if ( !contains( histo.name(), "rdz_vs_zed" ) && contains( histo.name(), "1d") ) {
2822 std::cout << "Rebinning histogram: " << histo.name() << std::endl;
2823 if ( htest->GetNbinsX()>500 ) htest->Rebin(10);
2824 if ( href && href->GetNbinsX()>500 ) href->Rebin(10);
2825 }
2826#endif
2827
2828
2829 if ( make_efficiencies && histo.name().find("zed_eff")!=std::string::npos ) {
2830 if ( htest->GetNbinsX()>100 ) htest->Rebin(5);
2831 if ( href && href->GetNbinsX()>100 ) href->Rebin(5);
2832 }
2833
2834
2835 if ( fulldbg ) std::cout << __LINE__ << std::endl;
2836
2837 if ( scalepix && std::string(htest->GetName()).find("npix")!=std::string::npos ) Scale(htest,0.5);
2838 if ( scalepix && href && std::string(htest->GetName()).find("npix")!=std::string::npos ) Scale(href,0.5);
2839
2840 if ( fulldbg ) std::cout << __LINE__ << std::endl;
2841
2842 if ( notitle ) {
2843 htest->SetTitle("");
2844 if( href ) href->SetTitle("");
2845 }
2846
2847 if ( fulldbg ) std::cout << __LINE__ << std::endl;
2848
2849 }
2850
2851 std::cout << "done else" << std::endl;
2852
2853 if ( do2D ) continue;
2854
2855 std::cout << "done else:\t" << htest << std::endl;
2856 std::cout << "done else:\t" << htest->GetName() << std::endl;
2857
2858 if ( fulldbg ) std::cout << __LINE__ << std::endl;
2859
2860 if ( !d0mod && histo.name().find("d0_vs_phi")!=std::string::npos ) {
2861 d0mod = true;
2862 if ( htest ) d0fit( histo, htest, chains[j] );
2863 if ( href ) d0fit( histo, href, chains[j] );
2864 }
2865
2866 if ( !do2D && make_ref_efficiencies ) {
2867
2868 std::cout << "make ref efficiencies" << std::endl;
2869
2870 if ( htest && href ) {
2871
2873 // std::cout << "contains _eff " << contains( std::string(htest->GetName()), "eff" ) << std::endl;
2874
2875 if ( contains( std::string(htest->GetName()), "eff" ) && !contains( std::string(htest->GetName()), "_d" ) ){
2876
2877 std::string effhist = histo.name();
2878
2879
2880
2881 htestnum = Get( *fftest, chains[j]+"/"+effhist+"_n", testrun, 0, &savedhistos );
2882
2883
2884
2885 TH1F* hrefnumt = Get( *ffref, refchain[j]+"/"+effhist+"_n", rawrefrun, chainmap, &savedhistos );
2886
2887
2888
2889 if ( !noreftmp && hrefnumt!=0 ) {
2890 hrefnum = (TH1F*)hrefnumt->Clone();
2891 hrefnum->SetDirectory(0);
2892 }
2893
2894 }
2895 }
2896
2897 }
2898
2899 std::cout << "done effs ? " << bayes << "\thtest: " << htest << " :: " << htest->GetName() << std::endl;
2900
2901 if ( bayes ) {
2902
2903 std::cout << "make ref efficiencies " << htest->GetName() << std::endl;
2904
2905 if ( make_efficiencies && htest && contains( std::string(htest->GetName()), "eff" ) && !contains( std::string(htest->GetName()), "_d" ) ) {
2906
2907 std::string effhist = histo.name();
2908
2910
2911 if ( rebin!=1 ) std::cout << effhist << "\trebin: " << rebin << std::endl;
2912
2913
2914 htestnum = Get( *fftest, chains[j]+"/"+effhist+"_n", testrun, 0, &savedhistos ) ;
2915 htestden = Get( *fftest, chains[j]+"/"+effhist+"_d", testrun, 0, &savedhistos ) ;
2916
2917 if ( htestnum==0 && htestden==0 ) {
2918 TEfficiency* eff = 0;
2919
2920 eff = Get<TEfficiency>( *fftest, chains[j]+"/"+effhist, testrun, 0, &savedhistos ) ;
2921
2922 if ( eff ) {
2923 htestnum = (TH1F*)eff->GetPassedHistogram();
2924 htestden = (TH1F*)eff->GetTotalHistogram();
2925 }
2926
2927 }
2928
2929 std::cout << "eff: htestnum: " << htestnum << "\thtestden: " << htestden << std::endl;
2930
2931
2932 double ars = total_eff( htestnum, htestden );
2933
2934 std::cout << "heff: " << effhist << "\t" << ars << std::endl;
2935
2936
2937 std::cout << "1: Bayesian error calculation " << htestnum << " " << htestden << "\tscale " << scale_eff << std::endl;
2938
2939 if ( htestnum && htestden ) {
2940
2941#ifdef D0REBIN
2944 if ( d0rebin_flag ) {
2945 htestnum = d0rebin( htestnum );
2946 htestden = d0rebin( htestden );
2947 }
2948 else if ( rebin!=1 ) {
2949 htestnum = Rebin(htestnum, rebin );
2950 htestden = Rebin(htestden, rebin );
2951 }
2952#endif
2953 std::cout << "test histogram name: : " << htestnum->GetName() << "\txaxis: " << xaxis << "\t" << std::endl;
2954
2955 if ( make_efficiencies && std::string(htestnum->GetName()).find("ntrax_eff")!=std::string::npos ) {
2956
2957 bool low = true;
2958
2959 htestnum = rebin_log( htestnum, low );
2960 htestden = rebin_log( htestden, low );
2961 }
2962
2963#if 0
2966 if ( contains( htest->GetName(), "_vs_lb" ) ) {
2967 std::cout << "rebin " << histo.name() << std::endl;
2968 htestnum->Rebin(3);
2969 htestden->Rebin(3);
2970 }
2971
2972 if ( make_efficiencies && contains( htest->GetName(), "eta_eff" ) ) {
2973 std::cout << "rebin " << histo.name() << std::endl;
2974 htestnum->Rebin(2);
2975 htestden->Rebin(2);
2976 }
2977
2978#endif
2979
2980 // if ( RANGEMAP && (effhist.find("pT")!=std::string::npos || effhist.find("pt")!=std::string::npos ) ) {
2981 if ( RANGEMAP && (effhist.find("ET")!=std::string::npos ) ) {
2982 std::cout << "\trange: " << j << " " << htest << std::endl;
2983 bnd.range( chains[j], htestnum );
2984 bnd.range( chains[j], htestden );
2985 }
2986
2987 if ( lumitest_trans && translate_x && !contains( cc, "-mc" ) ) {
2988 htestnum = trans( htestnum, translate_x );
2989 htestden = trans( htestden, translate_x );
2990 }
2991
2992 Efficiency1D e( htestnum, htestden, "", scale_eff );
2993
2994 tgtest = e.Bayes(scale_eff);
2995
2996 htest = e.Hist();
2997
2998 htest->SetName( (std::string(htestnum->GetName())+"_eff").c_str() );
2999
3000 std::cout << "effhist: " << effhist << std::endl;
3001
3002 }
3003
3005
3006 std::cout << "recalculating reference efficiencies ..." << std::endl;
3007
3008 if ( href ) {
3009
3010 std::cout << "doin ..." << std::endl;
3011
3012
3013 TH1F* hrefnum = Get( *ffref, refchain[j]+"/"+histo.name()+"_n", rawrefrun, chainmap );
3014 TH1F* hrefden = Get( *ffref, refchain[j]+"/"+histo.name()+"_d", rawrefrun, chainmap );
3015
3016
3017 if ( hrefnum==0 && hrefden==0 ) {
3018 TEfficiency* eff = 0;
3019
3020 eff = Get<TEfficiency>( *ffref, refchain[j]+"/"+histo.name(), rawrefrun, chainmap ) ;
3021
3022 if ( eff ) {
3023 hrefnum = (TH1F*)eff->GetPassedHistogram();
3024 hrefden = (TH1F*)eff->GetTotalHistogram();
3025 }
3026
3027 }
3028
3029
3030
3031 std::cout << "2. Bayesian error calculation " << htestnum << " " << htestden << "\tscale " << scale_eff << std::endl;
3032 std::cout << "3. Bayesian error calculation " << hrefnum << " " << hrefden << "\tscale " << scale_eff_ref << std::endl;
3033
3034
3035 if ( hrefnum && hrefden ) {
3036
3037 if ( lumiref_trans && translate_x && !contains( cr, "-mc" ) ) {
3038 hrefnum = trans( hrefnum, translate_x );
3039 hrefden = trans( hrefden, translate_x );
3040 }
3041
3042#ifdef D0REBIN
3045 if ( d0rebin_flag ) {
3046 hrefnum = d0rebin( hrefnum );
3047 hrefden = d0rebin( hrefden );
3048 }
3049 else if ( rebin!=1 ) {
3050 hrefnum = Rebin(hrefnum, rebin );
3051 hrefden = Rebin(hrefden, rebin );
3052 }
3053#endif
3054
3055 std::cout << hrefnum << " " << hrefden << std::endl;
3056
3057 Efficiency1D e( hrefnum, hrefden, "", scale_eff_ref );
3059 // tgref = e.Bayes(scale_eff);
3060
3061 href = e.Hist();
3062
3063 }
3064 }
3065 }
3066
3067 std::cout << "dbg: htest: " << htest << std::endl;
3068 std::cout << "dbg: htest name " << htest->GetName() << std::endl;
3069
3070 if ( true && histo.name().find("invmass")!=std::string::npos ) {
3071 testfit( htest, histo.name() );
3072 }
3073
3074
3075 }
3076
3077
3078 std::cout << "chains[j] " << chains[j] << std::endl;
3079 std::cout << "histo.name() " << histo.name() << std::endl;
3080 std::cout << "href " << href << "\t (TEfficiency " << isTEfficiency(href) << ")" << std::endl;
3081
3082 if ( isTEfficiency(href) ) {
3083 // TH1F* hrefeff = makeplot<TEfficiency>(href);
3084 TH1F* hrefeff = makeplot(href);
3085 href = hrefeff;
3086 std::cout << "efficiency" << std::endl;
3087 }
3088
3089 std::cout << "href " << href << "\t (TEfficiency " << isTEfficiency(href) << ")" << std::endl;
3090
3091
3092 if ( htest==0 ) {
3093 std::cout << " no test histogram : " << (chains[j]+"/"+histo.name()) << std::endl;
3094 continue;
3095 }
3096
3097
3098 if ( !noreftmp && href==0 ) {
3099 std::cout << " no ref histogram : " << (chains[j]+"/"+histo.name()) << std::endl;
3100 noreftmp = true;
3101 Plotter::setplotref(!noreftmp);
3102 noreflabel="reference not found";
3105 // continue;
3106 }
3107
3108 std::cout << "htest: " << isTEfficiency(htest) << std::endl;
3109
3110 if ( isTEfficiency(htest) ) htest = makeplot(htest);
3111
3112 htest->GetYaxis()->SetTitleOffset(1.55);
3113 htest->GetXaxis()->SetTitleOffset(1.5);
3114 htest->GetXaxis()->SetTitle(xaxis.c_str());
3115 htest->GetYaxis()->SetTitle(yaxis.c_str());
3116
3117 std::cout << "htest: " << htest << "\t" << __LINE__ << std::endl;
3118
3119
3120 if ( !noreftmp ) {
3121
3122 href->GetYaxis()->SetTitleOffset(1.5);
3123 href->GetXaxis()->SetTitleOffset(1.5);
3124 std::cout << "xaxis: " << href->GetXaxis()->GetTitle() << std::endl;
3125
3126 }
3127
3128 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3129
3130#if 0
3131 if ( !contains(histo.name(),"vtx_eff") && contains(histo.name(),"ntracks") ) {
3132
3133 double xm = htest->GetMean();
3134
3135 if ( xm>=10 ) {
3136 double lxm = std::log10(xm);
3137 int newbins = int(0.5+xm/std::pow(10,int(lxm)))*pow(10,int(lxm));
3138 int nrebin = int( (newbins+5)/10 );
3139
3140 if ( nrebin>1 ) {
3141 std::cout << "rebin: " << htest->GetName() << "\tbins: " << nrebin << std::endl;
3142 htest->Rebin(nrebin);
3143 htest->Sumw2();
3144 if ( !noreftmp ) {
3145 href->Rebin(nrebin);
3146 href->Sumw2();
3147 }
3148 }
3149 }
3150 }
3151#endif
3152
3153 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3154
3155
3157 if ( plotname == "" ) {
3158
3159 if ( key!="" ) {
3160 htest->SetTitle("");
3161 if ( href ) href->SetTitle("");
3162 plotname = key+"_";
3163 }
3164 else if (fcontains(chains[j],"HLT_")) {
3165 htest->SetTitle("");
3166 if ( href ) href->SetTitle("");
3167 plotname = "HLT_";
3168 }
3169 else if (fcontains(chains[j],"EF_")) {
3170 htest->SetTitle("");
3171 if ( href ) href->SetTitle("");
3172 plotname = "EF_";
3173 }
3174 else if (fcontains(chains[j],"L2_")) {
3175 htest->SetTitle("");
3176 if ( href ) href->SetTitle("");
3177 plotname = "L2_";
3178 }
3179 else if (contains(chains[j],"FTK") && ! contains(chains[j],"HLT_") ) {
3180 htest->SetTitle(("FTK "+ histo.name()).c_str());
3181 if ( href ) href->SetTitle(("FTK "+ histo.name()).c_str());
3182 plotname = "FTK_";
3183 }
3184
3185 plotname += histo.name();
3186
3189 replace(plotname, '/', '_');
3190
3191 }
3192
3193
3194 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3195
3196 bool residual = false;
3197
3198 if ( contains(histo.name(),"_res") || contains(histo.name(),"residual_") || contains(histo.name(),"1d") ) residual = true;
3199
3200 std::string collection = basename( chains[j] );
3201
3202 std::string actual_chain = basename( dirname( chains[j] ) );
3203
3204 if ( collection.find("_InDet")!=std::string::npos ) collection.erase( 0, collection.find("_InDet")+1 );
3205 if ( actual_chain.find("_InDet")!=std::string::npos ) actual_chain.erase( actual_chain.find("_InDet") );
3206
3207
3208 std::cout << "raw: " << chains[j] << std::endl;
3209 std::cout << "track collection: " << collection << std::endl;
3210 std::cout << "actual chain: " << actual_chain << std::endl;
3211
3212 std::regex rx("_HLT_[^_]*RoI.*");
3213 std::regex rx1("_HLT_[^_]*_RoI.*");
3214
3215 std::cout << "\n\n\nactual_chain: " << actual_chain << std::endl;
3216
3217 arsaway( actual_chain, "_L1.*", "" );
3218 arsaway( actual_chain, "L1.*", "" );
3219
3220 actual_chain = std::regex_replace( actual_chain, std::regex( "L1.*:" ), "" );
3221
3222 if ( actual_chain.find("jvt")!=std::string::npos ) actual_chain.erase(
3223 actual_chain.find("jvt"),
3224 actual_chain.find("HLT_IDTrack")-actual_chain.find("jvt") );
3225
3226 std::cout << " : " << actual_chain << "\n\n\n" << std::endl;
3227
3228
3229 actual_chain = std::regex_replace( actual_chain, std::regex( "_HLT_IDTrack.*" ), "" );
3230
3231
3232 collection = std::regex_replace( collection, std::regex(".*HLT_IDTrack_"), "IDTrack " );
3233 collection = std::regex_replace( collection, std::regex("IDTrack "), "" );
3234 collection = std::regex_replace( std::regex_replace( collection, rx, "" ), rx1, "" );
3235
3236 if ( actual_chain.find("HLT_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find("HLT_IDTrack_"), 12 );
3237 if ( actual_chain.find("_IDTrack_")!=std::string::npos ) actual_chain.erase( actual_chain.find("_IDTrack_"), 9 );
3238 if ( actual_chain.find("IDTrack")!=std::string::npos ) actual_chain.erase( actual_chain.find("IDTrack"), 7 );
3239 if ( actual_chain.find("_idperf")!=std::string::npos ) actual_chain.erase( actual_chain.find("_idperf"), 7 );
3240 if ( actual_chain.find("_bperf")!=std::string::npos ) actual_chain.erase( actual_chain.find("_bperf"), 6 );
3241 if ( actual_chain.find("_boffperf")!=std::string::npos ) actual_chain.erase( actual_chain.find("_boffperf"), 9 );
3242 if ( actual_chain.find("_HLT_")!=std::string::npos ) actual_chain.replace( actual_chain.find("_HLT_"), 5, " " );
3243 if ( actual_chain.find("HLT_")!=std::string::npos ) actual_chain.erase( actual_chain.find("HLT_"), 4 );
3244
3245
3246
3247 if ( collection.find("_IDTrkNoCut")!=std::string::npos ) collection.erase( collection.find("_IDTrkNoCut"), 11 );
3248 if ( collection.find("xAODCnv")!=std::string::npos ) collection.erase( collection.find("xAODCnv"), 7 );
3249 if ( collection.find("HLT_IDTrack_")!=std::string::npos ) collection.erase( collection.find("HLT_IDTrack_"), 12 );
3250 if ( collection.find("HLT_IDTrack")!=std::string::npos ) collection.erase( collection.find("HLT_IDTrack"), 11 );
3251 if ( collection.find("Tracking")!=std::string::npos ) collection.replace( collection.find("Tracking"), 8, "Trk" );
3252 if ( collection.find("InDetTrigTrk_")!=std::string::npos ) collection.erase( collection.find("InDetTrigTrk_"), 13 );
3253 if ( collection.find("HLT_xAODTracks_")!=std::string::npos ) collection.erase( collection.find("HLT_xAODTracks_"), 15 );
3254 if ( collection.find("_HLT_")!=std::string::npos ) collection.replace( collection.find("_HLT_"), 5, " " );
3255 if ( collection.find("HLT_")!=std::string::npos ) collection.erase( collection.find("HLT_"), 4 );
3256 if ( collection.find("_extra")!=std::string::npos ) collection.resize( collection.find("_extra") );
3257
3258 if ( actual_chain.size()>25 ) {
3259 size_t pos = actual_chain.find_last_of("_");
3260 while ( pos!=std::string::npos && actual_chain.size()>25 ) {
3261 actual_chain.resize(pos);
3262 pos = actual_chain.find_last_of("_");
3263 }
3264 }
3265
3266 std::cout << blue << "actual chain: " << actual_chain << "\tcollection: " << collection << reset << std::endl;
3267
3268 std::string c = actual_chain + " : " + collection;
3269
3270 std::cout << "track collection: " << collection << " <-" << std::endl;
3271 std::cout << "actual chain: " << actual_chain << " <-" << std::endl;
3272
3273 replace( c, "_In", " : " );
3274
3275 c = " " + c;
3276
3277 std::cout << "use label: " << c << "\tchains size " << chains.size() << "\t" << usrlabels.size() << std::endl;
3278
3279 std::cout << "chains.size() " << chains.size() << " " << j << std::endl;
3280 std::cout << "chains.size() " << chains.size() << " " << j << std::endl;
3281
3282 std::cout << "chains[j] : " << j << " " << chains[j] << std::endl;
3283
3284 std::cout << "userlabels.size() " << usrlabels.size() << std::endl;
3285
3286 if ( usrlabels.size() < j+1 ) {
3287 if ( usrlabels.size()!=0 ) std::cerr << "userlabels not large enough - not using userlabels" << std::endl;
3288 }
3289 else c = usrlabels[ j ];
3290
3291 std::cout << "use label: c: " << c << std::endl;
3292
3294
3295 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3296
3297 std::cout << blue << "xaxis: " << xaxis << reset << std::endl;
3298
3299 if ( ALLRANGEMAP || xaxis.find("p_{T}")!=std::string::npos || xaxis.find("E_{T}")!=std::string::npos ) {
3300
3301 if ( RANGEMAP && xaxis.find("p_{T}")!=std::string::npos ) {
3302 bnd.range( chains[j], htest );
3303 if ( href ) bnd.range( chains[j], href );
3304 }
3305
3306 if ( RANGEMAP || ALLRANGEMAP ) {
3307
3308 LINEF = false;
3309
3310 std::cout << "\n\n\nctags " << ctags.size() << "\n\n" << std::endl;
3311
3312 for ( size_t ic=0 ; ic<ctags.size() ; ic++ ) {
3313
3314 std::cout << "\n\nic: " << ic << " " << ctags[ic] << " " << ccolours[ic] << "\n\n" << std::endl;
3315
3316 if ( chains[j].find(ctags[ic])!=std::string::npos ) {
3317 std::cout << "\ttag " << ctags[ic] << " \tcolour: " << ccolours[ic] << "\tstyle: " << cstyles[ic] << std::endl;
3318 htest->SetLineColor( ccolours[ic] );
3319 htest->SetMarkerColor( ccolours[ic] );
3320 htest->SetMarkerStyle( cstyles[ic] );
3321 c = ctaglabels[ic];
3322 if ( tgtest ) {
3323 tgtest->SetLineColor(htest->GetMarkerColor());
3324 tgtest->SetMarkerStyle(htest->GetMarkerStyle());
3325 tgtest->SetMarkerColor(htest->GetMarkerColor());
3326 }
3327 break;
3328 }
3329 }
3330
3331 }
3332
3333 std::cout << "test: " << chains[j] << "chains colour: " << htest->GetMarkerColor() << std::endl;
3334
3335 }
3336
3337
3338 std::cout << "movin' on ..." << std::endl;
3339
3340 std::cout << "chain: " << chains[j] << " \t marker colour: " << htest->GetMarkerColor() << std::endl;
3341
3342 std::cout << "Plotter marker : " << htest->GetMarkerColor() << " " << htest->GetMarkerStyle() << std::endl;
3343
3344 // do we really want ... chain_name+usrlabels[j] ?
3345 if ( uselabels ) plots.push_back( Plotter( htest, href, " " + chain_name[j] + c, tgtest ) );
3346 else {
3347 std::cout << "using label: " << c << std::endl;
3348 plots.push_back( Plotter( htest, href, c, tgtest ) );
3349 }
3350
3351 std::cout << "AxisInfo: " << xaxis << std::endl;
3352
3353 plots.back().xaxis( &(histo.xaxis()) );
3354 plots.back().yaxis( &(histo.yaxis()) );
3355
3356 std::cout << "c: " << c << "\t" << ftest->GetName() << std::endl;
3357
3358 if ( refbands ) {
3359 std::cout << "refbands: " << refbands << std::endl;
3360 plots.back().mc( true );
3361 translate_x = false;
3362 }
3363
3364 if ( ALLRANGEMAP || ( RANGEMAP && xaxis.find("p_{T}")!=std::string::npos ) ) plots.back().max_entries( ccolours.size() );
3365
3366 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3367
3368 if ( make_ref_efficiencies ) {
3369
3370 if ( htestnum && hrefnum ) {
3371 Efficiency1D e( htestnum, hrefnum, "", scale_eff );
3372
3373 TH1* h = e.Hist();
3374
3375 double range = h->GetMaximum()-h->GetMinimum();
3376
3377 if ( range<0.2*scale_eff ) {
3378
3379 double fmax = int( (h->GetMaximum() + 20)*0.1 )*0.1*scale_eff;
3380 double fmin = int( (h->GetMinimum() - 10)*0.1 )*0.1*scale_eff;
3381
3382 if ( fmax>1*scale_eff ) fmax = 1.02*scale_eff;
3383 if ( fmin<0 ) fmin = 0;
3384
3385 h->SetMinimum(fmin);
3386 h->SetMaximum(fmax);
3387
3388 }
3389
3390 plots_eff.push_back( Plotter( e.Hist(), 0, c ) );
3391
3392 }
3393 }
3394
3395
3396 std::cout << "means: " << drawmeans << " " << means << std::endl;
3397
3398 std::cout << "chi2: " << std::endl;
3399
3400 std::cout << "htest " << htest << std::endl;
3401 std::cout << "href " << href << std::endl;
3402
3403 std::cout << "chi2: " << chi2( htest, href ) << "\t histo name: " << histo.name() << std::endl;
3404
3405 testfit( htest, histo.name() );
3406
3407
3408 if ( href ) Chi2.push_back( label( "chi2 = %5.2lf / %2.0lf", chi2( htest, href ), double(htest->GetNbinsX()) ) );
3409
3410 std::cout << "Chi2.push_back()" << std::endl;
3411
3412 if ( drawmeans || means ) {
3413
3414 double mean_95 = htest->GetMean();
3415 double dmean_95 = htest->GetMeanError();
3416 double rms_95 = htest->GetRMS();
3417 double drms_95 = htest->GetRMSError();
3418
3419 Mean.push_back(label(" mean = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
3420 MeanLF.push_back(label("mean = %6.4lf #pm %6.4lf", mean_95, dmean_95) );
3421 RMS.push_back(label( " rms = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
3422
3423 }
3424
3425 std::cout << "residual: " << residual << " " << drawresiduals << std::endl;
3426
3427 if ( residual && drawresiduals ) {
3428
3430
3431 xpos = xpos_original;
3432
3433 std::cout << "calculating resolutions : " << histo.name() << " " << htest->GetName() << std::endl;
3434
3435 TF1* d95 = Resplot::FitNull95(reinterpret_cast<TH1D*>(htest));
3436
3437 double mean_95 = d95->GetParameter(1);
3438 double dmean_95 = d95->GetParError(1);
3439 double rms_95 = d95->GetParameter(2);
3440 double drms_95 = d95->GetParError(2);
3441
3442 std::cout << "\t\t" << histo.name()
3443 << "\tmean: " << mean_95 << " +- " << dmean_95
3444 << "\trms: " << rms_95 << " +- " << drms_95 << std::endl;
3445
3447
3448 if ( !power_set ) {
3449 for ( int ip=-2 ; ip<9 ; ip++ ) {
3450 if ( std::fabs(mean_95) >= std::pow( 10., double(-ip) ) ) {
3451 mean_power = ip;
3452 break;
3453 }
3454 }
3455
3456 for ( int ip=-2 ; ip<9 ; ip++ ) {
3457 if ( std::fabs(rms_95) >= std::pow( 10., double(-ip) ) ) {
3458 rms_power = ip;
3459 break;
3460 }
3461 }
3462 }
3463
3464 power_set = true;
3465
3466 std::cout << "\t\t" << histo.name()
3467 << "\tmean: " << mean_95 << " +- " << dmean_95 << " : pow " << mean_power
3468 << "\trms: " << rms_95 << " +- " << drms_95 << " : pow " << rms_power << std::endl;
3469
3470
3471 if ( mean_power == 0 ) {
3472 Mean.push_back(label("mean_{95} = %4.2lf #pm %4.2lf", mean_95, dmean_95) );
3473 }
3474 else {
3475 Mean.push_back(label("mean_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3476 mean_95*std::pow(10.,double(mean_power)), dmean_95*std::pow(10,double(mean_power)), -mean_power ) );
3477
3478 }
3479
3480 if ( rms_power == 0 ) {
3481 RMS.push_back(label( "rms_{95} = %4.2lf #pm %4.2lf", rms_95, drms_95 ) );
3482 }
3483 else {
3484 RMS.push_back(label( "rms_{95} = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3485 rms_95*std::pow(10.,double(rms_power)), drms_95*std::pow(10,double(rms_power)), -rms_power ) );
3486 }
3487
3488 if ( href ) {
3489 TF1* d95ref = Resplot::FitNull95(reinterpret_cast<TH1D*>(href));
3490
3491 double mean_95ref = d95ref->GetParameter(1);
3492 double dmean_95ref = d95ref->GetParError(1);
3493 double rms_95ref = d95ref->GetParameter(2);
3494 double drms_95ref = d95ref->GetParError(2);
3495
3496 std::cout << "\t\t" << histo.name()
3497 << "\tmean ref: " << mean_95ref << " +- " << dmean_95ref << " : pow " << mean_power
3498 << "\trms ref: " << rms_95ref << " +- " << drms_95ref << " : pow " << rms_power << std::endl;
3499
3500 if ( mean_power == 0 ) {
3501 MeanRef.push_back(label("mean_{95} ref = %4.2lf #pm %4.2lf", mean_95ref, dmean_95ref) );
3502 }
3503 else {
3504 MeanRef.push_back(label("mean_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3505 mean_95ref*std::pow(10,double(mean_power)), dmean_95ref*std::pow(10,double(mean_power)), -mean_power ) );
3506
3507 }
3508
3509
3510 if ( rms_power == 0 ) {
3511 RMSRef.push_back(label( "rms_{95} ref = %4.2lf #pm %4.2lf", rms_95ref, drms_95ref ) );
3512 }
3513 else {
3514 RMSRef.push_back(label( "rms_{95} ref = ( %4.2lf #pm %4.2lf ) #times 10^{%d}",
3515 rms_95ref*std::pow(10,double(rms_power)), drms_95ref*std::pow(10,double(rms_power)), -rms_power ) );
3516 }
3517 }
3518
3519 htest->Sumw2();
3520 if ( href ) href->Sumw2();
3521 }
3522
3523 if ( yinfo.normset() ) {
3524 Norm( htest );
3525 if ( href ) Norm( href );
3526 if ( xinfo.rangeset() ) {
3527 Norm( htest, 1, xinfo.lo(), xinfo.hi() );
3528 if ( href ) Norm( href, 1, xinfo.lo(), xinfo.hi() );
3529 }
3530 }
3531 else if ( yinfo.refnormset() ) {
3532 if ( href ) {
3533 Norm( href, Entries(htest) );
3534 if ( xinfo.rangeset() ) {
3535 Norm( href, 1, xinfo.lo(), xinfo.hi() );
3536 }
3537 }
3538 }
3539
3540 if ( yinfo.binwidth() ) {
3541 binwidth( htest );
3542 if ( href ) binwidth( href );
3543 }
3544
3545 if ( !noreftmp && normref &&
3546 !contains( histo.name(), "mean") && !contains( histo.name(), "sigma" ) &&
3547 !contains( histo.name(), "Eff") && !contains( histo.name(), "eff") &&
3548 !contains( histo.name(), "Res") && !contains( histo.name(), "vs") && !contains( histo.name(), "_lb") ) {
3549 Norm( href, Entries( htest ) );
3550 }
3551
3552 }
3553
3554 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3555
3556 if ( !noplots ) {
3557
3560
3561 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3562
3563 std::cout << "duff: " << xinfo << std::endl;
3564
3566 plots.sortx( xinfo );
3567
3568 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3569
3570 double yminset = 0;
3571 double ymaxset = 0;
3572
3573 double rmin = 0;
3574 double rmax = 0;
3575
3576 if ( xinfo.rangeset() ) {
3577 rmin = plots.realmin( plots.lo(), plots.hi() );
3578 rmax = plots.realmax( plots.lo(), plots.hi() );
3581 // if ( yinfo.normset() ) {
3582 // Norm( htest, 1, rmin, rmax );
3583 // if ( href ) Norm( href, 1, rmin, rmax );
3584 // }
3585 }
3586 else {
3587 rmin = plots.realmin();
3588 rmax = plots.realmax();
3589 }
3590
3591 if ( yinfo.autoset() ) {
3592
3593 int csize = chains.size() + taglabels.size() + ( atlasstyle ? 1 : 0 );
3594
3595 if ( yinfo.log() && rmin>0 && rmax>0 ) {
3596
3598 double delta = std::log10(rmax)-std::log10(rmin);
3599
3601 // ymaxset = rmax*std::pow(10,delta*0.15*csize);
3602
3603 yminset = rmin*std::pow(10,-delta*0.1);
3604
3605 double newdelta = std::log10(rmax) - std::log10(yminset) + 0.05*delta;
3606
3607 if ( csize<10 ) ymaxset = rmin*std::pow(10,newdelta/(1-0.07*csize));
3608 else ymaxset = rmin*std::pow(10,newdelta*2);
3609
3610 if ( yminset!=yminset ) {
3611 std::cerr << " range error " << delta << " " << yminset << " " << ymaxset << "\t(" << rmin << " " << rmax << ")" << std::endl;
3615 continue;
3616 }
3617
3618 }
3619 else {
3620
3623
3624 if ( ypos>0.5 ) {
3625 double delta = rmax-rmin;
3626
3627 yminset = rmin-0.1*delta;
3628
3629 if ( rmin>=0 && yminset<=0 ) yminset = 0;
3630
3631 double newdelta = rmax - yminset + 0.05*delta;
3632
3633 if ( csize<10 ) ymaxset = yminset + newdelta/(1-0.09*csize);
3634 else ymaxset = yminset + newdelta*2;
3635 }
3636 else {
3637 double delta = rmax-rmin;
3638
3639 ymaxset = rmax+0.1*delta;
3640
3641 double newdelta = ymaxset - rmin - 0.05*delta;
3642
3643 if ( csize<10 ) yminset = ymaxset - newdelta/(1-0.09*csize);
3644 else yminset = ymaxset - newdelta*2;
3645
3646 if ( rmin>=0 && yminset<=0 ) yminset = 0;
3647
3648 }
3649
3650 }
3651
3652 }
3653 else {
3654 if ( yinfo.rangeset() ) {
3655 yminset = yinfo.lo();
3656 ymaxset = yinfo.hi();
3657 }
3658 }
3659
3660 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3661
3662 // more useful debugging ...
3663 // std::cout << "yauto: " << yinfo.autoset() << "\tyrange " << yinfo.rangeset() << std::endl;
3664
3665 // std::cout << "yminset " << yminset << "\tymaxset " << ymaxset << std::endl;
3666
3667 if ( yinfo.autoset() && yinfo.rangeset() ) {
3668
3669 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3670
3671 if ( yminset>yinfo.lo() ) yminset = yinfo.lo();
3672 if ( ymaxset<yinfo.hi() ) ymaxset = yinfo.hi();
3673 }
3674
3675
3676 if ( make_efficiencies && contains(histo.name(),"_eff") ) {
3677
3678 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3679
3680 if ( effset ) {
3681 ymaxset = effmax;
3682 yminset = effmin;
3683 }
3684 }
3685
3686 if ( ymaxset!=0 || yminset!=0 ) {
3687
3688 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3689
3690 plots.Max( ymaxset );
3691 plots.Min( yminset );
3692 }
3693
3694 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3695
3696 if ( yminset!=0 || ymaxset!=0 ) {
3697 if ( yminset>0 ) plots.SetLogy(yinfo.log());
3698 else plots.SetLogy(false);
3699 }
3700 else plots.SetLogy(yinfo.log());
3701
3702 // plots.SetLogy(false);
3703
3704 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3705
3706 // plots.limits();
3707
3709
3710 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3711
3712 plots.Draw( legend );
3713
3714 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3715
3716 if ( atlasstyle ) ATLASLabel( xpos, ypositions[0]+deltay, atlaslabel, labelcolour, ncolsp, nrowsp );
3717
3718 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3719
3720 for ( unsigned it=0 ; it<taglabels.size() ; it++ ) {
3721 DrawLabel( xpos, ypositions[it], taglabels[it], labelcolour, 0.04 );
3722 }
3723
3724 for ( unsigned it=0 ; it<taglabels2.size() ; it++ ) {
3725 DrawLabel( xpos+0.35, ypositions2[it], taglabels2[it], labelcolour, 0.04 );
3726 }
3727
3728 }
3729
3730 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3731
3732 std::cout << "means: " << means << std::endl;
3733
3734 // if ( means ) for ( unsigned j=0 ; j<MeanLF.size() ; j++ ) DrawLabel( 0.5, (0.65-(j+chains.size()-1)*0.035), MeanLF[j], colours[j%6] ); // DrawLabel( 0.75, 0.85-j*0.035, Chi2[j], colours[j%6] );
3735 if ( means ) {
3736 if ( runnumber!="" ) DrawLabel( 0.2, 0.89, "run "+runnumber );
3737 for ( unsigned j=0 ; j<MeanLF.size() ; j++ ) DrawLabel( 0.2, (0.85-(j+chains.size()-1)*0.035), MeanLF[j], colours[j%6] );
3738 }
3739
3740
3741 // double ytop = 0.67;
3742 double ytop = 0.5;
3743
3744 if ( ( !nostats || !nomeans ) && !noplots ) {
3745 if ( dochi2 ) for ( unsigned j=0 ; j<Chi2.size() ; j++ ) DrawLabel( 0.75, 0.85-j*0.035, Chi2[j], colours[j%6] );
3746 if ( ( (contains(histo.name(),"_res") ||
3747 contains(histo.name(),"1d") ||
3748 histo.name()=="pT" ||
3749 contains(histo.name(),"residual_") ||
3750 contains(histo.name(),"vs_pt") ) && !contains(histo.name(),"sigma") ) || drawmeans ) {
3751
3752 if ( contains(histo.name(),"_res") || contains(histo.name(),"residual_") || contains(histo.name(),"1d") || drawresiduals ) {
3753 for ( unsigned j=0 ; j<chains.size() ; j++ ) {
3754 if ( !noreftmp ) {
3755 if ( j<MeanRef.size() ) {
3756 if ( !nomeans ) DrawLabel( xpos_original, (ytop-j*0.035), MeanRef[j], colours[j%6] );
3757 DrawLabel( xpos_original, (ytop-0.035*chains.size()-j*0.035)-0.01, RMSRef[j], colours[j%6] );
3758 }
3759 }
3760 if ( j<Mean.size() ) {
3761 if ( !nomeans ) DrawLabel( 0.62, (ytop-j*0.035), Mean[j], colours[j%6] );
3762 DrawLabel( 0.62, (ytop-0.035*chains.size()-j*0.035)-0.01, RMS[j], colours[j%6] );
3763 }
3764 }
3765 }
3766 }
3767 }
3768
3769 if ( xinfo.log() ) gPad->SetLogx(true);
3770 else gPad->SetLogx(false);
3771
3772 if ( yinfo.log() ) gPad->SetLogy(true);
3773 else gPad->SetLogy(false);
3774
3775 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3776
3777 if ( !noplots ) {
3778
3779 if ( make_ref_efficiencies ) {
3780
3781 plots_eff.SetXaxisTitle( plots.GetXaxisTitle() );
3782 plots_eff.SetYaxisTitle( plots.GetYaxisTitle() );
3783
3784 plots_eff.Draw( legend_eff );
3785 }
3786
3787 if ( !noreflabel.empty() ) DrawLabel(0.1, 0.06, noreflabel, kRed, 0.03 );
3788
3789 } // no plots
3790
3791 }
3792
3793
3799
3800 if ( !noplots ) {
3801
3802 if ( !quiet ) {
3803
3804 tc->cd();
3805
3806 std::string useplotname;
3807
3808 if ( panel.size()>1 ) {
3809 useplotname = panel.name();
3810 replace( useplotname, '/', '_' );
3811 }
3812 else {
3813 useplotname = plotname;
3814 }
3815
3816 useplotname.erase( std::remove( useplotname.begin(), useplotname.end(), '+' ), useplotname.end() );
3817
3818 std::string printbase = dir + useplotname + tag;
3819
3820 tc->Update();
3821
3822 if ( !nopdf ) print_pad( printbase+".pdf" );
3823 if ( !nopng ) print_pad( printbase+".png" );
3824 if ( Cfile ) print_pad( printbase+".C" );
3825
3826 std::cout << std::endl;
3827 }
3828
3829 }
3830
3831 if ( tc ) delete tc;
3832
3833 }
3834
3835
3836 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3837
3839
3840
3842 bool files_duplicated = ( fref_==ftest_ );
3843
3844 if ( deleteref && !files_duplicated ) {
3845
3846 if ( fref_ ) {
3847
3849
3850 std::cout << "main() cleaning up reference file" << std::endl;
3851
3852 TFile* newout = new TFile(".newout.root","recreate");
3853 newout->cd();
3854
3856 copyReleaseInfo( fref, newout );
3857
3858 TDirectory* base = gDirectory;
3859
3860 for ( unsigned i=0 ; i<savedhistos.size() ; i++ ) {
3861
3863 // std::cout << i << " " << savedhistos[i] << std::endl;
3864
3865 std::vector<std::string> dirs = AxisInfo::split( savedhistos[i], "/" );
3866
3867 for ( unsigned j=0 ; j<dirs.size()-1 ; j++ ) {
3868 std::cout << "\t" << dirs[j] << std::endl;
3869 TDirectory* renedir = gDirectory->GetDirectory( dirs[j].c_str() );
3870 if ( renedir==0 ) gDirectory->mkdir( dirs[j].c_str() );
3871 gDirectory->cd( dirs[j].c_str() );
3872 }
3873
3874
3875 TH1* href = Get( *fref, savedhistos[i].c_str(), "", chainmap );
3876 if ( !noreftmp && href ) {
3877 std::cout << i << " " << savedhistos[i] << " 0x" << href << std::endl;
3878 href->Write( dirs.back().c_str() );
3879 }
3880
3881
3882 base->cd();
3883 }
3884
3885 newout->Close();
3886
3887 }
3888 }
3889
3890
3891 if ( fulldbg ) std::cout << __LINE__ << std::endl;
3892
3894
3895 if ( fref_ && !files_duplicated ) fref_->Close();
3896 if ( ftest_ ) ftest_->Close();
3897
3899
3900 if ( deleteref && !noref ) {
3901 std::cout << "ref " << frefname << "\ttest " << ftestname << std::endl;
3902 if ( frefname != ftestname && !files_duplicated ) {
3903 std::string cmd = std::string("mv ") + frefname + " " + frefname + ".bak";
3904 std::system( cmd.c_str() );
3905
3906 cmd = std::string("mv .newout.root ") + std::string(frefname);
3907 std::system( cmd.c_str() );
3908 }
3909 else {
3910 std::cerr << "reference file and test file are the same - not replacing" << std::endl;
3911 }
3912 }
3913
3914 std::cout << "deleting at " << __LINE__ << std::endl;
3915
3916 if ( fref_ && !files_duplicated ) delete fref_;
3917 if ( ftest_ ) delete ftest_;
3918
3919 return 0;
3920}
TStyle * AtlasStyle()
static Double_t rc
void ATLASLabel(Double_t x, Double_t y, char *text=NULL, Color_t color=1)
class to store information about axes, limits, whether it is log or linear scale etc
Definition computils.h:154
bool autoset() const
Definition computils.h:262
double binwidth() const
Definition computils.h:285
bool rangeset() const
Definition computils.h:270
bool refnormset() const
Definition computils.h:266
bool trim() const
Definition computils.h:272
double hi() const
Definition computils.h:279
bool log() const
Definition computils.h:260
static std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition computils.h:291
double offset() const
Definition computils.h:275
bool normset() const
Definition computils.h:264
double lo() const
Definition computils.h:278
details of the histogram axes etc
Definition computils.h:1562
slightly more convenient legend class
Definition computils.h:350
int ncols() const
Definition computils.h:1675
size_t size() const
Definition computils.h:1666
const std::string & name() const
Definition computils.h:1664
int nrows() const
Definition computils.h:1674
set of generic plots
Definition computils.h:1204
static void setwatermark(bool b)
Definition computils.h:1527
Get tag-value pairs from a file.
Definition ReadCards.h:50
void range(const std::string &chain, TH1F *h)
static void setplotref(bool b)
Definition computils.h:1131
void d0fit(const HistDetails &histo, TH1 *ht, const std::string &chain="")
void autoy(TH2 *h)
get the auto y range of a 2d histogram
TH1F * rebin_log(TH1F *h, bool low=false)
bool EPS
bool fulldbg
const std::string blue
bool LINES
Definition computils.cxx:41
void normy(TH2 *h)
zero the contents of a 2d histogram
TH1F * trans(TH1F *h, bool t=false)
void print_pad(const std::string &s)
int markers[6]
Definition computils.cxx:49
void arsaway(std::string &s, const std::string &pattern, const std::string &rep)
void testfit(TH1 *htest, const std::string &s)
const std::string black
bool isTEfficiency(T *h)
double total_eff(TH1 *hn, TH1 *hd)
std::string fullreplace(std::string s, const std::string &s2, const std::string &s3)
void ifdbg(const std::string &)
void autox(TH2 *h, bool t=false)
get the auto x range of a 2d histogram
TH1F * d0rebin(TH1F *h)
bool LINEF
Definition computils.cxx:40
std::map< std::string, std::string > chainmap_t
global typedef here is ok, since this is a standalone executable, including a main().
double chi2(TH1 *h0, TH1 *h1)
TH1F * makeplot(TObject *hreft)
TH1F * Rebin(TH1F *h, double f)
void Scale(TH1 *h, double d=1)
void SetZeros(TH2D *h)
int colours[6]
Definition computils.cxx:48
T * Get(TFile &f, const std::string &n, const std::string &dir="", const chainmap_t *chainmap=0, std::vector< std::string > *saved=0)
get a histogram given a path, and an optional initial directory if histogram is not found,...
void copyReleaseInfo(TFile *finput, TFile *foutdir)
copy the release info TTree
void Norm(TH1 *h, double scale, double xmin, double xmax)
double Entries(TH1 *h)
std::string findrun(TFile *f)
bool exists(const std::string &filename)
does a file exist
bool JLflag
Definition computils.cxx:44
bool fcontains(const std::string &s, const std::string &p)
contains a string at the beginning of the string
tPlotter< TH1F > Plotter
Definition computils.h:1173
static std::string release
Definition computils.h:54
panel_type res_panel
panel_type diff_panel
panel_type eff_panel
StatusCode usage()
std::vector< std::string > savedhistos
Definition hcg.cxx:55
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:312
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:140
std::string base
Definition hcg.cxx:83
std::map< std::string, int > dirs
list of directories to be explicitly included, together with corresponding depths of subdirectories
Definition hcg.cxx:104
std::string chop(std::string &s1, const std::string &s2)
Definition hcg.cxx:163
static std::vector< uint32_t > runnumber
Definition iLumiCalc.h:37
std::string label(const std::string &format, int i)
Definition label.h:19
bool binwidth
Definition listroot.cxx:58
const std::regex rx1(R"(_v[0-9]+$)")
TF1 * FitNull(TH1D *s, double a=-999, double b=-999)
Definition Resplot.cxx:1093
bool setoldrms95(bool b)
Definition Resplot.h:722
bool setscalerms95(bool b)
Definition Resplot.h:723
TF1 * FitNull95(TH1D *s, double a=0, double b=0)
Definition Resplot.cxx:1472
constexpr int pow(int x)
Definition conifer.h:27
int ic
Definition grepfile.py:33
rebin(binning, data)
mkdir(path, recursive=True)
DataModel_detail::iterator< DVL > remove(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, const T &value)
Specialization of remove for DataVector/List.
TFile * file
std::string dirname(std::string name)
Definition utils.cxx:200
std::string basename(std::string name)
Definition utils.cxx:207

◆ makeplot()

TH1F * makeplot ( TObject * hreft)

these are nice, would have liked to keep them ...

Definition at line 654 of file comparitor.cxx.

654 {
655
656 TH1F* href = 0; // (TH1F*)hreft->Clone();
657
658 if ( isTEfficiency( hreft ) ) {
659
660 TH1F* hn = (TH1F*)dynamic_cast<TEfficiency*>(hreft)->GetPassedHistogram();
661 TH1F* hd = (TH1F*)dynamic_cast<TEfficiency*>(hreft)->GetTotalHistogram();
663 // TH1F* hn = (TH1F*)((TEfficiency*)hreft)->GetPassedHistogram();
664 // TH1F* hd = (TH1F*)((TEfficiency*)hreft)->GetTotalHistogram();
665
666 // hd->DrawCopy();
667 // gPad->SetLogy(true);
668 // gPad->Print("den.pdf");
669
670 // hn->DrawCopy("same");
671 // gPad->SetLogy(true);
672 // gPad->Print("num.pdf");
673
674 href = (TH1F*)hn->Clone("ars"); href->SetDirectory(0);
675 for ( int ie=1 ; ie<=href->GetNbinsX() ; ie++ ) {
676 if ( hd->GetBinContent(ie)==0 ) { href->SetBinContent( ie, 0 ); href->SetBinError( ie, 0 ); }
677 else {
678 double e = hn->GetBinContent(ie)/hd->GetBinContent(ie);
679 double ee = e*(1-e)/hn->GetBinContent(ie);
680 //if (e>1) e=1;
681 href->SetBinContent( ie, e );
682 href->SetBinError( ie, ee );
683 }
684 }
685 }
686
687 // if ( href) href->DrawCopy();
688 // gPad->SetLogy(false);
689 // gPad->Print("plot.pdf");
690
691 return href;
692}

◆ normaliseBinWidth()

void normaliseBinWidth ( TH1 * h)

Definition at line 76 of file comparitor.cxx.

76 {
77
78 if ( !h ) return;
79
80 int nbins = h->GetNbinsX();
81 double width = h->GetBinWidth(1);
82
83 double eps = 1e-12;
84
85 bool variable = false;
86
87 for ( int i=2 ; i<=nbins ; i++ ) {
88 if ( std::fabs( h->GetBinWidth(i)-width )>eps ) {
89 variable = true;
90 break;
91 }
92 }
93
94 if ( !variable ) return;
95
96 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
97 double w = h->GetBinWidth(i);
98 h->SetBinContent( i, h->GetBinContent(i)/w );
99 h->SetBinError( i, h->GetBinError(i)/w );
100 }
101
102}
const double width

◆ normy()

void normy ( TH2 * h)

zero the contents of a 2d histogram

Definition at line 713 of file comparitor.cxx.

713 {
714 int Nx = h->GetNbinsX();
715 int Ny = h->GetNbinsY();
716 for ( int i=1 ; i<=Nx ; i++ ) {
717 double n = 0;
718 for ( int j=1 ; j<=Ny ; j++ ) n += h->GetBinContent(i,j);
719 if ( n>0 ) for ( int j=1 ; j<=Ny ; j++ ) h->SetBinContent( i, j, h->GetBinContent(i,j)/n );
720 }
721}

◆ print_pad()

void print_pad ( const std::string & s)

Definition at line 647 of file comparitor.cxx.

647 {
648 std::cout << green << "Printing " << s << reset << std::endl;
649 gPad->Print( s.c_str() );
650 if ( EPS ) gPad->Print( (s+".eps").c_str() );
651}

◆ Rebin()

TH1F * Rebin ( TH1F * h,
double f )

Definition at line 258 of file comparitor.cxx.

258 {
259
260 std::cout << "\nREBIN: " << h->GetName() << " :: " << f << std::endl;
261
262 if ( int(f) == f ) {
263 TH1F* n = (TH1F*)h->Clone((std::string(h->GetName())+"-foeda").c_str()); n->SetDirectory(0);
264 n->Rebin(int(f));
265 return n;
266 }
267
268 int fi=int(f);
269 double fb=(f-fi);
270
271 for ( int i=0 ; i<10 ; i++ ) {
272 fb *= 10;
273 if ( std::fabs(int(fb)-fb)<1e-6 ) break;
274 }
275
276 std::vector<double> limits;
277 std::vector<double> contents;
278
279 for ( int i=1 ; i<=h->GetNbinsX()+1 ; i++ ) {
280 limits.push_back( h->GetBinLowEdge(i) );
281 contents.push_back( h->GetBinContent(i) );
282 if ( i<fb ) {
283 for ( int ib=1 ; ib<fi ; ib++ ) contents.back() += h->GetBinContent(++i);
284 }
285 }
286
287 TH1F* n = new TH1F( "foeda", h->GetTitle(), limits.size()-1, &limits[0] ); n->SetDirectory(0);
288
289 for ( size_t i=0 ; i<contents.size() ; i++ ) n->SetBinContent( i+1, contents[i] );
290
291 return n;
292}
void contents(std::vector< std::string > &keys, TDirectory *td, const std::string &directory, const std::string &pattern, const std::string &path)

◆ rebin_log()

TH1F * rebin_log ( TH1F * h,
bool low = false )

Definition at line 297 of file comparitor.cxx.

297 {
298
299 double limits[40] = {
300 0.5, 1.5, 2.5, 3.5, 4.5,
301 5.5, 6.5, 7.5, 8.5, 9.5,
302 10.5, 11.5, 12.5, 13.5, 14.5,
303 15.5, 16.5, 17.5, 18.5, 19.5,
304 20.5, 21.5, 22.5, 23.5, 24.5,
305 25.5, 26.5, 28.5, 30.5, 32.5,
306 35.5, 38.5, 42.5, 46.5, 50.5,
307 55.5, 60.5, 66.5, 72.5, 78.5
308 };
309
310 double lowlimits[24] = {
311 0.5, 1.5, 2.5, 3.5, 4.5,
312 5.5, 6.5, 7.5, 8.5, 9.5,
313 10.5, 11.5, 12.5, 14.5, 17.5,
314 20.5, 24.5, 29.5, 35.5, 42.5,
315 50.5, 60.5, 72.5, 86.5,
316 };
317
318 TH1F* n;
319
320 if ( low ) n = new TH1F( "foeda", h->GetTitle(), 39, limits );
321 else n = new TH1F( "foeda", h->GetTitle(), 23, lowlimits );
322
323 n->SetDirectory(0);
324
325 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
326 n->Fill( h->GetBinCenter(i), h->GetBinContent(i) );
327 }
328
329
330 for ( int i=1 ; i<=n->GetNbinsX() ; i++ ) {
331 n->SetBinError(i, std::sqrt( n->GetBinContent(i) ) );
332 }
333
334 return n;
335}

◆ Scale()

void Scale ( TH1 * h,
double d = 1 )

Definition at line 249 of file comparitor.cxx.

249 {
250 if ( d==1 ) return;
251 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
252 h->SetBinContent( i, h->GetBinContent(i)*d );
253 h->SetBinError( i, h->GetBinError(i)*d );
254 }
255}

◆ SetZeros()

void SetZeros ( TH2D * h)

Definition at line 240 of file comparitor.cxx.

240 {
241 for ( int i=1 ; i<=h->GetNbinsX() ; i++ ) {
242 for ( int j=1 ; j<=h->GetNbinsY() ; j++ ) {
243 int ibin = h->GetBin( i, j );
244 if ( h->GetBinContent(ibin)==0 ) h->SetBinContent(ibin, 0.1);
245 }
246 }
247}

◆ testfit()

void testfit ( TH1 * htest,
const std::string & s )

Definition at line 107 of file comparitor.cxx.

107 {
108
109 if ( htest && s.find("invmass")!=std::string::npos ) {
110
111 TVirtualPad* p = gPad;
112
113 TCanvas canv("canv", "", 700, 600 );
114 canv.cd();
115
116 std::cout << "testfit: s" << s << "\t" << htest << std::endl;
117
118 // TF1 finv( "inv", "pow([0]*exp( (x-[1])*([1]-x)/([2]*[2]) ), [6]) + [3]+x*([4]+x*[5])" );
119 TF1 finv( "inv", "pow([0]/([2]+([1]-x)*([1]-x)), [6]) + [3]+x*([4]+x*[5])" );
120
121 finv.SetParameter(0, 10000);
122 finv.SetParameter(1, 91);
123 finv.SetParameter(2, 7);
124 finv.SetParameter(3, 1000);
125 finv.SetParameter(4, 0.01);
126 finv.SetParameter(5, 0);
127 finv.SetParameter(6, 1);
128
129 finv.SetLineWidth(1);
130
131 finv.SetParLimits(1, 89, 93 );
132 finv.SetParLimits(2, 5, 50 );
133
134 std::vector<double> errors(htest->GetNbinsX());
135 for ( size_t i=0 ; i<errors.size() ; i++ ) {
136 errors[i] = htest->GetBinError(i+1);
137 htest->SetBinError(i+1, 20);
138 if (htest->GetBinContent(i+1)==0 ) htest->SetBinError(i+1, 0);
139 }
140
141 htest->Fit( &finv, "", "", 75, 105 );
142
143 static int i = 0;
144
145 for ( size_t i=0 ; i<errors.size() ; i++ ) htest->SetBinError(i+1, errors[i] );
146
147 htest->GetXaxis()->SetRangeUser(55,125);
148 htest->DrawCopy("e1");
149
150 gPad->Print( ("invmass-"+std::to_string(i++)+".pdf").c_str() );
151
152 std::cout << "inv mass: " << finv.GetParameter(1) << " +- " << finv.GetParError(1) << std::endl;
153
154 p->cd();
155
156 }
157
158}

◆ total_eff()

double total_eff ( TH1 * hn,
TH1 * hd )

Definition at line 161 of file comparitor.cxx.

161 {
162 double n = 0;
163 double d = 0;
164
165 for ( int i=0 ; i<=hn->GetNbinsX()+1 ; i++ ) n += hn->GetBinContent(i);
166 for ( int i=0 ; i<=hd->GetNbinsX()+1 ; i++ ) d += hd->GetBinContent(i);
167
168 std::cout << "num: " << n << "\tden: " << d << "\t";
169
170 if ( d!=0 ) return (n/d);
171
172 return 0;
173}

◆ trans()

TH1F * trans ( TH1F * h,
bool t = false )

Definition at line 199 of file comparitor.cxx.

199 {
200
201 std::cout << "trans in" << std::endl;
202
203 if ( !t ) return h;
204
205 std::cout << "trans processing ..." << std::endl;
206
207 h->SetDirectory(0);
208
209 std::vector<double> xlim( h->GetNbinsX()+1 );
210
211 for ( int i=0 ; i<h->GetNbinsX()+1 ; i++ ) {
212 xlim[i] = h->GetBinLowEdge(i+1)*(1-0.054);
213 }
214
215 TH1F* hn = new TH1F( (std::string(h->GetName())+"-transx").c_str(), h->GetTitle(), h->GetNbinsX(), &xlim[0] );
216 hn->SetDirectory(0);
217
218 hn->SetLineStyle(h->GetLineStyle());
219 hn->SetLineColor(h->GetLineColor());
220 hn->SetLineWidth(h->GetLineWidth());
221 hn->SetMarkerStyle(h->GetMarkerStyle());
222 hn->SetMarkerColor(h->GetMarkerColor());
223 hn->SetMarkerSize(h->GetMarkerSize());
224
225 for ( int i=0 ; i<h->GetNbinsX() ; i++ ) {
226 if ( hn->GetBinLowEdge(i)<14 ) continue;
227 hn->SetBinContent( i+1, h->GetBinContent( i+1 ) );
228 hn->SetBinError( i+1, h->GetBinError( i+1 ) );
229 }
230
231 delete h;
232
233 return hn;
234
235}

◆ usage()

int usage ( const std::string & name,
int status,
const std::string & err_msg = "" )

Definition at line 544 of file comparitor.cxx.

544 {
545 if ( err_msg != "" ) std::cerr << err_msg << "\n" << std::endl;
546 std::ostream& s = std::cout;
547 s << "Usage: " << name << "\t [OPTIONS] test.root reference.root chain1 chain2 chain2 ...\n\n";
548 s << "\t" << " plots comparison histograms";
549 s << " - compiled on " << __DATE__ << " at " << __TIME__ << "\n\n";
550 s << "Options: \n";
551 s << " -c, --config value \t configure which histograms to plot from config file,\n\n";
552 s << " -t, --tag value \t appends tag 'value' to the end of output plot names, \n";
553 s << " -k, --key value \t prepends key 'value' to the front of output plots name, \n";
554 s << " -t, --tag value \t post pend tag 'value' to the end of output plots name, \n";
555 s << " -d, --dir value \t creates output files into directory, \"value\" \n\n";
556 s << " --ncols value \t creates panels with \"value\" columns\n\n";
557
558 s << " -e, --efficiencies \t make test efficiencies with respect to reference \n";
559 s << " -es, --effscale value \t scale efficiencies to value\n";
560 s << " -er, --effscaleref value \t scale reference efficiencies to value\n";
561 s << " -nb --nobayes \t do not calculate Basyesian efficiency uncertaintiesr\n\n";
562
563 s << " -r, --refit \t refit all test resplots\n";
564 s << " -rr, --refitref \t also refit all reference resplots\n";
565 s << " --oldrms \t use fast rms95 when refitting resplots\n\n";
566
567 s << " -as, --atlasstyle \t use ATLAS style\n";
568 s << " -l, --labels values\t use specified labels for key\n";
569 s << " --taglabels values\t use specified additional labels \n";
570 s << " -al, --atlaslable value \t set value for atlas label\n";
571 s << " -sx, --swapaxtitles exp pattern\t swap the expression \"exp \" in the axis titles with \"pattern\"\n";
572 s << " -ac, --addchains \t if possible, add chain names histogram labels \n\n";
573
574 s << " -m, --mapfile \t remap file for reference histograms \n\n";
575
576 s << " -rc, --refchains values ..\t allow different reference chains for comparison\n";
577 s << " -s, --swap pattern regex \t swap \"pattern\" in the chain names by \"regex\"\n";
578 s << " --swapr pattern regex \t swap \"pattern\" in the ref chain names by \"regex\"\n";
579 s << " --swapt pattern regex \t swap \"pattern\" in the test chain names by \"regex\"\n";
580 s << " -nr, --noref \t do not plot reference histograms\n";
581 s << " --normref \t normalise the reference counting histograms to test histograms\n";
582 s << " -us, --usechainref \t use the histograms from chain definied in the \"Chain\" histogram as reference\n\n";
583 s << " --lumi \t scale pile-up mu values down by 5.4%\n";
584 s << " --lumitest \t scale pile-up mu values down by 5.4% for test histograms\n";
585 s << " --lumiref \t ecale pile-up mu values down by 5.4% for reference histograms\n";
586 s << " -rb, --refbands \t draw the reference as an error band, rather than a histogram\n\n";
587
588 s << " -ns, --nostats \t do not show stats for mean and rms\n";
589 s << " -nm, --nomeans \t do not show stats for the means\n";
590 s << " --means \t show stats for the means\n";
591 s << " --chi2 \t show the chi2 with respect to the reference\n\n";
592
593 s << " -np, --noplots \t do not actually make any plot\n";
594 s << " -q, --quiet \t make the plots but do not print them out\n\n";
595
596 s << " --unscalepix \t do not scale the number of pixels by 0.5 (unscaled by default)\n";
597 s << " --scalepix \t do scale the number of pixels by 0.5 (unscaled by default)\n";
598 s << " --yrange min max \t use specified y axis range\n";
599 s << " -xo, --xoffset value \t relative x offset for the key\n";
600 s << " -yp, --ypos value \t relative yposition for the key\n";
601 s << " -xe, --xerror value \t size of the x error tick marks\n";
602 s << " -nw, --nowatermark \t do not plot the release watermark\n\n";
603
604 s << " -C, --Cfiles \t write C files also\n";
605 s << " --eps \t create eps files\n";
606 s << " --nopng \t do not print png files\n";
607 s << " --nopdf \t do not print pdf files\n";
608 s << " --deleteref \t delete unused reference histograms\n\n";
609
610 s << " --printconfig \t print the configuration being used in the form useable as an input file\n\n";
611
612 s << " --run value \t print the run number on the plot\n\n";
613
614 s << " -h, --help \t this help\n";
615 // s << "\nSee " << PACKAGE_URL << " for more details\n";
616 // s << "\nReport bugs to <" << PACKAGE_BUGREPORT << ">";
617 s << std::endl;
618 return status;
619}
status
Definition merge.py:16

◆ zero()

void zero ( TH2 * h)

zero the contents of a 2d histogram

Definition at line 698 of file comparitor.cxx.

698 {
699 int Nx = h->GetNbinsX();
700 int Ny = h->GetNbinsY();
701 for ( int i=1 ; i<=Nx ; i++ ) {
702 for ( int j=1 ; j<=Ny ; j++ ) {
703 if ( h->GetBinContent( i, j )==0 ) {
704 h->SetBinContent( i, j, 1e-10 );
705 h->SetBinError( i, j, 1e-10 );
706 }
707 }
708 }
709}

Variable Documentation

◆ black

const std::string black = "\033[0;30m"

Definition at line 62 of file comparitor.cxx.

◆ blue

const std::string blue = "\033[0;34m"

Definition at line 65 of file comparitor.cxx.

◆ colours

int colours[6]
extern

Definition at line 48 of file computils.cxx.

48{ 1, 2, kBlue-4, 6, kCyan-2, kMagenta+2 };

◆ EPS

bool EPS = false

Definition at line 72 of file comparitor.cxx.

◆ fitcanvas

TCanvas* fitcanvas = 0

Definition at line 180 of file comparitor.cxx.

◆ fitcanvas_rec

TCanvas* fitcanvas_rec = 0

Definition at line 181 of file comparitor.cxx.

◆ fulldbg

bool fulldbg = false

Definition at line 67 of file comparitor.cxx.

◆ green

const std::string green = "\033[0;32m"

Definition at line 64 of file comparitor.cxx.

◆ LINEF

bool LINEF
extern

Definition at line 40 of file computils.cxx.

◆ LINES

bool LINES
extern

Definition at line 41 of file computils.cxx.

◆ markers

int markers[6]
extern

Definition at line 49 of file computils.cxx.

49{ 20, 24, 25, 26, 25, 22 };

◆ red

const std::string red = "\033[0;31m"

Definition at line 63 of file comparitor.cxx.

◆ reset

const std::string reset = "\033[0m"

Definition at line 61 of file comparitor.cxx.