CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim > Class Template Reference

#include <FTLDigitizer.h>

Inheritance diagram for ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >:
FTLDigitizerBase

Public Member Functions

void accumulate (edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre) override
 handle SimHit accumulation More...
 
void accumulate (PileUpEventPrincipal const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre) override
 
void accumulate (edm::Handle< edm::PSimHitContainer > const &hits, int bxCrossing, CLHEP::HepRandomEngine *hre) override
 
void beginRun (const edm::EventSetup &es) override
 actions at the start/end of run More...
 
void endRun () override
 
void finalizeEvent (edm::Event &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre) override
 
 FTLDigitizer (const edm::ParameterSet &config, edm::ConsumesCollector &iC, edm::ProducerBase &parent)
 
void initializeEvent (edm::Event const &e, edm::EventSetup const &c) override
 actions at the start/end of event More...
 
 ~FTLDigitizer () override
 
- Public Member Functions inherited from FTLDigitizerBase
 FTLDigitizerBase (const edm::ParameterSet &config, edm::ConsumesCollector &iC, edm::ProducerBase &parent)
 
const std::string & name () const
 
virtual ~FTLDigitizerBase ()
 

Private Member Functions

void resetSimHitDataAccumulator ()
 

Private Attributes

const double bxTime_
 
edm::ESHandle< FastTimeDDDConstantsdddFTL_
 
SensorPhysics deviceSim_
 
ElectronicsSim electronicsSim_
 
edm::ESWatcher< IdealGeometryRecordidealGeomWatcher_
 
const int maxSimHitsAccTime_
 
FTLSimHitDataAccumulator simHitAccumulator_
 
const float tofDelay_
 
std::unordered_set< DetIdvalidIds_
 

Additional Inherited Members

- Protected Attributes inherited from FTLDigitizerBase
const std::string digiCollection_
 
const edm::InputTag inputSimHits_
 
const ForwardSubdetector mySubDet_
 
const float refSpeed_
 
const uint32_t verbosity_
 

Detailed Description

template<class SensorPhysics, class ElectronicsSim>
class ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >

Definition at line 48 of file FTLDigitizer.h.

Constructor & Destructor Documentation

template<class SensorPhysics , class ElectronicsSim >
ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::FTLDigitizer ( const edm::ParameterSet config,
edm::ConsumesCollector iC,
edm::ProducerBase parent 
)
inline

Definition at line 52 of file FTLDigitizer.h.

54  :
55  FTLDigitizerBase(config,iC,parent),
56  deviceSim_( config.getParameterSet("DeviceSimulation") ),
57  electronicsSim_( config.getParameterSet("ElectronicsSimulation") ),
58  maxSimHitsAccTime_( config.getParameter< uint32_t >("maxSimHitsAccTime") ),
59  bxTime_( config.getParameter< double >("bxTime") ),
60  tofDelay_( config.getParameter< double >("tofDelay") ) { }
T getParameter(std::string const &) const
FTLDigitizerBase(const edm::ParameterSet &config, edm::ConsumesCollector &iC, edm::ProducerBase &parent)
ElectronicsSim electronicsSim_
Definition: FTLDigitizer.h:91
ParameterSet const & getParameterSet(std::string const &) const
template<class SensorPhysics , class ElectronicsSim >
ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::~FTLDigitizer ( )
inlineoverride

Definition at line 62 of file FTLDigitizer.h.

References EnergyCorrector::c, MillePedeFileConverter_cfg::e, and hfClusterShapes_cfi::hits.

62 { }

Member Function Documentation

template<class SensorPhysics , class ElectronicsSim >
void ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::accumulate ( edm::Event const &  e,
edm::EventSetup const &  c,
CLHEP::HepRandomEngine *  hre 
)
overridevirtual

handle SimHit accumulation

Implements FTLDigitizerBase.

Definition at line 108 of file FTLDigitizer.h.

