ATLAS Offline Software
LArCollisionTimeDecorator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // LArCollisionTimeDecorator.cxx, (c) ATLAS Detector software
8 // Author: Olivier Arnaez ( olivier.arnaez@cern.ch )
9 
14 
15 #include <vector>
16 #include <utility>
17 #include <string>
18 
19 namespace DerivationFramework {
20 
22  const std::string& name,
23  const IInterface* parent) :
25  {
26  declareInterface<DerivationFramework::IAugmentationTool>(this);
27  }
28 
30  {
31 
32  if (m_sgName.empty()) {
33  ATH_MSG_WARNING("No decoration prefix name provided for the output of LArCollisionTimeDecorator!");
34  }
35 
36  if (m_eventInfoKey.key().empty()) {
37  ATH_MSG_ERROR("No EventInfo collection provided for LArCollisionTimeDecorator!");
38  return StatusCode::FAILURE;
39  }
42  {
43  std::vector<std::string> names;
44  names.resize(kNIntDecor);
45  names[kncellA]="ncellA";
46  names[kncellC]="ncellC";
47  createDecoratorKeys(*this,m_eventInfoKey,"" /* common prefix */,names, m_intDecorKeys);
48  }
49 
50  {
51  std::vector<std::string> names;
52  names.resize(kNFloatDecor);
53  names[kenergyA] = "energyA";
54  names[kenergyC] = "energyC";
55  names[ktimeA] = "timeA";
56  names[ktimeC] = "timeC";
57  createDecoratorKeys(*this,m_eventInfoKey,"" /* common prefix */,names, m_floatDecorKeys);
58  }
59 
60  return StatusCode::SUCCESS;
61  }
62 
64  {
65  return StatusCode::SUCCESS;
66  }
67 
69  {
70  ATH_MSG_DEBUG("Adding LAr time info to EventInfo");
71  const EventContext& ctx = Gaudi::Hive::currentContext();
73  CHECK( eventInfo.isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE);
74 
76 
77  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,int> > int_decor_handles(createDecorators<xAOD::EventInfo,int>(m_intDecorKeys,ctx));
78  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,float> > float_decor_handles(createDecorators<xAOD::EventInfo,float>(m_floatDecorKeys,ctx));
79  assert( int_decor_handles.size() == kNIntDecor);
80  assert( float_decor_handles.size() == kNFloatDecor);
81  if (tps.isValid()) {
82  int_decor_handles[kncellA](*eventInfo) = tps->ncellA();
83  int_decor_handles[kncellC](*eventInfo) = tps->ncellC();
84  float_decor_handles[kenergyA](*eventInfo) = tps->energyA();
85  float_decor_handles[kenergyC](*eventInfo) = tps->energyC();
86  float_decor_handles[ktimeA](*eventInfo) = tps->timeA();
87  float_decor_handles[ktimeC](*eventInfo) = tps->timeC();
88  float LArECtimeDiff = tps->timeA()-tps->timeC();
89  ATH_MSG_DEBUG("Decorating LAr time info, LArECTimeDiff = " << LArECtimeDiff);
90  }
91  else {
92  ATH_MSG_WARNING("Missing LArCollisionTime information.");
93  }
94 
95  return StatusCode::SUCCESS;
96  }
97 
98 }
DecoratorUtils.h
LArCollisionTime::energyC
double energyC() const
total energy C side
Definition: LArCollisionTime.h:39
DerivationFramework::LArCollisionTimeDecorator::kncellC
@ kncellC
Definition: LArCollisionTimeDecorator.h:47
DerivationFramework::LArCollisionTimeDecorator::m_larCollisionTimeKey
SG::ReadHandleKey< LArCollisionTime > m_larCollisionTimeKey
Definition: LArCollisionTimeDecorator.h:45
DerivationFramework::LArCollisionTimeDecorator::kenergyC
@ kenergyC
Definition: LArCollisionTimeDecorator.h:48
DerivationFramework::LArCollisionTimeDecorator::finalize
StatusCode finalize()
Definition: LArCollisionTimeDecorator.cxx:63
DerivationFramework::createDecoratorKeys
void createDecoratorKeys(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::WriteDecorHandleKey< T_Cont > > &decor_out)
Definition: DecoratorUtils.h:20
LArCollisionTime::energyA
double energyA() const
total energy A side
Definition: LArCollisionTime.h:36
AthMsgStreamMacros.h
DerivationFramework::LArCollisionTimeDecorator::addBranches
virtual StatusCode addBranches() const
Pass the thinning service
Definition: LArCollisionTimeDecorator.cxx:68
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DerivationFramework::LArCollisionTimeDecorator::initialize
StatusCode initialize()
Definition: LArCollisionTimeDecorator.cxx:29
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DerivationFramework::LArCollisionTimeDecorator::m_floatDecorKeys
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_floatDecorKeys
Definition: LArCollisionTimeDecorator.h:51
DerivationFramework::LArCollisionTimeDecorator::kNIntDecor
@ kNIntDecor
Definition: LArCollisionTimeDecorator.h:47
DerivationFramework::LArCollisionTimeDecorator::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: LArCollisionTimeDecorator.h:43
LArCollisionTime::ncellC
int ncellC() const
get number of cells for time C side
Definition: LArCollisionTime.h:33
LArCollisionTimeDecorator.h
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
python.subdetectors.mmg.names
names
Definition: mmg.py:8
DerivationFramework::LArCollisionTimeDecorator::ktimeA
@ ktimeA
Definition: LArCollisionTimeDecorator.h:48
WriteDecorHandle.h
Handle class for adding a decoration to an object.
test_pyathena.parent
parent
Definition: test_pyathena.py:15
LArCollisionTime::timeC
double timeC() const
time C side
Definition: LArCollisionTime.h:45
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
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?
DerivationFramework::LArCollisionTimeDecorator::kenergyA
@ kenergyA
Definition: LArCollisionTimeDecorator.h:48
DerivationFramework::LArCollisionTimeDecorator::ktimeC
@ ktimeC
Definition: LArCollisionTimeDecorator.h:48
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
DerivationFramework::LArCollisionTimeDecorator::m_intDecorKeys
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_intDecorKeys
Definition: LArCollisionTimeDecorator.h:50
DerivationFramework::LArCollisionTimeDecorator::kNFloatDecor
@ kNFloatDecor
Definition: LArCollisionTimeDecorator.h:48
LArCollisionTime::ncellA
int ncellA() const
get number of cells for time A side
Definition: LArCollisionTime.h:30
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DerivationFramework::LArCollisionTimeDecorator::m_sgName
Gaudi::Property< std::string > m_sgName
Definition: LArCollisionTimeDecorator.h:41
LArCollisionTime::timeA
double timeA() const
time A side
Definition: LArCollisionTime.h:42
AthAlgTool
Definition: AthAlgTool.h:26
DerivationFramework::LArCollisionTimeDecorator::LArCollisionTimeDecorator
LArCollisionTimeDecorator(const std::string &type, const std::string &name, const IInterface *parent)
Definition: LArCollisionTimeDecorator.cxx:21
DerivationFramework::LArCollisionTimeDecorator::kncellA
@ kncellA
Definition: LArCollisionTimeDecorator.h:47