15 #include "boost/multi_array.hpp" 22 const bool MYDEBUG =
false;
35 :
PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, genErrorDBObject,
nullptr,lorentzAngleWidth,0) {
39 <<
" constructing a generic algorithm for ideal pixel detector.\n" 69 if( isUpgrade_ || (DoCosmics_) ) UseErrorsFromTemplates_ =
false;
71 if ( !UseErrorsFromTemplates_ && ( TruncatePixelCharge_ ||
72 IrradiationBiasCorrection_ ||
75 <<
"\nERROR: UseErrorsFromTemplates_ is set to False in PixelCPEGeneric_cfi.py. " 76 <<
" In this case it does not make sense to set any of the following to True: " 77 <<
" TruncatePixelCharge_, IrradiationBiasCorrection_, DoCosmics_, LoadTemplatesFromDB_ !!!" 82 if ( UseErrorsFromTemplates_ ) {
87 <<
"ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " 88 << ( *genErrorDBObject_ ).version();
89 if(MYDEBUG)
cout<<
"Loaded genErrorDBObject v"<<( *genErrorDBObject_ ).version()<<endl;
93 <<
"ERROR: GenErrors not loaded correctly from text file. Reconstruction will fail.";
97 if(MYDEBUG)
cout<<
" Use simple parametrised errors "<<endl;
106 yerr_barrel_l1_= {0.00375,0.00230,0.00250,0.00250,0.00230,0.00230,0.00210,0.00210,0.00240};
110 yerr_barrel_ln_= {0.00375,0.00230,0.00250,0.00250,0.00230,0.00230,0.00210,0.00210,0.00240};
129 yerr_barrel_l1_= {0.00199,0.00136,0.0015,0.00153,0.00152,0.00171,0.00154,0.00157,0.00154};
140 cout <<
"From PixelCPEGeneric::PixelCPEGeneric(...)" << endl;
141 cout <<
"(int)UseErrorsFromTemplates_ = " << (
int)UseErrorsFromTemplates_ << endl;
142 cout <<
"TruncatePixelCharge_ = " << (
int)TruncatePixelCharge_ << endl;
143 cout <<
"IrradiationBiasCorrection_ = " << (
int)IrradiationBiasCorrection_ << endl;
144 cout <<
"(int)DoCosmics_ = " << (
int)DoCosmics_ << endl;
181 float locBz = theDetParam.
bz;
182 float locBx = theDetParam.
bx;
185 theClusterParam.
pixmx = -999.9;
186 theClusterParam.
sigmay = -999.9;
187 theClusterParam.
deltay = -999.9;
188 theClusterParam.
sigmax = -999.9;
189 theClusterParam.
deltax = -999.9;
190 theClusterParam.
sy1 = -999.9;
191 theClusterParam.
dy1 = -999.9;
192 theClusterParam.
sy2 = -999.9;
193 theClusterParam.
dy2 = -999.9;
194 theClusterParam.
sx1 = -999.9;
195 theClusterParam.
dx1 = -999.9;
196 theClusterParam.
sx2 = -999.9;
197 theClusterParam.
dx2 = -999.9;
209 theClusterParam.
dy1, theClusterParam.
sy2, theClusterParam.
dy2, theClusterParam.
sx1,
210 theClusterParam.
dx1, theClusterParam.
sx2, theClusterParam.
dx2 );
214 bool useLAWidthFromGenError =
false;
215 if(useLAWidthFromGenError) {
216 chargeWidthX = (-micronsToCm*gtempl.
lorxwidth());
217 chargeWidthY = (-micronsToCm*gtempl.
lorywidth());
218 if(MYDEBUG)
cout<<
" redefine la width (gen-error) "<< chargeWidthX<<
" "<< chargeWidthY <<endl;
220 if(MYDEBUG)
cout<<
" GenError: "<<gtemplID_<<endl;
223 theClusterParam.
deltax = theClusterParam.
deltax * micronsToCm;
224 theClusterParam.
dx1 = theClusterParam.
dx1 * micronsToCm;
225 theClusterParam.
dx2 = theClusterParam.
dx2 * micronsToCm;
227 theClusterParam.
deltay = theClusterParam.
deltay * micronsToCm;
228 theClusterParam.
dy1 = theClusterParam.
dy1 * micronsToCm;
229 theClusterParam.
dy2 = theClusterParam.
dy2 * micronsToCm;
231 theClusterParam.
sigmax = theClusterParam.
sigmax * micronsToCm;
232 theClusterParam.
sx1 = theClusterParam.
sx1 * micronsToCm;
233 theClusterParam.
sx2 = theClusterParam.
sx2 * micronsToCm;
235 theClusterParam.
sigmay = theClusterParam.
sigmay * micronsToCm;
236 theClusterParam.
sy1 = theClusterParam.
sy1 * micronsToCm;
237 theClusterParam.
sy2 = theClusterParam.
sy2 * micronsToCm;
241 theClusterParam.
qBin_ = 0;
284 <<
"\n\t >>> theClusterParam.theCluster->x = " << theClusterParam.
theCluster->
x()
285 <<
"\n\t >>> theClusterParam.theCluster->y = " << theClusterParam.
theCluster->
y()
290 <<
"\n\t >>> meas: inner lower left = " << meas_URcorn_LLpix.x()
291 <<
"," << meas_URcorn_LLpix.y()
292 <<
"\n\t >>> meas: inner upper right = " << meas_LLcorn_URpix.x()
293 <<
"," << meas_LLcorn_URpix.y()
306 cout <<
"\t >>> Generic:: processing X" << endl;
312 local_URcorn_LLpix.x(), local_LLcorn_URpix.
x(),
325 xPos = xPos + shiftX;
329 cout <<
"\t >>> Generic:: processing Y" << endl;
335 local_URcorn_LLpix.y(), local_LLcorn_URpix.
y(),
347 yPos = yPos + shiftY;
358 if ( !bigInX ) xPos -= theClusterParam.
dx1;
359 else xPos -= theClusterParam.
dx2;
363 xPos -= theClusterParam.
deltax;
373 if ( !bigInY ) yPos -= theClusterParam.
dy1;
374 else yPos -= theClusterParam.
dy2;
378 yPos -= theClusterParam.
deltay;
403 float upper_edge_first_pix,
404 float lower_edge_last_pix,
411 float eff_charge_cut_low,
412 float eff_charge_cut_high,
419 float geom_center = 0.5f * ( upper_edge_first_pix + lower_edge_last_pix );
424 if ( size == 1 ) {
return geom_center;}
428 float W_inner = lower_edge_last_pix - upper_edge_first_pix;
431 float W_pred = theThickness * cot_angle
437 float sum_of_edge = 2.0f;
438 if (first_is_big) sum_of_edge += 1.0f;
439 if (last_is_big) sum_of_edge += 1.0f;
443 float W_eff =
std::abs( W_pred ) - W_inner;
452 if ( (size >= size_cut) || (
453 ( W_eff/pitch < eff_charge_cut_low ) |
454 ( W_eff/pitch > eff_charge_cut_high ) ) )
456 W_eff = pitch * 0.5f * sum_of_edge;
465 float Qdiff = Q_l - Q_f;
466 float Qsum = Q_l + Q_f;
469 if(Qsum==0) Qsum=1.0f;
471 float hit_pos = geom_center + 0.5f*(Qdiff/Qsum) * W_eff;
477 #warning "Debug printouts in PixelCPEGeneric.cc has been commented because they cannot be compiled" 548 for (
int i = 0;
i != isize; ++
i)
552 int pix_adc =
pixel.adc;
558 if (
pixel.x == xmin ) Q_f_X += pix_adc;
559 if (
pixel.x == xmax ) Q_l_X += pix_adc;
562 if (
pixel.y == ymin ) Q_f_Y += pix_adc;
563 if (
pixel.y == ymax ) Q_l_Y += pix_adc;
581 const bool localPrint =
false;
600 if(
int(sizex) != (maxPixelRow - minPixelRow+1) )
cout<<
" wrong x"<<endl;
601 if(
int(sizey) != (maxPixelCol - minPixelCol+1) )
cout<<
" wrong y"<<endl;
609 cout<<
" edge clus "<<xerr<<
" "<<yerr<<endl;
610 if(bigInX || bigInY)
cout<<
" big "<<bigInX<<
" "<<bigInY<<endl;
611 if(edgex || edgey)
cout<<
" edge "<<edgex<<
" "<<edgey<<endl;
613 if(theClusterParam.
qBin_ == 0)
614 cout<<
" qbin 0! "<<edgex<<
" "<<edgey<<
" "<<bigInX<<
" "<<bigInY<<
" " 615 <<sizex<<
" "<<sizey<<endl;
625 if ( !bigInX ) {xerr = theClusterParam.
sx1;}
626 else {xerr = theClusterParam.
sx2;}
627 }
else {xerr = theClusterParam.
sigmax;}
632 if ( !bigInY ) {yerr = theClusterParam.
sy1;}
633 else {yerr = theClusterParam.
sy2;}
634 }
else {yerr = theClusterParam.
sigmay;}
638 cout<<
" in if "<<edgex<<
" "<<edgey<<
" "<<sizex<<
" "<<sizey<<endl;
639 cout<<
" errors "<<xerr<<
" "<<yerr<<
" "<<theClusterParam.
sx1<<
" "<<theClusterParam.
sx2<<
" "<<theClusterParam.
sigmax<<endl;
693 for (
int irow = 0; irow < 7; ++irow) {
697 for (
int icol = 0; icol < 21; ++icol) {
711 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
715 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
723 auto xerr_sq = xerr*xerr;
724 auto yerr_sq = yerr*yerr;
T getParameter(std::string const &) const
std::vector< float > xerr_barrel_l1_
static bool pushfile(int filenum, std::vector< SiPixelGenErrorStore > &pixelTemp, std::string dir="")
float the_eff_charge_cut_highY
std::vector< float > xerr_barrel_ln_
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const SiPixelCluster * theCluster
bool isBarrel(GeomDetEnumerators::SubDetector m)
bool UseErrorsFromTemplates_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< SiPixelGenErrorStore > thePixelGenError_
const PixelGeomDetUnit * theDet
GeomDetType::SubDetector thePart
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
bool IrradiationBiasCorrection_
const RectangularPixelTopology * theRecTopol
std::vector< float > yerr_endcap_
PixelCPEGeneric(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelGenErrorDBObject *, const SiPixelLorentzAngle *)
The constructor.
int qbin(int id, float cotalpha, float cotbeta, float locBz, float locBx, float qclus, bool irradiationCorrections, int &pixmx, float &sigmay, float &deltay, float &sigmax, float &deltax, float &sy1, float &dy1, float &sy2, float &dy2, float &sx1, float &dx1, float &sx2, float &dx2)
bool TruncatePixelCharge_
bool isItEdgePixelInX(int ixbin) const override
const PixelTopology * theTopol
bool LoadTemplatesFromDB_
float the_eff_charge_cut_lowX
bool inflate_all_errors_no_trk_angle
Abs< T >::type abs(const T &t)
DetId geographicalId() const
The label of this GeomDet.
float xerr_barrel_l1_def_
float lorxwidth()
signed lorentz x-width (microns)
std::vector< float > xerr_endcap_
bool isItBigPixelInY(const int iybin) const override
bool isItBigPixelInX(const int ixbin) const override
Topology::LocalTrackPred loc_trk_pred
const TrackerTopology & ttopo_
const SiPixelGenErrorDBObject * genErrorDBObject_
float the_eff_charge_cut_lowY
ClusterParam * createClusterParam(const SiPixelCluster &cl) const override
std::vector< float > yerr_barrel_l1_
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
float yerr_barrel_l1_def_
unsigned int layer(const DetId &id) const
std::vector< float > yerr_barrel_ln_
Pixel cluster – collection of neighboring pixels above threshold.
float generic_position_formula(int size, int Q_f, int Q_l, float upper_edge_first_pix, float lower_edge_last_pix, float lorentz_shift, float theThickness, float cot_angle, float pitch, bool first_is_big, bool last_is_big, float eff_charge_cut_low, float eff_charge_cut_high, float size_cut) const
float lorywidth()
signed lorentz y-width (microns)
float xerr_barrel_ln_def_
bool containsBigPixelInY(int iymin, int iymax) const override
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
bool containsBigPixelInX(int ixmin, int ixmax) const override
bool isItEdgePixelInY(int iybin) const override
float yerr_barrel_ln_def_
void collect_edge_charges(ClusterParam &theClusterParam, int &Q_f_X, int &Q_l_X, int &Q_f_Y, int &Q_l_Y) const
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
float the_eff_charge_cut_highX