References edm::Event::getByLabel(), and trackerHits::simHits.

110  {
112  e.getByLabel(inputSimHits_, simHits);
113  accumulate(simHits,0,hre);
114  }
const edm::InputTag inputSimHits_
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre) override
handle SimHit accumulation
Definition: FTLDigitizer.h:108
template<class SensorPhysics , class ElectronicsSim >
void ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::accumulate ( PileUpEventPrincipal const &  e,
edm::EventSetup const &  c,
CLHEP::HepRandomEngine *  hre 
)
overridevirtual

Implements FTLDigitizerBase.

Definition at line 117 of file FTLDigitizer.h.

References PileUpEventPrincipal::bunchCrossing(), PileUpEventPrincipal::getByLabel(), and trackerHits::simHits.

119  {
121  e.getByLabel(inputSimHits_, simHits);
122  accumulate(simHits,e.bunchCrossing(),hre);
123  }
const edm::InputTag inputSimHits_
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre) override
handle SimHit accumulation
Definition: FTLDigitizer.h:108
template<class SensorPhysics , class ElectronicsSim >
void ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::accumulate ( edm::Handle< edm::PSimHitContainer > const &  hits,
int  bxCrossing,
CLHEP::HepRandomEngine *  hre 
)
overridevirtual

Implements FTLDigitizerBase.

Definition at line 126 of file FTLDigitizer.h.

References ALCARECOTkAlJpsiMuMu_cff::charge, TauDecayModes::dec, f, mps_fire::i, createfilelist::int, ftl_digitizer::FTLHelpers::orderByDetIdThenTime(), and HGCalUncalibRecHit_cfi::tdcOnset.

