ATLAS Offline Software
MergeHijingParsTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MergeHijingParsTool.h"
6 
8  const std::string& name,
9  const IInterface* parent) :
11 {
12 }
13 
15  ATH_CHECK(m_pMergeSvc.retrieve());
17  return StatusCode::SUCCESS;
18 }
19 
20 StatusCode MergeHijingParsTool::prepareEvent(const EventContext& ctx, unsigned int nInputEvents) {
21  ATH_MSG_VERBOSE ( "Calling prepareEvent()" );
22  ATH_MSG_DEBUG( "prepareEvent: there are " << nInputEvents << " subevents in this event.");
23  m_firstSubEvent=true;
25  return StatusCode::SUCCESS;
26 }
27 
29  SubEventIterator bSubEvents,
30  SubEventIterator eSubEvents)
31 {
32  ATH_MSG_VERBOSE ( "processBunchXing()" );
33  if(m_outputObject.isValid()) {
34  ATH_MSG_VERBOSE("Already written out a HijingEventParams for the current signal event.");
35  return StatusCode::SUCCESS;
36  }
37  SubEventIterator iEvt = bSubEvents;
38  for (; iEvt!=eSubEvents; ++iEvt) {
39  const HijingEventParams *hijing_pars(nullptr);
40  if (m_pMergeSvc->retrieveSingleSubEvtData(m_outputObject.name(), hijing_pars,
41  bunchXing, iEvt).isSuccess()) {
42  ATH_CHECK(m_outputObject.record(std::make_unique<HijingEventParams>(hijing_pars->get_np(),
43  hijing_pars->get_nt(),
44  hijing_pars->get_n0(),
45  hijing_pars->get_n01(),
46  hijing_pars->get_n10(),
47  hijing_pars->get_n11(),
48  hijing_pars->get_natt(),
49  hijing_pars->get_jatt(),
50  hijing_pars->get_b(),
51  hijing_pars->get_bphi())));
52  // FIXME Why is there no copy constructor for this class?!
53  // add in setting Psi angles manually.
54  for(int n=1;n<7;++n) {
55  m_outputObject->set_psi(n,hijing_pars->get_psi(n));
56  }
57 
58  if(m_firstSubEvent) {
59  ATH_MSG_DEBUG( "processBunchXing: copied original event HijingEventParams" );
60  }
61  else {
62  ATH_MSG_DEBUG( "processBunchXing: copied background event HijingEventParams" );
63  }
64  return StatusCode::SUCCESS;
65  }
66 
67  if(m_firstSubEvent) {
68  ATH_MSG_VERBOSE("processBunchXing: No HijingEventParams found in the signal eventStore." );
69  m_firstSubEvent=false;
70  }
71  }
72  return StatusCode::SUCCESS;
73 }
74 
75 StatusCode MergeHijingParsTool::mergeEvent(const EventContext& /*ctx*/)
76 {
77  //Double check that something was found.
78  if(!m_outputObject.isValid()) {
79  ATH_MSG_ERROR ( "mergeEvent: No HijingEventParams found in the signal or background eventStores." );
80  return StatusCode::FAILURE;
81  }
82  return StatusCode::SUCCESS;
83 }
84 
85 bool MergeHijingParsTool::toProcess(int bunchXing) const {
86  //We are only interested in the HijingEventParams for the original event
87  //which should be in BC 0 !
88  return (bunchXing==0);
89 }
90 
92  ATH_MSG_VERBOSE ( "processAllSubEvents()" );
94  typedef PileUpMergeSvc::TimedList<HijingEventParams>::type TimedHijingParamsList;
95  TimedHijingParamsList HijingList;
96  const HijingEventParams *hijing_pars(nullptr);
97  if (!(m_pMergeSvc->retrieveSubEvtsData(m_outputObject.name(), HijingList).isSuccess())
98  || HijingList.size()==0) {
99  ATH_MSG_INFO ( " Cannot find HijingEventParams from PileUp service " );
100  return StatusCode::SUCCESS;
101  }
102  ATH_MSG_DEBUG ( " HijingEventParams found from PileUp service " );
103  for (const auto& hijingParams: HijingList) {
104  hijing_pars = hijingParams.second;
105  // create new container for overlayed event
106  ATH_CHECK(m_outputObject.record(std::make_unique<HijingEventParams>(hijing_pars->get_np(),
107  hijing_pars->get_nt(),
108  hijing_pars->get_n0(),
109  hijing_pars->get_n01(),
110  hijing_pars->get_n10(),
111  hijing_pars->get_n11(),
112  hijing_pars->get_natt(),
113  hijing_pars->get_jatt(),
114  hijing_pars->get_b(),
115  hijing_pars->get_bphi())));
116  // FIXME Why is there no copy constructor for this class?!
117  // add in setting Psi angles manually.
118  for(int n=1;n<7;++n) {
119  m_outputObject->set_psi(n,hijing_pars->get_psi(n));
120  }
121  break;
122  }
123  //Double check that something was found.
124  if(!m_outputObject.isValid()) {
125  ATH_MSG_ERROR( "processAllSubEvents: No HijingEventParams found in the signal or background eventStores." );
126  return StatusCode::FAILURE;
127  }
128  return StatusCode::SUCCESS;
129 }
MergeHijingParsTool::processBunchXing
virtual StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
called for each active bunch-crossing to process current SubEvents bunchXing is in ns
Definition: MergeHijingParsTool.cxx:28
HijingEventParams::get_natt
int get_natt() const
Definition: HijingEventParams.h:89
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MergeHijingParsTool::MergeHijingParsTool
MergeHijingParsTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MergeHijingParsTool.cxx:7
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
MergeHijingParsTool::m_pMergeSvc
ServiceHandle< PileUpMergeSvc > m_pMergeSvc
Definition: MergeHijingParsTool.h:51
HijingEventParams::get_np
int get_np() const
Definition: HijingEventParams.h:83
MergeHijingParsTool::m_outputObjectKey
SG::WriteHandleKey< HijingEventParams > m_outputObjectKey
Definition: MergeHijingParsTool.h:52
HijingEventParams::get_psi
float get_psi(int n) const
Definition: HijingEventParams.h:95
MergeHijingParsTool.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
HijingEventParams::get_n10
int get_n10() const
Definition: HijingEventParams.h:87
PileUpMergeSvc::TimedList::type
std::list< value_t > type
type of the collection of timed data object
Definition: PileUpMergeSvc.h:75
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MergeHijingParsTool::initialize
virtual StatusCode initialize() override final
Definition: MergeHijingParsTool.cxx:14
beamspotman.n
n
Definition: beamspotman.py:731
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
HijingEventParams
Definition: HijingEventParams.h:23
HijingEventParams::get_n11
int get_n11() const
Definition: HijingEventParams.h:88
HijingEventParams::set_psi
void set_psi(int ihar, float psi)
Definition: HijingEventParams.h:107
test_pyathena.parent
parent
Definition: test_pyathena.py:15
HijingEventParams::get_n0
int get_n0() const
Definition: HijingEventParams.h:85
MergeHijingParsTool::toProcess
virtual bool toProcess(int bunchXing) const override final
return false if not interested in certain xing times (in ns) implemented by default in PileUpToolBase...
Definition: MergeHijingParsTool.cxx:85
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
HijingEventParams::get_n01
int get_n01() const
Definition: HijingEventParams.h:86
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
MergeHijingParsTool::prepareEvent
virtual StatusCode prepareEvent(const EventContext &ctx, unsigned int nInputEvents) override final
called before the subevts loop.
Definition: MergeHijingParsTool.cxx:20
HijingEventParams::get_bphi
float get_bphi() const
Definition: HijingEventParams.h:92
PileUpToolBase
Definition: PileUpToolBase.h:18
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HijingEventParams::get_b
float get_b() const
Definition: HijingEventParams.h:91
MergeHijingParsTool::m_firstSubEvent
bool m_firstSubEvent
Definition: MergeHijingParsTool.h:54
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition: IPileUpTool.h:22
MergeHijingParsTool::processAllSubEvents
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
Propagate the HijingParsections to the output StoreGate.
Definition: MergeHijingParsTool.cxx:91
MergeHijingParsTool::mergeEvent
virtual StatusCode mergeEvent(const EventContext &ctx) override final
called at the end of the subevts loop.
Definition: MergeHijingParsTool.cxx:75
MergeHijingParsTool::m_outputObject
SG::WriteHandle< HijingEventParams > m_outputObject
Definition: MergeHijingParsTool.h:53
HijingEventParams::get_jatt
int get_jatt() const
Definition: HijingEventParams.h:90
HijingEventParams::get_nt
int get_nt() const
Definition: HijingEventParams.h:84