ATLAS Offline Software
PileUpEventInfoWriter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
15 #include "PileUpEventInfoWriter.h"
16 
17 // Event includes
18 #include "EventInfo/EventInfo.h"
19 #include "EventInfo/EventID.h"
20 #include "EventInfo/EventType.h"
23 
24 #include "GaudiKernel/IIncidentSvc.h"
25 
26 // Constructor with parameters:
28  ISvcLocator *pSvcLocator) :
29  AthAlgorithm(name,pSvcLocator)
30 {}
31 
32 // Initialize method:
34 {
35  // Set to be listener for end of event
36  SmartIF<IIncidentSvc> incSvc{Gaudi::svcLocator()->service("IncidentSvc")};
37  ATH_CHECK(incSvc.isValid());
38  long int pri=100;
39  incSvc->addListener( this, "EndEvent", pri);
40 
41  return StatusCode::SUCCESS;
42 }
43 
44 // Execute method:
46 {
47  ATH_MSG_DEBUG("PileUpEventInfoWriter::execute() - do nothing" );
48 
49  // Write a PileupEventInfo
50 
51  const EventInfo * evt = nullptr;
52  ATH_CHECK( evtStore()->retrieve( evt, "McEventInfo" ) );
53  ATH_MSG_DEBUG( "Event ID: ["
54  << evt->event_ID()->run_number() << ","
55  << evt->event_ID()->event_number() << ":"
56  << evt->event_ID()->time_stamp() << "] " );
57  ATH_MSG_DEBUG( "Event type: user type "
58  << evt->event_type()->user_type() );
59 
60  EventID* pOvrID = new EventID(evt->event_ID()->run_number(),
61  evt->event_ID()->event_number());
62  EventType* pOvrEt = new EventType(); //FIXME
63  pOvrEt->set_user_type("Overlaid"); //FIXME
64 
65  PileUpEventInfo* pOverEvent = new PileUpEventInfo(pOvrID, pOvrEt);
66  pOverEvent->addSubEvt(0, PileUpTimeEventIndex::Signal, evt, &*evtStore());
67 
68  PileUpEventInfo* pevt = pOverEvent;
69 
70  ATH_MSG_DEBUG("PileUpEventInfo");
71  ATH_MSG_DEBUG("Event ID: ["
72  << pevt->event_ID()->run_number() << ","
73  << pevt->event_ID()->event_number() << ":"
74  << pevt->event_ID()->time_stamp() << "] ");
75  ATH_MSG_DEBUG("Event type: user type "
76  << pevt->event_type()->user_type());
77 
78  // Get normal event info as a sub-event info
79  ATH_MSG_DEBUG("SubEventInfos");
82  if (it == end) {
83  ATH_MSG_DEBUG("None found" );
84  }
85  for (; it != end; ++it) {
86  const EventInfo* sevt = (*it).pSubEvt;
87  ATH_MSG_DEBUG("Time, index "
88  << (*it).time() << " " << (*it).index());
89  if (sevt) {
90  ATH_MSG_DEBUG("Event ID: ["
91  << sevt->event_ID()->run_number() << ","
92  << sevt->event_ID()->event_number() << ":"
93  << sevt->event_ID()->time_stamp() << "] ");
94  ATH_MSG_DEBUG("Event type: user type "
95  << sevt->event_type()->user_type());
96  }
97  else {
98  ATH_MSG_DEBUG("Subevent is null ptr ");
99  }
100  }
101 
102  ATH_CHECK( evtStore()->record(pOverEvent, "OverlayEvent") );
103  ATH_MSG_DEBUG( "Wrote PileUpEventInfo " );
104 
105  return StatusCode::SUCCESS;
106 }
107 
108 
110 void PileUpEventInfoWriter::handle(const Incident& inc) {
111 
112  ATH_MSG_DEBUG("entering handle(), incidence type " << inc.type()
113  << " from " << inc.source() );
114 
115  // Only call fillIOV for EndEvent incident
116  if (inc.type() != "EndEvent") return;
117 
118  // Get proxy for PileUpEventInfo and remove it
119 
120  // PileupEventInfo as itself
121  const PileUpEventInfo* pevt = nullptr;
122  if (evtStore()->retrieve( pevt ).isFailure() ) {
123  ATH_MSG_ERROR(" Could not get pileup event info" );
124  throw GaudiException("PileUpEventInfoWriter::handle Could not get pileup event info",
125  "PileUpEventInfoWriter", StatusCode::FAILURE);
126  }
127  else {
128  if (evtStore()->remove(pevt).isFailure() ) {
129  ATH_MSG_ERROR(" Could not remove pileup event info" );
130  throw GaudiException("PileUpEventInfoWriter::handle Could not remove pileup event info",
131  "PileUpEventInfoWriter", StatusCode::FAILURE);
132  }
133  else {
134  ATH_MSG_DEBUG("Removed PileUpEventInfo/OverlayEvent: " );
135  }
136  }
137  ATH_MSG_DEBUG("end event handle" );
138 
139 }
140 
141 
142 // Finalize method:
144 {
145  ATH_MSG_DEBUG("PileUpEventInfoWriter::finalize()" );
146  return StatusCode::SUCCESS;
147 }
148 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
EventType::user_type
std::string user_type(void) const
Access to user type.
Definition: EventType.cxx:94
PileUpEventInfo.h
This class provides information about an overlaid event. It extends EventInfo with a list of sub-evts...
PileUpEventInfoWriter::finalize
virtual StatusCode finalize()
Algorithm finalize at end of job.
Definition: PileUpEventInfoWriter.cxx:143
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
PileUpEventInfoWriter::PileUpEventInfoWriter
PileUpEventInfoWriter()
Avoid use of default constructor.
skel.it
it
Definition: skel.GENtoEVGEN.py:396
EventType.h
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
PileUpTimeEventIndex.h
PileUpEventInfoWriter::initialize
virtual StatusCode initialize()
Algorithm initialize at begin of job.
Definition: PileUpEventInfoWriter.cxx:33
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
PileUpEventInfoWriter::execute
virtual StatusCode execute()
Algorithm execute once per event.
Definition: PileUpEventInfoWriter.cxx:45
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
PileUpEventInfo::beginSubEvt
SubEvent::iterator beginSubEvt()
Definition: PileUpEventInfo.h:131
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PileUpEventInfo
Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Old PileUpEventInfo
Definition: EventTPCnv.cxx:87
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
EventInfo::event_ID
EventID * event_ID()
the unique identification of the event.
Definition: EventInfo/EventInfo/EventInfo.h:224
PileUpTimeEventIndex::Signal
@ Signal
Definition: PileUpTimeEventIndex.h:16
PileUpEventInfo::addSubEvt
void addSubEvt(time_type t, PileUpTimeEventIndex::PileUpType puType, const EventInfo *pse, StoreGateSvc *psg)
setter for the subEvt collection t=0(ns) for the original event
Definition: PileUpEventInfo.h:104
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:43
PileUpEventInfoWriter.h
Test reading of PileUpEventInfo.
PileUpEventInfo
This class provides information about an overlaid event. It extends EventInfo with a list of sub-evts...
Definition: PileUpEventInfo.h:37
EventType::set_user_type
void set_user_type(const std::string &user_type)
Add user (string) type.
Definition: EventType.cxx:57
PileUpEventInfo::SubEvent::const_iterator
std::list< SubEvent >::const_iterator const_iterator
Definition: PileUpEventInfo.h:97
PileUpEventInfoWriter::handle
void handle(const Incident &incident)
incident service handle for EndEvent
Definition: PileUpEventInfoWriter.cxx:110
EventID
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventID.h:35
EventInfo::event_type
EventType * event_type()
the type of the event, e.g. simulation, testbeam, etc
Definition: EventInfo/EventInfo/EventInfo.h:234
PileUpEventInfo::endSubEvt
SubEvent::iterator endSubEvt()
Definition: PileUpEventInfo.h:132