CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
CSCWireElectronicsSim Class Reference

#include <CSCWireElectronicsSim.h>

Inheritance diagram for CSCWireElectronicsSim:
CSCBaseElectronicsSim

Public Member Functions

 CSCWireElectronicsSim (const edm::ParameterSet &p)
 configurable parameters More...
 
void fillDigis (CSCWireDigiCollection &digis)
 
void setFraction (float newFraction)
 
- Public Member Functions inherited from CSCBaseElectronicsSim
const DigiSimLinksdigiSimLinks () const
 
void setLayerId (const CSCDetId &id)
 for standalone apps who don't calculate it from the geometry More...
 
void setRandomEngine (CLHEP::HepRandomEngine &engine)
 
void simulate (const CSCLayer *layer, const std::vector< CSCDetectorHit > &inputHits)
 
virtual ~CSCBaseElectronicsSim ()
 

Private Member Functions

float calculateAmpResponse (float t) const
 
virtual int channelIndex (int channel) const
 we code strip indices from 1-80, and wire indices start at 100 More...
 
virtual void initParameters ()
 initialization for each layer More...
 
virtual int readoutElement (int element) const
 
virtual float timeOfFlightCalibration (int wireGroup) const
 

Private Attributes

float theFraction
 
float theWireNoise
 
float theWireThreshold
 

Additional Inherited Members

- Public Types inherited from CSCBaseElectronicsSim
typedef std::map< int,
CSCAnalogSignal, std::less
< int > > 
CSCSignalMap
 
typedef edm::DetSet
< StripDigiSimLink
DigiSimLinks
 
- Protected Types inherited from CSCBaseElectronicsSim
enum  { NONE, CONSERVATIVE, RADICAL }
 
typedef std::multimap< int,
CSCDetectorHit, std::less< int > > 
DetectorHitMap
 
- Protected Member Functions inherited from CSCBaseElectronicsSim
CSCAnalogSignaladd (const CSCAnalogSignal &)
 
virtual void addLinks (int channelIndex)
 
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 More...
 
void combineAnalogSignals (const std::vector< CSCAnalogSignal > &)
 
 CSCBaseElectronicsSim (const edm::ParameterSet &p)
 
void fillAmpResponse ()
 
CSCAnalogSignalfind (int element)
 
CSCDetId layerId () const
 the CSCDetId corresponding to the current layer More...
 
virtual CSCAnalogSignal makeNoiseSignal (int element)
 
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 inherited from CSCBaseElectronicsSim
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
 
CLHEP::RandGaussQ * theRandGaussQ
 
float theSamplingTime
 
int theShapingTime
 
CSCSignalMap theSignalMap
 
std::vector< double > theSignalPropagationSpeed
 
float theSignalStartTime
 
float theSignalStopTime
 
const CSCChamberSpecstheSpecs
 
std::vector< double > theTimingCalibrationError
 

Detailed Description

Model the readout electronics chain for EMU CSC wires

Author
Rick Wilkinson

Definition at line 21 of file CSCWireElectronicsSim.h.

Constructor & Destructor Documentation

CSCWireElectronicsSim::CSCWireElectronicsSim ( const edm::ParameterSet p)

configurable parameters

Definition at line 13 of file CSCWireElectronicsSim.cc.

References CSCBaseElectronicsSim::fillAmpResponse().

Member Function Documentation

float CSCWireElectronicsSim::calculateAmpResponse ( float  t) const
privatevirtual

Implements CSCBaseElectronicsSim.

Definition at line 160 of file CSCWireElectronicsSim.cc.

References reco::dp, create_public_lumi_plots::exp, p1, and funct::pow().

160  {
161  static const float fC_by_ns = 1000000;
162  static const float resistor = 20000;
163  static const float amplifier_pole = 1/7.5;
164  static const float fastest_chamber_exp_risetime = 10.;
165  static const float p0=amplifier_pole;
166  static const float p1=1/fastest_chamber_exp_risetime;
167 
168  static const float dp = p0 - p1;
169 
170  // ENABLE DISC:
171 
172  static const float norm = -12 * resistor * p1 * pow(p0/dp, 4) / fC_by_ns;
173 
174  float enable_disc_volts = norm*( exp(-p0*t) *(1 +
175  t*dp +
176  pow(t*dp,2)/2 +
177  pow(t*dp,3)/6 )
178  - exp(-p1*t) );
179  static const float collectionFraction = 0.12;
180  static const float igain = 1./0.005; // volts per fC
181  return enable_disc_volts * igain * collectionFraction;
182 }
auto dp
Definition: deltaR.h:24
double p1[4]
Definition: TauolaWrapper.h:89
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
virtual int CSCWireElectronicsSim::channelIndex ( int  channel) const
inlineprivatevirtual

we code strip indices from 1-80, and wire indices start at 100

Reimplemented from CSCBaseElectronicsSim.

Definition at line 43 of file CSCWireElectronicsSim.h.

Referenced by fillDigis().

43 {return channel+100;}
void CSCWireElectronicsSim::fillDigis ( CSCWireDigiCollection digis)

Definition at line 35 of file CSCWireElectronicsSim.cc.

References CSCBaseElectronicsSim::addLinks(), CSCChamberSpecs::chamberType(), channelIndex(), CSCBaseElectronicsSim::doNoise_, CSCAnalogSignal::getBinValue(), CSCAnalogSignal::getSize(), i, CSCBaseElectronicsSim::layerId(), LogTrace, CSCBaseElectronicsSim::theBunchSpacing, CSCBaseElectronicsSim::theBunchTimingOffsets, theFraction, CSCBaseElectronicsSim::theOffsetOfBxZero, CSCBaseElectronicsSim::theRandGaussQ, CSCBaseElectronicsSim::theSamplingTime, CSCBaseElectronicsSim::theSignalMap, CSCBaseElectronicsSim::theSignalStartTime, CSCBaseElectronicsSim::theSpecs, CSCBaseElectronicsSim::theTimingCalibrationError, theWireNoise, theWireThreshold, dtDQMClient_cfg::threshold, and timeOfFlightCalibration().

Referenced by CSCDigitizer::doAction().

35  {
36 
37  if(theSignalMap.empty()) {
38  return;
39  }
40 
41  // Loop over analog signals, run the fractional discriminator on each one,
42  // and save the DIGI in the layer.
43  for(CSCSignalMap::iterator mapI = theSignalMap.begin(),
44  lastSignal = theSignalMap.end();
45  mapI != lastSignal; ++mapI)
46  {
47  int wireGroup = (*mapI).first;
48  const CSCAnalogSignal & signal = (*mapI).second;
49  LogTrace("CSCWireElectronicsSim") << "CSCWireElectronicsSim: dump of wire signal follows... "
50  << signal;
51  int signalSize = signal.getSize();
52 
53  int timeWord = 0; // and this will remain if too early or late (<bx-6 or >bx+9)
54 
55  // the way we handle noise in this chamber is by randomly varying
56  // the threshold
58  if (doNoise_) {
59  threshold += theRandGaussQ->fire() * theWireNoise;
60  }
61  for(int ibin = 0; ibin < signalSize; ++ibin)
62  {
63  if(signal.getBinValue(ibin) > threshold)
64  {
65  // jackpot. Now define this signal as everything up until
66  // the signal goes below zero.
67  int lastbin = signalSize;
68  int i;
69  for(i = ibin; i < signalSize; ++i) {
70  if(signal.getBinValue(i) < 0.) {
71  lastbin = i;
72  break;
73  }
74  }
75 
76  float qMax = 0.0;
77  // in this loop, find the max charge and the 'fifth' electron arrival
78  for ( i = ibin; i < lastbin; ++i)
79  {
80  float next_charge = signal.getBinValue(i);
81  if(next_charge > qMax) {
82  qMax = next_charge;
83  }
84  }
85 
86  int bin_firing_FD = 0;
87  for ( i = ibin; i < lastbin; ++i)
88  {
89  if( signal.getBinValue(i) >= qMax * theFraction )
90  {
91  bin_firing_FD = i;
92  //@@ Long-standing but unlikely minor bug, I (Tim) think - following 'break' was missing...
93  //@@ ... So if both ibins 0 and 1 could fire FD, we'd flag the firing bin as 1 not 0
94  //@@ (since the above test was restricted to bin_firing_FD==0 too).
95  break;
96  }
97  }
98 
99  float tofOffset = timeOfFlightCalibration(wireGroup);
100  int chamberType = theSpecs->chamberType();
101 
102  // Note that CSCAnalogSignal::superimpose does not reset theTimeOffset to the earliest
103  // of the two signal's time offsets. If it did then we could handle signals from any
104  // time range e.g. form pileup events many bx's from the signal bx (bx=0).
105  // But then we would be wastefully storing signals over times which we can never
106  // see in the real detector, because only hits within a few bx's of bx=0 are read out.
107  // Instead, the working time range for wire hits is always started from
108  // theSignalStartTime, set as a parameter in the config file.
109  // On the other hand, if any of the overlapped CSCAnalogSignals happens to have
110  // a timeOffset earlier than theSignalStartTime (which is currently set to -100 ns)
111  // then we're in trouble. For pileup events this would mean events from collisions
112  // earlier than 4 bx before the signal bx.
113 
114  float fdTime = theSignalStartTime + theSamplingTime*bin_firing_FD;
115  if(doNoise_) {
116  fdTime += theTimingCalibrationError[chamberType] * theRandGaussQ->fire();
117  }
118 
119  float bxFloat = (fdTime - tofOffset- theBunchTimingOffsets[chamberType]) / theBunchSpacing
121  int bxInt = static_cast<int>(bxFloat);
122  if(bxFloat >= 0 && bxFloat < 16)
123  {
124  timeWord |= (1 << bxInt );
125  // discriminator stays high for 35 ns
126  if(bxFloat-bxInt > 0.6)
127  {
128  timeWord |= (1 << (bxInt+1) );
129  }
130  }
131 
132  // Wire digi as of Oct-2006 adapted to real data: time word has 16 bits with set bit
133  // flagging appropriate bunch crossing, and bx 0 corresponding to the 7th bit, 'bit 6':
134 
135  // 1st bit set (bit 0) <-> bx -6
136  // 2nd 1 <-> bx -5
137  // ... ... ....
138  // 7th 6 <-> bx 0
139  // 8th 7 <-> bx +1
140  // ... ... ....
141  // 16th 15 <-> bx +9
142 
143  // skip over all the time bins used for this digi
144  ibin = lastbin;
145  } // if over threshold
146  } // loop over time bins in signal
147 
148  // Only create a wire digi if there is a wire hit within [-6 bx, +9 bx]
149  if(timeWord != 0)
150  {
151  CSCWireDigi newDigi(wireGroup, timeWord);
152  LogTrace("CSCWireElectronicsSim") << newDigi;
153  digis.insertDigi(layerId(), newDigi);
154  addLinks(channelIndex(wireGroup));
155  }
156  } // loop over wire signals
157 }
std::vector< double > theBunchTimingOffsets
int i
Definition: DBlmapReader.cc:9
const CSCChamberSpecs * theSpecs
float getBinValue(int i) const
virtual int channelIndex(int channel) const
we code strip indices from 1-80, and wire indices start at 100
CLHEP::RandGaussQ * theRandGaussQ
int getSize() const
#define LogTrace(id)
virtual void addLinks(int channelIndex)
int chamberType() const
CSCDetId layerId() const
the CSCDetId corresponding to the current layer
virtual float timeOfFlightCalibration(int wireGroup) const
std::vector< double > theTimingCalibrationError
void CSCWireElectronicsSim::initParameters ( )
privatevirtual

