ATLAS Offline Software
Loading...
Searching...
No Matches
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
42 ATH_CHECK(Converter::initialize());
43
45 ATH_CHECK( m_dataProvider.retrieve() );
46
47 return StatusCode::SUCCESS;
48}
49
50StatusCode 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)
101StatusCode EventInfoMuonCalibStreamCnv::createRep(DataObject * /* pObj */, IOpaqueAddress *& /* pAddr */) {
102 ATH_MSG_DEBUG(" Nothing to be done for EventInfo createRep ");
103 return StatusCode::SUCCESS;
104}
105
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
uint32_t CLID
The Class ID type.
convert to and from a SG storable
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
ServiceHandle< IMuonCalibStreamDataProviderSvc > m_dataProvider
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
ServiceHandle< IConversionSvc > m_MuonCalibStreamCnvSvc
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
void setBCID(uint32_t value)
Set the bunch crossing ID of the event.
void setTimeStampNSOffset(uint32_t value)
Set the nanosecond offset wrt. the time stamp.
void setTimeStamp(uint32_t value)
Set the POSIX time of the event.
void setEventNumber(uint64_t value)
Set the current event's event number.
void setEventTypeBitmask(uint32_t value)
Set the event type bitmask.
void setRunNumber(uint32_t value)
Set the current event's run number.
@ IS_CALIBRATION
true: calibration, false: physics
void setLumiBlock(uint32_t value)
Set the current event's luminosity block number.
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
EventInfo_v1 EventInfo
Definition of the latest event info version.
EventAuxInfo_v3 EventAuxInfo
Definition of the latest event auxiliary info version.