ATLAS Offline Software
Loading...
Searching...
No Matches
GoodRunsListSelectorTool Class Reference

This file contains the class definition for the GoodRunsListSelectorTool class. More...

#include <GoodRunsListSelectorTool.h>

Inheritance diagram for GoodRunsListSelectorTool:
Collaboration diagram for GoodRunsListSelectorTool:

Public Member Functions

 GoodRunsListSelectorTool (const std::string &, const std::string &, const IInterface *)
virtual ~GoodRunsListSelectorTool ()
StatusCode initialize ()
 Initialize AlgTool.
bool passEvent (const EventIDBase &pEvent)
 called for each event by EventSelector to decide if the event should be passed
StatusCode finalize ()
 Finalize AlgTool.
bool passRunLB (int runNumber, int lumiBlockNr, const std::vector< std::string > &grlnameVec=std::vector< std::string >(), const std::vector< std::string > &brlnameVec=std::vector< std::string >())
 called for each event by GoodRunsListSelectorAlg to decide if the event should be passed
bool passThisRunLB (const std::vector< std::string > &grlnameVec=std::vector< std::string >(), const std::vector< std::string > &brlnameVec=std::vector< std::string >())
 called for each event by GoodRunsListSelectorAlg to decide if the event should be passed
bool registerGRLSelector (const std::string &name, const std::vector< std::string > &grlnameVec, const std::vector< std::string > &brlnameVec)
 register grl/brl combination
const std::map< std::string, vvPair > & getGRLSelectorRegistry ()
 get GRL selector registry
const Root::TGRLCollectiongetGRLCollection () const
 get grl/brl collection
const Root::TGRLCollectiongetBRLCollection () const

Protected Member Functions

bool fileExists (const char *fileName)

Protected Attributes

std::vector< std::string > m_goodrunslistVec
std::vector< std::string > m_blackrunslistVec
Root::TGRLCollectionm_grlcollection
Root::TGRLCollectionm_brlcollection
Root::TGoodRunsListReaderm_reader
std::map< std::string, TFormula * > m_dqformula
int m_boolop
bool m_passthrough
bool m_rejectanybrl
bool m_eventselectormode
std::map< std::string, vvPairm_registry

Detailed Description

This file contains the class definition for the GoodRunsListSelectorTool class.

Definition at line 35 of file GoodRunsListSelectorTool.h.

Constructor & Destructor Documentation

◆ GoodRunsListSelectorTool()

GoodRunsListSelectorTool::GoodRunsListSelectorTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 23 of file GoodRunsListSelectorTool.cxx.

24 : base_class( type, name, parent )
25 , m_reader(0)
26 , m_boolop(0)
27 , m_passthrough(true)
28 , m_rejectanybrl(false)
29 , m_eventselectormode(false)
30{
31 declareProperty( "GoodRunsListVec", m_goodrunslistVec, "list of input xml files" );
32 declareProperty( "BlackRunsListVec", m_blackrunslistVec, "list of input xml files" );
33 declareProperty( "BoolOperation", m_boolop );
34 declareProperty( "PassThrough", m_passthrough = true);
35 declareProperty( "RejectBlackRunsInEventSelector", m_rejectanybrl = false );
36 declareProperty( "EventSelectorMode", m_eventselectormode = false );
37
38 m_grlcollection = new Root::TGRLCollection();
39 m_brlcollection = new Root::TGRLCollection();
40 m_reader = new Root::TGoodRunsListReader();
41}
Root::TGoodRunsListReader * m_reader
Root::TGRLCollection * m_grlcollection
std::vector< std::string > m_blackrunslistVec
Root::TGRLCollection * m_brlcollection
std::vector< std::string > m_goodrunslistVec

◆ ~GoodRunsListSelectorTool()

GoodRunsListSelectorTool::~GoodRunsListSelectorTool ( )
virtual

Definition at line 44 of file GoodRunsListSelectorTool.cxx.

