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::SiStripApvShotCleaner ( )

Definition at line 8 of file SiStripApvShotCleaner.cc.

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

◆ ~SiStripApvShotCleaner()

SiStripApvShotCleaner::~SiStripApvShotCleaner ( )
inline

Definition at line 15 of file SiStripApvShotCleaner.h.

15 {}

Member Function Documentation

◆ clean() [1/2]

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.

Referenced by ThreeThresholdAlgorithm::clusterizeDetUnit_().

21  {
22  return false;
23  } //FIXME

◆ clean() [2/2]

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

Definition at line 13 of file SiStripApvShotCleaner.cc.

References mps_fire::end, recoMuon::in, loop(), and reset().

15  {
16  if (in.size() < 64)
17  return false;
18 
19  if (loop(in)) {
20  reset(scan, end);
21  return true;
22  }
23  return false;
24 }
void reset(edm::DetSet< SiStripDigi >::const_iterator &a, edm::DetSet< SiStripDigi >::const_iterator &b)
bool loop(const edmNew::DetSet< SiStripDigi > &in)

◆ dumpInVector()

void SiStripApvShotCleaner::dumpInVector ( edm::DetSet< SiStripDigi >::const_iterator *  pFirstDigiOfApv,
size_t  maxNumOfApvs 
)
private

Definition at line 83 of file SiStripApvShotCleaner.cc.

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

Referenced by loop().

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

◆ loop() [1/2]

bool SiStripApvShotCleaner::loop ( const edmNew::DetSet< SiStripDigi > &  in)
inline

Definition at line 28 of file SiStripApvShotCleaner.h.

Referenced by clean().

28 { return false; } //FIXME

◆ loop() [2/2]

bool SiStripApvShotCleaner::loop ( const edm::DetSet< SiStripDigi > &  in)

Definition at line 26 of file SiStripApvShotCleaner.cc.

References cacheDetId, ztail::d, dumpInVector(), mps_fire::i, recoMuon::in, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, maxNumOfApvs, pFirstDigiOfApv, shotApv_, shots_, contentValuesCheck::ss, stripsForMedian, stripsPerApv, and heppy_batch::val.

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

◆ noShots()

bool SiStripApvShotCleaner::noShots ( )
inline

Definition at line 17 of file SiStripApvShotCleaner.h.

References shots_.

17 { return !shots_; }

◆ reset()

void SiStripApvShotCleaner::reset ( edm::DetSet< SiStripDigi >::const_iterator &  a,
edm::DetSet< SiStripDigi >::const_iterator &  b 
)

Definition at line 148 of file SiStripApvShotCleaner.cc.

References a, b, cacheDetId, pDetSet, and vdigis.

Referenced by clean().

149  {
150  pDetSet = std::make_unique<edm::DetSet<SiStripDigi>>(cacheDetId);
151  pDetSet->data.swap(vdigis);
152  a = pDetSet->begin();
153  b = pDetSet->end();
154 }
std::vector< SiStripDigi > vdigis
std::unique_ptr< edm::DetSet< SiStripDigi > > pDetSet
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ subtractCM()

void SiStripApvShotCleaner::subtractCM ( )
private

Definition at line 109 of file SiStripApvShotCleaner.cc.

References a, gpuClustering::adc, apvDigis, b, cacheDetId, mps_fire::i, contentValuesCheck::ss, nano_mu_digi_cff::strip, and stripsForMedian.

Referenced by dumpInVector().

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

Member Data Documentation

◆ apvDigis

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

Definition at line 44 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and subtractCM().

◆ cacheDetId

uint32_t SiStripApvShotCleaner::cacheDetId
private

Definition at line 39 of file SiStripApvShotCleaner.h.

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

◆ maxNumOfApvs

unsigned short SiStripApvShotCleaner::maxNumOfApvs
private

Definition at line 46 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and loop().

◆ pDetSet

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

Definition at line 45 of file SiStripApvShotCleaner.h.

Referenced by reset().

◆ pFirstDigiOfApv

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

Definition at line 42 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and loop().

◆ shotApv_

bool SiStripApvShotCleaner::shotApv_[25]
private

Definition at line 41 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and loop().

◆ shots_

bool SiStripApvShotCleaner::shots_
private

Definition at line 40 of file SiStripApvShotCleaner.h.

Referenced by loop(), and noShots().

◆ stripsForMedian

unsigned short SiStripApvShotCleaner::stripsForMedian
private

Definition at line 48 of file SiStripApvShotCleaner.h.

Referenced by loop(), and subtractCM().

◆ stripsPerApv

unsigned short SiStripApvShotCleaner::stripsPerApv
private

Definition at line 47 of file SiStripApvShotCleaner.h.

Referenced by loop().

◆ vdigis

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

Definition at line 44 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and reset().