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
 
TFile * thePixelResolutionFile3
 
std::string thePixelResolutionFileName1
 
std::string thePixelResolutionFileName2
 
std::string thePixelResolutionFileName3
 
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, contentValuesFiles::fullPath, edm::ParameterSet::getParameter(), initializeBarrel(), initializeForward(), GeomDetEnumerators::isBarrel(), isForward, GeomDetEnumerators::isTrackerPixel(), pset_, SiPixelTemplate::pushfile(), tempId, thePixelPart, thePixelResolutionFile1, thePixelResolutionFile2, thePixelResolutionFile3, thePixelResolutionFileName1, thePixelResolutionFileName2, thePixelResolutionFileName3, 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 
52 
54  throw cms::Exception("SiPixelGaussianSmearingRecHitConverterAlgorithm :")
55  <<"Not a pixel detector"<<endl;
56 
58  isForward = false;
59  thePixelResolutionFileName1 = pset_.getParameter<string>( "NewPixelBarrelResolutionFile1" );
60  thePixelResolutionFile1 = new
61  TFile( edm::FileInPath( thePixelResolutionFileName1 ).fullPath().c_str() ,"READ");
62  thePixelResolutionFileName2 = pset_.getParameter<string>( "NewPixelBarrelResolutionFile2" );
64  TFile( edm::FileInPath( thePixelResolutionFileName2 ).fullPath().c_str() ,"READ");
65  //ALICE
66  thePixelResolutionFileName3 = pset_.getParameter<string>( "NewPixelBarrelResolutionFile3" );
68  TFile( edm::FileInPath( thePixelResolutionFileName3 ).fullPath().c_str() ,"READ");
70  tempId = pset_.getParameter<int> ( "templateIdBarrel" );
72  throw cms::Exception("SiPixelGaussianSmearingRecHitConverterAlgorithm:")
73  <<"SiPixel Barrel Template Not Loaded Correctly!"<<endl;
74 #ifdef FAMOS_DEBUG
75  cout<<"The Barrel map size is "<<theXHistos.size()<<" and "<<theYHistos.size()<<endl;
76 #endif
77  }
78  else {
79  isForward = true;
80  thePixelResolutionFileName1 = pset_.getParameter<string>( "NewPixelForwardResolutionFile" );
81  thePixelResolutionFile1 = new
82  TFile( edm::FileInPath( thePixelResolutionFileName1 ).fullPath().c_str() ,"READ");
83  //ALICE
84  thePixelResolutionFileName2 = pset_.getParameter<string>( "NewPixelForwardResolutionFile2" );
85  thePixelResolutionFile2 = new
86  TFile( edm::FileInPath( thePixelResolutionFileName2 ).fullPath().c_str() ,"READ");
88  tempId = pset_.getParameter<int> ( "templateIdForward" );
90  throw cms::Exception("SiPixelGaussianSmearingRecHitConverterAlgorithm:")
91  <<"SiPixel Forward Template Not Loaded Correctly!"<<endl;
92 #ifdef FAMOS_DEBUG
93  cout<<"The Forward map size is "<<theXHistos.size()<<" and "<<theYHistos.size()<<endl;
94 #endif
95  }
96 
97  if ( thePixelResolutionFile2) {
98  thePixelResolutionFile2->Close();
100  }
101  if ( thePixelResolutionFile1) {
102  thePixelResolutionFile1->Close();
104  }
105  thePixelResolutionFile1=0;
106  thePixelResolutionFile2=0;
107 }
T getParameter(std::string const &) const
bool isBarrel(GeomDetEnumerators::SubDetector m)
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
std::map< unsigned, const SimpleHistogramGenerator * > theXHistos
std::map< unsigned, const SimpleHistogramGenerator * > theYHistos
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)
tuple cout
Definition: gather_cfg.py:145
SiPixelGaussianSmearingRecHitConverterAlgorithm::~SiPixelGaussianSmearingRecHitConverterAlgorithm ( )
virtual

Definition at line 109 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.cc.

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