45{
46 if (m_grlcollection!=0) delete m_grlcollection;
47 if (m_brlcollection!=0) delete m_brlcollection;
48 if (m_reader!=0) delete m_reader;
49
50 // delete all the formula pntrs in the map
51 while ( ! m_dqformula.empty() ) {
52 std::map< std::string,TFormula* >::iterator itr= m_dqformula.begin();
53 TFormula* form = (*itr).second;
54 m_dqformula.erase(itr);
55 delete form;
56 }
57}
std::map< std::string, TFormula * > m_dqformula

Member Function Documentation

◆ fileExists()

bool GoodRunsListSelectorTool::fileExists ( const char * fileName)
protected

stat() is able to get the file attributes, so the file obviously exists if filesize==0 assume the copying failed.

stat() is not able to get the file attributes, so the file obviously does not exist.

Definition at line 276 of file GoodRunsListSelectorTool.cxx.

277{
278 struct stat info;
279 int ret = -1;
280
281 //get the file attributes
282 ret = stat(fileName, &info);
283
284 if(ret == 0) {
287 //if (info.st_size == 0) return false;
288 //else
289 return true;
290 } else {
292 return false;
293 }
294}

◆ finalize()

StatusCode GoodRunsListSelectorTool::finalize ( )

Finalize AlgTool.

Definition at line 268 of file GoodRunsListSelectorTool.cxx.

269{
270 ATH_MSG_DEBUG ("finalize() ");
271 return StatusCode::SUCCESS;
272}
#define ATH_MSG_DEBUG(x)

◆ getBRLCollection()

const Root::TGRLCollection * GoodRunsListSelectorTool::getBRLCollection ( ) const
inline

Definition at line 62 of file GoodRunsListSelectorTool.h.

62{ return m_brlcollection; }

◆ getGRLCollection()

const Root::TGRLCollection * GoodRunsListSelectorTool::getGRLCollection ( ) const
inline

get grl/brl collection

Definition at line 61 of file GoodRunsListSelectorTool.h.

61{ return m_grlcollection; }

◆ getGRLSelectorRegistry()

const std::map< std::string, vvPair > & GoodRunsListSelectorTool::getGRLSelectorRegistry ( )
inline

get GRL selector registry

Definition at line 58 of file GoodRunsListSelectorTool.h.

58{ return m_registry; }
std::map< std::string, vvPair > m_registry

◆ initialize()

StatusCode GoodRunsListSelectorTool::initialize ( )

Initialize AlgTool.

reset pass-through mode

warn about pass-thru mode

checking existence of goodrunslists / blocklists

start reading xml files

this merge accounts for same identical metadata, version, name, etc.

this merge accounts for same identical metadata, version, name, etc.

Definition at line 61 of file GoodRunsListSelectorTool.cxx.

