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

Go to the source code of this file.

Classes

class  bands

Typedefs

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

Functions

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

Variables

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

Detailed Description

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

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

Definition in file comparitor.cxx.

Typedef Documentation

◆ chainmap_t

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

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

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

Definition at line 345 of file comparitor.cxx.

Function Documentation

◆ arsaway()

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

Definition at line 193 of file comparitor.cxx.

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

◆ ascale()

void ascale ( TH1F * h,
double s_ )

Definition at line 632 of file comparitor.cxx.

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

◆ autox()

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

get the auto x range of a 2d histogram

Definition at line 727 of file comparitor.cxx.

727 {
728
729 int Nx = h->GetNbinsX();
730 int Ny = h->GetNbinsY();
731
732 double xhi = h->GetXaxis()->GetBinLowEdge(1);
733 double xlo = h->GetXaxis()->GetBinLowEdge( h->GetXaxis()->GetNbins() );
734
735 for ( int i=1 ; i<=Nx ; i++ ) {
736 double x = h->GetXaxis()->GetBinLowEdge(i);
737 for ( int j=1 ; j<=Ny ; j++ ) {
738 double n = h->GetBinContent(i,j);
739 if ( n!=0 ) {
740 if ( x<xlo ) {
741 if ( i>1 ) xlo = h->GetXaxis()->GetBinLowEdge(i-1);
742 else xlo = x;
743 }
744 if ( x>xhi ) {
745 if ( i<h->GetXaxis()->GetNbins() ) xhi = h->GetXaxis()->GetBinLowEdge(i+1);
746 else xhi = x;
747 }
748 }
749 }
750 }
751
752 if ( t ) {
753 xlo -= 5.4;
754 xhi -= 5.4;
755 }
756
757 h->GetXaxis()->SetRangeUser( xlo, xhi );
758}
#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 762 of file comparitor.cxx.

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

◆ binwidth()

void binwidth ( TH1F * h)

Definition at line 624 of file comparitor.cxx.

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

◆ chi2()

double chi2 ( TH1 * h0,
TH1 * h1 )

Definition at line 792 of file comparitor.cxx.

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

◆ d0fit()

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

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

Definition at line 844 of file comparitor.cxx.

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

◆ d0rebin()

TH1F * d0rebin ( TH1F * h)

Definition at line 483 of file comparitor.cxx.

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

◆ eround()

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

Definition at line 185 of file comparitor.cxx.

185 {
186 char ss[1024];
187 std::string s= "%" + std::to_string(decfigs+2) + "." + std::to_string(decfigs) + "lf";
188 std::sprintf( ss, s.c_str(), x );
189 return ss;
190}
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 642 of file comparitor.cxx.

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

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

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

828 {
829 // std::cout << "if dbg: " << s << std::endl;
830}

◆ isTEfficiency()

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

Definition at line 423 of file comparitor.cxx.

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

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

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

◆ makeplot()

TH1F * makeplot ( TObject * hreft)

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

Definition at line 656 of file comparitor.cxx.

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

◆ normaliseBinWidth()

void normaliseBinWidth ( TH1 * h)

Definition at line 78 of file comparitor.cxx.

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

◆ normy()

void normy ( TH2 * h)

zero the contents of a 2d histogram

Definition at line 715 of file comparitor.cxx.

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

◆ print_pad()

void print_pad ( const std::string & s)

Definition at line 649 of file comparitor.cxx.

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

◆ Rebin()

TH1F * Rebin ( TH1F * h,
double f )

Definition at line 260 of file comparitor.cxx.

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

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

◆ Scale()

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

Definition at line 251 of file comparitor.cxx.

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

◆ SetZeros()

void SetZeros ( TH2D * h)

Definition at line 242 of file comparitor.cxx.

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

◆ testfit()

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

Definition at line 109 of file comparitor.cxx.

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

◆ total_eff()

double total_eff ( TH1 * hn,
TH1 * hd )

Definition at line 163 of file comparitor.cxx.

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

◆ trans()

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

Definition at line 201 of file comparitor.cxx.

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

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

◆ zero()

void zero ( TH2 * h)

zero the contents of a 2d histogram

Definition at line 700 of file comparitor.cxx.

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

Variable Documentation

◆ black

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

Definition at line 64 of file comparitor.cxx.

◆ blue

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

Definition at line 67 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 74 of file comparitor.cxx.

◆ fitcanvas

TCanvas* fitcanvas = 0

Definition at line 182 of file comparitor.cxx.

◆ fitcanvas_rec

TCanvas* fitcanvas_rec = 0

Definition at line 183 of file comparitor.cxx.

◆ fulldbg

bool fulldbg = false

Definition at line 69 of file comparitor.cxx.

◆ green

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

Definition at line 66 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 65 of file comparitor.cxx.

◆ reset

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

Definition at line 63 of file comparitor.cxx.