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 4 of file RPixClusterToHit.cc.

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

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

Definition at line 9 of file RPixClusterToHit.cc.

9 {}

Member Function Documentation

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

Definition at line 11 of file RPixClusterToHit.cc.

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

Referenced by CTPPSPixelRecHitProducer::run().

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

Definition at line 22 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 create_public_lumi_plots::weights.

Referenced by buildHits().

22  {
23 
24 // take a cluster, generate a rec hit and push it in the rec hit vector
25 
26 //call the topology
28 //call the numbering inside the ROC
29  CTPPSPixelIndices pxlInd;
30 // get information from the cluster
31 // get the whole cluster size and row/col size
32  unsigned int thisClusterSize = aCluster.size();
33  unsigned int thisClusterRowSize = aCluster.sizeRow();
34  unsigned int thisClusterColSize = aCluster.sizeCol();
35 
36 // get the minimum pixel row/col
37  unsigned int thisClusterMinRow = aCluster.minPixelRow();
38  unsigned int thisClusterMinCol = aCluster.minPixelCol();
39 
40 // calculate "on edge" flag
41  bool anEdgePixel = false;
42  if(aCluster.minPixelRow() == 0 || aCluster.minPixelCol() == 0 ||
43  int(aCluster.minPixelRow()+aCluster.rowSpan()) == (pxlInd.getDefaultRowDetSize()-1) ||
44  int(aCluster.minPixelCol()+aCluster.colSpan()) == (pxlInd.getDefaultColDetSize()-1) )
45  anEdgePixel = true;
46 
47 // check for bad (ADC=0) pixels in cluster
48  bool aBadPixel = false;
49  for(unsigned int i = 0; i < thisClusterSize; i++){
50  if(aCluster.pixelADC(i)==0) aBadPixel = true;
51  }
52 
53 // check for spanning two ROCs
54  bool twoRocs = false;
55  int currROCId = pxlInd.getROCId(aCluster.pixelCol(0),aCluster.pixelRow(0) );
56 
57  for(unsigned int i = 1; i < thisClusterSize; i++){
58  if(pxlInd.getROCId(aCluster.pixelCol(i),aCluster.pixelRow(i) ) != currROCId){
59  twoRocs = true;
60  break;
61  }
62  }
63 
64 //estimate position and error of the hit
65  double avgWLocalX = 0;
66  double avgWLocalY = 0;
67  double weights = 0;
68  double weightedVarianceX = 0.;
69  double weightedVarianceY = 0.;
70 
71  if(verbosity_)
72  edm::LogInfo("RPixClusterToHit") << " hit pixels: ";
73 
74  for(unsigned int i = 0; i < thisClusterSize; i++){
75 
76  if(verbosity_)edm::LogInfo("RPixClusterToHit") << aCluster.pixelRow(i) << " " << aCluster.pixelCol(i)<<" " << aCluster.pixelADC(i);
77 
78  double minPxlX = 0;
79  double minPxlY = 0;
80  double maxPxlX = 0;
81  double maxPxlY = 0;
82  topology.pixelRange(aCluster.pixelRow(i),aCluster.pixelCol(i),minPxlX,maxPxlX,minPxlY, maxPxlY);
83  double halfSizeX = (maxPxlX-minPxlX)/2.;
84  double halfSizeY = (maxPxlY-minPxlY)/2.;
85  double avgPxlX = minPxlX + halfSizeX;
86  double avgPxlY = minPxlY + halfSizeY;
87 //error propagation
88  weightedVarianceX += aCluster.pixelADC(i)*aCluster.pixelADC(i)*halfSizeX*halfSizeX/3.;
89  weightedVarianceY += aCluster.pixelADC(i)*aCluster.pixelADC(i)*halfSizeY*halfSizeY/3.;
90 
91  avgWLocalX += avgPxlX*aCluster.pixelADC(i);
92  avgWLocalY += avgPxlY*aCluster.pixelADC(i);
93  weights += aCluster.pixelADC(i);
94 
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() << ","
100  << aCluster.minPixelRow()+aCluster.rowSpan() << ","
101  << aCluster.minPixelCol() << ","
102  << aCluster.minPixelCol()+aCluster.colSpan()
103  << ")";
104  return;
105  }
106 
107  double invWeights = 1./weights;
108  double avgLocalX = avgWLocalX*invWeights;
109  double avgLocalY = avgWLocalY*invWeights;
110 
111  double varianceX = weightedVarianceX*invWeights*invWeights;
112  double varianceY = weightedVarianceY*invWeights*invWeights;
113 
114  LocalPoint lp(avgLocalX,avgLocalY,0);
115  LocalError le(varianceX,0,varianceY);
116  CTPPSPixelRecHit rh(lp,le,anEdgePixel,aBadPixel,twoRocs,thisClusterMinRow,thisClusterMinCol,thisClusterSize,thisClusterRowSize,thisClusterColSize);
117  if(verbosity_)edm::LogInfo("RPixClusterToHit") << lp << " with error " << le ;
118 
119  hits.push_back(rh);
120 
121  return;
122 
123 }
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 27 of file RPixClusterToHit.h.

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