ATLAS Offline Software
JetMomentMapCnv_p6.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 
9 
10 void
12  JetMomentMap_p6* persObj,
13  MsgStream &reporter ) const
14 {
15  reporter << MSG::DEBUG << "JetMomentMapConverterBase toPers() Template _p6" << endmsg;
16 
17  size_t njet = transObj->map().size();
18  persObj->m_momentNum.resize(njet);
19  persObj->m_jetIds.resize(njet);
20  persObj->m_moments.reserve(njet*10); // just a guess
21  persObj->m_momentStatus.reserve(njet*10); // just a guess
22 
23 
24  JetMomentMap::map_t::const_iterator mapIt = transObj->map().begin();
25  JetMomentMap::map_t::const_iterator mapItE = transObj->map().end();
26  size_t i=0;
27  for(; mapIt != mapItE; ++mapIt){
28  // check validity of vectors
29  if( ! (*mapIt).second.isValid() ){ // in principle this should not happen
30  persObj->m_momentNum[i] = 0;
31  persObj->m_jetIds[i] = (*mapIt).first;
32  continue ; // don't save anything.
33  }
34 
35  const JetMomentMap::record_t & moments = *(*mapIt).second.get();
36  size_t jetId= (*mapIt).first;
37 
38  size_t momNum = moments.size();
39  if ( momNum >= JetMomentMap_p6::s_maxNumMoment ){
40  reporter << MSG::ERROR << " Attempt to save "<< momNum <<" jet moments failed. Limiting this number to "<< JetMomentMap_p6::s_maxNumMoment-1<< endmsg;
42  }
43  persObj->m_momentNum[i] = momNum;
44  persObj->m_jetIds[i] = jetId;
45  for( size_t j=0; j<momNum;j++){
46  bool used = moments[j].tag();
47  if(used) persObj->m_moments.push_back(moments[j].moment() );
48  persObj->m_momentStatus.push_back(used);
49  }
50  i++;
51 
52  }
53  reporter << MSG::DEBUG << "JetMomentMapConverterBase toPers() Template _p6 Ending" << endmsg;
54 
55 }
56 
57 void
59  JetMomentMap* transObj,
60  MsgStream &reporter ) const
61 {
62  reporter << MSG::DEBUG << "JetMomentMapConverterBase toTrans() Template _p6" << endmsg;
63 
64  transObj->clear();
65  size_t njet = persObj->m_momentNum.size() ;
66  size_t offset = 0;
67  size_t valueOffset = 0;
68 
69  for( size_t i=0; i<njet;i++){
70  size_t momNum = persObj->m_momentNum[i];
71 
72  // create a new record, assign it to the map
73  JetMomentMap::record_t * moments_ptr = new JetMomentMap::record_t(momNum);
74  JetMomentMap::record_t & moments = *moments_ptr;
75  transObj->m_store[ persObj->m_jetIds[i] ] = JetMomentMap::record_ptr_t(moments_ptr);
76 
77  // fill the records from pers object
78  for( size_t j=0; j<momNum;j++){
79  if( persObj->m_momentStatus[offset+j] ){
80  moments[j] = JetMoment::MomentData(persObj->m_moments[valueOffset], true) ;
81  valueOffset++;
82  }else{
83  moments[j] = JetMoment::MomentData(0, false) ;
84  }
85 
86  }
87 
88  offset += momNum;
89  }
90 }
JetMomentMap
Definition: JetMomentMap.h:21
used
JetMoment::MomentData
Definition: JetMoment.h:21
JetMapBase::m_store
map_t m_store
Store last valid record index ‍/ mutable size_t m_lastIndex; not used so remove it for simplicity /!
Definition: JetMapBase.h:160
JetMomentMap_p6::s_maxNumMoment
static const mom_num_t s_maxNumMoment
Definition: JetMomentMap_p6.h:23
JetMomentMapConverterBase< JetMomentMap_p6 >::transToPers
void transToPers(const JetMomentMap *transObj, JetMomentMap_p6 *persObj, MsgStream &reporter) const override
Method creating the persistent representation JetMomentMap_p6 from its transient representation JetMo...
Definition: JetMomentMapCnv_p6.cxx:11
JetMomentMap_p6::m_moments
std::vector< float > m_moments
Definition: JetMomentMap_p6.h:27
JetMomentMap_p6::m_momentStatus
std::vector< bool > m_momentStatus
Definition: JetMomentMap_p6.h:28
JetMapBase::map
map_t & map()
lumiFormat.i
int i
Definition: lumiFormat.py:85
JetMomentMap_p6::m_momentNum
std::vector< mom_num_t > m_momentNum
Definition: JetMomentMap_p6.h:29
JetCollection.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
JetMomentMap_p6::m_jetIds
std::vector< unsigned int > m_jetIds
Definition: JetMomentMap_p6.h:30
JetMomentMap::record_t
base_t::record_t record_t
Definition: JetMomentMap.h:32
JetMomentMapConverterBase< JetMomentMap_p6 >::persToTrans
void persToTrans(const JetMomentMap_p6 *persObj, JetMomentMap *transObj, MsgStream &reporter) const override
Definition: JetMomentMapCnv_p6.cxx:58
JetMomentMapCnv_p6.h
JetMomentMap_p6
Definition: JetMomentMap_p6.h:13
DEBUG
#define DEBUG
Definition: page_access.h:11
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
JetMapBase::clear
virtual void clear()