16 #include "boost/multi_array.hpp"
27 const bool useNewSimplerErrors =
false;
29 const bool MYDEBUG =
false;
42 :
PixelCPEBase(conf, mag, geom, lorentzAngle, genErrorDBObject, 0,lorentzAngleWidth,0) {
51 :
PixelCPEBase(conf, mag, geom, lorentzAngle, genErrorDBObject, templateDBobject,lorentzAngleWidth,0) {
56 <<
" constructing a generic algorithm for ideal pixel detector.\n"
85 yerr_barrel_ln_= {0.00299,0.00203,0.0023,0.00237,0.00233,0.00243,0.00232,0.00259,0.00176};
95 yerr_barrel_l1_= {0.00199,0.00136,0.0015,0.00153,0.00152,0.00171,0.00154,0.00157,0.00154};
101 yerr_barrel_l1_= {0.00299,0.00203,0.0023,0.00237,0.00233,0.00243,0.00232,0.00259,0.00176};
109 if(
isUpgrade_ || (DoCosmics_) ) UseErrorsFromTemplates_ =
false;
111 if ( !UseErrorsFromTemplates_ && ( TruncatePixelCharge_ ||
112 IrradiationBiasCorrection_ ||
116 <<
"\nERROR: UseErrorsFromTemplates_ is set to False in PixelCPEGeneric_cfi.py. "
117 <<
" In this case it does not make sense to set any of the following to True: "
118 <<
" TruncatePixelCharge_, IrradiationBiasCorrection_, DoCosmics_, LoadTemplatesFromDB_ !!!"
123 if ( UseErrorsFromTemplates_ ) {
130 <<
"ERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
131 << ( *genErrorDBObject_ ).version();
135 <<
"ERROR: Templates not loaded correctly from text file. Reconstruction will fail.";
140 if(useNewSimplerErrors) {
147 <<
"ERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
148 << ( *genErrorDBObject_ ).version();
152 <<
"ERROR: Templates not loaded correctly from text file. Reconstruction will fail.";
161 <<
"ERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
162 << ( *templateDBobject_ ).version();
166 <<
"ERROR: Templates not loaded correctly from text file. Reconstruction will fail.";
170 #endif // NEW_CPEERROR
188 yerr_barrel_l1_= {0.00375,0.00230,0.00250,0.00250,0.00230,0.00230,0.00210,0.00210,0.00240};
192 yerr_barrel_ln_= {0.00375,0.00230,0.00250,0.00250,0.00230,0.00230,0.00210,0.00210,0.00240};
231 float locBz = theDetParam.
bz;
234 theClusterParam.
pixmx = -999.9;
235 theClusterParam.
sigmay = -999.9;
236 theClusterParam.
deltay = -999.9;
237 theClusterParam.
sigmax = -999.9;
238 theClusterParam.
deltax = -999.9;
239 theClusterParam.
sy1 = -999.9;
240 theClusterParam.
dy1 = -999.9;
241 theClusterParam.
sy2 = -999.9;
242 theClusterParam.
dy2 = -999.9;
243 theClusterParam.
sx1 = -999.9;
244 theClusterParam.
dx1 = -999.9;
245 theClusterParam.
sx2 = -999.9;
246 theClusterParam.
dx2 = -999.9;
260 theClusterParam.
dy1, theClusterParam.
sy2, theClusterParam.
dy2, theClusterParam.
sx1,
261 theClusterParam.
dx1, theClusterParam.
sx2, theClusterParam.
dx2 );
265 bool useLAWidthFromGenError =
false;
266 if(useLAWidthFromGenError) {
267 chargeWidthX = (-micronsToCm*gtempl.
lorxwidth());
268 chargeWidthY = (-micronsToCm*gtempl.
lorywidth());
271 if(MYDEBUG)
cout<<
" new errors "<<gtemplID_<<
" "<<theClusterParam.
sy1<<endl;
273 #else // select which one
275 if(useNewSimplerErrors) {
284 theClusterParam.
pixmx,
286 theClusterParam.
sy1, theClusterParam.
dy1, theClusterParam.
sy2, theClusterParam.
dy2, theClusterParam.
sx1, theClusterParam.
dx1, theClusterParam.
sx2, theClusterParam.
dx2 );
291 bool useLAWidthFromGenError =
false;
292 if(useLAWidthFromGenError) {
293 chargeWidthX = (-micronsToCm*gtempl.
lorxwidth());
294 chargeWidthY = (-micronsToCm*gtempl.
lorywidth());
297 if(MYDEBUG)
cout<<
" new errors "<<gtemplID_<<
" "<<theClusterParam.
sy1<<endl;
308 theClusterParam.
pixmx,
310 theClusterParam.
sy1, theClusterParam.
dy1, theClusterParam.
sy2, theClusterParam.
dy2, theClusterParam.
sx1, theClusterParam.
dx1, theClusterParam.
sx2, theClusterParam.
dx2 );
312 if(MYDEBUG)
cout<<
" errors "<<templID_<<
" "<<theClusterParam.
sy1<<endl;
316 #endif // NEW_CPEERROR
319 theClusterParam.
deltax = theClusterParam.
deltax * micronsToCm;
320 theClusterParam.
dx1 = theClusterParam.
dx1 * micronsToCm;
321 theClusterParam.
dx2 = theClusterParam.
dx2 * micronsToCm;
323 theClusterParam.
deltay = theClusterParam.
deltay * micronsToCm;
324 theClusterParam.
dy1 = theClusterParam.
dy1 * micronsToCm;
325 theClusterParam.
dy2 = theClusterParam.
dy2 * micronsToCm;
327 theClusterParam.
sigmax = theClusterParam.
sigmax * micronsToCm;
328 theClusterParam.
sx1 = theClusterParam.
sx1 * micronsToCm;
329 theClusterParam.
sx2 = theClusterParam.
sx2 * micronsToCm;
331 theClusterParam.
sigmay = theClusterParam.
sigmay * micronsToCm;
332 theClusterParam.
sy1 = theClusterParam.
sy1 * micronsToCm;
333 theClusterParam.
sy2 = theClusterParam.
sy2 * micronsToCm;
377 <<
"\n\t >>> theClusterParam.theCluster->x = " << theClusterParam.
theCluster->
x()
378 <<
"\n\t >>> theClusterParam.theCluster->y = " << theClusterParam.
theCluster->
y()
383 <<
"\n\t >>> meas: inner lower left = " << meas_URcorn_LLpix.x()
384 <<
"," << meas_URcorn_LLpix.y()
385 <<
"\n\t >>> meas: inner upper right = " << meas_LLcorn_URpix.x()
386 <<
"," << meas_LLcorn_URpix.y()
399 cout <<
"\t >>> Generic:: processing X" << endl;
405 local_URcorn_LLpix.x(), local_LLcorn_URpix.
x(),
418 xPos = xPos + shiftX;
422 cout <<
"\t >>> Generic:: processing Y" << endl;
428 local_URcorn_LLpix.y(), local_LLcorn_URpix.
y(),
440 yPos = yPos + shiftY;
449 if ( !bigInX ) xPos -= theClusterParam.
dx1;
450 else xPos -= theClusterParam.
dx2;
454 xPos -= theClusterParam.
deltax;
463 if ( !bigInY ) yPos -= theClusterParam.
dy1;
464 else yPos -= theClusterParam.
dy2;
467 yPos -= theClusterParam.
deltay;
492 float upper_edge_first_pix,
493 float lower_edge_last_pix,
500 float eff_charge_cut_low,
501 float eff_charge_cut_high,
508 float geom_center = 0.5f * ( upper_edge_first_pix + lower_edge_last_pix );
513 if ( size == 1 ) {
return geom_center;}
517 float W_inner = lower_edge_last_pix - upper_edge_first_pix;
520 float W_pred = theThickness * cot_angle
526 float sum_of_edge = 2.0f;
527 if (first_is_big) sum_of_edge += 1.0f;
528 if (last_is_big) sum_of_edge += 1.0f;
532 float W_eff =
std::abs( W_pred ) - W_inner;
541 if ( (size >= size_cut) || (
542 ( W_eff/pitch < eff_charge_cut_low ) |
543 ( W_eff/pitch > eff_charge_cut_high ) ) )
545 W_eff = pitch * 0.5f * sum_of_edge;
554 float Qdiff = Q_l - Q_f;
555 float Qsum = Q_l + Q_f;
558 if(Qsum==0) Qsum=1.0f;
560 float hit_pos = geom_center + 0.5f*(Qdiff/Qsum) * W_eff;
568 cout <<
"\t >>> We are in the Barrel." ;
570 cout <<
"\t >>> We are in the Forward." ;
573 <<
"\n\t >>> cot(angle) = " << cot_angle <<
" pitch = " << pitch <<
" size = " << size
574 <<
"\n\t >>> upper_edge_first_pix = " << upper_edge_first_pix
575 <<
"\n\t >>> lower_edge_last_pix = " << lower_edge_last_pix
576 <<
"\n\t >>> geom_center = " << geom_center
577 <<
"\n\t >>> half_lorentz_shift = " << half_lorentz_shift
578 <<
"\n\t >>> W_inner = " << W_inner
579 <<
"\n\t >>> W_pred = " << W_pred
580 <<
"\n\t >>> W_eff(orig) = " << fabs( W_pred ) - W_inner
581 <<
"\n\t >>> W_eff(used) = " << W_eff
582 <<
"\n\t >>> sum_of_edge = " << sum_of_edge
583 <<
"\n\t >>> Qdiff = " << Qdiff <<
" Qsum = " << Qsum
584 <<
"\n\t >>> hit_pos = " << hit_pos
585 <<
"\n\t >>> RecHits: total = " << nRecHitsTotal_
586 <<
" used edge = " << nRecHitsUsedEdge_
589 cout <<
"\n\t >>> Used Edge algorithm." ;
591 cout <<
"\n\t >>> Used angle information." ;
630 for (
int i = 0;
i != isize; ++
i)
634 float pix_adc = pixel.
adc;
640 if ( pixel.x == xmin ) Q_f_X += pix_adc;
641 if ( pixel.x == xmax ) Q_l_X += pix_adc;
644 if ( pixel.y == ymin ) Q_f_Y += pix_adc;
645 if ( pixel.y == ymax ) Q_l_Y += pix_adc;
663 const bool localPrint =
false;
681 if(
int(sizex) != (maxPixelRow - minPixelRow+1) )
cout<<
" wrong x"<<endl;
682 if(
int(sizey) != (maxPixelCol - minPixelCol+1) )
cout<<
" wrong y"<<endl;
689 cout<<
" endge clus "<<xerr<<
" "<<yerr<<endl;
690 if(bigInX || bigInY)
cout<<
" big "<<bigInX<<
" "<<bigInY<<endl;
691 if(edgex || edgey)
cout<<
" edge "<<edgex<<
" "<<edgey<<endl;
693 if(theClusterParam.
qBin_ == 0)
694 cout<<
" qbin 0! "<<edgex<<
" "<<edgey<<
" "<<bigInX<<
" "<<bigInY<<
" "
695 <<sizex<<
" "<<sizey<<endl;
696 if(sizex==2 && sizey==2)
cout<<
" size 2*2 "<<theClusterParam.
qBin_<<endl;
708 if ( !bigInX ) {xerr = theClusterParam.
sx1;}
709 else {xerr = theClusterParam.
sx2;}
710 }
else {xerr = theClusterParam.
sigmax;}
715 if ( !bigInY ) {yerr = theClusterParam.
sy1;}
716 else {yerr = theClusterParam.
sy2;}
717 }
else {yerr = theClusterParam.
sigmay;}
721 cout<<
" in if "<<edgex<<
" "<<edgey<<
" "<<sizex<<
" "<<sizey<<endl;
722 cout<<
" errors "<<xerr<<
" "<<yerr<<
" "<<theClusterParam.
sx1<<
" "<<theClusterParam.
sx2<<
" "<<theClusterParam.
sigmax<<endl;
728 cout <<
"Track angles are not known and we are processing cosmics." << endl;
774 for (
int irow = 0; irow < 7; ++irow) {
778 for (
int icol = 0; icol < 21; ++icol) {
792 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
796 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
800 cout<<
" errors "<<xerr<<
" "<<yerr<<endl;
801 if(theClusterParam.
qBin_ == 0)
cout<<
" qbin 0 "<<xerr<<
" "<<yerr<<endl;
804 auto xerr_sq = xerr*xerr;
805 auto yerr_sq = yerr*yerr;
T getParameter(std::string const &) const
bool containsBigPixelInY(int iymin, int iymax) const
std::vector< float > xerr_barrel_l1_
bool isItEdgePixelInY(int iybin) const
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
float the_eff_charge_cut_highY
int qbin(int id, float cotalpha, float cotbeta, float locBz, float qclus, float &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)
std::vector< float > xerr_barrel_ln_
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
virtual bool isItBigPixelInY(const int iybin) const
const SiPixelCluster * theCluster
bool isItEdgePixelInX(int ixbin) const
bool UseErrorsFromTemplates_
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< SiPixelGenErrorStore > thePixelGenError_
PixelCPEGeneric(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const SiPixelLorentzAngle *, const SiPixelGenErrorDBObject *, const SiPixelTemplateDBObject *, const SiPixelLorentzAngle *)
The constructor.
const PixelGeomDetUnit * theDet
GeomDetType::SubDetector thePart
bool IrradiationBiasCorrection_
unsigned int layer() const
layer id
const RectangularPixelTopology * theRecTopol
std::vector< float > yerr_endcap_
bool TruncatePixelCharge_
const PixelTopology * theTopol
bool LoadTemplatesFromDB_
float the_eff_charge_cut_lowX
bool inflate_all_errors_no_trk_angle
void collect_edge_charges(ClusterParam &theClusterParam, float &Q_f_X, float &Q_l_X, float &Q_f_Y, float &Q_l_Y) const
Abs< T >::type abs(const T &t)
const SiPixelTemplateDBObject * templateDBobject_
DetId geographicalId() const
The label of this GeomDet.
float xerr_barrel_l1_def_
float lorxwidth()
signed lorentz x-width (microns)
float generic_position_formula(int size, float Q_f, float 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
bool containsBigPixelInX(int ixmin, int ixmax) const
std::vector< float > xerr_endcap_
Topology::LocalTrackPred loc_trk_pred
const SiPixelGenErrorDBObject * genErrorDBObject_
float the_eff_charge_cut_lowY
std::vector< float > yerr_barrel_l1_
float yerr_barrel_l1_def_
std::vector< float > yerr_barrel_ln_
Pixel cluster – collection of neighboring pixels above threshold.
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const
float lorywidth()
signed lorentz y-width (microns)
virtual bool isItBigPixelInX(const int ixbin) const
std::vector< SiPixelTemplateStore > thePixelTemp_
float xerr_barrel_ln_def_
static bool pushfile(int filenum, std::vector< SiPixelGenErrorStore > &thePixelTemp_)
float yerr_barrel_ln_def_
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const
int qbin(int id, float cotalpha, float cotbeta, float locBz, float qclus, float &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)
tuple size
Write out results.
float the_eff_charge_cut_highX
ClusterParam * createClusterParam(const SiPixelCluster &cl) const