CMS 3D CMS Logo

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

#include <OldThreeThresholdAlgorithm.h>

Inheritance diagram for OldThreeThresholdAlgorithm:
StripClusterizerAlgorithm

Public Member Functions

float channelThresholdInNoiseSigma () const
 
void clusterizeDetUnit (const edm::DetSet< SiStripDigi > &digis, edmNew::DetSetVector< SiStripCluster >::FastFiller &output)
 
void clusterizeDetUnit (const edmNew::DetSet< SiStripDigi > &digis, edmNew::DetSetVector< SiStripCluster >::FastFiller &output)
 
float clusterThresholdInNoiseSigma () const
 
void initialize (const edm::EventSetup &)
 
float seedThresholdInNoiseSigma () const
 
void stripByStripAdd (uint16_t strip, uint16_t adc, std::vector< SiStripCluster > &out)
 
bool stripByStripBegin (uint32_t id)
 
void stripByStripEnd (std::vector< SiStripCluster > &out)
 
- Public Member Functions inherited from StripClusterizerAlgorithm
void clusterize (const edm::DetSetVector< SiStripDigi > &, output_t &)
 
void clusterize (const edmNew::DetSetVector< SiStripDigi > &, output_t &)
 
virtual void clusterizeDetUnit (const edm::DetSet< SiStripDigi > &, output_t::FastFiller &)=0
 
virtual void clusterizeDetUnit (const edmNew::DetSet< SiStripDigi > &, output_t::FastFiller &)=0
 
virtual ~StripClusterizerAlgorithm ()
 

Private Member Functions

template<typename InputDetSet >
void clusterizeDetUnit_ (const InputDetSet &digis, edmNew::DetSetVector< SiStripCluster >::FastFiller &output)
 
 OldThreeThresholdAlgorithm (float strip_thr, float seed_thr, float clust_thr, int max_holes, std::string qualityLabel, bool setDetId)
 

Private Attributes

std::vector< SiStripDigicluster_digis_
 
edm::ESHandle< SiStripGaingainHandle_
 
int max_holes_
 
edm::ESHandle< SiStripNoisesnoiseHandle_
 
edm::ESHandle< SiStripQualityqualityHandle_
 
std::string qualityLabel_
 
float theChannelThreshold
 
float theClusterThreshold
 
float theSeedThreshold
 

Friends

class StripClusterizerAlgorithmFactory
 

Additional Inherited Members

- Public Types inherited from StripClusterizerAlgorithm
typedef edmNew::DetSetVector
< SiStripCluster
output_t
 
- Protected Member Functions inherited from StripClusterizerAlgorithm
bool allBadBetween (uint16_t L, const uint16_t &R) const
 
bool bad (const uint16_t &strip) const
 
uint32_t currentId ()
 
float gain (const uint16_t &strip) const
 
bool isModuleUsable (const uint32_t &id) const
 
float noise (const uint16_t &strip) const
 
virtual void setDetId (const uint32_t)
 
 StripClusterizerAlgorithm ()
 
- Protected Attributes inherited from StripClusterizerAlgorithm
bool _setDetId
 
std::string qualityLabel
 

Detailed Description

Definition at line 28 of file OldThreeThresholdAlgorithm.h.

Constructor & Destructor Documentation

OldThreeThresholdAlgorithm::OldThreeThresholdAlgorithm ( float  strip_thr,
float  seed_thr,
float  clust_thr,
int  max_holes,
std::string  qualityLabel,
bool  setDetId 
)
inlineprivate

Member Function Documentation

float OldThreeThresholdAlgorithm::channelThresholdInNoiseSigma ( ) const
inline

Definition at line 44 of file OldThreeThresholdAlgorithm.h.

References theChannelThreshold.

Referenced by clusterizeDetUnit_().

void OldThreeThresholdAlgorithm::clusterizeDetUnit ( const edm::DetSet< SiStripDigi > &  digis,
edmNew::DetSetVector< SiStripCluster >::FastFiller &  output 
)

Definition at line 14 of file OldThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_().

14  {
15  clusterizeDetUnit_(digis,output);
16 }
void clusterizeDetUnit_(const InputDetSet &digis, edmNew::DetSetVector< SiStripCluster >::FastFiller &output)
void OldThreeThresholdAlgorithm::clusterizeDetUnit ( const edmNew::DetSet< SiStripDigi > &  digis,
edmNew::DetSetVector< SiStripCluster >::FastFiller &  output 
)

Definition at line 17 of file OldThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_().

17  {
18  clusterizeDetUnit_(digis,output);
19 }
void clusterizeDetUnit_(const InputDetSet &digis, edmNew::DetSetVector< SiStripCluster >::FastFiller &output)
template<typename InputDetSet >
void OldThreeThresholdAlgorithm::clusterizeDetUnit_ ( const InputDetSet &  digis,
edmNew::DetSetVector< SiStripCluster >::FastFiller &  output 
)
private

Definition at line 22 of file OldThreeThresholdAlgorithm.cc.

References StripClusterizerAlgorithm::_setDetId, edmNew::DetSetVector< T >::FastFiller::back(), begin, channelThresholdInNoiseSigma(), DeDxDiscriminatorTools::charge(), cluster_digis_, clusterThresholdInNoiseSigma(), end, edm::hlt::Exception, gainHandle_, edm::isDebugEnabled(), j, LogDebug, max_holes_, noiseHandle_, edmNew::DetSetVector< T >::FastFiller::push_back(), qualityHandle_, seedThresholdInNoiseSigma(), mathSSE::sqrt(), and strip().

Referenced by clusterizeDetUnit().

23  {
24 
25 #ifdef PATCH_FOR_DIGIS_DUPLICATION
26  bool printPatchError=false;
27  int countErrors=0;
28 #endif
29  const uint32_t& detID = input.detId();
30 
31  if (!qualityHandle_->IsModuleUsable(detID)){
32 #ifdef DEBUG_SiStripClusterizer_
33  LogDebug("SiStripClusterizer") << "[OldThreeThresholdAlgorithm::clusterizeDetUnit] detid " << detID << " skipped because flagged NOT Usable in SiStripQuality " << std::endl;
34 #endif
35  return;
36  }
37 
38  typename InputDetSet::const_iterator begin=input.begin();
39  typename InputDetSet::const_iterator end =input.end();
40 
41  typename InputDetSet::const_iterator ibeg, iend, ihigh, itest;
42  ibeg = iend = begin;
43  cluster_digis_.clear();
44  cluster_digis_.reserve(10);
45 
46  //output.data.reserve( (end - begin)/3 + 1); // FIXME put back in if needed
47 
48  SiStripApvGain::Range detGainRange = gainHandle_->getRange(detID);
49  SiStripNoises::Range detNoiseRange = noiseHandle_->getRange(detID);
50  SiStripQuality::Range detQualityRange = qualityHandle_->getRange(detID);
51 
52  // AboveSeed predicate(seedThresholdInNoiseSigma(),SiStripNoiseService_,detID);
53  AboveSeed predicate(seedThresholdInNoiseSigma(), noiseHandle_, detNoiseRange, qualityHandle_, detQualityRange);
54 
55 #ifdef DEBUG_SiStripClusterizer_
56  std::stringstream ss;
57 #endif
58 
59  while ( ibeg != end &&
60  (ihigh = std::find_if( ibeg, end, predicate)) != end) {
61 
62 #ifdef DEBUG_SiStripClusterizer_
64  ss << "\nSeed Channel:\n\t\t detID "<< detID << " digis " << ihigh->strip()
65  << " adc " << ihigh->adc() << " is "
66  << " channelNoise " << noiseHandle_->getNoise(ihigh->strip(),detNoiseRange)
67  << " IsBadChannel from SiStripQuality " << qualityHandle_->IsStripBad(detQualityRange,ihigh->strip());
68 #endif
69 
70  // The seed strip is ihigh. Scan up and down from it, finding nearby strips above
71  // threshold, allowing for some holes. The accepted cluster runs from strip ibeg
72  // to iend, and itest is the strip under study, not yet accepted.
73  iend = ihigh;
74  itest = iend + 1;
75  while ( itest != end && (itest->strip() - iend->strip() <= max_holes_ + 1 )) {
76  float channelNoise = noiseHandle_->getNoise(itest->strip(),detNoiseRange);
77  bool IsBadChannel = qualityHandle_->IsStripBad(detQualityRange,itest->strip());
78 
79 #ifdef DEBUG_SiStripClusterizer_
81  ss << "\nStrips on the right:\n\t\t detID " << detID << " digis " << itest->strip()
82  << " adc " << itest->adc() << " " << " channelNoise " << channelNoise
83  << " IsBadChannel from SiStripQuality " << IsBadChannel;
84 #endif
85 
86  if (!IsBadChannel && itest->adc() >= static_cast<int>( channelThresholdInNoiseSigma() * channelNoise)) {
87  iend = itest;
88  }
89  ++itest;
90  }
91  //if the next digi after iend is an adiacent bad digi then insert into candidate cluster
92  itest=iend+1;
93  if ( itest != end && (itest->strip() - iend->strip() == 1) && qualityHandle_->IsStripBad(detQualityRange,itest->strip()) ){
94 #ifdef DEBUG_SiStripClusterizer_
96  ss << "\n\t\tInserted bad strip at the end edge iend->strip()= " << iend->strip() << " itest->strip() = " << itest->strip();
97 #endif
98 
99  iend++;
100  }
101 
102  ibeg = ihigh;
103  itest = ibeg - 1;
104  while ( itest >= begin && (ibeg->strip() - itest->strip() <= max_holes_ + 1 )) {
105  float channelNoise = noiseHandle_->getNoise(itest->strip(),detNoiseRange);
106  bool IsBadChannel = qualityHandle_->IsStripBad(detQualityRange,itest->strip());
107 
108 #ifdef DEBUG_SiStripClusterizer_
109  if(edm::isDebugEnabled())
110  ss << "\nStrips on the left:\n\t\t detID " << detID << " digis " << itest->strip()
111  << " adc " << itest->adc() << " " << " channelNoise " << channelNoise
112  << " IsBadChannel from SiStripQuality " << IsBadChannel;
113 #endif
114 
115 
116  if (!IsBadChannel && itest->adc() >= static_cast<int>( channelThresholdInNoiseSigma() * channelNoise)) {
117  ibeg = itest;
118  }
119  --itest;
120  }
121  //if the next digi after ibeg is an adiacent bad digi then insert into candidate cluster
122  itest=ibeg-1;
123  if ( itest >= begin && (ibeg->strip() - itest->strip() == 1) && qualityHandle_->IsStripBad(detQualityRange,itest->strip()) ) {
124 #ifdef DEBUG_SiStripClusterizer_
125  if(edm::isDebugEnabled())
126  ss << "\nInserted bad strip at the begin edge ibeg->strip()= " << ibeg->strip() << " itest->strip() = " << itest->strip();
127 #endif
128  ibeg--;
129  }
130 
131  float charge = 0;
132  float sigmaNoise2=0;
133  //int counts=0;
134  cluster_digis_.clear();
135 #ifdef PATCH_FOR_DIGIS_DUPLICATION
136  bool isDigiListBad=false;
137  int16_t oldStrip=-1;
138 #endif
139 
140  for (itest=ibeg; itest<=iend; itest++) {
141  float channelNoise = noiseHandle_->getNoise(itest->strip(),detNoiseRange);
142  bool IsBadChannel = qualityHandle_->IsStripBad(detQualityRange,itest->strip());
143 
144 #ifdef PATCH_FOR_DIGIS_DUPLICATION
145  if(itest->strip()==oldStrip){
146  isDigiListBad=true;
147  printPatchError=true;
148  countErrors++;
149  break;
150  }
151  oldStrip=itest->strip();
152 #endif
153 
154 
155 #ifdef DEBUG_SiStripClusterizer_
156  if(edm::isDebugEnabled())
157  ss << "\nLooking at cluster digis:\n\t\t detID " << detID << " digis " << itest->strip()
158  << " adc " << itest->adc() << " channelNoise " << channelNoise
159  << " IsBadChannel from SiStripQuality " << IsBadChannel;
160 #endif
161 
162 
163  //check for consecutive digis
164  if (itest!=ibeg && itest->strip()-(itest-1)->strip()!=1){
165  //digi *(itest-1) and *itest are not consecutive: create an equivalent number of Digis with zero amp
166  for (int j=(itest-1)->strip()+1;j<itest->strip();j++){
167  cluster_digis_.push_back(SiStripDigi(j,0)); //if strip bad or under threshold set StripDigi.adc_=0
168 #ifdef DEBUG_SiStripClusterizer_
169  ss << "\n\t\tHole added: detID " << detID << " digis " << j << " adc 0 ";
170 #endif
171  }
172  }
173  if (!IsBadChannel && itest->adc() >= static_cast<int>( channelThresholdInNoiseSigma()*channelNoise)) {
174 
175  float gainFactor = gainHandle_->getStripGain(itest->strip(), detGainRange);
176 
177  // Begin of Change done by Loic Quertenmont
178  // Protection if the Charge/Gain brings the charge to be bigger
179  // than 255 (largest integer containable in uint8)
180  // Also, Gain is applied only if the strip is not saturating.
181  // Same convention as in SimTracker/SiStripDigitizer/src/SiTrivialDigitalConverter.cc
182 
183  float stripCharge=(static_cast<float>(itest->adc()));
184 
185  // //dummy DEBUGG
186  // float stripCharge;
187  // for (uint16_t myadc=0; myadc<=255; myadc++){
188 
189  // stripCharge=(static_cast<float>(myadc));
190 
191  // gainFactor=0.73;
192  // //ENDDEBUGG
193 
194  //correct for gain only non-truncated channel charge. Throw exception if channel charge exceeding 255 ADC counts is found
195 
196  if(stripCharge<254){
197  stripCharge /= gainFactor;
198 
199  if(stripCharge>511.5){stripCharge=255;}
200  else if(stripCharge>253.5){stripCharge=254;}
201  }
202  else if(stripCharge>255){
203  throw cms::Exception("LogicError") << "Cluster charge (" << stripCharge << ") out of range. This clustering algorithm should only work with input charges lower than or equal to 255 ADC counts";
204 
205  }
206 
207  // //dummy DEBUGG
208  // std::vector<SiStripDigi> b; b.push_back(SiStripDigi(itest->strip(), static_cast<uint8_t>(stripCharge+0.5)));;
209  // SiStripCluster c( detID, SiStripCluster::SiStripDigiRange( b.begin(),b.end()));
210  // edm::LogInfo("MYTEST") << "myadc="<<myadc<<" stripCharge="<<stripCharge<<" stored charge="<< (unsigned int)(c.amplitudes()[0])<< std::endl;
211  // edm::LogInfo("MYTEST") << "myadc="<< (unsigned int)(static_cast<uint8_t>(255.5));
212  // }
213  // //ENDDEBUGG
214 
215  // End of Change done by Loic Quertenmont
216 
217 
218 
219  charge += stripCharge;
220  sigmaNoise2 += channelNoise*channelNoise/(gainFactor*gainFactor);
221 
222  cluster_digis_.push_back(SiStripDigi(itest->strip(), static_cast<uint8_t>(stripCharge+0.5)));
223  } else {
224  cluster_digis_.push_back(SiStripDigi(itest->strip(),0)); //if strip bad or under threshold set SiStripDigi.adc_=0
225 
226 #ifdef DEBUG_SiStripClusterizer_
227  if(edm::isDebugEnabled())
228  ss << "\n\t\tBad or under threshold digis: detID " << detID << " digis " << itest->strip()
229  << " adc " << itest->adc() << " channelNoise " << channelNoise
230  << " IsBadChannel from SiStripQuality " << IsBadChannel;
231 #endif
232  }
233  }
234  float sigmaNoise = sqrt(sigmaNoise2);
235 
236 #ifdef PATCH_FOR_DIGIS_DUPLICATION
237  if (charge >= clusterThresholdInNoiseSigma()*sigmaNoise && !isDigiListBad) {
238 #else
239  if (charge >= clusterThresholdInNoiseSigma()*sigmaNoise ) {
240 #endif
241 
242 #ifdef DEBUG_SiStripClusterizer_
243  if(edm::isDebugEnabled())
244  ss << "\n\t\tCluster accepted :)";
245 #endif
247  cluster_digis_.end())));
248  if (_setDetId) output.back().setId( detID);
249  } else {
250 #ifdef DEBUG_SiStripClusterizer_
251  if(edm::isDebugEnabled())
252  ss << "\n\t\tCluster rejected :(";
253 #endif
254  }
255  ibeg = iend+1;
256  }
257 
258 #ifdef PATCH_FOR_DIGIS_DUPLICATION
259  if(printPatchError)
260  edm::LogError("SiStripClusterizer") << "[OldThreeThresholdAlgorithm::clusterizeDetUnit] \n There are errors in " << countErrors << " clusters due to not unique digis ";
261 #endif
262 
263 #ifdef DEBUG_SiStripClusterizer_
264  LogDebug("SiStripClusterizer") << "[OldThreeThresholdAlgorithm::clusterizeDetUnit] \n" << ss.str();
265 #endif
266  }
#define LogDebug(id)
bool isDebugEnabled()
void push_back(data_type const &d)
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
double charge(const std::vector< uint8_t > &Ampls)
edm::ESHandle< SiStripGain > gainHandle_
std::vector< SiStripDigi > cluster_digis_
edm::ESHandle< SiStripNoises > noiseHandle_
T sqrt(T t)
Definition: SSEVec.h:46
std::pair< ContainerIterator, ContainerIterator > Range
int j
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:38
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
edm::ESHandle< SiStripQuality > qualityHandle_
#define begin
Definition: vmac.h:31
std::pair< ContainerIterator, ContainerIterator > Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:41
float OldThreeThresholdAlgorithm::clusterThresholdInNoiseSigma ( ) const
inline

