CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiPixelGaussianSmearingRecHitConverterAlgorithm Class Reference

#include <SiPixelGaussianSmearingRecHitConverterAlgorithm.h>

Public Member Functions

LocalError getError ()
 
double getErrorX ()
 
double getErrorY ()
 
double getErrorZ ()
 
unsigned int getPixelMultiplicityAlpha ()
 
unsigned int getPixelMultiplicityBeta ()
 
Local3DPoint getPosition ()
 
double getPositionX ()
 
double getPositionY ()
 
double getPositionZ ()
 
 SiPixelGaussianSmearingRecHitConverterAlgorithm (const edm::ParameterSet &pset, GeomDetType::SubDetector pixelPart)
 
void smearHit (const PSimHit &simHit, const PixelGeomDetUnit *detUnit, const double boundX, const double boundY, RandomEngineAndDistribution const *)
 
virtual ~SiPixelGaussianSmearingRecHitConverterAlgorithm ()
 

Private Member Functions

void initializeBarrel ()
 
void initializeForward ()
 
bool isFlipped (const PixelGeomDetUnit *theDet) const
 

Private Attributes

bool isForward
 
edm::ParameterSet pset_
 
double rescotAlpha_binMin
 
unsigned int rescotAlpha_binN
 
double rescotAlpha_binWidth
 
double rescotBeta_binMin
 
unsigned int rescotBeta_binN
 
double rescotBeta_binWidth
 
int resqbin_binMin
 
unsigned int resqbin_binN
 
int resqbin_binWidth
 
int tempId
 
unsigned int theClslenx
 
unsigned int theClsleny
 
LocalError theError
 
double theErrorX
 
double theErrorY
 
double theErrorZ
 
unsigned int theLayer
 
GeomDetType::SubDetector thePixelPart
 
TFile * thePixelResolutionFile1
 
TFile * thePixelResolutionFile2
 
std::string thePixelResolutionFileName1
 
std::string thePixelResolutionFileName2
 
std::vector< SiPixelTemplateStorethePixelTemp_
 
Local3DPoint thePosition
 
double thePositionX
 
double thePositionY
 
double thePositionZ
 
std::map< unsigned, const
SimpleHistogramGenerator * > 
theXHistos
 
std::map< unsigned, const
SimpleHistogramGenerator * > 
theYHistos
 
bool useCMSSWPixelParameterization
 

Detailed Description

Definition at line 36 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Constructor & Destructor Documentation

SiPixelGaussianSmearingRecHitConverterAlgorithm::SiPixelGaussianSmearingRecHitConverterAlgorithm ( const edm::ParameterSet pset,
GeomDetType::SubDetector  pixelPart 
)
explicit

Definition at line 40 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.cc.

References gather_cfg::cout, edm::hlt::Exception, contentValuesFiles::fullPath, edm::ParameterSet::getParameter(), initializeBarrel(), initializeForward(), isForward, GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, pset_, SiPixelTemplate::pushfile(), tempId, thePixelPart, thePixelResolutionFile1, thePixelResolutionFile2, thePixelResolutionFileName1, thePixelResolutionFileName2, thePixelTemp_, theXHistos, theYHistos, and useCMSSWPixelParameterization.

43 :
44  pset_(pset),
45  thePixelPart(pixelPart)
46 {
47  // Switch between old (ORCA) and new (CMSSW) pixel parameterization
48  useCMSSWPixelParameterization = pset.getParameter<bool>("UseCMSSWPixelParametrization");
49 
51  isForward = false;
52  thePixelResolutionFileName1 = pset_.getParameter<string>( "NewPixelBarrelResolutionFile1" );
54  TFile( edm::FileInPath( thePixelResolutionFileName1 ).fullPath().c_str() ,"READ");
55  thePixelResolutionFileName2 = pset_.getParameter<string>( "NewPixelBarrelResolutionFile2" );
57  TFile( edm::FileInPath( thePixelResolutionFileName2 ).fullPath().c_str() ,"READ");
59  tempId = pset_.getParameter<int> ( "templateIdBarrel" );
61  throw cms::Exception("SiPixelGaussianSmearingRecHitConverterAlgorithm:")
62  <<"SiPixel Barrel Template Not Loaded Correctly!"<<endl;
63 #ifdef FAMOS_DEBUG
64  cout<<"The Barrel map size is "<<theXHistos.size()<<" and "<<theYHistos.size()<<endl;
65 #endif
66  }
67  else
69  isForward = true;
70  thePixelResolutionFileName1 = pset_.getParameter<string>( "NewPixelForwardResolutionFile" );
71  thePixelResolutionFile1 = new
72  TFile( edm::FileInPath( thePixelResolutionFileName1 ).fullPath().c_str() ,"READ");
74  tempId = pset_.getParameter<int> ( "templateIdForward" );
76  throw cms::Exception("SiPixelGaussianSmearingRecHitConverterAlgorithm:")
77  <<"SiPixel Forward Template Not Loaded Correctly!"<<endl;
78 #ifdef FAMOS_DEBUG
79  cout<<"The Forward map size is "<<theXHistos.size()<<" and "<<theYHistos.size()<<endl;
80 #endif
81  }
82  else
83  throw cms::Exception("SiPixelGaussianSmearingRecHitConverterAlgorithm :")
84  <<"Not a pixel detector"<<endl;
85 }
T getParameter(std::string const &) const
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
std::map< unsigned, const SimpleHistogramGenerator * > theXHistos
std::map< unsigned, const SimpleHistogramGenerator * > theYHistos
tuple cout
Definition: gather_cfg.py:121
SiPixelGaussianSmearingRecHitConverterAlgorithm::~SiPixelGaussianSmearingRecHitConverterAlgorithm ( )
virtual

