|
|
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_,
366 LogDebug(
"PixelCPEClusterRepair::localPosition")
367 <<
"reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
370 theClusterParam.
qBin_ = 0;
375 float lorentz_drift = -999.9;
377 lorentz_drift = 60.0f;
379 lorentz_drift = 10.0f;
384 lorentz_drift * micronsToCm;
388 edm::LogError(
"PixelCPEClusterRepair") <<
"@SUB = PixelCPEClusterRepair::localPosition"
389 <<
"Should never be here. PixelCPEClusterRepair should always be called "
390 "with track angles. This is a bad error !!! ";
393 lorentz_drift * micronsToCm;
422 float nonsense = -99999.9f;
427 theClusterParam.
qBin_ = 0;
434 float locBz = theDetParam.
bz;
435 float locBx = theDetParam.
bx;
456 if (clusterPayload.
mrow > 4) {
459 theClusterParam.
ierr2 = 8;
477 theClusterParam.
qBin_,
485 LogDebug(
"PixelCPEClusterRepair::localPosition")
486 <<
"2D reconstruction failed with error " << theClusterParam.
ierr2 <<
"\n";
489 theClusterParam.
qBin_ = 0;
492 float lorentz_drift = -999.9;
494 lorentz_drift = 60.0f;
496 lorentz_drift = 10.0f;
501 lorentz_drift * micronsToCm;
505 edm::LogError(
"PixelCPEClusterRepair") <<
"@SUB = PixelCPEClusterRepair::localPosition"
506 <<
"Should never be here. PixelCPEClusterRepair should always be called "
507 "with track angles. This is a bad error !!! ";
510 lorentz_drift * micronsToCm;
542 bool recommend =
false;
544 recommend = rec.recommend(
id,
ttopo_);
570 float nypix = clusterPayload.
mcol;
571 for (
int i = 0;
i < clusterPayload.
mcol;
i++) {
579 float nydiff = templ.
clsleny() - nypix;
607 if (min_col % 2 == 0) {
624 ClusterParamTemplate& theClusterParam = static_cast<ClusterParamTemplate&>(theClusterParamBase);
628 float xerr = 0.0f, yerr = 0.0f;
650 throw cms::Exception(
"PixelCPEClusterRepair::localPosition :") <<
"A non-pixel detector type in here?";
654 xerr = 55.0f * micronsToCm;
655 yerr = 36.0f * micronsToCm;
657 xerr = 42.0f * micronsToCm;
658 yerr = 39.0f * micronsToCm;
687 <<
" Edgey = " << theClusterParam.
edgeTypeY_ <<
" ErrX = " << xerr
688 <<
" ErrY = " << yerr;
693 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
697 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
699 return LocalError(xerr * xerr, 0, yerr * yerr);
703 static const boost::regex rule(
"([A-Z]+)(\\s+(\\d+))?");
706 if (!regex_match(
str.c_str(),
match, rule))
707 throw cms::Exception(
"Configuration") <<
"Rule '" <<
str <<
"' not understood.\n";
713 else if (strncmp(
match[1].
first,
"PXE", 3) == 0)
717 <<
"Detector '" <<
match[1].first <<
"' not understood. Should be PXB, PXE.\n";
728 desc.add<
int>(
"barrelTemplateID", 0);
729 desc.add<
int>(
"forwardTemplateID", 0);
730 desc.add<
int>(
"directoryWithTemplates", 0);
731 desc.add<
int>(
"speed", -2);
732 desc.add<
bool>(
"UseClusterSplitter",
false);
733 desc.add<
double>(
"MaxSizeMismatchInY", 0.3);
734 desc.add<
double>(
"MinChargeRatio", 0.8);
735 desc.add<std::vector<std::string>>(
"Recommend2D", {
"PXB 2",
"PXB 3",
"PXB 4"});
736 desc.add<
bool>(
"RunDamagedClusters",
false);
const PixelTopology * theTopol
static constexpr float bothEdgeYError_
const SiPixelTemplateDBObject * templateDBobject_
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
static constexpr float bothEdgeXError_
Log< level::Warning, false > LogWarning
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_
float getSplitClusterErrorX() const
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
static constexpr float xEdgeXError_
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
float getSplitClusterErrorY() const
Log< level::Error, false > LogError
bool LoadTemplatesFromDB_
GeomDetType::SubDetector thePart
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
static constexpr float yEdgeYError_
virtual float localY(float mpY) const =0
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Topology::LocalTrackPred loc_trk_pred
~PixelCPEClusterRepair() override
T getParameter(std::string const &) const
static constexpr float clusterSplitMaxError_
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
static constexpr float xEdgeYError_
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_
static constexpr float yEdgeXError_