|
|
Go to the documentation of this file.
18 #include "boost/multi_array.hpp"
19 #include <boost/regex.hpp>
29 constexpr
float micronsToCm = 1.0e-4;
30 constexpr
int cluster_matrix_size_x = 13;
31 constexpr
int cluster_matrix_size_y = 21;
45 :
PixelCPEBase(conf,
mag,
geom, ttopo, lorentzAngle, nullptr, templateDBobject, nullptr, 1) {
46 LogDebug(
"PixelCPEClusterRepair::(constructor)") << endl;
53 <<
"\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
54 << (*templateDBobject_).version() <<
"\n\n";
59 <<
"\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject2D version "
60 << (*templateDBobject2D).version() <<
"\n\n";
62 LogDebug(
"PixelCPEClusterRepair") <<
"Loading templates for barrel and forward from ASCII files." << endl;
72 <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
77 <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
81 LogDebug(
"PixelCPEClusterRepair::PixelCPEClusterRepair:") <<
"Template speed = " <<
speed_ <<
"\n";
84 int theMagField =
mag->nominalValue();
86 if (theMagField >= 36 && theMagField < 39) {
87 LogDebug(
"PixelCPEClusterRepair::PixelCPEClusterRepair:")
88 <<
"Magnetic field value is: " << theMagField <<
" kgauss. Algorithm is being run \n";
103 std::vector<std::string> str_recommend2D = conf.
getParameter<std::vector<std::string>>(
"Recommend2D");
105 for (
auto&
str : str_recommend2D) {
110 if (theMagField < 36 || theMagField > 39) {
123 unsigned m_detectors = dus.size();
124 for (
unsigned int i = 1;
i < 7; ++
i) {
125 LogDebug(
"PixelCPEClusterRepair:: LookingForFirstStrip")
137 LogDebug(
"LookingForFirstStrip") <<
" Chosen offset: " << m_detectors;
140 LogDebug(
"PixelCPEClusterRepair::fillDetParams():") <<
"caching " << m_detectors <<
" pixel detectors" << endl;
142 bool printed_info =
false;
143 for (
unsigned i = 0;
i != m_detectors; ++
i) {
147 if (
p.detTemplateId !=
p.detTemplateId2D && !printed_info) {
149 <<
"different template ID between 1D and 2D " <<
p.detTemplateId <<
" " <<
p.detTemplateId2D << endl;
166 return std::make_unique<ClusterParamTemplate>(
cl);
177 ClusterParamTemplate& theClusterParam = static_cast<ClusterParamTemplate&>(theClusterParamBase);
178 bool filled_from_2d =
false;
181 throw cms::Exception(
"PixelCPEClusterRepair::localPosition :") <<
"A non-pixel detector type in here?";
208 float tmp_x =
float(row_offset) + 0.5f;
209 float tmp_y =
float(col_offset) + 0.5f;
218 edm::LogError(
"PixelCPEClusterRepair") <<
"@SUB = PixelCPEClusterRepair::localPosition"
219 <<
"Should never be here. PixelCPEClusterRepair should always be called "
220 "with track angles. This is a bad error !!! ";
226 int mrow = 0, mcol = 0;
229 int irow =
int(pix.x);
230 int icol =
int(pix.y);
236 mrow =
std::min(mrow, cluster_matrix_size_x);
239 mcol =
std::min(mcol, cluster_matrix_size_y);
244 bool xdouble[mrow], ydouble[mcol];
246 for (
int irow = 0; irow < mrow; ++irow)
250 for (
int icol = 0; icol < mcol; ++icol)
254 float clustMatrix[mrow][mcol];
255 float clustMatrix2[mrow][mcol];
262 memset(clustMatrix, 0,
sizeof(
float) * mrow * mcol);
265 int irow =
int(pix.x) - row_offset;
266 int icol =
int(pix.y) - col_offset;
268 if ((irow < mrow) & (icol < mcol))
269 clustMatrix[irow][icol] =
float(pix.adc);
274 memcpy(clustMatrix2, clustMatrix,
sizeof(
float) * mrow * mcol);
277 theClusterParam.
ierr = 0;
278 theClusterParam.
ierr2 = 0;
284 filled_from_2d =
true;
285 callTempReco2D(theDetParam, theClusterParam, clusterPayload2d, ID2, lp);
288 callTempReco1D(theDetParam, theClusterParam, clusterPayload, ID1, lp);
289 filled_from_2d =
false;
298 theClusterParamBase.
qBin_ = theClusterParam.
qBin_;
301 if (filled_from_2d) {
323 float nonsense = -99999.9f;
328 theClusterParam.
qBin_ = 0;
335 float locBz = theDetParam.
bz;
336 float locBx = theDetParam.
bx;
338 const bool deadpix =
false;
339 std::vector<std::pair<int, int>> zeropix;
340 int nypix = 0, nxpix = 0;
355 theClusterParam.
qBin_,
367 LogDebug(
"PixelCPEClusterRepair::localPosition")
368 <<
"reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
371 theClusterParam.
qBin_ = 0;
376 float lorentz_drift = -999.9;
378 lorentz_drift = 60.0f;
380 lorentz_drift = 10.0f;
385 lorentz_drift * micronsToCm;
389 edm::LogError(
"PixelCPEClusterRepair") <<
"@SUB = PixelCPEClusterRepair::localPosition"
390 <<
"Should never be here. PixelCPEClusterRepair should always be called "
391 "with track angles. This is a bad error !!! ";
394 lorentz_drift * micronsToCm;
424 float nonsense = -99999.9f;
429 theClusterParam.
qBin_ = 0;
436 float locBz = theDetParam.
bz;
437 float locBx = theDetParam.
bx;
458 if (clusterPayload.
mrow > 4) {
461 theClusterParam.
ierr2 = 8;
479 theClusterParam.
qBin_,
488 LogDebug(
"PixelCPEClusterRepair::localPosition")
489 <<
"2D reconstruction failed with error " << theClusterParam.
ierr2 <<
"\n";
492 theClusterParam.
qBin_ = 0;
495 float lorentz_drift = -999.9;
497 lorentz_drift = 60.0f;
499 lorentz_drift = 10.0f;
504 lorentz_drift * micronsToCm;
508 edm::LogError(
"PixelCPEClusterRepair") <<
"@SUB = PixelCPEClusterRepair::localPosition"
509 <<
"Should never be here. PixelCPEClusterRepair should always be called "
510 "with track angles. This is a bad error !!! ";
513 lorentz_drift * micronsToCm;
546 bool recommend =
false;
548 recommend = rec.recommend(
id,
ttopo_);
574 float nypix = clusterPayload.
mcol;
575 for (
int i = 0;
i < clusterPayload.
mcol;
i++) {
583 float nydiff = templ.
clsleny() - nypix;
611 if (min_col % 2 == 0) {
628 ClusterParamTemplate& theClusterParam = static_cast<ClusterParamTemplate&>(theClusterParamBase);
632 float xerr = 0.0f, yerr = 0.0f;
642 throw cms::Exception(
"PixelCPEClusterRepair::localPosition :") <<
"A non-pixel detector type in here?";
646 xerr = 55.0f * micronsToCm;
647 yerr = 36.0f * micronsToCm;
649 xerr = 42.0f * micronsToCm;
650 yerr = 39.0f * micronsToCm;
682 <<
" Edgey = " << theClusterParam.
edgeTypeY_ <<
" ErrX = " << xerr
683 <<
" ErrY = " << yerr;
688 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
692 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
694 return LocalError(xerr * xerr, 0, yerr * yerr);
698 static const boost::regex rule(
"([A-Z]+)(\\s+(\\d+))?");
701 if (!regex_match(
str.c_str(),
match, rule))
702 throw cms::Exception(
"Configuration") <<
"Rule '" <<
str <<
"' not understood.\n";
708 else if (strncmp(
match[1].
first,
"PXE", 3) == 0)
712 <<
"Detector '" <<
match[1].first <<
"' not understood. Should be PXB, PXE.\n";
723 desc.
add<
int>(
"barrelTemplateID", 0);
724 desc.
add<
int>(
"forwardTemplateID", 0);
725 desc.
add<
int>(
"directoryWithTemplates", 0);
726 desc.
add<
int>(
"speed", -2);
727 desc.
add<
bool>(
"UseClusterSplitter",
false);
728 desc.
add<
double>(
"MaxSizeMismatchInY", 0.3);
729 desc.
add<
double>(
"MinChargeRatio", 0.8);
730 desc.
add<std::vector<std::string>>(
"Recommend2D", {
"PXB 2",
"PXB 3",
"PXB 4"});
731 desc.
add<
bool>(
"RunDamagedClusters",
false);
const PixelTopology * theTopol
const SiPixelTemplateDBObject * templateDBobject_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
float qavg()
average cluster charge for this set of track angles
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
const RectangularPixelTopology * theRecTopol
const SiPixel2DTemplateDBObject * templateDBobject2D_
const TrackerTopology & ttopo_
float maxSizeMismatchInY_
int PixelTempReco1D(int id, float cotalpha, float cotbeta, float locBz, float locBx, ClusMatrix &cluster, SiPixelTemplate &templ, float &yrec, float &sigmay, float &proby, float &xrec, float &sigmax, float &probx, int &qbin, int speed, bool deadpix, std::vector< std::pair< int, int > > &zeropix, float &probQ, int &nypix, int &nxpix)
U second(std::pair< T, U > const &p)
void callTempReco1D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
const TrackerGeometry & geom_
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
void callTempReco2D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco2D::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
Pixel cluster – collection of neighboring pixels above threshold.
Point3DBase< Scalar, LocalTag > LocalPoint
const PixelGeomDetUnit * theDet
PixelCPEClusterRepair(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *, const SiPixel2DTemplateDBObject *)
const SiPixelCluster * theCluster
bool isItBigPixelInY(const int iybin) const override
std::vector< SiPixelTemplateStore > thePixelTemp_
bool isItBigPixelInX(const int ixbin) const override
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
constexpr SubDetector tkDetEnum[8]
Rule(const std::string &str)
std::unique_ptr< ClusterParam > createClusterParam(const SiPixelCluster &cl) const override
void checkRecommend2D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco::ClusMatrix &clusterPayload, int ID) const
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
DetId geographicalId() const
The label of this GeomDet.
short getTemplateID(const uint32_t &detid) const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
bool isBarrel(GeomDetEnumerators::SubDetector m)
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
bool LoadTemplatesFromDB_
GeomDetType::SubDetector thePart
T getParameter(std::string const &) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
virtual float localY(float mpY) const =0
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Topology::LocalTrackPred loc_trk_pred
~PixelCPEClusterRepair() override
virtual float localX(float mpX) const =0
int PixelTempReco2D(int id, float cotalpha, float cotbeta, float locBz, float locBx, int edgeflagy, int edgeflagx, ClusMatrix &cluster, SiPixelTemplate2D &templ, float &yrec, float &sigmay, float &xrec, float &sigmax, float &probxy, float &probQ, int &qbin, float &deltay, int &npixel)
float clsleny()
y-size of smaller interpolated template in pixels
unsigned int offsetDU(SubDetector sid) const
bool isEndcap(GeomDetEnumerators::SubDetector m)
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
std::vector< SiPixelTemplateStore2D > thePixelTemp2D_
bool interpolate(int id, float cotalpha, float cotbeta, float locBz, float locBx)
std::vector< Rule > recommend2D_