CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HGCDigitizer Class Reference

#include <HGCDigitizer.h>

Public Types

typedef std::tuple< int, uint32_t, float > HGCCaloHitTuple_t
 

Public Member Functions

void accumulate (edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre)
 handle SimHit accumulation More...
 
void accumulate (PileUpEventPrincipal const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre)
 
template<typename GEOM >
void accumulate (edm::Handle< edm::PCaloHitContainer > const &hits, int bxCrossing, const GEOM *geom, CLHEP::HepRandomEngine *hre)
 
void beginRun (const edm::EventSetup &es)
 actions at the start/end of run More...
 
std::string digiCollection ()
 
void endRun ()
 
void finalizeEvent (edm::Event &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre)
 
 HGCDigitizer (const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
 
void initializeEvent (edm::Event const &e, edm::EventSetup const &c)
 actions at the start/end of event More...
 
bool producesEEDigis ()
 
bool producesHEbackDigis ()
 
bool producesHEfrontDigis ()
 
 ~HGCDigitizer ()
 

Static Public Member Functions

static bool orderByDetIdThenTime (const HGCCaloHitTuple_t &a, const HGCCaloHitTuple_t &b)
 

Private Member Functions

void resetSimHitDataAccumulator ()
 

Private Attributes

std::array< double, 3 > averageOccupancies_
 
double bxTime_
 
std::vector< float > cce_
 
std::string digiCollection_
 
int digitizationType_
 
double ev_per_eh_pair_
 
const HcalGeometrygHcal_
 
const HGCalGeometrygHGCal_
 
std::string hitCollection_
 
std::map< uint32_t, std::vector< std::pair< float, float > > > hitRefs_bx0
 
int maxSimHitsAccTime_
 
ForwardSubdetector mySubDet_
 
uint32_t nEvents_
 
float refSpeed_
 
std::unique_ptr< hgc::HGCSimHitDataAccumulatorsimHitAccumulator_
 
std::unique_ptr< HGCEEDigitizertheHGCEEDigitizer_
 
std::unique_ptr< HGCHEbackDigitizertheHGCHEbackDigitizer_
 
std::unique_ptr< HGCHEfrontDigitizertheHGCHEfrontDigitizer_
 
float tofDelay_
 
std::unordered_set< DetIdvalidIds_
 
uint32_t verbosity_
 

Detailed Description

Definition at line 28 of file HGCDigitizer.h.

Member Typedef Documentation

typedef std::tuple<int,uint32_t,float> HGCDigitizer::HGCCaloHitTuple_t

Definition at line 36 of file HGCDigitizer.h.

Constructor & Destructor Documentation

HGCDigitizer::HGCDigitizer ( const edm::ParameterSet ps,
edm::ConsumesCollector iC 
)

Definition at line 131 of file HGCDigitizer.cc.

References bxTime_, cce_, edm::ConsumesCollector::consumes(), digiCollection_, digitizationType_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), HGCEE, HGCHEB, HGCHEF, hitCollection_, maxSimHitsAccTime_, mySubDet_, AlCaHLTBitMon_QueryRunRegistry::string, edm::swap(), groupFilesInBlocks::temp, theHGCEEDigitizer_, theHGCHEbackDigitizer_, theHGCHEfrontDigitizer_, tofDelay_, validIds_, and verbosity_.

