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;
APVShot::isGenuine
const bool isGenuine() const
Definition: APVShot.cc:47
APVShot.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
APVShot::computeShot
void computeShot(const std::vector< SiStripDigi > &digis, const DetId &detid, const bool zs=true)
Definition: APVShot.cc:16
APVShot::APVShot
APVShot()
Definition: APVShot.cc:7
APVShot::subDet
const int subDet() const
Definition: APVShot.cc:55
APVShot::_nstrips
int _nstrips
Definition: APVShot.h:27
APVShot::_apv
int _apv
Definition: APVShot.h:26
groupFilesInBlocks.reverse
reverse
Definition: groupFilesInBlocks.py:131
APVShot::_detid
DetId _detid
Definition: APVShot.h:29
DetId
Definition: DetId.h:17
APVShot::_threshold
const static int _threshold
Definition: APVShot.h:31
APVShot::_median
float _median
Definition: APVShot.h:28
SiStripDigi.h
APVShot::apvNumber
const int apvNumber() const
Definition: APVShot.cc:49
APVShot::median
const float median() const
Definition: APVShot.cc:53
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
APVShot::_zs
bool _zs
Definition: APVShot.h:25
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
funct::true
true
Definition: Factorize.h:173
APVShot::nStrips
const int nStrips() const
Definition: APVShot.cc:51
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
APVShot::detId
const unsigned int detId() const
Definition: APVShot.cc:57
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Exception
Definition: hltDiff.cc:245
Exception.h