ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCnv
LArSimEventTPCnv
src
LArHitFloatContainerCnv_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/LArHitFloat.h
"
6
#include "
LArSimEvent/LArHitFloatContainer.h
"
7
#include "Identifier/Identifier.h"
8
9
#include "
Identifier/IdentifierHash.h
"
10
#include "
CaloIdentifier/CaloCell_ID.h
"
11
12
#include "
CxxUtils/Compressor.h
"
13
14
// LArHitFloatContainerCnv_p2, used for T/P separation
15
// author Ilija Vukotic
16
17
#include "
LArSimEventTPCnv/LArHitFloatContainerCnv_p2.h
"
18
#include "
StoreGate/StoreGateSvc.h
"
19
#include "GaudiKernel/ServiceHandle.h"
20
#include <map>
21
#include <stdexcept>
22
23
24
LArHitFloatContainerCnv_p2::LArHitFloatContainerCnv_p2
()
25
:
m_cellIdHelper
(nullptr)
26
{
27
ServiceHandle<StoreGateSvc>
detStore (
"DetectorStore"
,
"LArHitFloatContainerCnv_p2"
);
28
if
(detStore->retrieve (
m_cellIdHelper
,
"CaloCell_ID"
).isFailure()) {
29
throw
std::runtime_error (
"LArHitFloatContainerCnv_p2: Can't get CaloCell_ID"
);
30
}
31
}
32
33
34
void
LArHitFloatContainerCnv_p2::transToPers
(
const
LArHitFloatContainer
* 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
44
LArHitFloatContainer::const_iterator it = transCont->begin();
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( (transCont->at(pos)).energy() );
65
tempT.push_back( (transCont->at(pos)).time() );
66
// if (!ev) std::cout<<"Writing Hash: "<<iter->first<<"\t E: "<< (float) (transCont->At(pos))->energy()<<"\t T: "<< (float) (transCont->At(pos))->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
=
""
;
//stores name
76
77
// ev++;
78
}
79
80
81
82
void
LArHitFloatContainerCnv_p2::persToTrans
(
const
LArHitContainer_p2
* persCont,
LArHitFloatContainer
* 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
90
Compressor
A
;
91
std::vector<float> tempE; tempE.reserve(cells);
92
std::vector<float> tempT; tempT.reserve(cells);
93
94
A
.expandFromUStoFloat(persCont->
m_time
,tempT);
95
A
.expandToFloat(persCont->
m_energy
,tempE);
96
unsigned
int
sum=0;
97
for
(
unsigned
int
i=0;i<cells;++i){
98
sum+= persCont->
m_channelHash
[i];
99
LArHitFloat
hit
(
m_cellIdHelper
->cell_id(sum),tempE[i],tempT[i]);
100
// if(!dog) std::cout<<"Reading hash: "<< sum <<"\t E: "<< (double)tempE[i]<<"\t T: "<<(tempT[i]) <<std::endl;
101
transCont->push_back(
hit
);
102
}
103
// dog++;
104
}
105
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
CaloCell_ID.h
Compressor.h
IdentifierHash.h
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
LArHitFloatContainerCnv_p2.h
LArHitFloatContainer.h
LArHitFloat.h
StoreGateSvc.h
size
size_t size() const
Number of registered mappings.
Compressor
Definition
Compressor.h:26
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
LArHitContainer_p2
Persistent represenation of a LArHitContainer,.
Definition
LArHitContainer_p2.h:16
LArHitContainer_p2::m_channelHash
std::vector< unsigned int > m_channelHash
Definition
LArHitContainer_p2.h:25
LArHitContainer_p2::m_energy
std::vector< unsigned int > m_energy
Definition
LArHitContainer_p2.h:26
LArHitContainer_p2::m_name
std::string m_name
Definition
LArHitContainer_p2.h:28
LArHitContainer_p2::m_time
std::vector< unsigned short > m_time
Definition
LArHitContainer_p2.h:27
LArHitFloatContainerCnv_p2::LArHitFloatContainerCnv_p2
LArHitFloatContainerCnv_p2()
Definition
LArHitFloatContainerCnv_p2.cxx:24
LArHitFloatContainerCnv_p2::persToTrans
virtual void persToTrans(const LArHitContainer_p2 *persColl, LArHitFloatContainer *transColl, MsgStream &log) override
Definition
LArHitFloatContainerCnv_p2.cxx:82
LArHitFloatContainerCnv_p2::m_cellIdHelper
const CaloCell_ID * m_cellIdHelper
Definition
LArHitFloatContainerCnv_p2.h:25
LArHitFloatContainerCnv_p2::transToPers
virtual void transToPers(const LArHitFloatContainer *transColl, LArHitContainer_p2 *persColl, MsgStream &log) override
Definition
LArHitFloatContainerCnv_p2.cxx:34
LArHitFloatContainer
Container for LArHitFloat.
Definition
LArHitFloatContainer.h:18
LArHitFloat
Class to store hit energy and time in LAr cell from G4 simulation.
Definition
LArHitFloat.h:18
ServiceHandle
Definition
ClusterMakerTool.h:36
A
hold the test vectors and ease the comparison
Generated on
for ATLAS Offline Software by
1.17.0