ATLAS Offline Software
BCM_ZeroSuppression.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GaudiKernel/StatusCode.h"
6 
8 
11 #include "StoreGate/ReadHandle.h"
12 #include "StoreGate/WriteHandle.h"
13 
14 #include <vector>
15 using namespace std;
16 
18  ISvcLocator* pSvcLocator)
19  : AthReentrantAlgorithm(name, pSvcLocator)
20 {
21  declareProperty("BcmContainerName", m_bcmContainerName = "BCM_RDOs");
22  declareProperty("BcmOutputContainerName", m_bcmOutputName = "BCM_CompactDOs");
23 }
24 
26 = default;
27 
31  return StatusCode::SUCCESS;
32 }
33 
34 StatusCode BCM_ZeroSuppression::execute(const EventContext& ctx) const {
35  // Retrieve BCM RDO
37  if( !bcm_rdo.isValid() ) {
38  // There is a warning from StoreGate anyways at this point.
39  // @TODO return failure instead ?
40  return StatusCode::SUCCESS;
41  }
42 
43  // Create output RDO container and record it to StoreGate
45  if (bcm_compact_DO.record(std::make_unique<BCM_RDO_Container>()).isFailure()) {
46  ATH_MSG_FATAL( "Container '" << m_bcmOutputName << "' could not be registered in StoreGate");
47  return StatusCode::FAILURE;
48  }
49 
50  // check if the collection exists if in the original container and loop over it
51  // and copy only those which have information in them
52  for (const BCM_RDO_Collection *BCM_RDO: *bcm_rdo) {
53 
54  std::unique_ptr<BCM_RDO_Collection> my_collection(std::make_unique<BCM_RDO_Collection>() );
55 
56  for (const BCM_RawData *RDO_element: *BCM_RDO) {
57 
58  int bcm_pulse1width = RDO_element->getPulse1Width();
59  int bcm_pulse2width = RDO_element->getPulse2Width();
60  if ((bcm_pulse1width != 0) || (bcm_pulse2width !=0)) {
61  my_collection->push_back((new BCM_RawData(*RDO_element)));
62  }
63 
64  }
65 
66  if (!my_collection->empty()) {
67  ATH_MSG_VERBOSE("Container '" << m_bcmOutputName.key() << "' is being filled");
68  bcm_compact_DO->push_back(my_collection.release());
69  }
70 
71  }//end of container loop
72 
73  return StatusCode::SUCCESS;
74 }
75 
77  return StatusCode::SUCCESS;
78 }
BCM_ZeroSuppression.h
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
BCM_ZeroSuppression::execute
StatusCode execute(const EventContext &ctx) const override
Definition: BCM_ZeroSuppression.cxx:34
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
BCM_ZeroSuppression::m_bcmOutputName
SG::WriteHandleKey< BCM_RDO_Container > m_bcmOutputName
Definition: BCM_ZeroSuppression.h:37
WriteHandle.h
Handle class for recording to StoreGate.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
BCM_RawData
Definition: BCM_RawData.h:36
BCM_RawData.h
BCM_RDO_Collection.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
BCM_ZeroSuppression::finalize
StatusCode finalize() override
Definition: BCM_ZeroSuppression.cxx:76
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
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
BCM_ZeroSuppression::~BCM_ZeroSuppression
~BCM_ZeroSuppression()
BCM_ZeroSuppression::BCM_ZeroSuppression
BCM_ZeroSuppression(const std::string &name, ISvcLocator *pSvcLocator)
Definition: BCM_ZeroSuppression.cxx:17
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
BCM_ZeroSuppression::initialize
StatusCode initialize() override
Definition: BCM_ZeroSuppression.cxx:28
BCM_ZeroSuppression::m_bcmContainerName
SG::ReadHandleKey< BCM_RDO_Container > m_bcmContainerName
A data member to contain the name of the BCM RDO that contains the input BCM information.
Definition: BCM_ZeroSuppression.h:36
ReadHandle.h
Handle class for reading from StoreGate.
BCM_RDO_Collection
Definition: BCM_RDO_Collection.h:27
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.