5 #define PATCH_FOR_DIGIS_DUPLICATION
21 template<
typename InputDetSet>
25 #ifdef PATCH_FOR_DIGIS_DUPLICATION
26 bool printPatchError=
false;
29 const uint32_t& detID = input.detId();
32 #ifdef DEBUG_SiStripClusterizer_
33 LogDebug(
"SiStripClusterizer") <<
"[OldThreeThresholdAlgorithm::clusterizeDetUnit] detid " << detID <<
" skipped because flagged NOT Usable in SiStripQuality " << std::endl;
38 typename InputDetSet::const_iterator
begin=input.begin();
39 typename InputDetSet::const_iterator
end =input.end();
41 typename InputDetSet::const_iterator ibeg, iend, ihigh, itest;
55 #ifdef DEBUG_SiStripClusterizer_
59 while ( ibeg != end &&
60 (ihigh = std::find_if( ibeg, end, predicate)) != end) {
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());
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());
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;
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();
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());
108 #ifdef DEBUG_SiStripClusterizer_
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;
123 if ( itest >= begin && (ibeg->strip() - itest->strip() == 1) &&
qualityHandle_->IsStripBad(detQualityRange,itest->strip()) ) {
124 #ifdef DEBUG_SiStripClusterizer_
126 ss <<
"\nInserted bad strip at the begin edge ibeg->strip()= " << ibeg->strip() <<
" itest->strip() = " << itest->strip();
135 #ifdef PATCH_FOR_DIGIS_DUPLICATION
136 bool isDigiListBad=
false;
140 for (itest=ibeg; itest<=iend; itest++) {
141 float channelNoise =
noiseHandle_->getNoise(itest->strip(),detNoiseRange);
142 bool IsBadChannel =
qualityHandle_->IsStripBad(detQualityRange,itest->strip());
144 #ifdef PATCH_FOR_DIGIS_DUPLICATION
145 if(itest->strip()==oldStrip){
147 printPatchError=
true;
151 oldStrip=itest->strip();
155 #ifdef DEBUG_SiStripClusterizer_
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;
164 if (itest!=ibeg && itest->strip()-(itest-1)->strip()!=1){
166 for (
int j=(itest-1)->strip()+1;
j<itest->strip();
j++){
168 #ifdef DEBUG_SiStripClusterizer_
169 ss <<
"\n\t\tHole added: detID " << detID <<
" digis " <<
j <<
" adc 0 ";
175 float gainFactor =
gainHandle_->getStripGain(itest->strip(), detGainRange);
183 float stripCharge=(
static_cast<float>(itest->adc()));
197 stripCharge /= gainFactor;
199 if(stripCharge>511.5){stripCharge=255;}
200 else if(stripCharge>253.5){stripCharge=254;}
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";
219 charge += stripCharge;
220 sigmaNoise2 += channelNoise*channelNoise/(gainFactor*gainFactor);
226 #ifdef DEBUG_SiStripClusterizer_
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;
234 float sigmaNoise =
sqrt(sigmaNoise2);
236 #ifdef PATCH_FOR_DIGIS_DUPLICATION
242 #ifdef DEBUG_SiStripClusterizer_
244 ss <<
"\n\t\tCluster accepted :)";
250 #ifdef DEBUG_SiStripClusterizer_
252 ss <<
"\n\t\tCluster rejected :(";
258 #ifdef PATCH_FOR_DIGIS_DUPLICATION
260 edm::LogError(
"SiStripClusterizer") <<
"[OldThreeThresholdAlgorithm::clusterizeDetUnit] \n There are errors in " << countErrors <<
" clusters due to not unique digis ";
263 #ifdef DEBUG_SiStripClusterizer_
264 LogDebug(
"SiStripClusterizer") <<
"[OldThreeThresholdAlgorithm::clusterizeDetUnit] \n" << ss.str();
void push_back(data_type const &d)
float seedThresholdInNoiseSigma() const
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
void initialize(const edm::EventSetup &)
void clusterizeDetUnit_(const InputDetSet &digis, edmNew::DetSetVector< SiStripCluster >::FastFiller &output)
std::string qualityLabel_
edm::ESHandle< SiStripGain > gainHandle_
static std::string const input
std::vector< SiStripDigi > cluster_digis_
edm::ESHandle< SiStripNoises > noiseHandle_
std::pair< ContainerIterator, ContainerIterator > Range
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
edm::ESHandle< SiStripQuality > qualityHandle_
float channelThresholdInNoiseSigma() const
void clusterizeDetUnit(const edm::DetSet< SiStripDigi > &digis, edmNew::DetSetVector< SiStripCluster >::FastFiller &output)
std::pair< ContainerIterator, ContainerIterator > Range
float clusterThresholdInNoiseSigma() const
std::pair< ContainerIterator, ContainerIterator > Range