ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
14#include <vector>
15using 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
29 ATH_CHECK( m_bcmContainerName.initialize() );
30 ATH_CHECK( m_bcmOutputName.initialize() );
31 return StatusCode::SUCCESS;
32}
33
34StatusCode 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
StatusCode finalize() override
StatusCode execute(const EventContext &ctx) const override
SG::WriteHandleKey< BCM_RDO_Container > m_bcmOutputName
BCM_ZeroSuppression(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< BCM_RDO_Container > m_bcmContainerName
A data member to contain the name of the BCM RDO that contains the input BCM information.
StatusCode initialize() override
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
STL namespace.