ATLAS Offline Software
LArHitContainerCnv_p2.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "LArSimEvent/LArHit.h"
7 #include "Identifier/Identifier.h"
8 
11 
13 
14 // LArHitContainerCnv_p2, used for T/P separation
15 // author Ilija Vukotic
16 
18 #include "StoreGate/StoreGateSvc.h"
19 #include "GaudiKernel/ServiceHandle.h"
20 #include <map>
21 #include <stdexcept>
22 
23 
25  : m_cellIdHelper(nullptr)
26 {
27  ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "LArHitContainerCnv_p2");
28  if (detStore->retrieve (m_cellIdHelper, "CaloCell_ID").isFailure()) {
29  throw std::runtime_error ("LArHitContainerCnv_p2: Can't get CaloCell_ID");
30  }
31 }
32 
33 
34 void LArHitContainerCnv_p2::transToPers(const LArHitContainer* transCont, LArHitContainer_p2* persCont, MsgStream &log)
35 { //static int ev=0;
36 
37  size_t size = transCont->size();
38  log << MSG::DEBUG << " *** Writing LArHitContainer_p2 of size:"<<size<<endmsg;
39 
40  persCont->m_channelHash.reserve(size);
41  std::vector<float> tempE; tempE.reserve(size);
42  std::vector<float> tempT; tempT.reserve(size);
43 
45 
46  std::multimap <unsigned int, unsigned int> map_hashPositions;// first hash ; second its position in container
47 
48  for (unsigned int w=0;w<size;++w){
49  IdentifierHash hashId = m_cellIdHelper->calo_cell_hash((*it)->cellID());
50  map_hashPositions.insert(std::pair<unsigned int, int>((unsigned int)hashId, w));
51 // if (!ev) std::cout<<hashId<<"\t"<<((*it)->cellID())<<std::endl;
52  ++it;
53  }
54 
55  std::multimap<unsigned int, unsigned int>::const_iterator iter;
56  unsigned int old=0;
57 // int count=0;
58  for (iter=map_hashPositions.begin(); iter != map_hashPositions.end(); ++iter) {
59  //cout <<"container position:"<< iter->second << " \t hash:" << iter->first << endl;
60  unsigned int pHash=(iter->first)-old; // to store as a difference
61  old=iter->first;
62  unsigned int pos=iter->second;
63  persCont->m_channelHash.push_back(pHash);
64  tempE.push_back( (float) (transCont->At(pos))->energy() );
65  tempT.push_back( (float) (transCont->At(pos))->time() );
66 // if (!ev) std::cout<<"Writing Hash: "<<iter->first<<"\t E: "<< (float) (transCont->At(pos))->m_energy<<"\t T: "<< (float) (transCont->At(pos))->m_time<<std::endl;
67 // count++;
68  }
69 // std::cout<<"ILIJA : "<<count<<std::endl;
70 
71  Compressor A; A.setNrBits(18);
72  A.reduce(tempE,persCont->m_energy); // packs energy
73  Compressor B;
74  B.reduceToUS(tempT, persCont->m_time);
75  persCont->m_name = transCont->Name(); //stores name
76 
77 // ev++;
78 }
79 
80 
81 
82 void LArHitContainerCnv_p2::persToTrans(const LArHitContainer_p2* persCont, LArHitContainer* transCont, MsgStream &log)
83 {
84 // static int dog=0;
85  size_t cells=persCont->m_channelHash.size();
86  log << MSG::DEBUG << " *** Reading LArHitContainer of size: "<<cells<<endmsg;
87  transCont->clear();
88  transCont->reserve(cells);
89  transCont->setName(persCont->name() );
90 
91 
92  Compressor A;
93  std::vector<float> tempE; tempE.reserve(cells);
94  std::vector<float> tempT; tempT.reserve(cells);
95 
96  A.expandFromUStoFloat(persCont->m_time,tempT);
97  A.expandToFloat(persCont->m_energy,tempE);
98  unsigned int sum=0;
99  for (unsigned int i=0;i<cells;++i){
100  sum+= persCont->m_channelHash[i];
101  LArHit* trans=new LArHit
103  tempE[i],
104  tempE[i] != 0 ? (double)(tempT[i])/tempE[i] : 0);
105 // if(!dog) std::cout<<"Reading hash: "<< sum <<"\t E: "<< (double)tempE[i]<<"\t T: "<<(tempT[i]) <<std::endl;
106  transCont->push_back(trans);
107  }
108 // dog++;
109 }
110 
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
AthenaHitsVector::Name
const std::string & Name() const
Definition: AthenaHitsVector.h:130
LArHitContainerCnv_p2::LArHitContainerCnv_p2
LArHitContainerCnv_p2()
Definition: LArHitContainerCnv_p2.cxx:24
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
LArHitContainer_p2::m_time
std::vector< unsigned short > m_time
Definition: LArHitContainer_p2.h:27
AthenaHitsVector::clear
void clear()
Definition: AthenaHitsVector.h:174
skel.it
it
Definition: skel.GENtoEVGEN.py:423
LArHitContainer
Hit collection.
Definition: LArHitContainer.h:26
CaloCell_ID.h
AthenaHitsVector< LArHit >::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
LArHitContainer_p2::m_name
std::string m_name
Definition: LArHitContainer_p2.h:28
Compressor.h
AthenaHitsVector::push_back
void push_back(T *t)
Definition: AthenaHitsVector.h:153
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
LArHitContainer_p2::m_channelHash
std::vector< unsigned int > m_channelHash
Definition: LArHitContainer_p2.h:25
LArHitContainerCnv_p2::m_cellIdHelper
const CaloCell_ID * m_cellIdHelper
Definition: LArHitContainerCnv_p2.h:24
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
AthenaHitsVector::setName
void setName(const std::string &name)
Definition: AthenaHitsVector.h:132
IdentifierHash.h
LArHitContainerCnv_p2::transToPers
virtual void transToPers(const LArHitContainer *transColl, LArHitContainer_p2 *persColl, MsgStream &log) override
Definition: LArHitContainerCnv_p2.cxx:34
dqt_zlumi_alleff_HIST.B
B
Definition: dqt_zlumi_alleff_HIST.py:110
LArHit
Class to store hit energy and time in LAr cell from G4 simulation.
Definition: LArHit.h:25
CaloCell_Base_ID::cell_id
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
LArHit.h
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
CSV_InDetExporter.old
old
Definition: CSV_InDetExporter.py:145
LArHitContainer.h
LArHitContainer_p2
Persistent represenation of a LArHitContainer,.
Definition: LArHitContainer_p2.h:16
LArHitContainer_p2::m_energy
std::vector< unsigned int > m_energy
Definition: LArHitContainer_p2.h:26
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
LArHitContainer_p2::name
const std::string & name() const
Definition: LArHitContainer_p2.h:36
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
LArHitContainerCnv_p2::persToTrans
virtual void persToTrans(const LArHitContainer_p2 *persColl, LArHitContainer *transColl, MsgStream &log) override
Definition: LArHitContainerCnv_p2.cxx:82
StoreGateSvc.h
AthenaHitsVector::At
const T * At(unsigned int pos) const
Definition: AthenaHitsVector.h:156
AthenaHitsVector::begin
const_iterator begin() const
Definition: AthenaHitsVector.h:139
LArHitContainerCnv_p2.h
ServiceHandle< StoreGateSvc >