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)
 
 CSCStripElectronicsSim (const edm::ParameterSet &p)
 configurable parameters More...
 
void fillDigis (CSCStripDigiCollection &digis, CSCComparatorDigiCollection &comparators)
 
void fillMissingLayer (const CSCLayer *layer, const CSCComparatorDigiCollection &comparators, CSCStripDigiCollection &digis)
 
CSCAnalogSignal makeNoiseSignal (int element)
 
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 setRandomEngine (CLHEP::HepRandomEngine &engine)
 
void simulate (const CSCLayer *layer, const std::vector< CSCDetectorHit > &inputHits)
 
virtual ~CSCBaseElectronicsSim ()
 

Private Member Functions

void addCrosstalk ()
 
void addCrosstalk (const CSCAnalogSignal &signal, int thisStrip, int otherStrip)
 
float calculateAmpResponse (float t) const
 
std::list< int > channelsToRead (const std::list< int > &keyStrips, int window) const
 
float comparatorReading (const CSCAnalogSignal &signal, float time) const
 calculates the comparator reading, including saturation and offsets More...
 
void doSaturation (CSCStripDigi &digi)
 
void fillStripDigis (const std::list< int > &keyStrips, CSCStripDigiCollection &digis)
 
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)
 
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 &)
 
virtual void addLinks (int channelIndex)
 
void addNoise ()
 
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)
 
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
 
CLHEP::RandGaussQ * theRandGaussQ
 
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 23 of file CSCStripElectronicsSim.h.

Constructor & Destructor Documentation

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

configurable parameters

Definition at line 20 of file CSCStripElectronicsSim.cc.

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

27  theComparatorWait(50.),
29  theDaqDeadTime(200.),
30  theTimingOffset(0.),
31  nScaBins_(p.getParameter<int>("nScaBins")),
32  doSuppression_(p.getParameter<bool>("doSuppression")),
33  doCrosstalk_(p.getParameter<bool>("doCrosstalk")),
37  sca_time_bin_size(50.),
38  sca_peak_bin(p.getParameter<int>("scaPeakBin")),
39  theComparatorTimeBinOffset(p.getParameter<double>("comparatorTimeBinOffset")),
40  theComparatorTimeOffset(p.getParameter<double>("comparatorTimeOffset")),
41  theComparatorSamplingTime(p.getParameter<double>("comparatorSamplingTime")),
42  theSCATimingOffsets(p.getParameter<std::vector<double> >("scaTimingOffsets"))
43 {
44 
45  if(doCrosstalk_) {
47  }
48 
50 }
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 53 of file CSCStripElectronicsSim.cc.

References doCrosstalk_, and theCrosstalkGenerator.

53  {
54  if(doCrosstalk_) {
55  delete theCrosstalkGenerator;
56  }
57 }
CSCCrosstalkGenerator * theCrosstalkGenerator

Member Function Documentation

void CSCStripElectronicsSim::addCrosstalk ( )
private

Definition at line 363 of file CSCStripElectronicsSim.cc.

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

Referenced by fillDigis().

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

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

393 {
394  float capacitiveCrosstalk, resistiveCrosstalk;
395  bool leftRight = (otherStrip > thisStrip);
396  theStripConditions->crosstalk(layerId(), thisStrip,
397  theLayerGeometry->length(), leftRight,
398  capacitiveCrosstalk, resistiveCrosstalk);
399  theCrosstalkGenerator->setParameters(capacitiveCrosstalk, 0., resistiveCrosstalk);
400  CSCAnalogSignal crosstalkSignal( theCrosstalkGenerator->getCrosstalk(signal) );
401  find(readoutElement(otherStrip)).superimpose(crosstalkSignal);
402 
403  // Now subtract the crosstalk signal from the original signal
404  crosstalkSignal *= -1.;
405  find(thisStrip).superimpose(crosstalkSignal);
406 
407 }
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)
virtual float length() const
float CSCStripElectronicsSim::calculateAmpResponse ( float  t) const
privatevirtual

Implements CSCBaseElectronicsSim.

Definition at line 84 of file CSCStripElectronicsSim.cc.

References CSCStripAmpResponse::calculateAmpResponse(), and theAmpResponse.

85 {
87 }
float calculateAmpResponse(float t) const
CSCStripAmpResponse theAmpResponse
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 257 of file CSCStripElectronicsSim.cc.

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

Referenced by fillStripDigis(), and selfTest().