128  {
129  using namespace FTLHelpers;
130  //configuration to apply for the computation of time-of-flight
131  bool weightToAbyEnergy(false);
132  float tdcOnset(0.f);
133 
134  //create list of tuples (pos in container, RECO DetId, time) to be sorted first
135  int nchits=(int)hits->size();
136  std::vector< FTLCaloHitTuple_t > hitRefs;
137  hitRefs.reserve(nchits);
138  for(int i=0; i<nchits; ++i) {
139  const auto& the_hit = hits->at(i);
140 
141  DetId id = ( validIds_.count(the_hit.detUnitId()) ? the_hit.detUnitId() : 0 );
142 
143  if (verbosity_>0) {
144  edm::LogInfo("HGCDigitizer") << " i/p " << std::hex << the_hit.detUnitId() << std::dec
145  << " o/p " << id.rawId() << std::endl;
146  }
147 
148  if( 0 != id.rawId() ) {
149  hitRefs.emplace_back( i, id.rawId(), the_hit.tof() );
150  }
151  }
152  std::sort(hitRefs.begin(),hitRefs.end(),FTLHelpers::orderByDetIdThenTime);
153 
154  //loop over sorted hits
155  nchits = hitRefs.size();
156  for(int i=0; i<nchits; ++i) {
157  const int hitidx = std::get<0>(hitRefs[i]);
158  const uint32_t id = std::get<1>(hitRefs[i]);
159 
160  //get the data for this cell, if not available then we skip it
161 
162  if( !validIds_.count(id) ) continue;
163  auto simHitIt = simHitAccumulator_.emplace(id,FTLCellInfo()).first;
164 
165  if(id==0) continue; // to be ignored at RECO level
166 
167  const float toa = std::get<2>(hitRefs[i]);
168  const PSimHit &hit=hits->at( hitidx );
169  const float charge = deviceSim_.getChargeForHit(hit);
170 
171  //distance to the center of the detector
172  const float dist2center( 0.1f*hit.entryPoint().mag() );
173 
174  //hit time: [time()]=ns [centerDist]=cm [refSpeed_]=cm/ns + delay by 1ns
175  //accumulate in 15 buckets of 25ns (9 pre-samples, 1 in-time, 5 post-samples)
176  const float tof = toa-dist2center/refSpeed_+tofDelay_ ;
177  const int itime= std::floor( tof/bxTime_ ) + 9;
178 
179  //no need to add bx crossing - tof comes already corrected from the mixing module
180  //itime += bxCrossing;
181  //itime += 9;
182 
183  if(itime<0 || itime>14) continue;
184 
185  //check if time index is ok and store energy
186  if(itime >= (int)simHitIt->second.hit_info[0].size() ) continue;
187 
188  (simHitIt->second).hit_info[0][itime] += charge;
189  float accCharge=(simHitIt->second).hit_info[0][itime];
190 
191  //time-of-arrival (check how to be used)
192  if(weightToAbyEnergy) (simHitIt->second).hit_info[1][itime] += charge*tof;
193  else if((simHitIt->second).hit_info[1][itime]==0)
194  {
195  if( accCharge>tdcOnset )
196  {
197  //extrapolate linear using previous simhit if it concerns to the same DetId
198  float fireTDC=tof;
199  if(i>0)
200  {
201  uint32_t prev_id = std::get<1>(hitRefs[i-1]);
202  if(prev_id==id)
203  {
204  float prev_toa = std::get<2>(hitRefs[i-1]);
205  float prev_tof(prev_toa-dist2center/refSpeed_+tofDelay_);
206  //float prev_charge = std::get<3>(hitRefs[i-1]);
207  float deltaQ2TDCOnset = tdcOnset-((simHitIt->second).hit_info[0][itime]-charge);
208  float deltaQ = charge;
209  float deltaT = (tof-prev_tof);
210  fireTDC = deltaT*(deltaQ2TDCOnset/deltaQ)+prev_tof;
211  }
212  }
213 
214  (simHitIt->second).hit_info[1][itime]=fireTDC;
215  }
216  }
217  }
218  hitRefs.clear();
219  }
std::unordered_set< DetId > validIds_
Definition: FTLDigitizer.h:102
const float refSpeed_
double f[11][100]
const uint32_t verbosity_
FTLSimHitDataAccumulator simHitAccumulator_
Definition: FTLDigitizer.h:96
Definition: DetId.h:18
bool orderByDetIdThenTime(const FTLCaloHitTuple_t &a, const FTLCaloHitTuple_t &b)
Definition: FTLDigitizer.h:33
template<class SensorPhysics , class ElectronicsSim >
void ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::beginRun ( const edm::EventSetup es)
overridevirtual

actions at the start/end of run

Get DDD constants

Implements FTLDigitizerBase.

Definition at line 242 of file FTLDigitizer.h.

References edm::EventSetup::get(), edm::swap(), and ecaldqm::zside().

242  {
243  if ( idealGeomWatcher_.check(es) ) {
245  es.get<IdealGeometryRecord>().get(dddFTL_);
246  { // force scope for the temporary nameless unordered_set
247  std::unordered_set<DetId>().swap(validIds_);
248  }
249  // recalculate valid detids
250  for( int zside = -1; zside <= 1; zside += 2 ) {
251  for( unsigned type = 1; type <= 2; ++type ) {
252  for( unsigned izeta = 0; izeta < 1<<10; ++izeta ) {
253  for( unsigned iphi = 0; iphi < 1<<10; ++iphi ) {
254 
255  if( dddFTL_->isValidXY(type, izeta, iphi) ) {
256  validIds_.emplace( FastTimeDetId( type,
257  izeta,
258  iphi,
259  zside ) );
260  }
261 
262  }
263  }
264  }
265  }
266  validIds_.reserve(validIds_.size());
267  }
268  deviceSim_.getEventSetup(es);
269  electronicsSim_.getEventSetup(es);
270  }
type
Definition: HCALResponse.h:21
edm::ESHandle< FastTimeDDDConstants > dddFTL_
Definition: FTLDigitizer.h:104
ElectronicsSim electronicsSim_
Definition: FTLDigitizer.h:91
bool isValidXY(int type, int izeta, int iphi) const
edm::ESWatcher< IdealGeometryRecord > idealGeomWatcher_
Definition: FTLDigitizer.h:103
int zside(DetId const &)
std::unordered_set< DetId > validIds_
Definition: FTLDigitizer.h:102
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
const T & get() const
Definition: EventSetup.h:59
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
template<class SensorPhysics , class ElectronicsSim >
void ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::endRun ( )
inlineoverridevirtual

