22 #include <boost/foreach.hpp> 29 constexpr std::array<double,3> occupancyGuesses = { { 0.5,0.2,0.2 } };
39 void getValidDetIds(
const HGCalGeometry* geom, std::unordered_set<DetId>& valid) {
41 valid.reserve(ids.size());
42 valid.insert(ids.begin(),ids.end());
45 void getValidDetIds(
const HcalGeometry* geom, std::unordered_set<DetId>& valid) {
47 for(
const auto&
id : ids ) {
52 valid.reserve(valid.size());
73 int subdet(
DetId(simId).subdetId()), layer, cell, sec, subsec, zp;
83 std::pair<int,int> recoLayerCell=dddConst.simToReco(cell,layer,sec,topo.detectorType());
84 cell = recoLayerCell.first;
85 layer = recoLayerCell.second;
86 if (layer<0 || cell<0) {
98 const std::vector<float>&cces) {
99 if( cces.empty() )
return 1.
f;
100 const auto& topo = geom->
topology();
105 int waferTypeL = dddConst.waferTypeL(wafer);
106 return cces[waferTypeL-1];
111 const std::vector<float>&cces) {
122 refSpeed_(0.1*
CLHEP::c_light),
123 averageOccupancies_(occupancyGuesses),
140 if( myCfg_.existsAs<std::vector<double> >(
"chargeCollectionEfficiencies" ) ) {
142 const auto&
temp = myCfg_.getParameter<std::vector<double> >(
"chargeCollectionEfficiencies");
143 for(
double cce :
temp ) {
193 static_cast<const CaloSubdetectorGeometry*>(
gHGCal_) );
222 edm::LogInfo(
"HGCDigitizer") <<
" @ finalize event - produced " << digiResult->size() <<
" EE hits";
229 edm::LogInfo(
"HGCDigitizer") <<
" @ finalize event - produced " << digiResult->size() <<
" HE front hits";
236 edm::LogInfo(
"HGCDigitizer") <<
" @ finalize event - produced " << digiResult->size() <<
" HE back hits";
257 }
else if(
nullptr !=
gHcal_ ) {
261 <<
"HGCDigitizer is not producing EE, FH, or BH digis!";
279 }
else if (
nullptr !=
gHcal_ ) {
283 <<
"HGCDigitizer is not producing EE, FH, or BH digis!";
288 template<
typename GEOM>
292 CLHEP::HepRandomEngine* hre) {
293 if(
nullptr == geom )
return;
298 bool weightToAbyEnergy(
false);
321 int nchits=(
int)hits->size();
322 std::vector< HGCCaloHitTuple_t > hitRefs;
323 hitRefs.reserve(nchits);
324 for(
int i=0;
i<nchits; ++
i) {
325 const auto& the_hit = hits->at(
i);
327 DetId id = simToReco(geom,the_hit.id());
331 edm::LogInfo(
"HGCDigitizer") <<
" i/p " << std::hex << the_hit.id() <<
" o/p " <<
id.rawId() <<
std::dec << std::endl;
333 edm::LogInfo(
"HGCDigitizer") <<
" i/p " << std::hex << the_hit.id() <<
" o/p " <<
id.rawId() <<
std::dec << std::endl;
336 if( 0 !=
id.rawId() ) {
337 hitRefs.emplace_back(
i,
id.rawId(), (
float)the_hit.time() );
343 nchits = hitRefs.size();
344 for(
int i=0;
i<nchits; ++
i) {
345 const int hitidx = std::get<0>(hitRefs[
i]);
346 const uint32_t
id = std::get<1>(hitRefs[
i]);
355 const float toa = std::get<2>(hitRefs[
i]);
357 const float charge = hit.energy()*1e6*keV2fC*getCCE(geom,
id,
cce_);
360 const float dist2center( getPositionDistance(geom,
id) );
365 const int itime= std::floor( tof/
bxTime_ ) + 9;
371 if(itime<0 || itime>14)
continue;
374 if(itime >= (
int)simHitIt->second.hit_info[0].size() )
continue;
376 (simHitIt->second).hit_info[0][itime] += charge;
377 float accCharge=(simHitIt->second).hit_info[0][itime];
380 if(weightToAbyEnergy) (simHitIt->second).hit_info[1][itime] += charge*tof;
381 else if((simHitIt->second).hit_info[1][itime]==0) {
388 uint32_t prev_id = std::get<1>(hitRefs[
i-1]);
391 float prev_toa = std::get<2>(hitRefs[
i-1]);
392 float prev_tof(prev_toa-dist2center/
refSpeed_+tofDelay_);
394 float deltaQ2TDCOnset =
tdcOnset-((simHitIt->second).hit_info[0][itime]-charge);
396 float deltaT = (tof-prev_tof);
397 fireTDC = deltaT*(deltaQ2TDCOnset/deltaQ)+prev_tof;
401 (simHitIt->second).hit_info[1][itime]=fireTDC;
426 }
else if(
nullptr !=
gHcal_ ) {
430 <<
"HGCDigitizer is not producing EE, FH, or BH digis!";
435 <<
"Added " << nadded <<
":" <<
validIds_.size()
437 <<
" in first event processed" << std::endl;
451 it->second.hit_info[0].fill(0.);
452 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.
std::vector< float > cce_
edm::SortedCollection< HGCEEDataFrame > HGCEEDigiCollection
void finalizeEvent(edm::Event &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre)
ForwardSubdetector mySubDet_
std::string hitCollection_
void resetSimHitDataAccumulator()
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
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)
void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
actions at the start/end of event
GlobalPoint getPosition(const DetId &id) const
const HGCalGeometry * gHGCal_
void swap(Association< C > &lhs, Association< C > &rhs)
std::string digiCollection_
const HcalTopology & topology() const
uint32_t rawId() const
get the raw id
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_
int wafer() const
get the wafer #
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool producesHEfrontDigis()
std::unique_ptr< HGCHEbackDigitizer > theHGCHEbackDigitizer_
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)
bool producesHEbackDigis()
const HGCalDDDConstants & dddConstants() const
const CaloCellGeometry * getGeometry(const DetId &id) const override
Get the cell geometry of a given detector id. Should return false if not found.
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)
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)