258 {
259  std::list<int> result;
260  std::list<int>::const_iterator keyStripItr = keyStrips.begin();
261  if(doSuppression_)
262  {
263  for( ; keyStripItr != keyStrips.end(); ++keyStripItr)
264  {
265  // pick the five strips around the comparator
266  for(int istrip = (*keyStripItr)-window; istrip <= (*keyStripItr)+window; ++istrip)
267  {
268  if(istrip>0 && istrip<= nElements)
269  {
270  result.push_back(readoutElement(istrip));
271  }
272  }
273  }
274  result.sort();
275  result.unique();
276  }
277  else
278  {
279  // read the whole CFEB, 16 strips
280  std::list<int> cfebsToRead;
281  for( ; keyStripItr != keyStrips.end(); ++keyStripItr)
282  {
283  int cfeb = (readoutElement(*keyStripItr)-1)/16;
284  cfebsToRead.push_back(cfeb);
285  int remainder = (readoutElement(*keyStripItr)-1)%16;
286  // if we're within 3 strips of an edge, take neighboring CFEB, too
287  if(remainder < window && cfeb != 0)
288  {
289  cfebsToRead.push_back(cfeb-1);
290  }
291  // the 'readouElement' makes it so that ME1/1 has just one CFEB
292  int maxCFEBs = readoutElement(nElements)/16 - 1;
293  if(remainder >= 16-window && cfeb != maxCFEBs)
294  {
295  cfebsToRead.push_back(cfeb+1);
296  }
297  }
298  cfebsToRead.sort();
299  cfebsToRead.unique();
300 
301  // now convert the CFEBS to strips
302  for(std::list<int>::const_iterator cfebItr = cfebsToRead.begin();
303  cfebItr != cfebsToRead.end(); ++cfebItr)
304  {
305  for(int i = 1; i <= 16; ++i)
306  {
307  result.push_back((*cfebItr)*16 + i);
308  }
309  }
310  }
311  return result;
312 }
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 
) const
private

calculates the comparator reading, including saturation and offsets

Definition at line 106 of file CSCStripElectronicsSim.cc.

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

Referenced by runComparator().

107  {
110 }
#define min(a, b)
Definition: mlp_lapack.h:161
CLHEP::RandGaussQ * theRandGaussQ
float getValue(float t) const
void CSCStripElectronicsSim::createDigi ( int  istrip,
const CSCAnalogSignal signal,
std::vector< CSCStripDigi > &  result 
)

Definition at line 410 of file CSCStripElectronicsSim.cc.

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

Referenced by fillStripDigis().

411 {
412  // fill in the sca information
413  std::vector<int> scaCounts(nScaBins_);
414 
415  float pedestal = theStripConditions->pedestal(layerId(), channel);
416  float gain = theStripConditions->smearedGain(layerId(), channel);
417  int chamberType = theSpecs->chamberType();
418  float timeSmearing = theRandGaussQ->fire() * theTimingCalibrationError[chamberType];
419  // undo the correction for TOF, instead, using some nominal
420  // value from ME2/1
421  float t0 = theSignalStartTime+theSCATimingOffsets[chamberType] + timeSmearing
422  + 29. - theAverageTimeOfFlight;
423  for(int scaBin = 0; scaBin < nScaBins_; ++scaBin) {
424  float t = t0 + scaBin*sca_time_bin_size;
425  scaCounts[scaBin] = static_cast< int >
426  ( pedestal + signal.getValue(t) * gain );
427  }
428  CSCStripDigi newDigi(channel, scaCounts);
429 
430  // do saturation of 12-bit ADC
431  doSaturation(newDigi);
432 
433  result.push_back(newDigi);
434  addLinks(channelIndex(channel));
435  LogTrace("CSCStripElectronicsSim") << newDigi;
436 }
const CSCChamberSpecs * theSpecs
virtual float pedestal(const CSCDetId &detId, int channel) const =0
in ADC counts
CSCStripConditions * theStripConditions
CLHEP::RandGaussQ * theRandGaussQ
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
virtual float smearedGain(const CSCDetId &detId, int channel) const
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
float getValue(float t) 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 439 of file CSCStripElectronicsSim.cc.

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

Referenced by createDigi().

440 {
441  std::vector<int> scaCounts(digi.getADCCounts());
442  for(unsigned scaBin = 0; scaBin < scaCounts.size(); ++scaBin) {
443  scaCounts[scaBin] = std::min(scaCounts[scaBin], 4095);
444  }
445  digi.setADCCounts(scaCounts);
446 }
std::vector< int > getADCCounts() const
Get ADC readings.
Definition: CSCStripDigi.cc:41
#define min(a, b)
Definition: mlp_lapack.h:161
void setADCCounts(std::vector< int > ADCCounts)
Definition: CSCStripDigi.cc:72
void CSCStripElectronicsSim::fillDigis ( CSCStripDigiCollection digis,
CSCComparatorDigiCollection comparators 
)

Definition at line 323 of file CSCStripElectronicsSim.cc.

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

Referenced by CSCDigitizer::doAction().

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

Definition at line 449 of file CSCStripElectronicsSim.cc.

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

Referenced by CSCDigitizer::doAction().

451 {
452  theSignalMap.clear();
453  setLayer(layer);
454  CSCDetId chamberId(theLayerId.chamberId());
455  // find all comparator key strips in this chamber
456  std::list<int> chamberKeyStrips;
457  for(CSCComparatorDigiCollection::DigiRangeIterator comparatorItr = comparators.begin();
458  comparatorItr != comparators.end(); ++comparatorItr)
459  {
460  // could be more efficient
461  if(CSCDetId((*comparatorItr).first).chamberId() == chamberId)
462  {
463  std::vector<CSCComparatorDigi> layerComparators((*comparatorItr).second.first, (*comparatorItr).second.second);
464  std::list<int> layerKeyStrips = getKeyStrips(layerComparators);
465  chamberKeyStrips.insert(chamberKeyStrips.end(), layerKeyStrips.begin(), layerKeyStrips.end());
466  }
467  }
468  chamberKeyStrips.sort();
469  chamberKeyStrips.unique();
470  fillStripDigis(chamberKeyStrips, digis);
471 }
void fillStripDigis(const std::list< int > &keyStrips, CSCStripDigiCollection &digis)
void setLayer(const CSCLayer *layer)
CSCDetId chamberId() const
Definition: CSCDetId.h:55
std::list< int > getKeyStrips(const std::vector< CSCComparatorDigi > &comparators) const
finds the key strips from these comparators
void CSCStripElectronicsSim::fillStripDigis ( const std::list< int > &  keyStrips,
CSCStripDigiCollection digis 
)
private

Definition at line 346 of file CSCStripElectronicsSim.cc.

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

Referenced by fillDigis(), and fillMissingLayer().

348 {
349  std::list<int> stripsToDo = channelsToRead(keyStrips, 3);
350  std::vector<CSCStripDigi> stripDigis;
351  stripDigis.reserve(stripsToDo.size());
352  for(std::list<int>::const_iterator stripItr = stripsToDo.begin();
353  stripItr != stripsToDo.end(); ++stripItr)
354  {
355  createDigi( *stripItr, find(*stripItr), stripDigis);
356  }
357 
358  CSCStripDigiCollection::Range stripRange(stripDigis.begin(), stripDigis.end());
359  digis.put(stripRange, layerId());
360 }
void createDigi(int istrip, const CSCAnalogSignal &signal, std::vector< CSCStripDigi > &result)
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)
std::pair< const_iterator, const_iterator > Range
std::list< int > CSCStripElectronicsSim::getKeyStrips ( const std::vector< CSCComparatorDigi > &  comparators) const
private

finds the key strips from these comparators

Definition at line 225 of file CSCStripElectronicsSim.cc.

References abs, query::result, and CSCBaseElectronicsSim::theOffsetOfBxZero.

Referenced by fillMissingLayer().

226 {
227  std::list<int> result;
228  for(std::vector<CSCComparatorDigi>::const_iterator compItr = comparators.begin();
229  compItr != comparators.end(); ++compItr)
230  {
231  if(std::abs(compItr->getTimeBin()-theOffsetOfBxZero) <= 2)
232  {
233  result.push_back(compItr->getStrip());
234  }
235  }
236  // need sort for unique to work.
237  result.sort();
238  result.unique();
239  return result;
240 }
#define abs(x)
Definition: mlp_lapack.h:159
tuple result
Definition: query.py:137
std::list< int > CSCStripElectronicsSim::getKeyStripsFromMC ( ) const
private

get ths strips that have detector hits

Definition at line 244 of file CSCStripElectronicsSim.cc.

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

Referenced by fillDigis().

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

initialization for each layer

Implements CSCBaseElectronicsSim.

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

59  {
62  //selfTest();
63 
64  //calculate the offset to the peak
65  float averageDistance = theLayer->surface().position().mag();
66  theAverageTimeOfFlight = averageDistance * cm / c_light; // Units of c_light: mm/ns
67  int chamberType = theSpecs->chamberType();
69  + theBunchTimingOffsets[chamberType];
70 //TODO make sure config gets overridden
74  theNumberOfSamples = nScaBins_*static_cast<int>(sca_time_bin_size/theSamplingTime);
75 
76 }
std::vector< double > theBunchTimingOffsets
const CSCChamberSpecs * theSpecs
const CSCLayerGeometry * theLayerGeometry
int numberOfStrips() const
T mag() const
Definition: PV3DBase.h:66
int chamberType() const
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
const PositionType & position() const
CSCAnalogSignal CSCStripElectronicsSim::makeNoiseSignal ( int  element)
virtual

