CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CSCStripElectronicsSim Class Reference

#include <CSCStripElectronicsSim.h>

Inheritance diagram for CSCStripElectronicsSim:
CSCBaseElectronicsSim

Public Member Functions

void createDigi (int istrip, const CSCAnalogSignal &signal, std::vector< CSCStripDigi > &result, CLHEP::HepRandomEngine *)
 
 CSCStripElectronicsSim (const edm::ParameterSet &p)
 configurable parameters More...
 
void fillDigis (CSCStripDigiCollection &digis, CSCComparatorDigiCollection &comparators, CLHEP::HepRandomEngine *)
 
void fillMissingLayer (const CSCLayer *layer, const CSCComparatorDigiCollection &comparators, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *)
 
CSCAnalogSignal makeNoiseSignal (int element, CLHEP::HepRandomEngine *) override
 
void setStripConditions (CSCStripConditions *cond)
 
 ~CSCStripElectronicsSim () override
 
- Public Member Functions inherited from CSCBaseElectronicsSim
const DigiSimLinksdigiSimLinks () const
 
void setLayerId (const CSCDetId &id)
 for standalone apps who don't calculate it from the geometry More...
 
void simulate (const CSCLayer *layer, const std::vector< CSCDetectorHit > &inputHits, CLHEP::HepRandomEngine *)
 
virtual ~CSCBaseElectronicsSim ()
 

Private Member Functions

void addCrosstalk (CLHEP::HepRandomEngine *)
 
void addCrosstalk (const CSCAnalogSignal &signal, int thisStrip, int otherStrip, CLHEP::HepRandomEngine *)
 
float calculateAmpResponse (float t) const override
 
std::list< int > channelsToRead (const std::list< int > &keyStrips, int window) const
 
float comparatorReading (const CSCAnalogSignal &signal, float time, CLHEP::HepRandomEngine *) const
 calculates the comparator reading, including saturation and offsets More...
 
void doSaturation (CSCStripDigi &digi)
 
void fillStripDigis (const std::list< int > &keyStrips, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *)
 
std::list< int > getKeyStrips (const std::vector< CSCComparatorDigi > &comparators) const
 finds the key strips from these comparators More...
 
std::list< int > getKeyStripsFromMC () const
 get ths strips that have detector hits More...
 
void getReadoutRange (int inputStrip, int &minStrip, int &maxStrip)
 
void initParameters () override
 initialization for each layer More...
 
int readoutElement (int strip) const override
 
void runComparator (std::vector< CSCComparatorDigi > &result, CLHEP::HepRandomEngine *)
 
void selfTest () const
 

Private Attributes

bool doCrosstalk_
 
bool doSuppression_
 
int nScaBins_
 
int sca_peak_bin
 
float sca_time_bin_size
 
CSCStripAmpResponse theAmpResponse
 
float theAverageTimeOfFlight
 
int theComparatorClockJump
 
float theComparatorDeadTime
 
float theComparatorNoise
 
float theComparatorRMSOffset
 
double theComparatorSamplingTime
 
float theComparatorSaturation
 
float theComparatorThreshold
 
double theComparatorTimeBinOffset
 
double theComparatorTimeOffset
 
float theComparatorWait
 
CSCCrosstalkGeneratortheCrosstalkGenerator
 
float theDaqDeadTime
 
std::vector< double > theSCATimingOffsets
 
CSCStripConditionstheStripConditions
 
float theTimingOffset
 

Additional Inherited Members

- Public Types inherited from CSCBaseElectronicsSim
typedef std::map< int, CSCAnalogSignal, std::less< int > > CSCSignalMap
 
typedef edm::DetSet< StripDigiSimLinkDigiSimLinks
 
- Protected Types inherited from CSCBaseElectronicsSim
enum  { NONE, CONSERVATIVE, RADICAL }
 
typedef std::multimap< int, CSCDetectorHit, std::less< int > > DetectorHitMap
 
- Protected Member Functions inherited from CSCBaseElectronicsSim
CSCAnalogSignaladd (const CSCAnalogSignal &, CLHEP::HepRandomEngine *)
 
virtual void addLinks (int channelIndex)
 
void addNoise (CLHEP::HepRandomEngine *)
 
CSCAnalogSignal amplifySignal (const CSCDetectorHit &)
 
double averageTimeOfFlight (const DetId &detId) const
 
virtual int channelIndex (int channel) const
 lets users map channels to different indices for links More...
 
void combineAnalogSignals (const std::vector< CSCAnalogSignal > &)
 
 CSCBaseElectronicsSim (const edm::ParameterSet &p)
 
void fillAmpResponse ()
 
CSCAnalogSignalfind (int element, CLHEP::HepRandomEngine *)
 
CSCDetId layerId () const
 the CSCDetId corresponding to the current layer More...
 
void setLayer (const CSCLayer *layer)
 
void setNoise (float rmsNoise, float noiseSigmaThreshold)
 
void setSignalTimeRange (double startTime, double stopTime)
 
virtual float signalDelay (int element, float pos) const
 
- Protected Attributes inherited from CSCBaseElectronicsSim
bool doNoise_
 
