![]() |
![]() |
#include <SimMuon/CSCDigitizer/src/CSCBaseElectronicsSim.h>
Public Types | |
typedef std::map< int, CSCAnalogSignal, std::less < int > > | CSCSignalMap |
typedef edm::DetSet < StripDigiSimLink > | DigiSimLinks |
Public Member Functions | |
const DigiSimLinks & | digiSimLinks () const |
void | setRandomEngine (CLHEP::HepRandomEngine &engine) |
void | simulate (const CSCLayer *layer, const std::vector< CSCDetectorHit > &inputHits) |
virtual | ~CSCBaseElectronicsSim () |
Protected Types | |
enum | { NONE, CONSERVATIVE, RADICAL } |
typedef std::multimap< int, CSCDetectorHit, std::less < int > > | DetectorHitMap |
Protected Member Functions | |
CSCAnalogSignal & | add (const CSCAnalogSignal &) |
virtual void | addLinks (int channelIndex) |
creates links from Digi to SimTrack disabled for now | |
void | addNoise () |
CSCAnalogSignal | amplifySignal (const CSCDetectorHit &) |
double | averageTimeOfFlight (const DetId &detId) const |
the average time-of-flight from the interaction point to the given detector | |
virtual float | calculateAmpResponse (float t) const =0 |
virtual int | channelIndex (int channel) const |
lets users map channels to different indices for links | |
void | combineAnalogSignals (const std::vector< CSCAnalogSignal > &) |
CSCBaseElectronicsSim (const edm::ParameterSet &p) | |
For verbosity. | |
void | fillAmpResponse () |
CSCAnalogSignal & | find (int element) |
virtual void | initParameters ()=0 |
CSCDetId | layerId () const |
the CSCDetId corresponding to the current layer | |
virtual CSCAnalogSignal | makeNoiseSignal (int element) |
virtual int | readoutElement (int element) const =0 |
void | setNoise (float rmsNoise, float noiseSigmaThreshold) |
void | setSignalTimeRange (double startTime, double stopTime) |
How long before & after the bunch crossing to simulate shortening the time can save CPU. | |
virtual float | signalDelay (int element, float pos) const =0 |
how long, in ns, it takes a signal at pos to propagate to the readout edge. | |
Protected Attributes | |
bool | doNoise_ |
int | nElements |
CSCAnalogSignal | theAmpResponse |
float | theBunchSpacing |
std::vector< double > | theBunchTimingOffsets |
DetectorHitMap | theDetectorHitMap |
DigiSimLinks | theDigiSimLinks |
const CSCLayer * | theLayer |
const CSCLayerGeometry * | theLayerGeometry |
bool | theNoiseWasAdded |
int | theNumberOfSamples |
int | theOffsetOfBxZero |
float | thePeakTimeSigma |
CLHEP::RandGaussQ * | theRandGaussQ |
float | theSamplingTime |
int | theShapingTime |
CSCSignalMap | theSignalMap |
float | theSignalStartTime |
float | theSignalStopTime |
const CSCChamberSpecs * | theSpecs |
It has three non-virtual functions, so that's enough to deserve a new class. And since it has virtual functions it needs a virtual dtor.
Definition at line 34 of file CSCBaseElectronicsSim.h.
typedef std::map<int, CSCAnalogSignal, std::less<int> > CSCBaseElectronicsSim::CSCSignalMap |
Definition at line 38 of file CSCBaseElectronicsSim.h.
typedef std::multimap<int, CSCDetectorHit, std::less<int> > CSCBaseElectronicsSim::DetectorHitMap [protected] |
Definition at line 155 of file CSCBaseElectronicsSim.h.
Definition at line 39 of file CSCBaseElectronicsSim.h.
anonymous enum [protected] |
CSCBaseElectronicsSim::~CSCBaseElectronicsSim | ( | ) | [virtual] |
Definition at line 39 of file CSCBaseElectronicsSim.cc.
References theRandGaussQ.
00040 { 00041 delete theRandGaussQ; 00042 }
CSCBaseElectronicsSim::CSCBaseElectronicsSim | ( | const edm::ParameterSet & | p | ) | [protected] |
For verbosity.
Definition at line 14 of file CSCBaseElectronicsSim.cc.
References theBunchTimingOffsets.
00015 : 00016 theSpecs(0), 00017 theLayerGeometry(0), 00018 theLayer(0), 00019 theSignalMap(), 00020 theAmpResponse(), 00021 theBunchSpacing(25.), 00022 theNoiseWasAdded(false), 00023 nElements(0), 00024 theShapingTime(p.getParameter<int>("shapingTime")), 00025 thePeakTimeSigma(p.getParameter<double>("peakTimeSigma")), 00026 theBunchTimingOffsets(p.getParameter<std::vector<double> >("bunchTimingOffsets")), 00027 theSignalStartTime(p.getParameter<double>("signalStartTime")), 00028 theSignalStopTime(p.getParameter<double>("signalStopTime")), 00029 theSamplingTime(p.getParameter<double>("samplingTime")), 00030 theNumberOfSamples(static_cast<int>((theSignalStopTime-theSignalStartTime)/theSamplingTime)), 00031 theOffsetOfBxZero(p.getParameter<int>("timeBitForBxZero")), 00032 doNoise_(p.getParameter<bool>("doNoise")), 00033 theRandGaussQ(0) 00034 { 00035 assert(theBunchTimingOffsets.size() == 11); 00036 }
CSCAnalogSignal & CSCBaseElectronicsSim::add | ( | const CSCAnalogSignal & | signal | ) | [protected] |
Definition at line 168 of file CSCBaseElectronicsSim.cc.
References element(), find(), CSCAnalogSignal::getElement(), and CSCAnalogSignal::superimpose().
00168 { 00169 int element = signal.getElement(); 00170 CSCAnalogSignal & newSignal = find(element); 00171 newSignal.superimpose(signal); 00172 return newSignal; 00173 }
creates links from Digi to SimTrack disabled for now
Definition at line 176 of file CSCBaseElectronicsSim.cc.
References PSimHit::eventId(), edm::DetSet< T >::push_back(), simTrackId, theDetectorHitMap, and theDigiSimLinks.
Referenced by CSCStripElectronicsSim::createDigi(), and CSCWireElectronicsSim::fillDigis().
00176 { 00177 std::pair<DetectorHitMap::iterator, DetectorHitMap::iterator> channelHitItr 00178 = theDetectorHitMap.equal_range(channelIndex); 00179 00180 // find the fraction contribution for each SimTrack 00181 std::map<int,float> simTrackChargeMap; 00182 std::map<int, EncodedEventId> eventIdMap; 00183 float totalCharge = 0; 00184 for( DetectorHitMap::iterator hitItr = channelHitItr.first; 00185 hitItr != channelHitItr.second; ++hitItr){ 00186 const PSimHit * hit = hitItr->second.getSimHit(); 00187 // might be zero for unit tests and such 00188 if(hit != 0) { 00189 int simTrackId = hitItr->second.getSimHit()->trackId(); 00190 float charge = hitItr->second.getCharge(); 00191 std::map<int,float>::iterator chargeItr = simTrackChargeMap.find(simTrackId); 00192 if( chargeItr == simTrackChargeMap.end() ) { 00193 simTrackChargeMap[simTrackId] = charge; 00194 eventIdMap[simTrackId] = hit->eventId(); 00195 } else { 00196 chargeItr->second += charge; 00197 } 00198 totalCharge += charge; 00199 } 00200 } 00201 00202 for(std::map<int,float>::iterator chargeItr = simTrackChargeMap.begin(); 00203 chargeItr != simTrackChargeMap.end(); ++chargeItr) { 00204 int simTrackId = chargeItr->first; 00205 theDigiSimLinks.push_back( StripDigiSimLink(channelIndex, simTrackId, 00206 eventIdMap[simTrackId], chargeItr->second/totalCharge ) ); 00207 00208 } 00209 }
void CSCBaseElectronicsSim::addNoise | ( | ) | [protected] |
Definition at line 133 of file CSCBaseElectronicsSim.cc.
References makeNoiseSignal(), theNoiseWasAdded, thePeakTimeSigma, theRandGaussQ, and theSignalMap.
Referenced by simulate().
00133 { 00134 for(CSCSignalMap::iterator mapI = theSignalMap.begin(); 00135 mapI!= theSignalMap.end(); ++mapI) { 00136 // superimpose electronics noise 00137 (*mapI).second.superimpose(makeNoiseSignal((*mapI).first)); 00138 // DON'T do amp gain variations. Handled in strips by calibration code 00139 // and variations in the shaper peaking time. 00140 double timeOffset = theRandGaussQ->fire((*mapI).second.getTimeOffset(), thePeakTimeSigma); 00141 (*mapI).second.setTimeOffset(timeOffset); 00142 } 00143 theNoiseWasAdded = true; 00144 }
CSCAnalogSignal CSCBaseElectronicsSim::amplifySignal | ( | const CSCDetectorHit & | detectorHit | ) | [protected] |
Definition at line 109 of file CSCBaseElectronicsSim.cc.
References channelIndex(), element(), CSCDetectorHit::getCharge(), CSCDetectorHit::getElement(), CSCDetectorHit::getPosition(), CSCDetectorHit::getTime(), readoutElement(), signalDelay(), theAmpResponse, and theDetectorHitMap.
Referenced by simulate().
00109 { 00110 int element = readoutElement(detectorHit.getElement()); 00111 00112 float readoutTime = detectorHit.getTime() 00113 + signalDelay(element, detectorHit.getPosition()); 00114 00115 // start from the amp response, and modify it. 00116 CSCAnalogSignal thisSignal(theAmpResponse); 00117 thisSignal *= detectorHit.getCharge(); 00118 thisSignal.setTimeOffset(readoutTime); 00119 thisSignal.setElement(element); 00120 // keep track of links between digis and hits 00121 theDetectorHitMap.insert( DetectorHitMap::value_type(channelIndex(element), detectorHit) ); 00122 return thisSignal; 00123 }
double CSCBaseElectronicsSim::averageTimeOfFlight | ( | const DetId & | detId | ) | const [protected] |
the average time-of-flight from the interaction point to the given detector
Referenced by CSCStripElectronicsSim::initParameters().
virtual float CSCBaseElectronicsSim::calculateAmpResponse | ( | float | t | ) | const [protected, pure virtual] |
lets users map channels to different indices for links
Reimplemented in CSCWireElectronicsSim.
Definition at line 103 of file CSCBaseElectronicsSim.h.
Referenced by amplifySignal(), and CSCStripElectronicsSim::createDigi().
void CSCBaseElectronicsSim::combineAnalogSignals | ( | const std::vector< CSCAnalogSignal > & | ) | [protected] |
const DigiSimLinks& CSCBaseElectronicsSim::digiSimLinks | ( | ) | const [inline] |
Definition at line 48 of file CSCBaseElectronicsSim.h.
References theDigiSimLinks.
Referenced by CSCDigitizer::doAction().
00048 {return theDigiSimLinks;}
void CSCBaseElectronicsSim::fillAmpResponse | ( | ) | [protected] |
Definition at line 90 of file CSCBaseElectronicsSim.cc.
References calculateAmpResponse(), i, LogTrace, theAmpResponse, theNumberOfSamples, and theSamplingTime.
Referenced by CSCStripElectronicsSim::CSCStripElectronicsSim(), and CSCWireElectronicsSim::CSCWireElectronicsSim().
00090 { 00091 std::vector<float> ampBinValues(theNumberOfSamples); 00092 int i = 0; 00093 for( ; i < theNumberOfSamples; ++i) { 00094 ampBinValues[i] = calculateAmpResponse(i*theSamplingTime); 00095 // truncate any entries that are trivially small 00096 if(i>5 && ampBinValues[i] < 0.000001) break; 00097 } 00098 ampBinValues.resize(i); 00099 theAmpResponse = CSCAnalogSignal(0, theSamplingTime, ampBinValues, 1., 0.); 00100 00101 LogTrace("CSCBaseElectronicsSim") << 00102 "CSCBaseElectronicsSim: dump of theAmpResponse follows...\n" 00103 << theAmpResponse; 00104 }
CSCAnalogSignal & CSCBaseElectronicsSim::find | ( | int | element | ) | [protected] |
Definition at line 147 of file CSCBaseElectronicsSim.cc.
References LogTrace, makeNoiseSignal(), nElements, theNoiseWasAdded, theNumberOfSamples, theSamplingTime, theSignalMap, and theSignalStartTime.
Referenced by add(), CSCStripElectronicsSim::addCrosstalk(), CSCStripElectronicsSim::createDigi(), and CSCStripElectronicsSim::runComparator().
00147 { 00148 if(element <= 0 || element > nElements) { 00149 LogTrace("CSCBaseElectronicsSim") << "CSCBaseElectronicsSim: bad element = " << element << 00150 ". There are " << nElements << " elements."; 00151 edm::LogError("Error in CSCBaseElectronicsSim: element out of bounds"); 00152 } 00153 CSCSignalMap::iterator signalMapItr = theSignalMap.find(element); 00154 if(signalMapItr == theSignalMap.end()) { 00155 CSCAnalogSignal newSignal; 00156 if(theNoiseWasAdded) { 00157 newSignal = makeNoiseSignal(element); 00158 } else { 00159 std::vector<float> emptyV(theNumberOfSamples); 00160 newSignal = CSCAnalogSignal(element, theSamplingTime, emptyV, 0., theSignalStartTime); 00161 } 00162 signalMapItr = theSignalMap.insert( std::pair<int, CSCAnalogSignal>(element, newSignal) ).first; 00163 } 00164 return (*signalMapItr).second; 00165 }
virtual void CSCBaseElectronicsSim::initParameters | ( | ) | [protected, pure virtual] |
CSCDetId CSCBaseElectronicsSim::layerId | ( | ) | const [protected] |
the CSCDetId corresponding to the current layer
Definition at line 213 of file CSCBaseElectronicsSim.cc.
References CSCLayer::geographicalId(), DetId::rawId(), and theLayer.
Referenced by CSCStripElectronicsSim::addCrosstalk(), CSCStripElectronicsSim::createDigi(), CSCStripElectronicsSim::fillDigis(), CSCWireElectronicsSim::fillDigis(), CSCStripElectronicsSim::makeNoiseSignal(), and simulate().
00213 { 00214 return CSCDetId(theLayer->geographicalId().rawId()); 00215 }
CSCAnalogSignal CSCBaseElectronicsSim::makeNoiseSignal | ( | int | element | ) | [protected, virtual] |
Reimplemented in CSCStripElectronicsSim.
Definition at line 126 of file CSCBaseElectronicsSim.cc.
References theNumberOfSamples, theSamplingTime, and theSignalStartTime.
Referenced by addNoise(), and find().
00126 { 00127 std::vector<float> binValues(theNumberOfSamples); 00128 // default is empty 00129 return CSCAnalogSignal(element, theSamplingTime, binValues, 0., theSignalStartTime); 00130 }
Implemented in CSCStripElectronicsSim, and CSCWireElectronicsSim.
Referenced by amplifySignal(), and simulate().
void CSCBaseElectronicsSim::setNoise | ( | float | rmsNoise, | |
float | noiseSigmaThreshold | |||
) | [protected] |
void CSCBaseElectronicsSim::setRandomEngine | ( | CLHEP::HepRandomEngine & | engine | ) |
Definition at line 45 of file CSCBaseElectronicsSim.cc.
References theRandGaussQ.
Referenced by CSCDigitizer::setRandomEngine().
00046 { 00047 if(theRandGaussQ) delete theRandGaussQ; 00048 theRandGaussQ = new RandGaussQ(engine); 00049 }
void CSCBaseElectronicsSim::setSignalTimeRange | ( | double | startTime, | |
double | stopTime | |||
) | [inline, protected] |
How long before & after the bunch crossing to simulate shortening the time can save CPU.
Definition at line 79 of file CSCBaseElectronicsSim.h.
References theSignalStartTime, and theSignalStopTime.
00079 { 00080 theSignalStartTime = startTime; 00081 theSignalStopTime = stopTime; 00082 }
virtual float CSCBaseElectronicsSim::signalDelay | ( | int | element, | |
float | pos | |||
) | const [protected, pure virtual] |
how long, in ns, it takes a signal at pos to propagate to the readout edge.
This may be negative, since the timing may be calibrated to the center of the detector
Implemented in CSCStripElectronicsSim, and CSCWireElectronicsSim.
Referenced by amplifySignal().
void CSCBaseElectronicsSim::simulate | ( | const CSCLayer * | layer, | |
const std::vector< CSCDetectorHit > & | inputHits | |||
) |
Definition at line 52 of file CSCBaseElectronicsSim.cc.
References a, addNoise(), amplifySignal(), c, CSCLayer::chamber(), doNoise_, element(), i, initParameters(), layerId(), readoutElement(), CSCChamber::specs(), theDetectorHitMap, theDigiSimLinks, theLayer, theNoiseWasAdded, theSignalMap, and theSpecs.
Referenced by CSCDigitizer::doAction().
00054 { 00055 theNoiseWasAdded = false; 00056 00057 TimeMe a("CSCBaseEl:simulate"); 00058 { 00059 theSignalMap.clear(); 00060 theDetectorHitMap.clear(); 00061 // fill the specs member data 00062 theSpecs = layer->chamber()->specs(); 00063 theLayer = layer; 00064 // can we swap for efficiency? 00065 theDigiSimLinks = DigiSimLinks(layerId().rawId()); 00066 initParameters(); 00067 } 00068 00069 { 00070 TimeMe c("CSCBaseEl:loop"); 00071 size_t nHits = detectorHits.size(); 00072 // turn each detector hit into an analog signal 00073 for( size_t i = 0; i < nHits; ++i) { 00074 int element = readoutElement( detectorHits[i].getElement() ); 00075 00076 // skip if hit element is not part of a readout element 00077 // e.g. wire in non-readout group 00078 if ( element != 0 ) add( amplifySignal(detectorHits[i]) ); 00079 } 00080 } 00081 00082 { 00083 if(doNoise_) { 00084 addNoise(); 00085 } 00086 } 00087 }
bool CSCBaseElectronicsSim::doNoise_ [protected] |
Definition at line 152 of file CSCBaseElectronicsSim.h.
Referenced by CSCWireElectronicsSim::fillDigis(), CSCStripElectronicsSim::makeNoiseSignal(), and simulate().
int CSCBaseElectronicsSim::nElements [protected] |
Definition at line 130 of file CSCBaseElectronicsSim.h.
Referenced by CSCStripElectronicsSim::addCrosstalk(), CSCStripElectronicsSim::channelsToRead(), find(), CSCStripElectronicsSim::initParameters(), CSCWireElectronicsSim::initParameters(), CSCStripElectronicsSim::runComparator(), and CSCStripElectronicsSim::selfTest().
CSCAnalogSignal CSCBaseElectronicsSim::theAmpResponse [protected] |
Reimplemented in CSCStripElectronicsSim.
Definition at line 119 of file CSCBaseElectronicsSim.h.
Referenced by amplifySignal(), and fillAmpResponse().
float CSCBaseElectronicsSim::theBunchSpacing [protected] |
Definition at line 122 of file CSCBaseElectronicsSim.h.
Referenced by CSCWireElectronicsSim::fillDigis(), and CSCStripElectronicsSim::runComparator().
std::vector<double> CSCBaseElectronicsSim::theBunchTimingOffsets [protected] |
Definition at line 137 of file CSCBaseElectronicsSim.h.
Referenced by CSCBaseElectronicsSim(), CSCWireElectronicsSim::fillDigis(), and CSCStripElectronicsSim::initParameters().
Definition at line 156 of file CSCBaseElectronicsSim.h.
Referenced by addLinks(), amplifySignal(), CSCStripElectronicsSim::getKeyStripsFromMC(), and simulate().
DigiSimLinks CSCBaseElectronicsSim::theDigiSimLinks [protected] |
Definition at line 157 of file CSCBaseElectronicsSim.h.
Referenced by addLinks(), digiSimLinks(), and simulate().
const CSCLayer* CSCBaseElectronicsSim::theLayer [protected] |
Definition at line 116 of file CSCBaseElectronicsSim.h.
Referenced by CSCStripElectronicsSim::initParameters(), CSCWireElectronicsSim::initParameters(), layerId(), simulate(), and CSCWireElectronicsSim::timeOfFlightCalibration().
const CSCLayerGeometry* CSCBaseElectronicsSim::theLayerGeometry [protected] |
Definition at line 115 of file CSCBaseElectronicsSim.h.
Referenced by CSCStripElectronicsSim::addCrosstalk(), CSCStripElectronicsSim::initParameters(), CSCWireElectronicsSim::initParameters(), CSCWireElectronicsSim::readoutElement(), CSCStripElectronicsSim::readoutElement(), and CSCWireElectronicsSim::timeOfFlightCalibration().
bool CSCBaseElectronicsSim::theNoiseWasAdded [protected] |
Definition at line 127 of file CSCBaseElectronicsSim.h.
Referenced by addNoise(), find(), and simulate().
int CSCBaseElectronicsSim::theNumberOfSamples [protected] |
Definition at line 147 of file CSCBaseElectronicsSim.h.
Referenced by fillAmpResponse(), find(), CSCStripElectronicsSim::initParameters(), makeNoiseSignal(), and CSCStripElectronicsSim::makeNoiseSignal().
int CSCBaseElectronicsSim::theOffsetOfBxZero [protected] |
Definition at line 150 of file CSCBaseElectronicsSim.h.
Referenced by CSCWireElectronicsSim::fillDigis(), CSCStripElectronicsSim::getKeyStrips(), and CSCStripElectronicsSim::runComparator().
float CSCBaseElectronicsSim::thePeakTimeSigma [protected] |
CLHEP::RandGaussQ* CSCBaseElectronicsSim::theRandGaussQ [protected] |
Definition at line 159 of file CSCBaseElectronicsSim.h.
Referenced by addNoise(), CSCStripElectronicsSim::comparatorReading(), CSCWireElectronicsSim::fillDigis(), setRandomEngine(), and ~CSCBaseElectronicsSim().
float CSCBaseElectronicsSim::theSamplingTime [protected] |
Definition at line 144 of file CSCBaseElectronicsSim.h.
Referenced by fillAmpResponse(), CSCWireElectronicsSim::fillDigis(), find(), CSCStripElectronicsSim::initParameters(), makeNoiseSignal(), CSCStripElectronicsSim::makeNoiseSignal(), and CSCStripElectronicsSim::runComparator().
int CSCBaseElectronicsSim::theShapingTime [protected] |
Definition at line 133 of file CSCBaseElectronicsSim.h.
Referenced by CSCStripElectronicsSim::initParameters(), and CSCWireElectronicsSim::initParameters().
CSCSignalMap CSCBaseElectronicsSim::theSignalMap [protected] |
Definition at line 118 of file CSCBaseElectronicsSim.h.
Referenced by CSCStripElectronicsSim::addCrosstalk(), addNoise(), CSCWireElectronicsSim::fillDigis(), find(), CSCStripElectronicsSim::runComparator(), and simulate().
float CSCBaseElectronicsSim::theSignalStartTime [protected] |
Definition at line 140 of file CSCBaseElectronicsSim.h.
Referenced by CSCWireElectronicsSim::fillDigis(), find(), CSCStripElectronicsSim::initParameters(), makeNoiseSignal(), CSCStripElectronicsSim::makeNoiseSignal(), CSCStripElectronicsSim::runComparator(), and setSignalTimeRange().
float CSCBaseElectronicsSim::theSignalStopTime [protected] |
Definition at line 141 of file CSCBaseElectronicsSim.h.
Referenced by CSCStripElectronicsSim::initParameters(), CSCStripElectronicsSim::runComparator(), and setSignalTimeRange().
const CSCChamberSpecs* CSCBaseElectronicsSim::theSpecs [protected] |
Definition at line 114 of file CSCBaseElectronicsSim.h.
Referenced by CSCWireElectronicsSim::fillDigis(), CSCStripElectronicsSim::initParameters(), CSCWireElectronicsSim::initParameters(), and simulate().