ATLAS Offline Software
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 
120 persToTrans( 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 
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 
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 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
PixelClusterCnv_p3::m_pixId2
const PixelID * m_pixId2
Definition: PixelClusterCnv_p3.h:47
InDet::SiWidthCnv_p2::transToPers
void transToPers(const InDet::SiWidth *, InDet::SiWidth_p2 *, MsgStream &)
Definition: SiWidthCnv_p2.cxx:27
InDet::PixelCluster::setFake
bool setFake(bool)
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:232
InDet::PixelCluster::isAmbiguous
bool isAmbiguous() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:236
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
InDet::PixelCluster_p3
Definition: PixelCluster_p3.h:18
InDet::PixelCluster::omegay
float omegay() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:197
Trk::locX
@ locX
Definition: ParamDefs.h:37
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
PixelCluster.h
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
PixelClusterCnv_p3::persToTrans
void persToTrans(const InDet::PixelCluster_p3 *, InDet::PixelCluster *, MsgStream &)
Definition: PixelClusterCnv_p3.cxx:120
Trk::PrepRawData::localCovariance
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
skel.it
it
Definition: skel.GENtoEVGEN.py:396
InDet::PixelCluster_p3::m_rdoList
std::vector< rdo_diff_type > m_rdoList
Definition: PixelCluster_p3.h:29
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
Identifier::get_compact
value_type get_compact() const
Get the compact id.
PixelClusterCnv_p3::transToPers
void transToPers(const InDet::PixelCluster *, InDet::PixelCluster_p3 *, MsgStream &)
Definition: PixelClusterCnv_p3.cxx:127
InDet::PixelCluster_p3::m_clusId
unsigned int m_clusId
Definition: PixelCluster_p3.h:28
InDet::PixelCluster_p3::m_mat01
float m_mat01
Definition: PixelCluster_p3.h:33
PixelID::calc_offset
Identifier::diff_type calc_offset(const Identifier &base, const Identifier &target) const
Calculate a channel offset between the two identifiers.
Definition: PixelID.h:564
PixelClusterCnv_p3::createPixelCluster
InDet::PixelCluster createPixelCluster(const InDet::PixelCluster_p3 *persObj, const Identifier &waferId, const InDetDD::SiDetectorElement *delEl, MsgStream &log)
Definition: PixelClusterCnv_p3.cxx:29
InDet::PixelCluster_p3::m_mat00
float m_mat00
Definition: PixelCluster_p3.h:32
PixelClusterCnv_p3.h
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
PixelID::base_bit
int base_bit(void) const
Return the lowest bit position used in the channel id.
Definition: PixelID.h:580
InDet::PixelCluster_p3::m_width
InDet::SiWidth_p2 m_width
Definition: PixelCluster_p3.h:41
InDet::PixelCluster::isFake
bool isFake() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:228
PixelClusterCnv_p3::m_swCnv
InDet::SiWidthCnv_p2 m_swCnv
Definition: PixelClusterCnv_p3.h:44
InDet::PixelCluster_p3::m_localPosY
float m_localPosY
Definition: PixelCluster_p3.h:31
PixelClusterCnv_p3::PixelClusterCnv_p3
PixelClusterCnv_p3()
Definition: PixelClusterCnv_p3.h:31
PixelID::pixel_id_offset
Identifier pixel_id_offset(const Identifier &base, Identifier::diff_type offset) const
Create an identifier with a given base and channel offset.
Definition: PixelID.h:572
InDet::PixelCluster::totalToT
int totalToT() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:205
InDet::PixelCluster::LVL1A
int LVL1A() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:269
InDet::PixelCluster_p3::m_properties
unsigned int m_properties
Definition: PixelCluster_p3.h:37
InDet::PixelCluster_p3::m_mat11
float m_mat11
Definition: PixelCluster_p3.h:34
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
EventPrimitives.h
InDet::PixelCluster::setAmbiguous
bool setAmbiguous(bool)
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:265
InDet::SiCluster::gangedPixel
bool gangedPixel() const
return the flag of this cluster containing a gangedPixel
Trk::PrepRawData::localPosition
const Amg::Vector2D & localPosition() const
return the local position reference
InDet::PixelCluster_p3::m_omegax
float m_omegax
Definition: PixelCluster_p3.h:35
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
InDet::PixelCluster_p3::m_splitInfo
int m_splitInfo
Definition: PixelCluster_p3.h:38
InDet::PixelCluster
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
InDet::SiCluster::width
const InDet::SiWidth & width() const
return width class reference
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
InDet::PixelCluster::omegax
float omegax() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:193
InDet::SiCluster::setGangedPixel
void setGangedPixel(bool ganged)
set the flag of this cluster containing a gangedPixel
InDet::PixelCluster::totalCharge
float totalCharge() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:213
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
InDet::PixelCluster_p3::m_chargeList
std::vector< float > m_chargeList
Definition: PixelCluster_p3.h:39
InDet::SiWidth
Definition: SiWidth.h:25
Identifier::value_type
unsigned long long value_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:27
InDet::SiWidthCnv_p2::persToTrans
void persToTrans(const InDet::SiWidth_p2 *, InDet::SiWidth *, MsgStream &)
Definition: SiWidthCnv_p2.cxx:15
InDet::PixelCluster_p3::rdo_diff_type
int rdo_diff_type
Definition: PixelCluster_p3.h:22
PixelID
Definition: PixelID.h:67
InDet::PixelCluster_p3::m_omegay
float m_omegay
Definition: PixelCluster_p3.h:36
readCCLHist.float
float
Definition: readCCLHist.py:83
InDet::PixelCluster_p3::m_localPosX
float m_localPosX
Definition: PixelCluster_p3.h:30
PixelID::pixel_id_from_shortened
Identifier pixel_id_from_shortened(Identifier32::value_type val) const
Create a compact pixel id from a (fixed format) legacy pixel channel id.
Definition: PixelID.h:546
InDet::PixelCluster::splitInfoRaw
int splitInfoRaw() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:260
InDet::PixelCluster::chargeList
const std::vector< float > & chargeList() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:209
Identifier
Definition: IdentifierFieldParser.cxx:14