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) :
24  base_class(type,name,parent)
25  {
26  }
27 
29  {
30 
31  if (m_sgName.empty()) {
32  ATH_MSG_WARNING("No decoration prefix name provided for the output of LArCollisionTimeDecorator!");
33  }
34 
35  if (m_eventInfoKey.key().empty()) {
36  ATH_MSG_ERROR("No EventInfo collection provided for LArCollisionTimeDecorator!");
37  return StatusCode::FAILURE;
38  }
41  {
42  std::vector<std::string> names;
43  names.resize(kNIntDecor);
44  names[kncellA]="ncellA";
45  names[kncellC]="ncellC";
46  createDecoratorKeys(*this,m_eventInfoKey,"" /* common prefix */,names, m_intDecorKeys);
47  }
48 
49  {
50  std::vector<std::string> names;
51  names.resize(kNFloatDecor);
52  names[kenergyA] = "energyA";
53  names[kenergyC] = "energyC";
54  names[ktimeA] = "timeA";
55  names[ktimeC] = "timeC";
56  createDecoratorKeys(*this,m_eventInfoKey,"" /* common prefix */,names, m_floatDecorKeys);
57  }
58 
59  return StatusCode::SUCCESS;
60  }
61 
63  {
64  return StatusCode::SUCCESS;
65  }
66 
68  {
69  ATH_MSG_DEBUG("Adding LAr time info to EventInfo");
70  const EventContext& ctx = Gaudi::Hive::currentContext();
72  CHECK( eventInfo.isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE);
73 
75 
76  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,int> > int_decor_handles(createDecorators<xAOD::EventInfo,int>(m_intDecorKeys,ctx));
77  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,float> > float_decor_handles(createDecorators<xAOD::EventInfo,float>(m_floatDecorKeys,ctx));
78  assert( int_decor_handles.size() == kNIntDecor);
79  assert( float_decor_handles.size() == kNFloatDecor);
80  if (tps.isValid()) {
81  int_decor_handles[kncellA](*eventInfo) = tps->ncellA();
82  int_decor_handles[kncellC](*eventInfo) = tps->ncellC();
83  float_decor_handles[kenergyA](*eventInfo) = tps->energyA();
84  float_decor_handles[kenergyC](*eventInfo) = tps->energyC();
85  float_decor_handles[ktimeA](*eventInfo) = tps->timeA();
86  float_decor_handles[ktimeC](*eventInfo) = tps->timeC();
87  float LArECtimeDiff = tps->timeA()-tps->timeC();
88  ATH_MSG_DEBUG("Decorating LAr time info, LArECTimeDiff = " << LArECtimeDiff);
89  }
90  else {
91  ATH_MSG_WARNING("Missing LArCollisionTime information.");
92  }
93 
94  return StatusCode::SUCCESS;
95  }
96 
97 }
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:62
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
Definition: LArCollisionTimeDecorator.cxx:67
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::LArCollisionTimeDecorator::initialize
StatusCode initialize()
Definition: LArCollisionTimeDecorator.cxx:28
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
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
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:240
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
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
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