CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripClusterInfo.cc
Go to the documentation of this file.
2 
9 #include <cmath>
10 
11 
12 
14  const edm::EventSetup& setup,
15  const int detId,
16  const std::string & quality)
17  : cluster_ptr(&cluster),
18  es(setup),
19  qualityLabel(quality),
20  detId_(detId) {
24 }
25 
26 std::pair<uint16_t,uint16_t > SiStripClusterInfo::
27 chargeLR() const {
28  std::vector<uint8_t>::const_iterator
29  begin( stripCharges().begin() ),
30  end( stripCharges().end() ),
31  max; max = max_element(begin,end);
32  return std::make_pair( accumulate(begin, max, uint16_t(0) ),
33  accumulate(max+1, end, uint16_t(0) ) );
34 }
35 
36 
38 variance() const {
39  float q(0), x1(0), x2(0);
40  for(std::vector<uint8_t>::const_iterator
41  begin(stripCharges().begin()), end(stripCharges().end()), it(begin);
42  it!=end; ++it) {
43  unsigned i = it-begin;
44  q += (*it);
45  x1 += (*it) * (i+0.5);
46  x2 += (*it) * (i*i+i+1./3);
47  }
48  return (x2 - x1*x1/q ) / q;
49 }
50 
51 std::vector<float> SiStripClusterInfo::
53  SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detId_);
54  SiStripApvGain::Range detGainRange = gainHandle->getRange(detId_);
55 
56  std::vector<float> results;
57  results.reserve(width());
58  for(size_t i = 0, e = width(); i < e; i++){
59  results.push_back(noiseHandle->getNoise(firstStrip()+i, detNoiseRange) / gainHandle->getStripGain( firstStrip()+i, detGainRange));
60  }
61  return results;
62 }
63 
64 std::vector<float> SiStripClusterInfo::
65 stripNoises() const {
66  SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detId_);
67 
68  std::vector<float> noises;
69  noises.reserve(width());
70  for(size_t i=0; i < width(); i++){
71  noises.push_back( noiseHandle->getNoise( firstStrip()+i, detNoiseRange) );
72  }
73  return noises;
74 }
75 
76 std::vector<float> SiStripClusterInfo::
77 stripGains() const {
78  SiStripApvGain::Range detGainRange = gainHandle->getRange(detId_);
79 
80  std::vector<float> gains;
81  gains.reserve(width());
82  for(size_t i=0; i< width(); i++){
83  gains.push_back( gainHandle->getStripGain( firstStrip()+i, detGainRange) );
84  }
85  return gains;
86 }
87 
88 std::vector<bool> SiStripClusterInfo::
90  std::vector<bool> isBad;
91  isBad.reserve(width());
92  for(int i=0; i< width(); i++) {
93  isBad.push_back( qualityHandle->IsStripBad( detId_,
94  firstStrip()+i) );
95  }
96  return isBad;
97 }
98 
100 calculate_noise(const std::vector<float>& noise) const {
101  float noiseSumInQuadrature = 0;
102  int numberStripsOverThreshold = 0;
103  for(int i=0;i<width();i++) {
104  if(stripCharges().at(i)!=0) {
105  noiseSumInQuadrature += noise.at(i) * noise.at(i);
106  numberStripsOverThreshold++;
107  }
108  }
109  return std::sqrt( noiseSumInQuadrature / numberStripsOverThreshold );
110 }
111 
112 
114 IsAnythingBad() const {
115  std::vector<bool> stripBad = stripQualitiesBad();
116  return
117  IsApvBad() ||
118  IsFiberBad() ||
119  IsModuleBad() ||
120  accumulate(stripBad.begin(), stripBad.end(),
121  false,
122  std::logical_or<bool>());
123 }
124 
126 IsApvBad() const {
127  return
128  qualityHandle->IsApvBad( detId_, firstStrip()/128 ) ||
129  qualityHandle->IsApvBad( detId_, (firstStrip()+width())/128 ) ;
130 }
131 
133 IsFiberBad() const {
134  return
135  qualityHandle->IsFiberBad( detId_, firstStrip()/256 ) ||
136  qualityHandle->IsFiberBad( detId_, (firstStrip()+width())/256 ) ;
137 }
138 
140 IsModuleBad() const {
141  return qualityHandle->IsModuleBad( detId_ );
142 }
143 
145 IsModuleUsable() const {
146  return qualityHandle->IsModuleUsable( detId_ );
147 }
148 
149 std::vector<SiStripCluster> SiStripClusterInfo::
151 
152  std::vector<SiStripCluster> clusters;
153 
154  std::vector<uint8_t> charges = stripCharges();
155  std::vector<float> gains = stripGains();
156  for(unsigned i=0; i < charges.size(); i++)
157  charges[i] = (charges[i] < 254)
158  ? static_cast<uint8_t>(charges[i] * gains[i])
159  : charges[i];
160 
161  std::auto_ptr<StripClusterizerAlgorithm>
163  algorithm->initialize(es);
164 
165  if( algorithm->stripByStripBegin( detId_ )) {
166  for(unsigned i = 0; i<width(); i++)
167  algorithm->stripByStripAdd( firstStrip()+i, charges[i], clusters );
168  algorithm->stripByStripEnd( clusters );
169  }
170 
171  return clusters;
172 }
173 
int i
Definition: DBlmapReader.cc:9
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
edm::ESHandle< SiStripGain > gainHandle
uint16_t firstStrip() const
edm::ESHandle< SiStripQuality > qualityHandle
SiStripClusterInfo(const SiStripCluster &cluster, const edm::EventSetup &es, const int detid, const std::string &qualityLabel="")
std::vector< float > stripGains() const
bool IsAnythingBad() const
std::pair< uint16_t, uint16_t > chargeLR() const
std::vector< bool > stripQualitiesBad() const
float variance() const
float calculate_noise(const std::vector< float > &) const
const T & max(const T &a, const T &b)
static std::auto_ptr< StripClusterizerAlgorithm > create(const edm::ParameterSet &)
T sqrt(T t)
Definition: SSEVec.h:48
uint16_t width() const
std::pair< ContainerIterator, ContainerIterator > Range
#define end
Definition: vmac.h:37
tuple conf
Definition: dbtoconf.py:185
const T & get() const
Definition: EventSetup.h:55
const edm::EventSetup & es
const std::vector< uint8_t > & stripCharges() const
bool IsModuleUsable() const
edm::ESHandle< SiStripNoises > noiseHandle
#define begin
Definition: vmac.h:30
std::vector< float > stripNoises() const
std::vector< SiStripCluster > reclusterize(const edm::ParameterSet &) const
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:48
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
std::vector< float > stripNoisesRescaledByGain() const