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  base_class(t, n, p)
25 {
26 
27 
28  declareProperty( "BCTool", m_bunchCrossingKey );
29 }
30 
32 }
33 
35 {
36 
37  ATH_CHECK(m_eventInfo_key.initialize());
38  ATH_CHECK(m_BCIDDistanceFrontKey.initialize());
39  ATH_CHECK(m_BCIDDistanceTailKey.initialize());
40  ATH_CHECK(m_BCIDGapBeforeTrainKey.initialize());
41  ATH_CHECK(m_BCIDGapAfterTrainKey.initialize());
42  ATH_CHECK(m_BCIDTypeKey.initialize());
43  ATH_CHECK(m_BCIDGapBeforeTrainMinus12Key.initialize());
44  ATH_CHECK(m_BCIDGapAfterTrainMinus12Key.initialize());
45  ATH_CHECK(m_BCIDTypeMinus12Key.initialize());
46 
47  ATH_MSG_VERBOSE("initialize() ..");
48  ATH_CHECK( m_bunchCrossingKey.initialize() );
49  ATH_MSG_INFO("The bunch crossing conditions key being used: " << m_bunchCrossingKey);
50 
51  return StatusCode::SUCCESS;
52 }
53 
55 {
56  ATH_MSG_VERBOSE("finalize() ...");
57  return StatusCode::SUCCESS;
58 }
59 
61 
62  auto eventInfo = SG::makeHandle (m_eventInfo_key);
63  if (!eventInfo.isValid()){
64  ATH_MSG_WARNING("Invalid xAOD::EventInfo datahandle"
65  << m_eventInfo_key.key());
66  return StatusCode::FAILURE;
67  }
68  auto ei = eventInfo.cptr();
69 
70  const EventContext& context = Gaudi::Hive::currentContext();
71  SG::ReadCondHandle<BunchCrossingCondData> bunchCrossingTool (m_bunchCrossingKey, context);
72  ATH_CHECK( bunchCrossingTool.isValid() );
73 
74  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDDistanceFront(m_BCIDDistanceFrontKey);
75  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDDistanceTail(m_BCIDDistanceTailKey);
76  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapBeforeTrain(m_BCIDGapBeforeTrainKey);
77  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapAfterTrain(m_BCIDGapAfterTrainKey);
78  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDType(m_BCIDTypeKey);
79  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapBeforeTrainMinus12(m_BCIDGapBeforeTrainMinus12Key);
80  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDGapAfterTrainMinus12(m_BCIDGapAfterTrainMinus12Key);
81  SG::WriteDecorHandle<xAOD::EventInfo,int> dec_BCIDTypeMinus12(m_BCIDTypeMinus12Key);
82 
83  dec_BCIDDistanceFront(*ei) = bunchCrossingTool->distanceFromFront(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
84  dec_BCIDDistanceTail(*ei) = bunchCrossingTool->distanceFromTail(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
85  dec_BCIDGapBeforeTrain(*ei) = bunchCrossingTool->gapBeforeTrain(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
86  dec_BCIDGapAfterTrain(*ei) = bunchCrossingTool->gapAfterTrain(ei->bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings);
87  dec_BCIDType(*ei) = bunchCrossingTool->bcType(ei->bcid());
88  if (ei->bcid()>=12){
89  dec_BCIDTypeMinus12(*ei) = bunchCrossingTool->bcType(ei->bcid()-12);
90  dec_BCIDGapBeforeTrainMinus12(*ei) = bunchCrossingTool->gapBeforeTrain(ei->bcid()-12, BunchCrossingCondData::BunchDistanceType::BunchCrossings);
91  dec_BCIDGapAfterTrainMinus12(*ei) = bunchCrossingTool->gapAfterTrain(ei->bcid()-12, BunchCrossingCondData::BunchDistanceType::BunchCrossings);
92  }else{
93  dec_BCIDTypeMinus12(*ei) = -1;
94  dec_BCIDGapBeforeTrainMinus12(*ei) = 0;
95  dec_BCIDGapAfterTrainMinus12(*ei) = 0;
96  }
97 
98  return StatusCode::SUCCESS;
99 }
100 
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
DerivationFramework::DistanceInTrainAugmentationTool::finalize
StatusCode finalize()
Definition: DistanceInTrainAugmentationTool.cxx:54
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:167
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:210
BunchCrossingCondData::gapBeforeTrain
int gapBeforeTrain(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Gap before the train this BCID is in.
Definition: BunchCrossingCondData.cxx:130
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:34
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
DerivationFramework::DistanceInTrainAugmentationTool::~DistanceInTrainAugmentationTool
~DistanceInTrainAugmentationTool()
Definition: DistanceInTrainAugmentationTool.cxx:31
beamspotman.n
n
Definition: beamspotman.py:729
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
Definition: DistanceInTrainAugmentationTool.cxx:60
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:38
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:198
DistanceInTrainAugmentationTool.h
DerivationFramework::DistanceInTrainAugmentationTool::m_bunchCrossingKey
SG::ReadCondHandleKey< BunchCrossingCondData > m_bunchCrossingKey
Definition: DistanceInTrainAugmentationTool.h:38