diff --git a/[refs] b/[refs] index 0a86194f8e9b2..72e7ca4dd4fa2 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/l1tmuon-upgrade-dev: 690a4df87fff6b3e45f825c46105474860e3ae0a +refs/heads/l1tmuon-upgrade-dev: 3025dc9f548c470b6514e04c52acd892d82691a6 diff --git a/trunk/RecoLocalTracker/SiStripClusterizer/interface/ThreeThresholdStripClusterizer.h b/trunk/RecoLocalTracker/SiStripClusterizer/interface/ThreeThresholdStripClusterizer.h deleted file mode 100644 index aba84169b5633..0000000000000 --- a/trunk/RecoLocalTracker/SiStripClusterizer/interface/ThreeThresholdStripClusterizer.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef RECOLOCALTRACKER_SISTRIPCLUSTERIZER_THREETHRESHOLDSTRIPCLUSTERIZER_H -#define RECOLOCALTRACKER_SISTRIPCLUSTERIZER_THREETHRESHOLDSTRIPCLUSTERIZER_H - -#include "FWCore/Framework/interface/EventSetup.h" -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/Common/interface/DetSetVectorNew.h" -#include "DataFormats/SiStripDigi/interface/SiStripDigi.h" -#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" - -#include -#include - -class ThreeThresholdStripClusterizer { - - public: - - ThreeThresholdStripClusterizer(float channel, float seed,float cluster, int holes, int bad=0, int adj=1); - ~ThreeThresholdStripClusterizer(); - void init(const edm::EventSetup& es, std::string qualityLabel=""); - - typedef edmNew::DetSetVector::FastFiller output_t; - void clusterizeDetUnit(const edm::DetSet&, output_t&); - void clusterizeDetUnit(const edmNew::DetSet&, output_t&); - - struct InvalidChargeException : public cms::Exception { public: InvalidChargeException(const SiStripDigi&); }; - - - private: - - template void clusterizeDetUnit_(const T &, output_t&); - - //state of the candidate cluster - std::vector ADCs; - uint16_t lastStrip; - float noiseSquared; - bool candidateHasSeed; - - //constant methods with state information - uint16_t firstStrip() const {return lastStrip - ADCs.size() + 1;} - bool candidateEnded(uint16_t) const; - bool candidateAccepted() const; - - //state modification methods - void clearCandidate() { candidateHasSeed = false; noiseSquared = 0; ADCs.clear();} - void addToCandidate(const SiStripDigi&); - void appendBadNeighborsToCandidate(); - class applyGain; //functor - - class ESinfo; ESinfo* info; - -}; - - - -class ThreeThresholdStripClusterizer::applyGain { - public: - uint16_t operator()(uint16_t); - applyGain(const ESinfo* es, uint16_t firststrip) : info(es), strip(firststrip) {} - private: - const ESinfo* info; - uint16_t strip; -}; - - - - -#include "FWCore/Framework/interface/ESHandle.h" -#include "CalibFormats/SiStripObjects/interface/SiStripGain.h" -#include "CondFormats/SiStripObjects/interface/SiStripNoises.h" -#include "CalibFormats/SiStripObjects/interface/SiStripQuality.h" - -class ThreeThresholdStripClusterizer::ESinfo { - - public: - - ESinfo(float chan, float seed, float clust, uint8_t holes, uint8_t bad, uint8_t adj) : - ChannelThreshold(chan), SeedThreshold(seed), ClusterThresholdSquared(clust*clust), - MaxSequentialHoles(holes), MaxSequentialBad(bad), MaxAdjacentBad(adj), - noise_cache_id(0), gain_cache_id(0), quality_cache_id(0) - {} - const float ChannelThreshold, SeedThreshold, ClusterThresholdSquared; - const uint8_t MaxSequentialHoles, MaxSequentialBad, MaxAdjacentBad; - - float noise(const uint16_t strip) const {return noiseHandle->getNoise(strip,noiseRange);} - float gain(const uint16_t strip) const {return gainHandle->getStripGain(strip,gainRange);} - bool bad(const uint16_t strip) const {return qualityHandle->IsStripBad(qualityRange, strip);} - bool allBadBetween(uint16_t a,uint16_t b) const {while(++aIsModuleUsable(id);} - - void setDetId(uint32_t); - SiStripApvGain::Range gainRange; - SiStripNoises::Range noiseRange; - SiStripQuality::Range qualityRange; - edm::ESHandle gainHandle; - edm::ESHandle noiseHandle; - edm::ESHandle qualityHandle; - uint32_t noise_cache_id, gain_cache_id, quality_cache_id; - -}; - -#endif diff --git a/trunk/RecoLocalTracker/SiStripClusterizer/src/SiStripClusterizerAlgorithm.cc b/trunk/RecoLocalTracker/SiStripClusterizer/src/SiStripClusterizerAlgorithm.cc deleted file mode 100644 index 2cca5d37bfdf0..0000000000000 --- a/trunk/RecoLocalTracker/SiStripClusterizer/src/SiStripClusterizerAlgorithm.cc +++ /dev/null @@ -1,71 +0,0 @@ -// File: SiStripClusterizerAlgorithm.cc -// Description: An algorithm for CMS track reconstruction. -// Author: O/ Gutsche -// Creation Date: OGU Aug. 1, 2005 - -#include "RecoLocalTracker/SiStripClusterizer/interface/SiStripClusterizerAlgorithm.h" - -//using namespace std; - -SiStripClusterizerAlgorithm::SiStripClusterizerAlgorithm(const edm::ParameterSet& conf) : - conf_(conf), - clusterMode_(conf.getParameter("ClusterMode")){ - - edm::LogInfo("SiStripClusterizer") << "[SiStripClusterizerAlgorithm::SiStripClusterizerAlgorithm] Constructing object..."; - edm::LogInfo("SiStripClusterizer") << "[SiStripClusterizerAlgorithm::SiStripClusterizerAlgorithm] ClusterizingMode: " << clusterMode_; - - if ( clusterMode_ == "ThreeThresholdClusterizer" ) { - ThreeThresholdStripClusterizer_ = new ThreeThresholdStripClusterizer(conf_.getParameter("ChannelThreshold"), - conf_.getParameter("SeedThreshold"), - conf_.getParameter("ClusterThreshold"), - conf_.getParameter("MaxHolesInCluster")); - validClusterizer_ = true; - } else { - edm::LogError("SiStripClusterizer") << "[SiStripClusterizerAlgorithm] No valid strip clusterizer selected, possible clusterizer: ThreeThresholdClusterizer" << std::endl; - throw edm::Exception(edm::errors::Configuration) << "[SiStripClusterizerAlgorithm] No valid strip clusterizer selected, possible clusterizer: ThreeThresholdClusterizer"; - validClusterizer_ = false; - } -} - -SiStripClusterizerAlgorithm::~SiStripClusterizerAlgorithm() { - if ( ThreeThresholdStripClusterizer_ != 0 ) { - delete ThreeThresholdStripClusterizer_; - } -} - -// void SiStripClusterizerAlgorithm::configure( SiStripNoiseService* in) { - -// ThreeThresholdStripClusterizer_->setSiStripNoiseService(in); -// } - - -void SiStripClusterizerAlgorithm::run(const edm::DetSetVector& input, edmNew::DetSetVector & output,const edm::EventSetup& es){ - - if ( validClusterizer_ ) { - int number_detunits = 0; - int number_localstriprechits = 0; - - ThreeThresholdStripClusterizer_->init(es, conf_.getParameter("SiStripQualityLabel")); - - //loop on all detset inside the input collection - edm::DetSetVector::const_iterator DSViter=input.begin(); - for (; DSViter!=input.end();DSViter++) { - ++number_detunits; -#ifdef DEBUG_SiStripClusterizer_ - LogDebug("SiStripClusterizer") << "[SiStripClusterizerAlgorithm::run] DetID " << DSViter->id; -#endif - if (DSViter->empty()) continue; - - edmNew::DetSetVector::FastFiller ssc(output, DSViter->id); - - ThreeThresholdStripClusterizer_->clusterizeDetUnit(*DSViter,ssc); - - number_localstriprechits += ssc.size(); - - if (ssc.empty()) ssc.abort(); // insert the DetSet in the DetSetVec only if there is at least a digi - //if (ssc.data.size()) - // output.push_back(ssc); // insert the DetSet in the DetSetVec only if there is at least a digi - } - edm::LogInfo("SiStripClusterizer") << "[SiStripClusterizerAlgorithm] execution in mode " << clusterMode_ << " generating " << number_localstriprechits << " SiStripClusters in " << number_detunits << " DetUnits."; - } -} diff --git a/trunk/RecoLocalTracker/SiStripClusterizer/src/ThreeThresholdStripClusterizer.cc b/trunk/RecoLocalTracker/SiStripClusterizer/src/ThreeThresholdStripClusterizer.cc deleted file mode 100644 index 41e68a2c88557..0000000000000 --- a/trunk/RecoLocalTracker/SiStripClusterizer/src/ThreeThresholdStripClusterizer.cc +++ /dev/null @@ -1,151 +0,0 @@ -#include "RecoLocalTracker/SiStripClusterizer/interface/ThreeThresholdStripClusterizer.h" - -#include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h" -#include "CalibTracker/Records/interface/SiStripGainRcd.h" -#include "CalibTracker/Records/interface/SiStripQualityRcd.h" - -#include -#include -#include -#include - -ThreeThresholdStripClusterizer:: -ThreeThresholdStripClusterizer(float strip_thr, float seed_thr,float clust_thr, int max_holes, int max_bad, int max_adj) : - info(new ESinfo(strip_thr,seed_thr,clust_thr,max_holes,max_bad,max_adj)) { - ADCs.reserve(128); //largest possible cluster (2APV * 64 adjacent strips per APV) -} - - -ThreeThresholdStripClusterizer:: -~ThreeThresholdStripClusterizer() { - delete info; -} - - -void ThreeThresholdStripClusterizer:: -init(const edm::EventSetup& es, std::string qualityLabel) { - uint32_t n_cache_id = es.get().cacheIdentifier(); - uint32_t g_cache_id = es.get().cacheIdentifier(); - uint32_t q_cache_id = es.get().cacheIdentifier(); - - if(n_cache_id != info->noise_cache_id) { - es.get().get(info->noiseHandle); - info->noise_cache_id = n_cache_id; - } - if(g_cache_id != info->gain_cache_id) { - es.get().get(info->gainHandle); - info->gain_cache_id = g_cache_id; - } - if(q_cache_id != info->quality_cache_id) { - es.get().get(qualityLabel,info->qualityHandle); - info->quality_cache_id = q_cache_id; - } -} - -inline -void ThreeThresholdStripClusterizer:: -ESinfo::setDetId(uint32_t id) { - gainRange = gainHandle->getRange(id); - noiseRange = noiseHandle->getRange(id); - qualityRange = qualityHandle->getRange(id); -} - - -template -inline -void ThreeThresholdStripClusterizer:: -clusterizeDetUnit_(const digiDetSet & digis, output_t& output) { - if( !info->isModuleUsable( digis.detId() )) return; - info->setDetId( digis.detId() ); - - typename digiDetSet::const_iterator scan(digis.begin()), end(digis.end()); - while( scan != end ) { - clearCandidate(); - while( scan != end && !candidateEnded( scan->strip() ) ) - addToCandidate(*scan++); - if( candidateAccepted() ) { - transform( ADCs.begin(), ADCs.end(), ADCs.begin(), applyGain(info, firstStrip()) ); - appendBadNeighborsToCandidate(); - output.push_back( SiStripCluster( digis.detId(), firstStrip(), ADCs.begin(), ADCs.end()) ); - } - } -} - - -inline -bool ThreeThresholdStripClusterizer:: -candidateEnded(uint16_t testStrip) const { - uint16_t holes = testStrip - lastStrip - 1; - return ( !ADCs.empty() && // a candidate exists, and - holes > info->MaxSequentialHoles && // too many holes if not all are bad strips, and - ( holes > info->MaxSequentialBad || // (too many bad strips anyway, or - !info->allBadBetween( lastStrip, testStrip ))); // not all holes are bad strips) -} - - -inline -void ThreeThresholdStripClusterizer:: -addToCandidate(const SiStripDigi& digi) { - float noise = info->noise(digi.strip()); - if( !info->bad(digi.strip()) && digi.adc() >= static_cast( noise * info->ChannelThreshold)) { - if(!candidateHasSeed) candidateHasSeed = digi.adc() >= static_cast( noise * info->SeedThreshold); - if( ADCs.empty() ) lastStrip = digi.strip() - 1; //begin candidate - while( ++lastStrip < digi.strip() ) ADCs.push_back(0); //pad holes - ADCs.push_back( digi.adc() ); - noiseSquared += noise*noise; - } -} - - -inline -bool ThreeThresholdStripClusterizer:: -candidateAccepted() const { - return ( candidateHasSeed && - noiseSquared * info->ClusterThresholdSquared - <= std::pow( std::accumulate(ADCs.begin(),ADCs.end(),float(0)), 2)); -} - - -inline -uint16_t ThreeThresholdStripClusterizer:: -applyGain::operator()(uint16_t adc) { - if(adc > 255) throw InvalidChargeException(SiStripDigi(adc,strip)); - if(adc > 253) return adc; //saturated, do not scale - uint16_t charge = static_cast( adc/info->gain(strip++) + 0.5 ); //adding 0.5 turns truncation into rounding - return ( charge > 511 ? 255 : - ( charge > 253 ? 254 : charge )); -} - - -inline -void ThreeThresholdStripClusterizer:: -appendBadNeighborsToCandidate() { - uint8_t max = info->MaxAdjacentBad; - while(0 < max--) { - if(info->bad(firstStrip()-1)) { ADCs.insert( ADCs.begin(), 0); } - if(info->bad( lastStrip + 1)) { ADCs.push_back(0); lastStrip++;} - } -} - - -ThreeThresholdStripClusterizer:: -InvalidChargeException::InvalidChargeException(const SiStripDigi& digi) - : cms::Exception("Invalid Charge") { - std::stringstream s; - s << "Digi charge of " << digi.adc() << " ADC " - << "is out of range on strip " << digi.strip() << ". " - << "The ThreeThresholdStripClusterizer algorithm only works " - << "with input charges less than 256 ADC counts." << std::endl; - this->append(s.str()); -} - - -void ThreeThresholdStripClusterizer:: -clusterizeDetUnit(const edm::DetSet& digis, output_t& output) { - clusterizeDetUnit_(digis,output); -} - -void ThreeThresholdStripClusterizer:: -clusterizeDetUnit(const edmNew::DetSet& digis, output_t& output) { - clusterizeDetUnit_(digis,output); -}