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 edm::DetSet< SiStripDigi > &in, edm::DetSet< SiStripDigi >::const_iterator &scan, edm::DetSet< SiStripDigi >::const_iterator &end)
 
bool clean (const edmNew::DetSet< SiStripDigi > &in, edmNew::DetSet< SiStripDigi >::const_iterator &scan, edmNew::DetSet< SiStripDigi >::const_iterator &end)
 
bool loop (const edm::DetSet< SiStripDigi > &in)
 
bool loop (const edmNew::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 7 of file SiStripApvShotCleaner.cc.

8  : maxNumOfApvs(6), //FED Default: 6 (i.e. max num apvs )
9  stripsPerApv(128),
10  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 edm::DetSet< SiStripDigi > &  in,
edm::DetSet< SiStripDigi >::const_iterator &  scan,
edm::DetSet< SiStripDigi >::const_iterator &  end 
)

Definition at line 12 of file SiStripApvShotCleaner.cc.

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 }

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

◆ clean() [2/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.

21  {
22  return false;
23  } //FIXME

Referenced by ThreeThresholdAlgorithm::clusterizeDetUnit_().

◆ dumpInVector()

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

Definition at line 82 of file SiStripApvShotCleaner.cc.

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 }

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

Referenced by loop().

◆ loop() [1/2]

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

Definition at line 25 of file SiStripApvShotCleaner.cc.

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 }

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

◆ loop() [2/2]

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

Definition at line 28 of file SiStripApvShotCleaner.h.

28 { return false; } //FIXME

Referenced by clean().

◆ noShots()

bool SiStripApvShotCleaner::noShots ( )
inline

Definition at line 17 of file SiStripApvShotCleaner.h.

17 { return !shots_; }

References shots_.

◆ reset()

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

Definition at line 147 of file SiStripApvShotCleaner.cc.

148  {
150  pDetSet->data.swap(vdigis);
151  a = pDetSet->begin();
152  b = pDetSet->end();
153 }

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

Referenced by clean().

◆ subtractCM()

void SiStripApvShotCleaner::subtractCM ( )
private

Definition at line 108 of file SiStripApvShotCleaner.cc.

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);
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 }

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

Referenced by dumpInVector().

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().

ecalMGPA::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:11
SiStripApvShotCleaner::dumpInVector
void dumpInVector(edm::DetSet< SiStripDigi >::const_iterator *, size_t)
Definition: SiStripApvShotCleaner.cc:82
mps_fire.i
i
Definition: mps_fire.py:355
edm::DetSet< SiStripDigi >
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
SiStripApvShotCleaner::stripsPerApv
unsigned short stripsPerApv
Definition: SiStripApvShotCleaner.h:47
edm::LogInfo
Definition: MessageLogger.h:254
SiStripApvShotCleaner::apvDigis
std::vector< SiStripDigi > apvDigis
Definition: SiStripApvShotCleaner.h:44
SiStripApvShotCleaner::reset
void reset(edm::DetSet< SiStripDigi >::const_iterator &a, edm::DetSet< SiStripDigi >::const_iterator &b)
Definition: SiStripApvShotCleaner.cc:147
SiStripApvShotCleaner::maxNumOfApvs
unsigned short maxNumOfApvs
Definition: SiStripApvShotCleaner.h:46
end
#define end
Definition: vmac.h:39
SiStripApvShotCleaner::subtractCM
void subtractCM()
Definition: SiStripApvShotCleaner.cc:108
SiStripApvShotCleaner::vdigis
std::vector< SiStripDigi > vdigis
Definition: SiStripApvShotCleaner.h:44
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SiStripApvShotCleaner::pFirstDigiOfApv
edm::DetSet< SiStripDigi >::const_iterator pFirstDigiOfApv[7]
Definition: SiStripApvShotCleaner.h:42
SiStripApvShotCleaner::pDetSet
std::unique_ptr< edm::DetSet< SiStripDigi > > pDetSet
Definition: SiStripApvShotCleaner.h:45
b
double b
Definition: hdecay.h:118
SiStripApvShotCleaner::stripsForMedian
unsigned short stripsForMedian
Definition: SiStripApvShotCleaner.h:48
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
SiStripApvShotCleaner::shotApv_
bool shotApv_[25]
Definition: SiStripApvShotCleaner.h:41
a
double a
Definition: hdecay.h:119
SiStripApvShotCleaner::shots_
bool shots_
Definition: SiStripApvShotCleaner.h:40
recoMuon::in
Definition: RecoMuonEnumerators.h:6
SiStripApvShotCleaner::loop
bool loop(const edmNew::DetSet< SiStripDigi > &in)
Definition: SiStripApvShotCleaner.h:28
heppy_batch.val
val
Definition: heppy_batch.py:351
SiStripApvShotCleaner::cacheDetId
uint32_t cacheDetId
Definition: SiStripApvShotCleaner.h:39
ztail.d
d
Definition: ztail.py:151
SiStripDigi
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12