ATLAS Offline Software
DistanceInTrainAugmentationTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Author: Chris Young (christopher.young@cern.ch)
8 // This code is designed to augment EventInfo with a variety
9 // of variables to describe where in the bunch train structure
10 // a given event lies. Care is taken to ensure that new trains
11 // are not defined at the abort gap or 4 non-colliding crossings
12 // in the 8b4e scheme.
15 
17 
18 
20 {
21 
31 
32  ATH_MSG_VERBOSE("initialize() ..");
34  ATH_MSG_INFO("The bunch crossing conditions key being used: " << m_bunchCrossingKey);
35 
36  return StatusCode::SUCCESS;
37 }
38 
39 
41 
42  auto eventInfo = SG::makeHandle (m_eventInfo_key, ctx);
43  if (!eventInfo.isValid()){
44  ATH_MSG_WARNING("Invalid xAOD::EventInfo datahandle"
45  << m_eventInfo_key.key());
46  return StatusCode::FAILURE;
47  }
48  auto ei = eventInfo.cptr();
49 
50  SG::ReadCondHandle<BunchCrossingCondData> bunchCrossingTool (m_bunchCrossingKey, ctx);
51  ATH_CHECK( bunchCrossingTool.isValid() );
52 
53  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDDistanceFront(m_BCIDDistanceFrontKey, ctx);
54  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDDistanceTail(m_BCIDDistanceTailKey, ctx);
55  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapBeforeTrain(m_BCIDGapBeforeTrainKey, ctx);
56  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapAfterTrain(m_BCIDGapAfterTrainKey, ctx);
57  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDType(m_BCIDTypeKey, ctx);
58  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapBeforeTrainMinus12(m_BCIDGapBeforeTrainMinus12Key, ctx);
59  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapAfterTrainMinus12(m_BCIDGapAfterTrainMinus12Key, ctx);
60  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDTypeMinus12(m_BCIDTypeMinus12Key, ctx);
61 
62  dec_BCIDDistanceFront(*ei) = bunchCrossingTool->distanceFromFront(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
63  dec_BCIDDistanceTail(*ei) = bunchCrossingTool->distanceFromTail(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
64  dec_BCIDGapBeforeTrain(*ei) = bunchCrossingTool->gapBeforeTrain(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
65  dec_BCIDGapAfterTrain(*ei) = bunchCrossingTool->gapAfterTrain(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
66  dec_BCIDType(*ei) = bunchCrossingTool->bcType(ei->bcid());
67  if (ei->bcid()>=12){
68  dec_BCIDTypeMinus12(*ei) = bunchCrossingTool->bcType(ei->bcid()-12);
69  dec_BCIDGapBeforeTrainMinus12(*ei) = bunchCrossingTool->gapBeforeTrain(ei->bcid()-12, BunchCrossingCondData::BunchDistanceType::BunchCrossings);
70  dec_BCIDGapAfterTrainMinus12(*ei) = bunchCrossingTool->gapAfterTrain(ei->bcid()-12, BunchCrossingCondData::BunchDistanceType::BunchCrossings);
71  }else{
72  dec_BCIDTypeMinus12(*ei) = -1;
73  dec_BCIDGapBeforeTrainMinus12(*ei) = 0;
74  dec_BCIDGapAfterTrainMinus12(*ei) = 0;
75  }
76 
77  return StatusCode::SUCCESS;
78 }
BunchCrossingCondData::distanceFromTail
int distanceFromTail(const bcid_type bcid, const BunchDistanceType type=NanoSec) const
The distance of the specific bunch crossing from the tail of the train.
Definition: BunchCrossingCondData.cxx:63
SG::ReadCondHandle
Definition: ReadCondHandle.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
BunchCrossingCondData::gapAfterTrain
int gapAfterTrain(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Gap after the train this BCID is in.
Definition: BunchCrossingCondData.cxx:167
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
DerivationFramework::DistanceInTrainAugmentationTool::m_BCIDGapBeforeTrainKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_BCIDGapBeforeTrainKey
Definition: DistanceInTrainAugmentationTool.h:40
DerivationFramework::DistanceInTrainAugmentationTool::m_BCIDGapAfterTrainKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_BCIDGapAfterTrainKey
Definition: DistanceInTrainAugmentationTool.h:41
BunchCrossingCondData::gapBeforeTrain
int gapBeforeTrain(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Gap before the train this BCID is in.
Definition: BunchCrossingCondData.cxx:130
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
DerivationFramework::DistanceInTrainAugmentationTool::m_BCIDGapAfterTrainMinus12Key
SG::WriteDecorHandleKey< xAOD::EventInfo > m_BCIDGapAfterTrainMinus12Key
Definition: DistanceInTrainAugmentationTool.h:44
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
DerivationFramework::DistanceInTrainAugmentationTool::m_BCIDDistanceTailKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_BCIDDistanceTailKey
Definition: DistanceInTrainAugmentationTool.h:39
BunchCrossingCondData::distanceFromFront
int distanceFromFront(const bcid_type bcid, const BunchDistanceType type=NanoSec) const
The distance of the specific bunch crossing from the front of the train.
Definition: BunchCrossingCondData.cxx:38
DerivationFramework::DistanceInTrainAugmentationTool::m_BCIDTypeMinus12Key
SG::WriteDecorHandleKey< xAOD::EventInfo > m_BCIDTypeMinus12Key
Definition: DistanceInTrainAugmentationTool.h:45
DerivationFramework::DistanceInTrainAugmentationTool::m_eventInfo_key
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo_key
Definition: DistanceInTrainAugmentationTool.h:36
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
DerivationFramework::DistanceInTrainAugmentationTool::m_BCIDDistanceFrontKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_BCIDDistanceFrontKey
Definition: DistanceInTrainAugmentationTool.h:38
DerivationFramework::DistanceInTrainAugmentationTool::m_BCIDTypeKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_BCIDTypeKey
Definition: DistanceInTrainAugmentationTool.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
BunchCrossingCondData::bcType
BunchCrossingType bcType(const bcid_type bcid) const
Convenience function for the type of the specific bunch crossing.
Definition: BunchCrossingCondData.cxx:198
DerivationFramework::DistanceInTrainAugmentationTool::initialize
virtual StatusCode initialize() override final
Definition: DistanceInTrainAugmentationTool.cxx:19
DerivationFramework::DistanceInTrainAugmentationTool::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition: DistanceInTrainAugmentationTool.cxx:40
DerivationFramework::DistanceInTrainAugmentationTool::m_BCIDGapBeforeTrainMinus12Key
SG::WriteDecorHandleKey< xAOD::EventInfo > m_BCIDGapBeforeTrainMinus12Key
Definition: DistanceInTrainAugmentationTool.h:43
DistanceInTrainAugmentationTool.h
DerivationFramework::DistanceInTrainAugmentationTool::m_bunchCrossingKey
SG::ReadCondHandleKey< BunchCrossingCondData > m_bunchCrossingKey
Definition: DistanceInTrainAugmentationTool.h:34