ATLAS Offline Software
Loading...
Searching...
No Matches
EventInfoCnv_p1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "EventInfo/EventInfo.h"
7#include "EventInfo/EventID.h"
9
14#include <math.h>
15
16static const EventIDCnv_p1 idConv;
19
20
21void EventInfoCnv_p1::transToPers(const EventInfo* trans, EventInfo_p1* pers, MsgStream &log) const {
22 idConv.transToPers(trans->event_ID(), &pers->m_event_ID, log);
23 typeConv.transToPers(trans->event_type(), &pers->m_event_type, log);
24 if( trans->trigger_info() ) {
25 pers->m_trigger_info = trigInfoCnv.createPersistentConst(trans->trigger_info(), log);
26 }
27}
28
29void EventInfoCnv_p1::persToTrans(const EventInfo_p1* pers, EventInfo* trans, MsgStream &log) const {
30 trans->setEventID (idConv.createTransientConst(&pers->m_event_ID, log));
31 EventType* event_type = typeConv.createTransientConst(&pers->m_event_type, log);
32 if( pers->m_trigger_info) {
33 trans->setTriggerInfo (trigInfoCnv.createTransientConst(pers->m_trigger_info, log));
34
35 // Fill MC event weight in transient EventType from persistent
36 // TriggerInfo. This is only needed for MC events: if the
37 // weight is zero, and TriggerInfo exists - was stored at end
38 // of eventFilterInfo
39
40 static const double MIN_WEIGHT = -1.0e+6;
41 static const double MAX_WEIGHT = +1.0e+6;
42 static const double BIN_WIDTH( (MAX_WEIGHT - MIN_WEIGHT) /
43 std::numeric_limits<unsigned int>::max() );
44 if (event_type->mc_event_weight() == 0 &&
45 trans->trigger_info()->eventFilterInfo().size()) {
46 double weight = (MIN_WEIGHT + BIN_WIDTH * (double(trans->trigger_info()->eventFilterInfo().back()) + 0.5));
47 if (fabs(weight - 0.999775) < 0.0001) weight = 1.0;
48 else if (fabs(weight + 0.999775) < 0.0001 ) weight = -1.0;
49 event_type->set_mc_event_weight(weight);
50 //trans->m_event_type->m_mc_event_weight = trans->m_trigger_info->eventFilterInfo().back();
51 }
52 }
53 trans->setEventType (event_type);
54}
55
56// work around the default constructor of EventInfo allocating memory
57EventInfo* EventInfoCnv_p1::createTransientConst( const EventInfo_p1* persObj, MsgStream &log) const {
58 std::unique_ptr<EventInfo> trans( new EventInfo(0,0,0) );
59 persToTrans(persObj, trans.get(), log);
60 return(trans.release());
61}
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
static const TriggerInfoCnv_p1 trigInfoCnv
static const EventTypeCnv_p1 typeConv
static const EventIDCnv_p1 idConv
This class provides general information about an event.
This class contains trigger related information.
virtual void transToPers(const EventInfo *transObj, EventInfo_p1 *persObj, MsgStream &log) const override
virtual void persToTrans(const EventInfo_p1 *persObj, EventInfo *transObj, MsgStream &log) const override
virtual EventInfo * createTransientConst(const EventInfo_p1 *persObj, MsgStream &log) const override
EventType_p1 m_event_type
EventID_p1 m_event_ID
TriggerInfo_p1 * m_trigger_info
void setEventID(owner< EventID * > pid)
Definition EventInfo.cxx:82
void setEventType(owner< EventType * >)
Definition EventInfo.cxx:90
void setTriggerInfo(owner< TriggerInfo * > pTrig)
Add TriggerInfo to existing object.
Definition EventInfo.cxx:98
EventID * event_ID()
the unique identification of the event.
TriggerInfo * trigger_info()
trigger information (ptr may be NULL)
EventType * event_type()
the type of the event, e.g. simulation, testbeam, etc
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition EventType.h:92
float mc_event_weight(unsigned int iweight=0) const
Access to MC weight.
void set_mc_event_weight(float weight, unsigned int iweight=0, unsigned int nWeightsMax=0)
Add in MC weight. For more than 1 weight, add with iweight > 0.
const std::vector< number_type > & eventFilterInfo() const
get event filter trigger info