ATLAS Offline Software
Loading...
Searching...
No Matches
IDTPM2::Efficiencies Class Reference

#include <Efficiencies.h>

Inheritance diagram for IDTPM2::Efficiencies:
Collaboration diagram for IDTPM2::Efficiencies:

Public Member Functions

 Efficiencies (const std::string &name, ToolHandle< GenericMonitoringTool > *m=0)
 Constructor.
virtual ~Efficiencies ()=default
 Destructor.
void initialize ()
 Dedicated fill method (for tracks and/or truth particles).
void execute (const TrackAnalysisStore &collections) const
void finalize ()
 Print out final stats on histograms.
const std::string & name () const
 generic utilities, just in case
ToolHandle< GenericMonitoringTool > * monTool ()
 mon tool
const ToolHandle< GenericMonitoringTool > * monTool () const
void set_monTool (ToolHandle< GenericMonitoringTool > *m)
 do we need / should we have this specific setter ??
std::string realPath (const std::string &tag="")
 This is a horrific function, has to get ALL the histograms, just to be able to work out how to get the actual path to the histograms for this tool - there simply MUST be a better way ...
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Static Public Member Functions

template<typename Derived>
static std::unique_ptr< IPlotBase > create (const std::string &name, ToolHandle< GenericMonitoringTool > *m)
 factory creation mathod

Protected Member Functions

void copyHist (TH1 *hsrc, TH1 *hdest, bool copyoverflow=true) const
 resolution porocessing stuff these don't really even need to be class functions, they could be simply utility functions
void getHist (const std::string &hname, TH1 *hsrc)
void getHist (ServiceHandle< ITHistSvc > &histsvc, const std::string &hname, TH1 *hsrc) const
void processResolution (const std::string &path, bool writeflag=false)
void processResolution (ServiceHandle< ITHistSvc > &histsvc, const std::string &path, bool writeflag=false) const
virtual ServiceHandle< ITHistSvc > & histSvc ()
 we may well need these at some point ...

Protected Attributes

const std::string & m_name
ToolHandle< GenericMonitoringTool > * m_monTool

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

TIDA::Histogram2D< float, bool > m_eff_vs_inclusive
 NB: the egregious root convention for a TEfficiency is Fill( ismatched, variable ), but that is awful, and inconsistent, so we swap that round.
TIDA::Histogram2D< float, bool > m_eff_vs_ntracks
TIDA::Histogram2D< float, bool > m_eff_vs_pt
TIDA::Histogram2D< float, bool > m_eff_vs_eta
TIDA::Histogram2D< float, bool > m_eff_vs_phi
TIDA::Histogram2D< float, bool > m_eff_vs_d0
TIDA::Histogram2D< float, bool > m_eff_vs_z0
TIDA::Histogram2D< float, bool > m_eff_vs_Et
TIDA::Histogram2D< float, bool > m_eff_vs_EtovPt
TIDA::Histogram2D< float, bool > m_eff_vs_actualMu
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels).
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging).

Detailed Description

Constructor & Destructor Documentation

◆ Efficiencies()

IDTPM2::Efficiencies::Efficiencies ( const std::string & name,
ToolHandle< GenericMonitoringTool > * m = 0 )

Constructor.


--— Constructor --—

Definition at line 16 of file Efficiencies.cxx.

17 : IPlotBase( name, m )
18{ }
const std::string & name() const
generic utilities, just in case
Definition IPlotBase.h:68
IPlotBase(const std::string &name, ToolHandle< GenericMonitoringTool > *m=0)
built from dirName and anaTag
Definition IPlotBase.h:41

◆ ~Efficiencies()

virtual IDTPM2::Efficiencies::~Efficiencies ( )
virtualdefault

Destructor.

Member Function Documentation

◆ copyHist()

void IDTPM2::IPlotBase::copyHist ( TH1 * hsrc,
TH1 * hdest,
bool copyoverflow = true ) const
protectedinherited

