ATLAS Offline Software
CaloCalibrationHitContainerCnv_p4.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "Identifier/Identifier.h"
8 
13 
15 
16 // CaloCalibrationHitContainerCnv_p4, used for T/P separation
17 // author Ilija Vukotic
18 
20 #include "map"
21 
23 {
24 
25  // static int ev=0;
26  size_t size = transCont->size();
27  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Writing CaloCalibrationHitContainer_p4 of size:"<<size<<endmsg;
28 
29  persCont->m_channelHash.reserve(size);
30  std::vector<float> tempE;
31  tempE.reserve(size*4);
32  std::vector<unsigned int> tempPID; tempPID.reserve(size);
33 
35 
36  std::multimap <unsigned int, unsigned int> map_hashPositions;// first hash ; second its position in container
37 
38  for (unsigned int w=0;w<size;++w) {
39 
40  unsigned int id = (*it)->cellID().get_identifier32().get_compact();
41  map_hashPositions.insert(std::pair<unsigned int, int>(id, w));
42  ++it;
43  }
44 
45  std::multimap<unsigned int, unsigned int>::const_iterator iter;
46  unsigned int old=0;
47  for (iter=map_hashPositions.begin(); iter != map_hashPositions.end(); ++iter) {
48  unsigned int pHash=(iter->first)-old; // to store as a difference
49  old=iter->first;
50  unsigned int pos=iter->second;
51  persCont->m_channelHash.push_back(pHash);
52  const CaloCalibrationHit& hit = *transCont->At(pos);
53  tempE.push_back( static_cast<float>(hit.energyEM()) );
54  tempE.push_back( static_cast<float>(hit.energyNonEM()) );
55  tempE.push_back( static_cast<float>(hit.energyInvisible()) );
56  tempE.push_back( static_cast<float>(hit.energyEscaped()) );
57  tempPID.push_back( static_cast<unsigned int>(hit.particleUID()) );
58  }
59 
60  Compressor A; A.setNrBits(18);
61  A.reduce(tempE,persCont->m_energy); // packs energy
62  persCont->m_name = transCont->Name(); //stores name
63  persCont->m_particleUID = tempPID;
64 
65 }
66 
67 
68 
70 {
71  size_t cells=persCont->m_channelHash.size();
72  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Reading CaloCalibrationHitContainer of size: "<<cells<<endmsg;
73  transCont->clear();
74  transCont->reserve(cells);
75  transCont->setName(persCont->name() );
76 
77  Compressor A;
78  std::vector<float> tempE;
79  tempE.reserve(cells*4);
80  A.expandToFloat(persCont->m_energy,tempE);
81 
82  unsigned int sum=0;
83  for (unsigned int i=0;i<cells;++i) {
84  sum+= persCont->m_channelHash[i];
85 
86  transCont->push_back
87  (new CaloCalibrationHit(static_cast<Identifier>(sum),
88  tempE[i*4],
89  tempE[i*4+1],
90  tempE[i*4+2],
91  tempE[i*4+3],
93  static_cast<int>(persCont->m_particleUID[i])));
94  }
95 }
CaloCalibrationHitContainer_p4::name
const std::string & name() const
Definition: CaloCalibrationHitContainer_p4.h:36
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
CaloCalibrationHitContainer
Definition: CaloCalibrationHitContainer.h:25
AthenaHitsVector::Name
const std::string & Name() const
Definition: AthenaHitsVector.h:130
CaloCalibrationHit.h
CaloCalibrationHitContainer_p4::m_name
std::string m_name
Definition: CaloCalibrationHitContainer_p4.h:27
CaloCalibrationHit::energyNonEM
double energyNonEM() const
Definition: CaloCalibrationHit.h:124
CaloCalibrationHitContainer_p4::m_particleUID
std::vector< unsigned int > m_particleUID
Definition: CaloCalibrationHitContainer_p4.h:28
CaloCalibrationHitContainerCnv_p4::persToTrans
virtual void persToTrans(const CaloCalibrationHitContainer_p4 *persColl, CaloCalibrationHitContainer *transColl, MsgStream &log)
Definition: CaloCalibrationHitContainerCnv_p4.cxx:69
HepMC::INVALID_PARTICLE_ID
constexpr int INVALID_PARTICLE_ID
Definition: MagicNumbers.h:56
AthenaHitsVector::clear
void clear()
Definition: AthenaHitsVector.h:174
skel.it
it
Definition: skel.GENtoEVGEN.py:396
CaloCalibrationHit::energyEM
double energyEM() const
Definition: CaloCalibrationHit.h:121
CaloCalibrationHitContainer_p4::m_channelHash
std::vector< unsigned int > m_channelHash
Definition: CaloCalibrationHitContainer_p4.h:25
CaloCalibrationHitContainerCnv_p4.h
CaloCalibrationHitContainer.h
CaloCell_ID.h
AthenaHitsVector< CaloCalibrationHit >::const_iterator
boost::transform_iterator< make_const, typename CONT::const_iterator > const_iterator
Definition: AthenaHitsVector.h:58
Compressor
Definition: Compressor.h:26
AthenaHitsVector::reserve
void reserve(size_type n)
Definition: AthenaHitsVector.h:182
dqt_zlumi_alleff_HIST.A
A
Definition: dqt_zlumi_alleff_HIST.py:110
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
A
Compressor.h
AthenaHitsVector::push_back
void push_back(T *t)
Definition: AthenaHitsVector.h:153
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
CaloCalibrationHit::energyInvisible
double energyInvisible() const
Definition: CaloCalibrationHit.h:127
CaloDM_ID.h
CaloCalibrationHit
Class to store calorimeter calibration hit.
Definition: CaloCalibrationHit.h:23
AthenaHitsVector::setName
void setName(const std::string &name)
Definition: AthenaHitsVector.h:132
IdentifierHash.h
CaloCalibrationHitContainer_p4
Persistent represenation of a CaloCalibrationContainer,.
Definition: CaloCalibrationHitContainer_p4.h:16
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
CaloCalibrationHit::particleUID
int particleUID() const
Definition: CaloCalibrationHit.h:159
CSV_InDetExporter.old
old
Definition: CSV_InDetExporter.py:145
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
AthenaHitsVector::size
size_type size() const
Definition: AthenaHitsVector.h:151
CaloCalibrationHitContainer_p4::m_energy
std::vector< unsigned int > m_energy
Definition: CaloCalibrationHitContainer_p4.h:26
CaloIdManager.h
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
CaloCalibrationHitContainerCnv_p4::transToPers
virtual void transToPers(const CaloCalibrationHitContainer *transColl, CaloCalibrationHitContainer_p4 *persColl, MsgStream &log)
Definition: CaloCalibrationHitContainerCnv_p4.cxx:22
AthenaHitsVector::At
const T * At(unsigned int pos) const
Definition: AthenaHitsVector.h:156
CaloCalibrationHit::energyEscaped
double energyEscaped() const
Definition: CaloCalibrationHit.h:130
AthenaHitsVector::begin
const_iterator begin() const
Definition: AthenaHitsVector.h:139
Identifier
Definition: IdentifierFieldParser.cxx:14