int nElements
 
CSCAnalogSignal theAmpResponse
 
float theBunchSpacing
 
std::vector< double > theBunchTimingOffsets
 
DetectorHitMap theDetectorHitMap
 
DigiSimLinks theDigiSimLinks
 
const CSCLayertheLayer
 
const CSCLayerGeometrytheLayerGeometry
 
CSCDetId theLayerId
 
bool theNoiseWasAdded
 
int theNumberOfSamples
 
int theOffsetOfBxZero
 
float thePeakTimeSigma
 
float theSamplingTime
 
int theShapingTime
 
CSCSignalMap theSignalMap
 
std::vector< double > theSignalPropagationSpeed
 
float theSignalStartTime
 
float theSignalStopTime
 
const CSCChamberSpecstheSpecs
 
std::vector< double > theTimingCalibrationError
 

Detailed Description

Model the readout electronics chain for EMU CSC strips

Author
Rick Wilkinson

Definition at line 28 of file CSCStripElectronicsSim.h.

Constructor & Destructor Documentation

◆ CSCStripElectronicsSim()

CSCStripElectronicsSim::CSCStripElectronicsSim ( const edm::ParameterSet p)
explicit

configurable parameters

Definition at line 25 of file CSCStripElectronicsSim.cc.

References doCrosstalk_, CSCBaseElectronicsSim::fillAmpResponse(), and theCrosstalkGenerator.

32  theComparatorWait(50.),
34  theDaqDeadTime(200.),
35  theTimingOffset(0.),
36  nScaBins_(p.getParameter<int>("nScaBins")),
37  doSuppression_(p.getParameter<bool>("doSuppression")),
38  doCrosstalk_(p.getParameter<bool>("doCrosstalk")),
39  theStripConditions(nullptr),
40  theCrosstalkGenerator(nullptr),
42  sca_time_bin_size(50.),
43  sca_peak_bin(p.getParameter<int>("scaPeakBin")),
44  theComparatorTimeBinOffset(p.getParameter<double>("comparatorTimeBinOffset")),
45  theComparatorTimeOffset(p.getParameter<double>("comparatorTimeOffset")),
46  theComparatorSamplingTime(p.getParameter<double>("comparatorSamplingTime")),
47  theSCATimingOffsets(p.getParameter<std::vector<double>>("scaTimingOffsets")) {
48  if (doCrosstalk_) {
50  }
51 
53 }
CSCBaseElectronicsSim(const edm::ParameterSet &p)
CSCStripConditions * theStripConditions
std::vector< double > theSCATimingOffsets
CSCCrosstalkGenerator * theCrosstalkGenerator
CSCStripAmpResponse theAmpResponse

◆ ~CSCStripElectronicsSim()

CSCStripElectronicsSim::~CSCStripElectronicsSim ( )
override

Definition at line 55 of file CSCStripElectronicsSim.cc.

References doCrosstalk_, and theCrosstalkGenerator.

55  {
56  if (doCrosstalk_) {
57  delete theCrosstalkGenerator;
58  }
59 }
CSCCrosstalkGenerator * theCrosstalkGenerator

Member Function Documentation

◆ addCrosstalk() [1/2]

void CSCStripElectronicsSim::addCrosstalk ( CLHEP::HepRandomEngine *  engine)
private

Definition at line 322 of file CSCStripElectronicsSim.cc.

References CSCBaseElectronicsSim::nElements, jetUpdater_cfi::sort, SortSignalsByTotal(), and CSCBaseElectronicsSim::theSignalMap.

Referenced by fillDigis().

322  {
323  // this is needed so we can add a noise signal to the map
324  // without messing up any iterators
325  std::vector<CSCAnalogSignal> realSignals;
326  realSignals.reserve(theSignalMap.size());
327  CSCSignalMap::iterator mapI = theSignalMap.begin(), mapEnd = theSignalMap.end();
328  for (; mapI != mapEnd; ++mapI) {
329  realSignals.push_back((*mapI).second);
330  }
331  sort(realSignals.begin(), realSignals.end(), SortSignalsByTotal);
332  std::vector<CSCAnalogSignal>::iterator realSignalItr = realSignals.begin(), realSignalsEnd = realSignals.end();
333  for (; realSignalItr != realSignalsEnd; ++realSignalItr) {
334  int thisStrip = (*realSignalItr).getElement();
335  // add it to each neighbor
336  if (thisStrip > 1) {
337  int otherStrip = thisStrip - 1;
338  addCrosstalk(*realSignalItr, thisStrip, otherStrip, engine);
339  }
340  if (thisStrip < nElements) {
341  int otherStrip = thisStrip + 1;
342  addCrosstalk(*realSignalItr, thisStrip, otherStrip, engine);
343  }
344  }
345 }
bool SortSignalsByTotal(const CSCAnalogSignal &s1, const CSCAnalogSignal &s2)
void addCrosstalk(CLHEP::HepRandomEngine *)

◆ addCrosstalk() [2/2]