62{
63 ATH_MSG_DEBUG ("initialize() ");
64
65 Root::TMsgLogger::SetMinLevel(static_cast<Root::TMsgLevel>(msgLevel()));
66
68 if (!m_goodrunslistVec.empty() || !m_blackrunslistVec.empty())
69 m_passthrough=false;
70
72 if (m_passthrough) ATH_MSG_WARNING ("Set to pass-through mode.");
73
75 std::vector<std::string>::iterator itr;
76 for (itr=m_goodrunslistVec.begin(); itr!=m_goodrunslistVec.end(); ++itr) {
77 //const char* fname;
78 std::string fname;
79 if ( itr->find('/')==0 || itr->find('$')==0 || itr->find('.')==0 || itr->find(':')!=string::npos ) {
80 fname = gSystem->ExpandPathName( itr->c_str() );
81 }
82 else {
84 }
85 if ( !fileExists(fname.c_str()) ) {
86 ATH_MSG_ERROR ("Cannot open file : " << fname);
87 return StatusCode::FAILURE;
88 }
89 }
90 for (itr=m_blackrunslistVec.begin(); itr!=m_blackrunslistVec.end(); ++itr) {
91 //const char* fname;
92 std::string fname;
93 if ( itr->find('/')==0 || itr->find('$')==0 || itr->find('.')==0 || itr->find(':')!=string::npos ) {
94 fname = gSystem->ExpandPathName( itr->c_str() );
95 }
96 else {
98 }
99 if ( !fileExists(fname.c_str()) ) {
100 ATH_MSG_ERROR ("Cannot open file : " << fname);
101 return StatusCode::FAILURE;
102 }
103 }
105 if ( !m_goodrunslistVec.empty() ) {
106 m_reader->Reset();
107 for (itr=m_goodrunslistVec.begin(); itr!=m_goodrunslistVec.end(); ++itr) {
108 //const char* fname;
109 std::string fname;
110 if ( itr->find('/')==0 || itr->find('$')==0 || itr->find('.')==0 || itr->find(':')!=string::npos ) {
111 fname = gSystem->ExpandPathName( itr->c_str() );
112 }
113 else {
114 fname = (PathResolverFindXMLFile( *itr ));
115 }
116 m_reader->AddXMLFile(fname);
117 }
118 m_reader->Interpret();
120 *m_grlcollection = m_reader->GetMergedGRLCollection(static_cast<Root::BoolOperation>(m_boolop));
121 }
122 if ( !m_blackrunslistVec.empty() ) {
123 m_reader->Reset();
124 for (itr=m_blackrunslistVec.begin(); itr!=m_blackrunslistVec.end(); ++itr) {
125 //const char* fname;
126 std::string fname;
127 if ( itr->find('/')==0 || itr->find('$')==0 || itr->find('.')==0 || itr->find(':')!=string::npos ) {
128 fname = gSystem->ExpandPathName( itr->c_str() );
129 }
130 else {
131 fname = (PathResolverFindXMLFile( *itr ));
132 }
133 m_reader->AddXMLFile(fname);
134 }
135 m_reader->Interpret();
137 *m_brlcollection = m_reader->GetMergedGRLCollection(static_cast<Root::BoolOperation>(m_boolop));
138 }
139
140 return StatusCode::SUCCESS;
141}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
std::string PathResolverFindXMLFile(const std::string &logical_file_name)
bool fileExists(const char *fileName)
static void SetMinLevel(TMsgLevel minLevel)
Definition TMsgLogger.h:92
TMsgLevel
Definition TMsgLogger.h:37

◆ passEvent()

bool GoodRunsListSelectorTool::passEvent ( const EventIDBase & pEvent)

called for each event by EventSelector to decide if the event should be passed

now make query decision ...

decide from XML files

Definition at line 145 of file GoodRunsListSelectorTool.cxx.

146{
147 ATH_MSG_DEBUG ("passEvent() ");
148
149 auto eventNumber = pEvent.event_number();
150 int runNumber = pEvent.run_number();
151 int lumiBlockNr = pEvent.lumi_block();
152 auto timeStamp = pEvent.time_stamp();
153
154 ATH_MSG_DEBUG ("passEvent() :: run number = " << runNumber <<
155 " ; event number = " << eventNumber <<
156 " ; lumiblock number = " << lumiBlockNr <<
157 " ; timestamp = " << timeStamp
158 );
159
161 bool pass(false);
162 if (m_passthrough) {
163 ATH_MSG_DEBUG ("passEvent() :: Pass through mode.");
164 pass = true;
165 }
167 else {
168 pass = this->passRunLB(runNumber,lumiBlockNr);
169 }
170
171 return pass;
172}
bool passRunLB(int runNumber, int lumiBlockNr, const std::vector< std::string > &grlnameVec=std::vector< std::string >(), const std::vector< std::string > &brlnameVec=std::vector< std::string >())
called for each event by GoodRunsListSelectorAlg to decide if the event should be passed
setEventNumber timeStamp

◆ passRunLB()

bool GoodRunsListSelectorTool::passRunLB ( int runNumber,
int lumiBlockNr,
const std::vector< std::string > & grlnameVec = std::vector<std::string>(),
const std::vector< std::string > & brlnameVec = std::vector<std::string>() )

