|
|
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;
161 return std::make_unique<ClusterParamTemplate>(
cl);
172 ClusterParamTemplate& theClusterParam = static_cast<ClusterParamTemplate&>(theClusterParamBase);
173 bool filled_from_2d =
false;
176 throw cms::Exception(
"PixelCPEClusterRepair::localPosition :") <<
"A non-pixel detector type in here?";
203 float tmp_x =
float(row_offset) + 0.5f;
204 float tmp_y =
float(col_offset) + 0.5f;
213 edm::LogError(
"PixelCPEClusterRepair") <<
"@SUB = PixelCPEClusterRepair::localPosition"
214 <<
"Should never be here. PixelCPEClusterRepair should always be called "
215 "with track angles. This is a bad error !!! ";
221 int mrow = 0, mcol = 0;
224 int irow =
int(pix.x);
225 int icol =
int(pix.y);
231 mrow =
std::min(mrow, cluster_matrix_size_x);
234 mcol =
std::min(mcol, cluster_matrix_size_y);
239 bool xdouble[mrow], ydouble[mcol];
241 for (
int irow = 0; irow < mrow; ++irow)
245 for (
int icol = 0; icol < mcol; ++icol)
249 float clustMatrix[mrow][mcol];
250 float clustMatrix2[mrow][mcol];
257 memset(clustMatrix, 0,
sizeof(
float) * mrow * mcol);
260 int irow =
int(pix.x) - row_offset;
261 int icol =
int(pix.y) - col_offset;
263 if ((irow < mrow) & (icol < mcol))
264 clustMatrix[irow][icol] =
float(pix.adc);
269 memcpy(clustMatrix2, clustMatrix,
sizeof(
float) * mrow * mcol);
272 theClusterParam.
ierr = 0;
273 theClusterParam.
ierr2 = 0;
279 filled_from_2d =
true;
280 callTempReco2D(theDetParam, theClusterParam, clusterPayload2d, ID2, lp);
283 callTempReco1D(theDetParam, theClusterParam, clusterPayload, ID1, lp);
284 filled_from_2d =
false;
293 theClusterParamBase.
qBin_ = theClusterParam.
qBin_;
296 if (filled_from_2d) {
318 float nonsense = -99999.9f;
323 theClusterParam.
qBin_ = 0;
330 float locBz = theDetParam.
bz;
331 float locBx = theDetParam.
bx;
333 const bool deadpix =
false;
334 std::vector<std::pair<int, int>> zeropix;
335 int nypix = 0, nxpix = 0;
350 theClusterParam.
qBin_,
361 LogDebug(
"PixelCPEClusterRepair::localPosition")
362 <<
"reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
365 theClusterParam.
qBin_ = 0;
370 float lorentz_drift = -999.9;
372 lorentz_drift = 60.0f;
374 lorentz_drift = 10.0f;
379 lorentz_drift * micronsToCm;
383 edm::LogError(
"PixelCPEClusterRepair") <<
"@SUB = PixelCPEClusterRepair::localPosition"
384 <<
"Should never be here. PixelCPEClusterRepair should always be called "
385 "with track angles. This is a bad error !!! ";
388 lorentz_drift * micronsToCm;
417 float nonsense = -99999.9f;
422 theClusterParam.
qBin_ = 0;
429 float locBz = theDetParam.
bz;
430 float locBx = theDetParam.
bx;
451 if (clusterPayload.
mrow > 4) {
454 theClusterParam.
ierr2 = 8;
472 theClusterParam.
qBin_,
480 LogDebug(
"PixelCPEClusterRepair::localPosition")
481 <<
"2D reconstruction failed with error " << theClusterParam.
ierr2 <<
"\n";
484 theClusterParam.
qBin_ = 0;
487 float lorentz_drift = -999.9;
489 lorentz_drift = 60.0f;
491 lorentz_drift = 10.0f;
496 lorentz_drift * micronsToCm;
500 edm::LogError(
"PixelCPEClusterRepair") <<
"@SUB = PixelCPEClusterRepair::localPosition"
501 <<
"Should never be here. PixelCPEClusterRepair should always be called "
502 "with track angles. This is a bad error !!! ";
505 lorentz_drift * micronsToCm;
537 bool recommend =
false;
539 recommend = rec.recommend(
id,
ttopo_);
565 float nypix = clusterPayload.
mcol;
566 for (
int i = 0;
i < clusterPayload.
mcol;
i++) {
574 float nydiff = templ.
clsleny() - nypix;
602 if (min_col % 2 == 0) {
619 ClusterParamTemplate& theClusterParam = static_cast<ClusterParamTemplate&>(theClusterParamBase);
623 float xerr = 0.0f, yerr = 0.0f;
645 throw cms::Exception(
"PixelCPEClusterRepair::localPosition :") <<
"A non-pixel detector type in here?";
649 xerr = 55.0f * micronsToCm;
650 yerr = 36.0f * micronsToCm;
652 xerr = 42.0f * micronsToCm;
653 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
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_