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

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

Gaudi::Property< std::vector< std::string > > m_goodrunslistVec {this, "GoodRunsListVec", {}, "list of input xml files"}
Gaudi::Property< std::vector< std::string > > m_blackrunslistVec {this,"BlackRunsListVec", {}, "list of input xml files"}
std::unique_ptr< Root::TGRLCollectionm_grlcollection {new Root::TGRLCollection()}
std::unique_ptr< Root::TGRLCollectionm_brlcollection {new Root::TGRLCollection()}
std::unique_ptr< Root::TGoodRunsListReaderm_reader {new Root::TGoodRunsListReader()}
Gaudi::Property< int > m_boolop {this,"BoolOperation",0}
Gaudi::Property< bool > m_passthrough {this,"PassThrough",true}
Gaudi::Property< bool > m_rejectanybrl {this,"RejectBlackRunsInEventSelector",false}
Gaudi::Property< bool > m_eventselectormode {this,"EventSelectorMode",false}
std::map< std::string, vvPairm_registry

Detailed Description

This file contains the class definition for the GoodRunsListSelectorTool class.

Definition at line 30 of file GoodRunsListSelectorTool.h.

Constructor & Destructor Documentation

◆ ~GoodRunsListSelectorTool()

virtual GoodRunsListSelectorTool::~GoodRunsListSelectorTool ( )
inlinevirtual

Definition at line 36 of file GoodRunsListSelectorTool.h.

36{};

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 231 of file GoodRunsListSelectorTool.cxx.

232{
233 struct stat info;
234 int ret = -1;
235
236 //get the file attributes
237 ret = stat(fileName, &info);
238
239 if(ret == 0) {
242 //if (info.st_size == 0) return false;
243 //else
244 return true;
245 } else {
247 return false;
248 }
249}

◆ finalize()

StatusCode GoodRunsListSelectorTool::finalize ( )

Finalize AlgTool.

Definition at line 223 of file GoodRunsListSelectorTool.cxx.

224{
225 ATH_MSG_DEBUG ("finalize() ");
226 return StatusCode::SUCCESS;
227}
#define ATH_MSG_DEBUG(x)

◆ getBRLCollection()

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

Definition at line 59 of file GoodRunsListSelectorTool.h.

59{ return m_brlcollection.get(); }
std::unique_ptr< Root::TGRLCollection > m_brlcollection

◆ getGRLCollection()

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

get grl/brl collection

Definition at line 58 of file GoodRunsListSelectorTool.h.

58{ return m_grlcollection.get(); }
std::unique_ptr< Root::TGRLCollection > m_grlcollection

◆ getGRLSelectorRegistry()

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

get GRL selector registry

Definition at line 55 of file GoodRunsListSelectorTool.h.

