7 #include "CLHEP/Units/GlobalPhysicalConstants.h"
10 #include "CLHEP/Random/RandGaussQ.h"
23 theNoiseWasAdded(
false),
25 theShapingTime(p.getParameter<int>(
"shapingTime")),
26 thePeakTimeSigma(p.getParameter<double>(
"peakTimeSigma")),
27 theBunchTimingOffsets(p.getParameter<std::vector<double> >(
"bunchTimingOffsets")),
28 theSignalStartTime(p.getParameter<double>(
"signalStartTime")),
29 theSignalStopTime(p.getParameter<double>(
"signalStopTime")),
30 theSamplingTime(p.getParameter<double>(
"samplingTime")),
31 theNumberOfSamples(static_cast<int>((theSignalStopTime-theSignalStartTime)/theSamplingTime)),
32 theOffsetOfBxZero(p.getParameter<int>(
"timeBitForBxZero")),
33 theSignalPropagationSpeed(p.getParameter<std::vector<double> >(
"signalSpeed")),
34 theTimingCalibrationError(p.getParameter<std::vector<double> >(
"timingCalibrationError")),
35 doNoise_(p.getParameter<bool>(
"doNoise"))
47 const std::vector<CSCDetectorHit> & detectorHits,
48 CLHEP::HepRandomEngine* engine)
61 size_t nHits = detectorHits.size();
63 for(
size_t i = 0;
i < nHits; ++
i) {
98 if(i>5 && ampBinValues[i] < 0.000001)
break;
100 ampBinValues.resize(i);
103 LogTrace(
"CSCBaseElectronicsSim") <<
104 "CSCBaseElectronicsSim: dump of theAmpResponse follows...\n"
114 float readoutTime = detectorHit.
getTime()
120 thisSignal.setTimeOffset(readoutTime);
121 thisSignal.setElement(element);
142 double timeOffset = CLHEP::RandGaussQ::shoot(engine, (*mapI).second.getTimeOffset(),
thePeakTimeSigma);
143 (*mapI).second.setTimeOffset(timeOffset);
150 if(element <= 0 || element >
nElements) {
151 LogTrace(
"CSCBaseElectronicsSim") <<
"CSCBaseElectronicsSim: bad element = " << element <<
152 ". There are " << nElements <<
" elements.";
153 edm::LogError(
"Error in CSCBaseElectronicsSim: element out of bounds");
155 CSCSignalMap::iterator signalMapItr =
theSignalMap.find(element);
164 signalMapItr =
theSignalMap.insert( std::pair<int, CSCAnalogSignal>(element, newSignal) ).first;
166 return (*signalMapItr).second;
182 float distance = -1. * pos;
184 return distance / speed;
189 std::pair<DetectorHitMap::iterator, DetectorHitMap::iterator> channelHitItr
193 std::map<int,float> simTrackChargeMap;
194 std::map<int, EncodedEventId> eventIdMap;
195 float totalCharge = 0;
196 for( DetectorHitMap::iterator hitItr = channelHitItr.first;
197 hitItr != channelHitItr.second; ++hitItr){
198 const PSimHit *
hit = hitItr->second.getSimHit();
201 int simTrackId = hitItr->second.getSimHit()->trackId();
202 float charge = hitItr->second.getCharge();
203 std::map<int,float>::iterator chargeItr = simTrackChargeMap.find(simTrackId);
204 if( chargeItr == simTrackChargeMap.end() ) {
205 simTrackChargeMap[simTrackId] = charge;
206 eventIdMap[simTrackId] = hit->
eventId();
208 chargeItr->second += charge;
210 totalCharge += charge;
214 for(std::map<int,float>::iterator chargeItr = simTrackChargeMap.begin();
215 chargeItr != simTrackChargeMap.end(); ++chargeItr) {
216 int simTrackId = chargeItr->first;
218 eventIdMap[simTrackId], chargeItr->second/totalCharge ) );
std::vector< double > theBunchTimingOffsets
CSCBaseElectronicsSim(const edm::ParameterSet &p)
float getPosition() const
virtual float signalDelay(int element, float pos) const
const CSCLayer * theLayer
const CSCChamberSpecs * theSpecs
CSCSignalMap theSignalMap
const CSCLayerGeometry * theLayerGeometry
void push_back(const T &t)
virtual float calculateAmpResponse(float t) const =0
CSCAnalogSignal amplifySignal(const CSCDetectorHit &)
virtual CSCAnalogSignal makeNoiseSignal(int element, CLHEP::HepRandomEngine *)
void setLayer(const CSCLayer *layer)
uint32_t rawId() const
get the raw id
int getElement() const
constructor from time and amp shape
CSCAnalogSignal theAmpResponse
std::vector< double > theSignalPropagationSpeed
const CSCChamberSpecs * specs() const
edm::DetSet< StripDigiSimLink > DigiSimLinks
DetId geographicalId() const
The label of this GeomDet.
EncodedEventId eventId() const
void superimpose(const CSCAnalogSignal &signal2)
virtual int readoutElement(int element) const =0
Container::value_type value_type
virtual void addLinks(int channelIndex)
DetectorHitMap theDetectorHitMap
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
CSCAnalogSignal & find(int element, CLHEP::HepRandomEngine *)
DigiSimLinks theDigiSimLinks
void addNoise(CLHEP::HepRandomEngine *)
virtual int channelIndex(int channel) const
lets users map channels to different indices for links
volatile std::atomic< bool > shutdown_flag false
void simulate(const CSCLayer *layer, const std::vector< CSCDetectorHit > &inputHits, CLHEP::HepRandomEngine *)
virtual void initParameters()=0
const CSCChamber * chamber() const
const CSCLayerGeometry * geometry() const
CSCAnalogSignal & add(const CSCAnalogSignal &, CLHEP::HepRandomEngine *)
virtual ~CSCBaseElectronicsSim()