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 accumulate (const PHGCSimAccumulator &simAccumulator)
 
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)
 
int geometryType ()
 
 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

uint32_t getType () const
 
bool getWeight (std::array< float, 3 > &tdcForToAOnset, float &keV2fC) const
 
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_
 
int geometryType_
 
const HcalGeometrygHcal_
 
const HGCalGeometrygHGCal_
 
std::string hitCollection_
 
std::map< uint32_t, std::vector< std::pair< float, float > > > hitRefs_bx0
 
int maxSimHitsAccTime_
 
DetId::Detector myDet_
 
ForwardSubdetector mySubDet_
 
uint32_t nEvents_
 
bool premixStage1_
 
double premixStage1MaxCharge_
 
double premixStage1MinCharge_
 
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 29 of file HGCDigitizer.h.

Member Typedef Documentation

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

Definition at line 37 of file HGCDigitizer.h.

Constructor & Destructor Documentation

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

Definition at line 180 of file HGCDigitizer.cc.

References bxTime_, cce_, edm::ConsumesCollector::consumes(), digiCollection_, digitizationType_, geometryType_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), DetId::HGCalEE, DetId::HGCalHSc, DetId::HGCalHSi, HGCEE, HGCHEB, HGCHEF, hitCollection_, maxSimHitsAccTime_, myDet_, mySubDet_, premixStage1_, premixStage1MaxCharge_, premixStage1MinCharge_, AlCaHLTBitMon_QueryRunRegistry::string, edm::swap(), groupFilesInBlocks::temp, theHGCEEDigitizer_, theHGCHEbackDigitizer_, theHGCHEfrontDigitizer_, tofDelay_, validIds_, and verbosity_.

