CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCRecoConditions.cc
Go to the documentation of this file.
4 #include <iostream>
5 
7 
9 
11 
14 
17 
18 float CSCRecoConditions::pedestal(const CSCDetId& id, int geomChannel) const {
19  LogTrace("CSCRecoConditions") << id << " geomChannel " << geomChannel << " pedestal "
20  << theConditions.pedestal(id, geomChannel);
21  return theConditions.pedestal(id, geomChannel);
22 }
23 
24 float CSCRecoConditions::pedestalSigma(const CSCDetId& id, int geomChannel) const {
25  return theConditions.pedestalSigma(id, geomChannel);
26 }
27 
28 float CSCRecoConditions::gain(const CSCDetId& id, int geomChannel) const {
29  LogTrace("CSCRecoConditions") << id << " geomChannel " << geomChannel << " gain "
30  << theConditions.gain(id, geomChannel);
31  return theConditions.gain(id, geomChannel);
32 }
33 
35 
36 float CSCRecoConditions::chipCorrection(const CSCDetId& id, int geomStrip) const {
37  // geometric strip to geometric channel (e.g. ME1a, 1-48->1-16 ganged or 1-48 unganged)
38  int geomChannel = theConditions.channelFromStrip(id, geomStrip);
39  return theConditions.chipCorrection(id, geomChannel);
40 }
41 
42 // stripWeights is required in CSCHitFromStripOnly.
43 // - Has nstrips in arg list because caller already has this value from CSCChamberSpecs.
44 // - We only have gains per geometric channel of course, and we only apply them by channel too
45 // (in CSCHitFromStripOnly), but we may as well fill values for each strip.
46 
47 void CSCRecoConditions::stripWeights(const CSCDetId& id, short int nstrips, float* weights) const {
48  for (short int i = 1; i < nstrips + 1; ++i) {
49  weights[i - 1] = stripWeight(id, i);
50  }
51 }
52 
53 // Calculate weight as 1/(gain/average gain)
54 // Input is offline CSCDetId (e.g. ir=4 for ME1A), and geom strip # (e.g. 1-48 for ME1A)
55 
56 float CSCRecoConditions::stripWeight(const CSCDetId& id, int geomStrip) const {
57  int geomChannel = theConditions.channelFromStrip(id, geomStrip);
58  float w = averageGain() / gain(id, geomChannel); // averageGain() from CSCConditions
59  // Weights are forced to lie within 0.5 and 1.5
60  if (w > 1.5)
61  w = 1.5;
62  if (w < 0.5)
63  w = 0.5;
64  LogTrace("CSCRecoConditions") << id << " geomStrip " << geomStrip << " stripWeight " << w;
65  return w;
66 }
67 
68 void CSCRecoConditions::noiseMatrix(const CSCDetId& id, int geomStrip, std::vector<float>& nMatrix) const {
69  // nMatrix will be filled with expanded noise matrix elements for strip 'geomStrip' and its immediate neighbours
70 
71  nMatrix.clear();
72 
73  // These are ME1/2 constants as fall-back
74  const float fakeme12[15] = {8.64, 3.47, 2.45, 8.60, 3.28, 1.88, 8.61, 3.18, 1.99, 7.67, 2.64, 0., 7.71, 0., 0.};
75 
76  float elem[15];
77 
78  for (short int i = geomStrip - 1; i < geomStrip + 2; ++i) {
79  std::vector<float> me(12);
80 
81  float w = stripWeight(id, i);
82  w = w * w;
83  int geomChannel = theConditions.channelFromStrip(id, i);
84  theConditions.noiseMatrixElements(id, geomChannel, me);
85  for (short int j = 0; j < 11; ++j) {
86  elem[j] = me[j] * w;
87  }
88  elem[11] = 0.;
89  elem[12] = me[11] * w;
90  elem[13] = 0.;
91  elem[14] = 0.;
92 
93  // Test that elements make sense:
94  bool isFlawed = false;
95  for (short int k = 0; k < 15; ++k) {
96  if (elem[k] < 0.001)
97  elem[k] = 0.001; // fix if too small...
98  if (elem[k] > 50.)
99  isFlawed = true; // fail if too big...
100  }
101 
102  if (isFlawed) {
103  // These are fake ME1/2:
104  for (short int m = 0; m < 15; ++m) {
105  elem[m] = fakeme12[m];
106  }
107  }
108 
109  for (int k = 0; k < 15; ++k) {
110  nMatrix.push_back(elem[k]);
111  }
112  }
113 }
114 
115 void CSCRecoConditions::crossTalk(const CSCDetId& id, int geomStrip, std::vector<float>& xtalks) const {
116  // xtalks will be filled with crosstalk for geomStrip and its immediate neighbours
117 
118  xtalks.clear();
119 
120  for (short int i = geomStrip - 1; i < geomStrip + 2; ++i) {
121  int geomChannel = theConditions.channelFromStrip(id, i);
122  std::vector<float> ct(4);
123  theConditions.crossTalk(id, geomChannel, ct);
124  xtalks.push_back(ct[0]);
125  xtalks.push_back(ct[1]);
126  xtalks.push_back(ct[2]);
127  xtalks.push_back(ct[3]);
128  }
129 }
130 
132 bool CSCRecoConditions::nearBadStrip(const CSCDetId& id, int geomStrip, int nstrips) const {
133  bool nearBad = (badStrip(id, geomStrip - 1, nstrips) || badStrip(id, geomStrip + 1, nstrips));
134  return nearBad;
135 }
136 
138 bool CSCRecoConditions::badStrip(const CSCDetId& id, int geomStrip, int nstrips) const {
139  // input nstrips is no. of strips in the layer (could get this from CSCChamberSpecs or CSCLayerGeometry
140  // but then need a CSCLayer*)
141 
142  bool bad = true; // if geomStrip out of range, call strip bad
143 
144  if (id != theConditions.idOfBadChannelWords()) {
145  bad = false; // if bad channel words for this id not filled, call strip good
146  return bad;
147  }
148 
149  if (geomStrip > 0 && geomStrip <= nstrips) {
150  bad = false; // default to good
151  int geomChan = theConditions.channelFromStrip(id, geomStrip);
152  int rawChan = theConditions.rawStripChannel(id, geomChan);
153  if (rawChan > 0 && rawChan < 113) {
154  const std::bitset<112>& badStrips = theConditions.badStripWord();
155  bad = badStrips.test(rawChan - 1); // 112 bits max, labelled 0-111.
156  }
157  }
158  return bad;
159 }
160 
162 const std::bitset<112>& CSCRecoConditions::badWireWord(const CSCDetId& id) const { return theConditions.badWireWord(); }
163 
166 }
167 
169 
170 float CSCRecoConditions::gasGainCorrection(const CSCDetId& id, int geomStrip, int wiregroup) const {
171  int geomChannel = theConditions.channelFromStrip(id, geomStrip);
172  return theConditions.gasGainCorrection(id, geomChannel, wiregroup);
173 }
float gasGainCorrection(const CSCDetId &id, int strip, int wireGroup) const
returns gas-gain correction
CSCRecoConditions(const edm::ParameterSet &pset, edm::ConsumesCollector)
const double w
Definition: UKUtility.cc:23
float pedestalSigma(const CSCDetId &detId, int channel) const
static ped rms in ADC counts
void noiseMatrixElements(const CSCDetId &id, int channel, std::vector< float > &me) const
void fillBadChannelWords(const CSCDetId &id)
void noiseMatrix(const CSCDetId &id, int centralStrip, std::vector< float > &nme) const
float chipCorrection(const CSCDetId &detId, int channel) const
chip speed correction in ns given detId (w/layer) and strip channel
float averageGain() const
return average gain over entire CSC system
bool nearBadStrip(const CSCDetId &id, int geomStrip, int nstrips) const
Is a neighbour bad?
float chamberTimingCorrection(const CSCDetId &detId) const
chamber timing correction in ns given detId of chamber
#define LogTrace(id)
void crossTalk(const CSCDetId &id, int channel, std::vector< float > &ct) const
float anodeBXoffset(const CSCDetId &detId) const
anode bx offset in bx given detId of chamber
float pedestal(const CSCDetId &detId, int channel) const
static ped in ADC counts
bool badStrip(const CSCDetId &id, int geomStrip, int nstrips) const
Is the strip bad?
float gain(const CSCDetId &id, int geomStrip) const
channels and geomstrips count from 1
const std::bitset< 112 > & badWireWord() const
bad wiregroup channel word for a CSCLayer - 1 bit per channel
void fillBadChannelWords(const CSCDetId &id)
fill bad strip &amp; bad wiregroup bitsets from conditions data
int rawStripChannel(const CSCDetId &id, int geomChannel) const
int channelFromStrip(const CSCDetId &id, int geomStrip) const
feedthrough for external access
CSCConditions theConditions
void initializeEvent(const edm::EventSetup &es)
fetch database content via EventSetup
float stripWeight(const CSCDetId &id, int geomStrip) const
return gain weight for given strip channel
float gain(const CSCDetId &detId, int channel) const
gain per channel
float chipCorrection(const CSCDetId &detId, int channel) const
All other functions are accessed by geometrical strip label (i.e. strip number according to local coo...
float anodeBXoffset(const CSCDetId &detId) const
void crossTalk(const CSCDetId &id, int centralStrip, std::vector< float > &xtalks) const
float pedestalSigma(const CSCDetId &id, int channel) const
sigma of static pedestal in ADC counts for strip channel (e.g. 1-16 for ganged ME1a, 1-48 for unganged ME1a)
void stripWeights(const CSCDetId &id, short int nstrips, float *weights) const
float pedestal(const CSCDetId &id, int channel) const
static pedestal in ADC counts for strip channel (e.g. 1-16 for ganged ME1a, 1-48 for unganged ME1a) ...
const CSCDetId & idOfBadChannelWords() const
the offline CSCDetId of current bad channel words
float gasGainCorrection(const CSCDetId &detId, int strip, int wire) const
float chamberTimingCorrection(const CSCDetId &id) const
void initializeEvent(const edm::EventSetup &es)
fetch the cond data from the database
const std::bitset< 112 > & badWireWord(const CSCDetId &id) const
Get bad wiregroup word.
const std::bitset< 112 > & badStripWord() const
bad strip channel word for a CSCLayer - 1 bit per channel