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::stream::EDProducerBase &parent)
 
void initializeEvent (edm::Event const &e, edm::EventSetup const &c) override
 actions at the start/end of event More...
 
virtual ~FTLDigitizer ()
 
- Public Member Functions inherited from FTLDigitizerBase
 FTLDigitizerBase (const edm::ParameterSet &config, edm::ConsumesCollector &iC, edm::stream::EDProducerBase &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 57 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::stream::EDProducerBase parent 
)
inline

Definition at line 61 of file FTLDigitizer.h.

63  :
64  FTLDigitizerBase(config,iC,parent),
65  deviceSim_( config.getParameterSet("DeviceSimulation") ),
66  electronicsSim_( config.getParameterSet("ElectronicsSimulation") ),
67  maxSimHitsAccTime_( config.getParameter< uint32_t >("maxSimHitsAccTime") ),
68  bxTime_( config.getParameter< double >("bxTime") ),
69  tofDelay_( config.getParameter< double >("tofDelay") ) { }
FTLDigitizerBase(const edm::ParameterSet &config, edm::ConsumesCollector &iC, edm::stream::EDProducerBase &parent)
T getParameter(std::string const &) const
ElectronicsSim electronicsSim_
Definition: FTLDigitizer.h:100
ParameterSet const & getParameterSet(std::string const &) const
template<class SensorPhysics , class ElectronicsSim >
virtual ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::~FTLDigitizer ( )
inlinevirtual

Definition at line 71 of file FTLDigitizer.h.

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

71 { }

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 117 of file FTLDigitizer.h.

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

119  {
121  e.getByLabel(inputSimHits_, simHits);
122  accumulate(simHits,0,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:117
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 126 of file FTLDigitizer.h.

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

128  {
130  e.getByLabel(inputSimHits_, simHits);
131  accumulate(simHits,e.bunchCrossing(),hre);
132  }
const edm::InputTag inputSimHits_
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *hre) override
handle SimHit accumulation
Definition: FTLDigitizer.h:117
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 135 of file FTLDigitizer.h.

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

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

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

251  {
252  if ( idealGeomWatcher_.check(es) ) {
254  es.get<IdealGeometryRecord>().get(dddFTL_);
255  { // force scope for the temporary nameless unordered_set
256  std::unordered_set<DetId>().swap(validIds_);
257  }
258  // recalculate valid detids
259  for( int zside = -1; zside <= 1; zside += 2 ) {
260  for( unsigned type = 1; type <= 2; ++type ) {
261  for( unsigned izeta = 0; izeta < 1<<10; ++izeta ) {
262  for( unsigned iphi = 0; iphi < 1<<10; ++iphi ) {
263 
264  if( dddFTL_->isValidXY(type, izeta, iphi) ) {
265  validIds_.emplace( FastTimeDetId( type,
266  izeta,
267  iphi,
268  zside ) );
269  }
270 
271  }
272  }
273  }
274  }
275  validIds_.reserve(validIds_.size());
276  }
277  deviceSim_.getEventSetup(es);
278  electronicsSim_.getEventSetup(es);
279  }
type
Definition: HCALResponse.h:21
edm::ESHandle< FastTimeDDDConstants > dddFTL_
Definition: FTLDigitizer.h:113
ElectronicsSim electronicsSim_
Definition: FTLDigitizer.h:100
bool isValidXY(int type, int izeta, int iphi) const
edm::ESWatcher< IdealGeometryRecord > idealGeomWatcher_
Definition: FTLDigitizer.h:112
std::unordered_set< DetId > validIds_
Definition: FTLDigitizer.h:111
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
const T & get() const
Definition: EventSetup.h:56
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 90 of file FTLDigitizer.h.

90 {}
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 237 of file FTLDigitizer.h.

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

238  {
239  auto digiCollection = std::make_unique<FTLDigiCollection>();
240 
242 
244 
245  //release memory for next event
247  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
ElectronicsSim electronicsSim_
Definition: FTLDigitizer.h:100
FTLSimHitDataAccumulator simHitAccumulator_
Definition: FTLDigitizer.h:105
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 231 of file FTLDigitizer.h.

231  {
232  deviceSim_.getEvent(e);
233  electronicsSim_.getEvent(e);
234  }
ElectronicsSim electronicsSim_
Definition: FTLDigitizer.h:100
template<class SensorPhysics , class ElectronicsSim >
void ftl_digitizer::FTLDigitizer< SensorPhysics, ElectronicsSim >::resetSimHitDataAccumulator ( )
inlineprivate

Definition at line 94 of file FTLDigitizer.h.

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

Member Data Documentation

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

Definition at line 104 of file FTLDigitizer.h.

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

Definition at line 113 of file FTLDigitizer.h.

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

Definition at line 99 of file FTLDigitizer.h.

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

Definition at line 100 of file FTLDigitizer.h.

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

Definition at line 112 of file FTLDigitizer.h.

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

Definition at line 103 of file FTLDigitizer.h.

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

Definition at line 105 of file FTLDigitizer.h.

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

Definition at line 108 of file FTLDigitizer.h.

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

Definition at line 111 of file FTLDigitizer.h.