37 const double PI = 3.14159265358979323;
47 thePixelPart(pixelPart),
64 throw cms::Exception(
"SiPixelGaussianSmearingRecHitConverterAlgorithm:")
65 <<
"SiPixel Barrel Template Not Loaded Correctly!"<<endl;
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 std::map<unsigned,const SimpleHistogramGenerator*>::const_iterator it;
119 float locx = localDir.
x();
120 float locy = localDir.
y();
121 float locz = localDir.
z();
124 float cotalpha = locx/locz;
131 float cotbeta = locy/locz;
134 if( cotbeta < 0 ) sign=-1.;
135 cotbeta = sign*cotbeta;
142 <<
" cotalpha(x) = " << cotalpha
143 <<
" cotbeta(y) = " << cotbeta
150 theSpecificTopology->
pitch().first,
151 theSpecificTopology->
pitch().second);
152 const int nrows = theSpecificTopology->
nrows();
153 const int ncolumns = theSpecificTopology->
ncolumns();
161 float pixelCenterY = 0.5 + (int)mpy;
162 float pixelCenterX = 0.5 + (int)mpx;
164 cout<<
"Struck pixel center at pitch units x: "<<pixelCenterX<<
" y: "<<pixelCenterY<<endl;
169 const Local3DPoint lpCenter = rectPixelTopology.localPosition( mpCenter );
171 cout<<
"Struck point at cm x: "<<lp.
x()<<
" y: "<<lp.
y()<<endl;
172 cout<<
"Struck pixel center at cm x: "<<lpCenter.
x()<<
" y: "<<lpCenter.
y()<<endl;
173 cout<<
"The boundX is "<<boundX<<
" boundY is "<<boundY<<endl;
177 float xtrk = lp.
x() - lpCenter.
x();
178 float ytrk = lp.
y() - lpCenter.
y();
180 const float ysize={0.015}, xsize={0.01};
182 float yhit = 20. + 8.*(ytrk/ysize);
183 float xhit = 20. + 8.*(xtrk/xsize);
184 int ybin = (int)yhit;
185 int xbin = (int)xhit;
186 float yfrac= yhit - (float)ybin;
187 float xfrac= xhit - (float)xbin;
189 if( ybin < 0 ) ybin = 0;
190 if( ybin > 39 ) ybin = 39;
191 if( xbin < 0 ) xbin = 0;
192 if( xbin > 39 ) xbin = 39;
198 float ny1_frac, ny2_frac, nx1_frac, nx2_frac;
199 bool singlex =
false, singley =
false;
206 bool hitbigx = rectPixelTopology.isItBigPixelInX( (
int)mpx );
207 bool hitbigy = rectPixelTopology.isItBigPixelInY( (
int)mpy );
210 if( xsizeProbability < nx2_frac ) singlex =
true;
211 else singlex =
false;
213 if( xsizeProbability < nx1_frac ) singlex =
true;
214 else singlex =
false;
217 if( ysizeProbability < ny2_frac ) singley =
true;
218 else singley =
false;
220 if( ysizeProbability < ny1_frac ) singley =
true;
221 else singley =
false;
227 for(
int i = 0;
i<4; ++
i) {
229 if(qbinProbability < qbin_frac[
i])
break;
234 float ytempl[41][
BYSIZE] = {{0}}, xtempl[41][
BXSIZE] = {{0}} ;
238 std::vector<double> ytemp(
BYSIZE);
240 ytemp[
i]=(1.-yfrac)*ytempl[ybin][
i]+yfrac*ytempl[ybin+1][
i];
243 std::vector<double> xtemp(
BXSIZE);
245 xtemp[
i]=(1.-xfrac)*xtempl[xbin][
i]+xfrac*xtempl[xbin+1][
i];
249 const float qThreshold =
templ.
s50()*2.0;
253 int offsetX1=0, offsetX2=0, offsetY1=0, offsetY2=0;
254 int firstY, lastY, firstX, lastX;
255 for( firstY = 0; firstY <
BYSIZE; ++firstY ) {
256 bool yCluster = ytemp[firstY] > qThreshold ;
259 offsetY1 =
BHY -firstY;
263 for( lastY = firstY; lastY <
BYSIZE; ++lastY )
265 bool yCluster = ytemp[lastY] > qThreshold ;
269 offsetY2 = lastY -
BHY;
274 for( firstX = 0; firstX <
BXSIZE; ++firstX ) {
275 bool xCluster = xtemp[firstX] > qThreshold ;
277 offsetX1 =
BHX - firstX;
281 for( lastX = firstX; lastX <
BXSIZE; ++ lastX ) {
282 bool xCluster = xtemp[lastX] > qThreshold ;
285 offsetX2 = lastX -
BHX;
290 bool edge, edgex, edgey;
292 unsigned int clslenx = offsetX1 + offsetX2 + 1;
293 unsigned int clsleny = offsetY1 + offsetY2 + 1;
298 int firstPixelInX = (int)mpx - offsetX1 ;
299 int firstPixelInY = (int)mpy - offsetY1 ;
300 int lastPixelInX = (int)mpx + offsetX2 ;
301 int lastPixelInY = (int)mpy + offsetY2 ;
302 firstPixelInX = (firstPixelInX >= 0) ? firstPixelInX : 0 ;
303 firstPixelInY = (firstPixelInY >= 0) ? firstPixelInY : 0 ;
304 lastPixelInX = (lastPixelInX < nrows ) ? lastPixelInX : nrows-1 ;
305 lastPixelInY = (lastPixelInY < ncolumns ) ? lastPixelInY : ncolumns-1;
307 edgex = rectPixelTopology.isItEdgePixelInX( firstPixelInX ) || rectPixelTopology.isItEdgePixelInX( lastPixelInX );
308 edgey = rectPixelTopology.isItEdgePixelInY( firstPixelInY ) || rectPixelTopology.isItEdgePixelInY( lastPixelInY );
309 edge = edgex || edgey;
311 bigx = rectPixelTopology.isItBigPixelInX( firstPixelInX ) || rectPixelTopology.isItBigPixelInX( lastPixelInX );
312 bigy = rectPixelTopology.isItBigPixelInY( firstPixelInY ) || rectPixelTopology.isItBigPixelInY( lastPixelInY );
313 bool hasBigPixelInX = rectPixelTopology.containsBigPixelInX( firstPixelInX, lastPixelInX );
314 bool hasBigPixelInY = rectPixelTopology.containsBigPixelInY( firstPixelInY, lastPixelInY );
317 float sigmay, sigmax, sy1, sy2, sx1, sx2;
322 if( edgex && !edgey ) {
326 else if( !edgex && edgey ) {
358 <<
"\talpha(x) = " << theErrorX
359 <<
"\tbeta(y) = " << theErrorY
367 if( cotalphaHistBin < 1 ) cotalphaHistBin = 1;
368 if( cotbetaHistBin < 1 ) cotbetaHistBin = 1;
372 unsigned int theXHistN;
373 unsigned int theYHistN;
377 theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
378 theYHistN = theXHistN;
384 if(hitbigx) theXHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
385 else theXHistN = 1 * 100000 + 1 * 1000 + cotalphaHistBin * 100 + cotbetaHistBin ;
389 if(hasBigPixelInX) theXHistN = 1 * 1000000 + 1 * 100000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
390 else theXHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
394 if(hitbigy) theYHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
395 else theYHistN = 1 * 100000 + 1 * 1000 + cotalphaHistBin * 100 + cotbetaHistBin ;
399 if(hasBigPixelInY) theYHistN = 1 * 1000000 + 1 * 100000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
400 else theYHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
408 theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
409 theYHistN = theXHistN;
415 theXHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
417 theXHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
419 theXHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
422 theYHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
424 theYHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
426 theYHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
446 <<
"\t\tx = " << boundX
447 <<
"\ty = " << boundY
449 std::cout <<
" Generated local position "
483 if ( tmp2<tmp1 )
return true;
501 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
502 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin ) {
503 unsigned int singleBigPixelHistN = 1 * 100000
504 + cotalphaHistBin * 100
512 unsigned int singlePixelHistN = 1 * 100000 + 1 * 1000
513 + cotalphaHistBin * 100
521 for(
unsigned qbinBin=1; qbinBin<=
resqbin_binN; ++qbinBin ) {
522 unsigned int edgePixelHistN = cotalphaHistBin * 1000
523 + cotbetaHistBin * 10
529 unsigned int multiPixelBigHistN = 1 * 1000000 + 1 * 100000
530 + cotalphaHistBin * 1000
531 + cotbetaHistBin * 10
537 unsigned int multiPixelHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000
538 + cotalphaHistBin * 1000
539 + cotbetaHistBin * 10
565 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
566 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin )
567 for(
unsigned qbinBin=1; qbinBin<=
resqbin_binN; ++qbinBin ) {
568 unsigned int edgePixelHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + qbinBin;
573 unsigned int PixelHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + qbinBin;
580 for (
unsigned cotalphaHistBin=1; cotalphaHistBin<=
rescotAlpha_binN; ++cotalphaHistBin )
581 for (
unsigned cotbetaHistBin=1; cotbetaHistBin<=
rescotBeta_binN; ++cotbetaHistBin )
583 unsigned int SingleBigPixelHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
588 unsigned int SinglePixelHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
SiPixelGaussianSmearingRecHitConverterAlgorithm(const edm::ParameterSet &pset, GeomDetType::SubDetector pixelPart, const RandomEngine *engine)
double rescotAlpha_binMin
bool isFlipped(const PixelGeomDetUnit *theDet) const
std::string thePixelResolutionFileName2
virtual int ncolumns() const =0
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
double rescotBeta_binWidth
virtual int nrows() const =0
unsigned int rescotBeta_binN
std::string thePixelResolutionFileName1
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])
const RandomEngine * random
bool useCMSSWPixelParameterization
float s50()
1/2 of the pixel threshold signal in electrons
virtual std::pair< float, float > pitch() const =0
LocalVector localDirection() const
Obsolete. Same as momentumAtEntry().unit(), for backward compatibility.
Point3DBase< float, LocalTag > Local3DPoint
Vector3DBase unit() const
bool pushfile(int filenum)
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 PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
double flatShoot(double xmin=0.0, double xmax=1.0) const
virtual ~SiPixelGaussianSmearingRecHitConverterAlgorithm()
void smearHit(const PSimHit &simHit, const PixelGeomDetUnit *detUnit, const double boundX, const double boundY)
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
TFile * thePixelResolutionFile1
TFile * thePixelResolutionFile2