test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
CSCBaseElectronicsSim Class Referenceabstract

#include <CSCBaseElectronicsSim.h>

Inheritance diagram for CSCBaseElectronicsSim:
CSCStripElectronicsSim CSCWireElectronicsSim

Public Types

typedef std::map< int,
CSCAnalogSignal, std::less
< int > > 
CSCSignalMap
 
typedef edm::DetSet
< StripDigiSimLink
DigiSimLinks
 

Public Member Functions

const DigiSimLinksdigiSimLinks () const
 
void setLayerId (const CSCDetId &id)
 for standalone apps who don't calculate it from the geometry More...
 
void simulate (const CSCLayer *layer, const std::vector< CSCDetectorHit > &inputHits, CLHEP::HepRandomEngine *)
 
virtual ~CSCBaseElectronicsSim ()
 

Protected Types

enum  { NONE, CONSERVATIVE, RADICAL }
 
typedef std::multimap< int,
CSCDetectorHit, std::less< int > > 
DetectorHitMap
 

Protected Member Functions

CSCAnalogSignaladd (const CSCAnalogSignal &, CLHEP::HepRandomEngine *)
 
virtual void addLinks (int channelIndex)
 
void addNoise (CLHEP::HepRandomEngine *)
 
CSCAnalogSignal amplifySignal (const CSCDetectorHit &)
 
double averageTimeOfFlight (const DetId &detId) const
 the average time-of-flight from the interaction point to the given detector More...
 
virtual float calculateAmpResponse (float t) const =0
 
virtual int channelIndex (int channel) const
 lets users map channels to different indices for links More...
 
void combineAnalogSignals (const std::vector< CSCAnalogSignal > &)
 
 CSCBaseElectronicsSim (const edm::ParameterSet &p)
 
void fillAmpResponse ()
 
CSCAnalogSignalfind (int element, CLHEP::HepRandomEngine *)
 
virtual void initParameters ()=0
 
CSCDetId layerId () const
 the CSCDetId corresponding to the current layer More...
 
virtual CSCAnalogSignal makeNoiseSignal (int element, CLHEP::HepRandomEngine *)
 
virtual int readoutElement (int element) const =0
 
void setLayer (const CSCLayer *layer)
 
void setNoise (float rmsNoise, float noiseSigmaThreshold)
 
void setSignalTimeRange (double startTime, double stopTime)
 
virtual float signalDelay (int element, float pos) const
 

Protected Attributes

bool doNoise_
 
int nElements
 
CSCAnalogSignal theAmpResponse
 
float theBunchSpacing
 
std::vector< double > theBunchTimingOffsets
 
DetectorHitMap theDetectorHitMap
 
DigiSimLinks theDigiSimLinks
 
const CSCLayertheLayer
 
const CSCLayerGeometrytheLayerGeometry
 
CSCDetId theLayerId
 
bool theNoiseWasAdded
 
int theNumberOfSamples
 
int theOffsetOfBxZero
 
float thePeakTimeSigma
 
float theSamplingTime
 
int theShapingTime
 
CSCSignalMap theSignalMap
 
std::vector< double > theSignalPropagationSpeed
 
float theSignalStartTime
 
float theSignalStopTime
 
const CSCChamberSpecstheSpecs
 
std::vector< double > theTimingCalibrationError
 

Detailed Description

Commonalities between CSCStripElectronicsSim and CSCWireElectronicsSim.

Author
Rick Wilkinson

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 37 of file CSCBaseElectronicsSim.h.

Member Typedef Documentation

typedef std::map<int, CSCAnalogSignal, std::less<int> > CSCBaseElectronicsSim::CSCSignalMap

Definition at line 41 of file CSCBaseElectronicsSim.h.

typedef std::multimap<int, CSCDetectorHit, std::less<int> > CSCBaseElectronicsSim::DetectorHitMap
protected

Definition at line 161 of file CSCBaseElectronicsSim.h.

Definition at line 42 of file CSCBaseElectronicsSim.h.

Member Enumeration Documentation

anonymous enum
protected

Constructor & Destructor Documentation

CSCBaseElectronicsSim::~CSCBaseElectronicsSim ( )
virtual

Definition at line 41 of file CSCBaseElectronicsSim.cc.