55{ 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 20 of file GoodRunsListSelectorTool.cxx.

21{
22 ATH_MSG_DEBUG ("initialize() ");
23
24 Root::TMsgLogger::SetMinLevel(static_cast<Root::TMsgLevel>(msgLevel()));
25
27 if (!m_goodrunslistVec.empty() || !m_blackrunslistVec.empty())
28 m_passthrough=false;
29
31 if (m_passthrough) ATH_MSG_WARNING ("Set to pass-through mode.");
32
34 std::vector<std::string>::iterator itr;
35 for (itr=m_goodrunslistVec.begin(); itr!=m_goodrunslistVec.end(); ++itr) {
36 std::string fname;
37 if ( itr->find('/')==0 || itr->find('$')==0 || itr->find('.')==0 || itr->find(':')!=string::npos ) {
38 fname = gSystem->ExpandPathName( itr->c_str() );
39 }
40 else {
42 }
43 if ( !fileExists(fname.c_str()) ) {
44 ATH_MSG_ERROR ("Cannot open file : " << fname);
45 return StatusCode::FAILURE;
46 }
47 }
48 for (itr=m_blackrunslistVec.begin(); itr!=m_blackrunslistVec.end(); ++itr) {
49 std::string fname;
50 if ( itr->find('/')==0 || itr->find('$')==0 || itr->find('.')==0 || itr->find(':')!=string::npos ) {
51 fname = gSystem->ExpandPathName( itr->c_str() );
52 }
53 else {
55 }
56 if ( !fileExists(fname.c_str()) ) {
57 ATH_MSG_ERROR ("Cannot open file : " << fname);
58 return StatusCode::FAILURE;
59 }
60 }
62 if ( !m_goodrunslistVec.empty() ) {
63 m_reader->Reset();
64 for (itr=m_goodrunslistVec.begin(); itr!=m_goodrunslistVec.end(); ++itr) {
65 std::string fname;
66 if ( itr->find('/')==0 || itr->find('$')==0 || itr->find('.')==0 || itr->find(':')!=string::npos ) {
67 fname = gSystem->ExpandPathName( itr->c_str() );
68 }
69 else {
71 }
72 m_reader->AddXMLFile(fname);
73 }
74 m_reader->Interpret();
76 *m_grlcollection = m_reader->GetMergedGRLCollection(static_cast<Root::BoolOperation>(m_boolop.value()));
77 }
78 if ( !m_blackrunslistVec.empty() ) {
79 m_reader->Reset();
80 for (itr=m_blackrunslistVec.begin(); itr!=m_blackrunslistVec.end(); ++itr) {
81 std::string fname;
82 if ( itr->find('/')==0 || itr->find('$')==0 || itr->find('.')==0 || itr->find(':')!=string::npos ) {
83 fname = gSystem->ExpandPathName( itr->c_str() );
84 }
85 else {
87 }
88 m_reader->AddXMLFile(fname);
89 }
90 m_reader->Interpret();
92 *m_brlcollection = m_reader->GetMergedGRLCollection(static_cast<Root::BoolOperation>(m_boolop.value()));
93 }
94
95 return StatusCode::SUCCESS;
96}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
std::string PathResolverFindXMLFile(const std::string &logical_file_name)
Gaudi::Property< std::vector< std::string > > m_blackrunslistVec
Gaudi::Property< int > m_boolop
Gaudi::Property< bool > m_passthrough
bool fileExists(const char *fileName)
std::unique_ptr< Root::TGoodRunsListReader > m_reader
Gaudi::Property< std::vector< std::string > > m_goodrunslistVec
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 100 of file GoodRunsListSelectorTool.cxx.

101{
102 ATH_MSG_DEBUG ("passEvent() ");
103
104 auto eventNumber = pEvent.event_number();
105 int runNumber = pEvent.run_number();
106 int lumiBlockNr = pEvent.lumi_block();
107 auto timeStamp = pEvent.time_stamp();
108
109 ATH_MSG_DEBUG ("passEvent() :: run number = " << runNumber <<
110 " ; event number = " << eventNumber <<
111 " ; lumiblock number = " << lumiBlockNr <<
112 " ; timestamp = " << timeStamp
113 );
114
116 bool pass(false);
117 if (m_passthrough) {
118 ATH_MSG_DEBUG ("passEvent() :: Pass through mode.");
119 pass = true;
120 }
122 else {
123 pass = this->passRunLB(runNumber,lumiBlockNr);
124 }
125
126 return pass;
127}
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 165 of file GoodRunsListSelectorTool.cxx.

168{
169 ATH_MSG_DEBUG ("passRunLB() ");
170
172 if (m_passthrough) {
173 ATH_MSG_DEBUG ("passRunLB() :: Pass through mode.");
174 return true;
175 }
176
179 if ( m_brlcollection->HasRunLumiBlock(runNumber,lumiBlockNr) ) {
180 ATH_MSG_DEBUG ("passRunLB() :: Event rejected by (_any_ of) merged black runs list.");
181 return false;
182 }
184 } else if (!brlnameVec.empty()) {
185 bool reject(false);
186 std::vector<Root::TGoodRunsList>::const_iterator brlitr;
187 for (unsigned int i=0; i<brlnameVec.size() && !reject; ++i) {
188 brlitr = m_brlcollection->find(brlnameVec[i]);
189 if (brlitr!=m_brlcollection->end())
190 reject = brlitr->HasRunLumiBlock(runNumber,lumiBlockNr);
191 }
192 if (reject) {
193 ATH_MSG_DEBUG ("passRunLB() :: Event rejected by specific black runs list.");
194 return false;
195 }
196 }
197
199 if (!grlnameVec.empty()) {
200 bool pass(false);
201 std::vector<Root::TGoodRunsList>::const_iterator grlitr;
202 for (unsigned int i=0; i<grlnameVec.size() && !pass; ++i) {
203 grlitr = m_grlcollection->find(grlnameVec[i]);
204 if (grlitr!=m_grlcollection->end())
205 pass = grlitr->HasRunLumiBlock(runNumber,lumiBlockNr);
206 }
207 if (pass) {
208 ATH_MSG_DEBUG ("passRunLB() :: Event accepted by specific good runs list.");
209 return true;
210 }
212 } else if (m_grlcollection->HasRunLumiBlock(runNumber,lumiBlockNr)) {
213 ATH_MSG_DEBUG ("passRunLB() :: Event accepted by (_any_ of) merged good runs list.");
214 return true;
215 }
216
217 ATH_MSG_DEBUG ("passRunLB() :: Event rejected, not in (any) good runs list.");
218 return false;
219}
Gaudi::Property< bool > m_eventselectormode
Gaudi::Property< bool > m_rejectanybrl

◆ 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 131 of file GoodRunsListSelectorTool.cxx.