181  :
185  refSpeed_(0.1*CLHEP::c_light), //[CLHEP::c_light]=mm/ns convert to cm/ns
186  averageOccupancies_(occupancyGuesses),
187  nEvents_(1)
188 {
189  //configure from cfg
190  hitCollection_ = ps.getParameter< std::string >("hitCollection");
191  digiCollection_ = ps.getParameter< std::string >("digiCollection");
192  maxSimHitsAccTime_ = ps.getParameter< uint32_t >("maxSimHitsAccTime");
193  bxTime_ = ps.getParameter< double >("bxTime");
194  geometryType_ = ps.getParameter< uint32_t >("geometryType");
195  digitizationType_ = ps.getParameter< uint32_t >("digitizationType");
196  verbosity_ = ps.getUntrackedParameter< uint32_t >("verbosity",0);
197  tofDelay_ = ps.getParameter< double >("tofDelay");
198  premixStage1_ = ps.getParameter<bool>("premixStage1");
199  premixStage1MinCharge_ = ps.getParameter<double>("premixStage1MinCharge");
200  premixStage1MaxCharge_ = ps.getParameter<double>("premixStage1MaxCharge");
201 
202  std::unordered_set<DetId>().swap(validIds_);
203 
204  iC.consumes<std::vector<PCaloHit> >(edm::InputTag("g4SimHits",hitCollection_));
205  const auto& myCfg_ = ps.getParameter<edm::ParameterSet>("digiCfg");
206 
207  if( myCfg_.existsAs<edm::ParameterSet>("chargeCollectionEfficiencies")) {
208  cce_.clear();
209  const auto& temp = myCfg_.getParameter<edm::ParameterSet>("chargeCollectionEfficiencies").getParameter<std::vector<double>>("values");
210  for( double cce : temp ) {
211  cce_.emplace_back(cce);
212  }
213  } else {
214  std::vector<float>().swap(cce_);
215  }
216 
217  if(hitCollection_.find("HitsEE")!=std::string::npos) {
218  if (geometryType_ == 0) {
220  } else {
222  }
223  theHGCEEDigitizer_=std::make_unique<HGCEEDigitizer>(ps);
224  }
225  if(hitCollection_.find("HitsHEfront")!=std::string::npos) {
226  if (geometryType_ == 0) {
228  } else {
230  }
231  theHGCHEfrontDigitizer_=std::make_unique<HGCHEfrontDigitizer>(ps);
232  }
233  if(hitCollection_.find("HcalHits")!=std::string::npos and geometryType_ == 0) {
235  theHGCHEbackDigitizer_=std::make_unique<HGCHEbackDigitizer>(ps);
236  }
237  if(hitCollection_.find("HitsHEback")!=std::string::npos and geometryType_ == 1) {
239  theHGCHEbackDigitizer_=std::make_unique<HGCHEbackDigitizer>(ps);
240  }
241 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
uint32_t nEvents_
Definition: HGCDigitizer.h:138
T getUntrackedParameter(std::string const &, T const &) const
bool premixStage1_
Definition: HGCDigitizer.h:100
std::vector< float > cce_
Definition: HGCDigitizer.h:140
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:125
int digitizationType_
Definition: HGCDigitizer.h:97
std::string hitCollection_
Definition: HGCDigitizer.h:91
DetId::Detector myDet_
Definition: HGCDigitizer.h:124
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
std::string digiCollection_
Definition: HGCDigitizer.h:91
std::unordered_map< uint32_t, HGCCellInfo > HGCSimHitDataAccumulator
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:119
std::unique_ptr< HGCHEbackDigitizer > theHGCHEbackDigitizer_
Definition: HGCDigitizer.h:115
double premixStage1MinCharge_
Definition: HGCDigitizer.h:103
int maxSimHitsAccTime_
Definition: HGCDigitizer.h:108
std::unique_ptr< HGCHEfrontDigitizer > theHGCHEfrontDigitizer_
Definition: HGCDigitizer.h:116
std::unique_ptr< HGCEEDigitizer > theHGCEEDigitizer_
Definition: HGCDigitizer.h:114
std::array< double, 3 > averageOccupancies_
Definition: HGCDigitizer.h:137
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:110
double bxTime_
Definition: HGCDigitizer.h:109
double premixStage1MaxCharge_
Definition: HGCDigitizer.h:105
uint32_t verbosity_
Definition: HGCDigitizer.h:128
HGCDigitizer::~HGCDigitizer ( )
inline

Definition at line 34 of file HGCDigitizer.h.

34 { }

Member Function Documentation

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

handle SimHit accumulation

Definition at line 302 of file HGCDigitizer.cc.

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

Referenced by HGCDigiProducer::accumulate(), accumulate(), PreMixingHGCalWorker::addPileups(), PreMixingHGCalWorker::addSignals(), and orderByDetIdThenTime().

302  {
303 
304  //get inputs
306  e.getByLabel(edm::InputTag("g4SimHits",hitCollection_),hits);
307  if( !hits.isValid() ){
308  edm::LogError("HGCDigitizer") << " @ accumulate : can't find " << hitCollection_ << " collection of g4SimHits";
309  return;
310  }
311 
312  //accumulate in-time the main event
313  if( nullptr != gHGCal_ ) {
314  accumulate(hits, 0, gHGCal_, hre);
315  } else if( nullptr != gHcal_ ) {
316  accumulate(hits, 0, gHcal_, hre);
317  } else {
318  throw cms::Exception("BadConfiguration")
319  << "HGCDigitizer is not producing EE, FH, or BH digis!";
320  }
321 }
std::string hitCollection_
Definition: HGCDigitizer.h:91
const HGCalGeometry * gHGCal_
Definition: HGCDigitizer.h:120
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:121
void HGCDigitizer::accumulate ( PileUpEventPrincipal const &  e,
edm::EventSetup const &  c,
CLHEP::HepRandomEngine *  hre 
)

Definition at line 324 of file HGCDigitizer.cc.

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

324  {
325 
326  //get inputs
328  e.getByLabel(edm::InputTag("g4SimHits",hitCollection_),hits);
329  if( !hits.isValid() ){
330  edm::LogError("HGCDigitizer") << " @ accumulate : can't find " << hitCollection_ << " collection of g4SimHits";
331  return;
332  }
333 
334  //accumulate for the simulated bunch crossing
335  if( nullptr != gHGCal_ ) {
336  accumulate(hits, e.bunchCrossing(), gHGCal_, hre);
337  } else if ( nullptr != gHcal_ ) {
338  accumulate(hits, e.bunchCrossing(), gHcal_, hre);
339  } else {
340  throw cms::Exception("BadConfiguration")
341  << "HGCDigitizer is not producing EE, FH, or BH digis!";
342  }
343 }
std::string hitCollection_
Definition: HGCDigitizer.h:91
const HGCalGeometry * gHGCal_
Definition: HGCDigitizer.h:120
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:121
template<typename GEOM >
void HGCDigitizer::accumulate ( edm::Handle< edm::PCaloHitContainer > const &  hits,
int  bxCrossing,
const GEOM *  geom,
CLHEP::HepRandomEngine *  hre 
)

Definition at line 347 of file HGCDigitizer.cc.

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

350  {
351  if( nullptr == geom ) return;
352 
353 
354 
355  //configuration to apply for the computation of time-of-flight
356  std::array<float, 3> tdcForToAOnset{ {0.f, 0.f, 0.f} };
357  float keV2fC(0.f);
358  bool weightToAbyEnergy= getWeight(tdcForToAOnset, keV2fC);
359 
360  //create list of tuples (pos in container, RECO DetId, time) to be sorted first
361  int nchits=(int)hits->size();
362  std::vector< HGCCaloHitTuple_t > hitRefs;
363  hitRefs.reserve(nchits);
364  for(int i=0; i<nchits; ++i) {
365  const auto& the_hit = hits->at(i);
366 
367  DetId id = simToReco(geom,the_hit.id());
368 
369  if (verbosity_>0) {
370  if (producesEEDigis())
371  edm::LogInfo("HGCDigitizer") << " i/p " << std::hex << the_hit.id() << " o/p " << id.rawId() << std::dec << std::endl;
372  else
373  edm::LogInfo("HGCDigitizer") << " i/p " << std::hex << the_hit.id() << " o/p " << id.rawId() << std::dec << std::endl;
374  }
375 
376  if( 0 != id.rawId() ) {
377  hitRefs.emplace_back( i, id.rawId(), (float)the_hit.time() );
378  }
379  }
380  std::sort(hitRefs.begin(),hitRefs.end(),this->orderByDetIdThenTime);
381 
382  //loop over sorted hits
383  nchits = hitRefs.size();
384  for(int i=0; i<nchits; ++i) {
385  const int hitidx = std::get<0>(hitRefs[i]);
386  const uint32_t id = std::get<1>(hitRefs[i]);
387 
388  //get the data for this cell, if not available then we skip it
389 
390  if( !validIds_.count(id) ) continue;
391  HGCSimHitDataAccumulator::iterator simHitIt = simHitAccumulator_->emplace(id,HGCCellInfo()).first;
392 
393  if(id==0) continue; // to be ignored at RECO level
394 
395  const float toa = std::get<2>(hitRefs[i]);
396  const PCaloHit &hit=hits->at( hitidx );
397  const float charge = hit.energy()*1e6*keV2fC*getCCE(geom,id,cce_);
398 
399  //distance to the center of the detector
400  const float dist2center( getPositionDistance(geom,id) );
401 
402  //hit time: [time()]=ns [centerDist]=cm [refSpeed_]=cm/ns + delay by 1ns
403  //accumulate in 15 buckets of 25ns (9 pre-samples, 1 in-time, 5 post-samples)
404  const float tof = toa-dist2center/refSpeed_+tofDelay_ ;
405  const int itime= std::floor( tof/bxTime_ ) + 9;
406 
407  //no need to add bx crossing - tof comes already corrected from the mixing module
408  //itime += bxCrossing;
409  //itime += 9;
410 
411  if(itime<0 || itime>14) continue;
412 
413  //check if time index is ok and store energy
414  if(itime >= (int)simHitIt->second.hit_info[0].size() ) continue;
415 
416  (simHitIt->second).hit_info[0][itime] += charge;
417 
418 
419  //working version with pileup only for in-time hits
420  int waferThickness = getCellThickness(geom,id);
421  bool orderChanged = false;
422  if(itime == 9){
423  if(hitRefs_bx0[id].empty()){
424  hitRefs_bx0[id].emplace_back(charge, tof);
425  }
426  else if(tof <= hitRefs_bx0[id].back().second){
427  std::vector<std::pair<float, float> >::iterator findPos =
428  std::upper_bound(hitRefs_bx0[id].begin(), hitRefs_bx0[id].end(), std::pair<float, float>(0.f,tof),
429  [](const auto& i, const auto& j){return i.second < j.second;});
430 
431  std::vector<std::pair<float, float> >::iterator insertedPos =
432  hitRefs_bx0[id].insert(findPos, (findPos == hitRefs_bx0[id].begin()) ?
433  std::pair<float, float>(charge,tof) : std::pair<float, float>((findPos-1)->first+charge,tof));
434 
435  for(std::vector<std::pair<float, float> >::iterator step = insertedPos+1; step != hitRefs_bx0[id].end(); ++step){
436  step->first += charge;
437  if(step->first > tdcForToAOnset[waferThickness-1] && step->second != hitRefs_bx0[id].back().second){
438  hitRefs_bx0[id].resize(std::upper_bound(hitRefs_bx0[id].begin(), hitRefs_bx0[id].end(), std::pair<float, float>(0.f,step->second),
439  [](const auto& i, const auto& j){return i.second < j.second;}) - hitRefs_bx0[id].begin());
440  for(auto stepEnd = step+1; stepEnd != hitRefs_bx0[id].end(); ++stepEnd) stepEnd->first += charge;
441  break;
442  }
443  }
444  orderChanged = true;
445  }
446  else{
447  if(hitRefs_bx0[id].back().first <= tdcForToAOnset[waferThickness-1]){
448  hitRefs_bx0[id].emplace_back(hitRefs_bx0[id].back().first+charge, tof);
449  }
450  }
451  }
452 
453  float accChargeForToA = hitRefs_bx0[id].empty() ? 0.f : hitRefs_bx0[id].back().first;
454 
455  //time-of-arrival (check how to be used)
456  if(weightToAbyEnergy) (simHitIt->second).hit_info[1][itime] += charge*tof;
457  else if(accChargeForToA > tdcForToAOnset[waferThickness-1] &&
458  ((simHitIt->second).hit_info[1][itime] == 0 || orderChanged == true) ){
459  float fireTDC = hitRefs_bx0[id].back().second;
460  if (hitRefs_bx0[id].size() > 1){
461  float chargeBeforeThr = 0.f;
462  float tofchargeBeforeThr = 0.f;
463  for(const auto& step : hitRefs_bx0[id]){
464  if(step.first + chargeBeforeThr <= tdcForToAOnset[waferThickness-1]){
465  chargeBeforeThr += step.first;
466  tofchargeBeforeThr = step.second;
467  }
468  else break;
469  }
470  float deltaQ = accChargeForToA - chargeBeforeThr;
471  float deltaTOF = fireTDC - tofchargeBeforeThr;
472  fireTDC = (tdcForToAOnset[waferThickness-1] - chargeBeforeThr) * deltaTOF / deltaQ + tofchargeBeforeThr;
473  }
474  (simHitIt->second).hit_info[1][itime] = fireTDC;
475  }
476 
477  }
478  hitRefs.clear();
479 }
size
Write out results.
std::vector< float > cce_
Definition: HGCDigitizer.h:140
bool producesEEDigis()
Definition: HGCDigitizer.h:70
bool getWeight(std::array< float, 3 > &tdcForToAOnset, float &keV2fC) const
U second(std::pair< T, U > const &p)
double f[11][100]
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:119
#define end
Definition: vmac.h:39
Definition: DetId.h:18
#define begin
Definition: vmac.h:32
std::map< uint32_t, std::vector< std::pair< float, float > > > hitRefs_bx0
Definition: HGCDigitizer.h:142
step
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:110
static bool orderByDetIdThenTime(const HGCCaloHitTuple_t &a, const HGCCaloHitTuple_t &b)
Definition: HGCDigitizer.h:38
double bxTime_
Definition: HGCDigitizer.h:109
uint32_t verbosity_
Definition: HGCDigitizer.h:128
void HGCDigitizer::accumulate ( const PHGCSimAccumulator simAccumulator)

Definition at line 481 of file HGCDigitizer.cc.

References f, getWeight(), hgcalDigitizer_cfi::keV2fC, premixStage1MaxCharge_, premixStage1MinCharge_, and simHitAccumulator_.

481  {
482  //configuration to apply for the computation of time-of-flight
483  std::array<float, 3> tdcForToAOnset{ {0.f, 0.f, 0.f} };
484  float keV2fC(0.f);
485  bool weightToAbyEnergy= getWeight(tdcForToAOnset, keV2fC);
486  loadSimHitAccumulator(*simHitAccumulator_, simAccumulator, premixStage1MinCharge_, premixStage1MaxCharge_, !weightToAbyEnergy);
487 }
bool getWeight(std::array< float, 3 > &tdcForToAOnset, float &keV2fC) const
double f[11][100]
double premixStage1MinCharge_
Definition: HGCDigitizer.h:103
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:110
double premixStage1MaxCharge_
Definition: HGCDigitizer.h:105
void HGCDigitizer::beginRun ( const edm::EventSetup es)

actions at the start/end of run

Definition at line 490 of file HGCDigitizer.cc.

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

Referenced by PreMixingHGCalWorker::beginRun(), HGCDigiProducer::beginRun(), and geometryType().

490  {
491  //get geometry
493  es.get<CaloGeometryRecord>().get(geom);
494 
495  gHGCal_ = nullptr;
496  gHcal_ = nullptr;
497 
498  if( producesEEDigis() ) gHGCal_ = dynamic_cast<const HGCalGeometry*>(geom->getSubdetectorGeometry(myDet_,mySubDet_));
499  if( producesHEfrontDigis() ) gHGCal_ = dynamic_cast<const HGCalGeometry*>(geom->getSubdetectorGeometry(myDet_,mySubDet_));
500 
501  if( producesHEbackDigis() ) {
502  if (geometryType_ == 0) {
503  gHcal_ = dynamic_cast<const HcalGeometry*>(geom->getSubdetectorGeometry(DetId::Hcal, HcalEndcap));
504  } else {
505  gHGCal_ = dynamic_cast<const HGCalGeometry*>(geom->getSubdetectorGeometry(myDet_,mySubDet_));
506  }
507  }
508 
509  int nadded(0);
510  //valid ID lists
511  if( nullptr != gHGCal_ ) {
512  getValidDetIds( gHGCal_, validIds_ );
513  } else if( nullptr != gHcal_ ) {
514  getValidDetIds( gHcal_, validIds_ );
515  } else {
516  throw cms::Exception("BadConfiguration")
517  << "HGCDigitizer is not producing EE, FH, or BH digis!";
518  }
519 
520  if (verbosity_ > 0)
521  edm::LogInfo("HGCDigitizer")
522  << "Added " << nadded << ":" << validIds_.size()
523  << " detIds without " << hitCollection_
524  << " in first event processed" << std::endl;
525 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:125
std::string hitCollection_
Definition: HGCDigitizer.h:91
DetId::Detector myDet_
Definition: HGCDigitizer.h:124
const HGCalGeometry * gHGCal_
Definition: HGCDigitizer.h:120
bool producesEEDigis()
Definition: HGCDigitizer.h:70
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:119
bool producesHEfrontDigis()
Definition: HGCDigitizer.h:72
bool producesHEbackDigis()
Definition: HGCDigitizer.h:74
T get() const
Definition: EventSetup.h:63
const HcalGeometry * gHcal_
Definition: HGCDigitizer.h:121
uint32_t verbosity_
Definition: HGCDigitizer.h:128
std::string HGCDigitizer::digiCollection ( )
inline

Definition at line 76 of file HGCDigitizer.h.

References digiCollection_.

Referenced by finalizeEvent(), HGCDigiProducer::HGCDigiProducer(), and PreMixingHGCalWorker::PreMixingHGCalWorker().

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

Definition at line 528 of file HGCDigitizer.cc.

References edm::swap(), and validIds_.

Referenced by PreMixingHGCalWorker::endRun(), HGCDigiProducer::endRun(), and geometryType().

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

Definition at line 252 of file HGCDigitizer.cc.

References averageOccupancies_, digiCollection(), digitizationType_, getType(), gHcal_, gHGCal_, hitRefs_bx0, training_settings::idx, eostools::move(), nEvents_, premixStage1_, premixStage1MaxCharge_, premixStage1MinCharge_, producesEEDigis(), producesHEbackDigis(), producesHEfrontDigis(), edm::Event::put(), simHitAccumulator_, theHGCEEDigitizer_, theHGCHEbackDigitizer_, theHGCHEfrontDigitizer_, and validIds_.

Referenced by HGCDigiProducer::finalizeEvent(), orderByDetIdThenTime(), and PreMixingHGCalWorker::put().

253 {
254  hitRefs_bx0.clear();
255 
256  const CaloSubdetectorGeometry* theGeom = ( nullptr == gHGCal_ ?
257  static_cast<const CaloSubdetectorGeometry*>(gHcal_) :
258  static_cast<const CaloSubdetectorGeometry*>(gHGCal_) );
259 
260  ++nEvents_;
261  unsigned idx = getType();
262  // release memory for unfilled parts of hash table
263  if( validIds_.size()*averageOccupancies_[idx] > simHitAccumulator_->size() ) {
264  simHitAccumulator_->reserve(simHitAccumulator_->size());
265  }
266  //update occupancy guess
267  const double thisOcc = simHitAccumulator_->size()/((double)validIds_.size());
269 
270  if(premixStage1_) {
271  std::unique_ptr<PHGCSimAccumulator> simResult;
272  if(!simHitAccumulator_->empty()) {
273  simResult = std::make_unique<PHGCSimAccumulator>(simHitAccumulator_->begin()->first);
274  saveSimHitAccumulator(*simResult, *simHitAccumulator_, validIds_, premixStage1MinCharge_, premixStage1MaxCharge_);
275  }
276  e.put(std::move(simResult), digiCollection());
277  } else {
278  if( producesEEDigis() ) {
279  auto digiResult = std::make_unique<HGCalDigiCollection>();
280  theHGCEEDigitizer_->run(digiResult,*simHitAccumulator_,theGeom,validIds_,digitizationType_, hre);
281  edm::LogInfo("HGCDigitizer") << " @ finalize event - produced " << digiResult->size() << " EE hits";
282  e.put(std::move(digiResult),digiCollection());
283  }
284  if( producesHEfrontDigis()) {
285  auto digiResult = std::make_unique<HGCalDigiCollection>();
287  edm::LogInfo("HGCDigitizer") << " @ finalize event - produced " << digiResult->size() << " HE front hits";
288  e.put(std::move(digiResult),digiCollection());
289  }
290  if( producesHEbackDigis() ) {
291  auto digiResult = std::make_unique<HGCalDigiCollection>();
293  edm::LogInfo("HGCDigitizer") << " @ finalize event - produced " << digiResult->size() << " HE back hits";
294  e.put(std::move(digiResult),digiCollection());
295  }
296  }
297 
299 }
uint32_t nEvents_
Definition: HGCDigitizer.h:138
bool premixStage1_
Definition: HGCDigitizer.h:100
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
int digitizationType_
Definition: HGCDigitizer.h:97
const HGCalGeometry * gHGCal_
Definition: HGCDigitizer.h:120
bool producesEEDigis()
Definition: HGCDigitizer.h:70
std::unordered_map< uint32_t, HGCCellInfo > HGCSimHitDataAccumulator
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:119
bool producesHEfrontDigis()
Definition: HGCDigitizer.h:72
uint32_t getType() const
std::unique_ptr< HGCHEbackDigitizer > theHGCHEbackDigitizer_
Definition: HGCDigitizer.h:115
double premixStage1MinCharge_
Definition: HGCDigitizer.h:103
bool producesHEbackDigis()
Definition: HGCDigitizer.h:74
std::unique_ptr< HGCHEfrontDigitizer > theHGCHEfrontDigitizer_
Definition: HGCDigitizer.h:116
std::unique_ptr< HGCEEDigitizer > theHGCEEDigitizer_
Definition: HGCDigitizer.h:114
std::map< uint32_t, std::vector< std::pair< float, float > > > hitRefs_bx0
Definition: HGCDigitizer.h:142
std::array< double, 3 > averageOccupancies_
Definition: HGCDigitizer.h:137
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:110
double premixStage1MaxCharge_
Definition: HGCDigitizer.h:105
std::string digiCollection()
Definition: HGCDigitizer.h:76
const HcalGeometry * gHcal_
Definition: HGCDigitizer.h:121
def move(src, dest)
Definition: eostools.py:510
int HGCDigitizer::geometryType ( )
inline

Definition at line 77 of file HGCDigitizer.h.

References beginRun(), endRun(), geometryType_, getType(), getWeight(), and hgcalDigitizer_cfi::keV2fC.

77 { return geometryType_; }
uint32_t HGCDigitizer::getType ( void  ) const
private

Definition at line 543 of file HGCDigitizer.cc.

References geometryType_, DetId::HGCalEE, DetId::HGCalHSc, DetId::HGCalHSi, HGCEE, HGCHEB, HGCHEF, training_settings::idx, SiStripPI::max, myDet_, and mySubDet_.

Referenced by finalizeEvent(), geometryType(), and initializeEvent().

543  {
544 
546  if (geometryType_ == 0) {
547  switch(mySubDet_) {
549  idx = 0;
550  break;
552  idx = 1;
553  break;
555  idx = 2;
556  break;
557  default:
558  break;
559  }
560  } else {
561  switch(myDet_) {
562  case DetId::HGCalEE:
563  idx = 0;
564  break;
565  case DetId::HGCalHSi:
566  idx = 1;
567  break;
568  case DetId::HGCalHSc:
569  idx = 2;
570  break;
571  default:
572  break;
573  }
574  }
575  return idx;
576 }
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:125
DetId::Detector myDet_
Definition: HGCDigitizer.h:124
bool HGCDigitizer::getWeight ( std::array< float, 3 > &  tdcForToAOnset,
float &  keV2fC 
) const
private

Definition at line 578 of file HGCDigitizer.cc.

References relativeConstraints::geom, geometryType_, DetId::HGCalEE, DetId::HGCalHSc, DetId::HGCalHSi, HGCEE, HGCHEB, HGCHEF, hfClusterShapes_cfi::hits, myDet_, mySubDet_, theHGCEEDigitizer_, theHGCHEbackDigitizer_, and theHGCHEfrontDigitizer_.

Referenced by accumulate(), and geometryType().

579  {
580 
581  bool weightToAbyEnergy(false);
582  if (geometryType_ == 0) {
583  switch( mySubDet_ ) {
585  weightToAbyEnergy = theHGCEEDigitizer_->toaModeByEnergy();
586  tdcForToAOnset = theHGCEEDigitizer_->tdcForToAOnset();
587  keV2fC = theHGCEEDigitizer_->keV2fC();
588  break;
590  weightToAbyEnergy = theHGCHEfrontDigitizer_->toaModeByEnergy();
591  tdcForToAOnset = theHGCHEfrontDigitizer_->tdcForToAOnset();
592  keV2fC = theHGCHEfrontDigitizer_->keV2fC();
593  break;
595  weightToAbyEnergy = theHGCHEbackDigitizer_->toaModeByEnergy();
596  tdcForToAOnset = theHGCHEbackDigitizer_->tdcForToAOnset();
597  keV2fC = theHGCHEbackDigitizer_->keV2fC();
598  break;
599  default:
600  break;
601  }
602  } else {
603  switch(myDet_) {
604  case DetId::HGCalEE:
605  weightToAbyEnergy = theHGCEEDigitizer_->toaModeByEnergy();
606  tdcForToAOnset = theHGCEEDigitizer_->tdcForToAOnset();
607  keV2fC = theHGCEEDigitizer_->keV2fC();
608  break;
609  case DetId::HGCalHSi:
610  weightToAbyEnergy = theHGCHEfrontDigitizer_->toaModeByEnergy();
611  tdcForToAOnset = theHGCHEfrontDigitizer_->tdcForToAOnset();
612  keV2fC = theHGCHEfrontDigitizer_->keV2fC();
613  break;
614  case DetId::HGCalHSc:
615  weightToAbyEnergy = theHGCHEbackDigitizer_->toaModeByEnergy();
616  tdcForToAOnset = theHGCHEbackDigitizer_->tdcForToAOnset();
617  keV2fC = theHGCHEbackDigitizer_->keV2fC();
618  break;
619  default:
620  break;
621  }
622  }
623 return weightToAbyEnergy;
624 }
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:125
DetId::Detector myDet_
Definition: HGCDigitizer.h:124
std::unique_ptr< HGCHEbackDigitizer > theHGCHEbackDigitizer_
Definition: HGCDigitizer.h:115
std::unique_ptr< HGCHEfrontDigitizer > theHGCHEfrontDigitizer_
Definition: HGCDigitizer.h:116
std::unique_ptr< HGCEEDigitizer > theHGCEEDigitizer_
Definition: HGCDigitizer.h:114
void HGCDigitizer::initializeEvent ( edm::Event const &  e,
edm::EventSetup const &  c 
)

actions at the start/end of event

Definition at line 244 of file HGCDigitizer.cc.

References averageOccupancies_, getType(), training_settings::idx, simHitAccumulator_, and validIds_.

Referenced by HGCDigiProducer::initializeEvent(), and orderByDetIdThenTime().

245 {
246  // reserve memory for a full detector
247  unsigned idx = getType();
248  simHitAccumulator_->reserve( averageOccupancies_[idx]*validIds_.size() );
249 }
std::unordered_set< DetId > validIds_
Definition: HGCDigitizer.h:119
uint32_t getType() const
std::array< double, 3 > averageOccupancies_
Definition: HGCDigitizer.h:137
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:110
static bool HGCDigitizer::orderByDetIdThenTime ( const HGCCaloHitTuple_t a,
const HGCCaloHitTuple_t b 
)
inlinestatic

Definition at line 38 of file HGCDigitizer.h.

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

Referenced by accumulate().

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

Definition at line 70 of file HGCDigitizer.h.

References DetId::HGCalEE, HGCEE, myDet_, and mySubDet_.

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

70  {
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:125
DetId::Detector myDet_
Definition: HGCDigitizer.h:124
bool HGCDigitizer::producesHEbackDigis ( )
inline

Definition at line 74 of file HGCDigitizer.h.

References DetId::HGCalHSc, HGCHEB, myDet_, and mySubDet_.

Referenced by beginRun(), and finalizeEvent().

74  {
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:125
DetId::Detector myDet_
Definition: HGCDigitizer.h:124
bool HGCDigitizer::producesHEfrontDigis ( )
inline

Definition at line 72 of file HGCDigitizer.h.

References DetId::HGCalHSi, HGCHEF, myDet_, and mySubDet_.

Referenced by beginRun(), and finalizeEvent().

72  {
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:125
DetId::Detector myDet_
Definition: HGCDigitizer.h:124
void HGCDigitizer::resetSimHitDataAccumulator ( )
private

Definition at line 534 of file HGCDigitizer.cc.

References simHitAccumulator_.

535 {
536  for( HGCSimHitDataAccumulator::iterator it = simHitAccumulator_->begin(); it!=simHitAccumulator_->end(); it++)
537  {
538  it->second.hit_info[0].fill(0.);
539  it->second.hit_info[1].fill(0.);
540  }
541 }
std::unique_ptr< hgc::HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:110

Member Data Documentation

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

Definition at line 137 of file HGCDigitizer.h.

Referenced by finalizeEvent(), and initializeEvent().

double HGCDigitizer::bxTime_
private

Definition at line 109 of file HGCDigitizer.h.

Referenced by accumulate(), and HGCDigitizer().

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

Definition at line 140 of file HGCDigitizer.h.

Referenced by accumulate(), and HGCDigitizer().

std::string HGCDigitizer::digiCollection_
private

Definition at line 91 of file HGCDigitizer.h.

Referenced by digiCollection(), and HGCDigitizer().

int HGCDigitizer::digitizationType_
private

Definition at line 97 of file HGCDigitizer.h.

Referenced by finalizeEvent(), and HGCDigitizer().

double HGCDigitizer::ev_per_eh_pair_
private

Definition at line 109 of file HGCDigitizer.h.

int HGCDigitizer::geometryType_
private

Definition at line 94 of file HGCDigitizer.h.

Referenced by beginRun(), geometryType(), getType(), getWeight(), and HGCDigitizer().

const HcalGeometry* HGCDigitizer::gHcal_
private

Definition at line 121 of file HGCDigitizer.h.

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

const HGCalGeometry* HGCDigitizer::gHGCal_
private

Definition at line 120 of file HGCDigitizer.h.

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

std::string HGCDigitizer::hitCollection_
private

Definition at line 91 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 142 of file HGCDigitizer.h.

Referenced by accumulate(), and finalizeEvent().

int HGCDigitizer::maxSimHitsAccTime_
private

Definition at line 108 of file HGCDigitizer.h.

Referenced by HGCDigitizer().

DetId::Detector HGCDigitizer::myDet_
private
ForwardSubdetector HGCDigitizer::mySubDet_
private
uint32_t HGCDigitizer::nEvents_
private

Definition at line 138 of file HGCDigitizer.h.

Referenced by finalizeEvent().

bool HGCDigitizer::premixStage1_
private

Definition at line 100 of file HGCDigitizer.h.

Referenced by finalizeEvent(), and HGCDigitizer().

double HGCDigitizer::premixStage1MaxCharge_
private

Definition at line 105 of file HGCDigitizer.h.

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

double HGCDigitizer::premixStage1MinCharge_
private

Definition at line 103 of file HGCDigitizer.h.

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

float HGCDigitizer::refSpeed_
private

Definition at line 131 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 114 of file HGCDigitizer.h.

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

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

Definition at line 115 of file HGCDigitizer.h.

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

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

Definition at line 116 of file HGCDigitizer.h.

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

float HGCDigitizer::tofDelay_
private

Definition at line 134 of file HGCDigitizer.h.

Referenced by accumulate(), and HGCDigitizer().

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

Definition at line 128 of file HGCDigitizer.h.

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