ATLAS Offline Software
TBDMContainerSplitter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
11  ISvcLocator* pSvcLocator) :
12  AthAlgorithm(name, pSvcLocator),
13  m_DMHitsKey("LArCalibrationHitDeadMaterial"),
14  m_DMHitsCaloKey("LArCalibrationHitDeadMaterial_Calo"),
15  m_DMHitsLeakKey("LArCalibrationHitDeadMaterial_Leakage"),
16  m_caloDmDescrManager(0)
17 {
18  declareProperty("InputDMContainer",m_DMHitsKey);
19  declareProperty("OutputDM_Calo",m_DMHitsCaloKey);
20  declareProperty("OutputDM_Leak",m_DMHitsLeakKey);
21 }
22 
24 { }
25 
27 {
28  ATH_MSG_INFO ( "in initialize()" );
29 
32  ATH_MSG_FATAL(" Could not get the CaloDmDescrManager !! ");
33  return StatusCode::FAILURE ;
34  }
35 
36  ATH_MSG_INFO ( "end of initialize()" );
37  return StatusCode::SUCCESS;
38 }
39 
40 
42 {
43  return StatusCode::SUCCESS;
44 }
45 
47 {
48  ATH_MSG_DEBUG ( "Executing TBDMContainerSplitter " );
49 
50  // Retrieve Original DM container
51  const CaloCalibrationHitContainer* inDMCont;
52  StatusCode sc = evtStore()->retrieve(inDMCont, m_DMHitsKey);
53  if ( sc.isFailure() ) {
55  ( "Cannot retrieve CaloCalibrationHitContainer "<<m_DMHitsKey<<" from StoreGate" );
56  setFilterPassed(false);
57  return StatusCode::SUCCESS;
58  }
59  // Create two new DMCont
62 
63  // Loop over original, and fill two new ones
64  for (const CaloCalibrationHit* hit : *inDMCont) {
65  Identifier myId = hit->cellID();
66  CaloDmDescrElement* myCDDE(0);
67  myCDDE = m_caloDmDescrManager->get_element(myId);
68  CaloCalibrationHit *chit = new CaloCalibrationHit(myId, hit->energyEM(), hit->energyNonEM(), hit->energyInvisible(), hit->energyEscaped());
69  if ( myCDDE ) {
70  if(myCDDE->eta()>2.5 && myCDDE->phi() > M_PI/2 && myCDDE->phi() < M_PI){ // Calo hit
71  outDMContCalo->push_back(chit);
72  } else{ //Leak hit
73  outDMContLeak->push_back(chit);
74  }
75  } else { // No CDDE, assume leak hit
76  outDMContLeak->push_back(chit);
77  }
78  }
79 
80  // Store new containers
81  sc = evtStore()->record(outDMContCalo, m_DMHitsCaloKey);
82  if ( sc.isFailure() ) {
83  ATH_MSG_ERROR ( "Could not store: "<<m_DMHitsCaloKey<<" to StoreGate" );
84  setFilterPassed(false);
85  return StatusCode::SUCCESS;
86  }
87  sc = evtStore()->record(outDMContLeak, m_DMHitsLeakKey);
88  if ( sc.isFailure() ) {
89  ATH_MSG_ERROR ( "Could not store: "<<m_DMHitsLeakKey<<" to StoreGate" );
90  setFilterPassed(false);
91  return StatusCode::SUCCESS;
92  }
93 
94 
95  setFilterPassed(true);
96  return StatusCode::SUCCESS;
97 
98 }
99 
CaloCalibrationHitContainer
Definition: CaloCalibrationHitContainer.h:25
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloDmDescrManager::get_element
CaloDmDescrElement * get_element(const Identifier &cellId) const
Definition: CaloDmDescrManager.cxx:107
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TBDMContainerSplitter.h
M_PI
#define M_PI
Definition: ActiveFraction.h:11
TBDMContainerSplitter::initialize
virtual StatusCode initialize() override
Definition: TBDMContainerSplitter.cxx:26
TBDMContainerSplitter::m_caloDmDescrManager
const CaloDmDescrManager * m_caloDmDescrManager
Definition: TBDMContainerSplitter.h:32
CaloCalibrationHitContainer
CaloCalibrationHitContainer
Definition: CaloSimEventTPCnv.cxx:17
CaloCalibrationHitContainer.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloDmDescrManager::instance
static const CaloDmDescrManager * instance()
Definition: CaloDmDescrManager.cxx:67
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
AthenaHitsVector::push_back
void push_back(T *t)
Definition: AthenaHitsVector.h:153
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CaloDmDescrManager.h
CaloDmDescrElement::phi
float phi() const
Definition: CaloDmDescrManager.h:59
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
CaloDmDescrElement::eta
float eta() const
Definition: CaloDmDescrManager.h:57
CaloDmDescrElement
Definition: CaloDmDescrManager.h:33
AthAlgorithm
Definition: AthAlgorithm.h:47
TBDMContainerSplitter::execute
virtual StatusCode execute() override
Definition: TBDMContainerSplitter.cxx:46
TBDMContainerSplitter::m_DMHitsLeakKey
std::string m_DMHitsLeakKey
Definition: TBDMContainerSplitter.h:30
CaloCalibrationHit
Class to store calorimeter calibration hit.
Definition: CaloCalibrationHit.h:23
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TBDMContainerSplitter::m_DMHitsCaloKey
std::string m_DMHitsCaloKey
Definition: TBDMContainerSplitter.h:29
TBDMContainerSplitter::TBDMContainerSplitter
TBDMContainerSplitter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TBDMContainerSplitter.cxx:10
TBDMContainerSplitter::~TBDMContainerSplitter
virtual ~TBDMContainerSplitter()
Definition: TBDMContainerSplitter.cxx:23
TBDMContainerSplitter::m_DMHitsKey
std::string m_DMHitsKey
Definition: TBDMContainerSplitter.h:28
TBDMContainerSplitter::finalize
virtual StatusCode finalize() override
Definition: TBDMContainerSplitter.cxx:41
Identifier
Definition: IdentifierFieldParser.cxx:14