132  :
135  refSpeed_(0.1*CLHEP::c_light), //[CLHEP::c_light]=mm/ns convert to cm/ns
136  averageOccupancies_(occupancyGuesses),
137  nEvents_(1)
138 {
139  //configure from cfg
140  hitCollection_ = ps.getParameter< std::string >("hitCollection");
141  digiCollection_ = ps.getParameter< std::string >("digiCollection");
142  maxSimHitsAccTime_ = ps.getParameter< uint32_t >("maxSimHitsAccTime");
143  bxTime_ = ps.getParameter< double >("bxTime");
144  digitizationType_ = ps.getParameter< uint32_t >("digitizationType");
145  verbosity_ = ps.getUntrackedParameter< uint32_t >("verbosity",0);
146  tofDelay_ = ps.getParameter< double >("tofDelay");
147 
148  std::unordered_set<DetId>().swap(validIds_);
149 
150  iC.consumes<std::vector<PCaloHit> >(edm::InputTag("g4SimHits",hitCollection_));
151  const auto& myCfg_ = ps.getParameter<edm::ParameterSet>("digiCfg");
152 
153  if( myCfg_.existsAs<std::vector<double> >( "chargeCollectionEfficiencies" ) ) {
154  cce_.clear();
155  const auto& temp = myCfg_.getParameter<std::vector<double> >("chargeCollectionEfficiencies");
156  for( double cce : temp ) {
157  cce_.push_back(cce);
158  }
159  } else {
160  std::vector<float>().swap(cce_);
161  }
162 
163  if(hitCollection_.find("HitsEE")!=std::string::npos) {
165  theHGCEEDigitizer_=std::unique_ptr<HGCEEDigitizer>(new HGCEEDigitizer(ps) );
166  }
167  if(hitCollection_.find("HitsHEfront")!=std::string::npos)
168  {
170  theHGCHEfrontDigitizer_=std::unique_ptr<HGCHEfrontDigitizer>(new HGCHEfrontDigitizer(ps) );
171  }
172  if(hitCollection_.find("HcalHits")!=std::string::npos)
173  {
175  theHGCHEbackDigitizer_=std::unique_ptr<HGCHEbackDigitizer>(new HGCHEbackDigitizer(ps) );
176  }
177 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
uint32_t nEvents_
Definition: HGCDigitizer.h:116
T getUntrackedParameter(std::string const &, T const &) const
std::vector< float > cce_
Definition: HGCDigitizer.h:118
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:103
int digitizationType_
Definition: HGCDigitizer.h:84
std::string hitCollection_
Definition: HGCDigitizer.h:81
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
std::string digiCollection_
Definition: HGCDigitizer.h:81
std::unordered_map< uint32_t, HGCCellInfo > HGCSimHitDataAccumulator
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:98
std::unique_ptr< HGCHEbackDigitizer > theHGCHEbackDigitizer_
Definition: HGCDigitizer.h:94
int maxSimHitsAccTime_
Definition: HGCDigitizer.h:87
std::unique_ptr< HGCHEfrontDigitizer > theHGCHEfrontDigitizer_
Definition: HGCDigitizer.h:95
std::unique_ptr< HGCEEDigitizer > theHGCEEDigitizer_
Definition: HGCDigitizer.h:93
std::array< double, 3 > averageOccupancies_
Definition: HGCDigitizer.h:115
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:89
double bxTime_
Definition: HGCDigitizer.h:88
uint32_t verbosity_
Definition: HGCDigitizer.h:106
HGCDigitizer::~HGCDigitizer ( )
inline

Definition at line 33 of file HGCDigitizer.h.

33 { }

Member Function Documentation

void HGCDigitizer::accumulate ( edm::Event const &  e,
edm::EventSetup const &  c,
CLHEP::HepRandomEngine *  hre 
)

handle SimHit accumulation

Definition at line 258 of file HGCDigitizer.cc.

References Exception, edm::Event::getByLabel(), gHcal_, gHGCal_, hitCollection_, hfClusterShapes_cfi::hits, and edm::HandleBase::isValid().

Referenced by accumulate(), and orderByDetIdThenTime().

258  {
259 
260  //get inputs
262  e.getByLabel(edm::InputTag("g4SimHits",hitCollection_),hits);
263  if( !hits.isValid() ){
264  edm::LogError("HGCDigitizer") << " @ accumulate : can't find " << hitCollection_ << " collection of g4SimHits";
265  return;
266  }
267 
268  //accumulate in-time the main event
269  if( nullptr != gHGCal_ ) {
270  accumulate(hits, 0, gHGCal_, hre);
271  } else if( nullptr != gHcal_ ) {
272  accumulate(hits, 0, gHcal_, hre);
273  } else {
274  throw cms::Exception("BadConfiguration")
275  << "HGCDigitizer is not producing EE, FH, or BH digis!";
276  }
277 }
std::string hitCollection_
Definition: HGCDigitizer.h:81
const HGCalGeometry * gHGCal_
Definition: HGCDigitizer.h:99
bool isValid() const
Definition: HandleBase.h:74
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre)
handle SimHit accumulation
const HcalGeometry * gHcal_
Definition: HGCDigitizer.h:100
void HGCDigitizer::accumulate ( PileUpEventPrincipal const &  e,
edm::EventSetup const &  c,
CLHEP::HepRandomEngine *  hre 
)

