ATLAS Offline Software
Loading...
Searching...
No Matches
StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl Class Reference
Inheritance diagram for StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl:
Collaboration diagram for StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl:

Public Member Functions

 StandaloneL1TopoHistSvcImpl ()
 ~StandaloneL1TopoHistSvcImpl ()
void registerHist (TH1 *h)
void registerHist (TH2 *h)
TH1 * findHist (const std::string &histName)
void fillHist1D (const std::string &histName, double x)
void fillHist2D (const std::string &histName, double x, double y)
void setBaseDir (const std::string &baseDir)
void save ()
bool msgLvl (const MSGTC::Level lvl) const
 Test the output level.
MsgStreamTC & msg () const
 The standard message stream.
MsgStreamTC & msg (const MSGTC::Level lvl) const
 The standard message stream.
const std::string & getName () const
 name accessor

Private Attributes

std::map< std::string, TH1 * > m_hists1D
std::map< std::string, TH2 * > m_hists2D
std::string m_baseDir {""}
boost::thread_specific_ptr< MsgStreamTC > m_msg_tls
 MsgStreamTC instance (a std::cout like with print-out levels)
std::string m_name

Detailed Description

Definition at line 15 of file StandaloneL1TopoHistSvc.cxx.

Constructor & Destructor Documentation

◆ StandaloneL1TopoHistSvcImpl()

StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::StandaloneL1TopoHistSvcImpl ( )
inline

Definition at line 19 of file StandaloneL1TopoHistSvc.cxx.

19 :
20 TrigConfMessaging("StandaloneL1TopoHistSvc")
21 {}

◆ ~StandaloneL1TopoHistSvcImpl()

StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::~StandaloneL1TopoHistSvcImpl ( )
inline

Definition at line 23 of file StandaloneL1TopoHistSvc.cxx.

23 {
24 for( const auto & h : m_hists1D ) {
25 delete h.second;
26 }
27 for( const auto & h : m_hists2D ) {
28 delete h.second;
29 }
30 }

Member Function Documentation

◆ fillHist1D()

void StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::fillHist1D ( const std::string & histName,
double x )
inline

Definition at line 69 of file StandaloneL1TopoHistSvc.cxx.

69 {
70 auto h = m_hists1D.find(histName);
71 if( h == end(m_hists1D) ) {
72 TRG_MSG_WARNING("No histogram found for " << histName);
73 } else
74 h->second->Fill(x);
75 }
#define x

◆ fillHist2D()

void StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::fillHist2D ( const std::string & histName,
double x,
double y )
inline

Definition at line 77 of file StandaloneL1TopoHistSvc.cxx.

77 {
78 auto h = m_hists2D.find(histName);
79 if( h == end(m_hists2D) ) {
80 TRG_MSG_WARNING("No histogram found for " << histName);
81 } else
82 h->second->Fill(x,y);
83 }
#define y

◆ findHist()

TH1 * StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::findHist ( const std::string & histName)
inline

Definition at line 58 of file StandaloneL1TopoHistSvc.cxx.

58 {
59 auto colPos = histName.find_first_of('/');
60 std::string realhistName = histName.substr(colPos+1);
61 auto h = m_hists1D.find(realhistName);
62 if( h == end(m_hists1D) ) {
63 return nullptr;
64 } else {
65 return h->second;
66 }
67 }

◆ getName()

const std::string & TrigConf::TrigConfMessaging::getName ( ) const
inlineinherited

name accessor

Returns
the name

Definition at line 101 of file TrigConfMessaging.h.

101 {
102 return m_name;
103 }

◆ msg() [1/2]

MsgStreamTC & TrigConf::TrigConfMessaging::msg ( ) const
inlineinherited

The standard message stream.

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

Definition at line 86 of file TrigConfMessaging.h.

87 {
88 MsgStreamTC* ms = m_msg_tls.get();
89 if (!ms) {
90 ms = new MsgStreamTC(m_name);
91 m_msg_tls.reset(ms);
92 }
93 return *ms;
94 }
boost::thread_specific_ptr< MsgStreamTC > m_msg_tls
MsgStreamTC instance (a std::cout like with print-out levels)

◆ msg() [2/2]

