12 #include "CLHEP/Units/GlobalPhysicalConstants.h"
13 #include "CLHEP/Units/GlobalSystemOfUnits.h"
14 #include "boost/bind.hpp"
23 theComparatorThreshold(20.),
24 theComparatorNoise(0.),
25 theComparatorRMSOffset(2.),
26 theComparatorSaturation(1057.),
27 theComparatorWait(50.),
28 theComparatorDeadTime(100.),
31 nScaBins_(p.getParameter<int>(
"nScaBins")),
32 doSuppression_(p.getParameter<bool>(
"doSuppression")),
33 doCrosstalk_(p.getParameter<bool>(
"doCrosstalk")),
34 theStripConditions(0),
35 theCrosstalkGenerator(0),
36 theComparatorClockJump(2),
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"))
117 std::list<int> comparatorsWithSignal;
118 CSCSignalMap::iterator signalMapItr;
123 comparatorsWithSignal.push_back( ((*signalMapItr).first-1)/2 );
126 comparatorsWithSignal.unique();
127 for(std::list<int>::iterator listItr = comparatorsWithSignal.begin();
128 listItr != comparatorsWithSignal.end(); ++listItr) {
129 int iComparator = *listItr;
142 float comparatorTime =
time;
158 if(height1 > height2) {
159 mainSignal = &signal1;
160 float leftStrip = 0.;
161 if(iComparator > 0) {
166 output = (leftStrip < height2);
167 strip = iComparator*2 + 1;
170 mainSignal = &signal2;
171 float rightStrip = 0.;
176 output = (height1 < rightStrip);
177 strip = iComparator*2 + 2;
200 if ( (bxFloat>= 0) && (bxFloat<16) )
201 timeWord = (1 <<
static_cast<int>(bxFloat) );
204 result.push_back(newDigi);
210 float resetThreshold = 1;
220 sort(result.begin(), result.end());
228 for(std::vector<CSCComparatorDigi>::const_iterator compItr = comparators.begin();
229 compItr != comparators.end(); ++compItr)
233 result.push_back(compItr->getStrip());
260 std::list<int>::const_iterator keyStripItr = keyStrips.begin();
263 for( ; keyStripItr != keyStrips.end(); ++keyStripItr)
266 for(
int istrip = (*keyStripItr)-
window; istrip <= (*keyStripItr)+
window; ++istrip)
280 std::list<int> cfebsToRead;
281 for( ; keyStripItr != keyStrips.end(); ++keyStripItr)
284 cfebsToRead.push_back(cfeb);
287 if(remainder < window && cfeb != 0)
289 cfebsToRead.push_back(cfeb-1);
293 if(remainder >= 16-window && cfeb != maxCFEBs)
295 cfebsToRead.push_back(cfeb+1);
299 cfebsToRead.unique();
302 for(std::list<int>::const_iterator cfebItr = cfebsToRead.begin();
303 cfebItr != cfebsToRead.end(); ++cfebItr)
305 for(
int i = 1;
i <= 16; ++
i)
307 result.push_back((*cfebItr)*16 +
i);
330 std::vector<CSCComparatorDigi> comparatorOutputs;
333 if(!comparatorOutputs.empty())
336 comparatorOutputs.end());
337 comparators.put(range,
layerId());
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)
359 digis.put(stripRange,
layerId());
366 std::vector<CSCAnalogSignal> realSignals;
369 for( ; mapI != mapEnd; ++mapI) {
370 realSignals.push_back((*mapI).second);
373 std::vector<CSCAnalogSignal>::iterator realSignalItr = realSignals.begin(),
374 realSignalsEnd = realSignals.end();
375 for( ; realSignalItr != realSignalsEnd; ++realSignalItr)
377 int thisStrip = (*realSignalItr).getElement();
380 int otherStrip = thisStrip - 1;
384 int otherStrip = thisStrip + 1;
392 int thisStrip,
int otherStrip)
394 float capacitiveCrosstalk, resistiveCrosstalk;
395 bool leftRight = (otherStrip > thisStrip);
398 capacitiveCrosstalk, resistiveCrosstalk);
404 crosstalkSignal *= -1.;
423 for(
int scaBin = 0; scaBin <
nScaBins_; ++scaBin) {
425 scaCounts[scaBin] =
static_cast< int >
426 ( pedestal + signal.
getValue(t) * gain );
433 result.push_back(newDigi);
435 LogTrace(
"CSCStripElectronicsSim") << newDigi;
442 for(
unsigned scaBin = 0; scaBin < scaCounts.size(); ++scaBin) {
443 scaCounts[scaBin] =
std::min(scaCounts[scaBin], 4095);
456 std::list<int> chamberKeyStrips;
458 comparatorItr != comparators.end(); ++comparatorItr)
461 if(
CSCDetId((*comparatorItr).first).chamberId() == chamberId)
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());
468 chamberKeyStrips.sort();
469 chamberKeyStrips.unique();
477 std::list<int> keyStrips, stripsRead;
486 unsigned int expectedSize = isGanged ? 10 : 12;
487 assert(stripsRead.size() == expectedSize);
492 unsigned int expectedSize = isGanged ? 16 : 48;
493 assert(stripsRead.size() == expectedSize);
494 assert(stripsRead.front() == 1);
std::vector< double > theBunchTimingOffsets
const CSCLayer * theLayer
const CSCChamberSpecs * theSpecs
CSCSignalMap theSignalMap
const CSCLayerGeometry * theLayerGeometry
bool SortSignalsByTotal(const CSCAnalogSignal &s1, const CSCAnalogSignal &s2)
float comparatorReading(const CSCAnalogSignal &signal, float time) const
calculates the comparator reading, including saturation and offsets
double theComparatorTimeOffset
std::vector< int > getADCCounts() const
Get ADC readings.
virtual float pedestal(const CSCDetId &detId, int channel) const =0
in ADC counts
std::list< int > getKeyStripsFromMC() const
get ths strips that have detector hits
void fillMissingLayer(const CSCLayer *layer, const CSCComparatorDigiCollection &comparators, CSCStripDigiCollection &digis)
float calculateAmpResponse(float t) const
virtual void crosstalk(const CSCDetId &detId, int channel, double stripLength, bool leftRight, float &capacitive, float &resistive) const =0
float theComparatorDeadTime
void fillStripDigis(const std::list< int > &keyStrips, CSCStripDigiCollection &digis)
int numberOfStrips() const
void noisify(const CSCDetId &detId, CSCAnalogSignal &signal)
superimposes noise, in fC, on the signal
CSCAnalogSignal makeNoiseSignal(int element)
CSCStripConditions * theStripConditions
virtual ~CSCStripElectronicsSim()
void setLayer(const CSCLayer *layer)
CLHEP::RandGaussQ * theRandGaussQ
std::vector< double > theSCATimingOffsets
void setADCCounts(std::vector< int > ADCCounts)
void createDigi(int istrip, const CSCAnalogSignal &signal, std::vector< CSCStripDigi > &result)
std::list< int > channelsToRead(const std::list< int > &keyStrips, int window) const
float theComparatorRMSOffset
void runComparator(std::vector< CSCComparatorDigi > &result)
CSCDetId chamberId() const
CSCCrosstalkGenerator * theCrosstalkGenerator
void superimpose(const CSCAnalogSignal &signal2)
void initParameters()
initialization for each layer
void doSaturation(CSCStripDigi &digi)
int channel(int strip) const
float theComparatorThreshold
float calculateAmpResponse(float t) const
virtual void addLinks(int channelIndex)
DetectorHitMap theDetectorHitMap
CSCStripElectronicsSim(const edm::ParameterSet &p)
configurable parameters
double theComparatorTimeBinOffset
void setParameters(float crosstalk, float delay, float resistiveFraction)
std::list< int > getKeyStrips(const std::vector< CSCComparatorDigi > &comparators) const
finds the key strips from these comparators
virtual float smearedGain(const CSCDetId &detId, int channel) const
CSCAnalogSignal getCrosstalk(const CSCAnalogSignal &inputSignal) const
float theComparatorSaturation
void fillDigis(CSCStripDigiCollection &digis, CSCComparatorDigiCollection &comparators)
virtual int readoutElement(int strip) const
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
double theComparatorSamplingTime
float theAverageTimeOfFlight
CSCAnalogSignal & find(int element)
float getValue(float t) const
virtual int channelIndex(int channel) const
lets users map channels to different indices for links
std::pair< const_iterator, const_iterator > Range
virtual float length() const
const PositionType & position() const
CSCStripAmpResponse theAmpResponse
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
std::vector< double > theTimingCalibrationError