Definition at line 280 of file HGCDigitizer.cc.

References accumulate(), PileUpEventPrincipal::bunchCrossing(), Exception, PileUpEventPrincipal::getByLabel(), gHcal_, gHGCal_, hitCollection_, hfClusterShapes_cfi::hits, and edm::HandleBase::isValid().

280  {
281 
282  //get inputs
284  e.getByLabel(edm::InputTag("g4SimHits",hitCollection_),hits);
285  if( !hits.isValid() ){
286  edm::LogError("HGCDigitizer") << " @ accumulate : can't find " << hitCollection_ << " collection of g4SimHits";
287  return;
288  }
289 
290  //accumulate for the simulated bunch crossing
291  if( nullptr != gHGCal_ ) {
292  accumulate(hits, e.bunchCrossing(), gHGCal_, hre);
293  } else if ( nullptr != gHcal_ ) {
294  accumulate(hits, e.bunchCrossing(), gHcal_, hre);
295  } else {
296  throw cms::Exception("BadConfiguration")
297  << "HGCDigitizer is not producing EE, FH, or BH digis!";
298  }
299 }
std::string hitCollection_
Definition: HGCDigitizer.h:81
const HGCalGeometry * gHGCal_
Definition: HGCDigitizer.h:99
bool isValid() const
Definition: HandleBase.h:74
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre)
handle SimHit accumulation
const HcalGeometry * gHcal_
Definition: HGCDigitizer.h:100
template<typename GEOM >
void HGCDigitizer::accumulate ( edm::Handle< edm::PCaloHitContainer > const &  hits,
int  bxCrossing,
const GEOM *  geom,
CLHEP::HepRandomEngine *  hre 
)

Definition at line 303 of file HGCDigitizer.cc.

References begin, bxTime_, cce_, ALCARECOTkAlJpsiMuMu_cff::charge, TauDecayModes::dec, relativeConstraints::empty, end, f, plotBeamSpotDB::first, HGCEE, HGCHEB, HGCHEF, hitRefs_bx0, mps_fire::i, triggerObjects_cff::id, createfilelist::int, hgcalDigitizer_cfi::keV2fC, mySubDet_, orderByDetIdThenTime(), producesEEDigis(), refSpeed_, edm::second(), simHitAccumulator_, findQualityFiles::size, theHGCEEDigitizer_, theHGCHEbackDigitizer_, theHGCHEfrontDigitizer_, tofDelay_, validIds_, and verbosity_.

