ATLAS Offline Software
GoodRunsListFilterAlgorithm.cxx
Go to the documentation of this file.
1 // DerivationFrameworkCore includes
3 
6 
9 
10 namespace DerivationFramework {
11 
12 GoodRunsListFilterAlgorithm::GoodRunsListFilterAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) :
13  AthAlgorithm( name, pSvcLocator ),
14  m_grlTool("GoodRunsListSelectionTool/grlTool",this),
15  m_brlTool("GoodRunsListSelectionTool/brlTool",this)
16 {
17 
18  declareProperty( "GoodRunsListVec", m_goodRunsListVec, "Good Runs Lists files ... will pass events" );
19  declareProperty( "BlackRunsListVec", m_blackRunsListVec, "Black Runs Lists files ... will veto events" );
20 
21 }
22 
23 
25 
26 
28 
29  //configure the tools
30  CHECK( AAH::setProperty( m_grlTool , "GoodRunsListVec", m_goodRunsListVec ) );
31  CHECK( AAH::setProperty( m_brlTool , "GoodRunsListVec", m_blackRunsListVec ) );
32 
33  //determine the maxGRLRunNumber ...
34  if(!m_goodRunsListVec.empty()) {
35  CHECK( m_grlTool.retrieve() ); //will check the files are ok ..
36 
38  for(auto& f : m_goodRunsListVec) {
39  std::string path = PathResolverFindXMLFile( f );
40  if(path.empty()) path = PathResolverFindCalibFile( f );
41  if(path.empty()) continue; //skip this file .. should never happen
42  reader.AddXMLFile( path );
43  }
44 
45  if(!reader.Interpret()) {
46  ATH_MSG_ERROR("Failed to interpret GRLs ... this should never happen");
47  return StatusCode::FAILURE;
48  }
49 
50  std::vector<int> runs = reader.GetMergedGoodRunsList().GetRunlist();
51  m_maxGRLRunNumber = *max_element( runs.begin(), runs.end() );
52 
53  ATH_MSG_INFO("Max GRL RunNumber = " << m_maxGRLRunNumber << ". Data in later runs will pass GRL check");
54 
55  }
56 
57 
58  return StatusCode::SUCCESS;
59 }
60 
62 
63 
64 
65  return StatusCode::SUCCESS;
66 }
67 
69  //This algorithm decorates EventInfo with passDFGRL to indicate if
70  //GRL&&!BRL requirement has passed or failed
71  //The algorithm is also marked as not passing if it failed
72  //
73  //Any event that has a runNumber > the biggest runNumber in the GRLs
74  //will be passed (unless it fails the BRL requirement)
75 
76 
77  const xAOD::EventInfo* ei = nullptr;
78  CHECK( evtStore()->retrieve( ei, "EventInfo" ) );
79 
80  bool decision(true);
82  decision=true; //pass for MC
83  } else if( !m_blackRunsListVec.empty() && m_brlTool->passRunLB( *ei ) ) {
84  decision=false; //fail because in black list
85  } else if(ei->runNumber() > m_maxGRLRunNumber) {
86  decision=true; //pass because run number is past end of GRL
87  } else if( m_goodRunsListVec.empty() || m_grlTool->passRunLB( *ei ) ) {
88  decision=true; //pass: either there is no GRL given, or the event is in the GRL
89  } else {
90  decision=false; //event is not in the GRL
91  }
92 
93  setFilterPassed(decision);
94 
95  static const SG::AuxElement::Decorator< char > decEventInfo_passDFGRL("passDFGRL");
96  decEventInfo_passDFGRL( *ei ) = decision;
97 
98  ATH_MSG_VERBOSE("passDFGRL = " << decision);
99 
100  return StatusCode::SUCCESS;
101 }
102 
103 } //end of namespace
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
Root::TGoodRunsListReader
Definition: TGoodRunsListReader.h:34
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthAnalysisHelper::setProperty
static StatusCode setProperty(const std::string &name, const std::string &property, const W &value, bool override=true)
Definition: AthAnalysisHelper.h:79
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DerivationFramework::GoodRunsListFilterAlgorithm::GoodRunsListFilterAlgorithm
GoodRunsListFilterAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GoodRunsListFilterAlgorithm.cxx:12
find_tgc_unfilled_channelids.runs
int runs
Definition: find_tgc_unfilled_channelids.py:10
DerivationFramework::GoodRunsListFilterAlgorithm::m_brlTool
ToolHandle< IGoodRunsListSelectionTool > m_brlTool
Definition: GoodRunsListFilterAlgorithm.h:24
DerivationFramework::GoodRunsListFilterAlgorithm::m_blackRunsListVec
std::vector< std::string > m_blackRunsListVec
Definition: GoodRunsListFilterAlgorithm.h:27
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::GoodRunsListFilterAlgorithm::m_maxGRLRunNumber
uint m_maxGRLRunNumber
Definition: GoodRunsListFilterAlgorithm.h:29
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
DerivationFramework::GoodRunsListFilterAlgorithm::~GoodRunsListFilterAlgorithm
virtual ~GoodRunsListFilterAlgorithm()
Definition: GoodRunsListFilterAlgorithm.cxx:24
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:58
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PathResolverFindXMLFile
std::string PathResolverFindXMLFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:374
DerivationFramework::GoodRunsListFilterAlgorithm::execute
virtual StatusCode execute()
Definition: GoodRunsListFilterAlgorithm.cxx:68
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
AthAlgorithm
Definition: AthAlgorithm.h:47
DerivationFramework::GoodRunsListFilterAlgorithm::m_grlTool
ToolHandle< IGoodRunsListSelectionTool > m_grlTool
Definition: GoodRunsListFilterAlgorithm.h:24
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TGoodRunsListReader.h
GoodRunsListFilterAlgorithm.h
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
AthAnalysisHelper.h
DerivationFramework::GoodRunsListFilterAlgorithm::m_goodRunsListVec
std::vector< std::string > m_goodRunsListVec
Definition: GoodRunsListFilterAlgorithm.h:26
DerivationFramework::GoodRunsListFilterAlgorithm::finalize
virtual StatusCode finalize()
Definition: GoodRunsListFilterAlgorithm.cxx:61
DerivationFramework::GoodRunsListFilterAlgorithm::initialize
virtual StatusCode initialize()
uncomment and implement methods as required
Definition: GoodRunsListFilterAlgorithm.cxx:27
collisions.reader
reader
read the goodrunslist xml file(s)
Definition: collisions.py:22
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.