CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelGaussianSmearingRecHitConverterAlgorithm.cc
Go to the documentation of this file.
1 
13 // SiPixel Gaussian Smearing
15 
16 // Geometry
17 //#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
19 //#include "Geometry/CommonDetUnit/interface/GeomDetType.h"
23 
24 // Famos
27 
28 // STL
29 
30 // ROOT
31 #include <TFile.h>
32 #include <TH1F.h>
33 //#include <TAxis.h>
34 
35 //#define FAMOS_DEBUG
36 
37 const double PI = 3.14159265358979323;
38 const double microntocm = 0.0001;
39 using namespace std;
40 
42  const edm::ParameterSet& pset,
43  GeomDetType::SubDetector pixelPart)
44 :
45  pset_(pset),
46  thePixelPart(pixelPart)
47 {
48  // Switch between old (ORCA) and new (CMSSW) pixel parameterization
49  useCMSSWPixelParameterization = pset.getParameter<bool>("UseCMSSWPixelParametrization");
50 
52  isForward = false;
53  thePixelResolutionFileName1 = pset_.getParameter<string>( "NewPixelBarrelResolutionFile1" );
55  TFile( edm::FileInPath( thePixelResolutionFileName1 ).fullPath().c_str() ,"READ");
56  thePixelResolutionFileName2 = pset_.getParameter<string>( "NewPixelBarrelResolutionFile2" );
58  TFile( edm::FileInPath( thePixelResolutionFileName2 ).fullPath().c_str() ,"READ");
60  tempId = pset_.getParameter<int> ( "templateIdBarrel" );
61  if( ! templ.pushfile(tempId) )
62  throw cms::Exception("SiPixelGaussianSmearingRecHitConverterAlgorithm:")
63  <<"SiPixel Barrel Template Not Loaded Correctly!"<<endl;
64 #ifdef FAMOS_DEBUG
65  cout<<"The Barrel map size is "<<theXHistos.size()<<" and "<<theYHistos.size()<<endl;
66 #endif
67  }
68  else
70  isForward = true;
71  thePixelResolutionFileName1 = pset_.getParameter<string>( "NewPixelForwardResolutionFile" );
73  TFile( edm::FileInPath( thePixelResolutionFileName1 ).fullPath().c_str() ,"READ");
75  tempId = pset_.getParameter<int> ( "templateIdForward" );
76  if( ! templ.pushfile(tempId) )
77  throw cms::Exception("SiPixelGaussianSmearingRecHitConverterAlgorithm:")
78  <<"SiPixel Forward Template Not Loaded Correctly!"<<endl;
79 #ifdef FAMOS_DEBUG
80  cout<<"The Forward map size is "<<theXHistos.size()<<" and "<<theYHistos.size()<<endl;
81 #endif
82  }
83  else
84  throw cms::Exception("SiPixelGaussianSmearingRecHitConverterAlgorithm :")
85  <<"Not a pixel detector"<<endl;
86 }
87 
89 {
90 
91  std::map<unsigned,const SimpleHistogramGenerator*>::const_iterator it;
92  for ( it=theXHistos.begin(); it!=theXHistos.end(); ++it )
93  delete it->second;
94  for ( it=theYHistos.begin(); it!=theYHistos.end(); ++it )
95  delete it->second;
96 
97  theXHistos.clear();
98  theYHistos.clear();
99 
100 }
101 
103  const PSimHit& simHit,
104  const PixelGeomDetUnit* detUnit,
105  const double boundX,
106  const double boundY,
108 {
109 
110 #ifdef FAMOS_DEBUG
111  std::cout << " Pixel smearing in " << thePixelPart
112  << std::endl;
113 #endif
114  //
115  // at the beginning the position is the Local Point in the local pixel module reference frame
116  // same code as in PixelCPEBase
117  LocalVector localDir = simHit.momentumAtEntry().unit();
118  float locx = localDir.x();
119  float locy = localDir.y();
120  float locz = localDir.z();
121 
122  // alpha: angle with respect to local x axis in local (x,z) plane
123  float cotalpha = locx/locz;
124  if ( isFlipped( detUnit ) ) { // &&& check for FPIX !!!
125 #ifdef FAMOS_DEBUG
126  std::cout << " isFlipped " << std::endl;
127 #endif
128  }
129  // beta: angle with respect to local y axis in local (y,z) plane
130  float cotbeta = locy/locz;
131  float sign=1.;
132  if( isForward ) {
133  if( cotbeta < 0 ) sign=-1.;
134  cotbeta = sign*cotbeta;
135  }
136 
137 
138  //
139 #ifdef FAMOS_DEBUG
140  std::cout << " Local Direction " << simHit.localDirection()
141  << " cotalpha(x) = " << cotalpha
142  << " cotbeta(y) = " << cotbeta
143  << std::endl;
144 #endif
145 
146  const PixelTopology* theSpecificTopology = &(detUnit->specificType().specificTopology());
147  const RectangularPixelTopology *rectPixelTopology = static_cast<const RectangularPixelTopology*>(theSpecificTopology);
148 
149  const int nrows = theSpecificTopology->nrows();
150  const int ncolumns = theSpecificTopology->ncolumns();
151 
152  const Local3DPoint lp = simHit.localPosition();
153  //Transform local position to measurement position
154  const MeasurementPoint mp = rectPixelTopology->measurementPosition( lp );
155  float mpy = mp.y();
156  float mpx = mp.x();
157  //Get the center of the struck pixel in measurement position
158  float pixelCenterY = 0.5 + (int)mpy;
159  float pixelCenterX = 0.5 + (int)mpx;
160 #ifdef FAMOS_DEBUG
161  cout<<"Struck pixel center at pitch units x: "<<pixelCenterX<<" y: "<<pixelCenterY<<endl;
162 #endif
163 
164  const MeasurementPoint mpCenter(pixelCenterX, pixelCenterY);
165  //Transform the center of the struck pixel back into local position
166  const Local3DPoint lpCenter = rectPixelTopology->localPosition( mpCenter );
167 #ifdef FAMOS_DEBUG
168  cout<<"Struck point at cm x: "<<lp.x()<<" y: "<<lp.y()<<endl;
169  cout<<"Struck pixel center at cm x: "<<lpCenter.x()<<" y: "<<lpCenter.y()<<endl;
170  cout<<"The boundX is "<<boundX<<" boundY is "<<boundY<<endl;
171 #endif
172 
173  //Get the relative position of struck point to the center of the struck pixel
174  float xtrk = lp.x() - lpCenter.x();
175  float ytrk = lp.y() - lpCenter.y();
176  //Pixel Y, X pitch
177  const float ysize={0.015}, xsize={0.01};
178  //Variables for SiPixelTemplate input, see SiPixelTemplate reco
179  float yhit = 20. + 8.*(ytrk/ysize);
180  float xhit = 20. + 8.*(xtrk/xsize);
181  int ybin = (int)yhit;
182  int xbin = (int)xhit;
183  float yfrac= yhit - (float)ybin;
184  float xfrac= xhit - (float)xbin;
185  //Protect againt ybin, xbin being outside of range [0-39]
186  if( ybin < 0 ) ybin = 0;
187  if( ybin > 39 ) ybin = 39;
188  if( xbin < 0 ) xbin = 0;
189  if( xbin > 39 ) xbin = 39;
190 
191  //Variables for SiPixelTemplate output
192  //qBin -- normalized pixel charge deposition
193  float qbin_frac[4];
194  //Single pixel cluster projection possibility
195  float ny1_frac, ny2_frac, nx1_frac, nx2_frac;
196  bool singlex = false, singley = false;
197  templ.interpolate(tempId, cotalpha, cotbeta);
198  templ.qbin_dist(tempId, cotalpha, cotbeta, qbin_frac, ny1_frac, ny2_frac, nx1_frac, nx2_frac );
199  int nqbin;
200 
201  double xsizeProbability = random->flatShoot();
202  double ysizeProbability = random->flatShoot();
203  bool hitbigx = rectPixelTopology->isItBigPixelInX( (int)mpx );
204  bool hitbigy = rectPixelTopology->isItBigPixelInY( (int)mpy );
205 
206  if( hitbigx )
207  if( xsizeProbability < nx2_frac ) singlex = true;
208  else singlex = false;
209  else
210  if( xsizeProbability < nx1_frac ) singlex = true;
211  else singlex = false;
212 
213  if( hitbigy )
214  if( ysizeProbability < ny2_frac ) singley = true;
215  else singley = false;
216  else
217  if( ysizeProbability < ny1_frac ) singley = true;
218  else singley = false;
219 
220 
221 
222  // random multiplicity for alpha and beta
223  double qbinProbability = random->flatShoot();
224  for(int i = 0; i<4; ++i) {
225  nqbin = i;
226  if(qbinProbability < qbin_frac[i]) break;
227  }
228 
229  //Store interpolated pixel cluster profile
230  //BYSIZE, BXSIZE, const definition from SiPixelTemplate
231  float ytempl[41][BYSIZE] = {{0}}, xtempl[41][BXSIZE] = {{0}} ;
232  templ.ytemp(0, 40, ytempl);
233  templ.xtemp(0, 40, xtempl);
234 
235  std::vector<double> ytemp(BYSIZE);
236  for( int i=0; i<BYSIZE; ++i) {
237  ytemp[i]=(1.-yfrac)*ytempl[ybin][i]+yfrac*ytempl[ybin+1][i];
238  }
239 
240  std::vector<double> xtemp(BXSIZE);
241  for(int i=0; i<BXSIZE; ++i) {
242  xtemp[i]=(1.-xfrac)*xtempl[xbin][i]+xfrac*xtempl[xbin+1][i];
243  }
244 
245  //Pixel readout threshold
246  const float qThreshold = templ.s50()*2.0;
247 
248  //Cut away pixels below readout threshold
249  //For cluster lengths calculation
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 ;
254  if( yCluster )
255  {
256  offsetY1 = BHY -firstY;
257  break;
258  }
259  }
260  for( lastY = firstY; lastY < BYSIZE; ++lastY )
261  {
262  bool yCluster = ytemp[lastY] > qThreshold ;
263  if( !yCluster )
264  {
265  lastY = lastY - 1;
266  offsetY2 = lastY - BHY;
267  break;
268  }
269  }
270 
271  for( firstX = 0; firstX < BXSIZE; ++firstX ) {
272  bool xCluster = xtemp[firstX] > qThreshold ;
273  if( xCluster ) {
274  offsetX1 = BHX - firstX;
275  break;
276  }
277  }
278  for( lastX = firstX; lastX < BXSIZE; ++ lastX ) {
279  bool xCluster = xtemp[lastX] > qThreshold ;
280  if( !xCluster ) {
281  lastX = lastX - 1;
282  offsetX2 = lastX - BHX;
283  break;
284  }
285  }
286 
287  bool edge, edgex, edgey;
288  // bool bigx, bigy;
289  unsigned int clslenx = offsetX1 + offsetX2 + 1;
290  unsigned int clsleny = offsetY1 + offsetY2 + 1;
291 
292  theClslenx = clslenx;
293  theClsleny = clsleny;
294 
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;
303 
304  edgex = rectPixelTopology->isItEdgePixelInX( firstPixelInX ) || rectPixelTopology->isItEdgePixelInX( lastPixelInX );
305  edgey = rectPixelTopology->isItEdgePixelInY( firstPixelInY ) || rectPixelTopology->isItEdgePixelInY( lastPixelInY );
306  edge = edgex || edgey;
307 
308  // bigx = rectPixelTopology->isItBigPixelInX( firstPixelInX ) || rectPixelTopology->isItBigPixelInX( lastPixelInX );
309  // bigy = rectPixelTopology->isItBigPixelInY( firstPixelInY ) || rectPixelTopology->isItBigPixelInY( lastPixelInY );
310  bool hasBigPixelInX = rectPixelTopology->containsBigPixelInX( firstPixelInX, lastPixelInX );
311  bool hasBigPixelInY = rectPixelTopology->containsBigPixelInY( firstPixelInY, lastPixelInY );
312 
313  //Variables for SiPixelTemplate pixel hit error output
314  float sigmay, sigmax, sy1, sy2, sx1, sx2;
315  templ.temperrors(tempId, cotalpha, cotbeta, nqbin, sigmay, sigmax, sy1, sy2, sx1, sx2 );
316 
317  // define private mebers --> Errors
318  if( edge ) {
319  if( edgex && !edgey ) {
320  theErrorX = 23.0*microntocm;
321  theErrorY = 39.0*microntocm;
322  }
323  else if( !edgex && edgey ) {
324  theErrorX = 24.0*microntocm;
325  theErrorY = 96.0*microntocm;
326  }
327  else
328  {
329  theErrorX = 31.0*microntocm;
330  theErrorY = 90.0*microntocm;
331  }
332 
333  }
334  else {
335  if( singlex )
336  if ( hitbigx )
337  theErrorX = sx2*microntocm;
338  else
339  theErrorX = sx1*microntocm;
340  else theErrorX = sigmax*microntocm;
341  if( singley )
342  if( hitbigy )
343  theErrorY = sy2*microntocm;
344  else
345  theErrorY = sy1*microntocm;
346  else theErrorY = sigmay*microntocm;
347  }
348  theErrorZ = 1e-8; // 1 um means zero
350  // Local Error is 2D: (xx,xy,yy), square of sigma in first an third position
351  // as for resolution matrix
352  //
353 #ifdef FAMOS_DEBUG
354  std::cout << " Pixel Errors "
355  << "\talpha(x) = " << theErrorX
356  << "\tbeta(y) = " << theErrorY
357  << std::endl;
358 #endif
359  // Generate position
360  // get resolution histograms
361  int cotalphaHistBin = (int)( ( cotalpha - rescotAlpha_binMin ) / rescotAlpha_binWidth + 1 );
362  int cotbetaHistBin = (int)( ( cotbeta - rescotBeta_binMin ) / rescotBeta_binWidth + 1 );
363  // protection against out-of-range (undeflows and overflows)
364  if( cotalphaHistBin < 1 ) cotalphaHistBin = 1;
365  if( cotbetaHistBin < 1 ) cotbetaHistBin = 1;
366  if( cotalphaHistBin > (int)rescotAlpha_binN ) cotalphaHistBin = (int)rescotAlpha_binN;
367  if( cotbetaHistBin > (int)rescotBeta_binN ) cotbetaHistBin = (int)rescotBeta_binN;
368  //
369  unsigned int theXHistN;
370  unsigned int theYHistN;
371  if( !isForward ) {
372  if(edge)
373  {
374  theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
375  theYHistN = theXHistN;
376  }
377  else
378  {
379  if(singlex)
380  {
381  if(hitbigx) theXHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
382  else theXHistN = 1 * 100000 + 1 * 1000 + cotalphaHistBin * 100 + cotbetaHistBin ;
383  }
384  else
385  {
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);
388  }
389  if(singley)
390  {
391  if(hitbigy) theYHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
392  else theYHistN = 1 * 100000 + 1 * 1000 + cotalphaHistBin * 100 + cotbetaHistBin ;
393  }
394  else
395  {
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);
398  }
399  }
400  }
401  else
402  {
403  if(edge)
404  {
405  theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
406  theYHistN = theXHistN;
407  }
408  else
409  {
410  if( singlex )
411  if( hitbigx )
412  theXHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
413  else
414  theXHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
415  else
416  theXHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
417  if( singley )
418  if( hitbigy )
419  theYHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
420  else
421  theYHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
422  else
423  theYHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
424  }
425  }
426  unsigned int counter = 0;
427  do {
428  //
429  // Smear the hit Position
430  thePositionX = theXHistos[theXHistN]->generate(random);
431  thePositionY = theYHistos[theYHistN]->generate(random);
432  if( isForward ) thePositionY *= sign;
433  thePositionZ = 0.0; // set at the centre of the active area
434  //protect from empty resolution histograms
435  //if( thePositionX > 0.0799 ) thePositionX = 0;
436  //if( thePositionY > 0.0799 ) thePositionY = 0;
437  thePosition =
438  Local3DPoint(simHit.localPosition().x() + thePositionX ,
439  simHit.localPosition().y() + thePositionY ,
440  simHit.localPosition().z() + thePositionZ );
441 #ifdef FAMOS_DEBUG
442  std::cout << " Detector bounds: "
443  << "\t\tx = " << boundX
444  << "\ty = " << boundY
445  << std::endl;
446  std::cout << " Generated local position "
447  << "\tx = " << thePosition.x()
448  << "\ty = " << thePosition.y()
449  << std::endl;
450 #endif
451  counter++;
452  if(counter > 20) {
453  thePosition = Local3DPoint(simHit.localPosition().x(),
454  simHit.localPosition().y(),
455  simHit.localPosition().z());
456  break;
457  }
458  } while(fabs(thePosition.x()) > boundX || fabs(thePosition.y()) > boundY);
459 
460 }
461 
462 //-----------------------------------------------------------------------------
463 // I COPIED FROM THE PixelCPEBase BECAUSE IT'S BETTER THAN REINVENT IT
464 // The isFlipped() is a silly way to determine which detectors are inverted.
465 // In the barrel for every 2nd ladder the E field direction is in the
466 // global r direction (points outside from the z axis), every other
467 // ladder has the E field inside. Something similar is in the
468 // forward disks (2 sides of the blade). This has to be recognised
469 // because the charge sharing effect is different.
470 //
471 // The isFliped does it by looking and the relation of the local (z always
472 // in the E direction) to global coordinates. There is probably a much
473 // better way.(PJ: And faster!)
474 //-----------------------------------------------------------------------------
476  // Check the relative position of the local +/- z in global coordinates.
477  float tmp1 = theDet->surface().toGlobal(Local3DPoint(0.,0.,0.)).perp();
478  float tmp2 = theDet->surface().toGlobal(Local3DPoint(0.,0.,1.)).perp();
479  // std::cout << " 1: " << tmp1 << " 2: " << tmp2 << std::endl;
480  if ( tmp2<tmp1 ) return true;
481  else return false;
482 }
483 
485 {
486  //Hard coded at the moment, can easily be changed to be configurable
487  rescotAlpha_binMin = -0.2;
488  rescotAlpha_binWidth = 0.08 ;
489  rescotAlpha_binN = 5;
490  rescotBeta_binMin = -5.5;
491  rescotBeta_binWidth = 1.0;
492  rescotBeta_binN = 11;
493  resqbin_binMin = 0;
494  resqbin_binWidth = 1;
495  resqbin_binN = 4;
496 
497  // Initialize the barrel histos once and for all, and prepare the random generation
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
502  + cotbetaHistBin ;
503  theXHistos[singleBigPixelHistN] = new SimpleHistogramGenerator(
504  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hx%u" , singleBigPixelHistN ) ) );
505  theYHistos[singleBigPixelHistN] = new SimpleHistogramGenerator(
506  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hy%u" , singleBigPixelHistN ) ) );
507  unsigned int singlePixelHistN = 1 * 100000 + 1 * 1000
508  + cotalphaHistBin * 100
509  + cotbetaHistBin ;
510  theXHistos[singlePixelHistN] = new SimpleHistogramGenerator(
511  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hx%u" , singlePixelHistN ) ) );
512  theYHistos[singlePixelHistN] = new SimpleHistogramGenerator(
513  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hy%u" , singlePixelHistN ) ) );
514  for( unsigned qbinBin=1; qbinBin<=resqbin_binN; ++qbinBin ) {
515  unsigned int edgePixelHistN = cotalphaHistBin * 1000
516  + cotbetaHistBin * 10
517  + qbinBin;
518  theXHistos[edgePixelHistN] = new SimpleHistogramGenerator(
519  (TH1F*) thePixelResolutionFile2->Get( Form( "DQMData/clustBPIX/hx0%u" ,edgePixelHistN ) ) );
520  theYHistos[edgePixelHistN] = new SimpleHistogramGenerator(
521  (TH1F*) thePixelResolutionFile2->Get( Form( "DQMData/clustBPIX/hy0%u" ,edgePixelHistN ) ) );
522  unsigned int multiPixelBigHistN = 1 * 1000000 + 1 * 100000
523  + cotalphaHistBin * 1000
524  + cotbetaHistBin * 10
525  + qbinBin;
526  theXHistos[multiPixelBigHistN] = new SimpleHistogramGenerator(
527  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hx%u" ,multiPixelBigHistN ) ) );
528  theYHistos[multiPixelBigHistN] = new SimpleHistogramGenerator(
529  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hy%u" ,multiPixelBigHistN ) ) );
530  unsigned int multiPixelHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000
531  + cotalphaHistBin * 1000
532  + cotbetaHistBin * 10
533  + qbinBin;
534  theXHistos[multiPixelHistN] = new SimpleHistogramGenerator(
535  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hx%u" , multiPixelHistN ) ) );
536  theYHistos[multiPixelHistN] = new SimpleHistogramGenerator(
537  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hy%u" , multiPixelHistN ) ) );
538  } //end for qbinBin
539  }//end for cotalphaHistBin, cotbetaHistBin
540 }
541 
543 {
544  //Hard coded at the moment, can easily be changed to be configurable
545  rescotAlpha_binMin = 0.1;
546  rescotAlpha_binWidth = 0.1 ;
547  rescotAlpha_binN = 4;
548  rescotBeta_binMin = 0.;
549  rescotBeta_binWidth = 0.15;
550  rescotBeta_binN = 4;
551  resqbin_binMin = 0;
552  resqbin_binWidth = 1;
553  resqbin_binN = 4;
554 
555  // Initialize the forward histos once and for all, and prepare the random generation
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;
560  theXHistos[edgePixelHistN] = new SimpleHistogramGenerator(
561  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhx0%u" ,edgePixelHistN ) ) );
562  theYHistos[edgePixelHistN] = new SimpleHistogramGenerator(
563  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhy0%u" ,edgePixelHistN ) ) );
564  unsigned int PixelHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + qbinBin;
565  theXHistos[PixelHistN] = new SimpleHistogramGenerator(
566  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhx%u" ,PixelHistN ) ) );
567  theYHistos[PixelHistN] = new SimpleHistogramGenerator(
568  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhy%u" ,PixelHistN ) ) );
569  }//end cotalphaHistBin, cotbetaHistBin, qbinBin
570 
571  for ( unsigned cotalphaHistBin=1; cotalphaHistBin<=rescotAlpha_binN; ++cotalphaHistBin )
572  for ( unsigned cotbetaHistBin=1; cotbetaHistBin<=rescotBeta_binN; ++cotbetaHistBin )
573  {
574  unsigned int SingleBigPixelHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
575  theXHistos[SingleBigPixelHistN] = new SimpleHistogramGenerator(
576  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhx%u" ,SingleBigPixelHistN ) ) );
577  theYHistos[SingleBigPixelHistN] = new SimpleHistogramGenerator(
578  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhy%u" ,SingleBigPixelHistN ) ) );
579  unsigned int SinglePixelHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
580  theXHistos[SinglePixelHistN] = new SimpleHistogramGenerator(
581  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhx%u" ,SinglePixelHistN ) ) );
582  theYHistos[SinglePixelHistN] = new SimpleHistogramGenerator(
583  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhy%u" ,SinglePixelHistN ) ) );
584 
585  }
586 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:114
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
#define BXSIZE
T y() const
Definition: PV2DBase.h:46
T perp() const
Definition: PV3DBase.h:72
#define BYSIZE
double flatShoot(double xmin=0.0, double xmax=1.0) const
#define PI
virtual int ncolumns() const =0
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
Definition: PSimHit.h:47
T y() const
Definition: PV3DBase.h:63
virtual int nrows() const =0
TRandom random
Definition: MVATrainer.cc:138
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
std::map< unsigned, const SimpleHistogramGenerator * > theXHistos
bool interpolate(int id, float cotalpha, float cotbeta, float locBz)
virtual PixelGeomDetType & specificType() const
Local3DPoint localPosition() const
Definition: PSimHit.h:44
void xtemp(int fxbin, int lxbin, float xtemplate[41][BXSIZE])
#define BHX
T z() const
Definition: PV3DBase.h:64
void temperrors(int id, float cotalpha, float cotbeta, int qBin, float &sigmay, float &sigmax, float &sy1, float &sy2, float &sx1, float &sx2)
void ytemp(int fybin, int lybin, float ytemplate[41][BYSIZE])
float s50()
1/2 of the pixel threshold signal in electrons
LocalVector localDirection() const
Obsolete. Same as momentumAtEntry().unit(), for backward compatibility.
Definition: PSimHit.h:52
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
Vector3DBase unit() const
Definition: Vector3DBase.h:57
bool pushfile(int filenum)
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
void smearHit(const PSimHit &simHit, const PixelGeomDetUnit *detUnit, const double boundX, const double boundY, RandomEngineAndDistribution const *)
#define BHY
static std::atomic< unsigned int > counter
tuple cout
Definition: gather_cfg.py:121
SiPixelGaussianSmearingRecHitConverterAlgorithm(const edm::ParameterSet &pset, GeomDetType::SubDetector pixelPart)
T x() const
Definition: PV2DBase.h:45
T x() const
Definition: PV3DBase.h:62