306  {
307  if( nullptr == geom ) return;
308 
309 
310 
311  //configuration to apply for the computation of time-of-flight
312  bool weightToAbyEnergy(false);
313  std::array<float, 3> tdcForToAOnset{ {0.f, 0.f, 0.f} };
314  float keV2fC(0.f);
315  switch( mySubDet_ ) {
317  weightToAbyEnergy = theHGCEEDigitizer_->toaModeByEnergy();
318  tdcForToAOnset = theHGCEEDigitizer_->tdcForToAOnset();
319  keV2fC = theHGCEEDigitizer_->keV2fC();
320  break;
322  weightToAbyEnergy = theHGCHEfrontDigitizer_->toaModeByEnergy();
323  tdcForToAOnset = theHGCHEfrontDigitizer_->tdcForToAOnset();
324  keV2fC = theHGCHEfrontDigitizer_->keV2fC();
325  break;
327  weightToAbyEnergy = theHGCHEbackDigitizer_->toaModeByEnergy();
328  tdcForToAOnset = theHGCHEbackDigitizer_->tdcForToAOnset();
329  keV2fC = theHGCHEbackDigitizer_->keV2fC();
330  break;
331  default:
332  break;
333  }
334 
335  //create list of tuples (pos in container, RECO DetId, time) to be sorted first
336  int nchits=(int)hits->size();
337  std::vector< HGCCaloHitTuple_t > hitRefs;
338  hitRefs.reserve(nchits);
339  for(int i=0; i<nchits; ++i) {
340  const auto& the_hit = hits->at(i);
341 
342  DetId id = simToReco(geom,the_hit.id());
343 
344  if (verbosity_>0) {
345  if (producesEEDigis())
346  edm::LogInfo("HGCDigitizer") << " i/p " << std::hex << the_hit.id() << " o/p " << id.rawId() << std::dec << std::endl;
347  else
348  edm::LogInfo("HGCDigitizer") << " i/p " << std::hex << the_hit.id() << " o/p " << id.rawId() << std::dec << std::endl;
349  }
350 
351  if( 0 != id.rawId() ) {
352  hitRefs.emplace_back( i, id.rawId(), (float)the_hit.time() );
353  }
354  }
355  std::sort(hitRefs.begin(),hitRefs.end(),this->orderByDetIdThenTime);
356 
357  //loop over sorted hits
358  nchits = hitRefs.size();
359  for(int i=0; i<nchits; ++i) {
360  const int hitidx = std::get<0>(hitRefs[i]);
361  const uint32_t id = std::get<1>(hitRefs[i]);
362 
363  //get the data for this cell, if not available then we skip it
364 
365  if( !validIds_.count(id) ) continue;
366  HGCSimHitDataAccumulator::iterator simHitIt = simHitAccumulator_->emplace(id,HGCCellInfo()).first;
367 
368  if(id==0) continue; // to be ignored at RECO level
369 
370  const float toa = std::get<2>(hitRefs[i]);
371  const PCaloHit &hit=hits->at( hitidx );
372  const float charge = hit.energy()*1e6*keV2fC*getCCE(geom,id,cce_);
373 
374  //distance to the center of the detector
375  const float dist2center( getPositionDistance(geom,id) );
376 
377  //hit time: [time()]=ns [centerDist]=cm [refSpeed_]=cm/ns + delay by 1ns
378  //accumulate in 15 buckets of 25ns (9 pre-samples, 1 in-time, 5 post-samples)
379  const float tof = toa-dist2center/refSpeed_+tofDelay_ ;
380  const int itime= std::floor( tof/bxTime_ ) + 9;
381 
382  //no need to add bx crossing - tof comes already corrected from the mixing module
383  //itime += bxCrossing;
384  //itime += 9;
385 
386  if(itime<0 || itime>14) continue;
387 
388  //check if time index is ok and store energy
389  if(itime >= (int)simHitIt->second.hit_info[0].size() ) continue;
390 
391  (simHitIt->second).hit_info[0][itime] += charge;
392 
393 
394  //working version with pileup only for in-time hits
395  int waferThickness = getCellThickness(geom,id);
396  bool orderChanged = false;
397  if(itime == 9){
398  if(hitRefs_bx0[id].empty()){
399  hitRefs_bx0[id].push_back(std::pair<float, float>(charge, tof));
400  }
401  else if(tof <= hitRefs_bx0[id].back().second){
402  std::vector<std::pair<float, float> >::iterator findPos =
403  std::upper_bound(hitRefs_bx0[id].begin(), hitRefs_bx0[id].end(), std::pair<float, float>(0.f,tof),
404  [](const auto& i, const auto& j){return i.second < j.second;});
405 
406  std::vector<std::pair<float, float> >::iterator insertedPos =
407  hitRefs_bx0[id].insert(findPos, (findPos == hitRefs_bx0[id].begin()) ?
408  std::pair<float, float>(charge,tof) : std::pair<float, float>((findPos-1)->first+charge,tof));
409 
410  for(std::vector<std::pair<float, float> >::iterator step = insertedPos+1; step != hitRefs_bx0[id].end(); ++step){
411  step->first += charge;
412  if(step->first > tdcForToAOnset[waferThickness-1] && step->second != hitRefs_bx0[id].back().second){
413  hitRefs_bx0[id].resize(std::upper_bound(hitRefs_bx0[id].begin(), hitRefs_bx0[id].end(), std::pair<float, float>(0.f,step->second),
414  [](const auto& i, const auto& j){return i.second < j.second;}) - hitRefs_bx0[id].begin());
415  for(auto stepEnd = step+1; stepEnd != hitRefs_bx0[id].end(); ++stepEnd) stepEnd->first += charge;
416  break;
417  }
418  }
419  orderChanged = true;
420  }
421  else{
422  if(hitRefs_bx0[id].back().first <= tdcForToAOnset[waferThickness-1]){
423  hitRefs_bx0[id].push_back(std::pair<float, float>(hitRefs_bx0[id].back().first+charge, tof));
424  }
425  }
426  }
427 
428  float accChargeForToA = hitRefs_bx0[id].empty() ? 0.f : hitRefs_bx0[id].back().first;
429 
430  //time-of-arrival (check how to be used)
431  if(weightToAbyEnergy) (simHitIt->second).hit_info[1][itime] += charge*tof;
432  else if(accChargeForToA > tdcForToAOnset[waferThickness-1] &&
433  ((simHitIt->second).hit_info[1][itime] == 0 || orderChanged == true) ){
434  float fireTDC = hitRefs_bx0[id].back().second;
435  if (hitRefs_bx0[id].size() > 1){
436  float chargeBeforeThr = 0.f;
437  float tofchargeBeforeThr = 0.f;
438  for(const auto& step : hitRefs_bx0[id]){
439  if(step.first + chargeBeforeThr <= tdcForToAOnset[waferThickness-1]){
440  chargeBeforeThr += step.first;
441  tofchargeBeforeThr = step.second;
442  }
443  else break;
444  }
445  float deltaQ = accChargeForToA - chargeBeforeThr;
446  float deltaTOF = fireTDC - tofchargeBeforeThr;
447  fireTDC = (tdcForToAOnset[waferThickness-1] - chargeBeforeThr) * deltaTOF / deltaQ + tofchargeBeforeThr;
448  }
449  (simHitIt->second).hit_info[1][itime] = fireTDC;
450  }
451 
452  }
453  hitRefs.clear();
454 }
size
Write out results.
std::vector< float > cce_
Definition: HGCDigitizer.h:118
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:103
bool producesEEDigis()
Definition: HGCDigitizer.h:67
U second(std::pair< T, U > const &p)
double f[11][100]
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:98
#define end
Definition: vmac.h:39
std::unique_ptr< HGCHEbackDigitizer > theHGCHEbackDigitizer_
Definition: HGCDigitizer.h:94
Definition: DetId.h:18
std::unique_ptr< HGCHEfrontDigitizer > theHGCHEfrontDigitizer_
Definition: HGCDigitizer.h:95
std::unique_ptr< HGCEEDigitizer > theHGCEEDigitizer_
Definition: HGCDigitizer.h:93
#define begin
Definition: vmac.h:32
std::map< uint32_t, std::vector< std::pair< float, float > > > hitRefs_bx0
Definition: HGCDigitizer.h:120
step
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:89
static bool orderByDetIdThenTime(const HGCCaloHitTuple_t &a, const HGCCaloHitTuple_t &b)
Definition: HGCDigitizer.h:37
double bxTime_
Definition: HGCDigitizer.h:88
uint32_t verbosity_
Definition: HGCDigitizer.h:106
void HGCDigitizer::beginRun ( const edm::EventSetup es)

