CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCRecoConditions.cc
Go to the documentation of this file.
4 #include <iostream>
5 
6 CSCRecoConditions::CSCRecoConditions( const edm::ParameterSet & ps ) : theConditions( ps ) {
7 }
8 
10 }
11 
14 }
15 
19 }
20 
23 
24 float CSCRecoConditions::pedestal(const CSCDetId& id, int geomChannel) const {
25  LogTrace("CSCRecoConditions") << id << " geomChannel " << geomChannel << " pedestal " << theConditions.pedestal(id, geomChannel);
26  return theConditions.pedestal(id, geomChannel);
27 }
28 
29 float CSCRecoConditions::pedestalSigma(const CSCDetId& id, int geomChannel) const {
30  return theConditions.pedestalSigma(id, geomChannel);
31 }
32 
33 float CSCRecoConditions::gain(const CSCDetId& id, int geomChannel) const {
34  LogTrace("CSCRecoConditions") << id << " geomChannel " << geomChannel << " gain " << theConditions.gain(id, geomChannel);
35  return theConditions.gain(id, geomChannel);
36 }
37 
39 
40 float CSCRecoConditions::chipCorrection(const CSCDetId & id, int geomStrip) const {
41  // geometric strip to geometric channel (e.g. ME1a, 1-48->1-16 ganged or 1-48 unganged)
42  int geomChannel = theConditions.channelFromStrip( id, geomStrip );
43  return theConditions.chipCorrection(id, geomChannel);
44 }
45 
46 // stripWeights is required in CSCHitFromStripOnly.
47 // - Has nstrips in arg list because caller already has this value from CSCChamberSpecs.
48 // - We only have gains per geometric channel of course, and we only apply them by channel too
49 // (in CSCHitFromStripOnly), but we may as well fill values for each strip.
50 
51 void CSCRecoConditions::stripWeights( const CSCDetId& id, short int nstrips, float* weights ) const {
52 
53  for ( short int i = 1; i < nstrips+1; ++i) {
54  weights[i-1] = stripWeight(id, i) ;
55  }
56 }
57 
58 // Calculate weight as 1/(gain/average gain)
59 // Input is offline CSCDetId (e.g. ir=4 for ME1A), and geom strip # (e.g. 1-48 for ME1A)
60 
61 float CSCRecoConditions::stripWeight( const CSCDetId& id, int geomStrip ) const {
62  int geomChannel = theConditions.channelFromStrip( id, geomStrip );
63  float w = averageGain() / gain(id, geomChannel); // averageGain() from CSCConditions
64  // Weights are forced to lie within 0.5 and 1.5
65  if (w > 1.5) w = 1.5;
66  if (w < 0.5) w = 0.5;
67  LogTrace("CSCRecoConditions") << id << " geomStrip " << geomStrip << " stripWeight " << w;
68  return w;
69 }
70 
71 void CSCRecoConditions::noiseMatrix( const CSCDetId& id, int geomStrip, std::vector<float>& nMatrix ) const {
72 
73  // nMatrix will be filled with expanded noise matrix elements for strip 'geomStrip' and its immediate neighbours
74 
75  nMatrix.clear();
76 
77  // These are ME1/2 constants as fall-back
78  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.};
79 
80  float elem[15];
81 
82  for ( short int i = geomStrip-1; i < geomStrip+2; ++i) {
83 
84  std::vector<float> me(12);
85 
86  float w = stripWeight(id, i);
87  w = w*w;
88  int geomChannel = theConditions.channelFromStrip( id, i );
89  theConditions.noiseMatrixElements(id, geomChannel, me);
90  for ( short int j=0; j<11; ++j ) {
91  elem[j] = me[j] * w;
92  }
93  elem[11]= 0.;
94  elem[12]= me[11] * w;
95  elem[13]= 0.;
96  elem[14]= 0.;
97 
98  // Test that elements make sense:
99  bool isFlawed = false;
100  for ( short int k = 0; k < 15; ++k) {
101  if (elem[k] < 0.001) elem[k] = 0.001; // fix if too small...
102  if (elem[k] > 50.) isFlawed = true; // fail if too big...
103  }
104 
105  if ( isFlawed ) {
106  // These are fake ME1/2:
107  for ( short int m = 0; m < 15; ++m ) { elem[m] = fakeme12[m]; }
108  }
109 
110  for (int k = 0; k < 15; ++k) { nMatrix.push_back( elem[k] ); }
111  }
112 }
113 
114 void CSCRecoConditions::crossTalk( const CSCDetId& id, int geomStrip, std::vector<float>& xtalks) const {
115 
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 
140  // input nstrips is no. of strips in the layer (could get this from CSCChamberSpecs or CSCLayerGeometry
141  // but then need a CSCLayer*)
142 
143  bool bad = true; // if geomStrip out of range, call strip bad
144 
145  if ( id != theConditions.idOfBadChannelWords() ) {
146  bad = false; // if bad channel words for this id not filled, call strip good
147  return bad;
148  }
149 
150  if(geomStrip>0 && geomStrip<=nstrips){
151  bad = false; // default to good
152  int geomChan = theConditions.channelFromStrip( id, geomStrip );
153  int rawChan = theConditions.rawStripChannel( id, geomChan );
154  if( rawChan>0 && rawChan<113 ){
155  const std::bitset<112>& badStrips = theConditions.badStripWord();
156  bad = badStrips.test(rawChan-1); // 112 bits max, labelled 0-111.
157  }
158  }
159  return bad;
160 }
161 
163 const std::bitset<112>& CSCRecoConditions::badWireWord( const CSCDetId& id ) const {
164  return theConditions.badWireWord();
165 }
166 
169 }
170 
172  return theConditions.anodeBXoffset(id);
173 }
174 
175 float CSCRecoConditions::gasGainCorrection(const CSCDetId & id, int geomStrip, int wiregroup ) const {
176  int geomChannel = theConditions.channelFromStrip( id, geomStrip);
177  return theConditions.gasGainCorrection(id, geomChannel, wiregroup);
178 }
float gasGainCorrection(const CSCDetId &id, int strip, int wireGroup) const
returns gas-gain correction
int i
Definition: DBlmapReader.cc:9
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
fill vector (dim 12, must be allocated by caller) with noise matrix elements (scaled to float) ...
void fillBadChannelWords(const CSCDetId &id)
Fill bad channel words - one for strips, one for wires, for an offline CSCDetId.
CSCRecoConditions(const edm::ParameterSet &pset)
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
void crossTalk(const CSCDetId &id, int channel, std::vector< float > &ct) const
fill vector (dim 4, must be allocated by caller) with crosstalk sl, il, sr, ir
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
Definition: CSCConditions.h:94
void fillBadChannelWords(const CSCDetId &id)
fill bad strip &amp; bad wiregroup bitsets from conditions data
int rawStripChannel(const CSCDetId &id, int geomChannel) const
int j
Definition: DBlmapReader.cc:9
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
#define LogTrace(id)
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
Definition: CSCConditions.h:99
float gasGainCorrection(const CSCDetId &detId, int strip, int wire) const
gas gain correction as a function of detId (w/layer), strip, and wire channels
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
Definition: CSCConditions.h:89