16 #include "boost/multi_array.hpp"
21 #define NEW_CPEERROR // must be constistent with base.cc, generic cc/h and genericProducer.cc
25 const bool MYDEBUG =
false;
38 :
PixelCPEBase(conf, mag, geom, lorentzAngle, genErrorDBObject, 0,lorentzAngleWidth,0) {
47 :
PixelCPEBase(conf, mag, geom, lorentzAngle, genErrorDBObject, templateDBobject,lorentzAngleWidth,0) {
52 <<
" constructing a generic algorithm for ideal pixel detector.\n"
81 yerr_barrel_ln_= {0.00299,0.00203,0.0023,0.00237,0.00233,0.00243,0.00232,0.00259,0.00176};
91 yerr_barrel_l1_= {0.00199,0.00136,0.0015,0.00153,0.00152,0.00171,0.00154,0.00157,0.00154};
97 yerr_barrel_l1_= {0.00299,0.00203,0.0023,0.00237,0.00233,0.00243,0.00232,0.00259,0.00176};
105 if(
isUpgrade_ || (DoCosmics_) ) UseErrorsFromTemplates_ =
false;
107 if ( !UseErrorsFromTemplates_ && ( TruncatePixelCharge_ ||
108 IrradiationBiasCorrection_ ||
112 <<
"\nERROR: UseErrorsFromTemplates_ is set to False in PixelCPEGeneric_cfi.py. "
113 <<
" In this case it does not make sense to set any of the following to True: "
114 <<
" TruncatePixelCharge_, IrradiationBiasCorrection_, DoCosmics_, LoadTemplatesFromDB_ !!!"
119 if ( UseErrorsFromTemplates_ ) {
126 <<
"ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
127 << ( *genErrorDBObject_ ).version();
128 if(MYDEBUG)
cout<<
"Loaded genErrorDBObject v"<<( *genErrorDBObject_ ).version()<<endl;
132 <<
"ERROR: GenErrors not loaded correctly from text file. Reconstruction will fail.";
141 <<
"ERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
142 << ( *templateDBobject_ ).version();
143 if(MYDEBUG)
cout<<
"Loaded templateDBobject "<<( *templateDBobject_ ).version()<<endl;
148 <<
"ERROR: Templates not loaded correctly from text file. Reconstruction will fail.";
151 #endif // NEW_CPEERROR
156 cout <<
"From PixelCPEGeneric::PixelCPEGeneric(...)" << endl;
157 cout <<
"(int)UseErrorsFromTemplates_ = " << (int)UseErrorsFromTemplates_ << endl;
158 cout <<
"TruncatePixelCharge_ = " << (int)TruncatePixelCharge_ << endl;
159 cout <<
"IrradiationBiasCorrection_ = " << (int)IrradiationBiasCorrection_ << endl;
160 cout <<
"(int)DoCosmics_ = " << (int)DoCosmics_ << endl;
169 yerr_barrel_l1_= {0.00375,0.00230,0.00250,0.00250,0.00230,0.00230,0.00210,0.00210,0.00240};
173 yerr_barrel_ln_= {0.00375,0.00230,0.00250,0.00250,0.00230,0.00230,0.00210,0.00210,0.00240};
212 float locBz = theDetParam.
bz;
215 theClusterParam.
pixmx = -999.9;
216 theClusterParam.
sigmay = -999.9;
217 theClusterParam.
deltay = -999.9;
218 theClusterParam.
sigmax = -999.9;
219 theClusterParam.
deltax = -999.9;
220 theClusterParam.
sy1 = -999.9;
221 theClusterParam.
dy1 = -999.9;
222 theClusterParam.
sy2 = -999.9;
223 theClusterParam.
dy2 = -999.9;
224 theClusterParam.
sx1 = -999.9;
225 theClusterParam.
dx1 = -999.9;
226 theClusterParam.
sx2 = -999.9;
227 theClusterParam.
dx2 = -999.9;
241 theClusterParam.
dy1, theClusterParam.
sy2, theClusterParam.
dy2, theClusterParam.
sx1,
242 theClusterParam.
dx1, theClusterParam.
sx2, theClusterParam.
dx2 );
246 bool useLAWidthFromGenError =
false;
247 if(useLAWidthFromGenError) {
248 chargeWidthX = (-micronsToCm*gtempl.
lorxwidth());
249 chargeWidthY = (-micronsToCm*gtempl.
lorywidth());
250 if(MYDEBUG)
cout<<
" redefine la width (gen-error) "<< chargeWidthX<<
" "<< chargeWidthY <<endl;
252 if(MYDEBUG)
cout<<
" GenError: "<<gtemplID_<<endl;
254 #else // select templates
260 theClusterParam.
pixmx,
262 theClusterParam.
sy1, theClusterParam.
dy1, theClusterParam.
sy2, theClusterParam.
dy2, theClusterParam.
sx1, theClusterParam.
dx1, theClusterParam.
sx2, theClusterParam.
dx2 );
270 #endif // NEW_CPEERROR
273 theClusterParam.
deltax = theClusterParam.
deltax * micronsToCm;
274 theClusterParam.
dx1 = theClusterParam.
dx1 * micronsToCm;
275 theClusterParam.
dx2 = theClusterParam.
dx2 * micronsToCm;
277 theClusterParam.
deltay = theClusterParam.
deltay * micronsToCm;
278 theClusterParam.
dy1 = theClusterParam.
dy1 * micronsToCm;
279 theClusterParam.
dy2 = theClusterParam.
dy2 * micronsToCm;
281 theClusterParam.
sigmax = theClusterParam.
sigmax * micronsToCm;
282 theClusterParam.
sx1 = theClusterParam.
sx1 * micronsToCm;
283 theClusterParam.
sx2 = theClusterParam.
sx2 * micronsToCm;
285 theClusterParam.
sigmay = theClusterParam.
sigmay * micronsToCm;
286 theClusterParam.
sy1 = theClusterParam.
sy1 * micronsToCm;
287 theClusterParam.
sy2 = theClusterParam.
sy2 * micronsToCm;
331 <<
"\n\t >>> theClusterParam.theCluster->x = " << theClusterParam.
theCluster->
x()
332 <<
"\n\t >>> theClusterParam.theCluster->y = " << theClusterParam.
theCluster->
y()
337 <<
"\n\t >>> meas: inner lower left = " << meas_URcorn_LLpix.x()
338 <<
"," << meas_URcorn_LLpix.y()
339 <<
"\n\t >>> meas: inner upper right = " << meas_LLcorn_URpix.x()
340 <<
"," << meas_LLcorn_URpix.y()
353 cout <<
"\t >>> Generic:: processing X" << endl;
359 local_URcorn_LLpix.x(), local_LLcorn_URpix.
x(),
372 xPos = xPos + shiftX;
376 cout <<
"\t >>> Generic:: processing Y" << endl;
382 local_URcorn_LLpix.y(), local_LLcorn_URpix.
y(),
394 yPos = yPos + shiftY;
405 if ( !bigInX ) xPos -= theClusterParam.
dx1;
406 else xPos -= theClusterParam.
dx2;
410 xPos -= theClusterParam.
deltax;
420 if ( !bigInY ) yPos -= theClusterParam.
dy1;
421 else yPos -= theClusterParam.
dy2;
425 yPos -= theClusterParam.
deltay;
450 float upper_edge_first_pix,
451 float lower_edge_last_pix,
458 float eff_charge_cut_low,
459 float eff_charge_cut_high,
466 float geom_center = 0.5f * ( upper_edge_first_pix + lower_edge_last_pix );
471 if ( size == 1 ) {
return geom_center;}
475 float W_inner = lower_edge_last_pix - upper_edge_first_pix;
478 float W_pred = theThickness * cot_angle
484 float sum_of_edge = 2.0f;
485 if (first_is_big) sum_of_edge += 1.0f;
486 if (last_is_big) sum_of_edge += 1.0f;
490 float W_eff =
std::abs( W_pred ) - W_inner;
499 if ( (size >= size_cut) || (
500 ( W_eff/pitch < eff_charge_cut_low ) |
501 ( W_eff/pitch > eff_charge_cut_high ) ) )
503 W_eff = pitch * 0.5f * sum_of_edge;
512 float Qdiff = Q_l - Q_f;
513 float Qsum = Q_l + Q_f;
516 if(Qsum==0) Qsum=1.0f;
518 float hit_pos = geom_center + 0.5f*(Qdiff/Qsum) * W_eff;
526 cout <<
"\t >>> We are in the Barrel." ;
528 cout <<
"\t >>> We are in the Forward." ;
531 <<
"\n\t >>> cot(angle) = " << cot_angle <<
" pitch = " << pitch <<
" size = " << size
532 <<
"\n\t >>> upper_edge_first_pix = " << upper_edge_first_pix
533 <<
"\n\t >>> lower_edge_last_pix = " << lower_edge_last_pix
534 <<
"\n\t >>> geom_center = " << geom_center
535 <<
"\n\t >>> half_lorentz_shift = " << half_lorentz_shift
536 <<
"\n\t >>> W_inner = " << W_inner
537 <<
"\n\t >>> W_pred = " << W_pred
538 <<
"\n\t >>> W_eff(orig) = " << fabs( W_pred ) - W_inner
539 <<
"\n\t >>> W_eff(used) = " << W_eff
540 <<
"\n\t >>> sum_of_edge = " << sum_of_edge
541 <<
"\n\t >>> Qdiff = " << Qdiff <<
" Qsum = " << Qsum
542 <<
"\n\t >>> hit_pos = " << hit_pos
543 <<
"\n\t >>> RecHits: total = " << nRecHitsTotal_
544 <<
" used edge = " << nRecHitsUsedEdge_
547 cout <<
"\n\t >>> Used Edge algorithm." ;
549 cout <<
"\n\t >>> Used angle information." ;
588 for (
int i = 0;
i != isize; ++
i)
592 float pix_adc = pixel.
adc;
598 if ( pixel.x == xmin ) Q_f_X += pix_adc;
599 if ( pixel.x == xmax ) Q_l_X += pix_adc;
602 if ( pixel.y == ymin ) Q_f_Y += pix_adc;
603 if ( pixel.y == ymax ) Q_l_Y += pix_adc;
621 const bool localPrint =
false;
640 if(
int(sizex) != (maxPixelRow - minPixelRow+1) )
cout<<
" wrong x"<<endl;
641 if(
int(sizey) != (maxPixelCol - minPixelCol+1) )
cout<<
" wrong y"<<endl;
649 cout<<
" endge clus "<<xerr<<
" "<<yerr<<endl;
650 if(bigInX || bigInY)
cout<<
" big "<<bigInX<<
" "<<bigInY<<endl;
651 if(edgex || edgey)
cout<<
" edge "<<edgex<<
" "<<edgey<<endl;
653 if(theClusterParam.
qBin_ == 0)
654 cout<<
" qbin 0! "<<edgex<<
" "<<edgey<<
" "<<bigInX<<
" "<<bigInY<<
" "
655 <<sizex<<
" "<<sizey<<endl;
667 if ( !bigInX ) {xerr = theClusterParam.
sx1;}
668 else {xerr = theClusterParam.
sx2;}
669 }
else {xerr = theClusterParam.
sigmax;}
674 if ( !bigInY ) {yerr = theClusterParam.
sy1;}
675 else {yerr = theClusterParam.
sy2;}
676 }
else {yerr = theClusterParam.
sigmay;}
680 cout<<
" in if "<<edgex<<
" "<<edgey<<
" "<<sizex<<
" "<<sizey<<endl;
681 cout<<
" errors "<<xerr<<
" "<<yerr<<
" "<<theClusterParam.
sx1<<
" "<<theClusterParam.
sx2<<
" "<<theClusterParam.
sigmax<<endl;
687 cout <<
"Track angles are not known and we are processing cosmics." << endl;
733 for (
int irow = 0; irow < 7; ++irow) {
737 for (
int icol = 0; icol < 21; ++icol) {
751 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
755 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
763 auto xerr_sq = xerr*xerr;
764 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
PixelCPEGeneric(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const SiPixelLorentzAngle *, const SiPixelGenErrorDBObject *, const SiPixelLorentzAngle *)
The constructor.
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_
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_
PixelCPEBase(edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelTemplateDBObject *templateDBobject, const SiPixelLorentzAngle *lorentzAngleWidth, int flag=0)
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
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