45 thePixelPart(pixelPart)
54 throw cms::Exception(
"SiPixelGaussianSmearingRecHitConverterAlgorithm :")
55 <<
"Not a pixel detector"<<endl;
60 thePixelResolutionFile1 =
new
72 throw cms::Exception(
"SiPixelGaussianSmearingRecHitConverterAlgorithm:")
73 <<
"SiPixel Barrel Template Not Loaded Correctly!"<<endl;
81 thePixelResolutionFile1 =
new
90 throw cms::Exception(
"SiPixelGaussianSmearingRecHitConverterAlgorithm:")
91 <<
"SiPixel Forward Template Not Loaded Correctly!"<<endl;
101 if ( thePixelResolutionFile1) {
102 thePixelResolutionFile1->Close();
105 thePixelResolutionFile1=0;
112 std::map<unsigned,const SimpleHistogramGenerator*>::const_iterator it;
139 float locx = localDir.
x();
140 float locy = localDir.
y();
141 float locz = localDir.
z();
144 float cotalpha = locx/locz;
151 float cotbeta = locy/locz;
154 if( cotbeta < 0 ) sign=-1.;
155 cotbeta = sign*cotbeta;
162 <<
" cotalpha(x) = " << cotalpha
163 <<
" cotbeta(y) = " << cotbeta
170 const int nrows = theSpecificTopology->
nrows();
171 const int ncolumns = theSpecificTopology->
ncolumns();
179 float pixelCenterY = 0.5 + (int)mpy;
180 float pixelCenterX = 0.5 + (int)mpx;
182 cout<<
"Struck pixel center at pitch units x: "<<pixelCenterX<<
" y: "<<pixelCenterY<<endl;
189 cout<<
"Struck point at cm x: "<<lp.
x()<<
" y: "<<lp.
y()<<endl;
190 cout<<
"Struck pixel center at cm x: "<<lpCenter.
x()<<
" y: "<<lpCenter.
y()<<endl;
191 cout<<
"The boundX is "<<boundX<<
" boundY is "<<boundY<<endl;
195 float xtrk = lp.
x() - lpCenter.
x();
196 float ytrk = lp.
y() - lpCenter.
y();
200 float yhit = 20. + 8.*(ytrk/
ysize);
201 float xhit = 20. + 8.*(xtrk/
xsize);
202 int ybin = (int)yhit;
203 int xbin = (int)xhit;
204 float yfrac= yhit - (float)ybin;
205 float xfrac= xhit - (float)xbin;
207 if( ybin < 0 ) ybin = 0;
208 if( ybin > 39 ) ybin = 39;
209 if( xbin < 0 ) xbin = 0;
210 if( xbin > 39 ) xbin = 39;
216 float ny1_frac, ny2_frac, nx1_frac, nx2_frac;
217 bool singlex =
false, singley =
false;
220 templ.
qbin_dist(
tempId, cotalpha, cotbeta, qbin_frac, ny1_frac, ny2_frac, nx1_frac, nx2_frac );
223 double xsizeProbability = random->
flatShoot();
224 double ysizeProbability = random->
flatShoot();
229 if( xsizeProbability < nx2_frac ) singlex =
true;
230 else singlex =
false;
232 if( xsizeProbability < nx1_frac ) singlex =
true;
233 else singlex =
false;
236 if( ysizeProbability < ny2_frac ) singley =
true;
237 else singley =
false;
239 if( ysizeProbability < ny1_frac ) singley =
true;
240 else singley =
false;
245 double qbinProbability = random->
flatShoot();
246 for(
int i = 0;
i<4; ++
i) {
248 if(qbinProbability < qbin_frac[
i])
break;
253 float ytempl[41][
BYSIZE] = {{0}}, xtempl[41][
BXSIZE] = {{0}} ;
254 templ.
ytemp(0, 40, ytempl);
255 templ.
xtemp(0, 40, xtempl);
257 std::vector<double> ytemp(
BYSIZE);
259 ytemp[
i]=(1.-yfrac)*ytempl[ybin][
i]+yfrac*ytempl[ybin+1][
i];
262 std::vector<double> xtemp(
BXSIZE);
264 xtemp[
i]=(1.-xfrac)*xtempl[xbin][
i]+xfrac*xtempl[xbin+1][
i];
268 const float qThreshold = templ.
s50()*2.0;
272 int offsetX1=0, offsetX2=0, offsetY1=0, offsetY2=0;
273 int firstY, lastY, firstX, lastX;
274 for( firstY = 0; firstY <
BYSIZE; ++firstY ) {
275 bool yCluster = ytemp[firstY] > qThreshold ;
278 offsetY1 =
BHY -firstY;
282 for( lastY = firstY; lastY <
BYSIZE; ++lastY )
284 bool yCluster = ytemp[lastY] > qThreshold ;
288 offsetY2 = lastY -
BHY;
293 for( firstX = 0; firstX <
BXSIZE; ++firstX ) {
294 bool xCluster = xtemp[firstX] > qThreshold ;
296 offsetX1 =
BHX - firstX;
300 for( lastX = firstX; lastX <
BXSIZE; ++ lastX ) {
301 bool xCluster = xtemp[lastX] > qThreshold ;
304 offsetX2 = lastX -
BHX;
309 bool edge, edgex, edgey;
311 unsigned int clslenx = offsetX1 + offsetX2 + 1;
312 unsigned int clsleny = offsetY1 + offsetY2 + 1;
317 int firstPixelInX = (int)mpx - offsetX1 ;
318 int firstPixelInY = (int)mpy - offsetY1 ;
319 int lastPixelInX = (int)mpx + offsetX2 ;
320 int lastPixelInY = (int)mpy + offsetY2 ;
321 firstPixelInX = (firstPixelInX >= 0) ? firstPixelInX : 0 ;
322 firstPixelInY = (firstPixelInY >= 0) ? firstPixelInY : 0 ;
323 lastPixelInX = (lastPixelInX < nrows ) ? lastPixelInX : nrows-1 ;
324 lastPixelInY = (lastPixelInY < ncolumns ) ? lastPixelInY : ncolumns-1;
328 edge = edgex || edgey;
332 bool hasBigPixelInX = rectPixelTopology->
containsBigPixelInX( firstPixelInX, lastPixelInX );
333 bool hasBigPixelInY = rectPixelTopology->
containsBigPixelInY( firstPixelInY, lastPixelInY );
336 float sigmay, sigmax, sy1, sy2, sx1, sx2;
337 templ.
temperrors(
tempId, cotalpha, cotbeta, nqbin, sigmay, sigmax, sy1, sy2, sx1, sx2 );
341 if( edgex && !edgey ) {
345 else if( !edgex && edgey ) {
377 <<
"\talpha(x) = " << theErrorX
378 <<
"\tbeta(y) = " << theErrorY
386 if( cotalphaHistBin < 1 ) cotalphaHistBin = 1;
387 if( cotbetaHistBin < 1 ) cotbetaHistBin = 1;
391 unsigned int theXHistN;
392 unsigned int theYHistN;
397 theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
398 theYHistN = theXHistN;
404 if(hitbigx) theXHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
405 else theXHistN = 1 * 10000 + cotbetaHistBin * 10 + cotalphaHistBin ;
410 if(hasBigPixelInX) theXHistN = 1 * 1000000 + 1 * 100000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
411 else theXHistN = 1 * 100000 + 1 * 10000 + cotbetaHistBin * 100 + cotalphaHistBin * 10 + (nqbin+1);
416 if(hitbigy) theYHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
417 else theYHistN = 1 * 10000 + cotbetaHistBin * 10 + cotalphaHistBin ;
422 if(hasBigPixelInY) theYHistN = 1 * 1000000 + 1 * 100000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
424 else theYHistN = 1 * 100000 + 1 * 10000 + cotbetaHistBin * 100 + cotalphaHistBin * 10 + (nqbin+1);
433 theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
434 theYHistN = theXHistN;
440 theXHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
442 theXHistN = cotbetaHistBin * 10 + cotalphaHistBin;
446 theXHistN = 10000 + cotbetaHistBin * 100 + cotalphaHistBin * 10 + (nqbin+1);
451 theYHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
453 theYHistN = cotbetaHistBin * 10 + cotalphaHistBin;
457 theYHistN = 10000 + cotbetaHistBin * 100 + cotalphaHistBin * 10 + (nqbin+1);
479 <<
"\t\tx = " << boundX
480 <<
"\ty = " << boundY
482 std::cout <<
" Generated local position "
516 if ( tmp2<tmp1 )
return true;
534 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
535 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin ) {
536 unsigned int singleBigPixelHistN = 1 * 100000
537 + cotalphaHistBin * 100
550 unsigned int singlePixelHistN = 1 * 10000
551 + cotbetaHistBin * 10
558 for(
unsigned qbinBin=1; qbinBin<=
resqbin_binN; ++qbinBin ) {
559 unsigned int edgePixelHistN = cotalphaHistBin * 1000
560 + cotbetaHistBin * 10
566 unsigned int multiPixelBigHistN = 1 * 1000000 + 1 * 100000
567 + cotalphaHistBin * 1000
568 + cotbetaHistBin * 10
582 unsigned int multiPixelHistN = 1 * 100000 + 1 * 10000
583 + cotbetaHistBin * 100
584 + cotalphaHistBin * 10
608 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
609 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin )
610 for(
unsigned qbinBin=1; qbinBin<=
resqbin_binN; ++qbinBin ) {
611 unsigned int edgePixelHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + qbinBin;
621 unsigned int PixelHistN = 10000 + cotbetaHistBin * 100 + cotalphaHistBin * 10 + qbinBin;
629 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
630 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin )
632 unsigned int SingleBigPixelHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
642 unsigned int SinglePixelHistN = cotbetaHistBin * 10 + cotalphaHistBin;
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 isBarrel(GeomDetEnumerators::SubDetector m)
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])
std::string thePixelResolutionFileName3
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
TFile * thePixelResolutionFile3
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
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)
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