CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripApvShotCleaner Class Reference

#include <SiStripApvShotCleaner.h>

Public Member Functions

bool clean (const edmNew::DetSet< SiStripDigi > &in, edmNew::DetSet< SiStripDigi >::const_iterator &scan, edmNew::DetSet< SiStripDigi >::const_iterator &end)
 
bool clean (const edm::DetSet< SiStripDigi > &in, edm::DetSet< SiStripDigi >::const_iterator &scan, edm::DetSet< SiStripDigi >::const_iterator &end)
 
bool loop (const edmNew::DetSet< SiStripDigi > &in)
 
bool loop (const edm::DetSet< SiStripDigi > &in)
 
bool noShots ()
 
void reset (edm::DetSet< SiStripDigi >::const_iterator &a, edm::DetSet< SiStripDigi >::const_iterator &b)
 
 SiStripApvShotCleaner ()
 
 ~SiStripApvShotCleaner ()
 

Private Member Functions

void dumpInVector (edm::DetSet< SiStripDigi >::const_iterator *, size_t)
 
void subtractCM ()
 

Private Attributes

std::vector< SiStripDigiapvDigis
 
uint32_t cacheDetId
 
unsigned short maxNumOfApvs
 
std::unique_ptr< edm::DetSet< SiStripDigi > > pDetSet
 
edm::DetSet< SiStripDigi >::const_iterator pFirstDigiOfApv [7]
 
bool shotApv_ [25]
 
bool shots_
 
unsigned short stripsForMedian
 
unsigned short stripsPerApv
 
std::vector< SiStripDigivdigis
 

Detailed Description

Definition at line 11 of file SiStripApvShotCleaner.h.

Constructor & Destructor Documentation

SiStripApvShotCleaner::SiStripApvShotCleaner ( )

Definition at line 7 of file SiStripApvShotCleaner.cc.

8  : maxNumOfApvs(6), //FED Default: 6 (i.e. max num apvs )
9  stripsPerApv(128),
10  stripsForMedian(64) {}
SiStripApvShotCleaner::~SiStripApvShotCleaner ( )
inline

Definition at line 15 of file SiStripApvShotCleaner.h.

15 {};

Member Function Documentation

bool SiStripApvShotCleaner::clean ( const edmNew::DetSet< SiStripDigi > &  in,
edmNew::DetSet< SiStripDigi >::const_iterator &  scan,
edmNew::DetSet< SiStripDigi >::const_iterator &  end 
)
inline

Definition at line 19 of file SiStripApvShotCleaner.h.

References end, and recoMuon::in.

Referenced by ThreeThresholdAlgorithm::clusterizeDetUnit_().

21  {
22  return false;
23  } //FIXME
bool SiStripApvShotCleaner::clean ( const edm::DetSet< SiStripDigi > &  in,
edm::DetSet< SiStripDigi >::const_iterator &  scan,
edm::DetSet< SiStripDigi >::const_iterator &  end 
)

Definition at line 12 of file SiStripApvShotCleaner.cc.

References loop(), reset(), and edm::DetSet< T >::size().

14  {
15  if (in.size() < 64)
16  return false;
17 
18  if (loop(in)) {
19  reset(scan, end);
20  return true;
21  }
22  return false;
23 }
size_type size() const
Definition: DetSet.h:62
void reset(edm::DetSet< SiStripDigi >::const_iterator &a, edm::DetSet< SiStripDigi >::const_iterator &b)
bool loop(const edmNew::DetSet< SiStripDigi > &in)
void SiStripApvShotCleaner::dumpInVector ( edm::DetSet< SiStripDigi >::const_iterator *  pFirstDigiOfApv,
size_t  maxNumOfApvs 
)
private

Definition at line 82 of file SiStripApvShotCleaner.cc.

References apvDigis, cacheDetId, mps_fire::i, maxNumOfApvs, shotApv_, contentValuesCheck::ss, digitizers_cfi::strip, subtractCM(), and vdigis.

Referenced by loop().

83  {
84  vdigis.clear();
85  //loop on Apvs and remove shots. if an apv doesn't have shots, copy it
86  for (size_t i = 0; i < maxNumOfApvs; ++i) {
87  apvDigis.clear();
88 
89  if (shotApv_[i]) {
90  apvDigis.insert(apvDigis.end(), pFirstDigiOfApv[i], pFirstDigiOfApv[i + 1]);
91  subtractCM();
92  std::stable_sort(apvDigis.begin(), apvDigis.end());
93  vdigis.insert(vdigis.end(), apvDigis.begin(), apvDigis.end());
94  } else {
95  vdigis.insert(vdigis.end(), pFirstDigiOfApv[i], pFirstDigiOfApv[i + 1]);
96  }
97  }
98 
99 #ifdef DEBUGME
100  std::stringstream ss;
101  ss << "detid " << cacheDetId << " new digi.size " << vdigis.size() << "\n";
102  for (size_t i = 0; i < vdigis.size(); ++i)
103  ss << "\t " << i << " strip " << vdigis[i].strip() << " adc " << vdigis[i].adc();
104  edm::LogInfo("ApvShot") << ss.str() << std::endl;
105 #endif
106 }
std::vector< SiStripDigi > vdigis
std::vector< SiStripDigi > apvDigis
bool SiStripApvShotCleaner::loop ( const edmNew::DetSet< SiStripDigi > &  in)
inline

Definition at line 28 of file SiStripApvShotCleaner.h.

References a, b, dumpInVector(), reset(), and subtractCM().

Referenced by clean().

28 { return false; } //FIXME
bool SiStripApvShotCleaner::loop ( const edm::DetSet< SiStripDigi > &  in)

Definition at line 25 of file SiStripApvShotCleaner.cc.

References edm::DetSet< T >::begin(), cacheDetId, ztail::d, edm::DetSet< T >::detId(), dumpInVector(), edm::DetSet< T >::end(), mps_fire::i, maxNumOfApvs, pFirstDigiOfApv, shotApv_, shots_, edm::DetSet< T >::size(), contentValuesCheck::ss, stripsForMedian, stripsPerApv, and heppy_batch::val.

25  {
26 #ifdef DEBUGME
27  std::stringstream ss;
28  ss << __func__ << " working on detid " << in.detId() << " for a digi.size=" << in.size();
29 #endif
30 
31  shots_ = false;
32  for (auto& val : shotApv_)
33  val = false;
34 
35  cacheDetId = in.detId();
36 
37  //Find the position in the DetSet where the first strip of an apv should be inserted
38  // needed to deduce if at least stripsForMedian strips per apv have been fired
39  for (size_t i = 0; i <= maxNumOfApvs; ++i) {
40  SiStripDigi d(i * stripsPerApv, 0); //Fake digi, at the edge of the apv
41  pFirstDigiOfApv[i] = std::lower_bound(in.begin(), in.end(), d);
42 
43  //if satisfied it means that the number of digis in the apv i-1 is above stripsForMedia -> apvShot
44  if (i > 0 && pFirstDigiOfApv[i] - pFirstDigiOfApv[i - 1] > stripsForMedian) {
45  shots_ = true;
46  shotApv_[i - 1] = true;
47 #ifdef DEBUGME
48  ss << " found an apv shot of " << pFirstDigiOfApv[i] - pFirstDigiOfApv[i - 1] << " digis in detid " << in.detId()
49  << " apv " << i << std::endl;
50 #endif
51  }
52 
53  //---------------------
54  //Just for debug REMOVE
55  /*
56  if(i>0){
57  ss << "detid " << in.detId() << " apv " << i-1 << " number digis " << pFirstDigiOfApv[i]-pFirstDigiOfApv[i-1] << " \t shot " << shotApv_[i-1] << std::endl;
58  if(pFirstDigiOfApv[i]-pFirstDigiOfApv[i-1]>stripsForMedian-2){
59  edm::DetSet<SiStripDigi>::const_iterator dig=pFirstDigiOfApv[i-1];
60  while(dig!=pFirstDigiOfApv[i]){
61  ss << "\t strip " << dig->strip() << " dig.adc " << dig->adc();
62  dig++;
63  }
64  ss << std::endl;
65  }
66  }
67  */
68  //-------------------------------
69  }
70 
71 #ifdef DEBUGME
72  edm::LogInfo("ApvShot") << ss.str();
73 #endif
74 
75  if (!shots_)
76  return false;
77 
79  return true;
80 }
iterator end()
Definition: DetSet.h:59
edm::DetSet< SiStripDigi >::const_iterator pFirstDigiOfApv[7]
void dumpInVector(edm::DetSet< SiStripDigi >::const_iterator *, size_t)
det_id_type detId() const
Definition: DetSet.h:75
size_type size() const
Definition: DetSet.h:62
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
d
Definition: ztail.py:151
iterator begin()
Definition: DetSet.h:58
bool SiStripApvShotCleaner::noShots ( )
inline

