ATLAS Offline Software
EventInfoMuonCalibStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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("MuonCalibStreamCnvSvc", "EventInfoMuonCalibStreamCnv"),
34  m_dataProvider("MuonCalibStreamDataProviderSvc", "EventInfoMuonCalibStreamCnv")
35 {}
36 
38 
40  ATH_MSG_DEBUG("Initialize EventInfoMuonCalibStreamCnv");
41 
43 
44  ATH_CHECK( m_MuonCalibStreamCnvSvc.retrieve() );
45  ATH_CHECK( m_dataProvider.retrieve() );
46 
47  return StatusCode::SUCCESS;
48 }
49 
50 StatusCode EventInfoMuonCalibStreamCnv::createObj(IOpaqueAddress *pAddr, DataObject *&pObj) {
51 
52  MuonCalibStreamAddress *pRE_Addr;
53  pRE_Addr = dynamic_cast<MuonCalibStreamAddress *>(pAddr);
54  if (!pRE_Addr) {
55  ATH_MSG_ERROR(" Cannot cast to MuonCalibStreamAddress ");
56  return StatusCode::FAILURE;
57  }
58 
59  ATH_MSG_DEBUG(" Creating Objects ");
60 
61  // get CalibEvent
62  const LVL2_MUON_CALIBRATION::CalibEvent *event = m_dataProvider->getEvent();
63  if (!event) {
64  ATH_MSG_ERROR(" Can not get CalibEvent ");
65  return StatusCode::FAILURE;
66  }
67 
68  // Build EventInfo
69  uint64_t eventNumber = event->lvl1_id();
70  int runNumber = event->run_number();
71  float pt = event->pt();
72  // Time Stamp
73  uint64_t timeStamp = event->timestamp();
74  int lb_nr(0);
75 
76  // create xAOD::EventInfo objects directly
77  xAOD::EventInfo* evtInfo = new xAOD::EventInfo();
78  xAOD::EventAuxInfo* evtAuxInfo = new xAOD::EventAuxInfo();
79  evtInfo->setStore(evtAuxInfo);
80 
81  evtInfo->setRunNumber(runNumber);
82  evtInfo->setEventNumber(eventNumber);
83  evtInfo->setLumiBlock(lb_nr);
84  evtInfo->setTimeStamp(timeStamp);
85  evtInfo->setBCID(0);
86  evtInfo->setTimeStampNSOffset(pt);
87  uint32_t eventTypeBitmask = 0;
88  eventTypeBitmask |= xAOD::EventInfo::IS_CALIBRATION;
89  evtInfo->setEventTypeBitmask( eventTypeBitmask );
90 
91  pObj = SG::asStorable(evtInfo);
92 
93  // PRINT TIMESTAMP INFO
94  ATH_MSG_DEBUG("New EventInfo made, run/event/timestamp/pt/LB = "<<runNumber<<" "<<eventNumber<<" "<<timeStamp<<" "<<pt<<" "<<lb_nr);
95 
96  return StatusCode::SUCCESS;
97 } // EventInfoMuonCalibStreamCnv::createObj()
98 
99 // Fill RawEvent object from DataObject
100 // (but really just configure the message service)
101 StatusCode EventInfoMuonCalibStreamCnv::createRep(DataObject * /* pObj */, IOpaqueAddress *& /* pAddr */) {
102  ATH_MSG_DEBUG(" Nothing to be done for EventInfo createRep ");
103  return StatusCode::SUCCESS;
104 }
105 
MuonCalibStreamAddress.h
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:101
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
EventInfoMuonCalibStreamCnv::m_dataProvider
ServiceHandle< IMuonCalibStreamDataProviderSvc > m_dataProvider
Definition: EventInfoMuonCalibStreamCnv.h:35
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:65
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:241
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
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::m_MuonCalibStreamCnvSvc
ServiceHandle< IConversionSvc > m_MuonCalibStreamCnvSvc
Definition: EventInfoMuonCalibStreamCnv.h:34
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:50
xAOD::EventInfo_v1::setRunNumber
void setRunNumber(uint32_t value)
Set the current event's run number.
xAOD::EventInfo_v1::setLumiBlock
void setLumiBlock(uint32_t value)
Set the current event's luminosity block number.
MuonCalibStreamAddress
Definition: MuonCalibStreamAddress.h:14
EventInfoMuonCalibStreamCnv.h