resolution porocessing stuff these don't really even need to be class functions, they could be simply utility functions

Definition at line 20 of file IPlotBase.cxx.

20 {
21
22 if ( hsrc->GetNbinsX()!=hdest->GetNbinsX() ) return; // do we want to give an error message ?? throw and exception ??
23
24 int imin = 0;
25 int imax = hsrc->GetNbinsX()+1;
26
27 if ( !copyoverflow ) {
28 imin = 1;
29 imax = hsrc->GetNbinsX();
30 }
31
32 for ( int i=imin ; i<=imax ; i++ ) {
33 hdest->SetBinContent( i, hsrc->GetBinContent(i) );
34 hdest->SetBinError( i, hsrc->GetBinError(i) );
35 }
36
37 hdest->SetEntries( hsrc->GetEntries() );
38}
int imax(int i, int j)

◆ create()

template<typename Derived>
std::unique_ptr< IPlotBase > IDTPM2::IPlotBase::create ( const std::string & name,
ToolHandle< GenericMonitoringTool > * m )
inlinestaticinherited

factory creation mathod

Definition at line 50 of file IPlotBase.h.

51 {
52 return std::make_unique<Derived>( name, m );
53 }

◆ execute()

void IDTPM2::Efficiencies::execute ( const TrackAnalysisStore & collections) const
virtual

— Dedicated fill method —

don't need the actual test tracks

is there a matched track ??

Compute track parameters

Fill the histograms do we really need the weighted histograms ???

do we really even want these ???

truth mu ??

Implements IDTPM2::IPlotBase.

Definition at line 61 of file Efficiencies.cxx.

61 {
62
63 const std::vector<const TrackView*>& ref = collections.reference_tracks();
64
66 // const std::vector<const TrackView*>& test = collections.test_tracks();
67
68 double mu = collections.eventInfo()->actualInteractionsPerCrossing();
69
70 const TIDA::Associator<const TrackView>* matcher = collections.matcher();
71
72 for ( size_t i=0 ; i<ref.size(); i++ ) {
73
74 const TrackView& p = *ref[i];
75
76 bool matched = false;
77
79 if ( matcher->matched(ref[i]) ) matched = true;
80
82 float ppt = p.pt() / Gaudi::Units::GeV;
83 float peta = p.eta();
84 float pphi = p.phi();
85 float pd0 = p.d0();
86 float pz0 = p.z0();
87
88 float Et = p.ET() / Gaudi::Units::GeV;
89
90 if ( p.hasParent() ) Et = p.parent()->ET()*0.001;
91
92 float EtovPt = Et/ppt; // pt should never be 0 so don't bother to check that
93
96 m_eff_vs_inclusive.Fill( 1, matched );
97
98 m_eff_vs_ntracks.Fill( ref.size(), matched );
99
100 m_eff_vs_pt.Fill( ppt, matched );
101 // m_eff_vs_logPt.Fill( ppt, matched );
102 // m_eff_vs_lowPt.Fill( ppt, matched );
103 m_eff_vs_eta.Fill( peta, matched );
104 m_eff_vs_phi.Fill( pphi, matched );
105 m_eff_vs_d0.Fill( pd0, matched );
106 m_eff_vs_z0.Fill( pz0, matched );
107
108 m_eff_vs_Et.Fill( Et, matched );
109 m_eff_vs_EtovPt.Fill( EtovPt, matched );
110
111 m_eff_vs_actualMu.Fill( mu, matched );
112
114 // m_eff_vs_eta_vs_pt.Fill( ppt, matched, ppt );
115 // m_eff_vs_eta_vs_phi.Fill( pphi, pet, matched );
116 // m_eff_vs_z0_vs_d0.Fill( pd0, pz0, matched );
117 // float ptheta = p.theta(); /// no point setting it unless it is needed
118 // m_eff_vs_z0sin_vs_d0.Fill( pz0*std::sin(ptheta), pd0, matched );
119
121 // if( m_doTruthMuPlots ) m_eff_vs_truthMu.Fill( matched, matched );
122 }
123}
const std::regex ref(r_ef)
TIDA::Histogram2D< float, bool > m_eff_vs_inclusive
NB: the egregious root convention for a TEfficiency is Fill( ismatched, variable ),...
void Fill(T x, U y) const
const Matcher_t & matcher() const
Return the matcher object.

