CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual ~CSCStripElectronicsSim ()
 
- 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
 
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 ()
 initialization for each layer More...
 
virtual int readoutElement (int strip) const
 
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
< StripDigiSimLink
DigiSimLinks
 
- 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
 the average time-of-flight from the interaction point to the given detector More...
 
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 27 of file CSCStripElectronicsSim.h.

Constructor & Destructor Documentation

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

configurable parameters

Definition at line 23 of file CSCStripElectronicsSim.cc.

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

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

Definition at line 56 of file CSCStripElectronicsSim.cc.

References doCrosstalk_, and theCrosstalkGenerator.

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

Member Function Documentation

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

Definition at line 369 of file CSCStripElectronicsSim.cc.

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

Referenced by fillDigis().

369  {
370  // this is needed so we can add a noise signal to the map
371  // without messing up any iterators
372  std::vector<CSCAnalogSignal> realSignals;
373  realSignals.reserve(theSignalMap.size());
374  CSCSignalMap::iterator mapI = theSignalMap.begin(), mapEnd = theSignalMap.end();
375  for( ; mapI != mapEnd; ++mapI) {
376  realSignals.push_back((*mapI).second);
377  }
378  sort(realSignals.begin(), realSignals.end(), SortSignalsByTotal);
379  std::vector<CSCAnalogSignal>::iterator realSignalItr = realSignals.begin(),
380  realSignalsEnd = realSignals.end();
381  for( ; realSignalItr != realSignalsEnd; ++realSignalItr)
382  {
383  int thisStrip = (*realSignalItr).getElement();
384  // add it to each neighbor
385  if(thisStrip > 1) {
386  int otherStrip = thisStrip - 1;
387  addCrosstalk(*realSignalItr, thisStrip, otherStrip, engine);
388  }
389  if(thisStrip < nElements) {
390  int otherStrip = thisStrip + 1;
391  addCrosstalk(*realSignalItr, thisStrip, otherStrip, engine);
392  }
393  }
394 }
bool SortSignalsByTotal(const CSCAnalogSignal &s1, const CSCAnalogSignal &s2)
void addCrosstalk(CLHEP::HepRandomEngine *)
void CSCStripElectronicsSim::addCrosstalk ( const CSCAnalogSignal signal,
int  thisStrip,
int  otherStrip,
CLHEP::HepRandomEngine *  engine 
)
private

Definition at line 397 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.

400 {
401  float capacitiveCrosstalk, resistiveCrosstalk;
402  bool leftRight = (otherStrip > thisStrip);
403  theStripConditions->crosstalk(layerId(), thisStrip,
404  theLayerGeometry->length(), leftRight,
405  capacitiveCrosstalk, resistiveCrosstalk);
406  theCrosstalkGenerator->setParameters(capacitiveCrosstalk, 0., resistiveCrosstalk);
407  CSCAnalogSignal crosstalkSignal( theCrosstalkGenerator->getCrosstalk(signal) );
408  find(readoutElement(otherStrip), engine).superimpose(crosstalkSignal);
409 
410  // Now subtract the crosstalk signal from the original signal
411  crosstalkSignal *= -1.;
412  find(thisStrip, engine).superimpose(crosstalkSignal);
413 
414 }
const CSCLayerGeometry * theLayerGeometry
virtual void crosstalk(const CSCDetId &detId, int channel, double stripLength, bool leftRight, float &capacitive, float &resistive) const =0
CSCStripConditions * theStripConditions
CSCCrosstalkGenerator * theCrosstalkGenerator
void superimpose(const CSCAnalogSignal &signal2)
void setParameters(float crosstalk, float delay, float resistiveFraction)
CSCAnalogSignal getCrosstalk(const CSCAnalogSignal &inputSignal) const
virtual int readoutElement(int strip) const
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
CSCAnalogSignal & find(int element, CLHEP::HepRandomEngine *)
virtual float length() const
float CSCStripElectronicsSim::calculateAmpResponse ( float  t) const
privatevirtual
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 261 of file CSCStripElectronicsSim.cc.

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

Referenced by fillStripDigis(), and selfTest().

262 {
263  std::list<int> result;
264  std::list<int>::const_iterator keyStripItr = keyStrips.begin();
265  if(doSuppression_)
266  {
267  for( ; keyStripItr != keyStrips.end(); ++keyStripItr)
268  {
269  // pick the five strips around the comparator
270  for(int istrip = (*keyStripItr)-window; istrip <= (*keyStripItr)+window; ++istrip)
271  {
272  if(istrip>0 && istrip<= nElements)
273  {
274  result.push_back(readoutElement(istrip));
275  }
276  }
277  }
278  result.sort();
279  result.unique();
280  }
281  else
282  {
283  // read the whole CFEB, 16 strips
284  std::list<int> cfebsToRead;
285  for( ; keyStripItr != keyStrips.end(); ++keyStripItr)
286  {
287  int cfeb = (readoutElement(*keyStripItr)-1)/16;
288  cfebsToRead.push_back(cfeb);
289  int remainder = (readoutElement(*keyStripItr)-1)%16;
290  // if we're within 3 strips of an edge, take neighboring CFEB, too
291  if(remainder < window && cfeb != 0)
292  {
293  cfebsToRead.push_back(cfeb-1);
294  }
295  // the 'readouElement' makes it so that ME1/1 has just one CFEB
296  int maxCFEBs = readoutElement(nElements)/16 - 1;
297  if(remainder >= 16-window && cfeb != maxCFEBs)
298  {
299  cfebsToRead.push_back(cfeb+1);
300  }
301  }
302  cfebsToRead.sort();
303  cfebsToRead.unique();
304 
305  // now convert the CFEBS to strips
306  for(std::list<int>::const_iterator cfebItr = cfebsToRead.begin();
307  cfebItr != cfebsToRead.end(); ++cfebItr)
308  {
309  for(int i = 1; i <= 16; ++i)
310  {
311  result.push_back((*cfebItr)*16 + i);
312  }
313  }
314  }
315  return result;
316 }
int i
Definition: DBlmapReader.cc:9
def window
Definition: svgfig.py:642
tuple result
Definition: query.py:137
virtual int readoutElement(int strip) const
float CSCStripElectronicsSim::comparatorReading ( const CSCAnalogSignal signal,
float  time,
CLHEP::HepRandomEngine *  engine 
) const
private

calculates the comparator reading, including saturation and offsets

Definition at line 109 of file CSCStripElectronicsSim.cc.

References CSCAnalogSignal::getValue(), bookConverter::min, theComparatorRMSOffset, and theComparatorSaturation.

Referenced by runComparator().

