13 #include "CLHEP/Units/GlobalPhysicalConstants.h" 14 #include "CLHEP/Units/GlobalSystemOfUnits.h" 15 #include "CLHEP/Random/RandGaussQ.h" 17 #include "boost/bind.hpp" 26 theComparatorThreshold(20.),
27 theComparatorNoise(0.),
28 theComparatorRMSOffset(2.),
29 theComparatorSaturation(1057.),
30 theComparatorWait(50.),
31 theComparatorDeadTime(100.),
34 nScaBins_(p.getParameter<
int>(
"nScaBins")),
35 doSuppression_(p.getParameter<
bool>(
"doSuppression")),
36 doCrosstalk_(p.getParameter<
bool>(
"doCrosstalk")),
39 theComparatorClockJump(2),
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"))
111 CLHEP::HepRandomEngine* engine)
const {
121 std::list<int> comparatorsWithSignal;
122 CSCSignalMap::iterator signalMapItr;
127 comparatorsWithSignal.push_back( ((*signalMapItr).first-1)/2 );
130 comparatorsWithSignal.unique();
131 for(std::list<int>::iterator listItr = comparatorsWithSignal.begin();
132 listItr != comparatorsWithSignal.end(); ++listItr) {
133 int iComparator = *listItr;
146 float comparatorTime =
time;
162 if(height1 > height2) {
163 mainSignal = &signal1;
164 float leftStrip = 0.;
165 if(iComparator > 0) {
170 output = (leftStrip < height2);
171 strip = iComparator*2 + 1;
174 mainSignal = &signal2;
175 float rightStrip = 0.;
180 output = (height1 < rightStrip);
181 strip = iComparator*2 + 2;
204 if ( (bxFloat>= 0) && (bxFloat<16) )
205 timeWord = (1 <<
static_cast<int>(bxFloat) );
208 result.push_back(newDigi);
214 float resetThreshold = 1;
224 sort(result.begin(), result.end());
232 for(std::vector<CSCComparatorDigi>::const_iterator compItr = comparators.begin();
233 compItr != comparators.end(); ++compItr)
237 result.push_back(compItr->getStrip());
267 std::list<int>::const_iterator keyStripItr = keyStrips.begin();
270 for( ; keyStripItr != keyStrips.end(); ++keyStripItr)
273 for(
int istrip = (*keyStripItr)-
window; istrip <= (*keyStripItr)+
window; ++istrip)
287 std::list<int> cfebsToRead;
288 for( ; keyStripItr != keyStrips.end(); ++keyStripItr)
291 cfebsToRead.push_back(cfeb);
294 if(remainder < window && cfeb != 0)
296 cfebsToRead.push_back(cfeb-1);
300 if(remainder >= 16-window && cfeb != maxCFEBs)
302 cfebsToRead.push_back(cfeb+1);
306 cfebsToRead.unique();
309 for(std::list<int>::const_iterator cfebItr = cfebsToRead.begin();
310 cfebItr != cfebsToRead.end(); ++cfebItr)
312 for(
int i = 1;
i <= 16; ++
i)
314 result.push_back((*cfebItr)*16 +
i);
332 CLHEP::HepRandomEngine* engine)
338 std::vector<CSCComparatorDigi> comparatorOutputs;
341 if(!comparatorOutputs.empty())
344 comparatorOutputs.end());
345 comparators.put(range,
layerId());
356 CLHEP::HepRandomEngine* engine)
359 std::vector<CSCStripDigi> stripDigis;
360 stripDigis.reserve(stripsToDo.size());
361 for(std::list<int>::const_iterator stripItr = stripsToDo.begin();
362 stripItr != stripsToDo.end(); ++stripItr)
364 createDigi( *stripItr,
find(*stripItr, engine), stripDigis, engine);
368 digis.put(stripRange,
layerId());
375 std::vector<CSCAnalogSignal> realSignals;
378 for( ; mapI != mapEnd; ++mapI) {
379 realSignals.push_back((*mapI).second);
382 std::vector<CSCAnalogSignal>::iterator realSignalItr = realSignals.begin(),
383 realSignalsEnd = realSignals.end();
384 for( ; realSignalItr != realSignalsEnd; ++realSignalItr)
386 int thisStrip = (*realSignalItr).getElement();
389 int otherStrip = thisStrip - 1;
390 addCrosstalk(*realSignalItr, thisStrip, otherStrip, engine);
393 int otherStrip = thisStrip + 1;
394 addCrosstalk(*realSignalItr, thisStrip, otherStrip, engine);
401 int thisStrip,
int otherStrip,
402 CLHEP::HepRandomEngine* engine)
404 float capacitiveCrosstalk, resistiveCrosstalk;
405 bool leftRight = (otherStrip > thisStrip);
408 capacitiveCrosstalk, resistiveCrosstalk);
414 crosstalkSignal *= -1.;
421 CLHEP::HepRandomEngine* engine)
434 for(
int scaBin = 0; scaBin <
nScaBins_; ++scaBin) {
436 scaCounts[scaBin] =
static_cast< int > 444 result.push_back(newDigi);
446 LogTrace(
"CSCStripElectronicsSim") << newDigi;
453 for(
unsigned scaBin = 0; scaBin < scaCounts.size(); ++scaBin) {
454 scaCounts[scaBin] =
std::min(scaCounts[scaBin], 4095);
463 CLHEP::HepRandomEngine* engine)
469 std::list<int> chamberKeyStrips;
471 comparatorItr != comparators.end(); ++comparatorItr)
476 std::vector<CSCComparatorDigi> layerComparators((*comparatorItr).second.first, (*comparatorItr).second.second);
477 std::list<int> layerKeyStrips =
getKeyStrips(layerComparators);
478 chamberKeyStrips.insert(chamberKeyStrips.end(), layerKeyStrips.begin(), layerKeyStrips.end());
481 chamberKeyStrips.sort();
482 chamberKeyStrips.unique();
490 std::list<int> keyStrips, stripsRead;
499 unsigned int expectedSize = isGanged ? 10 : 12;
500 assert(stripsRead.size() == expectedSize);
505 unsigned int expectedSize = isGanged ? 16 : 48;
506 assert(stripsRead.size() == expectedSize);
507 assert(stripsRead.front() == 1);
std::vector< double > theBunchTimingOffsets
int readoutElement(int strip) const override
void initParameters() override
initialization for each layer
const CSCLayer * theLayer
const CSCChamberSpecs * theSpecs
CSCSignalMap theSignalMap
const CSCLayerGeometry * theLayerGeometry
bool SortSignalsByTotal(const CSCAnalogSignal &s1, const CSCAnalogSignal &s2)
std::vector< int > const & getADCCounts() const
Get ADC readings.
double theComparatorTimeOffset
std::list< int > getKeyStripsFromMC() const
get ths strips that have detector hits
void addCrosstalk(CLHEP::HepRandomEngine *)
float length() const override
void runComparator(std::vector< CSCComparatorDigi > &result, CLHEP::HepRandomEngine *)
float theComparatorDeadTime
int numberOfStrips() const
const Plane & surface() const
The nominal surface of the GeomDet.
void setADCCounts(const std::vector< int > &ADCCounts)
CSCStripConditions * theStripConditions
void setLayer(const CSCLayer *layer)
float comparatorReading(const CSCAnalogSignal &signal, float time, CLHEP::HepRandomEngine *) const
calculates the comparator reading, including saturation and offsets
std::vector< double > theSCATimingOffsets
std::list< int > channelsToRead(const std::list< int > &keyStrips, int window) const
float calculateAmpResponse(float t) const override
float theComparatorRMSOffset
void noisify(const CSCDetId &detId, CSCAnalogSignal &signal, CLHEP::HepRandomEngine *)
superimposes noise, in fC, on the signal
Abs< T >::type abs(const T &t)
CSCAnalogSignal makeNoiseSignal(int element, CLHEP::HepRandomEngine *) override
CSCDetId chamberId() const
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
void fillMissingLayer(const CSCLayer *layer, const CSCComparatorDigiCollection &comparators, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *)
CSCCrosstalkGenerator * theCrosstalkGenerator
void superimpose(const CSCAnalogSignal &signal2)
void doSaturation(CSCStripDigi &digi)
~CSCStripElectronicsSim() override
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
CSCAnalogSignal getCrosstalk(const CSCAnalogSignal &inputSignal) const
virtual float pedestal(const CSCDetId &detId, int channel) const =0
in ADC counts
float theComparatorSaturation
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
double theComparatorSamplingTime
CSCAnalogSignal & find(int element, CLHEP::HepRandomEngine *)
void fillDigis(CSCStripDigiCollection &digis, CSCComparatorDigiCollection &comparators, CLHEP::HepRandomEngine *)
float theAverageTimeOfFlight
virtual void crosstalk(const CSCDetId &detId, int channel, double stripLength, bool leftRight, float &capacitive, float &resistive) const =0
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::pair< const_iterator, const_iterator > Range
const PositionType & position() const
CSCStripAmpResponse theAmpResponse
void createDigi(int istrip, const CSCAnalogSignal &signal, std::vector< CSCStripDigi > &result, CLHEP::HepRandomEngine *)
void fillStripDigis(const std::list< int > &keyStrips, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *)
std::vector< double > theTimingCalibrationError