ATLAS Offline Software
EventInfoMuonCalibStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
5 
6 #include <time.h>
7 #include <iostream>
8 #include <memory>
9 
14 #include "GaudiKernel/DataObject.h"
15 #include "GaudiKernel/IRegistry.h"
16 #include "GaudiKernel/StatusCode.h"
17 #include "MuCalDecode/CalibEvent.h"
23 
24 // Update the EventInfo to xAOD::EventInfo 071120223
25 // Instantiation of a static factory class used by clients to create
26 // instances of this service
27 // static CnvFactory<EventInfoMuonCalibStreamCnv> s_factory;
28 // const ICnvFactory& EventInfoMuonCalibStreamCnvFactory = s_factory;
29 
31  Converter(storageType(), classID(), svcloc),
32  AthMessaging(msgSvc(), "EventInfoMuonCalibStreamCnv"),
33  m_MuonCalibStreamCnvSvc(0),
34  m_dataProvider(0)
35 {}
36 
38 
40  ATH_MSG_DEBUG("Initialize EventInfoMuonCalibStreamCnv");
41 
43 
44  // Check MuonCalibStreamCnvSvc
45  IService *svc;
46  ATH_CHECK(serviceLocator()->getService("MuonCalibStreamCnvSvc", svc));
47 
49  if (m_MuonCalibStreamCnvSvc == 0) {
50  ATH_MSG_ERROR(" Cannot cast to MuonCalibStreamCnvSvc ");
51  return StatusCode::FAILURE;
52  }
53 
54  ATH_CHECK(serviceLocator()->getService("MuonCalibStreamDataProviderSvc", svc));
55 
57  if (m_dataProvider == 0) {
58  ATH_MSG_ERROR(" Cannot cast to MuonCalibStreamDataProviderSvc ");
59  return StatusCode::FAILURE;
60  }
61 
62  return StatusCode::SUCCESS;
63 }
64 
65 StatusCode EventInfoMuonCalibStreamCnv::createObj(IOpaqueAddress *pAddr, DataObject *&pObj) {
66 
67  MuonCalibStreamAddress *pRE_Addr;
68  pRE_Addr = dynamic_cast<MuonCalibStreamAddress *>(pAddr);
69  if (!pRE_Addr) {
70  ATH_MSG_ERROR(" Cannot cast to MuonCalibStreamAddress ");
71  return StatusCode::FAILURE;
72  }
73 
74  ATH_MSG_DEBUG(" Creating Objects ");
75 
76  // get CalibEvent
77  const LVL2_MUON_CALIBRATION::CalibEvent *event = m_dataProvider->getEvent();
78  if (!event) {
79  ATH_MSG_ERROR(" Can not get CalibEvent ");
80  return StatusCode::FAILURE;
81  }
82 
83  // Build EventInfo
84  uint64_t eventNumber = event->lvl1_id();
85  int runNumber = event->run_number();
86  float pt = event->pt();
87  // Time Stamp
88  uint64_t timeStamp = event->timestamp();
89  int lb_nr(0);
90 
91  // create xAOD::EventInfo objects directly
92  xAOD::EventInfo* evtInfo = new xAOD::EventInfo();
93  xAOD::EventAuxInfo* evtAuxInfo = new xAOD::EventAuxInfo();
94  evtInfo->setStore(evtAuxInfo);
95 
96  evtInfo->setRunNumber(runNumber);
97  evtInfo->setEventNumber(eventNumber);
98  evtInfo->setLumiBlock(lb_nr);
99  evtInfo->setTimeStamp(timeStamp);
100  evtInfo->setBCID(0);
101  evtInfo->setTimeStampNSOffset(pt);
102  uint32_t eventTypeBitmask = 0;
103  eventTypeBitmask |= xAOD::EventInfo::IS_CALIBRATION;
104  evtInfo->setEventTypeBitmask( eventTypeBitmask );
105 
106  pObj = SG::asStorable(evtInfo);
107 
108  // PRINT TIMESTAMP INFO
109  ATH_MSG_DEBUG("New EventInfo made, run/event/timestamp/pt/LB = "<<runNumber<<" "<<eventNumber<<" "<<timeStamp<<" "<<pt<<" "<<lb_nr);
110 
111  return StatusCode::SUCCESS;
112 } // EventInfoMuonCalibStreamCnv::createObj()
113 
114 // Fill RawEvent object from DataObject
115 // (but really just configure the message service)
116 StatusCode EventInfoMuonCalibStreamCnv::createRep(DataObject * /* pObj */, IOpaqueAddress *& /* pAddr */) {
117  ATH_MSG_DEBUG(" Nothing to be done for EventInfo createRep ");
118  return StatusCode::SUCCESS;
119 }
120 
MuonCalibStreamAddress.h
EventInfoMuonCalibStreamCnv::m_dataProvider
MuonCalibStreamDataProviderSvc * m_dataProvider
Definition: EventInfoMuonCalibStreamCnv.h:43
MuonCalibStreamCnvSvc.h
xAOD::EventInfo_v1::setEventNumber
void setEventNumber(uint64_t value)
Set the current event's event number.
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition: IEventInfoCnvTool.h:17
AthCheckMacros.h
AthMsgStreamMacros.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
StorableConversions.h
convert to and from a SG storable
EventInfoMuonCalibStreamCnv::createRep
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Definition: EventInfoMuonCalibStreamCnv.cxx:116
initialize
void initialize()
Definition: run_EoverP.cxx:894
xAOD::EventAuxInfo_v3
Auxiliary information about the event.
Definition: EventAuxInfo_v3.h:28
xAOD::EventInfo_v1::IS_CALIBRATION
@ IS_CALIBRATION
true: calibration, false: physics
Definition: EventInfo_v1.h:155
test_pyathena.pt
pt
Definition: test_pyathena.py:11
MuonCalibStreamDataProviderSvc
Definition: MuonCalibStreamDataProviderSvc.h:16
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
EventInfoMuonCalibStreamCnv::m_MuonCalibStreamCnvSvc
MuonCalibStreamCnvSvc * m_MuonCalibStreamCnvSvc
Definition: EventInfoMuonCalibStreamCnv.h:42
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::EventInfo_v1::setEventTypeBitmask
void setEventTypeBitmask(uint32_t value)
Set the event type bitmask.
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
SG::AuxElement::setStore
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
Definition: AuxElement.cxx:221
MuonCalibStreamDataProviderSvc::getEvent
virtual const LVL2_MUON_CALIBRATION::CalibEvent * getEvent()
Definition: MuonCalibStreamDataProviderSvc.cxx:75
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonCalibStreamDataProviderSvc.h
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
EventInfoMuonCalibStreamCnv::initialize
virtual StatusCode initialize()
Definition: EventInfoMuonCalibStreamCnv.cxx:39
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
EventInfoMuonCalibStreamCnv::EventInfoMuonCalibStreamCnv
EventInfoMuonCalibStreamCnv(ISvcLocator *svcloc)
Definition: EventInfoMuonCalibStreamCnv.cxx:30
xAOD::EventInfo_v1::setTimeStamp
void setTimeStamp(uint32_t value)
Set the POSIX time of the event.
MuonCalibStreamInputSvc.h
xAOD::EventInfo_v1::setBCID
void setBCID(uint32_t value)
Set the bunch crossing ID of the event.
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
EventInfoMuonCalibStreamCnv::classID
static const CLID & classID()
Definition: EventInfoMuonCalibStreamCnv.cxx:37
xAOD::EventAuxInfo
EventAuxInfo_v3 EventAuxInfo
Definition of the latest event auxiliary info version.
Definition: EventAuxInfo.h:15
EventAuxInfo.h
Converter
Definition: Converter.h:27
EventInfo.h
xAOD::timeStamp
setEventNumber timeStamp
Definition: EventInfo_v1.cxx:128
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
xAOD::EventInfo_v1::setTimeStampNSOffset
void setTimeStampNSOffset(uint32_t value)
Set the nanosecond offset wrt. the time stamp.
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
EventInfoMuonCalibStreamCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Definition: EventInfoMuonCalibStreamCnv.cxx:65
xAOD::EventInfo_v1::setRunNumber
void setRunNumber(uint32_t value)
Set the current event's run number.
MuonCalibStreamCnvSvc
Definition: MuonCalibStreamCnvSvc.h:10
xAOD::EventInfo_v1::setLumiBlock
void setLumiBlock(uint32_t value)
Set the current event's luminosity block number.
MuonCalibStreamAddress
Definition: MuonCalibStreamAddress.h:14
EventInfoMuonCalibStreamCnv.h