Definition at line 46 of file OldThreeThresholdAlgorithm.h.

References theClusterThreshold.

Referenced by clusterizeDetUnit_().

void OldThreeThresholdAlgorithm::initialize ( const edm::EventSetup es)
virtual
float OldThreeThresholdAlgorithm::seedThresholdInNoiseSigma ( ) const
inline

Definition at line 45 of file OldThreeThresholdAlgorithm.h.

References theSeedThreshold.

Referenced by clusterizeDetUnit_().

void OldThreeThresholdAlgorithm::stripByStripAdd ( uint16_t  strip,
uint16_t  adc,
std::vector< SiStripCluster > &  out 
)
inlinevirtual

Implements StripClusterizerAlgorithm.

Definition at line 41 of file OldThreeThresholdAlgorithm.h.

41 {}
bool OldThreeThresholdAlgorithm::stripByStripBegin ( uint32_t  id)
inlinevirtual

Implements StripClusterizerAlgorithm.

Definition at line 40 of file OldThreeThresholdAlgorithm.h.

40 {return false;}
void OldThreeThresholdAlgorithm::stripByStripEnd ( std::vector< SiStripCluster > &  out)
inlinevirtual

Implements StripClusterizerAlgorithm.

Definition at line 42 of file OldThreeThresholdAlgorithm.h.

