CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/SimMuon/CSCDigitizer/src/CSCBaseElectronicsSim.h

Go to the documentation of this file.
00001 #ifndef MU_END_BASE_ELECTRONICS_SIM_H
00002 #define MU_END_BASE_ELECTRONICS_SIM_H
00003 
00016 #include "SimMuon/CSCDigitizer/src/CSCAnalogSignal.h"
00017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00018 #include <vector>
00019 #include <map>
00020 
00021 #include "DataFormats/Common/interface/DetSet.h"
00022 #include "SimDataFormats/TrackerDigiSimLink/interface/StripDigiSimLink.h"
00023 #include "CLHEP/Random/RandGaussQ.h"
00024 
00025 // declarations
00026 class CSCLayer;
00027 class CSCChamberSpecs;
00028 class CSCDetectorHit;
00029 class CSCLayerGeometry;
00030 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00031 class DetId;
00032 class PSimHit;
00033 
00034 class CSCBaseElectronicsSim
00035 {
00036 public:
00037 
00038   typedef std::map<int, CSCAnalogSignal, std::less<int> > CSCSignalMap;
00039   typedef edm::DetSet<StripDigiSimLink> DigiSimLinks;
00040  
00041   void setRandomEngine(CLHEP::HepRandomEngine& engine);
00042  
00043   // takes the input detector hits, turns them into DIGIs, and
00044   // stores them in the layer
00045   void simulate(const CSCLayer * layer,
00046                 const std::vector<CSCDetectorHit> & inputHits);
00047 
00048   const DigiSimLinks & digiSimLinks() const {return theDigiSimLinks;}
00049  
00050   virtual ~CSCBaseElectronicsSim();
00051 
00053   void setLayerId(const CSCDetId & id) {theLayerId = id;}
00054 
00055 protected:
00056   // constructor protected, so this class must be a base class
00057   CSCBaseElectronicsSim(const edm::ParameterSet & p);
00058 
00059   void setLayer(const CSCLayer * layer);
00060   // initialize things that change from layer to layer
00061   virtual void initParameters() = 0;
00062 
00063   void fillAmpResponse();
00064   virtual float calculateAmpResponse(float t) const = 0;
00065 
00066   // this one turns CSCDetectorHits into CSCAnalogSignals
00067   CSCAnalogSignal amplifySignal(const CSCDetectorHit &);
00068 
00069   // returns readout element.  So wire 20 might be part of wire group 2.
00070   virtual int readoutElement(int element) const = 0; 
00071 
00072   //  fills the member map of signals on strips, superimposing any duplicates
00073   void combineAnalogSignals(const std::vector<CSCAnalogSignal> &);
00074 
00075   void setNoise(float rmsNoise, float noiseSigmaThreshold);
00076 
00079   void setSignalTimeRange(double startTime, double stopTime) {
00080     theSignalStartTime = startTime;
00081     theSignalStopTime = stopTime;
00082   }
00083 
00084   void addNoise();
00085 
00086   CSCAnalogSignal & find(int element);
00087   // the returned signal will be the one stored in the
00088   // signal, not the original.  If another signal
00089   // is found on this element, they will be superimposed.
00090   CSCAnalogSignal & add(const CSCAnalogSignal &);
00091   virtual CSCAnalogSignal makeNoiseSignal(int element);
00092 
00096   virtual float signalDelay(int element, float pos) const;
00097 
00100   virtual void addLinks(int channelIndex);
00101 
00103   virtual int channelIndex(int channel) const {return channel;}
00104 
00106   CSCDetId layerId() const {return theLayerId;}
00107 
00109   double averageTimeOfFlight(const DetId & detId) const;
00110 
00111   // member data
00112   enum {NONE, CONSERVATIVE, RADICAL}; 
00113 
00114   const CSCChamberSpecs * theSpecs;
00115   const CSCLayerGeometry * theLayerGeometry;
00116   const CSCLayer * theLayer;  // the one currently being digitized
00117   CSCDetId theLayerId;
00118 
00119   CSCSignalMap theSignalMap;
00120   CSCAnalogSignal theAmpResponse;
00121 
00122   // Useful parameters
00123   float theBunchSpacing;
00124 
00125   // lets routines know whether new signals should
00126   //  have noise added, or just be empty.  If the
00127   //  noise hasn't been added yet, just make empty.
00128   bool theNoiseWasAdded;
00129 
00130   // the numbers of wire groups or strips in this layer
00131   int nElements;
00132 
00133   // amplifier parameters
00134   int theShapingTime;
00135   float thePeakTimeSigma;
00136   // used to correct the bunch timing so that the signal event 
00137   // comes at BX zero.
00138   std::vector<double> theBunchTimingOffsets;
00139 
00140   // when the signal is to be simulated
00141   float theSignalStartTime;
00142   float theSignalStopTime;
00143 
00144   // size of time bins for signal shape, in ns
00145   float theSamplingTime;
00146 
00147   // time bins for pulse shape
00148   int theNumberOfSamples;
00149 
00150   // Which bit in the 16-bit time word corresponds to the zeroth beam crossing?
00151   int theOffsetOfBxZero; // bit corresponding to bx 0 (counting from 0-15)
00154   std::vector<double> theSignalPropagationSpeed;
00155   std::vector<double> theTimingCalibrationError;
00156   bool doNoise_;
00157 
00158   // keeps track of which hits contribute to which channels
00159   typedef std::multimap<int, CSCDetectorHit, std::less<int> >  DetectorHitMap;
00160   DetectorHitMap theDetectorHitMap;
00161   DigiSimLinks theDigiSimLinks;
00162 
00163   CLHEP::RandGaussQ * theRandGaussQ;
00164 };
00165 
00166 #endif