CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HGCHEbackDigitizer.cc
Go to the documentation of this file.
2 #include "CLHEP/Random/RandPoissonQ.h"
3 #include "CLHEP/Random/RandGaussQ.h"
4 
5 //
7  try{
8  edm::ParameterSet caliceSpec = ps.getParameter<edm::ParameterSet>("digiCfg").getParameter<edm::ParameterSet>("caliceSpecific");
9  nPEperMIP_ = caliceSpec.getParameter<double>("nPEperMIP");
10  nTotalPE_ = caliceSpec.getParameter<double>("nTotalPE");
11  xTalk_ = caliceSpec.getParameter<double>("xTalk");
12  sdPixels_ = caliceSpec.getParameter<double>("sdPixels");
13  }catch(std::exception &e){
14  //no need to propagate
15  }
16 }
17 
18 //
19 void HGCHEbackDigitizer::runDigitizer(std::auto_ptr<HGCHEDigiCollection> &digiColl,HGCSimHitDataAccumulator &simData,uint32_t digitizationType, CLHEP::HepRandomEngine* engine) {
20  switch(digitizationType) {
21  case 1:
22  {
23  runCaliceLikeDigitizer(digiColl,simData,engine);
24  break;
25  }
26  }
27 }
28 
29 //
30 void HGCHEbackDigitizer::runCaliceLikeDigitizer(std::auto_ptr<HGCHEDigiCollection> &digiColl,HGCSimHitDataAccumulator &simData, CLHEP::HepRandomEngine* engine) {
31 
32  for(HGCSimHitDataAccumulator::iterator it=simData.begin();
33  it!=simData.end(); it++) {
34  //init a new data frame
35  HGCHEDataFrame newDataFrame( it->first );
36 
37  for(size_t i=0; i<it->second.size(); i++) {
38  //convert total energy GeV->keV->ADC counts
39  float totalEn( (it->second)[i]*1e6 );
40 
41  //convert energy to MIP
42  float totalIniMIPs = totalEn/mipInKeV_;
43 
44  //generate random number of photon electrons
45  CLHEP::RandPoissonQ randPoissonQ(*engine, totalIniMIPs*nPEperMIP_);
46  uint32_t npe = (uint32_t)randPoissonQ.fire();
47 
48  //number of pixels
49  float x=exp(-(float)(npe)/(float)(nTotalPE_));
50  uint32_t nPixel(0);
51  if(xTalk_*x!=1) nPixel=(uint32_t) std::max( float(nTotalPE_*(1-x)/(1-xTalk_*x)), float(0.) );
52 
53  //update signal
54  nPixel=(uint32_t)std::max( float(CLHEP::RandGaussQ::shoot(engine,(float)nPixel,(float)sdPixels_)),float(0.) );
55 
56  //convert to MIP again and saturate
57  float totalMIPs(totalIniMIPs);
58  if(nTotalPE_!=nPixel && (nTotalPE_-xTalk_*nPixel)/(nTotalPE_-nPixel)>0 )
59  totalMIPs = (nTotalPE_/nPEperMIP_)*log((nTotalPE_-xTalk_*nPixel)/(nTotalPE_-nPixel));
60  else
61  totalMIPs = 0;
62 
63  //add noise (in MIPs)
64  double noiseMIPs=CLHEP::RandGaussQ::shoot(engine,0.,1./mip2noise_);
65  totalMIPs=std::max(float(totalMIPs+noiseMIPs),float(0.));
66 
67  //round to integer (sample will saturate the value according to available bits)
68  uint16_t totalEnInt = floor( totalMIPs / lsbInMIP_ );
69 
70  //0 gain for the moment
71  HGCSample singleSample;
72  singleSample.set(0, totalEnInt );
73  newDataFrame.setSample(i, singleSample);
74 
75  }
76 
77  //run shaper
78  runShaper(newDataFrame);
79 
80  //prepare the output
81  updateOutput(digiColl,newDataFrame);
82  }
83 }
84 
85 //
87 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void set(uint16_t gain, uint16_t adc)
Definition: HGCSample.h:30
wrapper for a data word
Definition: HGCSample.h:12
HGCHEbackDigitizer(const edm::ParameterSet &ps)
void runCaliceLikeDigitizer(std::auto_ptr< HGCHEDigiCollection > &digiColl, HGCSimHitDataAccumulator &simData, CLHEP::HepRandomEngine *engine)
void runDigitizer(std::auto_ptr< HGCHEDigiCollection > &digiColl, HGCSimHitDataAccumulator &simData, uint32_t digitizationType, CLHEP::HepRandomEngine *engine)
void setSample(int i, const S &sample)
Definition: HGCDataFrame.h:47
std::unordered_map< uint32_t, HGCSimHitData > HGCSimHitDataAccumulator
void runShaper(HGCHEDataFrame &dataFrame)
applies a shape to each time sample and propagates the tails to the subsequent time samples ...
void updateOutput(std::auto_ptr< DColl > &coll, HGCHEDataFramerawDataFrame)
prepares the output according to the number of time samples to produce
tuple log
Definition: cmsBatch.py:341