◆ finalize()

void IDTPM2::Efficiencies::finalize ( )
virtual

Print out final stats on histograms.


--— finalizePlots --—

Implements IDTPM2::IPlotBase.

Definition at line 130 of file Efficiencies.cxx.

130{ MY_MSG_DEBUG << "Finalising efficiency plots" << endmsg; }
#define endmsg
#define MY_MSG_DEBUG
Definition MsgMacros.h:25

◆ getHist() [1/2]

void IDTPM2::IPlotBase::getHist ( const std::string & hname,
TH1 * hsrc )
inlineprotectedinherited

Definition at line 88 of file IPlotBase.h.

88{ return getHist( histSvc(), hname, hsrc ); }
void getHist(const std::string &hname, TH1 *hsrc)
Definition IPlotBase.h:88
virtual ServiceHandle< ITHistSvc > & histSvc()
we may well need these at some point ...
Definition IPlotBase.h:105

◆ getHist() [2/2]

void IDTPM2::IPlotBase::getHist ( ServiceHandle< ITHistSvc > & histsvc,
const std::string & hname,
TH1 * hsrc ) const
protectedinherited

Definition at line 42 of file IPlotBase.cxx.

42 {
43 TH1* h = 0;
44 if ( histsvc->getHist( hname, h ).isFailure() ) MY_MSG_WARNING << "Could not retieve histogram: " << hname << endmsg;
45 else copyHist( hsrc, h );
46}
#define MY_MSG_WARNING
Definition MsgMacros.h:23
void copyHist(TH1 *hsrc, TH1 *hdest, bool copyoverflow=true) const
resolution porocessing stuff these don't really even need to be class functions, they could be simply...
Definition IPlotBase.cxx:20
histsvc
TrigInDetMonitoring part ################################.

◆ histSvc()

virtual ServiceHandle< ITHistSvc > & IDTPM2::IPlotBase::histSvc ( )
inlineprotectedvirtualinherited

we may well need these at some point ...

this method is dangerous - should not be used anywhere except finalise or stop

Definition at line 105 of file IPlotBase.h.

105 {
106 if ( monTool()==0 ) throw std::runtime_error("IPlotBase: monTool not set");
107 return (*monTool())->histogramService();
108 }
ToolHandle< GenericMonitoringTool > * monTool()
mon tool
Definition IPlotBase.h:71

◆ initialize()

void IDTPM2::Efficiencies::initialize ( )
virtual

Dedicated fill method (for tracks and/or truth particles).


— Book the histograms —

why would we ever not want the efficiency vs mu ?

for later ...

m_eff_vs_eta_vs_pt = TIDA::Histogram<float,bool>( monTool(), "eff_vs_eta_vs_pt" ); m_eff_vs_eta_vs_phi = TIDA::Histogram<float,bool>( monTool(), "eff_vs_eta_vs_phi" ); m_eff_vs_z0_vs_d0 = TIDA::Histogram<float,bool>( monTool(), "eff_vs_z0_vs_d0" ); m_eff_vs_z0sin_vs_d0 = TIDA::Histogram<float,bool>( monTool(), "eff_vs_z0sin_vs_d0" );

Implements IDTPM2::IPlotBase.

Definition at line 23 of file Efficiencies.cxx.

