13 #include "CLHEP/Random/RandGaussQ.h" 14 #include "CLHEP/Units/GlobalPhysicalConstants.h" 15 #include "CLHEP/Units/GlobalSystemOfUnits.h" 17 #include <boost/bind/bind.hpp> 28 theComparatorThreshold(20.),
29 theComparatorNoise(0.),
30 theComparatorRMSOffset(2.),
31 theComparatorSaturation(1057.),
32 theComparatorWait(50.),
33 theComparatorDeadTime(100.),
36 nScaBins_(
p.getParameter<
int>(
"nScaBins")),
37 doSuppression_(
p.getParameter<
bool>(
"doSuppression")),
38 doCrosstalk_(
p.getParameter<
bool>(
"doCrosstalk")),
39 theStripConditions(nullptr),
40 theCrosstalkGenerator(nullptr),
41 theComparatorClockJump(2),
42 sca_time_bin_size(50.),
43 sca_peak_bin(
p.getParameter<
int>(
"scaPeakBin")),
44 theComparatorTimeBinOffset(
p.getParameter<double>(
"comparatorTimeBinOffset")),
45 theComparatorTimeOffset(
p.getParameter<double>(
"comparatorTimeOffset")),
46 theComparatorSamplingTime(
p.getParameter<double>(
"comparatorSamplingTime")),
47 theSCATimingOffsets(
p.getParameter<
std::
vector<double>>(
"scaTimingOffsets")) {
98 CLHEP::HepRandomEngine *engine)
const {
106 std::list<int> comparatorsWithSignal;
107 CSCSignalMap::iterator signalMapItr;
111 comparatorsWithSignal.push_back(((*signalMapItr).first - 1) / 2);
114 comparatorsWithSignal.unique();
115 for (std::list<int>::iterator listItr = comparatorsWithSignal.begin(); listItr != comparatorsWithSignal.end();
117 int iComparator = *listItr;
128 float comparatorTime =
time;
144 if (height1 > height2) {
145 mainSignal = &signal1;
146 float leftStrip = 0.;
147 if (iComparator > 0) {
153 output = (leftStrip < height2);
154 strip = iComparator * 2 + 1;
157 mainSignal = &signal2;
158 float rightStrip = 0.;
163 output = (height1 < rightStrip);
164 strip = iComparator * 2 + 2;
187 if ((bxFloat >= 0) && (bxFloat < 16))
188 timeWord = (1 <<
static_cast<int>(bxFloat));
191 result.push_back(newDigi);
197 float resetThreshold = 1;
198 while (time < theSignalStopTime && mainSignal->
getValue(
time) > resetThreshold) {
211 for (std::vector<CSCComparatorDigi>::const_iterator compItr = comparators.begin(); compItr != comparators.end();
214 result.push_back(compItr->getStrip());
242 std::list<int>::const_iterator keyStripItr = keyStrips.begin();
244 for (; keyStripItr != keyStrips.end(); ++keyStripItr) {
246 for (
int istrip = (*keyStripItr) -
window; istrip <= (*keyStripItr) +
window; ++istrip) {
256 std::list<int> cfebsToRead;
257 for (; keyStripItr != keyStrips.end(); ++keyStripItr) {
259 cfebsToRead.push_back(cfeb);
262 if (remainder <
window && cfeb != 0) {
263 cfebsToRead.push_back(cfeb - 1);
267 if (remainder >= 16 -
window && cfeb != maxCFEBs) {
268 cfebsToRead.push_back(cfeb + 1);
272 cfebsToRead.unique();
275 for (std::list<int>::const_iterator cfebItr = cfebsToRead.begin(); cfebItr != cfebsToRead.end(); ++cfebItr) {
276 for (
int i = 1;
i <= 16; ++
i) {
277 result.push_back((*cfebItr) * 16 +
i);
290 CLHEP::HepRandomEngine *engine) {
295 std::vector<CSCComparatorDigi> comparatorOutputs;
298 if (!comparatorOutputs.empty()) {
310 CLHEP::HepRandomEngine *engine) {
312 std::vector<CSCStripDigi> stripDigis;
313 stripDigis.reserve(stripsToDo.size());
314 for (std::list<int>::const_iterator stripItr = stripsToDo.begin(); stripItr != stripsToDo.end(); ++stripItr) {
315 createDigi(*stripItr,
find(*stripItr, engine), stripDigis, engine);
319 digis.put(stripRange,
layerId());
325 std::vector<CSCAnalogSignal> realSignals;
328 for (; mapI != mapEnd; ++mapI) {
329 realSignals.push_back((*mapI).second);
332 std::vector<CSCAnalogSignal>::iterator realSignalItr = realSignals.begin(), realSignalsEnd = realSignals.end();
333 for (; realSignalItr != realSignalsEnd; ++realSignalItr) {
334 int thisStrip = (*realSignalItr).getElement();
337 int otherStrip = thisStrip - 1;
338 addCrosstalk(*realSignalItr, thisStrip, otherStrip, engine);
341 int otherStrip = thisStrip + 1;
342 addCrosstalk(*realSignalItr, thisStrip, otherStrip, engine);
350 CLHEP::HepRandomEngine *engine) {
351 float capacitiveCrosstalk, resistiveCrosstalk;
352 bool leftRight = (otherStrip > thisStrip);
360 crosstalkSignal *= -1.;
366 std::vector<CSCStripDigi> &
result,
367 CLHEP::HepRandomEngine *engine) {
378 for (
int scaBin = 0; scaBin <
nScaBins_; ++scaBin) {
387 result.push_back(newDigi);
389 LogTrace(
"CSCStripElectronicsSim") <<
"CSCStripElectronicsSim: CSCStripDigi " << newDigi;
394 for (
unsigned scaBin = 0; scaBin < scaCounts.size(); ++scaBin) {
395 scaCounts[scaBin] =
std::min(scaCounts[scaBin], 4095);
403 CLHEP::HepRandomEngine *engine) {
408 std::list<int> chamberKeyStrips;
410 comparatorItr != comparators.end();
414 std::vector<CSCComparatorDigi> layerComparators((*comparatorItr).second.first, (*comparatorItr).second.second);
415 std::list<int> layerKeyStrips =
getKeyStrips(layerComparators);
416 chamberKeyStrips.insert(chamberKeyStrips.end(), layerKeyStrips.begin(), layerKeyStrips.end());
419 chamberKeyStrips.sort();
420 chamberKeyStrips.unique();
426 std::list<int> keyStrips, stripsRead;
434 unsigned int expectedSize = isGanged ? 10 : 12;
435 assert(stripsRead.size() == expectedSize);
438 unsigned int expectedSize = isGanged ? 16 : 48;
439 assert(stripsRead.size() == expectedSize);
440 assert(stripsRead.front() == 1);
std::vector< double > theBunchTimingOffsets
void initParameters() override
initialization for each layer
const CSCLayer * theLayer
const CSCChamberSpecs * theSpecs
CSCAnalogSignal getCrosstalk(const CSCAnalogSignal &inputSignal) const
CSCSignalMap theSignalMap
const CSCLayerGeometry * theLayerGeometry
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
bool SortSignalsByTotal(const CSCAnalogSignal &s1, const CSCAnalogSignal &s2)
double theComparatorTimeOffset
virtual float pedestal(const CSCDetId &detId, int channel) const =0
in ADC counts
float calculateAmpResponse(float t) const
void addCrosstalk(CLHEP::HepRandomEngine *)
float comparatorReading(const CSCAnalogSignal &signal, float time, CLHEP::HepRandomEngine *) const
calculates the comparator reading, including saturation and offsets
virtual void crosstalk(const CSCDetId &detId, int channel, double stripLength, bool leftRight, float &capacitive, float &resistive) const =0
void runComparator(std::vector< CSCComparatorDigi > &result, CLHEP::HepRandomEngine *)
float theComparatorDeadTime
int readoutElement(int strip) const override
int channel(int strip) const
void setADCCounts(const std::vector< int > &ADCCounts)
CSCStripConditions * theStripConditions
void setLayer(const CSCLayer *layer)
std::list< int > getKeyStripsFromMC() const
get ths strips that have detector hits
std::vector< double > theSCATimingOffsets
int numberOfStrips() const
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
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)
float length() const override
void doSaturation(CSCStripDigi &digi)
std::list< int > channelsToRead(const std::list< int > &keyStrips, int window) const
~CSCStripElectronicsSim() override
float theComparatorThreshold
virtual void addLinks(int channelIndex)
DetectorHitMap theDetectorHitMap
CSCStripElectronicsSim(const edm::ParameterSet &p)
configurable parameters
const Plane & surface() const
The nominal surface of the GeomDet.
const PositionType & position() const
float getValue(float t) const
double theComparatorTimeBinOffset
void setParameters(float crosstalk, float delay, float resistiveFraction)
CSCDetId chamberId() const
std::pair< const_iterator, const_iterator > Range
float theComparatorSaturation
double theComparatorSamplingTime
CSCAnalogSignal & find(int element, CLHEP::HepRandomEngine *)
void fillDigis(CSCStripDigiCollection &digis, CSCComparatorDigiCollection &comparators, CLHEP::HepRandomEngine *)
float theAverageTimeOfFlight
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
float calculateAmpResponse(float t) const override
virtual float smearedGain(const CSCDetId &detId, int channel, CLHEP::HepRandomEngine *) const
CSCStripAmpResponse theAmpResponse
std::list< int > getKeyStrips(const std::vector< CSCComparatorDigi > &comparators) const
finds the key strips from these comparators
void createDigi(int istrip, const CSCAnalogSignal &signal, std::vector< CSCStripDigi > &result, CLHEP::HepRandomEngine *)
std::vector< int > const & getADCCounts() const
Get ADC readings.
void fillStripDigis(const std::list< int > &keyStrips, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *)
std::vector< double > theTimingCalibrationError
virtual int channelIndex(int channel) const
lets users map channels to different indices for links