110 {
111 
112  std::map<unsigned,const SimpleHistogramGenerator*>::const_iterator it;
113  for ( it=theXHistos.begin(); it!=theXHistos.end(); ++it )
114  delete it->second;
115  for ( it=theYHistos.begin(); it!=theYHistos.end(); ++it )
116  delete it->second;
117 
118  theXHistos.clear();
119  theYHistos.clear();
120 
121 }
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 520 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, thePixelResolutionFile3, theXHistos, and theYHistos.

Referenced by SiPixelGaussianSmearingRecHitConverterAlgorithm().

521 {
522  //Hard coded at the moment, can easily be changed to be configurable
523  rescotAlpha_binMin = -0.2;
524  rescotAlpha_binWidth = 0.08 ;
525  rescotAlpha_binN = 5;
526  rescotBeta_binMin = -5.5;
527  rescotBeta_binWidth = 1.0;
528  rescotBeta_binN = 11;
529  resqbin_binMin = 0;
530  resqbin_binWidth = 1;
531  resqbin_binN = 4;
532 
533  // Initialize the barrel histos once and for all, and prepare the random generation
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
538  + cotbetaHistBin ;
539  theXHistos[singleBigPixelHistN] = new SimpleHistogramGenerator(
540  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hx%u" , singleBigPixelHistN ) ) );
541  theYHistos[singleBigPixelHistN] = new SimpleHistogramGenerator(
542  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hy%u" , singleBigPixelHistN ) ) );
543  /* unsigned int singlePixelHistN = 1 * 100000 + 1 * 1000
544  + cotalphaHistBin * 100
545  + cotbetaHistBin ;
546  theXHistos[singlePixelHistN] = new SimpleHistogramGenerator(
547  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hx%u" , singlePixelHistN ) ) );
548  theYHistos[singlePixelHistN] = new SimpleHistogramGenerator(
549  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hy%u" , singlePixelHistN ) ) );*/
550  unsigned int singlePixelHistN = 1 * 10000
551  + cotbetaHistBin * 10
552  + cotalphaHistBin ;
553  theXHistos[singlePixelHistN] = new SimpleHistogramGenerator(
554  (TH1F*) thePixelResolutionFile3->Get( Form( "hx%u" , singlePixelHistN ) ) );
555  theYHistos[singlePixelHistN] = new SimpleHistogramGenerator(
556  (TH1F*) thePixelResolutionFile3->Get( Form( "hy%u" , singlePixelHistN ) ) );
557 
558  for( unsigned qbinBin=1; qbinBin<=resqbin_binN; ++qbinBin ) {
559  unsigned int edgePixelHistN = cotalphaHistBin * 1000
560  + cotbetaHistBin * 10
561  + qbinBin;
562  theXHistos[edgePixelHistN] = new SimpleHistogramGenerator(
563  (TH1F*) thePixelResolutionFile2->Get( Form( "DQMData/clustBPIX/hx0%u" ,edgePixelHistN ) ) );
564  theYHistos[edgePixelHistN] = new SimpleHistogramGenerator(
565  (TH1F*) thePixelResolutionFile2->Get( Form( "DQMData/clustBPIX/hy0%u" ,edgePixelHistN ) ) );
566  unsigned int multiPixelBigHistN = 1 * 1000000 + 1 * 100000
567  + cotalphaHistBin * 1000
568  + cotbetaHistBin * 10
569  + qbinBin;
570  theXHistos[multiPixelBigHistN] = new SimpleHistogramGenerator(
571  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hx%u" ,multiPixelBigHistN ) ) );
572  theYHistos[multiPixelBigHistN] = new SimpleHistogramGenerator(
573  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hy%u" ,multiPixelBigHistN ) ) );
574  /* unsigned int multiPixelHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000
575  + cotalphaHistBin * 1000
576  + cotbetaHistBin * 10
577  + qbinBin;
578  theXHistos[multiPixelHistN] = new SimpleHistogramGenerator(
579  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hx%u" , multiPixelHistN ) ) );
580  theYHistos[multiPixelHistN] = new SimpleHistogramGenerator(
581  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustBPIX/hy%u" , multiPixelHistN ) ) );*/
582  unsigned int multiPixelHistN = 1 * 100000 + 1 * 10000
583  + cotbetaHistBin * 100
584  + cotalphaHistBin * 10
585  + qbinBin;
586  theXHistos[multiPixelHistN] = new SimpleHistogramGenerator(
587  (TH1F*) thePixelResolutionFile3->Get( Form( "hx%u" , multiPixelHistN ) ) );
588  theYHistos[multiPixelHistN] = new SimpleHistogramGenerator(
589  (TH1F*) thePixelResolutionFile3->Get( Form( "hy%u" , multiPixelHistN ) ) );
590  } //end for qbinBin
591  }//end for cotalphaHistBin, cotbetaHistBin
592 }
std::map< unsigned, const SimpleHistogramGenerator * > theXHistos
std::map< unsigned, const SimpleHistogramGenerator * > theYHistos
void SiPixelGaussianSmearingRecHitConverterAlgorithm::initializeForward ( )
private

Definition at line 594 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().

595 {
596  //Hard coded at the moment, can easily be changed to be configurable
597  rescotAlpha_binMin = 0.1;
598  rescotAlpha_binWidth = 0.1 ;
599  rescotAlpha_binN = 4;
600  rescotBeta_binMin = 0.;
601  rescotBeta_binWidth = 0.15;
602  rescotBeta_binN = 4;
603  resqbin_binMin = 0;
604  resqbin_binWidth = 1;
605  resqbin_binN = 4;
606 
607  // Initialize the forward histos once and for all, and prepare the random generation
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;
612  theXHistos[edgePixelHistN] = new SimpleHistogramGenerator(
613  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhx0%u" ,edgePixelHistN ) ) );
614  theYHistos[edgePixelHistN] = new SimpleHistogramGenerator(
615  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhy0%u" ,edgePixelHistN ) ) );
616  /* unsigned int PixelHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + qbinBin;
617  theXHistos[PixelHistN] = new SimpleHistogramGenerator(
618  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhx%u" ,PixelHistN ) ) );
619  theYHistos[PixelHistN] = new SimpleHistogramGenerator(
620  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhy%u" ,PixelHistN ) ) );*/
621  unsigned int PixelHistN = 10000 + cotbetaHistBin * 100 + cotalphaHistBin * 10 + qbinBin;
622  theXHistos[PixelHistN] = new SimpleHistogramGenerator(
623  (TH1F*) thePixelResolutionFile2->Get( Form( "hx0%u" ,PixelHistN ) ) );
624  theYHistos[PixelHistN] = new SimpleHistogramGenerator(
625  (TH1F*) thePixelResolutionFile2->Get( Form( "hy0%u" ,PixelHistN ) ) );
626 
627  }//end cotalphaHistBin, cotbetaHistBin, qbinBin
628 
629  for ( unsigned cotalphaHistBin=1; cotalphaHistBin<=rescotAlpha_binN; ++cotalphaHistBin )
630  for ( unsigned cotbetaHistBin=1; cotbetaHistBin<=rescotBeta_binN; ++cotbetaHistBin )
631  {
632  unsigned int SingleBigPixelHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
633  theXHistos[SingleBigPixelHistN] = new SimpleHistogramGenerator(
634  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhx%u" ,SingleBigPixelHistN ) ) );
635  theYHistos[SingleBigPixelHistN] = new SimpleHistogramGenerator(
636  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhy%u" ,SingleBigPixelHistN ) ) );
637  /* unsigned int SinglePixelHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
638  theXHistos[SinglePixelHistN] = new SimpleHistogramGenerator(
639  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhx%u" ,SinglePixelHistN ) ) );
640  theYHistos[SinglePixelHistN] = new SimpleHistogramGenerator(
641  (TH1F*) thePixelResolutionFile1->Get( Form( "DQMData/clustFPIX/fhy%u" ,SinglePixelHistN ) ) );*/
642  unsigned int SinglePixelHistN = cotbetaHistBin * 10 + cotalphaHistBin;
643  theXHistos[SinglePixelHistN] = new SimpleHistogramGenerator(
644  (TH1F*) thePixelResolutionFile2->Get( Form( "hx000%u" ,SinglePixelHistN ) ) );
645  theYHistos[SinglePixelHistN] = new SimpleHistogramGenerator(
646  (TH1F*) thePixelResolutionFile2->Get( Form( "hy000%u" ,SinglePixelHistN ) ) );
647 
648  }
649 }
std::map< unsigned, const SimpleHistogramGenerator * > theXHistos
std::map< unsigned, const SimpleHistogramGenerator * > theYHistos
bool SiPixelGaussianSmearingRecHitConverterAlgorithm::isFlipped ( const PixelGeomDetUnit theDet) const
private

Definition at line 511 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.cc.

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

Referenced by smearHit().

511  {
512  // Check the relative position of the local +/- z in global coordinates.
513  float tmp1 = theDet->surface().toGlobal(Local3DPoint(0.,0.,0.)).perp();
514  float tmp2 = theDet->surface().toGlobal(Local3DPoint(0.,0.,1.)).perp();
515  // std::cout << " 1: " << tmp1 << " 2: " << tmp2 << std::endl;
516  if ( tmp2<tmp1 ) return true;
517  else return false;
518 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
T perp() const
Definition: PV3DBase.h:72
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
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 123 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.cc.

References BHX, BHY, BXSIZE, BYSIZE, RectangularPixelTopology::containsBigPixelInX(), RectangularPixelTopology::containsBigPixelInY(), counter, gather_cfg::cout, alignCSCRings::e, RandomEngineAndDistribution::flatShoot(), i, SiPixelTemplate::interpolate(), isFlipped(), isForward, RectangularPixelTopology::isItBigPixelInX(), RectangularPixelTopology::isItBigPixelInY(), RectangularPixelTopology::isItEdgePixelInX(), RectangularPixelTopology::isItEdgePixelInY(), PSimHit::localDirection(), PSimHit::localPosition(), RectangularPixelTopology::localPosition(), RectangularPixelTopology::measurementPosition(), microntocm, PSimHit::momentumAtEntry(), PixelTopology::ncolumns(), PixelTopology::nrows(), SiPixelTemplate::qbin_dist(), rescotAlpha_binMin, rescotAlpha_binN, rescotAlpha_binWidth, rescotBeta_binMin, rescotBeta_binN, rescotBeta_binWidth, SiPixelTemplate::s50(), jetcorrextractor::sign(), PixelGeomDetType::specificTopology(), 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::smear().

129 {
130 
131 #ifdef FAMOS_DEBUG
132  std::cout << " Pixel smearing in " << thePixelPart
133  << std::endl;
134 #endif
135  //
136  // at the beginning the position is the Local Point in the local pixel module reference frame
137  // same code as in PixelCPEBase
138  LocalVector localDir = simHit.momentumAtEntry().unit();
139  float locx = localDir.x();
140  float locy = localDir.y();
141  float locz = localDir.z();
142 
143  // alpha: angle with respect to local x axis in local (x,z) plane
144  float cotalpha = locx/locz;
145  if ( isFlipped( detUnit ) ) { // &&& check for FPIX !!!
146 #ifdef FAMOS_DEBUG
147  std::cout << " isFlipped " << std::endl;
148 #endif
149  }
150  // beta: angle with respect to local y axis in local (y,z) plane
151  float cotbeta = locy/locz;
152  float sign=1.;
153  if( isForward ) {
154  if( cotbeta < 0 ) sign=-1.;
155  cotbeta = sign*cotbeta;
156  }
157 
158 
159  //
160 #ifdef FAMOS_DEBUG
161  std::cout << " Local Direction " << simHit.localDirection()
162  << " cotalpha(x) = " << cotalpha
163  << " cotbeta(y) = " << cotbeta
164  << std::endl;
165 #endif
166 
167  const PixelTopology* theSpecificTopology = &(detUnit->specificType().specificTopology());
168  const RectangularPixelTopology *rectPixelTopology = static_cast<const RectangularPixelTopology*>(theSpecificTopology);
169 
170  const int nrows = theSpecificTopology->nrows();
171  const int ncolumns = theSpecificTopology->ncolumns();
172 
173  const Local3DPoint lp = simHit.localPosition();
174  //Transform local position to measurement position
175  const MeasurementPoint mp = rectPixelTopology->measurementPosition( lp );
176  float mpy = mp.y();
177  float mpx = mp.x();
178  //Get the center of the struck pixel in measurement position
179  float pixelCenterY = 0.5 + (int)mpy;
180  float pixelCenterX = 0.5 + (int)mpx;
181 #ifdef FAMOS_DEBUG
182  cout<<"Struck pixel center at pitch units x: "<<pixelCenterX<<" y: "<<pixelCenterY<<endl;
183 #endif
184 
185  const MeasurementPoint mpCenter(pixelCenterX, pixelCenterY);
186  //Transform the center of the struck pixel back into local position
187  const Local3DPoint lpCenter = rectPixelTopology->localPosition( mpCenter );
188 #ifdef FAMOS_DEBUG
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;
192 #endif
193 
194  //Get the relative position of struck point to the center of the struck pixel
195  float xtrk = lp.x() - lpCenter.x();
196  float ytrk = lp.y() - lpCenter.y();
197  //Pixel Y, X pitch
198  const float ysize={0.015}, xsize={0.01};
199  //Variables for SiPixelTemplate input, see SiPixelTemplate reco
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;
206  //Protect againt ybin, xbin being outside of range [0-39]
207  if( ybin < 0 ) ybin = 0;
208  if( ybin > 39 ) ybin = 39;
209  if( xbin < 0 ) xbin = 0;
210  if( xbin > 39 ) xbin = 39;
211 
212  //Variables for SiPixelTemplate output
213  //qBin -- normalized pixel charge deposition
214  float qbin_frac[4];
215  //Single pixel cluster projection possibility
216  float ny1_frac, ny2_frac, nx1_frac, nx2_frac;
217  bool singlex = false, singley = false;
219  templ.interpolate(tempId, cotalpha, cotbeta);
220  templ.qbin_dist(tempId, cotalpha, cotbeta, qbin_frac, ny1_frac, ny2_frac, nx1_frac, nx2_frac );
221  int nqbin;
222 
223  double xsizeProbability = random->flatShoot();
224  double ysizeProbability = random->flatShoot();
225  bool hitbigx = rectPixelTopology->isItBigPixelInX( (int)mpx );
226  bool hitbigy = rectPixelTopology->isItBigPixelInY( (int)mpy );
227 
228  if( hitbigx )
229  if( xsizeProbability < nx2_frac ) singlex = true;
230  else singlex = false;
231  else
232  if( xsizeProbability < nx1_frac ) singlex = true;
233  else singlex = false;
234 
235  if( hitbigy )
236  if( ysizeProbability < ny2_frac ) singley = true;
237  else singley = false;
238  else
239  if( ysizeProbability < ny1_frac ) singley = true;
240  else singley = false;
241 
242 
243 
244  // random multiplicity for alpha and beta
245  double qbinProbability = random->flatShoot();
246  for(int i = 0; i<4; ++i) {
247  nqbin = i;
248  if(qbinProbability < qbin_frac[i]) break;
249  }
250 
251  //Store interpolated pixel cluster profile
252  //BYSIZE, BXSIZE, const definition from SiPixelTemplate
253  float ytempl[41][BYSIZE] = {{0}}, xtempl[41][BXSIZE] = {{0}} ;
254  templ.ytemp(0, 40, ytempl);
255  templ.xtemp(0, 40, xtempl);
256 
257  std::vector<double> ytemp(BYSIZE);
258  for( int i=0; i<BYSIZE; ++i) {
259  ytemp[i]=(1.-yfrac)*ytempl[ybin][i]+yfrac*ytempl[ybin+1][i];
260  }
261 
262  std::vector<double> xtemp(BXSIZE);
263  for(int i=0; i<BXSIZE; ++i) {
264  xtemp[i]=(1.-xfrac)*xtempl[xbin][i]+xfrac*xtempl[xbin+1][i];
265  }
266 
267  //Pixel readout threshold
268  const float qThreshold = templ.s50()*2.0;
269 
270  //Cut away pixels below readout threshold
271  //For cluster lengths calculation
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 ;
276  if( yCluster )
277  {
278  offsetY1 = BHY -firstY;
279  break;
280  }
281  }
282  for( lastY = firstY; lastY < BYSIZE; ++lastY )
283  {
284  bool yCluster = ytemp[lastY] > qThreshold ;
285  if( !yCluster )
286  {
287  lastY = lastY - 1;
288  offsetY2 = lastY - BHY;
289  break;
290  }
291  }
292 
293  for( firstX = 0; firstX < BXSIZE; ++firstX ) {
294  bool xCluster = xtemp[firstX] > qThreshold ;
295  if( xCluster ) {
296  offsetX1 = BHX - firstX;
297  break;
298  }
299  }
300  for( lastX = firstX; lastX < BXSIZE; ++ lastX ) {
301  bool xCluster = xtemp[lastX] > qThreshold ;
302  if( !xCluster ) {
303  lastX = lastX - 1;
304  offsetX2 = lastX - BHX;
305  break;
306  }
307  }
308 
309  bool edge, edgex, edgey;
310  // bool bigx, bigy;
311  unsigned int clslenx = offsetX1 + offsetX2 + 1;
312  unsigned int clsleny = offsetY1 + offsetY2 + 1;
313 
314  theClslenx = clslenx;
315  theClsleny = clsleny;
316 
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;
325 
326  edgex = rectPixelTopology->isItEdgePixelInX( firstPixelInX ) || rectPixelTopology->isItEdgePixelInX( lastPixelInX );
327  edgey = rectPixelTopology->isItEdgePixelInY( firstPixelInY ) || rectPixelTopology->isItEdgePixelInY( lastPixelInY );
328  edge = edgex || edgey;
329 
330  // bigx = rectPixelTopology->isItBigPixelInX( firstPixelInX ) || rectPixelTopology->isItBigPixelInX( lastPixelInX );
331  // bigy = rectPixelTopology->isItBigPixelInY( firstPixelInY ) || rectPixelTopology->isItBigPixelInY( lastPixelInY );
332  bool hasBigPixelInX = rectPixelTopology->containsBigPixelInX( firstPixelInX, lastPixelInX );
333  bool hasBigPixelInY = rectPixelTopology->containsBigPixelInY( firstPixelInY, lastPixelInY );
334 
335  //Variables for SiPixelTemplate pixel hit error output
336  float sigmay, sigmax, sy1, sy2, sx1, sx2;
337  templ.temperrors(tempId, cotalpha, cotbeta, nqbin, sigmay, sigmax, sy1, sy2, sx1, sx2 );
338 
339  // define private mebers --> Errors
340  if( edge ) {
341  if( edgex && !edgey ) {
342  theErrorX = 23.0*microntocm;
343  theErrorY = 39.0*microntocm;
344  }
345  else if( !edgex && edgey ) {
346  theErrorX = 24.0*microntocm;
347  theErrorY = 96.0*microntocm;
348  }
349  else
350  {
351  theErrorX = 31.0*microntocm;
352  theErrorY = 90.0*microntocm;
353  }
354 
355  }
356  else {
357  if( singlex )
358  if ( hitbigx )
359  theErrorX = sx2*microntocm;
360  else
361  theErrorX = sx1*microntocm;
362  else theErrorX = sigmax*microntocm;
363  if( singley )
364  if( hitbigy )
365  theErrorY = sy2*microntocm;
366  else
367  theErrorY = sy1*microntocm;
368  else theErrorY = sigmay*microntocm;
369  }
370  theErrorZ = 1e-8; // 1 um means zero
372  // Local Error is 2D: (xx,xy,yy), square of sigma in first an third position
373  // as for resolution matrix
374  //
375 #ifdef FAMOS_DEBUG
376  std::cout << " Pixel Errors "
377  << "\talpha(x) = " << theErrorX
378  << "\tbeta(y) = " << theErrorY
379  << std::endl;
380 #endif
381  // Generate position
382  // get resolution histograms
383  int cotalphaHistBin = (int)( ( cotalpha - rescotAlpha_binMin ) / rescotAlpha_binWidth + 1 );
384  int cotbetaHistBin = (int)( ( cotbeta - rescotBeta_binMin ) / rescotBeta_binWidth + 1 );
385  // protection against out-of-range (undeflows and overflows)
386  if( cotalphaHistBin < 1 ) cotalphaHistBin = 1;
387  if( cotbetaHistBin < 1 ) cotbetaHistBin = 1;
388  if( cotalphaHistBin > (int)rescotAlpha_binN ) cotalphaHistBin = (int)rescotAlpha_binN;
389  if( cotbetaHistBin > (int)rescotBeta_binN ) cotbetaHistBin = (int)rescotBeta_binN;
390  //
391  unsigned int theXHistN;
392  unsigned int theYHistN;
393  //ALICE
394  if( !isForward ) {
395  if(edge)
396  {
397  theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
398  theYHistN = theXHistN;
399  }
400  else
401  {
402  if(singlex)
403  {
404  if(hitbigx) theXHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
405  else theXHistN = 1 * 10000 + cotbetaHistBin * 10 + cotalphaHistBin ;
406 //else theXHistN = 1 * 100000 + 1 * 1000 + cotalphaHistBin * 100 + cotbetaHistBin ;
407  }
408  else
409  {
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);
412  //else theXHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
413  }
414  if(singley)
415  {
416  if(hitbigy) theYHistN = 1 * 100000 + cotalphaHistBin * 100 + cotbetaHistBin ;
417  else theYHistN = 1 * 10000 + cotbetaHistBin * 10 + cotalphaHistBin ;
418  // else theYHistN = 1 * 100000 + 1 * 1000 + cotalphaHistBin * 100 + cotbetaHistBin ;
419  }
420  else
421  {
422  if(hasBigPixelInY) theYHistN = 1 * 1000000 + 1 * 100000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
423  // else theYHistN = 1 * 1000000 + 1 * 100000 + 1 * 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
424  else theYHistN = 1 * 100000 + 1 * 10000 + cotbetaHistBin * 100 + cotalphaHistBin * 10 + (nqbin+1);
425 
426  }
427  }
428  }
429  else
430  {
431  if(edge)
432  {
433  theXHistN = cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
434  theYHistN = theXHistN;
435  }
436  else
437  {
438  if( singlex )
439  if( hitbigx )
440  theXHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
441  else{
442  theXHistN = cotbetaHistBin * 10 + cotalphaHistBin;
443  // theXHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
444  }
445  else{
446  theXHistN = 10000 + cotbetaHistBin * 100 + cotalphaHistBin * 10 + (nqbin+1);
447  // theXHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
448  }
449  if( singley )
450  if( hitbigy )
451  theYHistN = 100000 + cotalphaHistBin * 100 + cotbetaHistBin;
452  else{
453  theYHistN = cotbetaHistBin * 10 + cotalphaHistBin;
454  // theYHistN = 100000 + 1000 + cotalphaHistBin * 100 + cotbetaHistBin;
455  }
456  else{
457  theYHistN = 10000 + cotbetaHistBin * 100 + cotalphaHistBin * 10 + (nqbin+1);
458  //theYHistN = 100000 + 10000 + cotalphaHistBin * 1000 + cotbetaHistBin * 10 + (nqbin+1);
459  }
460  }
461  }
462  unsigned int counter = 0;
463  do {
464  //
465  // Smear the hit Position
466  thePositionX = theXHistos[theXHistN]->generate(random);
467  thePositionY = theYHistos[theYHistN]->generate(random);
468  if( isForward ) thePositionY *= sign;
469  thePositionZ = 0.0; // set at the centre of the active area
470  //protect from empty resolution histograms
471  //if( thePositionX > 0.0799 ) thePositionX = 0;
472  //if( thePositionY > 0.0799 ) thePositionY = 0;
473  thePosition =
474  Local3DPoint(simHit.localPosition().x() + thePositionX ,
475  simHit.localPosition().y() + thePositionY ,
476  simHit.localPosition().z() + thePositionZ );
477 #ifdef FAMOS_DEBUG
478  std::cout << " Detector bounds: "
479  << "\t\tx = " << boundX
480  << "\ty = " << boundY
481  << std::endl;
482  std::cout << " Generated local position "
483  << "\tx = " << thePosition.x()
484  << "\ty = " << thePosition.y()
485  << std::endl;
486 #endif
487  counter++;
488  if(counter > 20) {
489  thePosition = Local3DPoint(simHit.localPosition().x(),
490  simHit.localPosition().y(),
491  simHit.localPosition().z());
492  break;
493  }
494  } while(fabs(thePosition.x()) > boundX || fabs(thePosition.y()) > boundY);
495 
496 }
bool containsBigPixelInY(int iymin, int iymax) const
int i
Definition: DBlmapReader.cc:9
#define BXSIZE
T y() const
Definition: PV2DBase.h:46
bool isItEdgePixelInY(int iybin) const
#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
virtual bool isItBigPixelInY(const int iybin) const
double sign(double x)
bool isItEdgePixelInX(int ixbin) const
T y() const
Definition: PV3DBase.h:63
virtual int nrows() const =0
TRandom random
Definition: MVATrainer.cc:138
const Int_t ysize
virtual MeasurementPoint measurementPosition(const LocalPoint &lp) const
std::map< unsigned, const SimpleHistogramGenerator * > theXHistos
Local3DPoint localPosition() const
Definition: PSimHit.h:44
#define BHX
T z() const
Definition: PV3DBase.h:64
bool containsBigPixelInX(int ixmin, int ixmax) const
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
virtual LocalPoint localPosition(const MeasurementPoint &mp) const
std::map< unsigned, const SimpleHistogramGenerator * > theYHistos
virtual const TopologyType & specificTopology() const
#define BHY
static std::atomic< unsigned int > counter
virtual bool isItBigPixelInX(const int ixbin) const
tuple cout
Definition: gather_cfg.py:145
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 106 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getError(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::theErrorX
private

Definition at line 107 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getErrorX(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::theErrorY
private

Definition at line 108 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getErrorY(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::theErrorZ
private

Definition at line 109 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
TFile* SiPixelGaussianSmearingRecHitConverterAlgorithm::thePixelResolutionFile3
private
std::string SiPixelGaussianSmearingRecHitConverterAlgorithm::thePixelResolutionFileName1
private
std::string SiPixelGaussianSmearingRecHitConverterAlgorithm::thePixelResolutionFileName2
private
std::string SiPixelGaussianSmearingRecHitConverterAlgorithm::thePixelResolutionFileName3
private
std::vector< SiPixelTemplateStore > SiPixelGaussianSmearingRecHitConverterAlgorithm::thePixelTemp_
private
Local3DPoint SiPixelGaussianSmearingRecHitConverterAlgorithm::thePosition
private

Definition at line 102 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getPosition(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::thePositionX
private

Definition at line 103 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getPositionX(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::thePositionY
private

Definition at line 104 of file SiPixelGaussianSmearingRecHitConverterAlgorithm.h.

Referenced by getPositionY(), and smearHit().

double SiPixelGaussianSmearingRecHitConverterAlgorithm::thePositionZ
private

Definition at line 105 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