CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HGCDigitizerBase.cc
Go to the documentation of this file.
2 
3 using namespace hgc_digi;
4 
5 template<class DFr>
6 void HGCDigitizerBase<DFr>::run( std::auto_ptr<HGCDigitizerBase::DColl> &digiColl,
8  uint32_t digitizationType,
9  CLHEP::HepRandomEngine* engine) {
10  if(digitizationType==0) runSimple(digiColl,simData,engine);
11  else runDigitizer(digiColl,simData,digitizationType,engine);
12 }
13 
14 template<class DFr>
15 void HGCDigitizerBase<DFr>::runSimple(std::auto_ptr<HGCDigitizerBase::DColl> &coll,
16  HGCSimHitDataAccumulator &simData,
17  CLHEP::HepRandomEngine* engine) {
18  HGCSimHitData chargeColl,toa;
19  for(HGCSimHitDataAccumulator::iterator it=simData.begin();
20  it!=simData.end();
21  it++) {
22  chargeColl.fill(0.f);
23  toa.fill(0.f);
24  for(size_t i=0; i<it->second[0].size(); i++) {
25  double rawCharge((it->second)[0][i]);
26 
27  //time of arrival
28  toa[i]=(it->second)[1][i];
29  if(myFEelectronics_->toaMode()==HGCFEElectronics<DFr>::WEIGHTEDBYE && rawCharge>0)
30  toa[i]=(it->second)[1][i]/rawCharge;
31 
32  //convert total energy in GeV to charge (fC)
33  //double totalEn=rawEn*1e6*keV2fC_;
34  double totalCharge=rawCharge;
35 
36  //add noise (in fC)
37  //we assume it's randomly distributed and won't impact ToA measurement
38  totalCharge += std::max( CLHEP::RandGaussQ::shoot(engine,0,noise_fC_) , 0. );
39  if(totalCharge<0) totalCharge=0;
40 
41  chargeColl[i]= totalCharge;
42  }
43 
44  //run the shaper to create a new data frame
45  DFr rawDataFrame( it->first );
46  myFEelectronics_->runShaper(rawDataFrame, chargeColl, toa, engine);
47 
48  //update the output according to the final shape
49  updateOutput(coll,rawDataFrame);
50  }
51 }
52 
53 template<class DFr>
54 void HGCDigitizerBase<DFr>::updateOutput(std::auto_ptr<HGCDigitizerBase::DColl> &coll,
55  const DFr& rawDataFrame) {
56  int itIdx(9);
57  if(rawDataFrame.size()<=itIdx+2) return;
58 
59  DFr dataFrame( rawDataFrame.id() );
60  dataFrame.resize(5);
61  bool putInEvent(false);
62  HGCSample singleSample;
63  for(int it=0;it<5; it++) {
64  singleSample.set(rawDataFrame[itIdx-2+it].threshold(),
65  rawDataFrame[itIdx-2+it].mode(),
66  rawDataFrame[itIdx-2+it].toa(),
67  rawDataFrame[itIdx-2+it].data());
68  dataFrame.setSample(it, singleSample);
69  if(it==2) { putInEvent=rawDataFrame[itIdx-2+it].threshold(); }
70  }
71  if(putInEvent) coll->push_back(dataFrame);
72 }
73 
74 // cause the compiler to generate the appropriate code
int i
Definition: DBlmapReader.cc:9
void runSimple(std::auto_ptr< DColl > &coll, hgc::HGCSimHitDataAccumulator &simData, CLHEP::HepRandomEngine *engine)
a trivial digitization: sum energies and digitize without noise
wrapper for a data word
Definition: HGCSample.h:13
std::array< HGCSimData_t, nSamples > HGCSimHitData
double f[11][100]
void updateOutput(std::auto_ptr< DColl > &coll, const DFr &rawDataFrame)
prepares the output according to the number of time samples to produce
JetCorrectorParametersCollection coll
Definition: classes.h:10
void run(std::auto_ptr< DColl > &digiColl, hgc::HGCSimHitDataAccumulator &simData, uint32_t digitizationType, CLHEP::HepRandomEngine *engine)
steer digitization mode
models the behavior of the front-end electronics
std::unordered_map< uint32_t, std::array< HGCSimHitData, 2 > > HGCSimHitDataAccumulator
void set(bool thr, bool mode, uint16_t toa, uint16_t data)
Definition: HGCSample.h:33