CMS 3D CMS Logo

PixelCPEGenericBase.cc
Go to the documentation of this file.
3 
4 namespace {
5  constexpr float micronsToCm = 1.0e-4;
6  const auto convertDoubleVecToFloatVec = [](std::vector<double> const& iIn) {
7  return std::vector<float>(iIn.begin(), iIn.end());
8  };
9 } // namespace
10 
12  const MagneticField* mag,
13  const TrackerGeometry& geom,
14  const TrackerTopology& ttopo,
15  const SiPixelLorentzAngle* lorentzAngle,
16  const SiPixelGenErrorDBObject* genErrorDBObject,
17  const SiPixelLorentzAngle* lorentzAngleWidth = nullptr)
18  : PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, genErrorDBObject, nullptr, lorentzAngleWidth, 0),
19  edgeClusterErrorX_{static_cast<float>(conf.getParameter<double>("EdgeClusterErrorX"))},
20  edgeClusterErrorY_{static_cast<float>(conf.getParameter<double>("EdgeClusterErrorY"))},
21  useErrorsFromTemplates_{conf.getParameter<bool>("UseErrorsFromTemplates")},
22  truncatePixelCharge_{conf.getParameter<bool>("TruncatePixelCharge")},
23  xerr_barrel_l1_{convertDoubleVecToFloatVec(conf.getParameter<std::vector<double>>("xerr_barrel_l1"))},
24  yerr_barrel_l1_{convertDoubleVecToFloatVec(conf.getParameter<std::vector<double>>("yerr_barrel_l1"))},
25  xerr_barrel_ln_{convertDoubleVecToFloatVec(conf.getParameter<std::vector<double>>("xerr_barrel_ln"))},
26  yerr_barrel_ln_{convertDoubleVecToFloatVec(conf.getParameter<std::vector<double>>("yerr_barrel_ln"))},
27  xerr_endcap_{convertDoubleVecToFloatVec(conf.getParameter<std::vector<double>>("xerr_endcap"))},
28  yerr_endcap_{convertDoubleVecToFloatVec(conf.getParameter<std::vector<double>>("yerr_endcap"))},
29  xerr_barrel_l1_def_{static_cast<float>(conf.getParameter<double>("xerr_barrel_l1_def"))},
30  yerr_barrel_l1_def_{static_cast<float>(conf.getParameter<double>("yerr_barrel_l1_def"))},
31  xerr_barrel_ln_def_{static_cast<float>(conf.getParameter<double>("xerr_barrel_ln_def"))},
32  yerr_barrel_ln_def_{static_cast<float>(conf.getParameter<double>("yerr_barrel_ln_def"))},
33  xerr_endcap_def_{static_cast<float>(conf.getParameter<double>("xerr_endcap_def"))},
34  yerr_endcap_def_{static_cast<float>(conf.getParameter<double>("yerr_endcap_def"))} {};
35 
36 std::unique_ptr<PixelCPEBase::ClusterParam> PixelCPEGenericBase::createClusterParam(const SiPixelCluster& cl) const {
37  return std::make_unique<ClusterParamGeneric>(cl);
38 }
39 
40 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
46  int& q_f_X,
47  int& q_l_X,
48  int& q_f_Y,
49  int& q_l_Y,
50  bool truncate) {
51  ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
52 
53  // Initialize return variables.
54  q_f_X = q_l_X = 0;
55  q_f_Y = q_l_Y = 0;
56 
57  // Obtain boundaries in index units
58  int xmin = theClusterParam.theCluster->minPixelRow();
59  int xmax = theClusterParam.theCluster->maxPixelRow();
60  int ymin = theClusterParam.theCluster->minPixelCol();
61  int ymax = theClusterParam.theCluster->maxPixelCol();
62 
63  // Iterate over the pixels.
64  int isize = theClusterParam.theCluster->size();
65  for (int i = 0; i != isize; ++i) {
66  auto const& pixel = theClusterParam.theCluster->pixel(i);
67  // ggiurgiu@fnal.gov: add pixel charge truncation
68  int pix_adc = pixel.adc;
69  if (truncate)
70  pix_adc = std::min(pix_adc, theClusterParam.pixmx);
71 
72  //
73  // X projection
74  if (pixel.x == xmin)
75  q_f_X += pix_adc;
76  if (pixel.x == xmax)
77  q_l_X += pix_adc;
78  //
79  // Y projection
80  if (pixel.y == ymin)
81  q_f_Y += pix_adc;
82  if (pixel.y == ymax)
83  q_l_Y += pix_adc;
84  }
85 }
86 
88  float& xerr,
89  float& yerr,
90  bool& edgex,
91  bool& edgey,
92  bool& bigInX,
93  bool& bigInY,
94  int& maxPixelCol,
95  int& maxPixelRow,
96  int& minPixelCol,
97  int& minPixelRow,
98  uint& sizex,
99  uint& sizey,
100  DetParam const& theDetParam,
101  ClusterParamGeneric const& theClusterParam) const { // Default errors are the maximum error used for edge clusters.
102  // These are determined by looking at residuals for edge clusters
103  xerr = edgeClusterErrorX_ * micronsToCm;
104  yerr = edgeClusterErrorY_ * micronsToCm;
105 
106  // Find if cluster is at the module edge.
107  maxPixelCol = theClusterParam.theCluster->maxPixelCol();
108  maxPixelRow = theClusterParam.theCluster->maxPixelRow();
109  minPixelCol = theClusterParam.theCluster->minPixelCol();
110  minPixelRow = theClusterParam.theCluster->minPixelRow();
111 
112  edgex = (theDetParam.theRecTopol->isItEdgePixelInX(minPixelRow)) ||
113  (theDetParam.theRecTopol->isItEdgePixelInX(maxPixelRow));
114  edgey = (theDetParam.theRecTopol->isItEdgePixelInY(minPixelCol)) ||
115  (theDetParam.theRecTopol->isItEdgePixelInY(maxPixelCol));
116 
117  sizex = theClusterParam.theCluster->sizeX();
118  sizey = theClusterParam.theCluster->sizeY();
119 
120  // Find if cluster contains double (big) pixels.
121  bigInX = theDetParam.theRecTopol->containsBigPixelInX(minPixelRow, maxPixelRow);
122  bigInY = theDetParam.theRecTopol->containsBigPixelInY(minPixelCol, maxPixelCol);
123 };
124 
126  float& yerr,
127  const bool edgex,
128  const bool edgey,
129  const unsigned int sizex,
130  const unsigned int sizey,
131  const bool bigInX,
132  const bool bigInY,
133  const bool useTemplateErrors,
134  DetParam const& theDetParam,
135  ClusterParamGeneric const& theClusterParam) const {
136  if (useTemplateErrors) {
137  if (!edgex) { // Only use this for non-edge clusters
138  if (sizex == 1) {
139  if (!bigInX) {
140  xerr = theClusterParam.sx1;
141  } else {
142  xerr = theClusterParam.sx2;
143  }
144  } else {
145  xerr = theClusterParam.sigmax;
146  }
147  }
148 
149  if (!edgey) { // Only use for non-edge clusters
150  if (sizey == 1) {
151  if (!bigInY) {
152  yerr = theClusterParam.sy1;
153  } else {
154  yerr = theClusterParam.sy2;
155  }
156  } else {
157  yerr = theClusterParam.sigmay;
158  }
159  }
160 
161  } else { // simple errors
162 
163  if (GeomDetEnumerators::isTrackerPixel(theDetParam.thePart)) {
164  if (GeomDetEnumerators::isBarrel(theDetParam.thePart)) {
165  DetId id = (theDetParam.theDet->geographicalId());
166  int layer = ttopo_.layer(id);
167  if (layer == 1) {
168  if (!edgex) {
169  if (sizex <= xerr_barrel_l1_.size())
170  xerr = xerr_barrel_l1_[sizex - 1];
171  else
172  xerr = xerr_barrel_l1_def_;
173  }
174 
175  if (!edgey) {
176  if (sizey <= yerr_barrel_l1_.size())
177  yerr = yerr_barrel_l1_[sizey - 1];
178  else
179  yerr = yerr_barrel_l1_def_;
180  }
181  } else { // layer 2,3
182  if (!edgex) {
183  if (sizex <= xerr_barrel_ln_.size())
184  xerr = xerr_barrel_ln_[sizex - 1];
185  else
186  xerr = xerr_barrel_ln_def_;
187  }
188 
189  if (!edgey) {
190  if (sizey <= yerr_barrel_ln_.size())
191  yerr = yerr_barrel_ln_[sizey - 1];
192  else
193  yerr = yerr_barrel_ln_def_;
194  }
195  }
196 
197  } else { // EndCap
198 
199  if (!edgex) {
200  if (sizex <= xerr_endcap_.size())
201  xerr = xerr_endcap_[sizex - 1];
202  else
203  xerr = xerr_endcap_def_;
204  }
205 
206  if (!edgey) {
207  if (sizey <= yerr_endcap_.size())
208  yerr = yerr_endcap_[sizey - 1];
209  else
210  yerr = yerr_endcap_def_;
211  }
212  } // end endcap
213  }
214  }
215 }
216 
218  desc.add<std::vector<double>>("xerr_barrel_l1", {0.00115, 0.00120, 0.00088});
219  desc.add<std::vector<double>>("yerr_barrel_l1",
220  {0.00375, 0.00230, 0.00250, 0.00250, 0.00230, 0.00230, 0.00210, 0.00210, 0.00240});
221  desc.add<std::vector<double>>("xerr_barrel_ln", {0.00115, 0.00120, 0.00088});
222  desc.add<std::vector<double>>("yerr_barrel_ln",
223  {0.00375, 0.00230, 0.00250, 0.00250, 0.00230, 0.00230, 0.00210, 0.00210, 0.00240});
224  desc.add<std::vector<double>>("xerr_endcap", {0.0020, 0.0020});
225  desc.add<std::vector<double>>("yerr_endcap", {0.00210});
226  desc.add<double>("xerr_barrel_l1_def", 0.01030);
227  desc.add<double>("yerr_barrel_l1_def", 0.00210);
228  desc.add<double>("xerr_barrel_ln_def", 0.01030);
229  desc.add<double>("yerr_barrel_ln_def", 0.00210);
230  desc.add<double>("xerr_endcap_def", 0.0020);
231  desc.add<double>("yerr_endcap_def", 0.00075);
232 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
Pixel pixel(int i) const
const float yerr_barrel_l1_def_
const SiPixelCluster * theCluster
Definition: PixelCPEBase.h:76
const std::vector< float > yerr_barrel_ln_
int maxPixelRow() const
bool isBarrel(GeomDetEnumerators::SubDetector m)
const std::vector< float > xerr_barrel_ln_
int sizeY() const
const std::vector< float > yerr_barrel_l1_
static void collect_edge_charges(ClusterParam &theClusterParam, int &q_f_X, int &q_l_X, int &q_f_Y, int &q_l_Y, bool truncate)
bool containsBigPixelInY(int iymin, int iymax) const override
const std::vector< float > yerr_endcap_
const PixelGeomDetUnit * theDet
Definition: PixelCPEBase.h:47
GeomDetType::SubDetector thePart
Definition: PixelCPEBase.h:53
const RectangularPixelTopology * theRecTopol
Definition: PixelCPEBase.h:50
unsigned int layer(const DetId &id) const
int minPixelRow() const
bool containsBigPixelInX(int ixmin, int ixmax) const override
int minPixelCol() const
int maxPixelCol() const
int sizeX() const
const float edgeClusterErrorY_
const std::vector< float > xerr_endcap_
bool isItEdgePixelInY(int iybin) const override
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
static void fillPSetDescription(edm::ParameterSetDescription &desc)
const float xerr_barrel_l1_def_
PixelCPEGenericBase(edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const TrackerTopology &ttopo, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelLorentzAngle *lorentzAngleWidth)
const float yerr_barrel_ln_def_
Definition: DetId.h:17
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
bool isItEdgePixelInX(int ixbin) const override
const TrackerTopology & ttopo_
Definition: PixelCPEBase.h:231
void setXYErrors(float &xerr, float &yerr, const bool edgex, const bool edgey, const unsigned int sizex, const unsigned int sizey, const bool bigInX, const bool bigInY, const bool useTemplateErrors, DetParam const &theDetParam, ClusterParamGeneric const &theClusterParam) const
int size() const
const float xerr_barrel_ln_def_
const std::vector< float > xerr_barrel_l1_
Pixel cluster – collection of neighboring pixels above threshold.
const float edgeClusterErrorX_
std::unique_ptr< ClusterParam > createClusterParam(const SiPixelCluster &cl) const override
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
void initializeLocalErrorVariables(float &xerr, float &yerr, bool &edgex, bool &edgey, bool &bigInX, bool &bigInY, int &maxPixelCol, int &maxPixelRow, int &minPixelCol, int &minPixelRow, uint &sizex, uint &sizey, DetParam const &theDetParam, ClusterParamGeneric const &theClusterParam) const