Definition at line 17 of file SiStripApvShotCleaner.h.

References shots_.

17 { return !shots_; }
void SiStripApvShotCleaner::reset ( edm::DetSet< SiStripDigi >::const_iterator &  a,
edm::DetSet< SiStripDigi >::const_iterator &  b 
)

Definition at line 147 of file SiStripApvShotCleaner.cc.

References cacheDetId, pDetSet, and vdigis.

Referenced by clean(), and loop().

148  {
150  pDetSet->data.swap(vdigis);
151  a = pDetSet->begin();
152  b = pDetSet->end();
153 }
std::vector< SiStripDigi > vdigis
std::unique_ptr< edm::DetSet< SiStripDigi > > pDetSet
void SiStripApvShotCleaner::subtractCM ( )
private

Definition at line 108 of file SiStripApvShotCleaner.cc.

References a, ecalMGPA::adc(), SiStripDigi::adc(), apvDigis, b, cacheDetId, mps_fire::i, contentValuesCheck::ss, digitizers_cfi::strip, and stripsForMedian.

Referenced by dumpInVector(), and loop().

108  {
109  //order by charge
110  std::stable_sort(
111  apvDigis.begin(), apvDigis.end(), [](SiStripDigi const& a, SiStripDigi const& b) { return a.adc() > b.adc(); });
112 
113  //ignore case where 64th strip is 0ADC
114  if (apvDigis[stripsForMedian].adc() == 0) {
115 #ifdef DEBUGME
116  std::stringstream ss;
117  ss << "case with strip64=0 --> detid= " << cacheDetId << "\n";
118  edm::LogInfo("ApvShot") << ss.str();
119 #endif
120  return;
121  }
122 
123  //Find the Median
124  float CM = 0.5f * (apvDigis[stripsForMedian].adc() + apvDigis[stripsForMedian - 1].adc());
125 
126  if (CM <= 0)
127  return;
128 
129  //Subtract the median
130  const bool is10bit = apvDigis[0].adc() > 255; // approximation; definitely 10bit in this case
131  size_t i = 0;
132  for (; i < stripsForMedian && apvDigis[i].adc() > CM; ++i) {
133  const uint16_t adc =
134  ((apvDigis[i].adc() > 253) && !is10bit) ? apvDigis[i].adc() : (uint16_t)(apvDigis[i].adc() - CM);
135  apvDigis[i] = SiStripDigi(apvDigis[i].strip(), adc);
136  }
137  apvDigis.resize(i);
138 
139 #ifdef DEBUGME
140  std::stringstream ss;
141  ss << "[subtractCM] detid " << cacheDetId << " CM is " << CM << " the remaining strips after CM subtraction are "
142  << i;
143  edm::LogInfo("ApvShot") << ss.str();
144 #endif
145 }
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
double b
Definition: hdecay.h:118
std::vector< SiStripDigi > apvDigis
double a
Definition: hdecay.h:119
const uint16_t & adc() const
Definition: SiStripDigi.h:34

Member Data Documentation

std::vector<SiStripDigi> SiStripApvShotCleaner::apvDigis
private

Definition at line 44 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and subtractCM().

uint32_t SiStripApvShotCleaner::cacheDetId
private

Definition at line 39 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), loop(), reset(), and subtractCM().

unsigned short SiStripApvShotCleaner::maxNumOfApvs
private

Definition at line 46 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and loop().

std::unique_ptr<edm::DetSet<SiStripDigi> > SiStripApvShotCleaner::pDetSet
private

Definition at line 45 of file SiStripApvShotCleaner.h.

Referenced by reset().

edm::DetSet<SiStripDigi>::const_iterator SiStripApvShotCleaner::pFirstDigiOfApv[7]
private

Definition at line 42 of file SiStripApvShotCleaner.h.

Referenced by loop().

bool SiStripApvShotCleaner::shotApv_[25]
private

Definition at line 41 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and loop().

bool SiStripApvShotCleaner::shots_
private

Definition at line 40 of file SiStripApvShotCleaner.h.

Referenced by loop(), and noShots().

unsigned short SiStripApvShotCleaner::stripsForMedian
private

Definition at line 48 of file SiStripApvShotCleaner.h.

Referenced by loop(), and subtractCM().

unsigned short SiStripApvShotCleaner::stripsPerApv
private

Definition at line 47 of file SiStripApvShotCleaner.h.

Referenced by loop().

std::vector<SiStripDigi> SiStripApvShotCleaner::vdigis
private

Definition at line 44 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and reset().