initialization for each layer

Implements CSCBaseElectronicsSim.

Definition at line 23 of file CSCWireElectronicsSim.cc.

References e_SI, CSCBaseElectronicsSim::nElements, CSCLayerGeometry::numberOfWireGroups(), funct::pow(), CSCBaseElectronicsSim::theLayerGeometry, CSCBaseElectronicsSim::theShapingTime, CSCBaseElectronicsSim::theSpecs, theWireNoise, theWireThreshold, and CSCChamberSpecs::wireNoise().

23  {
26  * e_SI * pow(10.0,15);
28 }
const CSCChamberSpecs * theSpecs
const CSCLayerGeometry * theLayerGeometry
int numberOfWireGroups() const
#define e_SI
float wireNoise(float timeInterval) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
int CSCWireElectronicsSim::readoutElement ( int  element) const
privatevirtual

Implements CSCBaseElectronicsSim.

Definition at line 31 of file CSCWireElectronicsSim.cc.

References CSCBaseElectronicsSim::theLayerGeometry, and CSCLayerGeometry::wireGroup().

31  {
32  return theLayerGeometry->wireGroup(element);
33 }
const CSCLayerGeometry * theLayerGeometry
int wireGroup(int wire) const
void CSCWireElectronicsSim::setFraction ( float  newFraction)
inline

Definition at line 27 of file CSCWireElectronicsSim.h.

References theFraction.

27 {theFraction = newFraction;};
float CSCWireElectronicsSim::timeOfFlightCalibration ( int  wireGroup) const
privatevirtual

Definition at line 185 of file CSCWireElectronicsSim.cc.

References CSCLayer::centerOfWireGroup(), LogTrace, PV3DBase< T, PVType, FrameType >::mag(), CSCLayerGeometry::numberOfWireGroups(), CSCBaseElectronicsSim::theLayer, and CSCBaseElectronicsSim::theLayerGeometry.

Referenced by fillDigis().

185  {
186  // calibration is done for groups of 8 wire groups, facetiously
187  // called wireGroupGroups
188  int middleWireGroup = wireGroup - wireGroup%8 + 4;
189  int numberOfWireGroups = theLayerGeometry->numberOfWireGroups();
190  if(middleWireGroup > numberOfWireGroups)
191  middleWireGroup = numberOfWireGroups;
192 
193  GlobalPoint centerOfGroupGroup = theLayer->centerOfWireGroup(middleWireGroup);
194  float averageDist = centerOfGroupGroup.mag();
195  float averageTOF = averageDist * cm / c_light; // Units of c_light: mm/ns
196 
197  LogTrace("CSCWireElectronicsSim") << "CSCWireElectronicsSim: TofCalib wg = " << wireGroup <<
198  " mid wg = " << middleWireGroup <<
199  " av dist = " << averageDist <<
200  " av tof = " << averageTOF;
201 
202  return averageTOF;
203 }
const CSCLayerGeometry * theLayerGeometry
int numberOfWireGroups() const
T mag() const
Definition: PV3DBase.h:67
#define LogTrace(id)
GlobalPoint centerOfWireGroup(int wireGroup) const
Definition: CSCLayer.cc:10

Member Data Documentation

float CSCWireElectronicsSim::theFraction
private

Definition at line 48 of file CSCWireElectronicsSim.h.

Referenced by fillDigis(), and setFraction().

float CSCWireElectronicsSim::theWireNoise
private

Definition at line 49 of file CSCWireElectronicsSim.h.

Referenced by fillDigis(), and initParameters().

float CSCWireElectronicsSim::theWireThreshold
private

Definition at line 50 of file CSCWireElectronicsSim.h.

Referenced by fillDigis(), and initParameters().