CMS 3D CMS Logo

HGCDigitizer.h
Go to the documentation of this file.
1 #ifndef HGCalSimProducers_HGCDigitizer_h
2 #define HGCalSimProducers_HGCDigitizer_h
3 
8 
11 
19 
20 #include <vector>
21 #include <map>
22 #include <unordered_set>
23 #include <memory>
24 #include <tuple>
25 
26 class PCaloHit;
28 
29 class HGCDigitizer {
30 public:
32  ~HGCDigitizer() = default;
33 
34  // index , det id, time
35  typedef std::tuple<int, uint32_t, float> HGCCaloHitTuple_t;
37  unsigned int detId_a(std::get<1>(a)), detId_b(std::get<1>(b));
38 
39  if (detId_a < detId_b)
40  return true;
41  if (detId_a > detId_b)
42  return false;
43 
44  double time_a(std::get<2>(a)), time_b(std::get<2>(b));
45  if (time_a < time_b)
46  return true;
47 
48  return false;
49  }
50 
54  void accumulate(edm::Event const& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre);
55  void accumulate_forPreMix(edm::Event const& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre);
56 
57  void accumulate(PileUpEventPrincipal const& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre);
58  void accumulate_forPreMix(PileUpEventPrincipal const& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre);
59 
61  int bxCrossing,
62  const HGCalGeometry* geom,
63  CLHEP::HepRandomEngine* hre);
65  int bxCrossing,
66  const HGCalGeometry* geom,
67  CLHEP::HepRandomEngine* hre);
68 
69  void accumulate_forPreMix(const PHGCSimAccumulator& simAccumulator, const bool minbiasFlag);
73  void initializeEvent(edm::Event const& e, edm::EventSetup const& c);
74  void finalizeEvent(edm::Event& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre);
75 
77 
78 private:
79  uint32_t getType() const;
80 
81  std::unique_ptr<hgc::HGCSimHitDataAccumulator> simHitAccumulator_;
82  std::unique_ptr<hgc::HGCPUSimHitDataAccumulator> pusimHitAccumulator_;
83 
85 
86  //digitization type (it's up to the specializations to decide it's meaning)
87  const int digitizationType_;
88 
89  // if true, we're running mixing in premixing stage1 and have to produce the output differently
90  const bool premixStage1_;
91 
92  // Minimum charge threshold for premixing stage1
93  const double premixStage1MinCharge_;
94  // Maximum charge for packing in premixing stage1
95  const double premixStage1MaxCharge_;
96 
97  //handle sim hits
98  const int maxSimHitsAccTime_;
99  const double bxTime_;
106  //debug position
107  void checkPosition(const HGCalDigiCollection* digis) const;
108 
109  //digitizer
110  std::unique_ptr<HGCDigitizerBase> theDigitizer_;
111 
112  //geometries
115  std::unordered_set<DetId> validIds_;
116  const HGCalGeometry* gHGCal_ = nullptr;
117 
118  //misc switches
119  const uint32_t verbosity_;
120 
121  //delay to apply after evaluating time of arrival at the sensitive detector
122  const float tofDelay_;
123 
124  //average occupancies
125  std::array<double, 4> averageOccupancies_;
126  uint32_t nEvents_;
127 
128  //maxBx limit beyond which the Digitizer should filter out all hits
129  static const unsigned int maxBx_ = 14;
130  static const unsigned int thisBx_ = 9;
131  std::vector<float> cce_;
132  std::unordered_map<uint32_t, std::vector<std::pair<float, float>>> hitRefs_bx0;
133  std::unordered_map<uint32_t, std::vector<std::tuple<float, float, float>>> PhitRefs_bx0;
134  std::unordered_map<uint32_t, bool> hitOrder_monitor;
135 };
136 
137 #endif
const std::string hitsProducer_
Definition: HGCDigitizer.h:101
uint32_t nEvents_
Definition: HGCDigitizer.h:126
void checkPosition(const HGCalDigiCollection *digis) const
std::vector< float > cce_
Definition: HGCDigitizer.h:131
void finalizeEvent(edm::Event &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre)
std::unique_ptr< HGCDigitizerBase > theDigitizer_
Definition: HGCDigitizer.h:110
void resetSimHitDataAccumulator()
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
Definition: HGCDigitizer.h:113
const std::string digiCollection_
Definition: HGCDigitizer.h:84
void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
actions at the start/end of event
~HGCDigitizer()=default
const double premixStage1MaxCharge_
Definition: HGCDigitizer.h:95
const HGCalGeometry * gHGCal_
Definition: HGCDigitizer.h:116
uint32_t getType() const
const double premixStage1MinCharge_
Definition: HGCDigitizer.h:93
static const unsigned int maxBx_
Definition: HGCDigitizer.h:129
edm::ESWatcher< CaloGeometryRecord > geomWatcher_
Definition: HGCDigitizer.h:114
const uint32_t verbosity_
Definition: HGCDigitizer.h:119
std::unordered_map< uint32_t, std::vector< std::tuple< float, float, float > > > PhitRefs_bx0
Definition: HGCDigitizer.h:133
std::unordered_map< uint32_t, bool > hitOrder_monitor
Definition: HGCDigitizer.h:134
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:115
const int maxSimHitsAccTime_
Definition: HGCDigitizer.h:98
static const unsigned int thisBx_
Definition: HGCDigitizer.h:130
const bool premixStage1_
Definition: HGCDigitizer.h:90
double b
Definition: hdecay.h:118
double ev_per_eh_pair_
Definition: HGCDigitizer.h:100
std::tuple< int, uint32_t, float > HGCCaloHitTuple_t
Definition: HGCDigitizer.h:35
const edm::EDGetTokenT< std::vector< PCaloHit > > hitToken_
Definition: HGCDigitizer.h:103
std::array< double, 4 > averageOccupancies_
Definition: HGCDigitizer.h:125
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre)
handle SimHit accumulation
const float tofDelay_
Definition: HGCDigitizer.h:122
double a
Definition: hdecay.h:119
std::unordered_map< uint32_t, std::vector< std::pair< float, float > > > hitRefs_bx0
Definition: HGCDigitizer.h:132
const double bxTime_
Definition: HGCDigitizer.h:99
HGCDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:81
static bool orderByDetIdThenTime(const HGCCaloHitTuple_t &a, const HGCCaloHitTuple_t &b)
Definition: HGCDigitizer.h:36
void accumulate_forPreMix(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre)
std::unique_ptr< hgc::HGCPUSimHitDataAccumulator > pusimHitAccumulator_
Definition: HGCDigitizer.h:82
std::string digiCollection()
Definition: HGCDigitizer.h:76
void resetPUSimHitDataAccumulator()
const int digitizationType_
Definition: HGCDigitizer.h:87
const std::string hitCollection_
Definition: HGCDigitizer.h:102