ATLAS Offline Software
EventQualityFilterAlg.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // EventQualityFilterAlg.cxx
8 // Implementation file for class EventQualityFilterAlg
9 // Author: Karsten Koeneke <karsten.koeneke@cern.ch>
10 // Description: Algorithm to filter out events with a bad Event error
12 
13 // SelectionUtils includes
14 #include "EventQualityFilterAlg.h"
15 
16 // EDM includes
18 
19 // FrameWork includes
22 
23 
25 // Public methods:
27 
28 // Constructors
31  ISvcLocator* pSvcLocator ) :
32  ::AthFilterAlgorithm( name, pSvcLocator ),
33  m_useLArError(true),
34  m_useTileError(true),
35  m_useSCTError(true),
36  m_useCoreError(true)
37 {
38  //
39  // Property declaration
40  //
41  declareProperty( "VetoLArError", m_useLArError, "Veto events with a LAr error" );
42  declareProperty( "VetoTileError", m_useTileError, "Veto events with a Tile error" );
43  declareProperty( "VetoSCTError", m_useSCTError, "Veto events with an SCT error" );
44  declareProperty( "VetoCoreError", m_useCoreError, "Veto events with a Core error" );
45  //declareProperty( "VetoTileTrips", m_useTileTripReader, "Veto events with a Tile trip error" );
46 }
47 
48 
49 
50 
51 // Destructor
54 {}
55 
56 
57 
58 
59 // Athena Algorithm's Hooks
62 {
63  ATH_MSG_DEBUG ("Initializing " << name() << "...");
64  ATH_MSG_DEBUG( "Using: " << m_useLArError );
65  ATH_MSG_DEBUG( "Using: " << m_useTileError );
66  ATH_MSG_DEBUG( "Using: " << m_useSCTError );
67  ATH_MSG_DEBUG( "Using: " << m_useCoreError );
68  // ATH_MSG_DEBUG( "Using: " << m_useTileTripReader );
70  return StatusCode::SUCCESS;
71 }
72 
73 
74 
76 {
77  ATH_MSG_DEBUG ("Finalizing " << name() << "...");
78  return StatusCode::SUCCESS;
79 }
80 
81 
82 
84 {
85  ATH_MSG_DEBUG ("Executing " << name() << "...");
86 
87  const EventContext& ctx = Gaudi::Hive::currentContext();
88 
89  // Get the EventInfo object
91  if (!eventInfo.isValid()) {
92  ATH_MSG_ERROR("Could not retrieve EventInfo!");
93  return StatusCode::FAILURE;
94  }
95 
96 
97 
98  // Only do the event vetoing on data
99  const bool isSim = eventInfo->eventType(xAOD::EventInfo::EventType::IS_SIMULATION);
100  if ( isSim ) {
101  ATH_MSG_DEBUG ("It is an MC event... not vetoing...");
102  this->setFilterPassed(true);
103  return StatusCode::SUCCESS;
104  }
105 
106 
107  // Now make the event decision
108  bool passEvent(true);
109  if ( m_useLArError.value() && eventInfo->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error ){ passEvent = false; }
110  if ( m_useTileError.value() && eventInfo->errorState(xAOD::EventInfo::Tile) == xAOD::EventInfo::Error ){ passEvent = false; }
111  if ( m_useSCTError.value() && eventInfo->errorState(xAOD::EventInfo::SCT) == xAOD::EventInfo::Error ){ passEvent = false; }
112  if ( m_useCoreError.value() && eventInfo->isEventFlagBitSet(xAOD::EventInfo::Core, 18) ){ passEvent = false; }
113 
114  // Set the final decision
115  this->setFilterPassed(passEvent);
116 
117  return StatusCode::SUCCESS;
118 }
AthFilterAlgorithm::setFilterPassed
virtual void setFilterPassed(bool state) const
Set the filter passed flag to the specified state.
Definition: AthFilterAlgorithm.cxx:99
EventQualityFilterAlg.h
CurrentContext.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
EventQualityFilterAlg::m_eventInfo
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
EventInfo read handle.
Definition: EventQualityFilterAlg.h:66
EventQualityFilterAlg::initialize
virtual StatusCode initialize()
Definition: EventQualityFilterAlg.cxx:61
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition: EventInfo_v1.h:335
EventQualityFilterAlg::m_useCoreError
BooleanProperty m_useCoreError
Flag to turn on/off checking of core error flag.
Definition: EventQualityFilterAlg.h:60
EventQualityFilterAlg::finalize
virtual StatusCode finalize()
Definition: EventQualityFilterAlg.cxx:75
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
EventQualityFilterAlg::~EventQualityFilterAlg
virtual ~EventQualityFilterAlg()
Destructor:
Definition: EventQualityFilterAlg.cxx:53
AthFilterAlgorithm
Definition: AthFilterAlgorithm.h:26
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
EventQualityFilterAlg::EventQualityFilterAlg
EventQualityFilterAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Definition: EventQualityFilterAlg.cxx:30
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ReadHandle.h
Handle class for reading from StoreGate.
EventQualityFilterAlg::m_useLArError
BooleanProperty m_useLArError
Flag to turn on/off checking of LAr calorimeter error flag.
Definition: EventQualityFilterAlg.h:51
EventQualityFilterAlg::m_useSCTError
BooleanProperty m_useSCTError
Flag to turn on/off checking of SCT error flag.
Definition: EventQualityFilterAlg.h:57
EventQualityFilterAlg::m_useTileError
BooleanProperty m_useTileError
Flag to turn on/off checking of tile calorimter error flag.
Definition: EventQualityFilterAlg.h:54
EventInfo.h
xAOD::EventInfo_v1::Tile
@ Tile
The Tile calorimeter.
Definition: EventInfo_v1.h:336
xAOD::EventInfo_v1::errorState
EventFlagErrorState errorState(EventFlagSubDet subDet) const
Get the error state for a particular sub-detector.
Definition: EventInfo_v1.cxx:817
xAOD::EventInfo_v1::isEventFlagBitSet
bool isEventFlagBitSet(EventFlagSubDet subDet, size_t bit) const
Check one particular bit of one particular sub-detector.
Definition: EventInfo_v1.cxx:703
EventQualityFilterAlg::execute
virtual StatusCode execute()
Definition: EventQualityFilterAlg.cxx:83
xAOD::EventInfo_v1::Core
@ Core
Core flags describing the event.
Definition: EventInfo_v1.h:339
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.
xAOD::EventInfo_v1::SCT
@ SCT
The SCT.
Definition: EventInfo_v1.h:333