ATLAS Offline Software
CaloCalibrationHitContainerCnv_p3.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_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 = 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 
103  Compressor A;
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 
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
CaloCalibrationHit::energyNonEM
double energyNonEM() const
Definition: CaloCalibrationHit.h:124
HepMC::INVALID_PARTICLE_ID
constexpr int INVALID_PARTICLE_ID
Definition: MagicNumbers.h:57
CaloCalibrationHitContainerCnv_p3::persToTrans
virtual void persToTrans(const CaloCalibrationHitContainer_p3 *persColl, CaloCalibrationHitContainer *transColl, MsgStream &log)
Definition: CaloCalibrationHitContainerCnv_p3.cxx:90
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_p3::name
const std::string & name() const
Definition: CaloCalibrationHitContainer_p3.h:39
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
CaloCalibrationHitContainerCnv_p3::transToPers
virtual void transToPers(const CaloCalibrationHitContainer *transColl, CaloCalibrationHitContainer_p3 *persColl, MsgStream &log)
Definition: CaloCalibrationHitContainerCnv_p3.cxx:22
CaloCalibrationHit::energyInvisible
double energyInvisible() const
Definition: CaloCalibrationHit.h:127
CaloCalibrationHitContainer_p3::m_particleID
std::vector< unsigned int > m_particleID
Definition: CaloCalibrationHitContainer_p3.h:31
CaloCalibrationHitContainerCnv_p3.h
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
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
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
CaloIdManager.h
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
CaloCalibrationHitContainer_p3
Persistent represenation of a CaloCalibrationContainer,.
Definition: CaloCalibrationHitContainer_p3.h:16
CaloCalibrationHitContainer_p3::m_energy
std::vector< unsigned int > m_energy
Definition: CaloCalibrationHitContainer_p3.h:26
CaloCalibrationHitContainer_p3::m_channelHash
std::vector< unsigned int > m_channelHash
Definition: CaloCalibrationHitContainer_p3.h:25
AthenaHitsVector::At
const T * At(unsigned int pos) const
Definition: AthenaHitsVector.h:156
CaloCalibrationHit::energyEscaped
double energyEscaped() const
Definition: CaloCalibrationHit.h:130
CaloCalibrationHit::particleID
int particleID() const
Definition: CaloCalibrationHit.h:156
AthenaHitsVector::begin
const_iterator begin() const
Definition: AthenaHitsVector.h:139
CaloCalibrationHitContainer_p3::m_name
std::string m_name
Definition: CaloCalibrationHitContainer_p3.h:30
Identifier
Definition: IdentifierFieldParser.cxx:14