23 {
24
25 // MY_MSG_DEBUG << "Booking efficiency plots in " << getDirectory() << endmsg;
26
27 m_eff_vs_inclusive = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_inclusive" );
28 m_eff_vs_ntracks = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_ntracks" );
29 m_eff_vs_pt = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_pt" );
30 // may still want these in the future ...
31 // m_eff_vs_logPt = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_logPt" );
32 // m_eff_vs_lowPt = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_lowPt" );
33 m_eff_vs_eta = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_eta" );
34 m_eff_vs_phi = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_phi" );
35 m_eff_vs_d0 = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_d0" );
36 m_eff_vs_z0 = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_z0" );
37
38 m_eff_vs_Et = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_Et" );
39 m_eff_vs_EtovPt = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_EtovPt" );
40
41
43 m_eff_vs_actualMu = TIDA::Histogram2D<float,bool>( monTool(), "eff_vs_actualMu" );
44
46 // if( m_doTruthMuPlots ) m_eff_vs_truthMu = TIDA::Histogram<float,bool>( monTool(), "eff_vs_truthMu" );
47 // }
48
53
54
55}

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)
int outputLevel(const IMessageSvc *ims, const std::string &source)

◆ monTool() [1/2]

ToolHandle< GenericMonitoringTool > * IDTPM2::IPlotBase::monTool ( )
inlineinherited

mon tool

Definition at line 71 of file IPlotBase.h.

71{ return m_monTool; }
ToolHandle< GenericMonitoringTool > * m_monTool
Definition IPlotBase.h:116

◆ monTool() [2/2]

const ToolHandle< GenericMonitoringTool > * IDTPM2::IPlotBase::monTool ( ) const
inlineinherited

Definition at line 73 of file IPlotBase.h.

73{ return m_monTool; }

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 167 of file AthMessaging.h.

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels).
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 182 of file AthMessaging.h.

183{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 // If user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ name()

const std::string & IDTPM2::IPlotBase::name ( ) const
inlineinherited

generic utilities, just in case

Definition at line 68 of file IPlotBase.h.

68{ return m_name; }
const std::string & m_name
Definition IPlotBase.h:114

◆ processResolution() [1/2]

void IDTPM2::IPlotBase::processResolution ( const std::string & path,
bool writeflag = false )
inlineprotectedinherited

Definition at line 89 of file IPlotBase.h.

89{ return processResolution( histSvc(), path, writeflag ); }
void processResolution(const std::string &path, bool writeflag=false)
Definition IPlotBase.h:89

◆ processResolution() [2/2]

void IDTPM2::IPlotBase::processResolution ( ServiceHandle< ITHistSvc > & histsvc,
const std::string & path,
bool writeflag = false ) const
protectedinherited

process the histogramss NB: might be better if instead of adding the 2D histogram and then copying the 1D hjistograms back, we passed in the 1D histogram pointers and filled them directly in the Resplot

use the provides 1D, maan, sigme histograms etc would like to do this ...

use the provides 1D, maan, sigme histograms etc

Definition at line 49 of file IPlotBase.cxx.

49 {
50
51 TH2* hist2d = 0;
52
53 if ( histsvc->getHist( path+"2D", hist2d ).isFailure() ) MY_MSG_WARNING << "Could not retieve 2D: " << (path+"2D") << endmsg;
54 else {
55
60
61 Resplot::Resplot rp( path, hist2d );
62
63 rp.Finalise( Resplot::FitNull95 );
64
65 if ( !writeflag ) {
68 // if ( histsvc->regHist( path+"1D", rp.H1D() ).isFailure() ) MY_MSG_WARNING << "Unable to register histogram: 1D: " << name() << endmsg;
69 // if ( histsvc->regHist( path+"mean", rp.Mean() ).isFailure() ) MY_MSG_WARNING << "Unable to register histogram: mean: " << name() << endmsg;
70 // if ( histsvc->regHist( path+"sigma", rp.Sigma() ).isFailure() ) MY_MSG_WARNING << "Unable to register histogram: sigma: " << name() << endmsg;
71 // }
72 // else {
74 getHist( histsvc, path+"1D", rp.H1D() );
75 getHist( histsvc, path+"mean", rp.Mean() );
76 getHist( histsvc, path+"sigma", rp.Sigma() );
77 }
78 }
79
80}
ReadCards * rp
TF1 * FitNull95(TH1D *s, double a=0, double b=0)
Definition Resplot.cxx:1472
path
python interpreter configuration --------------------------------------—
Definition athena.py:130

◆ realPath()

std::string IDTPM2::IPlotBase::realPath ( const std::string & tag = "")
inherited

This is a horrific function, has to get ALL the histograms, just to be able to work out how to get the actual path to the histograms for this tool - there simply MUST be a better way ...

can add on our "fixed" histogram "Vertex" domain

Definition at line 86 of file IPlotBase.cxx.

86 {
87
88 std::string dir = (*monTool())->getPath();
89
91 std::string stub = dir.substr( dir.find('/', 1) + 1 ) + tag;
92
93 const std::vector<std::string>& allhists = histSvc()->getHists();
94
95 std::string basestr = "";
96
97 for ( size_t i=0 ; i<allhists.size() ; i++ ) {
98 if ( allhists[i].find(stub)!=std::string::npos ) {
99 std::string s = allhists[i];
100 basestr = s.substr(0,s.find("/"+stub)+1);
101 break;
102 }
103 }
104
105 return basestr + stub;
106
107}
bool allhists
Definition hcg.cxx:81
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:140

◆ set_monTool()

void IDTPM2::IPlotBase::set_monTool ( ToolHandle< GenericMonitoringTool > * m)
inlineinherited

do we need / should we have this specific setter ??

Definition at line 76 of file IPlotBase.h.

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging).