42 {
43 }
CSCBaseElectronicsSim::CSCBaseElectronicsSim ( const edm::ParameterSet p)
protected

Definition at line 15 of file CSCBaseElectronicsSim.cc.

References assert(), and theBunchTimingOffsets.

16 :
17  theSpecs(0),
19  theLayer(0),
20  theSignalMap(),
22  theBunchSpacing(25.),
23  theNoiseWasAdded(false),
24  nElements(0),
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")),
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"))
36 {
37  assert(theBunchTimingOffsets.size() == 11);
38 }
std::vector< double > theBunchTimingOffsets
T getParameter(std::string const &) const
const CSCChamberSpecs * theSpecs
const CSCLayerGeometry * theLayerGeometry
assert(m_qm.get())
std::vector< double > theSignalPropagationSpeed
std::vector< double > theTimingCalibrationError

Member Function Documentation

CSCAnalogSignal & CSCBaseElectronicsSim::add ( const CSCAnalogSignal signal,
CLHEP::HepRandomEngine *  engine 
)
protected

Definition at line 170 of file CSCBaseElectronicsSim.cc.

References find(), CSCAnalogSignal::getElement(), and CSCAnalogSignal::superimpose().

Referenced by counter.Counter::register(), and simulate().

170  {
171  int element = signal.getElement();
172  CSCAnalogSignal & newSignal = find(element, engine);
173  newSignal.superimpose(signal);
174  return newSignal;
175 }
int getElement() const
constructor from time and amp shape
void superimpose(const CSCAnalogSignal &signal2)
CSCAnalogSignal & find(int element, CLHEP::HepRandomEngine *)
void CSCBaseElectronicsSim::addLinks ( int  channelIndex)
protectedvirtual

creates links from Digi to SimTrack disabled for now

Definition at line 188 of file CSCBaseElectronicsSim.cc.

References RecoTauCleanerPlugins::charge, PSimHit::eventId(), edm::DetSet< T >::push_back(), theDetectorHitMap, and theDigiSimLinks.

Referenced by CSCStripElectronicsSim::createDigi(), and CSCWireElectronicsSim::fillDigis().

188  {
189  std::pair<DetectorHitMap::iterator, DetectorHitMap::iterator> channelHitItr
190  = theDetectorHitMap.equal_range(channelIndex);
191 
192  // find the fraction contribution for each SimTrack
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();
199  // might be zero for unit tests and such
200  if(hit != 0) {
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();
207  } else {
208  chargeItr->second += charge;
209  }
210  totalCharge += charge;
211  }
212  }
213 
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 ) );
219 
220  }
221 }
void push_back(const T &t)
Definition: DetSet.h:68
EncodedEventId eventId() const
Definition: PSimHit.h:105
virtual int channelIndex(int channel) const
lets users map channels to different indices for links
void CSCBaseElectronicsSim::addNoise ( CLHEP::HepRandomEngine *  engine)
protected

Definition at line 135 of file CSCBaseElectronicsSim.cc.

References makeNoiseSignal(), theNoiseWasAdded, thePeakTimeSigma, and theSignalMap.

Referenced by simulate().

135  {
136  for(CSCSignalMap::iterator mapI = theSignalMap.begin();
137  mapI!= theSignalMap.end(); ++mapI) {
138  // superimpose electronics noise
139  (*mapI).second.superimpose(makeNoiseSignal((*mapI).first, engine));
140  // DON'T do amp gain variations. Handled in strips by calibration code
141  // and variations in the shaper peaking time.
142  double timeOffset = CLHEP::RandGaussQ::shoot(engine, (*mapI).second.getTimeOffset(), thePeakTimeSigma);
143  (*mapI).second.setTimeOffset(timeOffset);
144  }
145  theNoiseWasAdded = true;
146 }
virtual CSCAnalogSignal makeNoiseSignal(int element, CLHEP::HepRandomEngine *)
CSCAnalogSignal CSCBaseElectronicsSim::amplifySignal ( const CSCDetectorHit detectorHit)
protected

Definition at line 111 of file CSCBaseElectronicsSim.cc.

References channelIndex(), CSCDetectorHit::getCharge(), CSCDetectorHit::getElement(), CSCDetectorHit::getPosition(), CSCDetectorHit::getTime(), readoutElement(), signalDelay(), theAmpResponse, and theDetectorHitMap.

Referenced by simulate().

111  {
112  int element = readoutElement(detectorHit.getElement());
113 
114  float readoutTime = detectorHit.getTime()
115  + signalDelay(element, detectorHit.getPosition());
116 
117  // start from the amp response, and modify it.
118  CSCAnalogSignal thisSignal(theAmpResponse);
119  thisSignal *= detectorHit.getCharge();
120  thisSignal.setTimeOffset(readoutTime);
121  thisSignal.setElement(element);
122  // keep track of links between digis and hits
123  theDetectorHitMap.insert( DetectorHitMap::value_type(channelIndex(element), detectorHit) );
124  return thisSignal;
125 }
float getPosition() const
int getElement() const
virtual float signalDelay(int element, float pos) const
float getCharge() const
float getTime() const
virtual int readoutElement(int element) const =0
virtual int channelIndex(int channel) const
lets users map channels to different indices for links
double CSCBaseElectronicsSim::averageTimeOfFlight ( const DetId detId) const
protected

the average time-of-flight from the interaction point to the given detector

virtual float CSCBaseElectronicsSim::calculateAmpResponse ( float  t) const
protectedpure virtual

Implemented in CSCStripElectronicsSim, and CSCWireElectronicsSim.

Referenced by fillAmpResponse().

virtual int CSCBaseElectronicsSim::channelIndex ( int  channel) const
inlineprotectedvirtual

lets users map channels to different indices for links

Reimplemented in CSCWireElectronicsSim.

Definition at line 105 of file CSCBaseElectronicsSim.h.

Referenced by amplifySignal(), and CSCStripElectronicsSim::createDigi().

105 {return channel;}
void CSCBaseElectronicsSim::combineAnalogSignals ( const std::vector< CSCAnalogSignal > &  )
protected
const DigiSimLinks& CSCBaseElectronicsSim::digiSimLinks ( ) const
inline

Definition at line 50 of file CSCBaseElectronicsSim.h.

References theDigiSimLinks.

Referenced by CSCDigitizer::doAction().

50 {return theDigiSimLinks;}
void CSCBaseElectronicsSim::fillAmpResponse ( )
protected

Definition at line 92 of file CSCBaseElectronicsSim.cc.

References calculateAmpResponse(), i, LogTrace, theAmpResponse, theNumberOfSamples, and theSamplingTime.

Referenced by CSCStripElectronicsSim::CSCStripElectronicsSim(), and CSCWireElectronicsSim::CSCWireElectronicsSim().

92  {
93  std::vector<float> ampBinValues(theNumberOfSamples);
94  int i = 0;
95  for( ; i < theNumberOfSamples; ++i) {
96  ampBinValues[i] = calculateAmpResponse(i*theSamplingTime);
97  // truncate any entries that are trivially small
98  if(i>5 && ampBinValues[i] < 0.000001) break;
99  }
100  ampBinValues.resize(i);
101  theAmpResponse = CSCAnalogSignal(0, theSamplingTime, ampBinValues, 1., 0.);
102 
103  LogTrace("CSCBaseElectronicsSim") <<
104  "CSCBaseElectronicsSim: dump of theAmpResponse follows...\n"
105  << theAmpResponse;
106 }
int i
Definition: DBlmapReader.cc:9
virtual float calculateAmpResponse(float t) const =0
#define LogTrace(id)
CSCAnalogSignal & CSCBaseElectronicsSim::find ( int  element,
CLHEP::HepRandomEngine *  engine 
)
protected

Definition at line 149 of file CSCBaseElectronicsSim.cc.

References LogTrace, makeNoiseSignal(), nElements, theNoiseWasAdded, theNumberOfSamples, theSamplingTime, theSignalMap, and theSignalStartTime.

Referenced by add(), CSCStripElectronicsSim::addCrosstalk(), CSCStripElectronicsSim::fillStripDigis(), and CSCStripElectronicsSim::runComparator().

