Skip to content
Snippets Groups Projects
Commit d608de4f authored by Adam Edward Barton's avatar Adam Edward Barton :speech_balloon:
Browse files

Merge branch 'TIDAUser-dev' into 'master'

Fix key locations (hopefully for the last time) add new utility

See merge request atlas/athena!43848
parents 7a38b06e 5bfbebbc
No related branches found
No related tags found
No related merge requests found
......@@ -143,8 +143,10 @@ RM = rm
TAR = tar
DOBJECTS = $(OBJDIR)/dependence.o $(OBJDIR)/AtlasStyle.o $(OBJDIR)/AtlasLabels.o
COBJECTS = $(OBJDIR)/comparitor.o $(OBJDIR)/computils.o $(OBJDIR)/AtlasStyle.o $(OBJDIR)/AtlasLabels.o
CCOBJECTS = $(OBJDIR)/cpucost.o $(OBJDIR)/computils.o $(OBJDIR)/AtlasStyle.o $(OBJDIR)/AtlasLabels.o
CCHEADERS = $(SRCDIR)/computils.h
CHOBJECTS = $(OBJDIR)/chains.o
WOBJECTS = $(OBJDIR)/wmain.o
SOBJECTS = $(OBJDIR)/skim.o
......@@ -197,11 +199,13 @@ RLIBS += -L$(TIDUB)/Resplot/lib/$(ARCH_TYPE) -lResplot -L$(TIDUB)/Readcards/lib/
# build executable: link
all : dirs resplot readcards rdict wdict reader comparitor cpucost chains skim listroot sb runtool
all : dirs resplot readcards rdict wdict reader comparitor cpucost chains skim listroot sb runtool dependence
$(OBJDIR)/computils.o : $(SRCDIR)/computils.h
$(OBJDIR)/comparitor.o : $(SRCDIR)/computils.h
rdict : $(EXEDIR)/rdict
$(EXEDIR)/rdict : dirs resplot readcards $(ROBJECTS) $(LIBSO)
$(CXX) $(LDFLAGS) -o $@ $(ROBJECTS) $(LIBS) $(RLIBS) $(GLIBS)
......@@ -214,6 +218,10 @@ reader : $(EXEDIR)/reader
$(EXEDIR)/reader : dirs $(OBJDIR)/reader.o $(LIBSO)
$(CXX) $(LDFLAGS) -o $@ $(OBJDIR)/reader.o $(LIBS) $(GLIBS)
dependence : $(EXEDIR)/dependence
$(EXEDIR)/dependence : dirs readcards $(DOBJECTS) $(LIBSO)
$(CXX) $(LDFLAGS) -o $@ $(DOBJECTS) $(LIBS) $(RLIBS) $(GLIBS)
skim : dirs $(EXEDIR)/skim
$(EXEDIR)/skim : dirs $(OBJDIR)/skim.o $(LIBSO)
$(CXX) $(LDFLAGS) -o $@ $(OBJDIR)/skim.o $(LIBS) $(GLIBS)
......@@ -227,11 +235,11 @@ $(EXEDIR)/refit : dirs $(OBJDIR)/refit.o $(LIBSO)
$(CXX) $(LDFLAGS) -o $@ $(OBJDIR)/refit.o $(LIBS) $(RLIBS) $(GLIBS)
comparitor : $(EXEDIR)/comparitor
$(EXEDIR)/comparitor : $(COBJECTS) $(LIBSO)
$(EXEDIR)/comparitor : $(COBJECTS) $(CCHEADERS) $(LIBSO)
$(CXX) $(LDFLAGS) -o $@ $(COBJECTS) $(LIBS) $(RLIBS) $(GLIBS)
cpucost : $(EXEDIR)/cpucost
$(EXEDIR)/cpucost : $(CCOBJECTS) $(LIBSO)
$(EXEDIR)/cpucost : $(CCOBJECTS) $(CCHEADERS) $(LIBSO)
$(CXX) $(LDFLAGS) -o $@ $(CCOBJECTS) $(LIBS) $(RLIBS) $(GLIBS)
chains : $(EXEDIR)/chains
......@@ -334,7 +342,7 @@ $(INSTALLDIR)/TIDA% : $(EXEDIR)/%
cp $< $@.exe
INSTALLFILES=comparitor chains cpucost runtool sb rdict reader
INSTALLFILES=comparitor chains cpucost runtool sb rdict reader dependence
ginstall : install $(patsubst %,$(INSTALLDIR)/TIDA%,$(INSTALLFILES))
......@@ -348,6 +356,7 @@ install : all
cp $(EXEDIR)/listroot $(HOME)/bin
cp $(EXEDIR)/runtool $(HOME)/bin
cp $(EXEDIR)/sb $(HOME)/bin
cp $(EXEDIR)/dependence $(HOME)/bin
cp $(SRCDIR)/*.pcm $(HOME)/bin
dirs : $(LIBDIR)/.d $(OBJDIR)/.d $(EXEDIR)/.d
......
......@@ -1338,9 +1338,10 @@ int main(int argc, char** argv) {
double xpos = 0.18;
double ypos = 0.91;
if ( contains(histo.name(),"eff") || contains(histo.name(),"Eff_") ) ypos = 0.17;
if ( contains(histo.name(),"eff") || contains(histo.name(),"Eff_") ) ypos = 0.19;
if ( histo.name()=="pT" || histo.name()=="pT_rec" ) ypos = 0.15;
/// leave this code commented here for the time being ...
/// if ( histo.name()=="pT" || histo.name()=="pT_rec" ) ypos = 0.19;
if ( atlasstyle ) {
xpos = 0.18;
......@@ -1380,14 +1381,12 @@ int main(int argc, char** argv) {
if ( ALLRANGEMAP || (RANGEMAP && xaxis.find("p_{T}")!=std::string::npos && ccolours.size() ) )
Nrows = ( Nrows < ccolours.size() ? Nrows : ccolours.size() );
std::cout << "\n\n\tNrows " << Nrows << std::endl;
int Nlines = Nrows + taglabels.size();
std::vector<double> ypositions;
double deltay = (Nrows*0.055-0.005)/Nrows;
double ylo = ypos;
double yhi = ypos;
......@@ -1402,7 +1401,7 @@ int main(int argc, char** argv) {
/// legends ....
Legend legend( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
Legend legend( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
Legend legend_eff( xpos, xpos+0.1, ylo, ylo+Nrows*0.06-0.005 );
......@@ -2372,7 +2371,7 @@ int main(int argc, char** argv) {
/// actually draw the plot here ...
if ( fulldbg ) if ( fulldbg ) std::cout << __LINE__ << std::endl;
plots.Draw( legend );
if ( fulldbg ) if ( fulldbg ) std::cout << __LINE__ << std::endl;
......
......@@ -375,7 +375,9 @@ public:
/// ha ! don't actually create the legend until we want to draw it,
/// then we can determine the size etc automatically
double y0 = m_y[1] - 0.4*m_entries.size()*(m_y[1]-m_y[0]);
double y0 = m_y[0];
m_y[1] = y0 + m_entries.size()*0.05;
m_leg = new TLegend( m_x[0], y0, m_x[1], m_y[1] );
......@@ -475,7 +477,7 @@ public:
bool trim_errors() const { return m_trim_errors; }
void Draw( int i, Legend& leg, bool mean=false, bool first=true ) {
void Draw( int i, Legend& leg, bool mean=false, bool first=true, bool drawlegend=false ) {
if ( htest() ) {
gStyle->SetOptStat(0);
......@@ -632,7 +634,7 @@ public:
m_entries++;
leg.Draw();
if ( drawlegend ) leg.Draw();
}
}
......@@ -951,9 +953,9 @@ public:
}
void Draw_i( Legend& leg, bool means=false ) {
bool first = true;
bool first = true;
if ( m_logy ) {
/// increase the number of log labels if only a few decades
for ( unsigned i=0 ; i<size() ; i++, first=false ) {
......@@ -967,7 +969,7 @@ public:
for ( unsigned i=0 ; i<size() ; i++ ) at(i).trim_errors( m_trim_errors );
for ( unsigned i=0 ; i<size() ; i++, first=false ) at(i).Draw( i, leg, means, first );
for ( unsigned i=0 ; i<size() ; i++, first=false ) at(i).Draw( i, leg, means, first, (i==size()-1) );
if ( watermark ) DrawLabel(0.1, 0.02, "built "+stime()+release, kBlack, 0.03 );
gPad->SetLogy(m_logy);
......
......@@ -375,6 +375,8 @@ int main(int argc, char** argv) {
continue;
}
std::cout << "mean time: " << testhist->GetMean() << "\t:: " << testhist->GetName() << std::endl;
if ( norm_width ) binwidth( testhist );
/// skip TH2 and TProfiles for the moment ...
......
/**
** @file dependence.cxx
**
** @author berare gokturk
** @date Mon 17 May 2021 20:02:26 CET
**
** Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
**/
#include <string>
#include <iostream>
#include "TrigInDetAnalysis/Efficiency.h"
#include "ReadCards.h"
#include "TH1F.h"
#include "TH1D.h"
#include "TF1.h"
#include "TFile.h"
#include "TPad.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "AtlasStyle.h"
int usage( const std::string& err_msg="", int status=0 ) {
std::string name = "dependence";
if ( err_msg!="" ) std::cerr << err_msg << std::endl;
std::ostream& s = std::cout;
s << "Usage: " << name << "\t [OPTIONS] \n\n";
s << "\t" << " plots comparison histograms";
s << " - compiled on " << __DATE__ << " at " << __TIME__ << "\n\n";
s << "Options: \n";
s << " -c, --config value \t configure which histograms to plot from config file,\n\n";
s << " -f, --fit \t fit a pol2 to the efficiencies\n\n";
s << " -as, --atlasstyle \t usethe atlas style\n\n";
s << " -h, --help \t this help\n";
s << std::endl;
return status;
}
void add_to_bin( double d, TH1* h, TH1* h0 ) {
int ibin = h->FindBin(d);
if ( ibin<1 || ibin>h->GetNbinsX() ) return;
double v = 0;
for ( int i=1 ; i<=h0->GetNbinsX() ; i++ ) v += h0->GetBinContent(i);
h->SetBinContent( ibin, v );
}
bool doFit = false;
void efficiency( std::vector<double>& bins, std::vector<double>& values, const std::vector<std::string>& files,
const std::string& histname, const std::string& plotname ) {
if ( values.size() != files.size() ) {
std::cerr << "number of values (" << values.size() << ") and files (" << files.size() << ") do not match" << std::endl;
std::exit(-1);
}
TH1F* hd = 0;
TH1F* hn = 0;
if ( bins.size()==3 ) {
hd = new TH1F( "denominator", ";roi z width [mm];efficiency ", int(bins[0]), bins[1], bins[2] );
hn = new TH1F( "numerator", ";roi z width [mm];efficiency ", int(bins[0]), bins[1], bins[2] );
}
else if ( bins.size()>3 ) {
hd = new TH1F( "denominator", ";roi z width [mm];efficiency ", bins.size()-1, &bins[0] );
hn = new TH1F( "numerator", ";roi z width [mm];efficiency ", bins.size()-1, &bins[0] );
}
else {
std::exit( usage( "unusable binning", -1) );
}
std::cout << "looping over files ..." << std::endl;
for ( size_t i=0 ; i<files.size() ; i++ ) {
// std::string s = "run" + std::to_string(i) + "/data-hists-offline" + ".root";
std::string s = files[i];
std::cout << "file: "<< s << "\tvalue: "<< values[i] << std::endl;
// std::cout << "\t hist: " << histname << std::endl;
TFile* f = new TFile( s.c_str() );
if ( f==0 ) {
std::cerr << "could not open file" << s << std::endl;
std::exit( -1 );
}
TH1F* he_n = (TH1F*)f->Get( (histname+"_n").c_str() );
TH1F* he_d = (TH1F*)f->Get( (histname+"_d").c_str() );
if ( he_n==0 ) {
std::cerr << "histogram " << histname+"_n" << "could not be retrieved" << std::endl;
continue;
}
if ( he_d==0 ) {
std::cerr << "histogram " << histname+"_d" << "could not be retrieved" << std::endl;
continue;
}
// std::cout << "\t he_n: " << he_n << std::endl;
// std::cout << "\t he_d: " << he_d << std::endl;
add_to_bin( values[i], hn, he_n );
add_to_bin( values[i], hd, he_d );
delete f;
}
double scale_eff = 1;
Efficiency e( hn, hd, "", scale_eff );
TGraphAsymmErrors* tgtest = e.Bayes(scale_eff);
TCanvas* c2 = new TCanvas( plotname.c_str(), "eff", 10, 10, 1000, 500 );
c2->cd();
TH1F* h = e.Hist();
h->SetMarkerStyle(20);
h->SetLineColor(h->GetMarkerColor());
h->GetYaxis()->SetRangeUser(0.90,1.02);
tgtest->SetMarkerStyle(20);
tgtest->SetMarkerColor(h->GetMarkerColor());
tgtest->SetLineColor(h->GetMarkerColor());
if ( doFit ) {
h->Fit( "pol2" );
TF1* f1 = (TF1*)h->GetListOfFunctions()->FindObject("pol2");
f1->SetLineWidth(1);
}
h->Draw("e1");
tgtest->Draw("samep");
gPad->SetLogx(true);
gPad->Print( plotname.c_str() );
delete hd;
delete hn;
delete c2;
}
int main( int argc, char** argv ) {
/// configuration file ...
std::string config_file = "";
bool atlasstyle = false;
/// read command line arguments ...
for ( int i=1 ; i<argc ; i++ ) {
std::string arg = argv[i];
if ( arg=="-h" || arg=="--help" ) return usage();
else if ( arg=="-f" || arg=="--fit" ) doFit = true;
else if ( arg=="-as" || arg=="--atlasstyle" ) atlasstyle = true;
else if ( arg=="-c" ) {
if ( ++i<argc ) config_file = argv[i];
else return usage( "no config file provided", -1 );
}
}
if ( config_file == "" ) return usage( "no config file provided", -1 );
if ( atlasstyle ) SetAtlasStyle();
gStyle->SetOptStat(0);
gStyle->SetErrorX(0);
/// open configuration file ...
ReadCards config(config_file);
/// get the list of efficiencies to cteate ...
std::vector<std::string> plots = config.GetStringVector("plots");
/// get the bins for the efficiency, and the values to be used for each file ...
std::vector<double> bins = config.GetVector("bins");
std::vector<double> values = config.GetVector("values");
/// and the list of files ...
std::vector<std::string> files = config.GetStringVector("files");
/// off we go ...
std::cout << "looping over plots ..." << std::endl;
for ( size_t i=0 ; i<plots.size() ; i+=2 ) {
std::string hist = plots[i];
std::string plotname = plots[i+1];
std::cout << "plot: " << plotname << "\t" << hist << std::endl;
efficiency( bins, values, files, hist, plotname );
}
return 0;
}
......@@ -116,6 +116,12 @@ atlas_add_executable( TIDAsb
Analysis/src/chainparser.cxx
LINK_LIBRARIES Readcards )
atlas_add_executable( TIDAdependence
Analysis/src/dependence.cxx
Analysis/src/AtlasStyle.h Analysis/src/AtlasStyle.cxx
Analysis/src/AtlasLabels.h Analysis/src/AtlasLabels.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} TrigInDetAnalysis Readcards )
# Disable naming convention checker.
# FIXME: This should be fixed properly once run2 is finished.
......@@ -134,6 +140,7 @@ if( ${CMAKE_CXX_FLAGS} MATCHES "libchecker_gccplugins" )
set_target_properties( TIDAlistroot PROPERTIES COMPILE_FLAGS -fplugin-arg-libchecker_gccplugins-checkers=no-naming )
set_target_properties( TIDAskim PROPERTIES COMPILE_FLAGS -fplugin-arg-libchecker_gccplugins-checkers=no-naming )
set_target_properties( TIDAfastadd PROPERTIES COMPILE_FLAGS -fplugin-arg-libchecker_gccplugins-checkers=no-naming )
set_target_properties( TIDAdependence PROPERTIES COMPILE_FLAGS -fplugin-arg-libchecker_gccplugins-checkers=no-naming )
endif()
# Install files from the package:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment