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