ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
8 const std::string& name,
9 const IInterface* parent) :
10 PileUpToolBase(type, name, parent)
11{
12}
13
15 ATH_CHECK(m_pMergeSvc.retrieve());
16 ATH_CHECK(m_outputObjectKey.initialize());
17 return StatusCode::SUCCESS;
18}
19
20StatusCode 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
75StatusCode 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
85bool 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
91StatusCode MergeHijingParsTool::processAllSubEvents(const EventContext& ctx) {
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition IPileUpTool.h:22
float get_psi(int n) const
float get_bphi() const
virtual bool toProcess(int bunchXing) const override final
return false if not interested in certain xing times (in ns) implemented by default in PileUpToolBase...
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
MergeHijingParsTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
Propagate the HijingParsections to the output StoreGate.
virtual StatusCode mergeEvent(const EventContext &ctx) override final
called at the end of the subevts loop.
SG::WriteHandle< HijingEventParams > m_outputObject
ServiceHandle< PileUpMergeSvc > m_pMergeSvc
virtual StatusCode initialize() override final
SG::WriteHandleKey< HijingEventParams > m_outputObjectKey
virtual StatusCode prepareEvent(const EventContext &ctx, unsigned int nInputEvents) override final
called before the subevts loop.
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
std::list< value_t > type
type of the collection of timed data object