CMS 3D CMS Logo

SiPixelDigitizerAlgorithm.h

Go to the documentation of this file.
00001 #ifndef SiPixelDigitizerAlgorithm_h
00002 #define SiPixelDigitizerAlgorithm_h
00003 
00004 #include <string>
00005 #include <map>
00006 
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 #include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
00009 #include "DataFormats/SiPixelDigi/interface/PixelDigiCollection.h"
00010 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00011 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
00012 
00013 //#include "SimGeneral/HepPDT/interface/HepPDTable.h"
00014 //#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
00015 
00016 #include "SimTracker/Common/interface/SiG4UniversalFluctuation.h"
00017 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00018 #include "DataFormats/DetId/interface/DetId.h"
00019 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00020 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
00021 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
00022 //#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomFromDetUnits.h"
00023 #include "SimGeneral/NoiseGenerators/interface/GaussianTailNoiseGenerator.h"
00024 //#include "DataFormats/GeometrySurface/interface/TkRotation.h"
00025 //#include "DataFormats/GeometrySurface/interface/GloballyPositioned.h"
00026 #include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h"
00027 //#include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLinkCollection.h"
00028 #include "DataFormats/Common/interface/DetSetVector.h"
00029 
00030 #include "CondFormats/SiPixelObjects/interface/PixelIndices.h"
00031 
00032 // pixel gain payload access (offline version)
00033 #include "CondTools/SiPixel/interface/SiPixelGainCalibrationOfflineService.h"
00034 
00035 // Accessing Pixel Lorentz Angle from the DB:
00036 #include "CondFormats/SiPixelObjects/interface/SiPixelLorentzAngle.h"
00037 #include "CondFormats/DataRecord/interface/SiPixelLorentzAngleRcd.h"
00038 
00039 // Accessing Pixel dead modules from the DB:
00040 //#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
00041 //#include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h"
00042 
00043 
00044 // For the random numbers
00045 namespace CLHEP {
00046   class RandGaussQ;
00047   class RandFlat;
00048 }
00049 
00050 class SiPixelDigitizerAlgorithm  {
00051  public:
00052   
00053   SiPixelDigitizerAlgorithm(const edm::ParameterSet& conf);
00054   ~SiPixelDigitizerAlgorithm();
00055   
00056   //run the algorithm to digitize a single det
00057   edm::DetSet<PixelDigi>::collection_type  
00058     run(const std::vector<PSimHit> &input,PixelGeomDetUnit *pixdet,GlobalVector);
00059 
00060    //
00061   std::vector<PixelDigiSimLink> make_link() {
00062     return link_coll; }
00063   void init(const edm::EventSetup& es);
00064   void fillDeadModules(const edm::EventSetup& es);
00065   void fillLorentzAngle(const edm::EventSetup& es);
00066 
00067  private:
00068   
00069   //Accessing Lorentz angle from DB:
00070   edm::ESHandle<SiPixelLorentzAngle> SiPixelLorentzAngle_;
00071 
00072   //Accessing Dead pixel modules from DB:
00073   //  edm::ESHandle<SiPixelQuality> SiPixelBadModule_;
00074 
00075 
00076 
00077   typedef std::vector<edm::ParameterSet> Parameters;
00078   Parameters DeadModules;
00079 
00080   // Define internal classes
00081   
00082   // Define a class to hold the calibration parameters per pixel
00083   // Internal
00084   class CalParameters {
00085   public:
00086     float p0;
00087     float p1;
00088     float p2;
00089     float p3;
00090   };
00091   //
00092   // Define a class for 3D ionization points and energy
00093   //
00097   class EnergyDepositUnit{
00098   public:
00099     EnergyDepositUnit(): _energy(0),_position(0,0,0){}
00100     EnergyDepositUnit(float energy,float x, float y, float z):
00101     _energy(energy),_position(x,y,z){}
00102     EnergyDepositUnit(float energy, Local3DPoint position):
00103     _energy(energy),_position(position){}
00104     float x() const{return _position.x();}
00105     float y() const{return _position.y();}
00106     float z() const{return _position.z();}
00107     float energy() const { return _energy;}
00108   private:
00109     float _energy;
00110     Local3DPoint _position;
00111   };
00112 
00113   //
00114   // define class to store signals on the collection surface
00115   //
00120   class SignalPoint {
00121   public:
00122     SignalPoint() : _pos(0,0), _time(0), _amplitude(0), 
00123       _sigma_x(1.), _sigma_y(1.), _hitp(0) {}
00124     
00125     SignalPoint( float x, float y, float sigma_x, float sigma_y,
00126                  float t, float a=1.0) :
00127     _pos(x,y), _time(t), _amplitude(a), _sigma_x(sigma_x), 
00128       _sigma_y(sigma_y), _hitp(0) {}
00129     
00130     SignalPoint( float x, float y, float sigma_x, float sigma_y,
00131                  float t, const PSimHit& hit, float a=1.0) :
00132     _pos(x,y), _time(t), _amplitude(a), _sigma_x(sigma_x), 
00133       _sigma_y(sigma_y),_hitp(&hit) {}
00134     
00135     const LocalPoint& position() const { return _pos;}
00136     float x()         const { return _pos.x();}
00137     float y()         const { return _pos.y();}
00138     float sigma_x()   const { return _sigma_x;}
00139     float sigma_y()   const { return _sigma_y;}
00140     float time()      const { return _time;}
00141     float amplitude() const { return _amplitude;}
00142     const PSimHit& hit()           { return *_hitp;}
00143     SignalPoint& set_amplitude( float amp) { _amplitude = amp; return *this;}
00144     
00145   
00146 
00147   private:
00148     LocalPoint         _pos;
00149     float              _time;
00150     float              _amplitude;
00151     float              _sigma_x;   // gaussian sigma in the x direction (cm)
00152     float              _sigma_y;   //    "       "          y direction (cm) */
00153     const PSimHit*   _hitp;
00154   };
00155  
00156   //
00157   // definition class
00158   //
00163   class Amplitude {
00164   public:
00165     Amplitude() : _amp(0.0) { _hits.reserve(1);}
00166     Amplitude( float amp, const PSimHit* hitp, float frac) :
00167     _amp(amp), _hits(1, hitp), _frac(1,frac) {
00168      //in case of digi from noisypixels
00169       //the MC information are removed 
00170       if (_frac[0]<-0.5) {
00171         _frac.pop_back();
00172         _hits.pop_back();
00173      }
00174     }
00175 
00176     // can be used as a float by convers.
00177     operator float() const { return _amp;}
00178     float ampl() const {return _amp;}
00179     std::vector<float> individualampl() const {return _frac;}
00180     const std::vector<const PSimHit*>& hits() { return _hits;}
00181 
00182     void operator+=( const Amplitude& other) {
00183       _amp += other._amp;
00184       //in case of contribution of noise to the digi
00185       //the MC information are removed 
00186       if (other._frac[0]>-0.5){
00187         _hits.insert( _hits.end(), other._hits.begin(), other._hits.end());
00188         _frac.insert(_frac.end(), other._frac.begin(), other._frac.end());
00189       }
00190    }
00191 
00192     void operator+=( const float& amp) {
00193       _amp += amp;
00194     }
00195    
00196     void set (const float amplitude) {  // Used to reset the amplitude
00197       _amp = amplitude;
00198     }
00199 /*     void setind (const float indamplitude) {  // Used to reset the amplitude */
00200 /*       _frac = idamplitude; */
00201 /*     } */
00202   private:
00203     float _amp;
00204     std::vector<const PSimHit*> _hits;
00205     std::vector<float> _frac;
00206   };  // end class Amplitude
00207 
00208 
00209  private:
00210 
00211     // Internal typedefs
00212     typedef std::map< int, Amplitude, std::less<int> >   signal_map_type;  // from
00213     typedef signal_map_type::iterator          signal_map_iterator; //Digi.Skel.  
00214     typedef std::map<unsigned int, std::vector<float>,std::less<unsigned int> > 
00215       simlink_map;
00216     typedef GloballyPositioned<double>      Frame;
00217 
00218     // Variables 
00219     edm::ParameterSet conf_;
00220     //external parameters 
00221     //-- primary ionization
00222     int    NumberOfSegments; // =20 does not work ;
00223     // go from Geant energy GeV to number of electrons
00224     float GeVperElectron; // 3.7E-09 
00225     
00226     //-- drift
00227     float Sigma0; //=0.0007  // Charge diffusion in microns for 300 micron Si
00228     float Dist300;  //=0.0300  // Define 300microns for normalization 
00229     bool alpha2Order;          // Switch on/off of E.B effect 
00230 
00231 
00232  
00233     //-- induce_signal
00234     float ClusterWidth;       // Gaussian charge cutoff width in sigma units
00235     //-- make_digis 
00236     float theElectronPerADC;     // Gain, number of electrons per adc count.
00237     int theAdcFullScale;         // Saturation count, 255=8bit.
00238     float theNoiseInElectrons;   // Noise (RMS) in units of electrons.
00239     float theReadoutNoise;       // Noise of the readount chain in elec,
00240                                  //inludes DCOL-Amp,TBM-Amp, Alt, AOH,OptRec.
00241     float thePixelThreshold;     // Pixel threshold in units of noise.
00242 
00243     float thePixelThresholdInE;  // Pixel noise in electrons.
00244 
00245     float theThresholdInE_FPix;  // Pixel threshold in electrons FPix.
00246     float theThresholdInE_BPix;  // Pixel threshold in electrons BPix.
00247 
00248     double theThresholdSmearing_FPix;
00249     double theThresholdSmearing_BPix;
00250 
00251     double electronsPerVCAL;          // for electrons - VCAL conversion
00252     double electronsPerVCAL_Offset;   // in misscalibrate()
00253 
00254     float theTofLowerCut;             // Cut on the particle TOF
00255     float theTofUpperCut;             // Cut on the particle TOF
00256     float tanLorentzAnglePerTesla_FPix;   //FPix Lorentz angle tangent per Tesla
00257     float tanLorentzAnglePerTesla_BPix;   //BPix Lorentz angle tangent per Tesla
00258 
00259 
00260 
00261     //-- add_noise
00262     bool addNoise;
00263     bool addNoisyPixels;
00264     bool fluctuateCharge;
00265     bool addPixelInefficiency;
00266     //-- pixel efficiency
00267     bool pixelInefficiency;      // Switch on pixel ineffciency
00268     int  thePixelLuminosity;        // luminosity for inefficiency, 0,1,10
00269 
00270     bool addThresholdSmearing;
00271         
00272     int theColsInChip;           // num of columns per ROC (for pix ineff.)
00273     int theRowsInChip;           // num of rows per ROC
00274     
00275     int numColumns; // number of pixel columns in a module (detUnit)
00276     int numRows;    // number          rows
00277     float moduleThickness; // sensor thickness 
00278     //  int digis; 
00279     const PixelGeomDetUnit* _detp;
00280     uint32_t detID;     // Det id
00281     
00282 
00283     std::vector<PSimHit> _PixelHits; //cache
00284     const PixelTopology* topol;
00285     
00286     std::vector<PixelDigi> internal_coll; //empty vector of PixelDigi used in digitize
00287 
00288     std::vector<PixelDigiSimLink> link_coll;
00289     GlobalVector _bfield;
00290     
00291     float PixelEff;
00292     float PixelColEff;
00293     float PixelChipEff;
00294     float PixelEfficiency;
00295     float PixelColEfficiency;
00296     float PixelChipEfficiency;
00297     float thePixelEfficiency[6];     // Single pixel effciency
00298     float thePixelColEfficiency[6];  // Column effciency
00299     float thePixelChipEfficiency[6]; // ROC efficiency
00300     
00301     //-- calibration smearing
00302     bool doMissCalibrate;         // Switch on the calibration smearing
00303     float theGainSmearing;        // The sigma of the gain fluctuation (around 1)
00304     float theOffsetSmearing;      // The sigma of the offset fluct. (around 0)
00305     
00306 
00307     // The PDTable
00308     //HepPDTable *particleTable;
00309     //ParticleDataTable *particleTable;
00310 
00311     //-- charge fluctuation
00312     double tMax;  // The delta production cut, should be as in OSCAR = 30keV
00313     //                                           cmsim = 100keV
00314     // The eloss fluctuation class from G4. Is the right place? 
00315     SiG4UniversalFluctuation * fluctuate;   // make a pointer 
00316     GaussianTailNoiseGenerator * theNoiser; //
00317 
00318 
00319 
00320 
00321     PixelIndices * pIndexConverter;         // Pointer to the index converter 
00322    
00323     std::vector<EnergyDepositUnit> _ionization_points;
00324     std::vector<SignalPoint> _collection_points;
00325     
00326     simlink_map simi;
00327     signal_map_type     _signal;       // from Digi.Skel.
00328 
00329     // To store calibration constants
00330     std::map<int,CalParameters,std::less<int> > calmap;
00331 
00332 
00333     //-- additional member functions    
00334     // Private methods
00335     void primary_ionization( const PSimHit& hit);
00336     std::vector<PixelDigi> digitize(PixelGeomDetUnit *det);
00337     void drift(const PSimHit& hit);
00338     void induce_signal( const PSimHit& hit);
00339     void fluctuateEloss(int particleId, float momentum, float eloss, 
00340                         float length, int NumberOfSegments,
00341                         float elossVector[]);
00342     void add_noise();
00343     void make_digis();
00344     void pixel_inefficiency();
00345     bool use_ineff_from_db_;
00346 
00347     bool use_module_killing_; // remove or not the dead pixel modules
00348     bool use_deadmodule_DB_; // if we want to get dead pixel modules from the DataBase.
00349     bool use_LorentzAngle_DB_; // if we want to get Lorentz angle from the DataBase.
00350 
00351     void pixel_inefficiency_db(); 
00352        // access to the gain calibration payloads in the db. Only gets initialized if check_dead_pixels_ is set to true.
00353     SiPixelGainCalibrationOfflineService * theSiPixelGainCalibrationService_;    
00354     float missCalibrate(int col, int row, float amp) const;  
00355     LocalVector DriftDirection();
00356 
00357     void module_killing_conf(); // remove dead modules using the list in the configuration file PixelDigi_cfi.py
00358     void module_killing_DB();  // remove dead modules uisng the list in the DB
00359 
00360    // For random numbers
00361     CLHEP::RandFlat *flatDistribution_;
00362     CLHEP::RandGaussQ *gaussDistribution_;
00363 
00364     // Threshold gaussian smearing:
00365     CLHEP::RandGaussQ *smearedThreshold_FPix_;
00366     CLHEP::RandGaussQ *smearedThreshold_BPix_;
00367 
00368 
00369   // the random generator
00370   CLHEP::RandGaussQ* theGaussianDistribution;
00371     
00372 };
00373 
00374 #endif

Generated on Tue Jun 9 17:47:53 2009 for CMSSW by  doxygen 1.5.4