149  {
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");
154  }
155  CSCSignalMap::iterator signalMapItr = theSignalMap.find(element);
156  if(signalMapItr == theSignalMap.end()) {
157  CSCAnalogSignal newSignal;
158  if(theNoiseWasAdded) {
159  newSignal = makeNoiseSignal(element, engine);
160  } else {
161  std::vector<float> emptyV(theNumberOfSamples);
162  newSignal = CSCAnalogSignal(element, theSamplingTime, emptyV, 0., theSignalStartTime);
163  }
164  signalMapItr = theSignalMap.insert( std::pair<int, CSCAnalogSignal>(element, newSignal) ).first;
165  }
166  return (*signalMapItr).second;
167 }
virtual CSCAnalogSignal makeNoiseSignal(int element, CLHEP::HepRandomEngine *)
#define LogTrace(id)
virtual void CSCBaseElectronicsSim::initParameters ( )
protectedpure virtual

Implemented in CSCStripElectronicsSim, and CSCWireElectronicsSim.

Referenced by setLayer().

CSCDetId CSCBaseElectronicsSim::layerId ( ) const
inlineprotected
CSCAnalogSignal CSCBaseElectronicsSim::makeNoiseSignal ( int  element,
CLHEP::HepRandomEngine *   
)
protectedvirtual

Reimplemented in CSCStripElectronicsSim.

Definition at line 128 of file CSCBaseElectronicsSim.cc.

References theNumberOfSamples, theSamplingTime, and theSignalStartTime.

Referenced by addNoise(), and find().

128  {
129  std::vector<float> binValues(theNumberOfSamples);
130  // default is empty
131  return CSCAnalogSignal(element, theSamplingTime, binValues, 0., theSignalStartTime);
132 }
virtual int CSCBaseElectronicsSim::readoutElement ( int  element) const
protectedpure virtual

Implemented in CSCStripElectronicsSim, and CSCWireElectronicsSim.

Referenced by amplifySignal(), and simulate().

void CSCBaseElectronicsSim::setLayer ( const CSCLayer layer)
protected

Definition at line 80 of file CSCBaseElectronicsSim.cc.

References CSCLayer::chamber(), CSCDetId, GeomDet::geographicalId(), CSCLayer::geometry(), initParameters(), DetId::rawId(), CSCChamber::specs(), theLayer, theLayerGeometry, theLayerId, and theSpecs.

Referenced by CSCStripElectronicsSim::fillMissingLayer(), and simulate().

81 {
82  // fill the specs member data
83  theSpecs = layer->chamber()->specs();
84  theLayerGeometry = layer->geometry();
85 
86  theLayer = layer;
89 }
const CSCChamberSpecs * theSpecs
const CSCLayerGeometry * theLayerGeometry
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const CSCChamberSpecs * specs() const
Definition: CSCChamber.h:42
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
virtual void initParameters()=0
const CSCChamber * chamber() const
Definition: CSCLayer.h:52
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:47
void CSCBaseElectronicsSim::setLayerId ( const CSCDetId id)
inline

for standalone apps who don't calculate it from the geometry

Definition at line 55 of file CSCBaseElectronicsSim.h.

References theLayerId.

void CSCBaseElectronicsSim::setNoise ( float  rmsNoise,
float  noiseSigmaThreshold 
)
protected
void CSCBaseElectronicsSim::setSignalTimeRange ( double  startTime,
double  stopTime 
)
inlineprotected

How long before & after the bunch crossing to simulate shortening the time can save CPU

Definition at line 81 of file CSCBaseElectronicsSim.h.

References dcs_trend_monitor_cfg::startTime, theSignalStartTime, and theSignalStopTime.

float CSCBaseElectronicsSim::signalDelay ( int  element,
float  pos 
) const
protectedvirtual

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

Definition at line 178 of file CSCBaseElectronicsSim.cc.

References CSCChamberSpecs::chamberType(), HLT_25ns10e33_v2_cff::distance, HLT_25ns10e33_v2_cff::speed, theSignalPropagationSpeed, and theSpecs.

Referenced by amplifySignal().

