ATLAS Offline Software
Loading...
Searching...
No Matches
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 = std::move(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
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}
#define endmsg
boost::transform_iterator< make_const, typename CONT::const_iterator > const_iterator
void reserve(size_type n)
void setName(const std::string &name)
const T * At(unsigned int pos) const
const_iterator begin() const
size_type size() const
const std::string & Name() const
virtual void persToTrans(const CaloCalibrationHitContainer_p4 *persColl, CaloCalibrationHitContainer *transColl, MsgStream &log)
virtual void transToPers(const CaloCalibrationHitContainer *transColl, CaloCalibrationHitContainer_p4 *persColl, MsgStream &log)
Persistent represenation of a CaloCalibrationContainer,.
Class to store calorimeter calibration hit.
double energyNonEM() const
double energyEscaped() const
double energyInvisible() const
constexpr int INVALID_PARTICLE_ID
hold the test vectors and ease the comparison