Definition at line 87 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.cc.

References citk::for(), theXHistos, and theYHistos.

88 {
89 
90  std::map<unsigned,const SimpleHistogramGenerator*>::const_iterator it;
91  for ( it=theXHistos.begin(); it!=theXHistos.end(); ++it )
92  delete it->second;
93  for ( it=theYHistos.begin(); it!=theYHistos.end(); ++it )
94  delete it->second;
95 
96  theXHistos.clear();
97  theYHistos.clear();
98 
99 }
std::map< unsigned, const SimpleHistogramGenerator * > theXHistos
std::map< unsigned, const SimpleHistogramGenerator * > theYHistos
for(const auto &isodef:isoDefs)

Member Function Documentation

LocalError SiPixelGaussianSmearingRecHitConverterAlgorithm::getError ( )
inline
double SiPixelGaussianSmearingRecHitConverterAlgorithm::getErrorX ( )
inline
double SiPixelGaussianSmearingRecHitConverterAlgorithm::getErrorY ( )
inline
double SiPixelGaussianSmearingRecHitConverterAlgorithm::getErrorZ ( )
inline
unsigned int SiPixelGaussianSmearingRecHitConverterAlgorithm::getPixelMultiplicityAlpha ( )
inline
unsigned int SiPixelGaussianSmearingRecHitConverterAlgorithm::getPixelMultiplicityBeta ( )
inline
Local3DPoint SiPixelGaussianSmearingRecHitConverterAlgorithm::getPosition ( )
inline
double SiPixelGaussianSmearingRecHitConverterAlgorithm::getPositionX ( )
inline
double SiPixelGaussianSmearingRecHitConverterAlgorithm::getPositionY ( )
inline
double SiPixelGaussianSmearingRecHitConverterAlgorithm::getPositionZ ( )
inline
void SiPixelGaussianSmearingRecHitConverterAlgorithm::initializeBarrel ( )
private

Definition at line 484 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.cc.

References rescotAlpha_binMin, rescotAlpha_binN, rescotAlpha_binWidth, rescotBeta_binMin, rescotBeta_binN, rescotBeta_binWidth, resqbin_binMin, resqbin_binN, resqbin_binWidth, thePixelResolutionFile1, thePixelResolutionFile2, theXHistos, and theYHistos.

Referenced by SiPixelGaussianSmearingRecHitConverterAlgorithm().

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 }
std::map< unsigned, const SimpleHistogramGenerator * > theXHistos
std::map< unsigned, const SimpleHistogramGenerator * > theYHistos
void SiPixelGaussianSmearingRecHitConverterAlgorithm::initializeForward ( )
private

Definition at line 542 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.cc.

References rescotAlpha_binMin, rescotAlpha_binN, rescotAlpha_binWidth, rescotBeta_binMin, rescotBeta_binN, rescotBeta_binWidth, resqbin_binMin, resqbin_binN, resqbin_binWidth, thePixelResolutionFile1, theXHistos, and theYHistos.

Referenced by SiPixelGaussianSmearingRecHitConverterAlgorithm().

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 }
std::map< unsigned, const SimpleHistogramGenerator * > theXHistos
std::map< unsigned, const SimpleHistogramGenerator * > theYHistos
bool SiPixelGaussianSmearingRecHitConverterAlgorithm::isFlipped ( const PixelGeomDetUnit theDet) const
private

Definition at line 475 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.cc.

References PV3DBase< T, PVType, FrameType >::perp(), GeomDet::surface(), and Surface::toGlobal().

Referenced by smearHit().

