13 const std::vector<short>& badChannels)
const
24 if (badChannels.size() < linearCutoff) {
25 return (
std::find( badChannels.begin(), badChannels.end(), channel) != badChannels.end());
27 else return std::binary_search( badChannels.begin(), badChannels.end(), channel);
51 std::vector<HDigiFP420> cluster_digis;
53 cluster_digis.reserve(15);
55 std::vector<ClusterFP420> rhits; rhits.reserve( (end - begin)/3 + 1);
57 AboveSeed predicate(seedThresholdInNoiseSigma(),vnoise);
60 int vnoisesize = vnoise.size();
62 if (vnoisesize<=itest->channel())
64 std::cout <<
"WARNING for detid " << detid <<
" there will be a request for noise for channel seed" << itest->channel() <<
" but this detid has vnoise.size= " << vnoise.size() <<
"\nskip"<< std::endl;
70 while ( ibeg != end && (ihigh = find_if( ibeg, end, predicate)) != end) {
78 while ( itest != end && (itest->channel() - iend->channel() <= max_voids_ + 1 )) {
79 float channelNoise = vnoise[itest->channel()].getNoise();
80 bool IsBadChannel = vnoise[itest->channel()].getDisable();
81 if (!IsBadChannel && itest->adc() >=
static_cast<int>( channelThresholdInNoiseSigma() * channelNoise)) {
88 if ( itest != end && (itest->channel() - iend->channel() == 1) && vnoise[itest->channel()].getDisable() ) {
89 std::cout <<
"Inserted bad electrode at the end edge iend->channel()= " << iend->channel() <<
" itest->channel() = " << itest->channel() << std::endl;
95 while ( itest >= begin && (ibeg->channel() - itest->channel() <= max_voids_ + 1 )) {
96 float channelNoise = vnoise[itest->channel()].getNoise();
97 bool IsBadChannel = vnoise[itest->channel()].getDisable();
98 if (!IsBadChannel && itest->adc() >=
static_cast<int>( channelThresholdInNoiseSigma() * channelNoise)) {
105 if ( itest >= begin && (ibeg->channel() - itest->channel() == 1) && vnoise[itest->channel()].getDisable() ) {
106 std::cout <<
"Inserted bad electrode at the begin edge ibeg->channel()= " << ibeg->channel() <<
" itest->channel() = " << itest->channel() << std::endl;
112 cluster_digis.clear();
113 for (i=ibeg; i<=iend; ++
i) {
114 float channelNoise = vnoise[i->channel()].getNoise();
115 bool IsBadChannel = vnoise[i->channel()].getDisable();
117 if (i!=ibeg && i->channel()-(i-1)->channel()!=1){
119 for (
int j=(i-1)->channel()+1;
j<i->channel();++
j){
127 if (!IsBadChannel && i->adc() >=
static_cast<int>( channelThresholdInNoiseSigma()*channelNoise)) {
129 sigmaNoise2 += channelNoise*channelNoise;
130 cluster_digis.push_back(*i);
132 cluster_digis.push_back(
HDigiFP420(i->channel(),0));
136 float sigmaNoise =
sqrt(sigmaNoise2);
140 unsigned int xytype=2;
141 if (charge >= static_cast<int>( clusterThresholdInNoiseSigma()*sigmaNoise)) {
143 cluster_digis.end()),
156 d = ichannel->stripV() - jchannel->stripV();
159 else if(xytype == 1) {
160 d = ichannel->stripH() - jchannel->stripH();
164 std::cout <<
"difNarr: wrong xytype = " << xytype << std::endl;
172 d = ichannel->stripVW() - jchannel->stripVW();
175 else if(xytype == 1) {
176 d = ichannel->stripHW() - jchannel->stripHW();
180 std::cout <<
"difWide: wrong xytype = " << xytype << std::endl;
195 std::vector<HDigiFP420> cluster_digis;
198 cluster_digis.reserve(25);
201 std::vector<ClusterFP420> rhits; rhits.reserve( (end - begin)/3 + 1);
204 AboveSeed predicate(seedThresholdInNoiseSigma(),vnoise);
218 int vnoisesize = vnoise.size();
219 if (vnoisesize<=itest->channel())
230 while ( ibeg != end && (ihigh = find_if( ibeg, end, predicate)) != end) {
241 while ( itest != end && (difNarr(xytype,itest,iend)<= max_voids_ + 1 ) && (difWide(xytype,itest,iend)<= 1) ) {
242 float channelNoise = vnoise[itest->channel()].getNoise();
243 bool IsBadChannel = vnoise[itest->channel()].getDisable();
244 if (!IsBadChannel && itest->adc() >=
static_cast<int>( channelThresholdInNoiseSigma() * channelNoise)) {
247 std::cout <<
"=========================================================================== " << std::endl;
248 std::cout <<
"Right side: itest->adc()= " << itest->adc() <<
" channel_noise = " <<
static_cast<int>( channelThresholdInNoiseSigma() * channelNoise) << std::endl;
255 if ( itest != end && (difNarr(xytype,itest,iend) == 1) && (difWide(xytype,itest,iend)< 1) && vnoise[itest->channel()].getDisable() ) {
257 std::cout <<
"Inserted bad electrode at the end edge iend->channel()= " << iend->channel() <<
" itest->channel() = " << itest->channel() << std::endl;
262 std::cout <<
"Result of going to right side iend->channel()= " << iend->channel() <<
" itest->channel() = " << itest->channel() << std::endl;
269 while ( itest >= begin && (difNarr(xytype,ibeg,itest) <= max_voids_ + 1 ) && (difWide(xytype,ibeg,itest) <= 1) ) {
270 float channelNoise = vnoise[itest->channel()].getNoise();
271 bool IsBadChannel = vnoise[itest->channel()].getDisable();
272 if (!IsBadChannel && itest->adc() >=
static_cast<int>( channelThresholdInNoiseSigma() * channelNoise)) {
275 std::cout <<
"Left side: itest->adc()= " << itest->adc() <<
" channel_noise = " <<
static_cast<int>( channelThresholdInNoiseSigma() * channelNoise) << std::endl;
282 if ( itest >= begin && (difNarr(xytype,ibeg,itest) == 1) && (difWide(xytype,ibeg,itest) < 1) && vnoise[itest->channel()].getDisable() ) {
284 std::cout <<
"Inserted bad electrode at the begin edge ibeg->channel()= " << ibeg->channel() <<
" itest->channel() = " << itest->channel() << std::endl;
289 std::cout <<
"Result of going to left side ibeg->channel()= " << ibeg->channel() <<
" itest->channel() = " << itest->channel() << std::endl;
300 cluster_digis.clear();
303 std::cout <<
"check for consecutive digis ibeg->channel()= " << ibeg->channel() <<
" iend->channel() = " << iend->channel() << std::endl;
305 for (i=ibeg; i<=iend; ++
i) {
306 float channelNoise = vnoise[i->channel()].getNoise();
307 bool IsBadChannel = vnoise[i->channel()].getDisable();
309 std::cout <<
"Looking at cluster digis: detid " << detid <<
" digis " << i->channel()
310 <<
" adc " << i->adc() <<
" channelNoise " << channelNoise <<
" IsBadChannel " << IsBadChannel << std::endl;
317 std::cout <<
"difNarr(xytype,i,i-1) = " << difNarr(xytype,i,i-1) << std::endl;
318 std::cout <<
"difWide(xytype,i,i-1) = " << difWide(xytype,i,i-1) << std::endl;
322 if (i!=ibeg && (difNarr(xytype,i,i-1) > 1 && difWide(xytype,i,i-1) > 1) ){
324 for (
int j=(i-1)->channel()+1;
j<i->channel();++
j){
326 std::cout <<
"not consecutive digis: set HDigiFP420.adc_=0 : j = " <<
j << std::endl;
333 if (!IsBadChannel && i->adc() >=
static_cast<int>( channelThresholdInNoiseSigma()*channelNoise)) {
335 sigmaNoise2 += channelNoise*channelNoise;
336 cluster_digis.push_back(*i);
338 std::cout <<
"put into cluster_digis good i info: i->channel() = " << i->channel() << std::endl;
341 cluster_digis.push_back(
HDigiFP420(i->channel(),0));
343 std::cout <<
"else if electrode bad or under threshold set HDigiFP420.adc_=0: i->channel() = " << i->channel() << std::endl;
352 float sigmaNoise =
sqrt(sigmaNoise2);
355 if (charge >= static_cast<int>( clusterThresholdInNoiseSigma()*sigmaNoise)) {
357 cluster_digis.end()),
360 std::cout <<
"Looking at cog and err : cog " << cog <<
" err " << err << std::endl;
361 std::cout <<
"=========================================================================== " << std::endl;
std::vector< ClusterNoiseFP420::ElectrodData > ElectrodNoiseVector
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::pair< HDigiFP420Iter, HDigiFP420Iter > HDigiFP420Range
std::vector< HDigiFP420 >::const_iterator HDigiFP420Iter
std::vector< ClusterFP420 > clusterizeDetUnit(HDigiFP420Iter begin, HDigiFP420Iter end, unsigned int detid, const ElectrodNoiseVector &vnoise)
bool badChannel(int channel, const std::vector< short > &badChannels) const
int difNarr(unsigned int xytype, HDigiFP420Iter ichannel, HDigiFP420Iter jchannel)
std::vector< ClusterFP420 > clusterizeDetUnitPixels(HDigiFP420Iter begin, HDigiFP420Iter end, unsigned int detid, const ElectrodNoiseVector &vnoise, unsigned int xytype, int verb)
int difWide(unsigned int xytype, HDigiFP420Iter ichannel, HDigiFP420Iter jchannel)