CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
SiStripApvShotCleaner Class Reference

#include <SiStripApvShotCleaner.h>

Classes

struct  orderingByCharge
 

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

9  :
10  pDetSet(0),
11  maxNumOfApvs(6), //FED Default: 6 (i.e. max num apvs )
12  stripsPerApv(128),
13  stripsForMedian(64){}
edm::DetSet< SiStripDigi > * pDetSet
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.

Referenced by ThreeThresholdAlgorithm::clusterizeDetUnit_().

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

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

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

References apvDigis, cacheDetId, i, maxNumOfApvs, shotApv_, subtractCM(), and vdigis.

Referenced by loop().

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

Referenced by clean().

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

Definition at line 30 of file SiStripApvShotCleaner.cc.

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

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

Definition at line 18 of file SiStripApvShotCleaner.h.

References shots_.

18 {return !shots_;}
void SiStripApvShotCleaner::refresh ( )

Definition at line 162 of file SiStripApvShotCleaner.cc.

References NULL, and pDetSet.

Referenced by reset().

162  {
163  if(pDetSet!=NULL)
164  delete pDetSet;
165 }
edm::DetSet< SiStripDigi > * pDetSet
#define NULL
Definition: scimark2.h:8
void SiStripApvShotCleaner::reset ( edm::DetSet< SiStripDigi >::const_iterator &  a,
edm::DetSet< SiStripDigi >::const_iterator &  b 
)

Definition at line 153 of file SiStripApvShotCleaner.cc.

References edm::DetSet< T >::begin(), cacheDetId, edm::DetSet< T >::data, edm::DetSet< T >::end(), pDetSet, refresh(), and vdigis.

Referenced by clean().

153  {
154  refresh();
156  pDetSet->data.swap(vdigis);
157  a=pDetSet->begin();
158  b=pDetSet->end();
159 }
iterator end()
Definition: DetSet.h:60
edm::DetSet< SiStripDigi > * pDetSet
std::vector< SiStripDigi > vdigis
iterator begin()
Definition: DetSet.h:59
collection_type data
Definition: DetSet.h:78
void SiStripApvShotCleaner::subtractCM ( )
private

Definition at line 114 of file SiStripApvShotCleaner.cc.

References ecalMGPA::adc(), apvDigis, cacheDetId, i, and stripsForMedian.

Referenced by dumpInVector().

114  {
115 
116  //order by charge
117  stable_sort(apvDigis.begin(),apvDigis.end(),orderingByCharge());
118 
119  //ignore case where 64th strip is 0ADC
120  if(apvDigis[stripsForMedian].adc()==0){
121 #ifdef DEBUGME
122  std::stringstream ss;
123  ss << "case with strip64=0 --> detid= "<<cacheDetId<< "\n";
124  edm::LogInfo("ApvShot") << ss.str();
125 #endif
126  return;
127  }
128 
129  //Find the Median
130  float CM = .5*(apvDigis[stripsForMedian].adc()+apvDigis[stripsForMedian-1].adc());
131 
132 
133  if(CM<=0)
134  return;
135 
136  //Subtract the median
137  size_t i=0;
138  for(;i<stripsForMedian&&apvDigis[i].adc()>CM;++i){
139  uint16_t adc=apvDigis[i].adc()>253?apvDigis[i].adc():(uint16_t)(apvDigis[i].adc()-CM);
140  apvDigis[i]=SiStripDigi(apvDigis[i].strip(),adc);
141  }
142  apvDigis.resize(i);
143 
144 #ifdef DEBUGME
145  std::stringstream ss;
146  ss << "[subtractCM] detid " << cacheDetId << " CM is " << CM << " the remaining strips after CM subtraction are " << i;
147  edm::LogInfo("ApvShot") << ss.str();
148 #endif
149 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
std::vector< SiStripDigi > apvDigis

Member Data Documentation

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

Definition at line 46 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and subtractCM().

uint32_t SiStripApvShotCleaner::cacheDetId
private

Definition at line 41 of file SiStripApvShotCleaner.h.

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

unsigned short SiStripApvShotCleaner::maxNumOfApvs
private

Definition at line 48 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and loop().

edm::DetSet<SiStripDigi>* SiStripApvShotCleaner::pDetSet
private

Definition at line 47 of file SiStripApvShotCleaner.h.

Referenced by refresh(), and reset().

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

Definition at line 44 of file SiStripApvShotCleaner.h.

Referenced by loop().

bool SiStripApvShotCleaner::shotApv_[25]
private

Definition at line 43 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and loop().

bool SiStripApvShotCleaner::shots_
private

Definition at line 42 of file SiStripApvShotCleaner.h.

Referenced by loop(), and noShots().

unsigned short SiStripApvShotCleaner::stripsForMedian
private

Definition at line 50 of file SiStripApvShotCleaner.h.

Referenced by loop(), and subtractCM().

unsigned short SiStripApvShotCleaner::stripsPerApv
private

Definition at line 49 of file SiStripApvShotCleaner.h.

Referenced by loop().

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

Definition at line 46 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and reset().