475  {
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 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:114
T perp() const
Definition: PV3DBase.h:72
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
void SiPixelGaussianSmearingRecHitConverterAlgorithm::smearHit ( const PSimHit simHit,
const PixelGeomDetUnit detUnit,
const double  boundX,
const double  boundY,
RandomEngineAndDistribution const *  random 
)

Definition at line 101 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.cc.

References BHX, BHY, BXSIZE, BYSIZE, counter, gather_cfg::cout, alignCSCRings::e, prof2calltree::edge, RandomEngineAndDistribution::flatShoot(), i, SiPixelTemplate::interpolate(), isFlipped(), isForward, PSimHit::localDirection(), PSimHit::localPosition(), microntocm, PSimHit::momentumAtEntry(), PixelTopology::ncolumns(), PixelTopology::nrows(), SiPixelTemplate::qbin_dist(), rescotAlpha_binMin, rescotAlpha_binN, rescotAlpha_binWidth, rescotBeta_binMin, rescotBeta_binN, rescotBeta_binWidth, SiPixelTemplate::s50(), PixelGeomDetUnit::specificType(), SiPixelTemplate::temperrors(), tempId, theClslenx, theClsleny, theError, theErrorX, theErrorY, theErrorZ, thePixelPart, thePixelTemp_, thePosition, thePositionX, thePositionY, thePositionZ, theXHistos, theYHistos, Vector3DBase< T, FrameTag >::unit(), PV2DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::x(), xsize, SiPixelTemplate::xtemp(), PV2DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::y(), ysize, SiPixelTemplate::ytemp(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by SiTrackerGaussianSmearingRecHitConverter::gaussianSmearing().

107 {
108 
109 #ifdef FAMOS_DEBUG
110  std::cout << " Pixel smearing in " << thePixelPart
111  << std::endl;
112 #endif
113  //
114  // at the beginning the position is the Local Point in the local pixel module reference frame
115  // same code as in PixelCPEBase
116  LocalVector localDir = simHit.momentumAtEntry().unit();
117  float locx = localDir.x();
118  float locy = localDir.y();
119  float locz = localDir.z();
120 
121  // alpha: angle with respect to local x axis in local (x,z) plane
122  float cotalpha = locx/locz;
123  if ( isFlipped( detUnit ) ) { // &&& check for FPIX !!!
124 #ifdef FAMOS_DEBUG
125  std::cout << " isFlipped " << std::endl;
126 #endif
127  }
128  // beta: angle with respect to local y axis in local (y,z) plane
129  float cotbeta = locy/locz;
130  float sign=1.;
131  if( isForward ) {
132  if( cotbeta < 0 ) sign=-1.;
133  cotbeta = sign*cotbeta;
134  }
135 
136 
137  //
138 #ifdef FAMOS_DEBUG
139  std::cout << " Local Direction " << simHit.localDirection()
140  << " cotalpha(x) = " << cotalpha
141  << " cotbeta(y) = " << cotbeta
142  << std::endl;
143 #endif
144 
145  const PixelTopology* theSpecificTopology = &(detUnit->specificType().specificTopology());
146  const RectangularPixelTopology *rectPixelTopology = static_cast<const RectangularPixelTopology*>(theSpecificTopology);
147 
148  const int nrows = theSpecificTopology->nrows();
149  const int ncolumns = theSpecificTopology->ncolumns();
150 
151  const Local3DPoint lp = simHit.localPosition();
152  //Transform local position to measurement position
153  const MeasurementPoint mp = rectPixelTopology->measurementPosition( lp );
154  float mpy = mp.y();
155  float mpx = mp.x();
156  //Get the center of the struck pixel in measurement position
157  float pixelCenterY = 0.5 + (int)mpy;
158  float pixelCenterX = 0.5 + (int)mpx;
159 #ifdef FAMOS_DEBUG
160  cout<<"Struck pixel center at pitch units x: "<<pixelCenterX<<" y: "<<pixelCenterY<<endl;
161 #endif
162 
163  const MeasurementPoint mpCenter(pixelCenterX, pixelCenterY);
164  //Transform the center of the struck pixel back into local position
165  const Local3DPoint lpCenter = rectPixelTopology->localPosition( mpCenter );
166 #ifdef FAMOS_DEBUG
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;
170 #endif
171 
172  //Get the relative position of struck point to the center of the struck pixel
173  float xtrk = lp.x() - lpCenter.x();
174  float ytrk = lp.y() - lpCenter.y();
175  //Pixel Y, X pitch
176  const float ysize={0.015}, xsize={0.01};
177  //Variables for SiPixelTemplate input, see SiPixelTemplate reco
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;
184  //Protect againt ybin, xbin being outside of range [0-39]
185  if( ybin < 0 ) ybin = 0;
186  if( ybin > 39 ) ybin = 39;
187  if( xbin < 0 ) xbin = 0;
188  if( xbin > 39 ) xbin = 39;
189 
190  //Variables for SiPixelTemplate output
191  //qBin -- normalized pixel charge deposition
192  float qbin_frac[4];
193  //Single pixel cluster projection possibility
194  float ny1_frac, ny2_frac, nx1_frac, nx2_frac;
195  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 }
int i
Definition: DBlmapReader.cc:9
#define BXSIZE
T y() const
Definition: PV2DBase.h:46
#define BYSIZE
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 Int_t ysize
std::map< unsigned, const SimpleHistogramGenerator * > theXHistos
Local3DPoint localPosition() const
Definition: PSimHit.h:44
#define BHX
T z() const
Definition: PV3DBase.h:64
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
std::map< unsigned, const SimpleHistogramGenerator * > theYHistos
#define BHY
static std::atomic< unsigned int > counter
tuple cout
Definition: gather_cfg.py:121
const Int_t xsize
T x() const
Definition: PV2DBase.h:45
T x() const
Definition: PV3DBase.h:62
virtual const PixelGeomDetType & specificType() const

Member Data Documentation

bool SiPixelGaussianSmearingRecHitConverterAlgorithm::isForward
private
edm::ParameterSet SiPixelGaussianSmearingRecHitConverterAlgorithm::pset_
private
double SiPixelGaussianSmearingRecHitConverterAlgorithm::rescotAlpha_binMin
private
unsigned int SiPixelGaussianSmearingRecHitConverterAlgorithm::rescotAlpha_binN
private
double SiPixelGaussianSmearingRecHitConverterAlgorithm::rescotAlpha_binWidth
private
double SiPixelGaussianSmearingRecHitConverterAlgorithm::rescotBeta_binMin
private
unsigned int SiPixelGaussianSmearingRecHitConverterAlgorithm::rescotBeta_binN
private
double SiPixelGaussianSmearingRecHitConverterAlgorithm::rescotBeta_binWidth
private
int SiPixelGaussianSmearingRecHitConverterAlgorithm::resqbin_binMin
private
unsigned int SiPixelGaussianSmearingRecHitConverterAlgorithm::resqbin_binN
private
int SiPixelGaussianSmearingRecHitConverterAlgorithm::resqbin_binWidth
private
int SiPixelGaussianSmearingRecHitConverterAlgorithm::tempId
private
unsigned int SiPixelGaussianSmearingRecHitConverterAlgorithm::theClslenx
private
unsigned int SiPixelGaussianSmearingRecHitConverterAlgorithm::theClsleny
private
LocalError SiPixelGaussianSmearingRecHitConverterAlgorithm::theError
private

Definition at line 104 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getError(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::theErrorX
private

Definition at line 105 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getErrorX(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::theErrorY
private

Definition at line 106 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getErrorY(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::theErrorZ
private

Definition at line 107 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getErrorZ(), and smearHit().

unsigned int SiPixelGaussianSmearingRecHitConverterAlgorithm::theLayer
private
GeomDetType::SubDetector SiPixelGaussianSmearingRecHitConverterAlgorithm::thePixelPart
private
TFile* SiPixelGaussianSmearingRecHitConverterAlgorithm::thePixelResolutionFile1
private
TFile* SiPixelGaussianSmearingRecHitConverterAlgorithm::thePixelResolutionFile2
private
std::string SiPixelGaussianSmearingRecHitConverterAlgorithm::thePixelResolutionFileName1
private
std::string SiPixelGaussianSmearingRecHitConverterAlgorithm::thePixelResolutionFileName2
private
std::vector< SiPixelTemplateStore > SiPixelGaussianSmearingRecHitConverterAlgorithm::thePixelTemp_
private
Local3DPoint SiPixelGaussianSmearingRecHitConverterAlgorithm::thePosition
private

Definition at line 100 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getPosition(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::thePositionX
private

Definition at line 101 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getPositionX(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::thePositionY
private

Definition at line 102 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getPositionY(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::thePositionZ
private

Definition at line 103 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getPositionZ(), and smearHit().

std::map<unsigned,const SimpleHistogramGenerator*> SiPixelGaussianSmearingRecHitConverterAlgorithm::theXHistos
private
std::map<unsigned,const SimpleHistogramGenerator*> SiPixelGaussianSmearingRecHitConverterAlgorithm::theYHistos
private
bool SiPixelGaussianSmearingRecHitConverterAlgorithm::useCMSSWPixelParameterization
private