actions at the start/end of run

Definition at line 457 of file HGCDigitizer.cc.

References Exception, DetId::Forward, relativeConstraints::geom, edm::EventSetup::get(), CaloGeometry::getSubdetectorGeometry(), gHcal_, gHGCal_, DetId::Hcal, HcalEndcap, HGCEE, HGCHEF, hitCollection_, producesEEDigis(), producesHEbackDigis(), producesHEfrontDigis(), validIds_, and verbosity_.

Referenced by digiCollection().

458 {
459  //get geometry
461  es.get<CaloGeometryRecord>().get(geom);
462 
463  gHGCal_ = nullptr;
464  gHcal_ = nullptr;
465 
466  if( producesEEDigis() ) gHGCal_ = dynamic_cast<const HGCalGeometry*>(geom->getSubdetectorGeometry(DetId::Forward, HGCEE));
467  if( producesHEfrontDigis() ) gHGCal_ = dynamic_cast<const HGCalGeometry*>(geom->getSubdetectorGeometry(DetId::Forward, HGCHEF));
468  if( producesHEbackDigis() ) gHcal_ = dynamic_cast<const HcalGeometry*>(geom->getSubdetectorGeometry(DetId::Hcal, HcalEndcap));
469 
470  int nadded(0);
471  //valid ID lists
472  if( nullptr != gHGCal_ ) {
473  getValidDetIds( gHGCal_, validIds_ );
474  } else if( nullptr != gHcal_ ) {
475  getValidDetIds( gHcal_, validIds_ );
476  } else {
477  throw cms::Exception("BadConfiguration")
478  << "HGCDigitizer is not producing EE, FH, or BH digis!";
479  }
480 
481  if (verbosity_ > 0)
482  edm::LogInfo("HGCDigitizer")
483  << "Added " << nadded << ":" << validIds_.size()
484  << " detIds without " << hitCollection_
485  << " in first event processed" << std::endl;
486 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:44
std::string hitCollection_
Definition: HGCDigitizer.h:81
const HGCalGeometry * gHGCal_
Definition: HGCDigitizer.h:99
bool producesEEDigis()
Definition: HGCDigitizer.h:67
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:98
bool producesHEfrontDigis()
Definition: HGCDigitizer.h:68
bool producesHEbackDigis()
Definition: HGCDigitizer.h:69
const T & get() const
Definition: EventSetup.h:59
const HcalGeometry * gHcal_
Definition: HGCDigitizer.h:100
uint32_t verbosity_
Definition: HGCDigitizer.h:106
std::string HGCDigitizer::digiCollection ( )
inline

Definition at line 70 of file HGCDigitizer.h.

References beginRun(), digiCollection_, and endRun().

Referenced by finalizeEvent().

70 { return digiCollection_; }
std::string digiCollection_
Definition: HGCDigitizer.h:81
void HGCDigitizer::endRun ( )

Definition at line 489 of file HGCDigitizer.cc.

References edm::swap(), and validIds_.

Referenced by digiCollection().

490 {
491  std::unordered_set<DetId>().swap(validIds_);
492 }
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:98
void HGCDigitizer::finalizeEvent ( edm::Event e,
edm::EventSetup const &  c,
CLHEP::HepRandomEngine *  hre 
)

Definition at line 201 of file HGCDigitizer.cc.

References averageOccupancies_, digiCollection(), digitizationType_, gHcal_, gHGCal_, HGCEE, HGCHEB, HGCHEF, hitRefs_bx0, training_settings::idx, SiStripPI::max, eostools::move(), mySubDet_, nEvents_, producesEEDigis(), producesHEbackDigis(), producesHEfrontDigis(), edm::Event::put(), simHitAccumulator_, theHGCEEDigitizer_, theHGCHEbackDigitizer_, theHGCHEfrontDigitizer_, and validIds_.

Referenced by orderByDetIdThenTime().

202 {
203  hitRefs_bx0.clear();
204 
205  const CaloSubdetectorGeometry* theGeom = ( nullptr == gHGCal_ ?
206  static_cast<const CaloSubdetectorGeometry*>(gHcal_) :
207  static_cast<const CaloSubdetectorGeometry*>(gHGCal_) );
208 
209  ++nEvents_;
211  switch(mySubDet_) {
213  idx = 0;
214  break;
216  idx = 1;
217  break;
219  idx = 2;
220  break;
221  default:
222  break;
223  }
224  // release memory for unfilled parts of hash table
225  if( validIds_.size()*averageOccupancies_[idx] > simHitAccumulator_->size() ) {
226  simHitAccumulator_->reserve(simHitAccumulator_->size());
227  }
228  //update occupancy guess
229  const double thisOcc = simHitAccumulator_->size()/((double)validIds_.size());
231 
232  if( producesEEDigis() )
233  {
234  std::unique_ptr<HGCEEDigiCollection> digiResult(new HGCEEDigiCollection() );
235  theHGCEEDigitizer_->run(digiResult,*simHitAccumulator_,theGeom,validIds_,digitizationType_, hre);
236  edm::LogInfo("HGCDigitizer") << " @ finalize event - produced " << digiResult->size() << " EE hits";
237  e.put(std::move(digiResult),digiCollection());
238  }
239  if( producesHEfrontDigis())
240  {
241  std::unique_ptr<HGCHEDigiCollection> digiResult(new HGCHEDigiCollection() );
243  edm::LogInfo("HGCDigitizer") << " @ finalize event - produced " << digiResult->size() << " HE front hits";
244  e.put(std::move(digiResult),digiCollection());
245  }
246  if( producesHEbackDigis() )
247  {
248  std::unique_ptr<HGCBHDigiCollection> digiResult(new HGCBHDigiCollection() );
250  edm::LogInfo("HGCDigitizer") << " @ finalize event - produced " << digiResult->size() << " HE back hits";
251  e.put(std::move(digiResult),digiCollection());
252  }
253 
255 }
uint32_t nEvents_
Definition: HGCDigitizer.h:116
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
edm::SortedCollection< HGCEEDataFrame > HGCEEDigiCollection
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:103
int digitizationType_
Definition: HGCDigitizer.h:84
const HGCalGeometry * gHGCal_
Definition: HGCDigitizer.h:99
bool producesEEDigis()
Definition: HGCDigitizer.h:67
std::unordered_map< uint32_t, HGCCellInfo > HGCSimHitDataAccumulator
edm::SortedCollection< HGCBHDataFrame > HGCBHDigiCollection
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:98
bool producesHEfrontDigis()
Definition: HGCDigitizer.h:68
std::unique_ptr< HGCHEbackDigitizer > theHGCHEbackDigitizer_
Definition: HGCDigitizer.h:94
bool producesHEbackDigis()
Definition: HGCDigitizer.h:69
std::unique_ptr< HGCHEfrontDigitizer > theHGCHEfrontDigitizer_
Definition: HGCDigitizer.h:95
std::unique_ptr< HGCEEDigitizer > theHGCEEDigitizer_
Definition: HGCDigitizer.h:93
std::map< uint32_t, std::vector< std::pair< float, float > > > hitRefs_bx0
Definition: HGCDigitizer.h:120
std::array< double, 3 > averageOccupancies_
Definition: HGCDigitizer.h:115
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:89
std::string digiCollection()
Definition: HGCDigitizer.h:70
edm::SortedCollection< HGCHEDataFrame > HGCHEDigiCollection
const HcalGeometry * gHcal_
Definition: HGCDigitizer.h:100
def move(src, dest)
Definition: eostools.py:510
void HGCDigitizer::initializeEvent ( edm::Event const &  e,
edm::EventSetup const &  c 
)

actions at the start/end of event

Definition at line 180 of file HGCDigitizer.cc.

References averageOccupancies_, HGCEE, HGCHEB, HGCHEF, training_settings::idx, SiStripPI::max, mySubDet_, simHitAccumulator_, and validIds_.

Referenced by orderByDetIdThenTime().

181 {
182  // reserve memory for a full detector
184  switch(mySubDet_) {
186  idx = 0;
187  break;
189  idx = 1;
190  break;
192  idx = 2;
193  break;
194  default:
195  break;
196  }
197  simHitAccumulator_->reserve( averageOccupancies_[idx]*validIds_.size() );
198 }
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:103
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:98
std::array< double, 3 > averageOccupancies_
Definition: HGCDigitizer.h:115
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:89
static bool HGCDigitizer::orderByDetIdThenTime ( const HGCCaloHitTuple_t a,
const HGCCaloHitTuple_t b 
)
inlinestatic

Definition at line 37 of file HGCDigitizer.h.

References accumulate(), EnergyCorrector::c, MillePedeFileConverter_cfg::e, finalizeEvent(), relativeConstraints::geom, hfClusterShapes_cfi::hits, and initializeEvent().

Referenced by accumulate().

38  {
39  unsigned int detId_a(std::get<1>(a)), detId_b(std::get<1>(b));
40 
41  if(detId_a<detId_b) return true;
42  if(detId_a>detId_b) return false;
43 
44  double time_a(std::get<2>(a)), time_b(std::get<2>(b));
45  if(time_a<time_b) return true;
46 
47  return false;
48  }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
bool HGCDigitizer::producesEEDigis ( )
inline

Definition at line 67 of file HGCDigitizer.h.

References HGCEE, and mySubDet_.

Referenced by accumulate(), beginRun(), and finalizeEvent().

ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:103
bool HGCDigitizer::producesHEbackDigis ( )
inline

Definition at line 69 of file HGCDigitizer.h.

References HGCHEB, and mySubDet_.

Referenced by beginRun(), and finalizeEvent().

ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:103
bool HGCDigitizer::producesHEfrontDigis ( )
inline

Definition at line 68 of file HGCDigitizer.h.

References HGCHEF, and mySubDet_.

Referenced by beginRun(), and finalizeEvent().

ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:103
void HGCDigitizer::resetSimHitDataAccumulator ( )
private

Definition at line 495 of file HGCDigitizer.cc.

References relativeConstraints::geom, hfClusterShapes_cfi::hits, and simHitAccumulator_.

496 {
497  for( HGCSimHitDataAccumulator::iterator it = simHitAccumulator_->begin(); it!=simHitAccumulator_->end(); it++)
498  {
499  it->second.hit_info[0].fill(0.);
500  it->second.hit_info[1].fill(0.);
501  }
502 }
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:89

Member Data Documentation

std::array<double,3> HGCDigitizer::averageOccupancies_
private

Definition at line 115 of file HGCDigitizer.h.

Referenced by finalizeEvent(), and initializeEvent().

double HGCDigitizer::bxTime_
private

Definition at line 88 of file HGCDigitizer.h.

Referenced by accumulate(), and HGCDigitizer().

std::vector<float> HGCDigitizer::cce_
private

Definition at line 118 of file HGCDigitizer.h.

Referenced by accumulate(), and HGCDigitizer().

std::string HGCDigitizer::digiCollection_
private

Definition at line 81 of file HGCDigitizer.h.

Referenced by digiCollection(), and HGCDigitizer().

int HGCDigitizer::digitizationType_
private

Definition at line 84 of file HGCDigitizer.h.

Referenced by finalizeEvent(), and HGCDigitizer().

double HGCDigitizer::ev_per_eh_pair_
private

Definition at line 88 of file HGCDigitizer.h.

const HcalGeometry* HGCDigitizer::gHcal_
private

Definition at line 100 of file HGCDigitizer.h.

Referenced by accumulate(), beginRun(), and finalizeEvent().

const HGCalGeometry* HGCDigitizer::gHGCal_
private

Definition at line 99 of file HGCDigitizer.h.

Referenced by accumulate(), beginRun(), and finalizeEvent().

std::string HGCDigitizer::hitCollection_
private

Definition at line 81 of file HGCDigitizer.h.

Referenced by accumulate(), beginRun(), and HGCDigitizer().

std::map< uint32_t, std::vector< std::pair<float, float> > > HGCDigitizer::hitRefs_bx0
private

Definition at line 120 of file HGCDigitizer.h.

Referenced by accumulate(), and finalizeEvent().

int HGCDigitizer::maxSimHitsAccTime_
private

Definition at line 87 of file HGCDigitizer.h.

Referenced by HGCDigitizer().

ForwardSubdetector HGCDigitizer::mySubDet_
private
uint32_t HGCDigitizer::nEvents_
private

Definition at line 116 of file HGCDigitizer.h.

Referenced by finalizeEvent().

float HGCDigitizer::refSpeed_
private

Definition at line 109 of file HGCDigitizer.h.

Referenced by accumulate().

std::unique_ptr<hgc::HGCSimHitDataAccumulator> HGCDigitizer::simHitAccumulator_
private
std::unique_ptr<HGCEEDigitizer> HGCDigitizer::theHGCEEDigitizer_
private

Definition at line 93 of file HGCDigitizer.h.

Referenced by accumulate(), finalizeEvent(), and HGCDigitizer().

std::unique_ptr<HGCHEbackDigitizer> HGCDigitizer::theHGCHEbackDigitizer_
private

Definition at line 94 of file HGCDigitizer.h.

Referenced by accumulate(), finalizeEvent(), and HGCDigitizer().

std::unique_ptr<HGCHEfrontDigitizer> HGCDigitizer::theHGCHEfrontDigitizer_
private

Definition at line 95 of file HGCDigitizer.h.

Referenced by accumulate(), finalizeEvent(), and HGCDigitizer().

float HGCDigitizer::tofDelay_
private

Definition at line 112 of file HGCDigitizer.h.

Referenced by accumulate(), and HGCDigitizer().

std::unordered_set<DetId> HGCDigitizer::validIds_
private
uint32_t HGCDigitizer::verbosity_
private

Definition at line 106 of file HGCDigitizer.h.

Referenced by accumulate(), beginRun(), and HGCDigitizer().