Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:32

0001 #ifndef EcalSimAlgos_EcalTimeMapDigitizer_h
0002 #define EcalSimAlgos_EcalTimeMapDigitizer_h
0003 
0004 /** Turns hits into digis.  Assumes that 
0005     there's an ElectroncsSim class with the
0006     interface analogToDigital(const CaloSamples &, Digi &);
0007 */
0008 
0009 #include "CalibFormats/CaloObjects/interface/CaloTSamples.h"
0010 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0011 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
0012 #include "DataFormats/DetId/interface/DetId.h"
0013 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0014 #include "CalibFormats/CaloObjects/interface/CaloTSamplesBase.h"
0015 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0016 
0017 class CaloSubdetectorGeometry;
0018 
0019 class EcalTimeMapDigitizer {
0020 public:
0021   struct time_average {
0022     static const unsigned short time_average_capacity = 10;
0023 
0024     DetId id;
0025     float average_time[time_average_capacity];
0026     unsigned int nhits[time_average_capacity];
0027     float tot_energy[time_average_capacity];
0028 
0029     time_average(const DetId& myId) : id(myId) {
0030       for (unsigned int i(0); i < time_average_capacity; ++i) {
0031         average_time[i] = 0;
0032         nhits[i] = 0;
0033         tot_energy[i] = 0;
0034       }
0035     };
0036 
0037     void calculateAverage() {
0038       for (unsigned int i(0); i < time_average_capacity; ++i) {
0039         if (nhits[i] > 0)
0040           average_time[i] = average_time[i] / tot_energy[i];
0041         else
0042           average_time[i] = 0;
0043       }
0044     };
0045 
0046     void setZero() {
0047       for (unsigned int i(0); i < time_average_capacity; ++i) {
0048         average_time[i] = 0;
0049         nhits[i] = 0;
0050         tot_energy[i] = 0;
0051       }
0052     };
0053 
0054     bool zero() {
0055       for (unsigned int i(0); i < time_average_capacity; ++i) {
0056         if (nhits[i] > 0)
0057           return false;
0058       }
0059       return true;
0060     };
0061   };
0062 
0063   typedef time_average TimeSamples;
0064 
0065   typedef EcalTimeDigi Digi;
0066 
0067   typedef std::vector<unsigned int> VecInd;
0068 
0069   explicit EcalTimeMapDigitizer(EcalSubdetector myDet);
0070 
0071   virtual ~EcalTimeMapDigitizer();
0072 
0073   void add(const std::vector<PCaloHit>& hits, int bunchCrossing);
0074 
0075   void setGeometry(const CaloSubdetectorGeometry* geometry);
0076 
0077   void initializeMap();
0078 
0079   void run(EcalTimeDigiCollection& output);
0080 
0081   void finalizeHits();
0082 
0083   inline void setTimeLayerId(const int& layerId) { m_timeLayerId = layerId; };
0084 
0085   int getTimeLayerId() { return m_timeLayerId; };
0086 
0087   EcalSubdetector subdetector() { return m_subDet; };
0088 
0089   int minBunch() const;
0090 
0091   int maxBunch() const;
0092 
0093   void blankOutUsedSamples();  // blank out previously used elements
0094 
0095   /*   const CaloVHitFilter* hitFilter() const ; */
0096 
0097 private:
0098   TimeSamples* findSignal(const DetId& detId);
0099 
0100   VecInd& index();
0101 
0102   const VecInd& index() const;
0103 
0104   unsigned int samplesSize() const;
0105 
0106   unsigned int samplesSizeAll() const;
0107 
0108   const TimeSamples* operator[](unsigned int i) const;
0109 
0110   TimeSamples* operator[](unsigned int i);
0111 
0112   TimeSamples* vSam(unsigned int i);
0113 
0114   TimeSamples* vSamAll(unsigned int i);
0115 
0116   const TimeSamples* vSamAll(unsigned int i) const;
0117 
0118   EcalSubdetector m_subDet;
0119   //time difference between bunches
0120 
0121   static const int BUNCHSPACE = 25;
0122 
0123   static const float MIN_ENERGY_THRESHOLD;  //50 KeV threshold to consider a valid hit in the timing detector
0124 
0125   static const int m_minBunch = -4;
0126   static const int m_maxBunch = 5;
0127 
0128   int m_timeLayerId;
0129 
0130   const CaloSubdetectorGeometry* m_geometry;
0131 
0132   double timeOfFlight(const DetId& detId, int layer) const;
0133 
0134   std::vector<TimeSamples> m_vSam;
0135 
0136   VecInd m_index;
0137 };
0138 
0139 #endif