ATLAS Offline Software
Loading...
Searching...
No Matches
PixelClusterCnv_p3.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5//-----------------------------------------------------------------------------
6//
7// file: PixelClusterCnv_p3.cxx
8//
9//-----------------------------------------------------------------------------
10
13
16
17#include <memory>
18#include <algorithm>
19
20
21
23 :
24 m_pixId2(pixid)
25{}
26
27
30 const Identifier& waferId,
31 const InDetDD::SiDetectorElement* detEl,
32 MsgStream &log)
33{
34 // if persistent m_clusId == 0, we are reading in 64 bit ids and
35 // need to extract the cluster id from the first id in the
36 // m_rdoList
37 Identifier clusId;
38 bool is64BitId = false;
39 unsigned int rdoListSize = persObj->m_rdoList.size();
40 if (persObj->m_clusId == 0) {
41 // 64-bit ids, get cluster id - wafer id has been stored in the
42 // transient object by the container cnv
43 clusId = Identifier(m_pixId2->pixel_id_offset(waferId, persObj->m_rdoList[0]) );
44 is64BitId = true;
45 rdoListSize--;
46 }
47 else {
48 // Must also fix cluster pixel id when reading in old 32-bit ids
49 // and the code has 64-bit ids
50 clusId = m_pixId2->pixel_id_from_shortened(persObj->m_clusId);
51 }
52
53 // Local Position
54 Amg::Vector2D localPos;
55 localPos[Trk::locX] = persObj->m_localPosX;
56 localPos[Trk::locY] = persObj->m_localPosY;
57
58 std::vector<Identifier> rdoList;
59 rdoList.resize(rdoListSize);
60 std::vector<Identifier>::iterator idit = rdoList.begin();
61 std::vector<InDet::PixelCluster_p3::rdo_diff_type>::const_iterator it = persObj->m_rdoList.begin();
62 if (is64BitId) ++it; // we have used first element of persistent rdoList for cluster id
63 for (; it != persObj->m_rdoList.end(); ++it) {
64 // When reading in data written for 32-bit ids, we need to use
65 // the PixelID helper to convert it if filling a 64-bit id
66 // (i.e. using pixel_id_from_shortened). This does nothing if
67 // the identifiers are still 32-bit RDS
68 if (is64BitId) {
69 *idit = Identifier(clusId.get_compact() + ( (static_cast<Identifier::value_type>(*it)) << m_pixId2->base_bit() ) );
70 }
71 else {
72 (*idit) = m_pixId2->pixel_id_from_shortened(persObj->m_clusId + (*it));
73 }
74 ++idit;
75 }
76
78 m_swCnv.persToTrans(&persObj->m_width, &width, log);
79
80 // Error matrix
81 auto cmat = Amg::MatrixX(2,2);
82 (cmat)(0,0) = static_cast<double>(persObj->m_mat00);
83 (cmat)(1,0) = static_cast<double>(persObj->m_mat01);
84 (cmat)(0,1) = static_cast<double>(persObj->m_mat01);
85 (cmat)(1,1) = static_cast<double>(persObj->m_mat11);
86
87
88 // Check if charge or ToT has been stored
89 int totalToT = 0;
90 float totalCharge = 0;
91 if ( (persObj->m_properties&(1<<27))!=0 )
92 totalCharge = (float)(persObj->m_properties & 0xFFFFFF);
93 else
94 totalToT = (persObj->m_properties & 0xFFFFFF);
95
96 auto chargeList = persObj->m_chargeList;
97 InDet::PixelCluster clus (clusId,
98 localPos,
99 std::move(rdoList),
100 ((persObj->m_properties)>>28) & 0xF, // lvl1a
101 totalToT,
102 std::move(chargeList),
103 totalCharge,
104 width,
105 detEl,
106 std::move(cmat),
107 persObj->m_omegax,
108 persObj->m_omegay,
109 persObj->m_splitInfo
110 );
111
112 clus.setGangedPixel( (persObj->m_properties&(1<<24))!=0 );
113 clus.setFake( (persObj->m_properties&(1<<25))!=0 );
114 clus.setAmbiguous( (persObj->m_properties&(1<<26))!=0 );
115 return clus;
116}
117
118
120persToTrans( const InDet::PixelCluster_p3 *persObj, InDet::PixelCluster *transObj, MsgStream &log)
121{
122 Identifier waferId = transObj->identify();
123 *transObj = createPixelCluster (persObj, waferId, nullptr, log);
124}//end of cnv_p3 method
125
126
127void PixelClusterCnv_p3::transToPers( const InDet::PixelCluster *transObj, InDet::PixelCluster_p3 *persObj, MsgStream &log )
128{
129// log << MSG::VERBOSE << "In PixelCluster::transToPers" << endmsg;
130 m_swCnv.transToPers(&transObj->width(), &persObj->m_width, log);
131
132 // base class:
133 //
134
135 // Local Position
136 persObj->m_localPosX = transObj->localPosition()[Trk::locX];
137 persObj->m_localPosY = transObj->localPosition()[Trk::locY];
138
139 // Error Matrix
140
141 persObj->m_mat00 = (transObj->localCovariance())(0,0);
142 persObj->m_mat01 = (transObj->localCovariance())(0,1);
143 persObj->m_mat11 = (transObj->localCovariance())(1,1);
144
145 // Charge balance
146 persObj->m_omegax = transObj->omegax();
147 persObj->m_omegay = transObj->omegay();
148
149 // List of Id of the cluster
150
151 // For 64-bit ids, we set m_clusId to 0 and instead save the
152 // diff in m_rdoList as the first element
153 persObj->m_rdoList.resize(transObj->rdoList().size() + 1);
154
155 std::vector<InDet::PixelCluster_p3::rdo_diff_type>::iterator pit = persObj->m_rdoList.begin();
156 // Get base identifier to calculate diffs
157 Identifier clusId = transObj->identify();
158 persObj->m_clusId = 0;
159 // Save offset to wafer id for the cluster id
160 Identifier waferId = m_pixId2->wafer_id(clusId); // remove the eta/phi of channel id
161 *pit = static_cast<InDet::PixelCluster_p3::rdo_diff_type>( m_pixId2->calc_offset(waferId, clusId) );
162 ++pit;
163
164 for (const Identifier& id : transObj->rdoList()) {
165 *pit = static_cast<InDet::PixelCluster_p3::rdo_diff_type>( m_pixId2->calc_offset(clusId, id) );
166 ++pit;
167 }
168
169 // Setting of cluster properties:
170 persObj->m_properties = 0;
171 if ( transObj->gangedPixel() ) persObj->m_properties |= (1<<24);
172 if ( transObj->isFake() ) persObj->m_properties |= (1<<25);
173 if ( transObj->isAmbiguous() ) persObj->m_properties |= (1<<26);
174 persObj->m_properties |= ((transObj->LVL1A() & 0xF)<<28);
175
176 if ( transObj->totalCharge()>0. ) {
177 persObj->m_properties |= (1<<27);
178 persObj->m_properties |= ( (int)(transObj->totalCharge()+0.5) & 0xFFFFFF );
179 } else {
180 persObj->m_properties |= ( transObj->totalToT() & 0xFFFFFF );
181 }
182 // needed for pixel cluster splitting
183 persObj->m_splitInfo = transObj->splitInfoRaw();
184 persObj->m_chargeList = transObj->chargeList();
185}
186
187
This is an Identifier helper class for the Pixel subdetector.
const double width
value_type get_compact() const
Get the compact id.
Class to hold geometrical description of a silicon detector element.
InDet::SiWidth_p2 m_width
std::vector< rdo_diff_type > m_rdoList
std::vector< float > m_chargeList
bool gangedPixel() const
return the flag of this cluster containing a gangedPixel
const InDet::SiWidth & width() const
return width class reference
void setGangedPixel(bool ganged)
set the flag of this cluster containing a gangedPixel
InDet::PixelCluster createPixelCluster(const InDet::PixelCluster_p3 *persObj, const Identifier &waferId, const InDetDD::SiDetectorElement *delEl, MsgStream &log)
const PixelID * m_pixId2
void persToTrans(const InDet::PixelCluster_p3 *, InDet::PixelCluster *, MsgStream &)
InDet::SiWidthCnv_p2 m_swCnv
void transToPers(const InDet::PixelCluster *, InDet::PixelCluster_p3 *, MsgStream &)
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:67
const Amg::Vector2D & localPosition() const
return the local position reference
Identifier identify() const
return the identifier
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37