ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCalibrationHitContainerCnv_p3.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "Identifier/Identifier.h"
8
13
15
16// CaloCalibrationHitContainerCnv_p3, 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_p3 of size:"<<size<<endmsg;
28
29 persCont->m_channelHash.reserve(size);
30 std::vector<float> tempE; tempE.reserve(size*4);
31 std::vector<unsigned int> tempPID; tempPID.reserve(size);
32
33// const CaloCell_ID* cellIdHelper = (CaloIdManager::instance())->getCaloCell_ID();
34// const CaloDM_ID* cellIdHelper = (CaloIdManager::instance())->getDM_ID();
35
36
38
39 std::multimap <unsigned int, unsigned int> map_hashPositions;// first hash ; second its position in container
40
41 for (unsigned int w=0;w<size;++w){
42 //IdentifierHash hashId = cellIdHelper->calo_cell_hash((*it)->m_ID);
43
44 unsigned int id = (*it)->cellID().get_identifier32().get_compact();
45 /* when hash things are clear it could be usefull to change from storing ID to storing hash
46 IdentifierHash hashId = -1;
47 if (cellIdHelper->is_lar_dm(id))
48 hashId =cellIdHelper->lar_zone_hash(id);
49 else if (cellIdHelper->is_tile_dm(id))
50 hashId =cellIdHelper->tile_zone_hash(id)+cellIdHelper->lar_zone_hash_max();
51 */
52 map_hashPositions.insert(std::pair<unsigned int, int>(id, w));
53/* if (!ev){
54 if ( cellIdHelper->is_lar_dm(id) ) std::cout<<"LAR ";
55 if ( cellIdHelper->is_tile_dm(id)) std::cout<<"TILE ";
56 std::cout<<hashId;
57 std::cout<<"\t"<<id<<std::endl;
58 }*/
59 ++it;
60 }
61
62 std::multimap<unsigned int, unsigned int>::const_iterator iter;
63 unsigned int old=0;
64 for (iter=map_hashPositions.begin(); iter != map_hashPositions.end(); ++iter) {
65 //cout <<"container position:"<< iter->second << " \t hash:" << iter->first << endl;
66 unsigned int pHash=(iter->first)-old; // to store as a difference
67 old=iter->first;
68 unsigned int pos=iter->second;
69 persCont->m_channelHash.push_back(pHash);
70 const CaloCalibrationHit& hit = *transCont->At(pos);
71 tempE.push_back( (float) hit.energyEM() );
72 tempE.push_back( (float) hit.energyNonEM() );
73 tempE.push_back( (float) hit.energyInvisible() );
74 tempE.push_back( (float) hit.energyEscaped() );
75 tempPID.push_back( (unsigned int) hit.particleID() );
76
77// if (!ev) std::cout<<"Writing Hash: "<<iter->first<<"\t E: "<< (float) (transCont->At(pos))->m_energy0<<std::endl;
78 }
79
80 Compressor A; A.setNrBits(18);
81 A.reduce(tempE,persCont->m_energy); // packs energy
82 persCont->m_name = transCont->Name(); //stores name
83 persCont->m_particleID = std::move(tempPID);
84
85// ev++;
86}
87
88
89
91{
92// static int dog=0;
93 size_t cells=persCont->m_channelHash.size();
94 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Reading CaloCalibrationHitContainer of size: "<<cells<<endmsg;
95 transCont->clear();
96 transCont->reserve(cells);
97 transCont->setName(persCont->name() );
98
99
100 //const CaloCell_ID* cellIdHelper = (CaloIdManager::instance())->getCaloCell_ID();
101 //const CaloDM_ID* cellIdHelper = (CaloIdManager::instance())->getDM_ID();
102
104 std::vector<float> tempE; tempE.reserve(cells*4);
105 A.expandToFloat(persCont->m_energy,tempE);
106
107 unsigned int sum=0;
108 for (unsigned int i=0;i<cells;++i){
109 sum+= persCont->m_channelHash[i];
110
111 /* //trans->m_ID=cellIdHelper->cell_id(sum);
112 //trans->m_ID=cellIdHelper->lar_zone_id(sum); when story with hashes gets clarified
113 */
114
115 transCont->push_back
116 (new CaloCalibrationHit(static_cast<Identifier>(sum),
117 tempE[i*4],
118 tempE[i*4+1],
119 tempE[i*4+2],
120 tempE[i*4+3],
121 static_cast<int>(persCont->m_particleID[i]),
123
124// if(!dog) std::cout<<"Reading hash: "<<sum <<"\t E: "<< (double)tempE[i] <<std::endl;
125 }
126// dog++;
127
128}
129
#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 transToPers(const CaloCalibrationHitContainer *transColl, CaloCalibrationHitContainer_p3 *persColl, MsgStream &log)
virtual void persToTrans(const CaloCalibrationHitContainer_p3 *persColl, CaloCalibrationHitContainer *transColl, 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