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

References clean().

9  :
10  maxNumOfApvs(6), //FED Default: 6 (i.e. max num apvs )
11  stripsPerApv(128),
12  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 17 of file SiStripApvShotCleaner.cc.

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

17  {
18  if(in.size()<64)
19  return false;
20 
21  if(loop(in)){
22  reset(scan,end);
23  return true;
24  }
25  return false;
26 }
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 87 of file SiStripApvShotCleaner.cc.

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

Referenced by loop().

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

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

112  {
113 
114  //order by charge
115  std::stable_sort(apvDigis.begin(),apvDigis.end(),
116  [](SiStripDigi const& a, SiStripDigi const& b) {return a.adc() > b.adc();});
117 
118  //ignore case where 64th strip is 0ADC
119  if(apvDigis[stripsForMedian].adc()==0){
120 #ifdef DEBUGME
121  std::stringstream ss;
122  ss << "case with strip64=0 --> detid= "<<cacheDetId<< "\n";
123  edm::LogInfo("ApvShot") << ss.str();
124 #endif
125  return;
126  }
127 
128  //Find the Median
129  float CM = 0.5f*(apvDigis[stripsForMedian].adc()+apvDigis[stripsForMedian-1].adc());
130 
131 
132  if(CM<=0)
133  return;
134 
135  //Subtract the median
136  size_t i=0;
137  for(;i<stripsForMedian&&apvDigis[i].adc()>CM;++i){
138  uint16_t adc=apvDigis[i].adc()>253?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 }
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:41

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