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 }
SiPixelCluster::minPixelCol
int minPixelCol() const
Definition: SiPixelCluster.h:152
PixelCPEGenericBase::yerr_barrel_l1_
const std::vector< float > yerr_barrel_l1_
Definition: PixelCPEGenericBase.h:90
PixelCPEBase::ClusterParam
Definition: PixelCPEBase.h:69
mps_fire.i
i
Definition: mps_fire.py:428
PixelCPEGenericBase::ClusterParamGeneric::sy2
float sy2
Definition: PixelCPEGenericBase.h:22
PixelCPEGenericBase::PixelCPEGenericBase
PixelCPEGenericBase(edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const TrackerTopology &ttopo, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelLorentzAngle *lorentzAngleWidth)
Definition: PixelCPEGenericBase.cc:11
RectangularPixelTopology.h
PixelCPEBase::DetParam::theRecTopol
const RectangularPixelTopology * theRecTopol
Definition: PixelCPEBase.h:50
min
T min(T a, T b)
Definition: MathUtil.h:58
TrackerTopology
Definition: TrackerTopology.h:16
PixelCPEGenericBase::yerr_barrel_l1_def_
const float yerr_barrel_l1_def_
Definition: PixelCPEGenericBase.h:92
PixelCPEGenericBase::ClusterParamGeneric::sx1
float sx1
Definition: PixelCPEGenericBase.h:23
PixelCPEBase::ttopo_
const TrackerTopology & ttopo_
Definition: PixelCPEBase.h:230
SiPixelCluster::maxPixelCol
int maxPixelCol() const
Definition: SiPixelCluster.h:153
PixelCPEGenericBase::ClusterParamGeneric::pixmx
int pixmx
Definition: PixelCPEGenericBase.h:16
PixelCPEGenericBase::initializeLocalErrorVariables
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
Definition: PixelCPEGenericBase.cc:87
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PixelCPEGenericBase::ClusterParamGeneric::sy1
float sy1
Definition: PixelCPEGenericBase.h:21
PixelCPEGenericBase::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Definition: PixelCPEGenericBase.cc:217
muonClassificationByHits_cfi.pixel
pixel
Definition: muonClassificationByHits_cfi.py:9
SiPixelCluster::maxPixelRow
int maxPixelRow() const
Definition: SiPixelCluster.h:151
TrackerTopology::layer
unsigned int layer(const DetId &id) const
Definition: TrackerTopology.cc:47
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:28
RectangularPixelTopology::containsBigPixelInY
bool containsBigPixelInY(int iymin, int iymax) const override
Definition: RectangularPixelTopology.h:137
PixelCPEGenericBase::yerr_endcap_def_
const float yerr_endcap_def_
Definition: PixelCPEGenericBase.h:93
PixelCPEGenericBase::xerr_barrel_ln_def_
const float xerr_barrel_ln_def_
Definition: PixelCPEGenericBase.h:92
PixelCPEGenericBase::edgeClusterErrorX_
const float edgeClusterErrorX_
Definition: PixelCPEGenericBase.h:84
PixelCPEGenericBase::ClusterParamGeneric::sigmax
float sigmax
Definition: PixelCPEGenericBase.h:20
parallelization.uint
uint
Definition: parallelization.py:124
PixelCPEBase::DetParam::theDet
const PixelGeomDetUnit * theDet
Definition: PixelCPEBase.h:47
PixelCPEGenericBase::ClusterParamGeneric
Definition: PixelCPEGenericBase.h:9
PixelCPEBase::ClusterParam::theCluster
const SiPixelCluster * theCluster
Definition: PixelCPEBase.h:75
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
DetId
Definition: DetId.h:17
RectangularPixelTopology::containsBigPixelInX
bool containsBigPixelInX(int ixmin, int ixmax) const override
Definition: RectangularPixelTopology.h:134
SiPixelCluster::sizeY
int sizeY() const
Definition: SiPixelCluster.h:140
PixelCPEGenericBase::collect_edge_charges
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)
Definition: PixelCPEGenericBase.cc:45
L1TOccupancyClient_cfi.ymax
ymax
Definition: L1TOccupancyClient_cfi.py:43
SiPixelCluster::minPixelRow
int minPixelRow() const
Definition: SiPixelCluster.h:150
SiPixelLorentzAngle
Definition: SiPixelLorentzAngle.h:11
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
PixelCPEGenericBase::xerr_barrel_l1_def_
const float xerr_barrel_l1_def_
Definition: PixelCPEGenericBase.h:92
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
PixelCPEGenericBase::ClusterParamGeneric::sx2
float sx2
Definition: PixelCPEGenericBase.h:24
RectangularPixelTopology::isItEdgePixelInX
bool isItEdgePixelInX(int ixbin) const override
Definition: RectangularPixelTopology.h:145
PixelCPEGenericBase::xerr_barrel_l1_
const std::vector< float > xerr_barrel_l1_
Definition: PixelCPEGenericBase.h:90
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
edm::ParameterSet
Definition: ParameterSet.h:47
PixelCPEGenericBase.h
PixelCPEGenericBase::xerr_endcap_def_
const float xerr_endcap_def_
Definition: PixelCPEGenericBase.h:93
GeomDetEnumerators::isTrackerPixel
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
Definition: GeomDetEnumerators.cc:68
PixelCPEGenericBase::xerr_barrel_ln_
const std::vector< float > xerr_barrel_ln_
Definition: PixelCPEGenericBase.h:90
GeomDetEnumerators::isBarrel
bool isBarrel(GeomDetEnumerators::SubDetector m)
Definition: GeomDetEnumerators.cc:57
PixelCPEGenericBase::edgeClusterErrorY_
const float edgeClusterErrorY_
Definition: PixelCPEGenericBase.h:85
SiPixelCluster::size
int size() const
Definition: SiPixelCluster.h:134
SiPixelCluster::pixel
Pixel pixel(int i) const
Definition: SiPixelCluster.h:170
PixelCPEGenericBase::createClusterParam
std::unique_ptr< ClusterParam > createClusterParam(const SiPixelCluster &cl) const override
Definition: PixelCPEGenericBase.cc:36
PixelCPEBase::DetParam::thePart
GeomDetType::SubDetector thePart
Definition: PixelCPEBase.h:52
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
PixelCPEBase::DetParam
Definition: PixelCPEBase.h:45
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
RectangularPixelTopology::isItEdgePixelInY
bool isItEdgePixelInY(int iybin) const override
Definition: RectangularPixelTopology.h:146
L1TOccupancyClient_cfi.ymin
ymin
Definition: L1TOccupancyClient_cfi.py:43
PixelCPEGenericBase::ClusterParamGeneric::sigmay
float sigmay
Definition: PixelCPEGenericBase.h:19
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
PixelCPEBase
Definition: PixelCPEBase.h:43
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PixelCPEGenericBase::setXYErrors
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
Definition: PixelCPEGenericBase.cc:125
SiPixelGenErrorDBObject
Definition: SiPixelGenErrorDBObject.h:16
PixelCPEGenericBase::xerr_endcap_
const std::vector< float > xerr_endcap_
Definition: PixelCPEGenericBase.h:91
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
SiPixelCluster::sizeX
int sizeX() const
Definition: SiPixelCluster.h:137
PixelCPEGenericBase::yerr_barrel_ln_
const std::vector< float > yerr_barrel_ln_
Definition: PixelCPEGenericBase.h:91
PixelCPEGenericBase::yerr_endcap_
const std::vector< float > yerr_endcap_
Definition: PixelCPEGenericBase.h:91
MagneticField
Definition: MagneticField.h:19
TrackerGeometry
Definition: TrackerGeometry.h:14
PixelCPEGenericBase::yerr_barrel_ln_def_
const float yerr_barrel_ln_def_
Definition: PixelCPEGenericBase.h:93