45 thePixelPart(pixelPart)
61 throw cms::Exception(
"SiPixelGaussianSmearingRecHitConverterAlgorithm:")
62 <<
"SiPixel Barrel Template Not Loaded Correctly!"<<endl;
76 throw cms::Exception(
"SiPixelGaussianSmearingRecHitConverterAlgorithm:")
77 <<
"SiPixel Forward Template Not Loaded Correctly!"<<endl;
83 throw cms::Exception(
"SiPixelGaussianSmearingRecHitConverterAlgorithm :")
84 <<
"Not a pixel detector"<<endl;
90 std::map<unsigned,const SimpleHistogramGenerator*>::const_iterator it;
117 float locx = localDir.
x();
118 float locy = localDir.
y();
119 float locz = localDir.
z();
122 float cotalpha = locx/locz;
129 float cotbeta = locy/locz;
132 if( cotbeta < 0 ) sign=-1.;
133 cotbeta = sign*cotbeta;
140 <<
" cotalpha(x) = " << cotalpha
141 <<
" cotbeta(y) = " << cotbeta
146 const RectangularPixelTopology *rectPixelTopology =
static_cast<const RectangularPixelTopology*
>(theSpecificTopology);
148 const int nrows = theSpecificTopology->
nrows();
149 const int ncolumns = theSpecificTopology->
ncolumns();
157 float pixelCenterY = 0.5 + (int)mpy;
158 float pixelCenterX = 0.5 + (int)mpx;
160 cout<<
"Struck pixel center at pitch units x: "<<pixelCenterX<<
" y: "<<pixelCenterY<<endl;
165 const Local3DPoint lpCenter = rectPixelTopology->localPosition( mpCenter );
167 cout<<
"Struck point at cm x: "<<lp.
x()<<
" y: "<<lp.
y()<<endl;
168 cout<<
"Struck pixel center at cm x: "<<lpCenter.
x()<<
" y: "<<lpCenter.
y()<<endl;
169 cout<<
"The boundX is "<<boundX<<
" boundY is "<<boundY<<endl;
173 float xtrk = lp.
x() - lpCenter.
x();
174 float ytrk = lp.
y() - lpCenter.
y();
176 const float ysize={0.015}, xsize={0.01};
178 float yhit = 20. + 8.*(ytrk/ysize);
179 float xhit = 20. + 8.*(xtrk/xsize);
180 int ybin = (int)yhit;
181 int xbin = (int)xhit;
182 float yfrac= yhit - (float)ybin;
183 float xfrac= xhit - (float)xbin;
185 if( ybin < 0 ) ybin = 0;
186 if( ybin > 39 ) ybin = 39;
187 if( xbin < 0 ) xbin = 0;
188 if( xbin > 39 ) xbin = 39;
194 float ny1_frac, ny2_frac, nx1_frac, nx2_frac;
195 bool singlex =
false, singley =
false;
198 templ.
qbin_dist(
tempId, cotalpha, cotbeta, qbin_frac, ny1_frac, ny2_frac, nx1_frac, nx2_frac );
201 double xsizeProbability = random->
flatShoot();
202 double ysizeProbability = random->
flatShoot();
203 bool hitbigx = rectPixelTopology->isItBigPixelInX( (
int)mpx );
204 bool hitbigy = rectPixelTopology->isItBigPixelInY( (
int)mpy );
207 if( xsizeProbability < nx2_frac ) singlex =
true;
208 else singlex =
false;
210 if( xsizeProbability < nx1_frac ) singlex =
true;
211 else singlex =
false;
214 if( ysizeProbability < ny2_frac ) singley =
true;
215 else singley =
false;
217 if( ysizeProbability < ny1_frac ) singley =
true;
218 else singley =
false;
223 double qbinProbability = random->
flatShoot();
224 for(
int i = 0;
i<4; ++
i) {
226 if(qbinProbability < qbin_frac[
i])
break;
231 float ytempl[41][
BYSIZE] = {{0}}, xtempl[41][
BXSIZE] = {{0}} ;
232 templ.
ytemp(0, 40, ytempl);
233 templ.
xtemp(0, 40, xtempl);
235 std::vector<double> ytemp(
BYSIZE);
237 ytemp[
i]=(1.-yfrac)*ytempl[ybin][
i]+yfrac*ytempl[ybin+1][
i];
240 std::vector<double> xtemp(
BXSIZE);
242 xtemp[
i]=(1.-xfrac)*xtempl[xbin][
i]+xfrac*xtempl[xbin+1][
i];
246 const float qThreshold = templ.
s50()*2.0;
250 int offsetX1=0, offsetX2=0, offsetY1=0, offsetY2=0;
251 int firstY, lastY, firstX, lastX;
252 for( firstY = 0; firstY <
BYSIZE; ++firstY ) {
253 bool yCluster = ytemp[firstY] > qThreshold ;
256 offsetY1 =
BHY -firstY;
260 for( lastY = firstY; lastY <
BYSIZE; ++lastY )
262 bool yCluster = ytemp[lastY] > qThreshold ;
266 offsetY2 = lastY -
BHY;
271 for( firstX = 0; firstX <
BXSIZE; ++firstX ) {
272 bool xCluster = xtemp[firstX] > qThreshold ;
274 offsetX1 =
BHX - firstX;
278 for( lastX = firstX; lastX <
BXSIZE; ++ lastX ) {
279 bool xCluster = xtemp[lastX] > qThreshold ;
282 offsetX2 = lastX -
BHX;
287 bool edge, edgex, edgey;
289 unsigned int clslenx = offsetX1 + offsetX2 + 1;
290 unsigned int clsleny = offsetY1 + offsetY2 + 1;
295 int firstPixelInX = (int)mpx - offsetX1 ;
296 int firstPixelInY = (int)mpy - offsetY1 ;
297 int lastPixelInX = (int)mpx + offsetX2 ;
298 int lastPixelInY = (int)mpy + offsetY2 ;
299 firstPixelInX = (firstPixelInX >= 0) ? firstPixelInX : 0 ;
300 firstPixelInY = (firstPixelInY >= 0) ? firstPixelInY : 0 ;
301 lastPixelInX = (lastPixelInX < nrows ) ? lastPixelInX : nrows-1 ;
302 lastPixelInY = (lastPixelInY < ncolumns ) ? lastPixelInY : ncolumns-1;
304 edgex = rectPixelTopology->isItEdgePixelInX( firstPixelInX ) || rectPixelTopology->isItEdgePixelInX( lastPixelInX );
305 edgey = rectPixelTopology->isItEdgePixelInY( firstPixelInY ) || rectPixelTopology->isItEdgePixelInY( lastPixelInY );
306 edge = edgex || edgey;
310 bool hasBigPixelInX = rectPixelTopology->containsBigPixelInX( firstPixelInX, lastPixelInX );
311 bool hasBigPixelInY = rectPixelTopology->containsBigPixelInY( firstPixelInY, lastPixelInY );
314 float sigmay, sigmax, sy1, sy2, sx1, sx2;
315 templ.
temperrors(
tempId, cotalpha, cotbeta, nqbin, sigmay, sigmax, sy1, sy2, sx1, sx2 );
319 if( edgex && !edgey ) {
323 else if( !edgex && edgey ) {
355 <<
"\talpha(x) = " << theErrorX
356 <<
"\tbeta(y) = " << theErrorY
364 if( cotalphaHistBin < 1 ) cotalphaHistBin = 1;
365 if( cotbetaHistBin < 1 ) cotbetaHistBin = 1;
369 unsigned int theXHistN;
370 unsigned int theYHistN;
374 theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
375 theYHistN = theXHistN;
381 if(hitbigx) theXHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
382 else theXHistN = 1 * 100000 + 1 * 1000 + cotalphaHistBin * 100 + cotbetaHistBin ;
386 if(hasBigPixelInX) theXHistN = 1 * 1000000 + 1 * 100000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
387 else theXHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
391 if(hitbigy) theYHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
392 else theYHistN = 1 * 100000 + 1 * 1000 + cotalphaHistBin * 100 + cotbetaHistBin ;
396 if(hasBigPixelInY) theYHistN = 1 * 1000000 + 1 * 100000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
397 else theYHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
405 theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
406 theYHistN = theXHistN;
412 theXHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
414 theXHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
416 theXHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
419 theYHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
421 theYHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
423 theYHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
443 <<
"\t\tx = " << boundX
444 <<
"\ty = " << boundY
446 std::cout <<
" Generated local position "
480 if ( tmp2<tmp1 )
return true;
498 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
499 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin ) {
500 unsigned int singleBigPixelHistN = 1 * 100000
501 + cotalphaHistBin * 100
507 unsigned int singlePixelHistN = 1 * 100000 + 1 * 1000
508 + cotalphaHistBin * 100
514 for(
unsigned qbinBin=1; qbinBin<=
resqbin_binN; ++qbinBin ) {
515 unsigned int edgePixelHistN = cotalphaHistBin * 1000
516 + cotbetaHistBin * 10
522 unsigned int multiPixelBigHistN = 1 * 1000000 + 1 * 100000
523 + cotalphaHistBin * 1000
524 + cotbetaHistBin * 10
530 unsigned int multiPixelHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000
531 + cotalphaHistBin * 1000
532 + cotbetaHistBin * 10
556 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
557 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin )
558 for(
unsigned qbinBin=1; qbinBin<=
resqbin_binN; ++qbinBin ) {
559 unsigned int edgePixelHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + qbinBin;
564 unsigned int PixelHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + qbinBin;
571 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
572 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin )
574 unsigned int SingleBigPixelHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
579 unsigned int SinglePixelHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
double rescotAlpha_binMin
bool isFlipped(const PixelGeomDetUnit *theDet) 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.
double rescotBeta_binWidth
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
virtual int nrows() const =0
unsigned int rescotBeta_binN
std::string thePixelResolutionFileName1
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
Local3DPoint localPosition() const
void xtemp(int fxbin, int lxbin, float xtemplate[41][BXSIZE])
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
void ytemp(int fybin, int lybin, float ytemplate[41][BYSIZE])
bool useCMSSWPixelParameterization
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
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
for(const auto &pset:thresholds)
void smearHit(const PSimHit &simHit, const PixelGeomDetUnit *detUnit, const double boundX, const double boundY, RandomEngineAndDistribution const *)
virtual ~SiPixelGaussianSmearingRecHitConverterAlgorithm()
static std::atomic< unsigned int > counter
SiPixelGaussianSmearingRecHitConverterAlgorithm(const edm::ParameterSet &pset, GeomDetType::SubDetector pixelPart)
TFile * thePixelResolutionFile1
virtual const PixelGeomDetType & specificType() const
TFile * thePixelResolutionFile2