CMS 3D CMS Logo

CSCRecoConditions.cc
Go to the documentation of this file.
4 #include <iostream>
5 
6 CSCRecoConditions::CSCRecoConditions(const edm::ParameterSet& ps) : theConditions(ps) {}
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 }
HLT_2018_cff.weights
weights
Definition: HLT_2018_cff.py:87167
mps_fire.i
i
Definition: mps_fire.py:355
CSCRecoConditions::chipCorrection
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...
Definition: CSCRecoConditions.cc:36
MessageLogger.h
CSCRecoConditions::initializeEvent
void initializeEvent(const edm::EventSetup &es)
fetch the cond data from the database
Definition: CSCRecoConditions.cc:10
CSCRecoConditions::pedestalSigma
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,...
Definition: CSCRecoConditions.cc:24
CSCRecoConditions::~CSCRecoConditions
~CSCRecoConditions()
Definition: CSCRecoConditions.cc:8
CSCConditions::idOfBadChannelWords
const CSCDetId & idOfBadChannelWords() const
the offline CSCDetId of current bad channel words
Definition: CSCConditions.h:98
CSCRecoConditions.h
CSCRecoConditions::gain
float gain(const CSCDetId &id, int geomStrip) const
channels and geomstrips count from 1
Definition: CSCRecoConditions.cc:28
CSCRecoConditions::noiseMatrix
void noiseMatrix(const CSCDetId &id, int centralStrip, std::vector< float > &nme) const
Definition: CSCRecoConditions.cc:68
CSCRecoConditions::averageGain
float averageGain() const
return average gain over entire CSC system
Definition: CSCRecoConditions.h:39
CSCRecoConditions::CSCRecoConditions
CSCRecoConditions(const edm::ParameterSet &pset)
Definition: CSCRecoConditions.cc:6
CSCRecoConditions::badWireWord
const std::bitset< 112 > & badWireWord(const CSCDetId &id) const
Get bad wiregroup word.
Definition: CSCRecoConditions.cc:162
CSCRecoConditions::chamberTimingCorrection
float chamberTimingCorrection(const CSCDetId &id) const
Definition: CSCRecoConditions.cc:164
CSCConditions::pedestal
float pedestal(const CSCDetId &detId, int channel) const
static ped in ADC counts
Definition: CSCConditions.cc:237
CSCConditions::channelFromStrip
int channelFromStrip(const CSCDetId &id, int geomStrip) const
feedthrough for external access
Definition: CSCConditions.cc:402
CSCRecoConditions::crossTalk
void crossTalk(const CSCDetId &id, int centralStrip, std::vector< float > &xtalks) const
Definition: CSCRecoConditions.cc:115
CSCConditions::fillBadChannelWords
void fillBadChannelWords(const CSCDetId &id)
Definition: CSCConditions.cc:119
CSCConditions::gain
float gain(const CSCDetId &detId, int channel) const
gain per channel
Definition: CSCConditions.cc:229
CSCConditions::noiseMatrixElements
void noiseMatrixElements(const CSCDetId &id, int channel, std::vector< float > &me) const
Definition: CSCConditions.cc:285
CSCConditions::badWireWord
const std::bitset< 112 > & badWireWord() const
bad wiregroup channel word for a CSCLayer - 1 bit per channel
Definition: CSCConditions.h:95
CSCConditions::chipCorrection
float chipCorrection(const CSCDetId &detId, int channel) const
chip speed correction in ns given detId (w/layer) and strip channel
Definition: CSCConditions.cc:314
w
const double w
Definition: UKUtility.cc:23
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
dqmdumpme.k
k
Definition: dqmdumpme.py:60
CSCRecoConditions::stripWeight
float stripWeight(const CSCDetId &id, int geomStrip) const
return gain weight for given strip channel
Definition: CSCRecoConditions.cc:56
CSCRecoConditions::badStrip
bool badStrip(const CSCDetId &id, int geomStrip, int nstrips) const
Is the strip bad?
Definition: CSCRecoConditions.cc:138
edm::ParameterSet
Definition: ParameterSet.h:36
CSCConditions::gasGainCorrection
float gasGainCorrection(const CSCDetId &detId, int strip, int wire) const
Definition: CSCConditions.cc:390
CSCRecoConditions::nearBadStrip
bool nearBadStrip(const CSCDetId &id, int geomStrip, int nstrips) const
Is a neighbour bad?
Definition: CSCRecoConditions.cc:132
CSCChannelTranslator.h
CSCDetId
Definition: CSCDetId.h:26
CSCConditions::anodeBXoffset
float anodeBXoffset(const CSCDetId &detId) const
anode bx offset in bx given detId of chamber
Definition: CSCConditions.cc:337
CSCRecoConditions::theConditions
CSCConditions theConditions
Definition: CSCRecoConditions.h:89
CSCRecoConditions::pedestal
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)
Definition: CSCRecoConditions.cc:18
CSCRecoConditions::fillBadChannelWords
void fillBadChannelWords(const CSCDetId &id)
fill bad strip & bad wiregroup bitsets from conditions data
Definition: CSCRecoConditions.cc:13
CSCConditions::rawStripChannel
int rawStripChannel(const CSCDetId &id, int geomChannel) const
Definition: CSCConditions.cc:406
edm::EventSetup
Definition: EventSetup.h:57
CSCConditions::initializeEvent
void initializeEvent(const edm::EventSetup &es)
fetch database content via EventSetup
Definition: CSCConditions.cc:66
CSCRecoConditions::gasGainCorrection
float gasGainCorrection(const CSCDetId &id, int strip, int wireGroup) const
returns gas-gain correction
Definition: CSCRecoConditions.cc:170
CSCConditions::pedestalSigma
float pedestalSigma(const CSCDetId &detId, int channel) const
static ped rms in ADC counts
Definition: CSCConditions.cc:245
CSCConditions::chamberTimingCorrection
float chamberTimingCorrection(const CSCDetId &detId) const
chamber timing correction in ns given detId of chamber
Definition: CSCConditions.cc:325
CSCConditions::badStripWord
const std::bitset< 112 > & badStripWord() const
bad strip channel word for a CSCLayer - 1 bit per channel
Definition: CSCConditions.h:92
CSCRecoConditions::anodeBXoffset
float anodeBXoffset(const CSCDetId &detId) const
Definition: CSCRecoConditions.cc:168
CSCRecoConditions::stripWeights
void stripWeights(const CSCDetId &id, short int nstrips, float *weights) const
Definition: CSCRecoConditions.cc:47
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:56
CSCConditions::crossTalk
void crossTalk(const CSCDetId &id, int channel, std::vector< float > &ct) const
Definition: CSCConditions.cc:302