7 #include "CLHEP/Units/GlobalPhysicalConstants.h"
21 theNoiseWasAdded(
false),
23 theShapingTime(p.getParameter<int>(
"shapingTime")),
24 thePeakTimeSigma(p.getParameter<double>(
"peakTimeSigma")),
25 theBunchTimingOffsets(p.getParameter<std::vector<double> >(
"bunchTimingOffsets")),
26 theSignalStartTime(p.getParameter<double>(
"signalStartTime")),
27 theSignalStopTime(p.getParameter<double>(
"signalStopTime")),
28 theSamplingTime(p.getParameter<double>(
"samplingTime")),
29 theNumberOfSamples(static_cast<int>((theSignalStopTime-theSignalStartTime)/theSamplingTime)),
30 theOffsetOfBxZero(p.getParameter<int>(
"timeBitForBxZero")),
31 theSignalPropagationSpeed(p.getParameter<std::vector<double> >(
"signalSpeed")),
32 theTimingCalibrationError(p.getParameter<std::vector<double> >(
"timingCalibrationError")),
33 doNoise_(p.getParameter<bool>(
"doNoise")),
54 const std::vector<CSCDetectorHit> & detectorHits)
67 size_t nHits = detectorHits.size();
69 for(
size_t i = 0;
i < nHits; ++
i) {
104 if(i>5 && ampBinValues[i] < 0.000001)
break;
106 ampBinValues.resize(i);
109 LogTrace(
"CSCBaseElectronicsSim") <<
110 "CSCBaseElectronicsSim: dump of theAmpResponse follows...\n"
120 float readoutTime = detectorHit.
getTime()
126 thisSignal.setTimeOffset(readoutTime);
127 thisSignal.setElement(element);
149 (*mapI).second.setTimeOffset(timeOffset);
156 if(element <= 0 || element >
nElements) {
157 LogTrace(
"CSCBaseElectronicsSim") <<
"CSCBaseElectronicsSim: bad element = " << element <<
158 ". There are " << nElements <<
" elements.";
159 edm::LogError(
"Error in CSCBaseElectronicsSim: element out of bounds");
161 CSCSignalMap::iterator signalMapItr =
theSignalMap.find(element);
170 signalMapItr =
theSignalMap.insert( std::pair<int, CSCAnalogSignal>(element, newSignal) ).first;
172 return (*signalMapItr).second;
188 float distance = -1. *
pos;
190 return distance /
speed;
195 std::pair<DetectorHitMap::iterator, DetectorHitMap::iterator> channelHitItr
199 std::map<int,float> simTrackChargeMap;
200 std::map<int, EncodedEventId> eventIdMap;
201 float totalCharge = 0;
202 for( DetectorHitMap::iterator hitItr = channelHitItr.first;
203 hitItr != channelHitItr.second; ++hitItr){
204 const PSimHit *
hit = hitItr->second.getSimHit();
207 int simTrackId = hitItr->second.getSimHit()->trackId();
208 float charge = hitItr->second.getCharge();
209 std::map<int,float>::iterator chargeItr = simTrackChargeMap.find(simTrackId);
210 if( chargeItr == simTrackChargeMap.end() ) {
211 simTrackChargeMap[simTrackId] =
charge;
212 eventIdMap[simTrackId] = hit->
eventId();
214 chargeItr->second +=
charge;
220 for(std::map<int,float>::iterator chargeItr = simTrackChargeMap.begin();
221 chargeItr != simTrackChargeMap.end(); ++chargeItr) {
222 int simTrackId = chargeItr->first;
224 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
virtual CSCAnalogSignal makeNoiseSignal(int element)
const CSCLayerGeometry * theLayerGeometry
void push_back(const T &t)
virtual float calculateAmpResponse(float t) const =0
Container::value_type value_type
CSCAnalogSignal amplifySignal(const CSCDetectorHit &)
void setRandomEngine(CLHEP::HepRandomEngine &engine)
void setLayer(const CSCLayer *layer)
CLHEP::RandGaussQ * theRandGaussQ
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
virtual void addLinks(int channelIndex)
DetectorHitMap theDetectorHitMap
CSCAnalogSignal & add(const CSCAnalogSignal &)
void simulate(const CSCLayer *layer, const std::vector< CSCDetectorHit > &inputHits)
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
DigiSimLinks theDigiSimLinks
CSCAnalogSignal & find(int element)
virtual int channelIndex(int channel) const
lets users map channels to different indices for links
virtual void initParameters()=0
const CSCChamber * chamber() const
const CSCLayerGeometry * geometry() const
virtual ~CSCBaseElectronicsSim()