ATLAS Offline Software
DistanceInTrainAugmentationTool.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 // DistanceInTrainAugmentationTool.cxx, (c) ATLAS Detector software
8 // Author: Chris Young (christopher.young@cern.ch)
10 // This code is designed to augment EventInfo with a variety
11 // of variables to describe where in the bunch train structure
12 // a given event lies. Care is taken to ensure that new trains
13 // are not defined at the abort gap or 4 non-colliding crossings
14 // in the 8b4e scheme.
17 
19 
20 
22  const std::string& n,
23  const IInterface* p) :
24  AthAlgTool(t, n, p)
25 {
26 
27  declareInterface<DerivationFramework::IAugmentationTool>(this);
28 
30 }
31 
33 }
34 
36 {
37 
38  ATH_CHECK(m_eventInfo_key.initialize());
39  ATH_CHECK(m_BCIDDistanceFrontKey.initialize());
40  ATH_CHECK(m_BCIDDistanceTailKey.initialize());
41  ATH_CHECK(m_BCIDGapBeforeTrainKey.initialize());
42  ATH_CHECK(m_BCIDGapAfterTrainKey.initialize());
43  ATH_CHECK(m_BCIDTypeKey.initialize());
44  ATH_CHECK(m_BCIDGapBeforeTrainMinus12Key.initialize());
45  ATH_CHECK(m_BCIDGapAfterTrainMinus12Key.initialize());
46  ATH_CHECK(m_BCIDTypeMinus12Key.initialize());
47 
48  ATH_MSG_VERBOSE("initialize() ..");
49  ATH_CHECK( m_bunchCrossingKey.initialize() );
50  ATH_MSG_INFO("The bunch crossing conditions key being used: " << m_bunchCrossingKey);
51 
52  return StatusCode::SUCCESS;
53 }
54 
56 {
57  ATH_MSG_VERBOSE("finalize() ...");
58  return StatusCode::SUCCESS;
59 }
60 
62 
63  auto eventInfo = SG::makeHandle (m_eventInfo_key);
64  if (!eventInfo.isValid()){
65  ATH_MSG_WARNING("Invalid xAOD::EventInfo datahandle"
66  << m_eventInfo_key.key());
67  return StatusCode::FAILURE;
68  }
69  auto ei = eventInfo.cptr();
70 
71  const EventContext& context = Gaudi::Hive::currentContext();
72  SG::ReadCondHandle<BunchCrossingCondData> bunchCrossingTool (m_bunchCrossingKey, context);
73  ATH_CHECK( bunchCrossingTool.isValid() );
74 
75  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDDistanceFront(m_BCIDDistanceFrontKey);
76  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDDistanceTail(m_BCIDDistanceTailKey);
77  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapBeforeTrain(m_BCIDGapBeforeTrainKey);
78  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapAfterTrain(m_BCIDGapAfterTrainKey);
79  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDType(m_BCIDTypeKey);
80  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapBeforeTrainMinus12(m_BCIDGapBeforeTrainMinus12Key);
81  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapAfterTrainMinus12(m_BCIDGapAfterTrainMinus12Key);
82  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDTypeMinus12(m_BCIDTypeMinus12Key);
83 
84  dec_BCIDDistanceFront(*ei) = bunchCrossingTool->distanceFromFront(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
85  dec_BCIDDistanceTail(*ei) = bunchCrossingTool->distanceFromTail(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
86  dec_BCIDGapBeforeTrain(*ei) = bunchCrossingTool->gapBeforeTrain(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
87  dec_BCIDGapAfterTrain(*ei) = bunchCrossingTool->gapAfterTrain(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
88  dec_BCIDType(*ei) = bunchCrossingTool->bcType(ei->bcid());
89  if (ei->bcid()>=12){
90  dec_BCIDTypeMinus12(*ei) = bunchCrossingTool->bcType(ei->bcid()-12);
91  dec_BCIDGapBeforeTrainMinus12(*ei) = bunchCrossingTool->gapBeforeTrain(ei->bcid()-12, BunchCrossingCondData::BunchDistanceType::BunchCrossings);
92  dec_BCIDGapAfterTrainMinus12(*ei) = bunchCrossingTool->gapAfterTrain(ei->bcid()-12, BunchCrossingCondData::BunchDistanceType::BunchCrossings);
93  }else{
94  dec_BCIDTypeMinus12(*ei) = -1;
95  dec_BCIDGapBeforeTrainMinus12(*ei) = 0;
96  dec_BCIDGapAfterTrainMinus12(*ei) = 0;
97  }
98 
99  return StatusCode::SUCCESS;
100 }
101 
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:60
DerivationFramework::DistanceInTrainAugmentationTool::finalize
StatusCode finalize()
Definition: DistanceInTrainAugmentationTool.cxx:55
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
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:164
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
BunchCrossingCondData::gapBeforeTrain
int gapBeforeTrain(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Gap before the train this BCID is in.
Definition: BunchCrossingCondData.cxx:127
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::DistanceInTrainAugmentationTool::initialize
StatusCode initialize()
Definition: DistanceInTrainAugmentationTool.cxx:35
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
DerivationFramework::DistanceInTrainAugmentationTool::~DistanceInTrainAugmentationTool
~DistanceInTrainAugmentationTool()
Definition: DistanceInTrainAugmentationTool.cxx:32
beamspotman.n
n
Definition: beamspotman.py:731
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::addBranches
virtual StatusCode addBranches() const
Pass the thinning service
Definition: DistanceInTrainAugmentationTool.cxx:61
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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:35
DerivationFramework::DistanceInTrainAugmentationTool::DistanceInTrainAugmentationTool
DistanceInTrainAugmentationTool(const std::string &t, const std::string &n, const IInterface *p)
Definition: DistanceInTrainAugmentationTool.cxx:21
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:195
AthAlgTool
Definition: AthAlgTool.h:26
DistanceInTrainAugmentationTool.h
DerivationFramework::DistanceInTrainAugmentationTool::m_bunchCrossingKey
SG::ReadCondHandleKey< BunchCrossingCondData > m_bunchCrossingKey
Definition: DistanceInTrainAugmentationTool.h:38