178  {
179  // readout is on top edge of chamber for strips, right edge
180  // for wires.
181  // zero calibrated to chamber center
182  float distance = -1. * pos;
184  return distance / speed;
185 }
const CSCChamberSpecs * theSpecs
std::vector< double > theSignalPropagationSpeed
int chamberType() const
void CSCBaseElectronicsSim::simulate ( const CSCLayer layer,
const std::vector< CSCDetectorHit > &  inputHits,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 46 of file CSCBaseElectronicsSim.cc.

References add(), addNoise(), amplifySignal(), doNoise_, AlCaHLTBitMon_QueryRunRegistry::getElement(), i, layerId(), readoutElement(), setLayer(), theDetectorHitMap, theDigiSimLinks, theNoiseWasAdded, and theSignalMap.

Referenced by CSCDigitizer::doAction().

49 {
50  theNoiseWasAdded = false;
51 
52  {
53  theSignalMap.clear();
54  theDetectorHitMap.clear();
55  setLayer(layer);
56  // can we swap for efficiency?
58  }
59 
60  {
61  size_t nHits = detectorHits.size();
62  // turn each detector hit into an analog signal
63  for( size_t i = 0; i < nHits; ++i) {
64  int element = readoutElement( detectorHits[i].getElement() );
65 
66  // skip if hit element is not part of a readout element
67  // e.g. wire in non-readout group
68  if ( element != 0 ) add( amplifySignal(detectorHits[i]), engine );
69  }
70  }
71 
72  {
73  if(doNoise_) {
74  addNoise(engine);
75  }
76  }
77 }
int i
Definition: DBlmapReader.cc:9
CSCAnalogSignal amplifySignal(const CSCDetectorHit &)
void setLayer(const CSCLayer *layer)
edm::DetSet< StripDigiSimLink > DigiSimLinks
virtual int readoutElement(int element) const =0
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
void addNoise(CLHEP::HepRandomEngine *)
CSCAnalogSignal & add(const CSCAnalogSignal &, CLHEP::HepRandomEngine *)

Member Data Documentation

bool CSCBaseElectronicsSim::doNoise_
protected
int CSCBaseElectronicsSim::nElements
protected
CSCAnalogSignal CSCBaseElectronicsSim::theAmpResponse
protected

Definition at line 122 of file CSCBaseElectronicsSim.h.

Referenced by amplifySignal(), and fillAmpResponse().

float CSCBaseElectronicsSim::theBunchSpacing
protected
std::vector<double> CSCBaseElectronicsSim::theBunchTimingOffsets
protected
DetectorHitMap CSCBaseElectronicsSim::theDetectorHitMap
protected
DigiSimLinks CSCBaseElectronicsSim::theDigiSimLinks
protected

Definition at line 163 of file CSCBaseElectronicsSim.h.

Referenced by addLinks(), digiSimLinks(), and simulate().

const CSCLayer* CSCBaseElectronicsSim::theLayer
protected
const CSCLayerGeometry* CSCBaseElectronicsSim::theLayerGeometry
protected
CSCDetId CSCBaseElectronicsSim::theLayerId
protected
bool CSCBaseElectronicsSim::theNoiseWasAdded
protected

Definition at line 130 of file CSCBaseElectronicsSim.h.

Referenced by addNoise(), find(), and simulate().

int CSCBaseElectronicsSim::theNumberOfSamples
protected
int CSCBaseElectronicsSim::theOffsetOfBxZero
protected
float CSCBaseElectronicsSim::thePeakTimeSigma
protected

Definition at line 137 of file CSCBaseElectronicsSim.h.

Referenced by addNoise().

float CSCBaseElectronicsSim::theSamplingTime
protected
int CSCBaseElectronicsSim::theShapingTime
protected
CSCSignalMap CSCBaseElectronicsSim::theSignalMap
protected
std::vector<double> CSCBaseElectronicsSim::theSignalPropagationSpeed
protected

Speed (cm/ns) that it takes for the signal to get from the element to the readout. Actually negative in strips, due to reflection effects.

Definition at line 156 of file CSCBaseElectronicsSim.h.

Referenced by signalDelay().

float CSCBaseElectronicsSim::theSignalStartTime
protected
float CSCBaseElectronicsSim::theSignalStopTime
protected
const CSCChamberSpecs* CSCBaseElectronicsSim::theSpecs
protected
std::vector<double> CSCBaseElectronicsSim::theTimingCalibrationError
protected