MsgStreamTC & TrigConf::TrigConfMessaging::msg ( const MSGTC::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 96 of file TrigConfMessaging.h.

97 {
98 return msg() << lvl;
99 }
MsgStreamTC & msg() const
The standard message stream.

◆ msgLvl()

bool TrigConf::TrigConfMessaging::msgLvl ( const MSGTC::Level lvl) const
inlineinherited

Test the output level.

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

Definition at line 75 of file TrigConfMessaging.h.

76 {
77 if (msg().level() <= lvl) {
78 msg() << lvl;
79 return true;
80 }
81 else {
82 return false;
83 }
84 }

◆ registerHist() [1/2]

void StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::registerHist ( TH1 * h)
inline

Definition at line 32 of file StandaloneL1TopoHistSvc.cxx.

32 {
33 if(h != nullptr) {
34 TRG_MSG_DEBUG("Registering histogram " << h->GetName());
35 const std::string key = h->GetName();
36 if( m_hists1D.find(key) == end(m_hists1D) ) {
37 m_hists1D[key] = h;
38 } else {
39 TRG_MSG_WARNING("StandaloneL1TopoHistSvc::registerHist: a histogram " << key << " exists already. Will keep the first one and delete the newly requested.");
40 delete h;
41 }
42 }
43 }

◆ registerHist() [2/2]

void StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::registerHist ( TH2 * h)
inline

Definition at line 45 of file StandaloneL1TopoHistSvc.cxx.

45 {
46 if(h != nullptr) {
47 TRG_MSG_DEBUG("Registering histogram " << h->GetName());
48 const std::string key = h->GetName();
49 if( m_hists2D.find(key) == end(m_hists2D) ) {
50 m_hists2D[key] = h;
51 } else {
52 TRG_MSG_WARNING("StandaloneL1TopoHistSvc::registerHist: a histogram " << key << " exists already. Will keep the first one and delete the newly requested.");
53 delete h;
54 }
55 }
56 }

◆ save()

void StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::save ( )
inline

Definition at line 89 of file StandaloneL1TopoHistSvc.cxx.

89 {
90
91 std::string filename = "L1Topo.root";
92 std::string basepath = "";
93
94 std::string opt = "RECREATE";
95
96 auto colPos = m_baseDir.find_last_of(':');
97 if( colPos != std::string::npos ) {
98 filename = m_baseDir.substr(0, colPos);
99 basepath = m_baseDir.substr(colPos+1);
100 } else {
102 }
103
104
105 TFile * f = TFile::Open(filename.c_str(),opt.c_str());
106 for( const auto & h : m_hists1D ) {
107
108 std::string fullName(h.second->GetName());
109 std::string path(basepath);
110
111 auto slashPos = fullName.find_last_of('/');
112 if(slashPos != std::string::npos) {
113 if(path!="")
114 path += "/";
115 path += fullName.substr(0,slashPos);
116 // set the name
117 h.second->SetName( fullName.substr(slashPos+1).c_str() );
118 }
119
120 const char* dir = path.c_str();
121 if( ! f->GetDirectory(dir)) {
122 f->mkdir(dir);
123 }
124 f->cd(dir);
125 h.second->Write();
126 }
127 for( const auto & h : m_hists2D ) {
128
129 std::string fullName(h.second->GetName());
130 std::string path(basepath);
131
132 auto slashPos = fullName.find_last_of('/');
133 if(slashPos != std::string::npos) {
134 if(path!="")
135 path += "/";
136 path += fullName.substr(0,slashPos);
137 // set the name
138 h.second->SetName( fullName.substr(slashPos+1).c_str() );
139 }
140
141 const char* dir = path.c_str();
142 if( ! f->GetDirectory(dir)) {
143 f->mkdir(dir);
144 }
145 f->cd(dir);
146 h.second->Write();
147 }
148 f->Write();
149 f->Close();
150 TRG_MSG_INFO("Wrote " << m_hists1D.size()+m_hists2D.size() << " l1topo algorithm histograms to file " << filename);
151 }
path
python interpreter configuration --------------------------------------—
Definition athena.py:128

◆ setBaseDir()

void StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::setBaseDir ( const std::string & baseDir)
inline

Definition at line 85 of file StandaloneL1TopoHistSvc.cxx.

85 {
87 }

Member Data Documentation

◆ m_baseDir

std::string StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::m_baseDir {""}
private

Definition at line 157 of file StandaloneL1TopoHistSvc.cxx.

157{""};

◆ m_hists1D

std::map<std::string,TH1*> StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::m_hists1D
private

Definition at line 155 of file StandaloneL1TopoHistSvc.cxx.

◆ m_hists2D

std::map<std::string,TH2*> StandaloneL1TopoHistSvc::StandaloneL1TopoHistSvcImpl::m_hists2D
private

Definition at line 156 of file StandaloneL1TopoHistSvc.cxx.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStreamTC> TrigConf::TrigConfMessaging::m_msg_tls
mutableprivateinherited

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

Definition at line 71 of file TrigConfMessaging.h.

◆ m_name

std::string TrigConf::TrigConfMessaging::m_name
privateinherited

Definition at line 72 of file TrigConfMessaging.h.


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