Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-23 22:53:25

0001 #ifndef CaloSimAlgos_CaloHitResponse_h
0002 #define CaloSimAlgos_CaloHitResponse_h
0003 
0004 #include "CalibFormats/CaloObjects/interface/CaloSamples.h"
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0007 #include "SimCalorimetry/CaloSimAlgos/interface/CaloVPECorrection.h"
0008 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
0009 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0010 
0011 #include <map>
0012 #include <vector>
0013 
0014 /**
0015 
0016  \class CaloHitResponse
0017 
0018  \brief Creates electronics signals from hits
0019 
0020 */
0021 
0022 namespace CLHEP {
0023   class HepRandomEngine;
0024 }
0025 
0026 class CaloVShape;
0027 class CaloShapes;
0028 class CaloVSimParameterMap;
0029 class CaloVHitCorrection;
0030 class CaloVHitFilter;
0031 class CaloSimParameters;
0032 
0033 class CaloHitResponse {
0034 public:
0035   typedef std::map<DetId, CaloSamples> AnalogSignalMap;
0036   // get this from somewhere external
0037   enum { BUNCHSPACE = 25 };
0038   static constexpr double dt = 0.5;
0039   static constexpr int invdt = 2;
0040 
0041   CaloHitResponse(const CaloVSimParameterMap *parameterMap,
0042                   const CaloVShape *shape,
0043                   bool PreMix1 = false,
0044                   bool HighFidelity = false);
0045   CaloHitResponse(const CaloVSimParameterMap *parameterMap,
0046                   const CaloShapes *shapes,
0047                   bool PreMix1 = false,
0048                   bool HighFidelity = false);
0049 
0050   /// doesn't delete the pointers passed in
0051   virtual ~CaloHitResponse();
0052 
0053   /// tells it which pileup bunches to do
0054   void setBunchRange(int minBunch, int maxBunch);
0055 
0056   /// geometry needed for time-of-flight
0057   void setGeometry(const CaloGeometry *geometry) { theGeometry = geometry; }
0058 
0059   virtual bool keepBlank() const { return true; }
0060 
0061   /// Initialize hits
0062   virtual void initializeHits() {}
0063 
0064   /// Finalize hits
0065   virtual void finalizeHits(CLHEP::HepRandomEngine *);
0066 
0067   /// Complete cell digitization.
0068   virtual void run(const MixCollection<PCaloHit> &hits, CLHEP::HepRandomEngine *);
0069 
0070   /// process a single SimHit
0071   virtual void add(const PCaloHit &hit, CLHEP::HepRandomEngine *);
0072 
0073   /// add a signal, in units of pe
0074   virtual void add(const CaloSamples &signal);
0075 
0076   /// if you want to reject hits, for example, from a certain subdetector, set
0077   /// this
0078   void setHitFilter(const CaloVHitFilter *filter) { theHitFilter = filter; }
0079 
0080   /// If you want to correct hits, for attenuation or delay, set this.
0081   void setHitCorrection(const CaloVHitCorrection *hitCorrection) { theHitCorrection = hitCorrection; }
0082 
0083   /// if you want to correct the photoelectrons
0084   void setPECorrection(const CaloVPECorrection *peCorrection) { thePECorrection = peCorrection; }
0085 
0086   /// frees up memory
0087   void clear() { theAnalogSignalMap.clear(); }
0088 
0089   /// adds the amplitude for a single hit to the frame
0090   void addHit(const PCaloHit *hit, CaloSamples &frame) const;
0091 
0092   /// creates the signal corresponding to this hit
0093   virtual CaloSamples makeAnalogSignal(const PCaloHit &inputHit, CLHEP::HepRandomEngine *) const;
0094 
0095   /// finds the amplitude contribution from this hit, applying
0096   /// photostatistics, if needed.  Results are in photoelectrons
0097   double analogSignalAmplitude(const DetId &id,
0098                                float energy,
0099                                const CaloSimParameters &parameters,
0100                                CLHEP::HepRandomEngine *) const;
0101 
0102   /// users can look for the signal for a given cell
0103   CaloSamples *findSignal(const DetId &detId);
0104 
0105   /// number of signals in the current cache
0106   int nSignals() const { return theAnalogSignalMap.size(); }
0107 
0108   int getReadoutFrameSize(const DetId &id) const;
0109 
0110   /// creates an empty signal for this DetId
0111   CaloSamples makeBlankSignal(const DetId &detId) const;
0112 
0113   /// time-of-flight, in ns, to get to this cell
0114   /// returns 0 if no geometry has been set
0115   double timeOfFlight(const DetId &detId) const;
0116 
0117   /// setting the phase shift for asynchronous trigger (e.g. test beams)
0118   void setPhaseShift(const double &thePhaseShift) { thePhaseShift_ = thePhaseShift; }
0119 
0120   /// check if crossing is within bunch range:
0121 
0122   bool withinBunchRange(int bunchCrossing) const {
0123     return (bunchCrossing >= theMinBunch && bunchCrossing <= theMaxBunch);
0124   }
0125 
0126   void setStorePrecise(bool sp) { storePrecise = sp; }
0127 
0128   void setIgnoreGeantTime(bool gt) { ignoreTime = gt; }
0129 
0130 protected:
0131   AnalogSignalMap theAnalogSignalMap;
0132 
0133   const CaloVSimParameterMap *theParameterMap;
0134   const CaloShapes *theShapes;
0135   const CaloVShape *theShape;
0136   const CaloVHitCorrection *theHitCorrection;
0137   const CaloVPECorrection *thePECorrection;
0138   const CaloVHitFilter *theHitFilter;
0139 
0140   const CaloGeometry *theGeometry;
0141 
0142   int theMinBunch;
0143   int theMaxBunch;
0144 
0145   double thePhaseShift_;
0146   bool storePrecise;
0147   bool preMixDigis;
0148   bool highFidelityPreMix;
0149   bool ignoreTime;
0150 };
0151 
0152 #endif