called for each event by GoodRunsListSelectorAlg to decide if the event should be passed

pass through

decision based on merged blackrunslist

decision based on specific blackrunlists

decision based on specific goodrunlists

decision based on merged goodrunslist

Definition at line 210 of file GoodRunsListSelectorTool.cxx.

213{
214 ATH_MSG_DEBUG ("passRunLB() ");
215
217 if (m_passthrough) {
218 ATH_MSG_DEBUG ("passRunLB() :: Pass through mode.");
219 return true;
220 }
221
224 if ( m_brlcollection->HasRunLumiBlock(runNumber,lumiBlockNr) ) {
225 ATH_MSG_DEBUG ("passRunLB() :: Event rejected by (_any_ of) merged black runs list.");
226 return false;
227 }
229 } else if (!brlnameVec.empty()) {
230 bool reject(false);
231 std::vector<Root::TGoodRunsList>::const_iterator brlitr;
232 for (unsigned int i=0; i<brlnameVec.size() && !reject; ++i) {
233 brlitr = m_brlcollection->find(brlnameVec[i]);
234 if (brlitr!=m_brlcollection->end())
235 reject = brlitr->HasRunLumiBlock(runNumber,lumiBlockNr);
236 }
237 if (reject) {
238 ATH_MSG_DEBUG ("passRunLB() :: Event rejected by specific black runs list.");
239 return false;
240 }
241 }
242
244 if (!grlnameVec.empty()) {
245 bool pass(false);
246 std::vector<Root::TGoodRunsList>::const_iterator grlitr;
247 for (unsigned int i=0; i<grlnameVec.size() && !pass; ++i) {
248 grlitr = m_grlcollection->find(grlnameVec[i]);
249 if (grlitr!=m_grlcollection->end())
250 pass = grlitr->HasRunLumiBlock(runNumber,lumiBlockNr);
251 }
252 if (pass) {
253 ATH_MSG_DEBUG ("passRunLB() :: Event accepted by specific good runs list.");
254 return true;
255 }
257 } else if (m_grlcollection->HasRunLumiBlock(runNumber,lumiBlockNr)) {
258 ATH_MSG_DEBUG ("passRunLB() :: Event accepted by (_any_ of) merged good runs list.");
259 return true;
260 }
261
262 ATH_MSG_DEBUG ("passRunLB() :: Event rejected, not in (any) good runs list.");
263 return false;
264}

◆ passThisRunLB()

bool GoodRunsListSelectorTool::passThisRunLB ( const std::vector< std::string > & grlnameVec = std::vector<std::string>(),
const std::vector< std::string > & brlnameVec = std::vector<std::string>() )

called for each event by GoodRunsListSelectorAlg to decide if the event should be passed

now make query decision ...

decide from XML files

Definition at line 176 of file GoodRunsListSelectorTool.cxx.

178{
179 ATH_MSG_DEBUG ("passThisRunLB() ");
180
181 const EventContext& ctx = Gaudi::Hive::currentContext();
182
183 int eventNumber = ctx.eventID().event_number();
184 int runNumber = ctx.eventID().run_number();
185 int lumiBlockNr = ctx.eventID().lumi_block();
186 int timeStamp = ctx.eventID().time_stamp();
187
188 ATH_MSG_DEBUG ("passThisRunLB() :: run number = " << runNumber <<
189 " ; event number = " << eventNumber <<
190 " ; lumiblock number = " << lumiBlockNr <<
191 " ; timestamp = " << timeStamp
192 );
193
195 bool pass(false);
196 if (m_passthrough) {
197 ATH_MSG_DEBUG ("passThisRunLB() :: Pass through mode.");
198 pass = true;
199 }
201 else {
202 pass = this->passRunLB(runNumber,lumiBlockNr,grlnameVec,brlnameVec);
203 }
204
205 return pass;
206}

◆ registerGRLSelector()