42 {}

Friends And Related Function Documentation

friend class StripClusterizerAlgorithmFactory
friend

Definition at line 30 of file OldThreeThresholdAlgorithm.h.

Member Data Documentation

std::vector<SiStripDigi> OldThreeThresholdAlgorithm::cluster_digis_
private

Definition at line 72 of file OldThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_().

edm::ESHandle<SiStripGain> OldThreeThresholdAlgorithm::gainHandle_
private

Definition at line 68 of file OldThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_(), and initialize().

int OldThreeThresholdAlgorithm::max_holes_
private

Definition at line 65 of file OldThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_().

edm::ESHandle<SiStripNoises> OldThreeThresholdAlgorithm::noiseHandle_
private

Definition at line 69 of file OldThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_(), and initialize().

edm::ESHandle<SiStripQuality> OldThreeThresholdAlgorithm::qualityHandle_
private

Definition at line 70 of file OldThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_(), and initialize().

std::string OldThreeThresholdAlgorithm::qualityLabel_
private

Definition at line 66 of file OldThreeThresholdAlgorithm.h.

Referenced by initialize().

float OldThreeThresholdAlgorithm::theChannelThreshold
private

Definition at line 62 of file OldThreeThresholdAlgorithm.h.

Referenced by channelThresholdInNoiseSigma().

float OldThreeThresholdAlgorithm::theClusterThreshold
private

Definition at line 64 of file OldThreeThresholdAlgorithm.h.

Referenced by clusterThresholdInNoiseSigma().

float OldThreeThresholdAlgorithm::theSeedThreshold
private

Definition at line 63 of file OldThreeThresholdAlgorithm.h.

Referenced by seedThresholdInNoiseSigma().