19 #include <boost/foreach.hpp>
21 using namespace hgc_digi;
26 checkValidDetIds_(
true),
29 refSpeed_(0.1*CLHEP::c_light)
72 edm::LogInfo(
"HGCDigitizer") <<
" @ finalize event - produced " << digiResult->size() <<
" EE hits";
79 edm::LogInfo(
"HGCDigitizer") <<
" @ finalize event - produced " << digiResult->size() <<
" HE front hits";
86 edm::LogInfo(
"HGCDigitizer") <<
" @ finalize event - produced " << digiResult->size() <<
" HE back hits";
137 CLHEP::HepRandomEngine* hre)
144 std::array<HGCSimHitData,2> baseData;
145 baseData[0].fill(0.);
146 baseData[1].fill(0.);
149 bool weightToAbyEnergy(
false);
150 float tdcOnset(0),keV2fC(0.0);
172 int nchits=(int)hits->size();
173 std::vector< HGCCaloHitTuple_t > hitRefs(nchits);
174 for(
int i=0;
i<nchits;
i++) {
175 int layer, cell, sec, subsec, zp;
176 uint32_t simId = hits->at(
i).
id();
187 cell = recoLayerCell.first;
188 layer = recoLayerCell.second;
189 if (layer<0 || cell<0) {
190 hitRefs[
i]=std::make_tuple(
i, 0, 0.);
211 hitRefs[
i]=std::make_tuple(
i,
213 (
float)hits->at(
i).time() );
218 for(
int i=0;
i<nchits; ++
i) {
219 const int hitidx = std::get<0>(hitRefs[
i]);
220 const uint32_t
id = std::get<1>(hitRefs[
i]);
223 const float toa = std::get<2>(hitRefs[
i]);
225 const float charge = hit.energy()*1e6*keV2fC;
228 const float dist2center( geom->getPosition(
id).mag() );
233 const int itime= std::floor( tof/
bxTime_ ) + 9;
239 if(itime<0 || itime>14)
continue;
248 if(itime >= (
int)simHitIt->second[0].size() )
continue;
250 (simHitIt->second)[0][itime] += charge;
251 float accCharge=(simHitIt->second)[0][itime];
254 if(weightToAbyEnergy) (simHitIt->second)[1][itime] += charge*tof;
255 else if((simHitIt->second)[1][itime]==0)
257 if( accCharge>tdcOnset)
263 uint32_t prev_id = std::get<1>(hitRefs[
i-1]);
266 float prev_toa = std::get<2>(hitRefs[
i-1]);
267 float prev_tof(prev_toa-dist2center/
refSpeed_+tofDelay_);
269 float deltaQ2TDCOnset = tdcOnset-((simHitIt->second)[0][itime]-charge);
271 float deltaT = (tof-prev_tof);
272 fireTDC = deltaT*(deltaQ2TDCOnset/deltaQ)+prev_tof;
276 (simHitIt->second)[1][itime]=fireTDC;
285 const std::vector<DetId> &validIds=geom->getValidDetIds();
288 for(std::vector<DetId>::const_iterator it=validIds.begin(); it!=validIds.end(); it++) {
289 uint32_t id(it->rawId());
297 <<
"Added " << nadded <<
":" << validIds.size()
299 <<
" in first event processed" << std::endl;
318 it->second[0].fill(0.);
319 it->second[1].fill(0.);
int bunchCrossing() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
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
bool detectorType() const
std::string digiCollection_
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
void beginRun(const edm::EventSetup &es)
actions at the start/end of run
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
HGCalGeometryMode geomMode() const
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::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
static bool orderByDetIdThenTime(const HGCCaloHitTuple_t &a, const HGCCaloHitTuple_t &b)
std::unordered_map< uint32_t, std::array< HGCSimHitData, 2 > > HGCSimHitDataAccumulator
std::string digiCollection()
edm::SortedCollection< HGCHEDataFrame > HGCHEDigiCollection
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)