ATLAS Offline Software
Loading...
Searching...
No Matches
SrCaloCalibrationHitContainerCnv_p1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
13#include "Identifier/Identifier.h"
15#include <map>
16
18 const SrCaloCalibrationHitContainer* transCont,
19 SrCaloCalibrationHitContainer_p1* persCont, MsgStream& log) {
20
21 size_t size = transCont->size();
22 if (log.level() <= MSG::DEBUG)
23 log << MSG::DEBUG
24 << " *** Writing SrCaloCalibrationHitContainer_p1 of size: " << size
25 << endmsg;
26
27 persCont->m_channelHash.reserve(size);
28 std::vector<float> tempE;
29 tempE.reserve(size * 4);
30 std::vector<unsigned int> tempPID;
31 tempPID.reserve(size);
33
34 std::multimap<unsigned long long, unsigned int>
35 map_hashPositions; // first hash ; second its position in container
36
37 for (unsigned int w = 0; w < size; ++w) {
38 unsigned long long id = (*it)->cellID().get_compact();
39 map_hashPositions.insert(std::pair<unsigned long long, int>(id, w));
40 ++it;
41 }
42
43 std::multimap<unsigned long long, unsigned int>::const_iterator iter;
44 unsigned long long old = 0;
45
46 for (iter = map_hashPositions.begin(); iter != map_hashPositions.end();
47 ++iter) {
48 unsigned long long pHash = (iter->first) - old;
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.particleID()));
58 }
59 // For future development: use Compressor class to reduce size of energy
60 // storage ?
61 // Compressor A; A.setNrBits(18);
62 // A.reduce(tempE,persCont->m_energy); // packs energy
63 persCont->m_energy = std::move(tempE); // Store directly without compression
64 persCont->m_name = transCont->Name(); // stores name
65 persCont->m_particleID = std::move(tempPID);
66}
67
70 SrCaloCalibrationHitContainer* transCont, MsgStream& log) {
71 size_t cells = persCont->m_channelHash.size();
72 if (log.level() <= MSG::DEBUG)
73 log << MSG::DEBUG
74 << " *** Reading SrCaloCalibrationHitContainer of size: " << cells
75 << endmsg;
76 transCont->clear();
77 transCont->reserve(cells);
78 transCont->setName(persCont->name());
79
80 // For future development: use Compressor class to reconstruct energy values
81 // Compressor A;
82 // std::vector<float> tempE;
83 const std::vector<float>& tempE = persCont->m_energy; // Direct reference
84 // tempE.reserve(cells*4);
85 // A.expandToFloat(persCont->m_energy,tempE);
86
87 unsigned long long sum = 0;
88 for (unsigned int i = 0; i < cells; ++i) {
89 sum += persCont->m_channelHash[i];
90 transCont->push_back(new CaloCalibrationHit(
91 static_cast<Identifier>(sum), tempE[i * 4], tempE[i * 4 + 1],
92 tempE[i * 4 + 2], tempE[i * 4 + 3],
93 static_cast<int>(persCont->m_particleID[i]),
95 }
96}
#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
Class to store calorimeter calibration hit.
double energyNonEM() const
double energyEscaped() const
double energyInvisible() const
virtual void transToPers(const SrCaloCalibrationHitContainer *transColl, SrCaloCalibrationHitContainer_p1 *persColl, MsgStream &log)
virtual void persToTrans(const SrCaloCalibrationHitContainer_p1 *persColl, SrCaloCalibrationHitContainer *transColl, MsgStream &log)
std::vector< unsigned long long > m_channelHash
constexpr int INVALID_PARTICLE_ID