void CSCStripElectronicsSim::addCrosstalk ( const CSCAnalogSignal signal,
int  thisStrip,
int  otherStrip,
CLHEP::HepRandomEngine *  engine 
)
private

Definition at line 347 of file CSCStripElectronicsSim.cc.

References CSCStripConditions::crosstalk(), CSCBaseElectronicsSim::find(), CSCCrosstalkGenerator::getCrosstalk(), CSCBaseElectronicsSim::layerId(), TrapezoidalPlaneBounds::length(), readoutElement(), CSCCrosstalkGenerator::setParameters(), CSCAnalogSignal::superimpose(), theCrosstalkGenerator, CSCBaseElectronicsSim::theLayerGeometry, and theStripConditions.

350  {
351  float capacitiveCrosstalk, resistiveCrosstalk;
352  bool leftRight = (otherStrip > thisStrip);
354  layerId(), thisStrip, theLayerGeometry->length(), leftRight, capacitiveCrosstalk, resistiveCrosstalk);
355  theCrosstalkGenerator->setParameters(capacitiveCrosstalk, 0., resistiveCrosstalk);
356  CSCAnalogSignal crosstalkSignal(theCrosstalkGenerator->getCrosstalk(signal));
357  find(readoutElement(otherStrip), engine).superimpose(crosstalkSignal);
358 
359  // Now subtract the crosstalk signal from the original signal
360  crosstalkSignal *= -1.;
361  find(thisStrip, engine).superimpose(crosstalkSignal);
362 }
CSCAnalogSignal getCrosstalk(const CSCAnalogSignal &inputSignal) const
const CSCLayerGeometry * theLayerGeometry
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
virtual void crosstalk(const CSCDetId &detId, int channel, double stripLength, bool leftRight, float &capacitive, float &resistive) const =0
int readoutElement(int strip) const override
CSCStripConditions * theStripConditions
CSCCrosstalkGenerator * theCrosstalkGenerator
void superimpose(const CSCAnalogSignal &signal2)
float length() const override
void setParameters(float crosstalk, float delay, float resistiveFraction)
CSCAnalogSignal & find(int element, CLHEP::HepRandomEngine *)

◆ calculateAmpResponse()

float CSCStripElectronicsSim::calculateAmpResponse ( float  t) const
overrideprivatevirtual

◆ channelsToRead()

std::list< int > CSCStripElectronicsSim::channelsToRead ( const std::list< int > &  keyStrips,
int  window 
) const
private

finds what strips to read. Will either take 5 strips around the keystrip, or the whole CFEB, based on doSuppression_

Definition at line 240 of file CSCStripElectronicsSim.cc.

References doSuppression_, mps_fire::i, CSCBaseElectronicsSim::nElements, readoutElement(), mps_fire::result, and svgfig::window().

Referenced by fillStripDigis(), and selfTest().

240  {
241  std::list<int> result;
242  std::list<int>::const_iterator keyStripItr = keyStrips.begin();
243  if (doSuppression_) {
244  for (; keyStripItr != keyStrips.end(); ++keyStripItr) {
245  // pick the five strips around the comparator
246  for (int istrip = (*keyStripItr) - window; istrip <= (*keyStripItr) + window; ++istrip) {
247  if (istrip > 0 && istrip <= nElements) {
248  result.push_back(readoutElement(istrip));
249  }
250  }
251  }
252  result.sort();
253  result.unique();
254  } else {
255  // read the whole CFEB, 16 strips
256  std::list<int> cfebsToRead;
257  for (; keyStripItr != keyStrips.end(); ++keyStripItr) {
258  int cfeb = (readoutElement(*keyStripItr) - 1) / 16;
259  cfebsToRead.push_back(cfeb);
260  int remainder = (readoutElement(*keyStripItr) - 1) % 16;
261  // if we're within 3 strips of an edge, take neighboring CFEB, too
262  if (remainder < window && cfeb != 0) {
263  cfebsToRead.push_back(cfeb - 1);
264  }
265  // the 'readouElement' makes it so that ME1/1 has just one CFEB
266  int maxCFEBs = readoutElement(nElements) / 16 - 1;
267  if (remainder >= 16 - window && cfeb != maxCFEBs) {
268  cfebsToRead.push_back(cfeb + 1);
269  }
270  }
271  cfebsToRead.sort();
272  cfebsToRead.unique();
273 
274  // now convert the CFEBS to strips
275  for (std::list<int>::const_iterator cfebItr = cfebsToRead.begin(); cfebItr != cfebsToRead.end(); ++cfebItr) {
276  for (int i = 1; i <= 16; ++i) {
277  result.push_back((*cfebItr) * 16 + i);
278  }
279  }
280  }
281  return result;
282 }
int readoutElement(int strip) const override
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:643

◆ comparatorReading()

float CSCStripElectronicsSim::comparatorReading ( const CSCAnalogSignal signal,
float  time,
CLHEP::HepRandomEngine *  engine 
) const
private

calculates the comparator reading, including saturation and offsets

Definition at line 96 of file CSCStripElectronicsSim.cc.

References CSCAnalogSignal::getValue(), SiStripPI::min, theComparatorRMSOffset, theComparatorSaturation, and hcalRecHitTable_cff::time.

