CMS 3D CMS Logo

SimpleElectronicsSimInMIPs.cc
Go to the documentation of this file.
2 
4 
5 using namespace ftl;
6 
8  debug_( pset.getUntrackedParameter<bool>("debug",false) ),
9  adcNbits_( pset.getParameter<uint32_t>("adcNbits") ),
10  tdcNbits_( pset.getParameter<uint32_t>("tdcNbits") ),
11  adcSaturation_MIP_( pset.getParameter<double>("adcSaturation_MIP") ),
12  adcLSB_MIP_( adcSaturation_MIP_/std::pow(2.,adcNbits_) ),
13  adcThreshold_MIP_( pset.getParameter<double>("adcThreshold_MIP") ),
14  toaLSB_ns_( pset.getParameter<double>("toaLSB_ns")) {
15 }
16 
18  FTLDigiCollection& output) const {
19 
20  FTLSimHitData chargeColl,toa;
21 
22  for(FTLSimHitDataAccumulator::const_iterator it=input.begin();
23  it!=input.end();
24  it++) {
25 
26  chargeColl.fill(0.f);
27  toa.fill(0.f);
28  for(size_t i=0; i<it->second.hit_info[0].size(); i++) {
29  //time of arrival
30  float finalToA = (it->second).hit_info[1][i];
31  while(finalToA < 0.f) finalToA+=25.f;
32  while(finalToA > 25.f) finalToA-=25.f;
33  toa[i]=finalToA;
34 
35  // collected charge (in this case in MIPs)
36  chargeColl[i] = (it->second).hit_info[0][i];
37  }
38 
39  //run the shaper to create a new data frame
40  FTLDataFrame rawDataFrame( it->first );
41  runTrivialShaper(rawDataFrame,chargeColl,toa);
42  updateOutput(output,rawDataFrame);
43 
44  }
45 
46 }
47 
48 
50  const ftl::FTLSimHitData& chargeColl,
51  const ftl::FTLSimHitData& toa) const {
52  bool debug = debug_;
53 #ifdef EDM_ML_DEBUG
54  for(int it=0; it<(int)(chargeColl.size()); it++) debug |= (chargeColl[it]>adcThreshold_fC_);
55 #endif
56 
57  if(debug) edm::LogVerbatim("FTLSimpleElectronicsSimInMIPs") << "[runTrivialShaper]" << std::endl;
58 
59  //set new ADCs
60  for(int it=0; it<(int)(chargeColl.size()); it++)
61  {
62  //brute force saturation, maybe could to better with an exponential like saturation
63  const uint32_t adc=std::floor( std::min(chargeColl[it],adcSaturation_MIP_) / adcLSB_MIP_ );
64  const uint32_t tdc_time=std::floor( toa[it] / toaLSB_ns_ );
65  FTLSample newSample;
66  newSample.set(chargeColl[it] > adcThreshold_MIP_,false,tdc_time,adc);
67  dataFrame.setSample(it,newSample);
68 
69  if(debug) edm::LogVerbatim("FTLSimpleElectronicsSimInMIPs") << adc << " (" << chargeColl[it] << "/" << adcLSB_MIP_ << ") ";
70  }
71 
72  if(debug) {
73  std::ostringstream msg;
74  dataFrame.print(msg);
75  edm::LogVerbatim("FTLSimpleElectronicsSimInMIPs") << msg.str() << std::endl;
76  }
77 }
78 
80  const FTLDataFrame& rawDataFrame) const {
81  int itIdx(9);
82  if(rawDataFrame.size()<=itIdx+2) return;
83 
84  FTLDataFrame dataFrame( rawDataFrame.id() );
85  dataFrame.resize(5);
86  bool putInEvent(false);
87  for(int it=0;it<5; ++it) {
88  dataFrame.setSample(it, rawDataFrame[itIdx-2+it]);
89  if(it==2) putInEvent = rawDataFrame[itIdx-2+it].threshold();
90  }
91 
92  if(putInEvent) {
93  coll.push_back(dataFrame);
94  }
95 }
int adc(sample_type sample)
get the ADC sample (12 bits)
std::array< FTLSimData_t, nSamples > FTLSimHitData
void print(std::ostream &out=std::cout)
Definition: FTLDataFrameT.h:50
void push_back(T const &t)
const D & id() const
det id
Definition: FTLDataFrameT.h:32
wrapper for a data word
Definition: FTLSample.h:13
std::unordered_map< uint32_t, FTLCellInfo > FTLSimHitDataAccumulator
static std::string const input
Definition: EdmProvDump.cc:45
void run(const ftl::FTLSimHitDataAccumulator &input, FTLDigiCollection &output) const
void resize(size_t s)
allow to set size
Definition: FTLDataFrameT.h:42
void setSample(int i, const S &sample)
Definition: FTLDataFrameT.h:49
double f[11][100]
void updateOutput(FTLDigiCollection &coll, const FTLDataFrame &rawDataFrame) const
T min(T a, T b)
Definition: MathUtil.h:58
#define debug
Definition: HDRShower.cc:19
JetCorrectorParametersCollection coll
Definition: classes.h:10
int size() const
total number of samples in the digi
Definition: FTLDataFrameT.h:37
tuple msg
Definition: mps_check.py:278
void runTrivialShaper(FTLDataFrame &dataFrame, const ftl::FTLSimHitData &chargeColl, const ftl::FTLSimHitData &toa) const
void set(bool thr, bool mode, uint16_t toa, uint16_t data)
Definition: FTLSample.h:34
SimpleElectronicsSimInMIPs(const edm::ParameterSet &pset)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40