133{
134 ATH_MSG_DEBUG ("passThisRunLB() ");
135
136 const EventContext& ctx = Gaudi::Hive::currentContext();
137
138 int eventNumber = ctx.eventID().event_number();
139 int runNumber = ctx.eventID().run_number();
140 int lumiBlockNr = ctx.eventID().lumi_block();
141 int timeStamp = ctx.eventID().time_stamp();
142
143 ATH_MSG_DEBUG ("passThisRunLB() :: run number = " << runNumber <<
144 " ; event number = " << eventNumber <<
145 " ; lumiblock number = " << lumiBlockNr <<
146 " ; timestamp = " << timeStamp
147 );
148
150 bool pass(false);
151 if (m_passthrough) {
152 ATH_MSG_DEBUG ("passThisRunLB() :: Pass through mode.");
153 pass = true;
154 }
156 else {
157 pass = this->passRunLB(runNumber,lumiBlockNr,grlnameVec,brlnameVec);
158 }
159
160 return pass;
161}

◆ 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 253 of file GoodRunsListSelectorTool.cxx.

254{
255 if (m_registry.find(name)!=m_registry.end()) {
256 ATH_MSG_WARNING ("registerGRLSelector() :: GRL selector with name <" << name << "> already registered. Return false.");
257 return false;
258 }
259
261 if (!brlnameVec.empty()) {
262 std::vector<Root::TGoodRunsList>::const_iterator brlitr;
263 for (unsigned int i=0; i<brlnameVec.size(); ++i) {
264 brlitr = m_brlcollection->find(brlnameVec[i]);
265 if (brlitr==m_brlcollection->end()) {
266 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)?");
267 return false;
268 }
269 }
270 }
271
273 if (!grlnameVec.empty()) {
274 std::vector<Root::TGoodRunsList>::const_iterator grlitr;
275 for (unsigned int i=0; i<grlnameVec.size(); ++i) {
276 grlitr = m_grlcollection->find(grlnameVec[i]);
277 if (grlitr==m_grlcollection->end()) {
278 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)?");
279 return false;
280 }
281 }
282 }
283
284 ATH_MSG_DEBUG ("registerGRLSelector() :: GRL selector with name <" << name << "> registered.");
285 m_registry[name] = vvPair(grlnameVec,brlnameVec);
286 return true;
287}
std::pair< std::vector< std::string >, std::vector< std::string > > vvPair

Member Data Documentation

◆ m_blackrunslistVec

Gaudi::Property<std::vector<std::string> > GoodRunsListSelectorTool::m_blackrunslistVec {this,"BlackRunsListVec", {}, "list of input xml files"}
protected

Definition at line 66 of file GoodRunsListSelectorTool.h.

66{this,"BlackRunsListVec", {}, "list of input xml files"};

◆ m_boolop

Gaudi::Property<int> GoodRunsListSelectorTool::m_boolop {this,"BoolOperation",0}
protected

Definition at line 74 of file GoodRunsListSelectorTool.h.

74{this,"BoolOperation",0};

◆ m_brlcollection

std::unique_ptr<Root::TGRLCollection> GoodRunsListSelectorTool::m_brlcollection {new Root::TGRLCollection()}
protected

Definition at line 70 of file GoodRunsListSelectorTool.h.

70{new Root::TGRLCollection()};

◆ m_eventselectormode

Gaudi::Property<bool> GoodRunsListSelectorTool::m_eventselectormode {this,"EventSelectorMode",false}
protected

Definition at line 77 of file GoodRunsListSelectorTool.h.

77{this,"EventSelectorMode",false};

◆ m_goodrunslistVec

Gaudi::Property<std::vector<std::string> > GoodRunsListSelectorTool::m_goodrunslistVec {this, "GoodRunsListVec", {}, "list of input xml files"}
protected

Definition at line 65 of file GoodRunsListSelectorTool.h.

65{this, "GoodRunsListVec", {}, "list of input xml files"};

◆ m_grlcollection

std::unique_ptr<Root::TGRLCollection> GoodRunsListSelectorTool::m_grlcollection {new Root::TGRLCollection()}
protected

Definition at line 69 of file GoodRunsListSelectorTool.h.

69{new Root::TGRLCollection()};

◆ m_passthrough

Gaudi::Property<bool> GoodRunsListSelectorTool::m_passthrough {this,"PassThrough",true}
protected

Definition at line 75 of file GoodRunsListSelectorTool.h.

75{this,"PassThrough",true};

◆ m_reader

std::unique_ptr<Root::TGoodRunsListReader> GoodRunsListSelectorTool::m_reader {new Root::TGoodRunsListReader()}
protected

Definition at line 72 of file GoodRunsListSelectorTool.h.

72{new Root::TGoodRunsListReader()};

◆ m_registry

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

Definition at line 79 of file GoodRunsListSelectorTool.h.

◆ m_rejectanybrl

Gaudi::Property<bool> GoodRunsListSelectorTool::m_rejectanybrl {this,"RejectBlackRunsInEventSelector",false}
protected

Definition at line 76 of file GoodRunsListSelectorTool.h.

76{this,"RejectBlackRunsInEventSelector",false};

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