bool GoodRunsListSelectorTool::registerGRLSelector ( const std::string & name,
const std::vector< std::string > & grlnameVec,
const std::vector< std::string > & brlnameVec )

register grl/brl combination

check if brl names are really known

check if grl names are really known

Definition at line 298 of file GoodRunsListSelectorTool.cxx.

299{
300 if (m_registry.find(name)!=m_registry.end()) {
301 ATH_MSG_WARNING ("registerGRLSelector() :: GRL selector with name <" << name << "> already registered. Return false.");
302 return false;
303 }
304
306 if (!brlnameVec.empty()) {
307 std::vector<Root::TGoodRunsList>::const_iterator brlitr;
308 for (unsigned int i=0; i<brlnameVec.size(); ++i) {
309 brlitr = m_brlcollection->find(brlnameVec[i]);
310 if (brlitr==m_brlcollection->end()) {
311 ATH_MSG_ERROR ("registerGRLSelector() :: requested BRL object with name <" << brlnameVec[i] << "> not found. Have you provided an object name from the BRL xml-file(s)?");
312 return false;
313 }
314 }
315 }
316
318 if (!grlnameVec.empty()) {
319 std::vector<Root::TGoodRunsList>::const_iterator grlitr;
320 for (unsigned int i=0; i<grlnameVec.size(); ++i) {
321 grlitr = m_grlcollection->find(grlnameVec[i]);
322 if (grlitr==m_grlcollection->end()) {
323 ATH_MSG_ERROR ("registerGRLSelector() :: requested GRL object with name <" << grlnameVec[i] << "> not found. Have you provided an object name from the GRL xml-file(s)?");
324 return false;
325 }
326 }
327 }
328
329 ATH_MSG_DEBUG ("registerGRLSelector() :: GRL selector with name <" << name << "> registered.");
330 m_registry[name] = vvPair(grlnameVec,brlnameVec);
331 return true;
332}
std::pair< std::vector< std::string >, std::vector< std::string > > vvPair

Member Data Documentation

◆ m_blackrunslistVec

std::vector<std::string> GoodRunsListSelectorTool::m_blackrunslistVec
protected

Definition at line 69 of file GoodRunsListSelectorTool.h.

◆ m_boolop

int GoodRunsListSelectorTool::m_boolop
protected

Definition at line 78 of file GoodRunsListSelectorTool.h.

◆ m_brlcollection

Root::TGRLCollection* GoodRunsListSelectorTool::m_brlcollection
protected

Definition at line 72 of file GoodRunsListSelectorTool.h.

◆ m_dqformula

std::map< std::string,TFormula* > GoodRunsListSelectorTool::m_dqformula
protected

Definition at line 76 of file GoodRunsListSelectorTool.h.

◆ m_eventselectormode

bool GoodRunsListSelectorTool::m_eventselectormode
protected

Definition at line 81 of file GoodRunsListSelectorTool.h.

◆ m_goodrunslistVec

std::vector<std::string> GoodRunsListSelectorTool::m_goodrunslistVec
protected

Definition at line 68 of file GoodRunsListSelectorTool.h.

◆ m_grlcollection

Root::TGRLCollection* GoodRunsListSelectorTool::m_grlcollection
protected

Definition at line 71 of file GoodRunsListSelectorTool.h.

◆ m_passthrough

bool GoodRunsListSelectorTool::m_passthrough
protected

Definition at line 79 of file GoodRunsListSelectorTool.h.

◆ m_reader

Root::TGoodRunsListReader* GoodRunsListSelectorTool::m_reader
protected

Definition at line 74 of file GoodRunsListSelectorTool.h.

◆ m_registry

std::map< std::string, vvPair > GoodRunsListSelectorTool::m_registry
protected

Definition at line 83 of file GoodRunsListSelectorTool.h.

◆ m_rejectanybrl

bool GoodRunsListSelectorTool::m_rejectanybrl
protected

Definition at line 80 of file GoodRunsListSelectorTool.h.


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