test
CMS 3D CMS Logo

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