13 #include "CLHEP/Random/RandGaussQ.h" 14 #include "CLHEP/Units/GlobalPhysicalConstants.h" 15 #include "CLHEP/Units/GlobalSystemOfUnits.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")) {
96 CLHEP::HepRandomEngine *engine)
const {
104 std::list<int> comparatorsWithSignal;
105 CSCSignalMap::iterator signalMapItr;
109 comparatorsWithSignal.push_back(((*signalMapItr).first - 1) / 2);
112 comparatorsWithSignal.unique();
113 for (std::list<int>::iterator listItr = comparatorsWithSignal.begin(); listItr != comparatorsWithSignal.end();
115 int iComparator = *listItr;
126 float comparatorTime =
time;
142 if (height1 > height2) {
143 mainSignal = &signal1;
144 float leftStrip = 0.;
145 if (iComparator > 0) {
151 output = (leftStrip < height2);
152 strip = iComparator * 2 + 1;
155 mainSignal = &signal2;
156 float rightStrip = 0.;
161 output = (height1 < rightStrip);
162 strip = iComparator * 2 + 2;
185 if ((bxFloat >= 0) && (bxFloat < 16))
186 timeWord = (1 <<
static_cast<int>(bxFloat));
189 result.push_back(newDigi);
195 float resetThreshold = 1;
196 while (time < theSignalStopTime && mainSignal->
getValue(
time) > resetThreshold) {
204 sort(result.begin(), result.end());
209 for (std::vector<CSCComparatorDigi>::const_iterator compItr = comparators.begin(); compItr != comparators.end();
212 result.push_back(compItr->getStrip());
229 back_inserter(result),
240 std::list<int>::const_iterator keyStripItr = keyStrips.begin();
242 for (; keyStripItr != keyStrips.end(); ++keyStripItr) {
244 for (
int istrip = (*keyStripItr) -
window; istrip <= (*keyStripItr) +
window; ++istrip) {
254 std::list<int> cfebsToRead;
255 for (; keyStripItr != keyStrips.end(); ++keyStripItr) {
257 cfebsToRead.push_back(cfeb);
260 if (remainder < window && cfeb != 0) {
261 cfebsToRead.push_back(cfeb - 1);
265 if (remainder >= 16 - window && cfeb != maxCFEBs) {
266 cfebsToRead.push_back(cfeb + 1);
270 cfebsToRead.unique();
273 for (std::list<int>::const_iterator cfebItr = cfebsToRead.begin(); cfebItr != cfebsToRead.end(); ++cfebItr) {
274 for (
int i = 1;
i <= 16; ++
i) {
275 result.push_back((*cfebItr) * 16 +
i);
288 CLHEP::HepRandomEngine *engine) {
293 std::vector<CSCComparatorDigi> comparatorOutputs;
296 if (!comparatorOutputs.empty()) {
298 comparators.put(range,
layerId());
308 CLHEP::HepRandomEngine *engine) {
310 std::vector<CSCStripDigi> stripDigis;
311 stripDigis.reserve(stripsToDo.size());
312 for (std::list<int>::const_iterator stripItr = stripsToDo.begin(); stripItr != stripsToDo.end(); ++stripItr) {
313 createDigi(*stripItr,
find(*stripItr, engine), stripDigis, engine);
317 digis.put(stripRange,
layerId());
323 std::vector<CSCAnalogSignal> realSignals;
326 for (; mapI != mapEnd; ++mapI) {
327 realSignals.push_back((*mapI).second);
330 std::vector<CSCAnalogSignal>::iterator realSignalItr = realSignals.begin(), realSignalsEnd = realSignals.end();
331 for (; realSignalItr != realSignalsEnd; ++realSignalItr) {
332 int thisStrip = (*realSignalItr).getElement();
335 int otherStrip = thisStrip - 1;
336 addCrosstalk(*realSignalItr, thisStrip, otherStrip, engine);
339 int otherStrip = thisStrip + 1;
340 addCrosstalk(*realSignalItr, thisStrip, otherStrip, engine);
348 CLHEP::HepRandomEngine *engine) {
349 float capacitiveCrosstalk, resistiveCrosstalk;
350 bool leftRight = (otherStrip > thisStrip);
358 crosstalkSignal *= -1.;
364 std::vector<CSCStripDigi> &
result,
365 CLHEP::HepRandomEngine *engine) {
376 for (
int scaBin = 0; scaBin <
nScaBins_; ++scaBin) {
378 scaCounts[scaBin] =
static_cast<int>(pedestal + signal.
getValue(t) *
gain);
385 result.push_back(newDigi);
387 LogTrace(
"CSCStripElectronicsSim") << newDigi;
392 for (
unsigned scaBin = 0; scaBin < scaCounts.size(); ++scaBin) {
393 scaCounts[scaBin] =
std::min(scaCounts[scaBin], 4095);
401 CLHEP::HepRandomEngine *engine) {
406 std::list<int> chamberKeyStrips;
408 comparatorItr != comparators.end();
412 std::vector<CSCComparatorDigi> layerComparators((*comparatorItr).second.first, (*comparatorItr).second.second);
413 std::list<int> layerKeyStrips =
getKeyStrips(layerComparators);
414 chamberKeyStrips.insert(chamberKeyStrips.end(), layerKeyStrips.begin(), layerKeyStrips.end());
417 chamberKeyStrips.sort();
418 chamberKeyStrips.unique();
424 std::list<int> keyStrips, stripsRead;
432 unsigned int expectedSize = isGanged ? 10 : 12;
433 assert(stripsRead.size() == expectedSize);
436 unsigned int expectedSize = isGanged ? 16 : 48;
437 assert(stripsRead.size() == expectedSize);
438 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
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
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