CMS 3D CMS Logo

RPixClusterToHit.cc
Go to the documentation of this file.
2 
4  verbosity_ = conf.getUntrackedParameter<int>("RPixVerbosity");
5 }
6 
8 
9 void RPixClusterToHit::buildHits(unsigned int detId,
10  const std::vector<CTPPSPixelCluster> &clusters,
11  std::vector<CTPPSPixelRecHit> &hits,
12  const PPSPixelTopology &ppt) {
13  if (verbosity_)
14  edm::LogInfo("PPS") << " RPixClusterToHit " << detId << " received cluster array of size = " << clusters.size();
15  for (unsigned int i = 0; i < clusters.size(); i++) {
16  make_hit(clusters[i], hits, ppt);
17  }
18 }
19 
21  std::vector<CTPPSPixelRecHit> &hits,
22  const PPSPixelTopology &ppt) {
23  // take a cluster, generate a rec hit and push it in the rec hit vector
24 
25  //call the numbering inside the ROC
26  CTPPSPixelIndices pxlInd;
27  // get information from the cluster
28  // get the whole cluster size and row/col size
29  unsigned int thisClusterSize = aCluster.size();
30  unsigned int thisClusterRowSize = aCluster.sizeRow();
31  unsigned int thisClusterColSize = aCluster.sizeCol();
32 
33  // get the minimum pixel row/col
34  unsigned int thisClusterMinRow = aCluster.minPixelRow();
35  unsigned int thisClusterMinCol = aCluster.minPixelCol();
36 
37  // calculate "on edge" flag
38  bool anEdgePixel = false;
39  if (aCluster.minPixelRow() == 0 || aCluster.minPixelCol() == 0 ||
40  int(aCluster.minPixelRow() + aCluster.rowSpan()) == (pxlInd.getDefaultRowDetSize() - 1) ||
41  int(aCluster.minPixelCol() + aCluster.colSpan()) == (pxlInd.getDefaultColDetSize() - 1))
42  anEdgePixel = true;
43 
44  // check for bad (ADC=0) pixels in cluster
45  bool aBadPixel = false;
46  for (unsigned int i = 0; i < thisClusterSize; i++) {
47  if (aCluster.pixelADC(i) == 0)
48  aBadPixel = true;
49  }
50 
51  // check for spanning two ROCs
52  bool twoRocs = false;
53  int currROCId = pxlInd.getROCId(aCluster.pixelCol(0), aCluster.pixelRow(0));
54 
55  for (unsigned int i = 1; i < thisClusterSize; i++) {
56  if (pxlInd.getROCId(aCluster.pixelCol(i), aCluster.pixelRow(i)) != currROCId) {
57  twoRocs = true;
58  break;
59  }
60  }
61 
62  //estimate position and error of the hit
63  double avgWLocalX = 0;
64  double avgWLocalY = 0;
65  double weights = 0;
66  double weightedVarianceX = 0.;
67  double weightedVarianceY = 0.;
68 
69  if (verbosity_)
70  edm::LogInfo("PPS") << "RPixClusterToHit "
71  << " hit pixels: ";
72 
73  for (unsigned int i = 0; i < thisClusterSize; i++) {
74  if (verbosity_)
75  edm::LogInfo("PPS") << "RPixClusterToHit " << aCluster.pixelRow(i) << " " << aCluster.pixelCol(i) << " "
76  << aCluster.pixelADC(i);
77 
78  double minPxlX = 0;
79  double minPxlY = 0;
80  double maxPxlX = 0;
81  double maxPxlY = 0;
82 
83  ppt.pixelRange(aCluster.pixelRow(i), aCluster.pixelCol(i), minPxlX, maxPxlX, minPxlY, maxPxlY);
84  double halfSizeX = (maxPxlX - minPxlX) / 2.;
85  double halfSizeY = (maxPxlY - minPxlY) / 2.;
86  double avgPxlX = minPxlX + halfSizeX;
87  double avgPxlY = minPxlY + halfSizeY;
88  //error propagation
89  weightedVarianceX += aCluster.pixelADC(i) * aCluster.pixelADC(i) * halfSizeX * halfSizeX / 3.;
90  weightedVarianceY += aCluster.pixelADC(i) * aCluster.pixelADC(i) * halfSizeY * halfSizeY / 3.;
91 
92  avgWLocalX += avgPxlX * aCluster.pixelADC(i);
93  avgWLocalY += avgPxlY * aCluster.pixelADC(i);
94  weights += aCluster.pixelADC(i);
95  }
96 
97  if (weights == 0) {
98  edm::LogError("RPixClusterToHit") << " unexpected weights = 0 for cluster (Row_min, Row_max, Col_min, Col_max) = ("
99  << aCluster.minPixelRow() << "," << aCluster.minPixelRow() + aCluster.rowSpan()
100  << "," << aCluster.minPixelCol() << ","
101  << aCluster.minPixelCol() + aCluster.colSpan() << ")";
102  return;
103  }
104 
105  double invWeights = 1. / weights;
106  double avgLocalX = avgWLocalX * invWeights;
107  double avgLocalY = avgWLocalY * invWeights;
108 
109  double varianceX = weightedVarianceX * invWeights * invWeights;
110  double varianceY = weightedVarianceY * invWeights * invWeights;
111 
112  LocalPoint lp(avgLocalX, avgLocalY, 0);
113  LocalError le(varianceX, 0, varianceY);
114  if (verbosity_)
115  edm::LogInfo("PPS") << "RPixClusterToHit " << lp << " with error " << le;
116 
117  hits.emplace_back(lp,
118  le,
119  anEdgePixel,
120  aBadPixel,
121  twoRocs,
122  thisClusterMinRow,
123  thisClusterMinCol,
124  thisClusterSize,
125  thisClusterRowSize,
126  thisClusterColSize);
127 
128  return;
129 }
RPixClusterToHit::buildHits
void buildHits(unsigned int detId, const std::vector< CTPPSPixelCluster > &clusters, std::vector< CTPPSPixelRecHit > &hits, const PPSPixelTopology &ppt)
Definition: RPixClusterToHit.cc:9
mps_fire.i
i
Definition: mps_fire.py:428
CTPPSPixelCluster::pixelCol
unsigned int pixelCol(unsigned int i) const
Definition: CTPPSPixelCluster.h:99
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
RPixClusterToHit.h
CTPPSPixelCluster::size
unsigned int size() const
Definition: CTPPSPixelCluster.h:81
RPixClusterToHit::RPixClusterToHit
RPixClusterToHit(edm::ParameterSet const &conf)
Definition: RPixClusterToHit.cc:3
CTPPSPixelIndices::getDefaultColDetSize
int getDefaultColDetSize() const
Definition: CTPPSPixelIndices.h:323
CTPPSPixelCluster::minPixelRow
unsigned int minPixelRow() const
Definition: CTPPSPixelCluster.h:89
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
PPSPixelTopology::pixelRange
void pixelRange(unsigned int arow, unsigned int acol, double &lower_x, double &higher_x, double &lower_y, double &higher_y) const
Definition: PPSPixelTopology.cc:71
CTPPSPixelIndices
Definition: CTPPSPixelIndices.h:74
CTPPSPixelCluster::pixelRow
unsigned int pixelRow(unsigned int i) const
Definition: CTPPSPixelCluster.h:98
RPixClusterToHit::make_hit
void make_hit(CTPPSPixelCluster aCluster, std::vector< CTPPSPixelRecHit > &hits, const PPSPixelTopology &ppt)
Definition: RPixClusterToHit.cc:20
HLT_FULL_cff.weights
weights
Definition: HLT_FULL_cff.py:99207
Point3DBase< float, LocalTag >
CTPPSPixelIndices::getROCId
int getROCId(const int col, const int row) const
Definition: CTPPSPixelIndices.h:234
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
edm::ParameterSet
Definition: ParameterSet.h:47
LocalError
Definition: LocalError.h:12
CTPPSPixelCluster::pixelADC
const std::vector< uint16_t > & pixelADC() const
Definition: CTPPSPixelCluster.h:96
RPixClusterToHit::verbosity_
int verbosity_
Definition: RPixClusterToHit.h:29
createfilelist.int
int
Definition: createfilelist.py:10
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
PPSPixelTopology
Definition: PPSPixelTopology.h:22
CTPPSPixelCluster::sizeCol
unsigned int sizeCol() const
Definition: CTPPSPixelCluster.h:87
CTPPSPixelIndices::getDefaultRowDetSize
int getDefaultRowDetSize() const
Definition: CTPPSPixelIndices.h:322
CTPPSPixelCluster::colSpan
unsigned int colSpan() const
Definition: CTPPSPixelCluster.h:92
RPixClusterToHit::~RPixClusterToHit
~RPixClusterToHit()
Definition: RPixClusterToHit.cc:7
CTPPSPixelCluster::sizeRow
unsigned int sizeRow() const
Definition: CTPPSPixelCluster.h:84
CTPPSPixelCluster::rowSpan
unsigned int rowSpan() const
Definition: CTPPSPixelCluster.h:93
CTPPSPixelCluster
Definition: CTPPSPixelCluster.h:14
CTPPSPixelCluster::minPixelCol
unsigned int minPixelCol() const
Definition: CTPPSPixelCluster.h:90