20 #include "boost/multi_array.hpp" 21 #include <boost/regex.hpp> 49 LogDebug(
"PixelCPEClusterRepair::(constructor)") << endl;
57 <<
"\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " 58 << (*templateDBobject_).version() <<
"\n\n";
63 <<
"\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject2D version " 64 << (*templateDBobject2D).version() <<
"\n\n";
68 LogDebug(
"PixelCPEClusterRepair") <<
"Loading templates for barrel and forward from ASCII files." << endl;
77 <<
"\nERROR: Template ID " <<
barrelTemplateID_ <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
81 <<
"\nERROR: Template ID " << forwardTemplateID_ <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
85 LogDebug(
"PixelCPEClusterRepair::PixelCPEClusterRepair:") <<
86 "Template speed = " <<
speed_ <<
"\n";
89 float theMagField = mag->
inTesla(center).
mag();
91 if(theMagField>=3.65 && theMagField<3.9){
106 std::vector<std::string> str_recommend2D = conf.
getParameter<std::vector<std::string> >(
"Recommend2D");
108 for (
auto &
str: str_recommend2D){
113 if(theMagField<3.65 || theMagField > 3.9){
127 unsigned m_detectors = dus.size();
128 for(
unsigned int i=1;
i<7;++
i) {
129 LogDebug(
"PixelCPEClusterRepair:: LookingForFirstStrip") <<
"Subdetector " <<
i 139 LogDebug(
"LookingForFirstStrip") <<
" Chosen offset: " << m_detectors;
143 LogDebug(
"PixelCPEClusterRepair::fillDetParams():") <<
"caching "<<m_detectors<<
" pixel detectors"<<endl;
145 bool printed_info =
false;
146 for (
unsigned i=0;
i!=m_detectors;++
i) {
150 if(
p.detTemplateId !=
p.detTemplateId2D && !printed_info){
151 edm::LogWarning(
"PixelCPEClusterRepair") <<
"different template ID between 1D and 2D " <<
p.detTemplateId <<
" " <<
p.detTemplateId2D << endl;
188 bool filled_from_2d =
false;
192 <<
"A non-pixel detector type in here?";
234 <<
"@SUB = PixelCPEClusterRepair::localPosition" 235 <<
"Should never be here. PixelCPEClusterRepair should always be called with track angles. This is a bad error !!! ";
245 int irow =
int(pix.x);
246 int icol =
int(pix.y);
250 mrow -= row_offset; mrow+=1; mrow =
std::min(mrow,cluster_matrix_size_x);
251 mcol -= col_offset; mcol+=1; mcol =
std::min(mcol,cluster_matrix_size_y);
252 assert(mrow>0); assert(mcol>0);
256 bool xdouble[mrow], ydouble[mcol];
258 for (
int irow = 0; irow < mrow; ++irow)
262 for (
int icol = 0; icol < mcol; ++icol)
266 float clustMatrix[mrow][mcol];
267 float clustMatrix2[mrow][mcol];
275 memset( clustMatrix, 0,
sizeof(
float)*mrow*mcol );
279 int irow =
int(pix.x) - row_offset;
280 int icol =
int(pix.y) - col_offset;
282 if ( (irow<mrow) & (icol<mcol) ) clustMatrix[irow][icol] =
float(pix.adc);
287 memcpy( clustMatrix2, clustMatrix,
sizeof(
float)*mrow*mcol);
290 theClusterParam.
ierr = 0;
291 theClusterParam.
ierr2 = 0;
299 filled_from_2d =
true;
300 callTempReco2D( theDetParam, theClusterParam, clusterPayload2d, ID2, lp );
304 callTempReco1D( theDetParam, theClusterParam, clusterPayload, ID1, lp );
305 filled_from_2d =
false;
314 theClusterParamBase.
qBin_ = theClusterParam.
qBin_;
344 float nonsense = -99999.9f;
348 theClusterParam.
qBin_ = 0;
355 float locBz = theDetParam.
bz;
356 float locBx = theDetParam.
bx;
358 const bool deadpix =
false;
359 std::vector<std::pair<int, int> > zeropix;
360 int nypix =0, nxpix = 0;
362 theClusterParam.
ierr =
369 theClusterParam.
qBin_,
378 LogDebug(
"PixelCPEClusterRepair::localPosition") <<
379 "reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
382 theClusterParam.
qBin_ = 0;
387 float lorentz_drift = -999.9;
389 lorentz_drift = 60.0f;
391 lorentz_drift = 10.0f;
401 <<
"@SUB = PixelCPEClusterRepair::localPosition" 402 <<
"Should never be here. PixelCPEClusterRepair should always be called with track angles. This is a bad error !!! ";
442 float nonsense = -99999.9f;
446 theClusterParam.
qBin_ = 0;
453 float locBz = theDetParam.
bz;
454 float locBx = theDetParam.
bx;
477 if(clusterPayload.
mrow > 4){
480 theClusterParam.
ierr2 = 8;
484 theClusterParam.
ierr2 =
494 theClusterParam.
qBin_,
503 LogDebug(
"PixelCPEClusterRepair::localPosition") <<
504 "2D reconstruction failed with error " << theClusterParam.
ierr2 <<
"\n";
507 theClusterParam.
qBin_ = 0;
510 float lorentz_drift = -999.9;
512 lorentz_drift = 60.0f;
514 lorentz_drift = 10.0f;
524 <<
"@SUB = PixelCPEClusterRepair::localPosition" 525 <<
"Should never be here. PixelCPEClusterRepair should always be called with track angles. This is a bad error !!! ";
559 bool recommend =
false;
561 recommend = rec.recommend(
id,
ttopo_);
587 float nypix = clusterPayload.
mcol;
588 for(
int i=0;
i<clusterPayload.
mcol;
i++){
589 if(clusterPayload.
ydouble[
i]) nypix+=1.;
595 float nydiff = templ.
clsleny() - nypix;
650 float xerr = 0.0f, yerr = 0.0f;
659 <<
"A non-pixel detector type in here?";
663 xerr = 55.0f * micronsToCm;
664 yerr = 36.0f * micronsToCm;
667 xerr = 42.0f * micronsToCm;
668 yerr = 39.0f * micronsToCm;
702 <<
" ErrX = " << xerr <<
" ErrY = " << yerr;
706 if ( !(xerr > 0.0
f) )
708 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
710 if ( !(yerr > 0.0
f) )
712 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
718 static const boost::regex rule(
"([A-Z]+)(\\s+(\\d+))?");
721 if (!regex_match(str.c_str(),
match, rule))
722 throw cms::Exception(
"Configuration") <<
"Rule '" << str <<
"' not understood.\n";
729 throw cms::Exception(
"PixelCPEClusterRepair::Configuration") <<
"Detector '" << match[1].first <<
"' not understood. Should be PXB, PXE.\n";
732 if (match[3].first != match[3].
second) {
733 layer_ = atoi(match[3].first);
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
T getParameter(std::string const &) const
static const char layer_[]
Point3DBase< Scalar, LocalTag > LocalPoint
bool interpolate(int id, float cotalpha, float cotbeta, float locBz, float locBx)
std::vector< SiPixelTemplateStore > thePixelTemp_
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
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)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const SiPixelCluster * theCluster
bool isBarrel(GeomDetEnumerators::SubDetector m)
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)
ClusterParam * createClusterParam(const SiPixelCluster &cl) const override
Rule(const std::string &str)
const PixelGeomDetUnit * theDet
GeomDetType::SubDetector thePart
const RectangularPixelTopology * theRecTopol
std::vector< Rule > recommend2D_
U second(std::pair< T, U > const &p)
PixelCPEClusterRepair(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *, const SiPixel2DTemplateDBObject *)
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
const PixelTopology * theTopol
bool LoadTemplatesFromDB_
const SiPixel2DTemplateDBObject * templateDBobject2D_
float clsleny()
y-size of smaller interpolated template in pixels
unsigned int offsetDU(SubDetector sid) const
const SiPixelTemplateDBObject * templateDBobject_
virtual float localX(float mpX) const =0
DetId geographicalId() const
The label of this GeomDet.
~PixelCPEClusterRepair() override
float maxSizeMismatchInY_
std::vector< SiPixelTemplateStore2D > thePixelTemp2D_
void callTempReco2D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco2D::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
bool isEndcap(GeomDetEnumerators::SubDetector m)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
bool isItBigPixelInY(const int iybin) const override
bool isItBigPixelInX(const int ixbin) const override
Topology::LocalTrackPred loc_trk_pred
short getTemplateID(const uint32_t &detid) const
const TrackerTopology & ttopo_
void checkRecommend2D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco::ClusMatrix &clusterPayload, int ID) const
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &pixelTemp, std::string dir="")
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
float qavg()
average cluster charge for this set of track angles
void callTempReco1D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
Pixel cluster – collection of neighboring pixels above threshold.
const TrackerGeometry & geom_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
virtual float localY(float mpY) const =0
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override