CMS 3D CMS Logo

APVShot.cc
Go to the documentation of this file.
1 #include <vector>
5 #include <algorithm>
6 
7 APVShot::APVShot() : _zs(true), _apv(-1), _nstrips(0), _median(-1), _detid() {}
8 
9 APVShot::APVShot(const bool zs) : _zs(zs), _apv(-1), _nstrips(0), _median(-1), _detid() {}
10 
11 APVShot::APVShot(const std::vector<SiStripDigi>& digis, const DetId& detid, const bool zs)
12  : _zs(zs), _apv(-1), _nstrips(0), _median(-1), _detid() {
13  computeShot(digis, detid, zs);
14 }
15 
16 void APVShot::computeShot(const std::vector<SiStripDigi>& digis, const DetId& detid, const bool zs) {
17  _zs = zs;
18  _detid = detid;
19 
20  _nstrips = 0;
21  _apv = -1;
22  _median = -1;
23 
24  std::vector<unsigned int> charge;
25  for (std::vector<SiStripDigi>::const_iterator digi = digis.begin(); digi != digis.end(); ++digi) {
26  if (!_zs || digi->adc() > 0) {
27  int oldapv = _apv;
28  _apv = digi->strip() / 128;
29  if (oldapv >= 0 && oldapv != _apv)
30  throw cms::Exception("WrongDigiVector") << "Digis from Different APVs";
31 
32  charge.push_back(digi->adc());
33  ++_nstrips;
34  }
35  }
36 
37  // charge to be sorted in descending order
38 
39  std::sort(charge.begin(), charge.end());
40  std::reverse(charge.begin(), charge.end());
41 
42  if (charge.size() > 64) {
43  _median = float(charge[64]);
44  }
45 }
46 
47 const bool APVShot::isGenuine() const { return (_nstrips > _threshold); }
48 
49 const int APVShot::apvNumber() const { return _apv; }
50 
51 const int APVShot::nStrips() const { return _nstrips; }
52 
53 const float APVShot::median() const { return _median; }
54 
55 const int APVShot::subDet() const { return _detid.subdetId(); }
56 
57 const unsigned int APVShot::detId() const { return _detid.rawId(); }
58 
59 const int APVShot::_threshold = 64;
static const int _threshold
Definition: APVShot.h:31
DetId _detid
Definition: APVShot.h:29
float _median
Definition: APVShot.h:28
const int subDet() const
Definition: APVShot.cc:55
bool _zs
Definition: APVShot.h:25
void computeShot(const std::vector< SiStripDigi > &digis, const DetId &detid, const bool zs=true)
Definition: APVShot.cc:16
const bool isGenuine() const
Definition: APVShot.cc:47
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
int _apv
Definition: APVShot.h:26
const int apvNumber() const
Definition: APVShot.cc:49
APVShot()
Definition: APVShot.cc:7
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const unsigned int detId() const
Definition: APVShot.cc:57
const float median() const
Definition: APVShot.cc:53
const int nStrips() const
Definition: APVShot.cc:51
int _nstrips
Definition: APVShot.h:27