ATLAS Offline Software
PileUpEventInfoWriter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
17 #include "PileUpEventInfoWriter.h"
18 
19 // Event includes
20 #include "EventInfo/EventInfo.h"
21 #include "EventInfo/EventID.h"
22 #include "EventInfo/EventType.h"
25 
26 #include "GaudiKernel/IIncidentSvc.h"
27 
28 // Constructor with parameters:
30  ISvcLocator *pSvcLocator) :
31  AthAlgorithm(name,pSvcLocator)
32 {}
33 
34 // Initialize method:
36 {
37  // Set to be listener for end of event
38  IIncidentSvc* incSvc = nullptr;
39  ATH_CHECK( service("IncidentSvc",incSvc) );
40  long int pri=100;
41  incSvc->addListener( this, "EndEvent", pri);
42 
43  return StatusCode::SUCCESS;
44 }
45 
46 // Execute method:
48 {
49  ATH_MSG_DEBUG("PileUpEventInfoWriter::execute() - do nothing" );
50 
51  // Write a PileupEventInfo
52 
53  const EventInfo * evt = nullptr;
54  ATH_CHECK( evtStore()->retrieve( evt, "McEventInfo" ) );
55  ATH_MSG_DEBUG( "Event ID: ["
56  << evt->event_ID()->run_number() << ","
57  << evt->event_ID()->event_number() << ":"
58  << evt->event_ID()->time_stamp() << "] " );
59  ATH_MSG_DEBUG( "Event type: user type "
60  << evt->event_type()->user_type() );
61 
62  EventID* pOvrID = new EventID(evt->event_ID()->run_number(),
63  evt->event_ID()->event_number());
64  EventType* pOvrEt = new EventType(); //FIXME
65  pOvrEt->set_user_type("Overlaid"); //FIXME
66 
67  PileUpEventInfo* pOverEvent = new PileUpEventInfo(pOvrID, pOvrEt);
68  pOverEvent->addSubEvt(0, PileUpTimeEventIndex::Signal, evt, &*evtStore());
69 
70  PileUpEventInfo* pevt = pOverEvent;
71 
72  ATH_MSG_DEBUG("PileUpEventInfo");
73  ATH_MSG_DEBUG("Event ID: ["
74  << pevt->event_ID()->run_number() << ","
75  << pevt->event_ID()->event_number() << ":"
76  << pevt->event_ID()->time_stamp() << "] ");
77  ATH_MSG_DEBUG("Event type: user type "
78  << pevt->event_type()->user_type());
79 
80  // Get normal event info as a sub-event info
81  ATH_MSG_DEBUG("SubEventInfos");
84  if (it == end) {
85  ATH_MSG_DEBUG("None found" );
86  }
87  for (; it != end; ++it) {
88  const EventInfo* sevt = (*it).pSubEvt;
89  ATH_MSG_DEBUG("Time, index "
90  << (*it).time() << " " << (*it).index());
91  if (sevt) {
92  ATH_MSG_DEBUG("Event ID: ["
93  << sevt->event_ID()->run_number() << ","
94  << sevt->event_ID()->event_number() << ":"
95  << sevt->event_ID()->time_stamp() << "] ");
96  ATH_MSG_DEBUG("Event type: user type "
97  << sevt->event_type()->user_type());
98  }
99  else {
100  ATH_MSG_DEBUG("Subevent is null ptr ");
101  }
102  }
103 
104  ATH_CHECK( evtStore()->record(pOverEvent, "OverlayEvent") );
105  ATH_MSG_DEBUG( "Wrote PileUpEventInfo " );
106 
107  return StatusCode::SUCCESS;
108 }
109 
110 
112 void PileUpEventInfoWriter::handle(const Incident& inc) {
113 
114  ATH_MSG_DEBUG("entering handle(), incidence type " << inc.type()
115  << " from " << inc.source() );
116 
117  // Only call fillIOV for EndEvent incident
118  if (inc.type() != "EndEvent") return;
119 
120  // Get proxy for PileUpEventInfo and remove it
121 
122  // PileupEventInfo as itself
123  const PileUpEventInfo* pevt = nullptr;
124  if (evtStore()->retrieve( pevt ).isFailure() ) {
125  ATH_MSG_ERROR(" Could not get pileup event info" );
126  throw GaudiException("PileUpEventInfoWriter::handle Could not get pileup event info",
127  "PileUpEventInfoWriter", StatusCode::FAILURE);
128  }
129  else {
130  if (evtStore()->remove(pevt).isFailure() ) {
131  ATH_MSG_ERROR(" Could not remove pileup event info" );
132  throw GaudiException("PileUpEventInfoWriter::handle Could not remove pileup event info",
133  "PileUpEventInfoWriter", StatusCode::FAILURE);
134  }
135  else {
136  ATH_MSG_DEBUG("Removed PileUpEventInfo/OverlayEvent: " );
137  }
138  }
139  ATH_MSG_DEBUG("end event handle" );
140 
141 }
142 
143 
144 // Finalize method:
146 {
147  ATH_MSG_DEBUG("PileUpEventInfoWriter::finalize()" );
148  return StatusCode::SUCCESS;
149 }
150 
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:145
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:423
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:35
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:47
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:210
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:195
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:42
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:112
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:220
PileUpEventInfo::endSubEvt
SubEvent::iterator endSubEvt()
Definition: PileUpEventInfo.h:132