Definition at line 141 of file AthMessaging.h.

◆ m_eff_vs_actualMu

TIDA::Histogram2D<float,bool> IDTPM2::Efficiencies::m_eff_vs_actualMu
private

◆ m_eff_vs_d0

TIDA::Histogram2D<float,bool> IDTPM2::Efficiencies::m_eff_vs_d0
private

◆ m_eff_vs_Et

TIDA::Histogram2D<float,bool> IDTPM2::Efficiencies::m_eff_vs_Et
private

◆ m_eff_vs_eta

TIDA::Histogram2D<float,bool> IDTPM2::Efficiencies::m_eff_vs_eta
private

◆ m_eff_vs_EtovPt

TIDA::Histogram2D<float,bool> IDTPM2::Efficiencies::m_eff_vs_EtovPt
private

◆ m_eff_vs_inclusive

TIDA::Histogram2D<float,bool> IDTPM2::Efficiencies::m_eff_vs_inclusive
private

NB: the egregious root convention for a TEfficiency is Fill( ismatched, variable ), but that is awful, and inconsistent, so we swap that round.

Definition at line 43 of file TrigMonitoring/TrigIDR4Monitoring/src/Efficiencies.h.

◆ m_eff_vs_ntracks

TIDA::Histogram2D<float,bool> IDTPM2::Efficiencies::m_eff_vs_ntracks
private

◆ m_eff_vs_phi

TIDA::Histogram2D<float,bool> IDTPM2::Efficiencies::m_eff_vs_phi
private

◆ m_eff_vs_pt

TIDA::Histogram2D<float,bool> IDTPM2::Efficiencies::m_eff_vs_pt
private

◆ m_eff_vs_z0

TIDA::Histogram2D<float,bool> IDTPM2::Efficiencies::m_eff_vs_z0
private

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_monTool

ToolHandle<GenericMonitoringTool>* IDTPM2::IPlotBase::m_monTool
protectedinherited

Definition at line 116 of file IPlotBase.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels).

Definition at line 132 of file AthMessaging.h.

◆ m_name

const std::string& IDTPM2::IPlotBase::m_name
protectedinherited

Definition at line 114 of file IPlotBase.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.


The documentation for this class was generated from the following files: