CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
RPixClusterToHit Class Reference

#include <RPixClusterToHit.h>

Public Member Functions

void buildHits (unsigned int detId, const std::vector< CTPPSPixelCluster > &clusters, std::vector< CTPPSPixelRecHit > &hits)
 
void make_hit (CTPPSPixelCluster aCluster, std::vector< CTPPSPixelRecHit > &hits)
 
 RPixClusterToHit (edm::ParameterSet const &conf)
 
 ~RPixClusterToHit ()
 

Private Attributes

int verbosity_
 

Detailed Description

Definition at line 15 of file RPixClusterToHit.h.

Constructor & Destructor Documentation

RPixClusterToHit::RPixClusterToHit ( edm::ParameterSet const &  conf)

Definition at line 3 of file RPixClusterToHit.cc.

References edm::ParameterSet::getUntrackedParameter(), and verbosity_.

3  {
4  verbosity_ = conf.getUntrackedParameter<int>("RPixVerbosity");
5 }
RPixClusterToHit::~RPixClusterToHit ( )

Definition at line 7 of file RPixClusterToHit.cc.

7 {}

Member Function Documentation

void RPixClusterToHit::buildHits ( unsigned int  detId,
const std::vector< CTPPSPixelCluster > &  clusters,
std::vector< CTPPSPixelRecHit > &  hits 
)

Definition at line 9 of file RPixClusterToHit.cc.

References mps_fire::i, make_hit(), and verbosity_.

Referenced by CTPPSPixelRecHitProducer::run().

11  {
12  if (verbosity_)
13  edm::LogInfo("RPixClusterToHit") << " RPixClusterToHit " << detId
14  << " received cluster array of size = " << clusters.size();
15  for (unsigned int i = 0; i < clusters.size(); i++) {
17  }
18 }
void make_hit(CTPPSPixelCluster aCluster, std::vector< CTPPSPixelRecHit > &hits)
void RPixClusterToHit::make_hit ( CTPPSPixelCluster  aCluster,
std::vector< CTPPSPixelRecHit > &  hits 
)

Definition at line 20 of file RPixClusterToHit.cc.

References CTPPSPixelCluster::colSpan(), CTPPSPixelIndices::getDefaultColDetSize(), CTPPSPixelIndices::getDefaultRowDetSize(), CTPPSPixelIndices::getROCId(), mps_fire::i, createfilelist::int, CTPPSPixelCluster::minPixelCol(), CTPPSPixelCluster::minPixelRow(), CTPPSPixelCluster::pixelADC(), CTPPSPixelCluster::pixelCol(), CTPPSPixelSimTopology::pixelRange(), CTPPSPixelCluster::pixelRow(), CTPPSPixelCluster::rowSpan(), CTPPSPixelCluster::size(), CTPPSPixelCluster::sizeCol(), CTPPSPixelCluster::sizeRow(), ecaldqm::topology(), verbosity_, and HGCalRecHit_cfi::weights.

Referenced by buildHits().

20  {
21  // take a cluster, generate a rec hit and push it in the rec hit vector
22 
23  //call the topology
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("RPixClusterToHit") << " hit pixels: ";
71 
72  for (unsigned int i = 0; i < thisClusterSize; i++) {
73  if (verbosity_)
74  edm::LogInfo("RPixClusterToHit") << aCluster.pixelRow(i) << " " << aCluster.pixelCol(i) << " "
75  << aCluster.pixelADC(i);
76 
77  double minPxlX = 0;
78  double minPxlY = 0;
79  double maxPxlX = 0;
80  double maxPxlY = 0;
81  topology.pixelRange(aCluster.pixelRow(i), aCluster.pixelCol(i), minPxlX, maxPxlX, minPxlY, maxPxlY);
82  double halfSizeX = (maxPxlX - minPxlX) / 2.;
83  double halfSizeY = (maxPxlY - minPxlY) / 2.;
84  double avgPxlX = minPxlX + halfSizeX;
85  double avgPxlY = minPxlY + halfSizeY;
86  //error propagation
87  weightedVarianceX += aCluster.pixelADC(i) * aCluster.pixelADC(i) * halfSizeX * halfSizeX / 3.;
88  weightedVarianceY += aCluster.pixelADC(i) * aCluster.pixelADC(i) * halfSizeY * halfSizeY / 3.;
89 
90  avgWLocalX += avgPxlX * aCluster.pixelADC(i);
91  avgWLocalY += avgPxlY * aCluster.pixelADC(i);
92  weights += aCluster.pixelADC(i);
93  }
94 
95  if (weights == 0) {
96  edm::LogError("RPixClusterToHit") << " unexpected weights = 0 for cluster (Row_min, Row_max, Col_min, Col_max) = ("
97  << aCluster.minPixelRow() << "," << aCluster.minPixelRow() + aCluster.rowSpan()
98  << "," << aCluster.minPixelCol() << ","
99  << aCluster.minPixelCol() + aCluster.colSpan() << ")";
100  return;
101  }
102 
103  double invWeights = 1. / weights;
104  double avgLocalX = avgWLocalX * invWeights;
105  double avgLocalY = avgWLocalY * invWeights;
106 
107  double varianceX = weightedVarianceX * invWeights * invWeights;
108  double varianceY = weightedVarianceY * invWeights * invWeights;
109 
110  LocalPoint lp(avgLocalX, avgLocalY, 0);
111  LocalError le(varianceX, 0, varianceY);
112  CTPPSPixelRecHit rh(lp,
113  le,
114  anEdgePixel,
115  aBadPixel,
116  twoRocs,
117  thisClusterMinRow,
118  thisClusterMinCol,
119  thisClusterSize,
120  thisClusterRowSize,
121  thisClusterColSize);
122  if (verbosity_)
123  edm::LogInfo("RPixClusterToHit") << lp << " with error " << le;
124 
125  hits.push_back(rh);
126 
127  return;
128 }
CaloTopology const * topology(0)
unsigned int rowSpan() const
int getDefaultRowDetSize() const
unsigned int size() const
unsigned int colSpan() const
unsigned int minPixelCol() const
const std::vector< uint16_t > & pixelADC() const
int getDefaultColDetSize() const
int getROCId(const int col, const int row) const
unsigned int pixelRow(unsigned int i) const
unsigned int sizeCol() const
void pixelRange(unsigned int arow, unsigned int acol, double &lower_x, double &higher_x, double &lower_y, double &higher_y) const
unsigned int minPixelRow() const
unsigned int sizeRow() const
unsigned int pixelCol(unsigned int i) const

Member Data Documentation

int RPixClusterToHit::verbosity_
private

Definition at line 26 of file RPixClusterToHit.h.

Referenced by buildHits(), make_hit(), and RPixClusterToHit().