Referenced by runComparator().

98  {
100  theComparatorRMSOffset * CLHEP::RandGaussQ::shoot(engine);
101 }
float getValue(float t) const

◆ createDigi()

void CSCStripElectronicsSim::createDigi ( int  istrip,
const CSCAnalogSignal signal,
std::vector< CSCStripDigi > &  result,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 364 of file CSCStripElectronicsSim.cc.

References CSCBaseElectronicsSim::addLinks(), CSCChamberSpecs::chamberType(), nano_mu_digi_cff::chamberType, CSCBaseElectronicsSim::channelIndex(), doSaturation(), PedestalClient_cfi::gain, CSCAnalogSignal::getValue(), CSCBaseElectronicsSim::layerId(), LogTrace, nScaBins_, CSCStripConditions::pedestal(), EcalCondDBWriter_cfi::pedestal, mps_fire::result, sca_time_bin_size, CSCStripConditions::smearedGain(), submitPVValidationJobs::t, FrontierCondition_GT_autoExpress_cfi::t0, theAverageTimeOfFlight, theSCATimingOffsets, CSCBaseElectronicsSim::theSignalStartTime, CSCBaseElectronicsSim::theSpecs, theStripConditions, CSCBaseElectronicsSim::theTimingCalibrationError, and hcalSimParameters_cfi::timeSmearing.

Referenced by fillStripDigis().

367  {
368  // fill in the sca information
369  std::vector<int> scaCounts(nScaBins_);
370 
371  float pedestal = theStripConditions->pedestal(layerId(), channel);
372  float gain = theStripConditions->smearedGain(layerId(), channel, engine);
374  float timeSmearing = CLHEP::RandGaussQ::shoot(engine) * theTimingCalibrationError[chamberType];
375  // undo the correction for TOF, instead, using some nominal
376  // value from ME2/1
378  for (int scaBin = 0; scaBin < nScaBins_; ++scaBin) {
379  float t = t0 + scaBin * sca_time_bin_size;
380  scaCounts[scaBin] = static_cast<int>(pedestal + signal.getValue(t) * gain);
381  }
382  CSCStripDigi newDigi(channel, scaCounts);
383 
384  // do saturation of 12-bit ADC
385  doSaturation(newDigi);
386 
387  result.push_back(newDigi);
388  addLinks(channelIndex(channel));
389  LogTrace("CSCStripElectronicsSim") << "CSCStripElectronicsSim: CSCStripDigi " << newDigi;
390 }
int chamberType() const
const CSCChamberSpecs * theSpecs
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
virtual float pedestal(const CSCDetId &detId, int channel) const =0
in ADC counts
#define LogTrace(id)
CSCStripConditions * theStripConditions
std::vector< double > theSCATimingOffsets
void doSaturation(CSCStripDigi &digi)
virtual void addLinks(int channelIndex)
float getValue(float t) const
virtual float smearedGain(const CSCDetId &detId, int channel, CLHEP::HepRandomEngine *) const
std::vector< double > theTimingCalibrationError
virtual int channelIndex(int channel) const
lets users map channels to different indices for links

◆ doSaturation()

void CSCStripElectronicsSim::doSaturation ( CSCStripDigi digi)
private

Definition at line 392 of file CSCStripElectronicsSim.cc.

References CSCStripDigi::getADCCounts(), SiStripPI::min, and CSCStripDigi::setADCCounts().

Referenced by createDigi().

392  {
393  std::vector<int> scaCounts(digi.getADCCounts());
394  for (unsigned scaBin = 0; scaBin < scaCounts.size(); ++scaBin) {
395  scaCounts[scaBin] = std::min(scaCounts[scaBin], 4095);
396  }
397  digi.setADCCounts(scaCounts);
398 }
void setADCCounts(const std::vector< int > &ADCCounts)
Definition: CSCStripDigi.cc:27
std::vector< int > const & getADCCounts() const
Get ADC readings.
Definition: CSCStripDigi.h:47

◆ fillDigis()

void CSCStripElectronicsSim::fillDigis ( CSCStripDigiCollection digis,
CSCComparatorDigiCollection comparators,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 288 of file CSCStripElectronicsSim.cc.

References addCrosstalk(), doCrosstalk_, fillStripDigis(), getKeyStripsFromMC(), CSCBaseElectronicsSim::layerId(), FastTimerService_cff::range, and runComparator().

Referenced by CSCDigitizer::doAction().

290  {
291  if (doCrosstalk_) {
292  addCrosstalk(engine);
293  }
294 
295  std::vector<CSCComparatorDigi> comparatorOutputs;
296  runComparator(comparatorOutputs, engine);
297  // copy these to the result
298  if (!comparatorOutputs.empty()) {
299  CSCComparatorDigiCollection::Range range(comparatorOutputs.begin(), comparatorOutputs.end());
300  comparators.put(range, layerId());
301  }
302 
303  // std::list<int> keyStrips = getKeyStrips(comparatorOutputs);
304  std::list<int> keyStrips = getKeyStripsFromMC();
305  fillStripDigis(keyStrips, digis, engine);
306 }
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
void addCrosstalk(CLHEP::HepRandomEngine *)
void runComparator(std::vector< CSCComparatorDigi > &result, CLHEP::HepRandomEngine *)
std::list< int > getKeyStripsFromMC() const
get ths strips that have detector hits
std::pair< const_iterator, const_iterator > Range
void fillStripDigis(const std::list< int > &keyStrips, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *)

◆ fillMissingLayer()

void CSCStripElectronicsSim::fillMissingLayer ( const CSCLayer layer,
const CSCComparatorDigiCollection comparators,
CSCStripDigiCollection digis,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 400 of file CSCStripElectronicsSim.cc.

References CSCDetId::chamberId(), fillStripDigis(), getKeyStrips(), nano_mu_digi_cff::layer, CSCBaseElectronicsSim::setLayer(), CSCBaseElectronicsSim::theLayerId, and CSCBaseElectronicsSim::theSignalMap.

Referenced by CSCDigitizer::doAction().

403  {
404  theSignalMap.clear();
405  setLayer(layer);
406  CSCDetId chamberId(theLayerId.chamberId());
407  // find all comparator key strips in this chamber
408  std::list<int> chamberKeyStrips;
409  for (CSCComparatorDigiCollection::DigiRangeIterator comparatorItr = comparators.begin();
410  comparatorItr != comparators.end();
411  ++comparatorItr) {
412  // could be more efficient
413  if (CSCDetId((*comparatorItr).first).chamberId() == chamberId) {
414  std::vector<CSCComparatorDigi> layerComparators((*comparatorItr).second.first, (*comparatorItr).second.second);
415  std::list<int> layerKeyStrips = getKeyStrips(layerComparators);
416  chamberKeyStrips.insert(chamberKeyStrips.end(), layerKeyStrips.begin(), layerKeyStrips.end());
417  }
418  }
419  chamberKeyStrips.sort();
420  chamberKeyStrips.unique();
421  fillStripDigis(chamberKeyStrips, digis, engine);
422 }
void setLayer(const CSCLayer *layer)
CSCDetId chamberId() const
Definition: CSCDetId.h:47
std::list< int > getKeyStrips(const std::vector< CSCComparatorDigi > &comparators) const
finds the key strips from these comparators
void fillStripDigis(const std::list< int > &keyStrips, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *)

◆ fillStripDigis()

void CSCStripElectronicsSim::fillStripDigis ( const std::list< int > &  keyStrips,
CSCStripDigiCollection digis,
CLHEP::HepRandomEngine *  engine 
)
private

Definition at line 308 of file CSCStripElectronicsSim.cc.

References channelsToRead(), createDigi(), CSCBaseElectronicsSim::find(), and CSCBaseElectronicsSim::layerId().

Referenced by fillDigis(), and fillMissingLayer().

310  {
311  std::list<int> stripsToDo = channelsToRead(keyStrips, 3);
312  std::vector<CSCStripDigi> stripDigis;
313  stripDigis.reserve(stripsToDo.size());
314  for (std::list<int>::const_iterator stripItr = stripsToDo.begin(); stripItr != stripsToDo.end(); ++stripItr) {
315  createDigi(*stripItr, find(*stripItr, engine), stripDigis, engine);
316  }
317 
318  CSCStripDigiCollection::Range stripRange(stripDigis.begin(), stripDigis.end());
319  digis.put(stripRange, layerId());
320 }
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
std::list< int > channelsToRead(const std::list< int > &keyStrips, int window) const
std::pair< const_iterator, const_iterator > Range
CSCAnalogSignal & find(int element, CLHEP::HepRandomEngine *)
void createDigi(int istrip, const CSCAnalogSignal &signal, std::vector< CSCStripDigi > &result, CLHEP::HepRandomEngine *)

◆ getKeyStrips()

std::list< int > CSCStripElectronicsSim::getKeyStrips ( const std::vector< CSCComparatorDigi > &  comparators) const
private

finds the key strips from these comparators

Definition at line 209 of file CSCStripElectronicsSim.cc.

References funct::abs(), mps_fire::result, and CSCBaseElectronicsSim::theOffsetOfBxZero.

Referenced by fillMissingLayer().

209  {
210  std::list<int> result;
211  for (std::vector<CSCComparatorDigi>::const_iterator compItr = comparators.begin(); compItr != comparators.end();
212  ++compItr) {
213  if (std::abs(compItr->getTimeBin() - theOffsetOfBxZero) <= 2) {
214  result.push_back(compItr->getStrip());
215  }
216  }
217  // need sort for unique to work.
218  result.sort();
219  result.unique();
220  return result;
221 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ getKeyStripsFromMC()

std::list< int > CSCStripElectronicsSim::getKeyStripsFromMC ( ) const
private

get ths strips that have detector hits

Definition at line 223 of file CSCStripElectronicsSim.cc.

References dqmdumpme::first, mps_fire::result, CSCBaseElectronicsSim::theDetectorHitMap, and HcalDetIdTransform::transform().

Referenced by fillDigis().

223  {
224  // assumes the detector hit map is filled
225  std::list<int> result;
227  theDetectorHitMap.end(),
228  // back_inserter(result),
229  // boost::bind(&DetectorHitMap::value_type::first,_1));
230  // suggested code from Chris Jones
231  back_inserter(result),
232  std::bind(&DetectorHitMap::value_type::first, std::placeholders::_1));
233  // back_inserter(result), [](DetectorHitMap::value_type const& iValue) {
234  // return iValue.first; } );
235  result.sort();
236  result.unique();
237  return result;
238 }
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ getReadoutRange()

void CSCStripElectronicsSim::getReadoutRange ( int  inputStrip,
int &  minStrip,
int &  maxStrip 
)
private

◆ initParameters()

void CSCStripElectronicsSim::initParameters ( )
overrideprivatevirtual

initialization for each layer

Implements CSCBaseElectronicsSim.

Definition at line 61 of file CSCStripElectronicsSim.cc.

References CSCChamberSpecs::chamberType(), nano_mu_digi_cff::chamberType, PV3DBase< T, PVType, FrameType >::mag(), CSCBaseElectronicsSim::nElements, nScaBins_, CSCLayerGeometry::numberOfStrips(), GloballyPositioned< T >::position(), sca_peak_bin, sca_time_bin_size, GeomDet::surface(), theAverageTimeOfFlight, CSCBaseElectronicsSim::theBunchTimingOffsets, theComparatorThreshold, CSCBaseElectronicsSim::theLayer, CSCBaseElectronicsSim::theLayerGeometry, CSCBaseElectronicsSim::theNumberOfSamples, CSCBaseElectronicsSim::theSamplingTime, CSCBaseElectronicsSim::theShapingTime, CSCBaseElectronicsSim::theSignalStartTime, CSCBaseElectronicsSim::theSignalStopTime, CSCBaseElectronicsSim::theSpecs, and theTimingOffset.

61  {
64  // selfTest();
65 
66  // calculate the offset to the peak
67  float averageDistance = theLayer->surface().position().mag();
68  theAverageTimeOfFlight = averageDistance * cm / c_light; // Units of c_light: mm/ns
71  // TODO make sure config gets overridden
75 }
std::vector< double > theBunchTimingOffsets
int chamberType() const
const CSCChamberSpecs * theSpecs
const CSCLayerGeometry * theLayerGeometry
int numberOfStrips() const
T mag() const
Definition: PV3DBase.h:64
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const PositionType & position() const

◆ makeNoiseSignal()

CSCAnalogSignal CSCStripElectronicsSim::makeNoiseSignal ( int  element,
CLHEP::HepRandomEngine *  engine 
)
overridevirtual

Reimplemented from CSCBaseElectronicsSim.

Definition at line 81 of file CSCStripElectronicsSim.cc.

References CSCBaseElectronicsSim::doNoise_, CSCAnalogSignal::getValue(), CSCBaseElectronicsSim::layerId(), CSCStripConditions::noisify(), nScaBins_, sca_time_bin_size, CSCBaseElectronicsSim::theNumberOfSamples, CSCBaseElectronicsSim::theSamplingTime, CSCBaseElectronicsSim::theSignalStartTime, and theStripConditions.

81  {
82  std::vector<float> noiseBins(nScaBins_);
83  CSCAnalogSignal tmpSignal(element, sca_time_bin_size, noiseBins);
84  if (doNoise_) {
85  theStripConditions->noisify(layerId(), tmpSignal, engine);
86  }
87  // now rebin it
88  std::vector<float> binValues(theNumberOfSamples);
89  for (int ibin = 0; ibin < theNumberOfSamples; ++ibin) {
90  binValues[ibin] = tmpSignal.getValue(ibin * theSamplingTime);
91  }
92  CSCAnalogSignal finalSignal(element, theSamplingTime, binValues, 0., theSignalStartTime);
93  return finalSignal;
94 }
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
CSCStripConditions * theStripConditions
void noisify(const CSCDetId &detId, CSCAnalogSignal &signal, CLHEP::HepRandomEngine *)
superimposes noise, in fC, on the signal

◆ readoutElement()

int CSCStripElectronicsSim::readoutElement ( int  strip) const
overrideprivatevirtual

◆ runComparator()

void CSCStripElectronicsSim::runComparator ( std::vector< CSCComparatorDigi > &  result,
CLHEP::HepRandomEngine *  engine 
)
private

Definition at line 103 of file CSCStripElectronicsSim.cc.

References comparatorReading(), CSCBaseElectronicsSim::find(), reco::JetExtendedAssociation::getValue(), CSCBaseElectronicsSim::nElements, readoutElement(), mps_fire::result, jetUpdater_cfi::sort, nano_mu_digi_cff::strip, CSCBaseElectronicsSim::theBunchSpacing, theComparatorDeadTime, theComparatorSamplingTime, theComparatorThreshold, theComparatorTimeBinOffset, theComparatorTimeOffset, theComparatorWait, CSCBaseElectronicsSim::theOffsetOfBxZero, CSCBaseElectronicsSim::theSignalMap, CSCBaseElectronicsSim::theSignalStartTime, CSCBaseElectronicsSim::theSignalStopTime, theTimingOffset, and hcalRecHitTable_cff::time.

Referenced by fillDigis().

103  {
104  // first, make a list of all the comparators we actually
105  // need to run
106  std::list<int> comparatorsWithSignal;
107  CSCSignalMap::iterator signalMapItr;
108  for (signalMapItr = theSignalMap.begin(); signalMapItr != theSignalMap.end(); ++signalMapItr) {
109  // Elements in signal map count from 1
110  // 1,2->0, 3,4->1, 5,6->2, ...
111  comparatorsWithSignal.push_back(((*signalMapItr).first - 1) / 2);
112  }
113  // no need to sort
114  comparatorsWithSignal.unique();
115  for (std::list<int>::iterator listItr = comparatorsWithSignal.begin(); listItr != comparatorsWithSignal.end();
116  ++listItr) {
117  int iComparator = *listItr;
118  // find signal1 and signal2
119  // iComparator counts from 0
120  // icomp =0->1,2, =1->3,4, =2->5,6, ...
121  const CSCAnalogSignal &signal1 = find(readoutElement(iComparator * 2 + 1), engine);
122  const CSCAnalogSignal &signal2 = find(readoutElement(iComparator * 2 + 2), engine);
125  if (comparatorReading(signal1, time, engine) > theComparatorThreshold ||
126  comparatorReading(signal2, time, engine) > theComparatorThreshold) {
127  // wait a bit, so we can run the comparator at the signal peak
128  float comparatorTime = time;
130 
131  float height1 = comparatorReading(signal1, time, engine);
132  float height2 = comparatorReading(signal2, time, engine);
133  int output = 0;
134  int strip = 0;
135  // distrip logic; comparator output is for pairs of strips:
136  // hit bin dec
137  // x--- 100 4
138  // -x-- 101 5
139  // --x- 110 6
140  // ---x 111 7
141  // just to prevent a copy
142  const CSCAnalogSignal *mainSignal = nullptr;
143  // pick the higher of the two strips in the pair
144  if (height1 > height2) {
145  mainSignal = &signal1;
146  float leftStrip = 0.;
147  if (iComparator > 0) {
148  leftStrip = comparatorReading(find(readoutElement(iComparator * 2), engine), time, engine);
149  }
150  // if this strip is higher than either of its neighbors, make a
151  // comparator digi
152  if (leftStrip < height1 && height1 > theComparatorThreshold) {
153  output = (leftStrip < height2);
154  strip = iComparator * 2 + 1;
155  }
156  } else {
157  mainSignal = &signal2;
158  float rightStrip = 0.;
159  if (iComparator * 2 + 3 <= nElements) {
160  rightStrip = comparatorReading(find(readoutElement(iComparator * 2 + 3), engine), time, engine);
161  }
162  if (rightStrip < height2 && height2 > theComparatorThreshold) {
163  output = (height1 < rightStrip);
164  strip = iComparator * 2 + 2;
165  }
166  }
167  if (strip != 0) {
168  float bxFloat =
170 
171  // Comparator digi as of Nov-2006 adapted to real data: time word has
172  // 16 bits with set bit flagging appropriate bunch crossing, and bx 0
173  // corresponding to 9th bit i.e.
174 
175  // 1st bit set (bit 0) <-> bx -9
176  // 2nd 1 <-> bx -8
177  // ... ... ....
178  // 8th 9 <-> bx 0
179  // 9th 10 <-> bx +1
180  // ... ... ....
181  // 16th 15 <-> bx +6
182 
183  // Parameter theOffsetOfBxZero = 9 @@WARNING! This offset may be
184  // changed (hardware)!
185 
186  int timeWord = 0; // and this will remain if too early or late
187  if ((bxFloat >= 0) && (bxFloat < 16))
188  timeWord = (1 << static_cast<int>(bxFloat)); // set appropriate bit
189 
190  CSCComparatorDigi newDigi(strip, output, timeWord);
191  result.push_back(newDigi);
192  }
193 
194  // wait for the comparator to reset
196  // really should be zero, but strip signal doesn't go negative yet
197  float resetThreshold = 1;
198  while (time < theSignalStopTime && mainSignal->getValue(time) > resetThreshold) {
200  }
201 
202  } // if over threshold
203  } // loop over time samples
204  } // loop over comparators
205  // sort by time
206  sort(result.begin(), result.end());
207 }
float comparatorReading(const CSCAnalogSignal &signal, float time, CLHEP::HepRandomEngine *) const
calculates the comparator reading, including saturation and offsets
int readoutElement(int strip) const override
CSCAnalogSignal & find(int element, CLHEP::HepRandomEngine *)
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
Definition: output.py:1

◆ selfTest()

void CSCStripElectronicsSim::selfTest ( ) const
private

Definition at line 424 of file CSCStripElectronicsSim.cc.

References cms::cuda::assert(), channelsToRead(), doSuppression_, CSCBaseElectronicsSim::nElements, and readoutElement().

424  {
425  // make sure the zero suppression algorithms work
426  std::list<int> keyStrips, stripsRead;
427  //
428  bool isGanged = (readoutElement(nElements) == 16);
429  keyStrips.push_back(readoutElement(19));
430  keyStrips.push_back(readoutElement(30));
431  keyStrips.push_back(readoutElement(32));
432  stripsRead = channelsToRead(keyStrips, 3);
433  if (doSuppression_) {
434  unsigned int expectedSize = isGanged ? 10 : 12;
435  assert(stripsRead.size() == expectedSize);
436  assert(stripsRead.front() == readoutElement(17));
437  } else {
438  unsigned int expectedSize = isGanged ? 16 : 48;
439  assert(stripsRead.size() == expectedSize);
440  assert(stripsRead.front() == 1);
441  }
442 }
int readoutElement(int strip) const override
assert(be >=bs)
std::list< int > channelsToRead(const std::list< int > &keyStrips, int window) const

◆ setStripConditions()

void CSCStripElectronicsSim::setStripConditions ( CSCStripConditions cond)
inline

Definition at line 42 of file CSCStripElectronicsSim.h.

References theStripConditions.

Referenced by CSCDigitizer::setStripConditions().

CSCStripConditions * theStripConditions

Member Data Documentation

◆ doCrosstalk_

bool CSCStripElectronicsSim::doCrosstalk_
private

◆ doSuppression_

bool CSCStripElectronicsSim::doSuppression_
private

Definition at line 101 of file CSCStripElectronicsSim.h.

Referenced by channelsToRead(), and selfTest().

◆ nScaBins_

int CSCStripElectronicsSim::nScaBins_
private

Definition at line 100 of file CSCStripElectronicsSim.h.

Referenced by createDigi(), initParameters(), and makeNoiseSignal().

◆ sca_peak_bin

int CSCStripElectronicsSim::sca_peak_bin
private

Definition at line 111 of file CSCStripElectronicsSim.h.

Referenced by initParameters().

◆ sca_time_bin_size

float CSCStripElectronicsSim::sca_time_bin_size
private

Definition at line 108 of file CSCStripElectronicsSim.h.

Referenced by createDigi(), initParameters(), and makeNoiseSignal().

◆ theAmpResponse

CSCStripAmpResponse CSCStripElectronicsSim::theAmpResponse
private

Definition at line 58 of file CSCStripElectronicsSim.h.

Referenced by calculateAmpResponse().

◆ theAverageTimeOfFlight

float CSCStripElectronicsSim::theAverageTimeOfFlight
private

Definition at line 121 of file CSCStripElectronicsSim.h.

Referenced by createDigi(), and initParameters().

◆ theComparatorClockJump

int CSCStripElectronicsSim::theComparatorClockJump
private

Definition at line 106 of file CSCStripElectronicsSim.h.

◆ theComparatorDeadTime

float CSCStripElectronicsSim::theComparatorDeadTime
private

Definition at line 95 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

◆ theComparatorNoise

float CSCStripElectronicsSim::theComparatorNoise
private

Definition at line 89 of file CSCStripElectronicsSim.h.

◆ theComparatorRMSOffset

float CSCStripElectronicsSim::theComparatorRMSOffset
private

Definition at line 90 of file CSCStripElectronicsSim.h.

Referenced by comparatorReading().

◆ theComparatorSamplingTime

double CSCStripElectronicsSim::theComparatorSamplingTime
private

Definition at line 116 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

◆ theComparatorSaturation

float CSCStripElectronicsSim::theComparatorSaturation
private

Definition at line 92 of file CSCStripElectronicsSim.h.

Referenced by comparatorReading().

◆ theComparatorThreshold

float CSCStripElectronicsSim::theComparatorThreshold
private

Definition at line 88 of file CSCStripElectronicsSim.h.

Referenced by initParameters(), and runComparator().

◆ theComparatorTimeBinOffset

double CSCStripElectronicsSim::theComparatorTimeBinOffset
private

Definition at line 113 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

◆ theComparatorTimeOffset

double CSCStripElectronicsSim::theComparatorTimeOffset
private

Definition at line 115 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

◆ theComparatorWait

float CSCStripElectronicsSim::theComparatorWait
private

Definition at line 94 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

◆ theCrosstalkGenerator

CSCCrosstalkGenerator* CSCStripElectronicsSim::theCrosstalkGenerator
private

◆ theDaqDeadTime

float CSCStripElectronicsSim::theDaqDeadTime
private

Definition at line 96 of file CSCStripElectronicsSim.h.

◆ theSCATimingOffsets

std::vector<double> CSCStripElectronicsSim::theSCATimingOffsets
private

Definition at line 118 of file CSCStripElectronicsSim.h.

Referenced by createDigi().

◆ theStripConditions

CSCStripConditions* CSCStripElectronicsSim::theStripConditions
private

◆ theTimingOffset

float CSCStripElectronicsSim::theTimingOffset
private

Definition at line 98 of file CSCStripElectronicsSim.h.

Referenced by initParameters(), and runComparator().