ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
#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_p2 *persColl, CaloCalibrationHitContainer *transColl, MsgStream &log)
virtual void transToPers(const CaloCalibrationHitContainer *transColl, CaloCalibrationHitContainer_p2 *persColl, MsgStream &log)
Persistent represenation of a CaloCalibrationContainer,.
Class to store calorimeter calibration hit.
double energyNonEM() const
double energyEscaped() const
double energyInvisible() const
hold the test vectors and ease the comparison