Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:45

0001 #ifndef __SimCalorimetry_FastTimingSimProducers_MTDDigitizerTypes_h__
0002 #define __SimCalorimetry_FastTimingSimProducers_MTDDigitizerTypes_h__
0003 
0004 #include "DataFormats/DetId/interface/DetId.h"
0005 #include <unordered_map>
0006 #include <array>
0007 
0008 namespace mtd_digitizer {
0009 
0010   //15 time samples: 9 pre-samples, 1 in-time, 5 post-samples
0011   constexpr size_t nSamples = 15;
0012 
0013   typedef float MTDSimData_t;
0014 
0015   typedef std::array<MTDSimData_t, nSamples> MTDSimHitData;
0016 
0017   struct MTDCellInfo {
0018     // for the BTL bar geometry:
0019     //     3rd array=energy (right side), 4th array=time-of-flight (right side)
0020     std::array<MTDSimHitData, 4> hit_info;
0021   };
0022 
0023   // Maximum value of time-of-flight for premixing packing
0024   constexpr float PREMIX_MAX_TOF = 25.0f;
0025 
0026   struct MTDCellId {
0027     MTDCellId() : detid_(0), row_(0), column_(0) {}
0028     const uint32_t detid_;
0029     const uint8_t row_, column_;
0030     MTDCellId(const DetId& id) : detid_(id.rawId()), row_(0), column_(0) {}
0031     MTDCellId(const DetId& id, uint8_t row, uint8_t col) : detid_(id.rawId()), row_(row), column_(col) {}
0032     bool operator==(const MTDCellId& eq) const {
0033       return (detid_ == eq.detid_) && (row_ == eq.row_) && (column_ == eq.column_);
0034     }
0035   };
0036 
0037   // use a wider integer now since we have to add row and column in an
0038   // intermediate det id for ETL
0039   typedef std::unordered_map<MTDCellId, MTDCellInfo> MTDSimHitDataAccumulator;
0040 
0041   constexpr int kNumberOfBX = 15;
0042   constexpr int kInTimeBX = 9;
0043 
0044 }  // namespace mtd_digitizer
0045 
0046 namespace std {
0047 
0048   constexpr int kRowOffset = 32;
0049   constexpr int kColOffset = 40;
0050 
0051   template <>
0052   struct hash<mtd_digitizer::MTDCellId> {
0053     typedef mtd_digitizer::MTDCellId argument_type;
0054     typedef std::size_t result_type;
0055     result_type operator()(argument_type const& s) const noexcept {
0056       uint64_t input = (uint64_t)s.detid_ | ((uint64_t)s.row_) << kRowOffset | ((uint64_t)s.column_) << kColOffset;
0057       return std::hash<uint64_t>()(input);
0058     }
0059   };
0060 }  // namespace std
0061 
0062 #endif