45 thePixelPart(pixelPart)
56 thePixelResolutionFile1 =
new
64 throw cms::Exception(
"SiPixelGaussianSmearingRecHitConverterAlgorithm:")
65 <<
"SiPixel Barrel Template Not Loaded Correctly!"<<endl;
74 thePixelResolutionFile1 =
new
79 throw cms::Exception(
"SiPixelGaussianSmearingRecHitConverterAlgorithm:")
80 <<
"SiPixel Forward Template Not Loaded Correctly!"<<endl;
86 throw cms::Exception(
"SiPixelGaussianSmearingRecHitConverterAlgorithm :")
87 <<
"Not a pixel detector"<<endl;
93 if ( thePixelResolutionFile1) {
94 thePixelResolutionFile1->Close();
97 thePixelResolutionFile1=0;
104 std::map<unsigned,const SimpleHistogramGenerator*>::const_iterator it;
131 float locx = localDir.
x();
132 float locy = localDir.
y();
133 float locz = localDir.
z();
136 float cotalpha = locx/locz;
143 float cotbeta = locy/locz;
146 if( cotbeta < 0 ) sign=-1.;
147 cotbeta = sign*cotbeta;
154 <<
" cotalpha(x) = " << cotalpha
155 <<
" cotbeta(y) = " << cotbeta
162 const int nrows = theSpecificTopology->
nrows();
163 const int ncolumns = theSpecificTopology->
ncolumns();
171 float pixelCenterY = 0.5 + (int)mpy;
172 float pixelCenterX = 0.5 + (int)mpx;
174 cout<<
"Struck pixel center at pitch units x: "<<pixelCenterX<<
" y: "<<pixelCenterY<<endl;
181 cout<<
"Struck point at cm x: "<<lp.
x()<<
" y: "<<lp.
y()<<endl;
182 cout<<
"Struck pixel center at cm x: "<<lpCenter.
x()<<
" y: "<<lpCenter.
y()<<endl;
183 cout<<
"The boundX is "<<boundX<<
" boundY is "<<boundY<<endl;
187 float xtrk = lp.
x() - lpCenter.
x();
188 float ytrk = lp.
y() - lpCenter.
y();
192 float yhit = 20. + 8.*(ytrk/
ysize);
193 float xhit = 20. + 8.*(xtrk/
xsize);
194 int ybin = (int)yhit;
195 int xbin = (int)xhit;
196 float yfrac= yhit - (float)ybin;
197 float xfrac= xhit - (float)xbin;
199 if( ybin < 0 ) ybin = 0;
200 if( ybin > 39 ) ybin = 39;
201 if( xbin < 0 ) xbin = 0;
202 if( xbin > 39 ) xbin = 39;
208 float ny1_frac, ny2_frac, nx1_frac, nx2_frac;
209 bool singlex =
false, singley =
false;
212 templ.
qbin_dist(
tempId, cotalpha, cotbeta, qbin_frac, ny1_frac, ny2_frac, nx1_frac, nx2_frac );
215 double xsizeProbability = random->
flatShoot();
216 double ysizeProbability = random->
flatShoot();
221 if( xsizeProbability < nx2_frac ) singlex =
true;
222 else singlex =
false;
224 if( xsizeProbability < nx1_frac ) singlex =
true;
225 else singlex =
false;
228 if( ysizeProbability < ny2_frac ) singley =
true;
229 else singley =
false;
231 if( ysizeProbability < ny1_frac ) singley =
true;
232 else singley =
false;
237 double qbinProbability = random->
flatShoot();
238 for(
int i = 0;
i<4; ++
i) {
240 if(qbinProbability < qbin_frac[
i])
break;
245 float ytempl[41][
BYSIZE] = {{0}}, xtempl[41][
BXSIZE] = {{0}} ;
246 templ.
ytemp(0, 40, ytempl);
247 templ.
xtemp(0, 40, xtempl);
249 std::vector<double> ytemp(
BYSIZE);
251 ytemp[
i]=(1.-yfrac)*ytempl[ybin][
i]+yfrac*ytempl[ybin+1][
i];
254 std::vector<double> xtemp(
BXSIZE);
256 xtemp[
i]=(1.-xfrac)*xtempl[xbin][
i]+xfrac*xtempl[xbin+1][
i];
260 const float qThreshold = templ.
s50()*2.0;
264 int offsetX1=0, offsetX2=0, offsetY1=0, offsetY2=0;
265 int firstY, lastY, firstX, lastX;
266 for( firstY = 0; firstY <
BYSIZE; ++firstY ) {
267 bool yCluster = ytemp[firstY] > qThreshold ;
270 offsetY1 =
BHY -firstY;
274 for( lastY = firstY; lastY <
BYSIZE; ++lastY )
276 bool yCluster = ytemp[lastY] > qThreshold ;
280 offsetY2 = lastY -
BHY;
285 for( firstX = 0; firstX <
BXSIZE; ++firstX ) {
286 bool xCluster = xtemp[firstX] > qThreshold ;
288 offsetX1 =
BHX - firstX;
292 for( lastX = firstX; lastX <
BXSIZE; ++ lastX ) {
293 bool xCluster = xtemp[lastX] > qThreshold ;
296 offsetX2 = lastX -
BHX;
301 bool edge, edgex, edgey;
303 unsigned int clslenx = offsetX1 + offsetX2 + 1;
304 unsigned int clsleny = offsetY1 + offsetY2 + 1;
309 int firstPixelInX = (int)mpx - offsetX1 ;
310 int firstPixelInY = (int)mpy - offsetY1 ;
311 int lastPixelInX = (int)mpx + offsetX2 ;
312 int lastPixelInY = (int)mpy + offsetY2 ;
313 firstPixelInX = (firstPixelInX >= 0) ? firstPixelInX : 0 ;
314 firstPixelInY = (firstPixelInY >= 0) ? firstPixelInY : 0 ;
315 lastPixelInX = (lastPixelInX < nrows ) ? lastPixelInX : nrows-1 ;
316 lastPixelInY = (lastPixelInY < ncolumns ) ? lastPixelInY : ncolumns-1;
320 edge = edgex || edgey;
324 bool hasBigPixelInX = rectPixelTopology->
containsBigPixelInX( firstPixelInX, lastPixelInX );
325 bool hasBigPixelInY = rectPixelTopology->
containsBigPixelInY( firstPixelInY, lastPixelInY );
328 float sigmay, sigmax, sy1, sy2, sx1, sx2;
329 templ.
temperrors(
tempId, cotalpha, cotbeta, nqbin, sigmay, sigmax, sy1, sy2, sx1, sx2 );
333 if( edgex && !edgey ) {
337 else if( !edgex && edgey ) {
369 <<
"\talpha(x) = " << theErrorX
370 <<
"\tbeta(y) = " << theErrorY
378 if( cotalphaHistBin < 1 ) cotalphaHistBin = 1;
379 if( cotbetaHistBin < 1 ) cotbetaHistBin = 1;
383 unsigned int theXHistN;
384 unsigned int theYHistN;
388 theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
389 theYHistN = theXHistN;
395 if(hitbigx) theXHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
396 else theXHistN = 1 * 100000 + 1 * 1000 + cotalphaHistBin * 100 + cotbetaHistBin ;
400 if(hasBigPixelInX) theXHistN = 1 * 1000000 + 1 * 100000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
401 else theXHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
405 if(hitbigy) theYHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
406 else theYHistN = 1 * 100000 + 1 * 1000 + cotalphaHistBin * 100 + cotbetaHistBin ;
410 if(hasBigPixelInY) theYHistN = 1 * 1000000 + 1 * 100000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
411 else theYHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
419 theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
420 theYHistN = theXHistN;
426 theXHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
428 theXHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
430 theXHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
433 theYHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
435 theYHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
437 theYHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
457 <<
"\t\tx = " << boundX
458 <<
"\ty = " << boundY
460 std::cout <<
" Generated local position "
494 if ( tmp2<tmp1 )
return true;
512 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
513 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin ) {
514 unsigned int singleBigPixelHistN = 1 * 100000
515 + cotalphaHistBin * 100
521 unsigned int singlePixelHistN = 1 * 100000 + 1 * 1000
522 + cotalphaHistBin * 100
528 for(
unsigned qbinBin=1; qbinBin<=
resqbin_binN; ++qbinBin ) {
529 unsigned int edgePixelHistN = cotalphaHistBin * 1000
530 + cotbetaHistBin * 10
536 unsigned int multiPixelBigHistN = 1 * 1000000 + 1 * 100000
537 + cotalphaHistBin * 1000
538 + cotbetaHistBin * 10
544 unsigned int multiPixelHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000
545 + cotalphaHistBin * 1000
546 + cotbetaHistBin * 10
570 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
571 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin )
572 for(
unsigned qbinBin=1; qbinBin<=
resqbin_binN; ++qbinBin ) {
573 unsigned int edgePixelHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + qbinBin;
578 unsigned int PixelHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + qbinBin;
585 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
586 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin )
588 unsigned int SingleBigPixelHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
593 unsigned int SinglePixelHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
bool containsBigPixelInY(int iymin, int iymax) const
double rescotAlpha_binMin
bool isFlipped(const PixelGeomDetUnit *theDet) const
bool isItEdgePixelInY(int iybin) const
std::string thePixelResolutionFileName2
std::vector< SiPixelTemplateStore > thePixelTemp_
double flatShoot(double xmin=0.0, double xmax=1.0) const
virtual int ncolumns() const =0
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
virtual bool isItBigPixelInY(const int iybin) const
double rescotBeta_binWidth
bool isItEdgePixelInX(int ixbin) const
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
virtual int nrows() const =0
unsigned int rescotBeta_binN
std::string thePixelResolutionFileName1
virtual MeasurementPoint measurementPosition(const LocalPoint &lp) const
const Plane & surface() const
The nominal surface of the GeomDet.
std::map< unsigned, const SimpleHistogramGenerator * > theXHistos
bool interpolate(int id, float cotalpha, float cotbeta, float locBz)
unsigned int resqbin_binN
unsigned int rescotAlpha_binN
void ytemp(int fybin, int lybin, float ytemplate[41][21+4])
Local3DPoint localPosition() const
void temperrors(int id, float cotalpha, float cotbeta, int qBin, float &sigmay, float &sigmax, float &sy1, float &sy2, float &sx1, float &sx2)
GeomDetType::SubDetector thePixelPart
bool useCMSSWPixelParameterization
bool containsBigPixelInX(int ixmin, int ixmax) const
float s50()
1/2 of the pixel threshold signal in electrons
LocalVector localDirection() const
Obsolete. Same as momentumAtEntry().unit(), for backward compatibility.
Point3DBase< float, LocalTag > Local3DPoint
Vector3DBase unit() const
virtual LocalPoint localPosition(const MeasurementPoint &mp) const
void xtemp(int fxbin, int lxbin, float xtemplate[41][13+4])
double rescotAlpha_binWidth
void qbin_dist(int id, float cotalpha, float cotbeta, float qbin_frac[4], float &ny1_frac, float &ny2_frac, float &nx1_frac, float &nx2_frac)
std::map< unsigned, const SimpleHistogramGenerator * > theYHistos
virtual const TopologyType & specificTopology() const
void smearHit(const PSimHit &simHit, const PixelGeomDetUnit *detUnit, const double boundX, const double boundY, RandomEngineAndDistribution const *)
virtual ~SiPixelGaussianSmearingRecHitConverterAlgorithm()
static std::atomic< unsigned int > counter
virtual bool isItBigPixelInX(const int ixbin) const
SiPixelGaussianSmearingRecHitConverterAlgorithm(const edm::ParameterSet &pset, GeomDetType::SubDetector pixelPart)
for(const auto &isodef:isoDefs)
TFile * thePixelResolutionFile1
virtual const PixelGeomDetType & specificType() const
TFile * thePixelResolutionFile2