Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:25:20

0001 #ifndef MU_END_STRIP_ELECTRONICS_SIM_H
0002 #define MU_END_STRIP_ELECTRONICS_SIM_H
0003 
0004 /** \class CSCStripElectronicsSim
0005  * Model the readout electronics chain for EMU CSC strips
0006  *
0007  * \author Rick Wilkinson
0008  *
0009  */
0010 
0011 #include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h"
0012 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
0013 #include "SimMuon/CSCDigitizer/src/CSCBaseElectronicsSim.h"
0014 #include "SimMuon/CSCDigitizer/src/CSCStripAmpResponse.h"
0015 
0016 class CSCDetectorHit;
0017 class CSCComparatorDigi;
0018 class CSCCrosstalkGenerator;
0019 class CSCStripConditions;
0020 #include <list>
0021 #include <string>
0022 #include <vector>
0023 
0024 namespace CLHEP {
0025   class HepRandomEngine;
0026 }
0027 
0028 class CSCStripElectronicsSim : public CSCBaseElectronicsSim {
0029 public:
0030   /// configurable parameters
0031   explicit CSCStripElectronicsSim(const edm::ParameterSet &p);
0032 
0033   ~CSCStripElectronicsSim() override;
0034 
0035   void fillDigis(CSCStripDigiCollection &digis, CSCComparatorDigiCollection &comparators, CLHEP::HepRandomEngine *);
0036 
0037   void fillMissingLayer(const CSCLayer *layer,
0038                         const CSCComparatorDigiCollection &comparators,
0039                         CSCStripDigiCollection &digis,
0040                         CLHEP::HepRandomEngine *);
0041 
0042   void setStripConditions(CSCStripConditions *cond) { theStripConditions = cond; }
0043 
0044   CSCAnalogSignal makeNoiseSignal(int element, CLHEP::HepRandomEngine *) override;
0045 
0046   void createDigi(int istrip,
0047                   const CSCAnalogSignal &signal,
0048                   std::vector<CSCStripDigi> &result,
0049                   CLHEP::HepRandomEngine *);
0050 
0051 private:
0052   /// initialization for each layer
0053   void initParameters() override;
0054 
0055   int readoutElement(int strip) const override;
0056 
0057   float calculateAmpResponse(float t) const override;
0058   CSCStripAmpResponse theAmpResponse;
0059 
0060   void runComparator(std::vector<CSCComparatorDigi> &result, CLHEP::HepRandomEngine *);
0061 
0062   /// calculates the comparator reading, including saturation and offsets
0063   float comparatorReading(const CSCAnalogSignal &signal, float time, CLHEP::HepRandomEngine *) const;
0064 
0065   // tells which strips to read out around the input strip
0066   void getReadoutRange(int inputStrip, int &minStrip, int &maxStrip);
0067 
0068   /// finds the key strips from these comparators
0069   std::list<int> getKeyStrips(const std::vector<CSCComparatorDigi> &comparators) const;
0070 
0071   /// get ths strips that have detector hits
0072   std::list<int> getKeyStripsFromMC() const;
0073   /// finds what strips to read.  Will either take 5 strips around
0074   /// the keystrip, or the whole CFEB, based on doSuppression_
0075   std::list<int> channelsToRead(const std::list<int> &keyStrips, int window) const;
0076 
0077   void fillStripDigis(const std::list<int> &keyStrips, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *);
0078 
0079   void addCrosstalk(CLHEP::HepRandomEngine *);
0080   void addCrosstalk(const CSCAnalogSignal &signal, int thisStrip, int otherStrip, CLHEP::HepRandomEngine *);
0081 
0082   void selfTest() const;
0083 
0084   // saturation of the 12-bit ADC.  Max reading is 4095
0085   void doSaturation(CSCStripDigi &digi);
0086 
0087   // useful constants
0088   float theComparatorThreshold;  // in fC
0089   float theComparatorNoise;
0090   float theComparatorRMSOffset;
0091   // note that we don't implement the effect of the x3.5 amplifier
0092   float theComparatorSaturation;
0093   // all of these times are in nanoseconds
0094   float theComparatorWait;
0095   float theComparatorDeadTime;
0096   float theDaqDeadTime;
0097   // save the calculation of time-of-flight+drift+shaping
0098   float theTimingOffset;
0099 
0100   int nScaBins_;
0101   bool doSuppression_;
0102   bool doCrosstalk_;
0103   CSCStripConditions *theStripConditions;
0104   CSCCrosstalkGenerator *theCrosstalkGenerator;
0105 
0106   int theComparatorClockJump;
0107   // the length of each SCA time bin, in ns.  50 by default
0108   float sca_time_bin_size;
0109   // the SCA bin which holds the peak signal.  4, by default.
0110   // that's really the 5th, since We start counting at 0
0111   int sca_peak_bin;
0112   // which time bin the trigger crossing goes in
0113   double theComparatorTimeBinOffset;
0114   // to center comparator signals
0115   double theComparatorTimeOffset;
0116   double theComparatorSamplingTime;
0117   // tweaks the timing of the SCA
0118   std::vector<double> theSCATimingOffsets;
0119   // remeber toe TOF correction in comparators,
0120   // so we can undo it for SCA
0121   float theAverageTimeOfFlight;
0122 };
0123 
0124 #endif