CMS 3D CMS Logo

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