ATLAS Offline Software
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"
6 #include "EventInfo/EventType.h"
7 #include "EventInfo/EventID.h"
9 
14 #include <math.h>
15 
16 static const EventIDCnv_p1 idConv;
17 static const EventTypeCnv_p1 typeConv;
18 static const TriggerInfoCnv_p1 trigInfoCnv;
19 
20 
21 void 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 
29 void 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) /
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
57 EventInfo* 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 }
EventIDCnv_p1::transToPers
virtual void transToPers(const EventID *transObj, EventID_p1 *persObj, MsgStream &log) const override
Definition: EventIDCnv_p1.cxx:8
EventInfo::setEventID
void setEventID(owner< EventID * > pid)
Definition: EventInfo.cxx:82
EventInfo::setEventType
void setEventType(owner< EventType * >)
Definition: EventInfo.cxx:90
max
#define max(a, b)
Definition: cfImp.cxx:41
EventInfo_p1
Definition: EventInfo_p1.h:18
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
EventInfo
EventInfo
Definition: EventTPCnv.cxx:47
EventTypeCnv_p1::createTransientConst
virtual EventType * createTransientConst(const EventType_p1 *persObj, MsgStream &log) const override
Definition: EventTypeCnv_p1.cxx:27
TriggerInfo.h
This class contains trigger related information.
EventType.h
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
EventIDCnv_p1::createTransientConst
virtual EventID * createTransientConst(const EventID_p1 *persObj, MsgStream &log) const override
Definition: EventIDCnv_p1.cxx:34
EventTypeCnv_p1::transToPers
virtual void transToPers(const EventType *transObj, EventType_p1 *persObj, MsgStream &log) const override
Definition: EventTypeCnv_p1.cxx:8
EventType::mc_event_weight
float mc_event_weight(unsigned int iweight=0) const
Access to MC weight.
Definition: EventType.cxx:175
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
EventTypeCnv_p1
Definition: EventTypeCnv_p1.h:13
EventInfo::setTriggerInfo
void setTriggerInfo(owner< TriggerInfo * > pTrig)
Add TriggerInfo to existing object.
Definition: EventInfo.cxx:98
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
EventInfoCnv_p1::createTransientConst
virtual EventInfo * createTransientConst(const EventInfo_p1 *persObj, MsgStream &log) const override
Definition: EventInfoCnv_p1.cxx:57
EventIDCnv_p1
Definition: EventIDCnv_p1.h:14
TriggerInfoCnv_p1.h
EventInfo::event_ID
EventID * event_ID()
the unique identification of the event.
Definition: EventInfo/EventInfo/EventInfo.h:224
EventInfo_p1::m_event_type
EventType_p1 m_event_type
Definition: EventInfo_p1.h:30
TriggerInfoCnv_p1::createPersistentConst
virtual TriggerInfo_p1 * createPersistentConst(const TriggerInfo *transObj, MsgStream &log) const override
Definition: TriggerInfoCnv_p1.cxx:42
EventInfoCnv_p1.h
EventInfoCnv_p1::transToPers
virtual void transToPers(const EventInfo *transObj, EventInfo_p1 *persObj, MsgStream &log) const override
Definition: EventInfoCnv_p1.cxx:21
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
TriggerInfoCnv_p1::createTransientConst
virtual TriggerInfo * createTransientConst(const TriggerInfo_p1 *persObj, MsgStream &log) const override
Definition: TriggerInfoCnv_p1.cxx:35
EventInfo_p1::m_event_ID
EventID_p1 m_event_ID
Definition: EventInfo_p1.h:29
EventIDCnv_p1.h
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:43
EventType::set_mc_event_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.
Definition: EventType.cxx:207
TriggerInfo::eventFilterInfo
const std::vector< number_type > & eventFilterInfo() const
get event filter trigger info
Definition: TriggerInfo.cxx:153
EventTypeCnv_p1.h
TriggerInfoCnv_p1
Definition: TriggerInfoCnv_p1.h:13
EventInfo::trigger_info
TriggerInfo * trigger_info()
trigger information (ptr may be NULL)
Definition: EventInfo/EventInfo/EventInfo.h:244
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
EventInfoCnv_p1::persToTrans
virtual void persToTrans(const EventInfo_p1 *persObj, EventInfo *transObj, MsgStream &log) const override
Definition: EventInfoCnv_p1.cxx:29
EventInfo_p1::m_trigger_info
TriggerInfo_p1 * m_trigger_info
Definition: EventInfo_p1.h:31
EventInfo::event_type
EventType * event_type()
the type of the event, e.g. simulation, testbeam, etc
Definition: EventInfo/EventInfo/EventInfo.h:234