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 8 of file SiStripApvShotCleaner.cc.

References clean().

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

Definition at line 16 of file SiStripApvShotCleaner.h.

16 {};

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 20 of file SiStripApvShotCleaner.h.

References end, and recoMuon::in.

Referenced by ThreeThresholdAlgorithm::clusterizeDetUnit_(), and SiStripApvShotCleaner().

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

Definition at line 16 of file SiStripApvShotCleaner.cc.

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

16  {
17  if(in.size()<64)
18  return false;
19 
20  if(loop(in)){
21  reset(scan,end);
22  return true;
23  }
24  return false;
25 }
size_type size() const
Definition: DetSet.h:63
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 86 of file SiStripApvShotCleaner.cc.

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

Referenced by loop().

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

Definition at line 23 of file SiStripApvShotCleaner.h.

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

Referenced by clean().

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

Definition at line 28 of file SiStripApvShotCleaner.cc.

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

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

Definition at line 18 of file SiStripApvShotCleaner.h.

References shots_.

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

Definition at line 152 of file SiStripApvShotCleaner.cc.

References cacheDetId, pDetSet, and vdigis.

Referenced by clean(), loop(), and subtractCM().

152  {
154  pDetSet->data.swap(vdigis);
155  a=pDetSet->begin();
156  b=pDetSet->end();
157 }
std::vector< SiStripDigi > vdigis
std::unique_ptr< edm::DetSet< SiStripDigi > > pDetSet
void SiStripApvShotCleaner::subtractCM ( )
private

Definition at line 111 of file SiStripApvShotCleaner.cc.

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

Referenced by dumpInVector(), and loop().

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

Member Data Documentation

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

Definition at line 41 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and subtractCM().

uint32_t SiStripApvShotCleaner::cacheDetId
private

Definition at line 36 of file SiStripApvShotCleaner.h.

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

unsigned short SiStripApvShotCleaner::maxNumOfApvs
private

Definition at line 43 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and loop().

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

Definition at line 42 of file SiStripApvShotCleaner.h.

Referenced by reset().

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

Definition at line 39 of file SiStripApvShotCleaner.h.

Referenced by loop().

bool SiStripApvShotCleaner::shotApv_[25]
private

Definition at line 38 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and loop().

bool SiStripApvShotCleaner::shots_
private

Definition at line 37 of file SiStripApvShotCleaner.h.

Referenced by loop(), and noShots().

unsigned short SiStripApvShotCleaner::stripsForMedian
private

Definition at line 45 of file SiStripApvShotCleaner.h.

Referenced by loop(), and subtractCM().

unsigned short SiStripApvShotCleaner::stripsPerApv
private

Definition at line 44 of file SiStripApvShotCleaner.h.

Referenced by loop().

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

Definition at line 41 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and reset().