22 #include <boost/foreach.hpp> 28 constexpr std::array<double,3> occupancyGuesses = { { 0.5,0.2,0.2 } };
38 void getValidDetIds(
const HGCalGeometry* geom, std::unordered_set<DetId>& valid) {
40 valid.reserve(ids.size());
41 valid.insert(ids.begin(),ids.end());
44 void getValidDetIds(
const HcalGeometry* geom, std::unordered_set<DetId>& valid) {
46 for(
const auto&
id : ids ) {
51 valid.reserve(valid.size());
72 int subdet, layer, cell, sec, subsec, zp;
82 std::pair<int,int> recoLayerCell=dddConst.simToReco(cell,layer,sec,topo.detectorType());
83 cell = recoLayerCell.first;
84 layer = recoLayerCell.second;
85 if (layer<0 || cell<0) {
101 refSpeed_(0.1*
CLHEP::c_light),
102 averageOccupancies_(occupancyGuesses),
161 static_cast<const CaloSubdetectorGeometry*>(
gHGCal_) );
190 edm::LogInfo(
"HGCDigitizer") <<
" @ finalize event - produced " << digiResult->size() <<
" EE hits";
197 edm::LogInfo(
"HGCDigitizer") <<
" @ finalize event - produced " << digiResult->size() <<
" HE front hits";
204 edm::LogInfo(
"HGCDigitizer") <<
" @ finalize event - produced " << digiResult->size() <<
" HE back hits";
225 }
else if(
nullptr !=
gHcal_ ) {
229 <<
"HGCDigitizer is not producing EE, FH, or BH digis!";
247 }
else if (
nullptr !=
gHcal_ ) {
251 <<
"HGCDigitizer is not producing EE, FH, or BH digis!";
256 template<
typename GEOM>
260 CLHEP::HepRandomEngine* hre) {
261 if(
nullptr == geom )
return;
266 bool weightToAbyEnergy(
false);
289 int nchits=(
int)hits->size();
290 std::vector< HGCCaloHitTuple_t > hitRefs;
291 hitRefs.reserve(nchits);
292 for(
int i=0;
i<nchits; ++
i) {
293 const auto& the_hit = hits->at(
i);
295 DetId id = simToReco(geom,the_hit.id());
299 edm::LogInfo(
"HGCDigitizer") <<
" i/p " << std::hex << the_hit.id() <<
std::dec <<
" o/p " <<
id.rawId() << std::endl;
301 edm::LogInfo(
"HGCDigitizer") <<
" i/p " << std::hex << the_hit.id() <<
std::dec <<
" o/p " <<
id.rawId() << std::endl;
304 if( 0 !=
id.rawId() ) {
305 hitRefs.emplace_back(
i,
id.rawId(), (
float)the_hit.time() );
311 nchits = hitRefs.size();
312 for(
int i=0;
i<nchits; ++
i) {
313 const int hitidx = std::get<0>(hitRefs[
i]);
314 const uint32_t
id = std::get<1>(hitRefs[
i]);
323 const float toa = std::get<2>(hitRefs[
i]);
328 const float dist2center( getPositionDistance(geom,
id) );
333 const int itime= std::floor( tof/
bxTime_ ) + 9;
339 if(itime<0 || itime>14)
continue;
342 if(itime >= (
int)simHitIt->second.hit_info[0].size() )
continue;
344 (simHitIt->second).hit_info[0][itime] += charge;
345 float accCharge=(simHitIt->second).hit_info[0][itime];
348 if(weightToAbyEnergy) (simHitIt->second).hit_info[1][itime] += charge*tof;
349 else if((simHitIt->second).hit_info[1][itime]==0) {
356 uint32_t prev_id = std::get<1>(hitRefs[
i-1]);
359 float prev_toa = std::get<2>(hitRefs[
i-1]);
360 float prev_tof(prev_toa-dist2center/
refSpeed_+tofDelay_);
362 float deltaQ2TDCOnset =
tdcOnset-((simHitIt->second).hit_info[0][itime]-charge);
364 float deltaT = (tof-prev_tof);
365 fireTDC = deltaT*(deltaQ2TDCOnset/deltaQ)+prev_tof;
369 (simHitIt->second).hit_info[1][itime]=fireTDC;
394 }
else if(
nullptr !=
gHcal_ ) {
398 <<
"HGCDigitizer is not producing EE, FH, or BH digis!";
403 <<
"Added " << nadded <<
":" <<
validIds_.size()
405 <<
" in first event processed" << std::endl;
419 it->second.hit_info[0].fill(0.);
420 it->second.hit_info[1].fill(0.);
int bunchCrossing() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
T getUntrackedParameter(std::string const &, T const &) const
const HcalDDDRecConstants * dddConstants() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::SortedCollection< HGCEEDataFrame > HGCEEDigiCollection
void finalizeEvent(edm::Event &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre)
ForwardSubdetector mySubDet_
std::string hitCollection_
void resetSimHitDataAccumulator()
void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
actions at the start/end of event
GlobalPoint getPosition(const DetId &id) const
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
const HGCalGeometry * gHGCal_
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
void swap(Association< C > &lhs, Association< C > &rhs)
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const override
Get a list of valid detector ids (for the given subdetector)
std::string digiCollection_
const HcalTopology & topology() const
std::unordered_map< uint32_t, HGCCellInfo > HGCSimHitDataAccumulator
edm::SortedCollection< HGCBHDataFrame > HGCBHDigiCollection
void beginRun(const edm::EventSetup &es)
actions at the start/end of run
const HGCalTopology & topology() const
std::unordered_set< DetId > validIds_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool producesHEfrontDigis()
std::unique_ptr< HGCHEbackDigitizer > theHGCHEbackDigitizer_
bool producesHEbackDigis()
const HGCalDDDConstants & dddConstants() const
static void unpackSquareIndex(const uint32_t &idx, int &z, int &lay, int &sec, int &subsec, int &cell)
std::unique_ptr< HGCHEfrontDigitizer > theHGCHEfrontDigitizer_
std::unique_ptr< HGCEEDigitizer > theHGCEEDigitizer_
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre)
handle SimHit accumulation
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
HGCDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
std::array< double, 3 > averageOccupancies_
DetId relabel(const uint32_t testId) const
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
static bool orderByDetIdThenTime(const HGCCaloHitTuple_t &a, const HGCCaloHitTuple_t &b)
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
std::string digiCollection()
edm::SortedCollection< HGCHEDataFrame > HGCHEDigiCollection
const HcalGeometry * gHcal_
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)