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.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 &)
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

◆ 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 833 of file comparitor.cxx.

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