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 
18 
19 float CSCRecoConditions::pedestal(const CSCDetId& id, int geomChannel) const {
20  LogTrace("CSCRecoConditions") << id << " geomChannel " << geomChannel << " pedestal " << 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 " << theConditions.gain(id, geomChannel);
30  return theConditions.gain(id, geomChannel);
31 }
32 
34 
35 float CSCRecoConditions::chipCorrection(const CSCDetId & id, int geomStrip) const {
36  // geometric strip to geometric channel (e.g. ME1a, 1-48->1-16 ganged or 1-48 unganged)
37  int geomChannel = theConditions.channelFromStrip( id, geomStrip );
38  return theConditions.chipCorrection(id, geomChannel);
39 }
40 
41 // stripWeights is required in CSCHitFromStripOnly.
42 // - Has nstrips in arg list because caller already has this value from CSCChamberSpecs.
43 // - We only have gains per geometric channel of course, and we only apply them by channel too
44 // (in CSCHitFromStripOnly), but we may as well fill values for each strip.
45 
46 void CSCRecoConditions::stripWeights( const CSCDetId& id, short int nstrips, float* weights ) const {
47 
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) w = 1.5;
61  if (w < 0.5) w = 0.5;
62  LogTrace("CSCRecoConditions") << id << " geomStrip " << geomStrip << " stripWeight " << w;
63  return w;
64 }
65 
66 void CSCRecoConditions::noiseMatrix( const CSCDetId& id, int geomStrip, std::vector<float>& nMatrix ) const {
67 
68  // nMatrix will be filled with expanded noise matrix elements for strip 'geomStrip' and its immediate neighbours
69 
70  nMatrix.clear();
71 
72  // These are ME1/2 constants as fall-back
73  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.};
74 
75  float elem[15];
76 
77  for ( short int i = geomStrip-1; i < geomStrip+2; ++i) {
78 
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) elem[k] = 0.001; // fix if too small...
97  if (elem[k] > 50.) isFlawed = true; // fail if too big...
98  }
99 
100  if ( isFlawed ) {
101  // These are fake ME1/2:
102  for ( short int m = 0; m < 15; ++m ) { elem[m] = fakeme12[m]; }
103  }
104 
105  for (int k = 0; k < 15; ++k) { nMatrix.push_back( elem[k] ); }
106  }
107 }
108 
109 void CSCRecoConditions::crossTalk( const CSCDetId& id, int geomStrip, std::vector<float>& xtalks) const {
110 
111  // xtalks will be filled with crosstalk for geomStrip and its immediate neighbours
112 
113  xtalks.clear();
114 
115  for ( short int i = geomStrip-1; i < geomStrip+2; ++i) {
116  int geomChannel = theConditions.channelFromStrip( id, i );
117  std::vector<float> ct(4);
118  theConditions.crossTalk(id, geomChannel, ct);
119  xtalks.push_back(ct[0]);
120  xtalks.push_back(ct[1]);
121  xtalks.push_back(ct[2]);
122  xtalks.push_back(ct[3]);
123  }
124 }
125 
127 bool CSCRecoConditions::nearBadStrip( const CSCDetId& id, int geomStrip ) const {
128  bool nearBad = (badStrip(id,geomStrip-1) || badStrip(id,geomStrip+1));
129  return nearBad;
130 }
131 
133 bool CSCRecoConditions::badStrip( const CSCDetId& id, int geomStrip ) const {
134  //@@ NOT YET UPDATED FOR UNGANGED ME11A
135 
136  bool aBadS = false;
137  if(geomStrip>0 && geomStrip<81){
138  int geomChan = theConditions.channelFromStrip( id, geomStrip );
139  const std::bitset<80>& badStrips = theConditions.badStripWord(id);
140 
141  int rawChan = theConditions.rawStripChannel( id, geomChan );
142  if( rawChan>0 && rawChan<81 ){
143  aBadS = badStrips.test(rawChan-1); // 80 bits max, labelled 0-79.
144 
145  }
146  }
147  return aBadS;
148 }
149 
151 const std::bitset<112>& CSCRecoConditions::badWireWord( const CSCDetId& id ) const {
152  return theConditions.badWireWord( id );
153 }
154 
157 }
158 
160  return theConditions.anodeBXoffset(id);
161 }
162 
163 float CSCRecoConditions::gasGainCorrection(const CSCDetId & id, int geomStrip, int wiregroup ) const {
164  int geomChannel = theConditions.channelFromStrip( id, geomStrip);
165  return theConditions.gasGainCorrection(id, geomChannel, wiregroup);
166 }
float gasGainCorrection(const CSCDetId &id, int strip, int wireGroup) const
returns gas-gain correction
const std::bitset< 80 > & badStripWord(const CSCDetId &id) const
bad channel words per CSCLayer - 1 bit per channel
int i
Definition: DBlmapReader.cc:9
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) ...
CSCRecoConditions(const edm::ParameterSet &pset)
void noiseMatrix(const CSCDetId &id, int centralStrip, std::vector< float > &nme) const
bool nearBadStrip(const CSCDetId &id, int geomStrip) const
Is a neighbour bad?
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
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
float gain(const CSCDetId &id, int geomStrip) const
channels and geomstrips count from 1
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
bool badStrip(const CSCDetId &id, int geomStrip) const
Is the strip bad?
CSCConditions theConditions
void initializeEvent(const edm::EventSetup &es)
fetch database content via EventSetup
const std::bitset< 112 > & badWireWord(const CSCDetId &id) const
#define LogTrace(id)
float stripWeight(const CSCDetId &id, int geomStrip) const
return gain weight for given strip channel
int k[5][pyjets_maxn]
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) ...
float gasGainCorrection(const CSCDetId &detId, int strip, int wire) const
gas gain correction as a function of detId (w/layer), strip, and wire channels
T w() 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.