Reimplemented from CSCBaseElectronicsSim.

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

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

Implements CSCBaseElectronicsSim.

Definition at line 79 of file CSCStripElectronicsSim.cc.

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

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

79  {
81 }
const CSCLayerGeometry * theLayerGeometry
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
int channel(int strip) const
void CSCStripElectronicsSim::runComparator ( std::vector< CSCComparatorDigi > &  result)
private

Definition at line 114 of file CSCStripElectronicsSim.cc.

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

Referenced by fillDigis().

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

Definition at line 474 of file CSCStripElectronicsSim.cc.

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

475 {
476  // make sure the zero suppression algorithms work
477  std::list<int> keyStrips, stripsRead;
478  //
479  bool isGanged = (readoutElement(nElements) == 16);
480  keyStrips.push_back(readoutElement(19));
481  keyStrips.push_back(readoutElement(30));
482  keyStrips.push_back(readoutElement(32));
483  stripsRead = channelsToRead(keyStrips, 3);
484  if(doSuppression_)
485  {
486  unsigned int expectedSize = isGanged ? 10 : 12;
487  assert(stripsRead.size() == expectedSize);
488  assert(stripsRead.front() == readoutElement(17));
489  }
490  else
491  {
492  unsigned int expectedSize = isGanged ? 16 : 48;
493  assert(stripsRead.size() == expectedSize);
494  assert(stripsRead.front() == 1);
495  }
496 }
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 37 of file CSCStripElectronicsSim.h.

References theStripConditions.

Referenced by CSCDigitizer::setStripConditions().

37 {theStripConditions = cond;}
CSCStripConditions * theStripConditions

Member Data Documentation

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

Definition at line 100 of file CSCStripElectronicsSim.h.

Referenced by channelsToRead(), and selfTest().

int CSCStripElectronicsSim::nScaBins_
private

Definition at line 99 of file CSCStripElectronicsSim.h.

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

int CSCStripElectronicsSim::sca_peak_bin
private

Definition at line 110 of file CSCStripElectronicsSim.h.

Referenced by initParameters().

float CSCStripElectronicsSim::sca_time_bin_size
private

Definition at line 107 of file CSCStripElectronicsSim.h.

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

CSCStripAmpResponse CSCStripElectronicsSim::theAmpResponse
private

Definition at line 50 of file CSCStripElectronicsSim.h.

Referenced by calculateAmpResponse().

float CSCStripElectronicsSim::theAverageTimeOfFlight
private

Definition at line 120 of file CSCStripElectronicsSim.h.

Referenced by createDigi(), and initParameters().

int CSCStripElectronicsSim::theComparatorClockJump
private

Definition at line 105 of file CSCStripElectronicsSim.h.

float CSCStripElectronicsSim::theComparatorDeadTime
private

Definition at line 94 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

float CSCStripElectronicsSim::theComparatorNoise
private

Definition at line 88 of file CSCStripElectronicsSim.h.

float CSCStripElectronicsSim::theComparatorRMSOffset
private

Definition at line 89 of file CSCStripElectronicsSim.h.

Referenced by comparatorReading().

double CSCStripElectronicsSim::theComparatorSamplingTime
private

Definition at line 115 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

float CSCStripElectronicsSim::theComparatorSaturation
private

Definition at line 91 of file CSCStripElectronicsSim.h.

Referenced by comparatorReading().

float CSCStripElectronicsSim::theComparatorThreshold
private

Definition at line 87 of file CSCStripElectronicsSim.h.

Referenced by initParameters(), and runComparator().

double CSCStripElectronicsSim::theComparatorTimeBinOffset
private

Definition at line 112 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

double CSCStripElectronicsSim::theComparatorTimeOffset
private

Definition at line 114 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

float CSCStripElectronicsSim::theComparatorWait
private

Definition at line 93 of file CSCStripElectronicsSim.h.

Referenced by runComparator().

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

Definition at line 95 of file CSCStripElectronicsSim.h.

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

Definition at line 117 of file CSCStripElectronicsSim.h.

Referenced by createDigi().

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

Definition at line 97 of file CSCStripElectronicsSim.h.

Referenced by initParameters(), and runComparator().