Implements FTLDigitizerBase.

Definition at line 81 of file FTLDigitizer.h.

81 {}
template<class SensorPhysics , class ElectronicsSim >
void ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::finalizeEvent ( edm::Event e,
edm::EventSetup const &  c,
CLHEP::HepRandomEngine *  hre 
)
overridevirtual

Implements FTLDigitizerBase.

Definition at line 228 of file FTLDigitizer.h.

References hgcalDigitizer_cfi::digiCollection, eostools::move(), and edm::Event::put().

229  {
230  auto digiCollection = std::make_unique<FTLDigiCollection>();
231 
233 
235 
236  //release memory for next event
238  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
ElectronicsSim electronicsSim_
Definition: FTLDigitizer.h:91
FTLSimHitDataAccumulator simHitAccumulator_
Definition: FTLDigitizer.h:96
const std::string digiCollection_
def move(src, dest)
Definition: eostools.py:510
template<class SensorPhysics , class ElectronicsSim >
void ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::initializeEvent ( edm::Event const &  e,
edm::EventSetup const &  c 
)
overridevirtual

actions at the start/end of event

Implements FTLDigitizerBase.

Definition at line 222 of file FTLDigitizer.h.

222  {
223  deviceSim_.getEvent(e);
224  electronicsSim_.getEvent(e);
225  }
ElectronicsSim electronicsSim_
Definition: FTLDigitizer.h:91
template<class SensorPhysics , class ElectronicsSim >
void ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::resetSimHitDataAccumulator ( )
inlineprivate

Definition at line 85 of file FTLDigitizer.h.

85  {
87  }
std::unordered_map< uint32_t, FTLCellInfo > FTLSimHitDataAccumulator
FTLSimHitDataAccumulator simHitAccumulator_
Definition: FTLDigitizer.h:96

Member Data Documentation

template<class SensorPhysics , class ElectronicsSim >
const double ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::bxTime_
private

Definition at line 95 of file FTLDigitizer.h.

template<class SensorPhysics , class ElectronicsSim >
edm::ESHandle<FastTimeDDDConstants> ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::dddFTL_
private

Definition at line 104 of file FTLDigitizer.h.

template<class SensorPhysics , class ElectronicsSim >
SensorPhysics ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::deviceSim_
private

Definition at line 90 of file FTLDigitizer.h.

template<class SensorPhysics , class ElectronicsSim >
ElectronicsSim ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::electronicsSim_
private

Definition at line 91 of file FTLDigitizer.h.

template<class SensorPhysics , class ElectronicsSim >
edm::ESWatcher<IdealGeometryRecord> ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::idealGeomWatcher_
private

Definition at line 103 of file FTLDigitizer.h.

template<class SensorPhysics , class ElectronicsSim >
const int ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::maxSimHitsAccTime_
private

Definition at line 94 of file FTLDigitizer.h.

template<class SensorPhysics , class ElectronicsSim >
FTLSimHitDataAccumulator ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::simHitAccumulator_
private

Definition at line 96 of file FTLDigitizer.h.

template<class SensorPhysics , class ElectronicsSim >
const float ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::tofDelay_
private

Definition at line 99 of file FTLDigitizer.h.

template<class SensorPhysics , class ElectronicsSim >
std::unordered_set<DetId> ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::validIds_
private

Definition at line 102 of file FTLDigitizer.h.