111  {
113  + theComparatorRMSOffset * CLHEP::RandGaussQ::shoot(engine);
114 }
float getValue(float t) const
void CSCStripElectronicsSim::createDigi ( int  istrip,
const CSCAnalogSignal signal,
std::vector< CSCStripDigi > &  result,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 417 of file CSCStripElectronicsSim.cc.

References CSCBaseElectronicsSim::addLinks(), CSCChamberSpecs::chamberType(), CSCBaseElectronicsSim::channelIndex(), doSaturation(), CSCAnalogSignal::getValue(), CSCBaseElectronicsSim::layerId(), LogTrace, nScaBins_, CSCStripConditions::pedestal(), EcalCondDBWriter_cfi::pedestal, sca_time_bin_size, CSCStripConditions::smearedGain(), edmStreamStallGrapher::t, theAverageTimeOfFlight, theSCATimingOffsets, CSCBaseElectronicsSim::theSignalStartTime, CSCBaseElectronicsSim::theSpecs, theStripConditions, and CSCBaseElectronicsSim::theTimingCalibrationError.

Referenced by fillStripDigis().

419 {
420  // fill in the sca information
421  std::vector<int> scaCounts(nScaBins_);
422 
423  float pedestal = theStripConditions->pedestal(layerId(), channel);
424  float gain = theStripConditions->smearedGain(layerId(), channel, engine);
425  int chamberType = theSpecs->chamberType();
426  float timeSmearing = CLHEP::RandGaussQ::shoot(engine) * theTimingCalibrationError[chamberType];
427  // undo the correction for TOF, instead, using some nominal
428  // value from ME2/1
429  float t0 = theSignalStartTime+theSCATimingOffsets[chamberType] + timeSmearing
430  + 29. - theAverageTimeOfFlight;
431  for(int scaBin = 0; scaBin < nScaBins_; ++scaBin) {
432  float t = t0 + scaBin*sca_time_bin_size;
433  scaCounts[scaBin] = static_cast< int >
434  ( pedestal + signal.getValue(t) * gain );
435  }
436  CSCStripDigi newDigi(channel, scaCounts);
437 
438  // do saturation of 12-bit ADC
439  doSaturation(newDigi);
440 
441  result.push_back(newDigi);
442  addLinks(channelIndex(channel));
443  LogTrace("CSCStripElectronicsSim") << newDigi;
444 }
const CSCChamberSpecs * theSpecs
virtual float pedestal(const CSCDetId &detId, int channel) const =0
in ADC counts
CSCStripConditions * theStripConditions
std::vector< double > theSCATimingOffsets
tuple result
Definition: query.py:137
void doSaturation(CSCStripDigi &digi)
#define LogTrace(id)
virtual void addLinks(int channelIndex)
int chamberType() const
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
float getValue(float t) const
virtual float smearedGain(const CSCDetId &detId, int channel, CLHEP::HepRandomEngine *) const
virtual int channelIndex(int channel) const
lets users map channels to different indices for links
std::vector< double > theTimingCalibrationError
void CSCStripElectronicsSim::doSaturation ( CSCStripDigi digi)
private

Definition at line 447 of file CSCStripElectronicsSim.cc.

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

Referenced by createDigi().

448 {
449  std::vector<int> scaCounts(digi.getADCCounts());
450  for(unsigned scaBin = 0; scaBin < scaCounts.size(); ++scaBin) {
451  scaCounts[scaBin] = std::min(scaCounts[scaBin], 4095);
452  }
453  digi.setADCCounts(scaCounts);
454 }
std::vector< int > const & getADCCounts() const
Get ADC readings.
Definition: CSCStripDigi.h:54
void setADCCounts(const std::vector< int > &ADCCounts)
Definition: CSCStripDigi.cc:22
void CSCStripElectronicsSim::fillDigis ( CSCStripDigiCollection digis,
CSCComparatorDigiCollection comparators,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 327 of file CSCStripElectronicsSim.cc.

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

Referenced by CSCDigitizer::doAction().

330 {
331  if(doCrosstalk_) {
332  addCrosstalk(engine);
333  }
334 
335  std::vector<CSCComparatorDigi> comparatorOutputs;
336  runComparator(comparatorOutputs, engine);
337  // copy these to the result
338  if(!comparatorOutputs.empty())
339  {
340  CSCComparatorDigiCollection::Range range(comparatorOutputs.begin(),
341  comparatorOutputs.end());
342  comparators.put(range, layerId());
343  }
344 
345  //std::list<int> keyStrips = getKeyStrips(comparatorOutputs);
346  std::list<int> keyStrips = getKeyStripsFromMC();
347  fillStripDigis(keyStrips, digis, engine);
348 }
std::list< int > getKeyStripsFromMC() const
get ths strips that have detector hits
void addCrosstalk(CLHEP::HepRandomEngine *)
void runComparator(std::vector< CSCComparatorDigi > &result, CLHEP::HepRandomEngine *)
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
std::pair< const_iterator, const_iterator > Range
void fillStripDigis(const std::list< int > &keyStrips, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *)
void CSCStripElectronicsSim::fillMissingLayer ( const CSCLayer layer,
const CSCComparatorDigiCollection comparators,
CSCStripDigiCollection digis,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 457 of file CSCStripElectronicsSim.cc.

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

Referenced by CSCDigitizer::doAction().

461 {
462  theSignalMap.clear();
463  setLayer(layer);
464  CSCDetId chamberId(theLayerId.chamberId());
465  // find all comparator key strips in this chamber
466  std::list<int> chamberKeyStrips;
467  for(CSCComparatorDigiCollection::DigiRangeIterator comparatorItr = comparators.begin();
468  comparatorItr != comparators.end(); ++comparatorItr)
469  {
470  // could be more efficient
471  if(CSCDetId((*comparatorItr).first).chamberId() == chamberId)
472  {
473  std::vector<CSCComparatorDigi> layerComparators((*comparatorItr).second.first, (*comparatorItr).second.second);
474  std::list<int> layerKeyStrips = getKeyStrips(layerComparators);
475  chamberKeyStrips.insert(chamberKeyStrips.end(), layerKeyStrips.begin(), layerKeyStrips.end());
476  }
477  }
478  chamberKeyStrips.sort();
479  chamberKeyStrips.unique();
480  fillStripDigis(chamberKeyStrips, digis, engine);
481 }
void setLayer(const CSCLayer *layer)
CSCDetId chamberId() const
Definition: CSCDetId.h:66
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 *)
void CSCStripElectronicsSim::fillStripDigis ( const std::list< int > &  keyStrips,
CSCStripDigiCollection digis,
CLHEP::HepRandomEngine *  engine 
)
private

Definition at line 351 of file CSCStripElectronicsSim.cc.

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

Referenced by fillDigis(), and fillMissingLayer().

354 {
355  std::list<int> stripsToDo = channelsToRead(keyStrips, 3);
356  std::vector<CSCStripDigi> stripDigis;
357  stripDigis.reserve(stripsToDo.size());
358  for(std::list<int>::const_iterator stripItr = stripsToDo.begin();
359  stripItr != stripsToDo.end(); ++stripItr)
360  {
361  createDigi( *stripItr, find(*stripItr, engine), stripDigis, engine);
362  }
363 
364  CSCStripDigiCollection::Range stripRange(stripDigis.begin(), stripDigis.end());
365  digis.put(stripRange, layerId());
366 }
std::list< int > channelsToRead(const std::list< int > &keyStrips, int window) const
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
CSCAnalogSignal & find(int element, CLHEP::HepRandomEngine *)
std::pair< const_iterator, const_iterator > Range
void createDigi(int istrip, const CSCAnalogSignal &signal, std::vector< CSCStripDigi > &result, CLHEP::HepRandomEngine *)
std::list< int > CSCStripElectronicsSim::getKeyStrips ( const std::vector< CSCComparatorDigi > &  comparators) const
private

finds the key strips from these comparators

Definition at line 229 of file CSCStripElectronicsSim.cc.

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

Referenced by fillMissingLayer().

230 {
231  std::list<int> result;
232  for(std::vector<CSCComparatorDigi>::const_iterator compItr = comparators.begin();
233  compItr != comparators.end(); ++compItr)
234  {
235  if(std::abs(compItr->getTimeBin()-theOffsetOfBxZero) <= 2)
236  {
237  result.push_back(compItr->getStrip());
238  }
239  }
240  // need sort for unique to work.
241  result.sort();
242  result.unique();
243  return result;
244 }
tuple result
Definition: query.py:137
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::list< int > CSCStripElectronicsSim::getKeyStripsFromMC ( ) const
private

get ths strips that have detector hits

Definition at line 248 of file CSCStripElectronicsSim.cc.

References first, query::result, CSCBaseElectronicsSim::theDetectorHitMap, and create_public_lumi_plots::transform.

Referenced by fillDigis().

249 {
250  // assumes the detector hit map is filled
251  std::list<int> result;
253  back_inserter(result), boost::bind(&DetectorHitMap::value_type::first,_1));
254  result.sort();
255  result.unique();
256  return result;
257 }
tuple result
Definition: query.py:137
bool first
Definition: L1TdeRCT.cc:75
void CSCStripElectronicsSim::getReadoutRange ( int  inputStrip,
int &  minStrip,
int &  maxStrip 
)
private
void CSCStripElectronicsSim::initParameters ( )
privatevirtual

initialization for each layer

Implements CSCBaseElectronicsSim.

Definition at line 62 of file CSCStripElectronicsSim.cc.

References CSCChamberSpecs::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.

62  {
65  //selfTest();
66 
67  //calculate the offset to the peak
68  float averageDistance = theLayer->surface().position().mag();
69  theAverageTimeOfFlight = averageDistance * cm / c_light; // Units of c_light: mm/ns
70  int chamberType = theSpecs->chamberType();
72  + theBunchTimingOffsets[chamberType];
73 //TODO make sure config gets overridden
77  theNumberOfSamples = nScaBins_*static_cast<int>(sca_time_bin_size/theSamplingTime);
78 
79 }
std::vector< double > theBunchTimingOffsets
const CSCChamberSpecs * theSpecs
const CSCLayerGeometry * theLayerGeometry
int numberOfStrips() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
T mag() const
Definition: PV3DBase.h:67
int chamberType() const
const PositionType & position() const
CSCAnalogSignal CSCStripElectronicsSim::makeNoiseSignal ( int  element,
CLHEP::HepRandomEngine *  engine 
)
overridevirtual

Reimplemented from CSCBaseElectronicsSim.

Definition at line 93 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.

93  {
94  std::vector<float> noiseBins(nScaBins_);
95  CSCAnalogSignal tmpSignal(element, sca_time_bin_size, noiseBins);
96  if(doNoise_) {
97  theStripConditions->noisify(layerId(), tmpSignal, engine);
98  }
99  // now rebin it
100  std::vector<float> binValues(theNumberOfSamples);
101  for(int ibin=0; ibin < theNumberOfSamples; ++ibin) {
102  binValues[ibin] = tmpSignal.getValue(ibin*theSamplingTime);
103  }
104  CSCAnalogSignal finalSignal(element, theSamplingTime, binValues, 0., theSignalStartTime);
105  return finalSignal;
106 }
CSCStripConditions * theStripConditions
void noisify(const CSCDetId &detId, CSCAnalogSignal &signal, CLHEP::HepRandomEngine *)
superimposes noise, in fC, on the signal
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
int CSCStripElectronicsSim::readoutElement ( int  strip) const
privatevirtual

Implements CSCBaseElectronicsSim.

Definition at line 82 of file CSCStripElectronicsSim.cc.

References CSCLayerGeometry::channel(), and CSCBaseElectronicsSim::theLayerGeometry.

Referenced by addCrosstalk(), channelsToRead(), runComparator(), and selfTest().

82  {
83  return theLayerGeometry->channel(strip);
84 }
const CSCLayerGeometry * theLayerGeometry
int channel(int strip) const
void CSCStripElectronicsSim::runComparator ( std::vector< CSCComparatorDigi > &  result,
CLHEP::HepRandomEngine *  engine 
)
private

Definition at line 118 of file CSCStripElectronicsSim.cc.

References comparatorReading(), CSCBaseElectronicsSim::find(), CSCAnalogSignal::getValue(), CSCBaseElectronicsSim::nElements, convertSQLitetoXML_cfg::output, readoutElement(), python.multivaluedict::sort(), CSCBaseElectronicsSim::theBunchSpacing, theComparatorDeadTime, theComparatorSamplingTime, theComparatorThreshold, theComparatorTimeBinOffset, theComparatorTimeOffset, theComparatorWait, CSCBaseElectronicsSim::theOffsetOfBxZero, CSCBaseElectronicsSim::theSignalMap, CSCBaseElectronicsSim::theSignalStartTime, CSCBaseElectronicsSim::theSignalStopTime, theTimingOffset, and cond::rpcobgas::time.

Referenced by fillDigis().

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

Definition at line 484 of file CSCStripElectronicsSim.cc.

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

485 {
486  // make sure the zero suppression algorithms work
487  std::list<int> keyStrips, stripsRead;
488  //
489  bool isGanged = (readoutElement(nElements) == 16);
490  keyStrips.push_back(readoutElement(19));
491  keyStrips.push_back(readoutElement(30));
492  keyStrips.push_back(readoutElement(32));
493  stripsRead = channelsToRead(keyStrips, 3);
494  if(doSuppression_)
495  {
496  unsigned int expectedSize = isGanged ? 10 : 12;
497  assert(stripsRead.size() == expectedSize);
498  assert(stripsRead.front() == readoutElement(17));
499  }
500  else
501  {
502  unsigned int expectedSize = isGanged ? 16 : 48;
503  assert(stripsRead.size() == expectedSize);
504  assert(stripsRead.front() == 1);
505  }
506 }
std::list< int > channelsToRead(const std::list< int > &keyStrips, int window) const
virtual int readoutElement(int strip) const
void CSCStripElectronicsSim::setStripConditions ( CSCStripConditions cond)
inline

Definition at line 42 of file CSCStripElectronicsSim.h.

References theStripConditions.

Referenced by CSCDigitizer::setStripConditions().

42 {theStripConditions = cond;}
CSCStripConditions * theStripConditions

Member Data Documentation

bool CSCStripElectronicsSim::doCrosstalk_
private
bool CSCStripElectronicsSim::doSuppression_
private

Definition at line 106 of file CSCStripElectronicsSim.h.

Referenced by channelsToRead(), and selfTest().

int CSCStripElectronicsSim::nScaBins_
private

Definition at line 105 of file CSCStripElectronicsSim.h.

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

int CSCStripElectronicsSim::sca_peak_bin
private

Definition at line 116 of file CSCStripElectronicsSim.h.

Referenced by initParameters().

float CSCStripElectronicsSim::sca_time_bin_size
private

Definition at line 113 of file CSCStripElectronicsSim.h.

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

CSCStripAmpResponse CSCStripElectronicsSim::theAmpResponse
private

Definition at line 55 of file CSCStripElectronicsSim.h.

Referenced by calculateAmpResponse().

float CSCStripElectronicsSim::theAverageTimeOfFlight
private

Definition at line 126 of file CSCStripElectronicsSim.h.

Referenced by createDigi(), and initParameters().

int CSCStripElectronicsSim::theComparatorClockJump
private

Definition at line 111 of file CSCStripElectronicsSim.h.

float CSCStripElectronicsSim::theComparatorDeadTime
private

Definition at line 100 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

float CSCStripElectronicsSim::theComparatorNoise
private

Definition at line 94 of file CSCStripElectronicsSim.h.

float CSCStripElectronicsSim::theComparatorRMSOffset
private

Definition at line 95 of file CSCStripElectronicsSim.h.

Referenced by comparatorReading().

double CSCStripElectronicsSim::theComparatorSamplingTime
private

Definition at line 121 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

float CSCStripElectronicsSim::theComparatorSaturation
private

Definition at line 97 of file CSCStripElectronicsSim.h.

Referenced by comparatorReading().

float CSCStripElectronicsSim::theComparatorThreshold
private

Definition at line 93 of file CSCStripElectronicsSim.h.

Referenced by initParameters(), and runComparator().

double CSCStripElectronicsSim::theComparatorTimeBinOffset
private

Definition at line 118 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

double CSCStripElectronicsSim::theComparatorTimeOffset
private

Definition at line 120 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

float CSCStripElectronicsSim::theComparatorWait
private

Definition at line 99 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

CSCCrosstalkGenerator* CSCStripElectronicsSim::theCrosstalkGenerator
private
float CSCStripElectronicsSim::theDaqDeadTime
private

Definition at line 101 of file CSCStripElectronicsSim.h.

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

Definition at line 123 of file CSCStripElectronicsSim.h.

Referenced by createDigi().

CSCStripConditions* CSCStripElectronicsSim::theStripConditions
private
float CSCStripElectronicsSim::theTimingOffset
private

Definition at line 103 of file CSCStripElectronicsSim.h.

Referenced by initParameters(), and runComparator().