ATLAS Offline Software
EventTypeCnv_p2.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "EventInfo/EventType.h"
6 #include <iostream>
8 #include "EventTPCnv/vectorize.h"
10 
11 
12 void EventTypeCnv_p2::persToTrans(std::vector<unsigned int>::const_iterator &i, EventType* trans, int version, bool bugcompat) const{
13  // std::cout<<"persToTrans of EventType ..."<<std::endl;
14  *trans = EventType();
15 
16  std::string user_type;
17  UITostr(user_type, i, bugcompat);
18  trans->set_user_type (user_type);
19 
20  std::vector<bool> bit_mask;
21  UITobitmap(bit_mask,i, bugcompat);
22  for (size_t ii = 0; ii < bit_mask.size(); ii++) {
23  if (bit_mask[ii])
24  trans->add_type (ii);
25  }
26 
27  // we now decode here instead of in EventType
28  float event_weight = (float)AtlasMcWeight::decode((*i)); ++i;
29  trans->set_mc_event_weight (event_weight, 0, 1);
30  if(version>2){
31  trans->set_mc_channel_number (*i); ++i;
32  trans->set_mc_event_number (*i); ++i;
33  }
34  // std::cout<<"persToTrans of EventType ver: "<<version<<"\t weight:"<<trans->m_mc_event_weight<<std::endl;
35 
36 }
37 
38 void EventTypeCnv_p2::transToPers(const EventType* trans, std::vector<unsigned int> &pers) const {
39  // Deprecated - writing out with _p3 RDS 2013/03
40 
41 // // std::cout<<"transToPers of EventType ..."<<std::endl;
42  strToUI(trans->user_type_raw(),pers);
43  bitmapToUI(trans->bit_mask(),pers);
44  double wt = 0;
45  if (trans->n_mc_event_weights() > 0)
46  wt = trans->mc_event_weight(0);
47  pers.push_back(AtlasMcWeight::encode(wt));
48  pers.push_back(trans->mc_channel_number());
49  pers.push_back(trans->mc_event_number());
50 
51 // // std::cout<<"transToPers of EventType. weight: "<<trans->m_mc_event_weight<<std::endl;
52 }
AtlasMcWeight::decode
double decode(number_type binnedWeight)
Convert weight from unsigned to double.
Definition: AtlasMcWeight.cxx:32
EventType::add_type
void add_type(EventTypeCode type_code)
Add a new event type.
Definition: EventType.cxx:51
EventType::set_mc_channel_number
void set_mc_channel_number(number_type chan)
Add in the MC generator channel number (aka gen run number)
Definition: EventType.cxx:197
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
EventType.h
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
vectorize.h
UITostr
void UITostr(std::string &n, std::vector< unsigned int >::const_iterator &i, bool bugcompat)
Definition: vectorize.cxx:29
EventType::mc_event_weight
float mc_event_weight(unsigned int iweight=0) const
Access to MC weight.
Definition: EventType.cxx:175
strToUI
void strToUI(const std::string &m, std::vector< unsigned int > &v)
Definition: vectorize.cxx:9
EventType::mc_channel_number
number_type mc_channel_number() const
Access to the MC generator channel number (was used as run number for generator events)
Definition: EventType.cxx:165
UITobitmap
void UITobitmap(std::vector< bool > &n, std::vector< unsigned int >::const_iterator &i, bool bugcompat)
Definition: vectorize.cxx:103
bitmapToUI
void bitmapToUI(const std::vector< bool > &m, std::vector< unsigned int > &v)
Definition: vectorize.cxx:85
AtlasMcWeight::encode
number_type encode(double weight)
Definition: AtlasMcWeight.cxx:65
AtlasMcWeight.h
Helper functions for MC weight insider the namespace AtlasMcWeight.
lumiFormat.i
int i
Definition: lumiFormat.py:92
EventTypeCnv_p2.h
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
get_generator_info.version
version
Definition: get_generator_info.py:33
EventTypeCnv_p2::transToPers
void transToPers(const EventType *transObj, std::vector< unsigned int > &persObj) const
Definition: EventTypeCnv_p2.cxx:38
EventType::set_mc_event_number
void set_mc_event_number(uint64_t evt)
Add in the MC generator event number.
Definition: EventType.cxx:202
EventType::set_user_type
void set_user_type(const std::string &user_type)
Add user (string) type.
Definition: EventType.cxx:57
EventType::mc_event_number
uint64_t mc_event_number() const
Access to the MC generator event number.
Definition: EventType.cxx:170
python.Bindings.bit_mask
bit_mask
Definition: Control/AthenaPython/python/Bindings.py:648
EventTypeCnv_p2::persToTrans
void persToTrans(std::vector< unsigned int >::const_iterator &persObj, EventType *transObj, int version, bool bugcompat) const
Definition: EventTypeCnv_p2.cxx:12
EventType::n_mc_event_weights
unsigned int n_mc_event_weights() const
Total number of MC weights.
Definition: EventType.cxx:214
readCCLHist.float
float
Definition: readCCLHist.py:83
EventType::user_type_raw
const std::string & user_type_raw(void) const
Access to user type.
Definition: EventType.cxx:108
EventType::bit_mask
const BitMask & bit_mask() const
Definition: EventType.cxx:192