From e4c0b86ea98dc4bf860e7d4f438034b0008b3d5d Mon Sep 17 00:00:00 2001 From: Mark Sutton <mark.sutton@cern.ch> Date: Mon, 24 Aug 2020 14:16:49 +0000 Subject: [PATCH] Show the algorithm names in timing plots and add isolation chains Changes to show the directory name for the timing plots on the plots themselves to more easily be able to tell one histogram from another in the display Also, introduces some additional performance plots for the muon isolation trackings --- .../Analysis/src/DrawLabel.h | 6 +- .../Analysis/src/computils.cxx | 10 +++ .../Analysis/src/computils.h | 81 ++++++++++++------- .../Analysis/src/cpucost.cxx | 44 +++++----- .../python/TrigIDtrkMonitoringConfig.py | 9 ++- 5 files changed, 95 insertions(+), 55 deletions(-) diff --git a/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/DrawLabel.h b/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/DrawLabel.h index 7ffae0958fa..109371e7fc8 100644 --- a/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/DrawLabel.h +++ b/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/DrawLabel.h @@ -23,8 +23,8 @@ class DrawLabel { public: - DrawLabel(double x, double y, const std::string& s, int colour=kBlack, double size=0.033 ) : - m_text(s), m_colour(colour), m_x(x), m_y(y), m_size(size) + DrawLabel(double x, double y, const std::string& s, int colour=kBlack, double size=0.033, double font=42 ) : + m_text(s), m_colour(colour), m_font(font), m_x(x), m_y(y), m_size(size) { // std::cout << "DrawLabel::DrawLabel() " << m_text << std::endl; Draw(); @@ -37,6 +37,7 @@ public: tt->SetNDC(); tt->SetTextColor(m_colour); tt->SetTextSize(m_size); + tt->SetTextFont(m_font); tt->DrawLatex(m_x, m_y, m_text.c_str() ); } @@ -47,6 +48,7 @@ private: std::string m_text; int m_colour; + int m_font; double m_x; double m_y; diff --git a/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/computils.cxx b/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/computils.cxx index 9f941103ea2..308fb28ca36 100644 --- a/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/computils.cxx +++ b/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/computils.cxx @@ -275,6 +275,16 @@ std::string tail( std::string s, const std::string& pattern ) { return s; } + +std::string head( std::string s, const std::string& pattern ) { + size_t pos = s.find_last_of(pattern); + if ( pos != std::string::npos ) { + s.erase( pos, s.size() ); + } + return s; +} + + void contents( std::vector<std::string>& keys, TDirectory* td, const std::string& directory, const std::string& pattern, const std::string& path ) { diff --git a/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/computils.h b/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/computils.h index 3c84c7b2c4c..6171e012b55 100644 --- a/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/computils.h +++ b/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/computils.h @@ -65,6 +65,9 @@ bool exists( const std::string& filename ); /// tail of a string std::string tail( std::string s, const std::string& pattern ); +/// head of a string +std::string head( std::string s, const std::string& pattern ); + /// match a file name std::string globbed( const std::string& s ); @@ -246,17 +249,17 @@ public: static std::vector<std::string> split( const std::string& s, const std::string& t=":" ) { - std::string _s = s; - size_t pos = _s.find(t); + std::string sc = s; + size_t pos = sc.find(t); std::vector<std::string> tags; while ( pos!=std::string::npos ) { - tags.push_back( chop(_s,t) ); - pos = _s.find(t); + tags.push_back( chop(sc,t) ); + pos = sc.find(t); } - tags.push_back(_s); + tags.push_back(sc); return tags; } @@ -307,37 +310,49 @@ class Legend { public: - Legend() : mleg(0) { } + Legend() : m_leg(0) { } Legend(double x1, double x2, double y1, double y2) { - mleg = new TLegend(x1, y1, x2, y2); - mleg->SetBorderSize(0); - mleg->SetTextFont(42); - mleg->SetTextSize(0.04); - mleg->SetFillStyle(3000); - mleg->SetFillColor(0); - mleg->SetLineColor(0); - } + m_leg = new TLegend( m_x[0]=x1, m_y[0]=y1, m_x[1]=x2, m_y[1]=y2); + m_leg->SetBorderSize(0); + m_leg->SetTextFont(42); + m_leg->SetTextSize(0.04); + m_leg->SetFillStyle(3000); + m_leg->SetFillColor(0); + m_leg->SetLineColor(0); + } // Legend( const Legend& leg ) : mleg((TLegend*)leg.mleg->Clone()) { } - Legend(const Legend& legend) : mleg(legend.mleg) { } + Legend(const Legend& legend) : m_leg(legend.m_leg) { } ~Legend() { } - TLegend* legend() { return mleg; } + TLegend* legend() { return m_leg; } - TLegend* operator->() { return mleg; } + TLegend* operator->() { return m_leg; } size_t size() const { - if ( mleg ) return mleg->GetNRows(); + if ( m_leg ) return m_leg->GetNRows(); else return 0; } + double TextSize() const { return m_leg->GetTextSize(); } + + int TextFont() const { return m_leg->GetTextFont(); } + + double height() const { return m_y[1]-m_y[0]; } + + double width() const { return m_x[1]-m_x[0]; } + + private: - TLegend* mleg; + TLegend* m_leg; + + double m_x[2]; + double m_y[2]; }; @@ -510,33 +525,37 @@ public: if ( mean ) { - char _meanref[64]; + char meanrefc[64]; bool displayref = false; if ( meanplotref && href() ) { displayref = true; - std::sprintf( _meanref, " <t> = %3.2f #pm %3.2f ms (ref)", href()->GetMean(), href()->GetMeanError() ); + std::sprintf( meanrefc, " <t> = %3.2f #pm %3.2f ms (ref)", href()->GetMean(), href()->GetMeanError() ); } else { - std::sprintf( _meanref, "%s", "" ); + std::sprintf( meanrefc, "%s", "" ); } - char _mean[64]; - std::sprintf( _mean, " <t> = %3.2f #pm %3.2f ms", htest()->GetMean(), htest()->GetMeanError() ); + char meanc[64]; + std::sprintf( meanc, " <t> = %3.2f #pm %3.2f ms", htest()->GetMean(), htest()->GetMeanError() ); - std::cout << "alg: " << m_plotfilename << " " << _mean << "\tref: " << _meanref << std::endl; + std::cout << "alg: " << m_plotfilename << " " << meanc << "\tref: " << meanrefc << std::endl; - std::string rkey = key; + std::string dkey = key; + if ( dkey.find( "TIME_" )!=std::string::npos ) dkey.erase( dkey.find( "TIME_" ), 5 ); + + std::string rkey = dkey; + if ( LINEF || leg.size() < m_max_entries ) { - key += std::string(" : "); - leg->AddEntry( htest(), key.c_str(), "p" ); - leg->AddEntry( hnull, _mean, "p" ); + dkey += std::string(" : "); + leg->AddEntry( htest(), (dkey+meanc).c_str(), "p" ); + // leg->AddEntry( hnull, meanc, "p" ); // leave this commented until we decide we really want to go with one line if ( displayref ) { rkey += std::string(" : "); leg->AddEntry( hnull, "", "l" ); - leg->AddEntry( href(), rkey.c_str(), "l" ); - leg->AddEntry( hnull, _meanref, "l" ); + leg->AddEntry( href(), (rkey+meanrefc).c_str(), "l" ); + // leg->AddEntry( hnull, meanrefc, "l" ); // leave this commented until we decide we really want to go with one line } } diff --git a/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/cpucost.cxx b/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/cpucost.cxx index 185c71bc2c8..b028dd2db59 100644 --- a/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/cpucost.cxx +++ b/Trigger/TrigAnalysis/TrigInDetAnalysisUser/Analysis/src/cpucost.cxx @@ -43,13 +43,13 @@ int usage(const std::string& name, int status) { s << " TIDA \'" << name << "\' extracts timing histograms\n\n"; s << "Options: \n"; s << " -o, --outputfolder value\t puts output in folder 'value' making it if it doesn't exist, \n\n"; - s << " -t, --tag value \t appends tag 'value' to the end of output plot names, \n"; - s << " -k, --key value \t prepends key 'value' to the front of output plot names, \n\n"; + s << " -t, --tag value \t appends tag 'value' to the end of output plot names, \n"; + s << " -k, --key value \t prepends key 'value' to the front of output plot names, \n\n"; s << " -a, --auto \t process all histograms that are in the file, \n"; s << " -d, --directory value \t if auto is set, search only in specifed directory, \n"; + s << " , --nodir \t do not print the directory name on the plot,\n"; s << " -p, --pattern value \t if auto is set, search for histograms containing this string, \n\n"; - s << " -nr, --noref \t do not use a reference file, \n"; - s << " -nr, --noref \t do not use a reference file, \n"; + s << " -nr, --noref \t do not use a reference file, \n\n"; s << " -x, --xoffset value \t offset the key by value \n\n"; s << " -v, --verbose \t verbose output\n"; s << " -h, --help \t this help\n"; @@ -76,7 +76,7 @@ int main(int argc, char** argv) { if (argc < 4) { return usage(argv[0], -1); } - std::string dir = ""; + std::string output_dir = ""; std::string tag = ""; std::string key = ""; @@ -115,6 +115,8 @@ int main(int argc, char** argv) { double xoffset = 0.17; + bool show_directory = true; + // Parse the arguments std::vector<std::string> algorithms; for(int argnum = 1; argnum < argc; argnum++){ @@ -124,7 +126,7 @@ int main(int argc, char** argv) { return usage(argv[0], 0); } else if (arg == "-o" || arg == "--outputfolder") { - if (++argnum < argc) { dir = argv[argnum]; } + if (++argnum < argc) { output_dir = argv[argnum]; } else { return usage(argv[0], -1); } } else if (arg == "-x" || arg == "--xoffset") { @@ -145,6 +147,9 @@ int main(int argc, char** argv) { else if (arg == "-a" || arg == "--auto") { autochains = true; } + else if (arg == "--nodir") { + show_directory = false; + } else if (arg == "-v" || arg == "--verbose") { verbose = true; } @@ -229,12 +234,12 @@ int main(int argc, char** argv) { // Make output directory - if ( dir != "" ) { - if ( mkdir( dir.c_str(), 0777 ) ) { - if ( exists(dir) ) std::cerr << "main() directory " << dir << " aleady exists" << std::endl; - else std::cerr << "main() could not create directory " << dir << std::endl; + if ( output_dir != "" ) { + if ( mkdir( output_dir.c_str(), 0777 ) ) { + if ( exists(output_dir) ) std::cerr << "main() directory " << output_dir << " aleady exists" << std::endl; + else std::cerr << "main() could not create directory " << output_dir << std::endl; } - dir += "/"; + output_dir += "/"; } #if 0 @@ -295,8 +300,8 @@ int main(int argc, char** argv) { double x1 = xoffset; double x2 = xoffset+0.25; - double y1 = 0.69; - double y2 = 0.90; + double y1 = 0.80; + double y2 = 0.87; /// adjust the legend if no reference times are to be plotted if ( noref ) y1 = y2-0.5*(y2-y1); @@ -348,11 +353,10 @@ int main(int argc, char** argv) { Plots plots; std::string algname = tail(algorithms[algorithm], "/" ); - + std::string dirname = tail( head(algorithms[algorithm], "/" ), "/" ); std::string algpname = algorithms[algorithm]; replace( algpname, "/", "_" ); - if ( algname.find("h_")==0 ) algname.erase(0, 2); // size_t indetpos = algname.find("InDet"); @@ -360,11 +364,11 @@ int main(int argc, char** argv) { plots.push_back( Plotter( testhist, refhist, " "+algname ) ); - std::string plotname = dir + key + algpname + tag; + std::string plotname = output_dir + key + algpname + tag; // histograms.at(histogram).fname + tag; - std::cout << "dir " << dir << "\tkey " << key << "\talgname " << algname << "\ttag " << tag << std::endl; + std::cout << "output dir " << output_dir << "\tkey " << key << "\talgname " << algname << "\ttag " << tag << std::endl; // std::cout << "testhist " << testhist << " " << refhist << std::endl; @@ -400,8 +404,8 @@ int main(int argc, char** argv) { if ( ylogt ) { if ( rmin == 0 ) rmin = rmax*0.0001; double delta = std::log10(rmax)-std::log10(rmin); - if ( atlasstyle ) plots.Max( rmax*std::pow(10,delta*0.15*2*(chains.size()+taglabels.size()+2)) ); - else plots.Max( rmax*std::pow(10,delta*0.15*2*(chains.size()+taglabels.size()+1)) ); + if ( atlasstyle ) plots.Max( rmax*std::pow(10,delta*0.15*2*(chains.size()+taglabels.size()+1.5)) ); + else plots.Max( rmax*std::pow(10,delta*0.15*2*(chains.size()+taglabels.size()+0.5)) ); plots.Min( rmin*std::pow(10,-delta*0.1) ); } else { @@ -425,6 +429,8 @@ int main(int argc, char** argv) { plots.Draw( legend, true ); + if ( show_directory ) DrawLabel( x1+0.01, y2+0.03, dirname, kBlack, legend.TextSize(), legend.TextFont() ); + plots.back().Print( (plotname+".pdf").c_str() ); if ( !nopng ) plots.back().Print( (plotname+".png").c_str() ); diff --git a/Trigger/TrigMonitoring/TrigIDtrkMonitoring/python/TrigIDtrkMonitoringConfig.py b/Trigger/TrigMonitoring/TrigIDtrkMonitoring/python/TrigIDtrkMonitoringConfig.py index 2eb38e57392..d72033db74a 100644 --- a/Trigger/TrigMonitoring/TrigIDtrkMonitoring/python/TrigIDtrkMonitoringConfig.py +++ b/Trigger/TrigMonitoring/TrigIDtrkMonitoring/python/TrigIDtrkMonitoringConfig.py @@ -2,6 +2,8 @@ def TrigIDtrkMonitoringTool( legacy_monitoring=False ): +# from AthenaCommon.Constants import VERBOSE,DEBUG,INFO,WARNING,ERROR + # do we want the lagacy monitoring ? from TriggerJobOpts.HLTTriggerResultGetter import EDMDecodingVersion @@ -162,6 +164,7 @@ def TrigIDtrkMonitoringTool( legacy_monitoring=False ): + ############################################################## # Muon instances ############################################################## @@ -172,15 +175,15 @@ def TrigIDtrkMonitoringTool( legacy_monitoring=False ): tidamuon.AnalysisConfig = "Tier0" tidamuon.SliceTag = "HLT/TRIDT/Muon/Expert" tidamuon.UseHighestPT = True - # tidabase.OutputLevel = DEBUG + # tidamuon.OutputLevel = VERBOSE if mt_chains: tidamuon.ntupleChainNames += [ "Offline", "HLT_mu.*idperf.*:key=HLT_IDTrack_Muon_FTF:roi=HLT_Roi_L2SAMuon", "HLT_mu.*idperf.*:key=HLT_IDTrack_Muon_IDTrig:roi=HLT_Roi_L2SAMuonForEF", - "HLT_mu.*i.*:key=HLT_IDTrack_MuonIso_FTF:roi=HLT_Roi_MuonIso", - "HLT_mu.*i.*:key=HLT_IDTrack_MuonIso_IDTrig:roi=HLT_Roi_MuonIso" + "HLT_mu.*ivar.*:key=HLT_IDTrack_MuonIso_FTF:roi=HLT_Roi_MuonIso", + "HLT_mu.*ivar.*:key=HLT_IDTrack_MuonIso_IDTrig:roi=HLT_Roi_MuonIso" ] else: tidamuon.ntupleChainNames += [ -- GitLab