Skip to content

Commit

Permalink
Find no. of strips without file reader
Browse files Browse the repository at this point in the history
  • Loading branch information
wmtford committed Nov 15, 2014
1 parent 630bc03 commit 421e3b8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 32 deletions.
35 changes: 13 additions & 22 deletions RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusterizer.cc
Expand Up @@ -5,8 +5,7 @@
#include "FWCore/Utilities/interface/transform.h"
#include "boost/foreach.hpp"
#include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
#include "CalibTracker/Records/interface/SiStripQualityRcd.h"
#include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
#include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"

SiStripClusterizer::
SiStripClusterizer(const edm::ParameterSet& conf)
Expand All @@ -15,7 +14,6 @@ SiStripClusterizer(const edm::ParameterSet& conf)
algorithm( StripClusterizerAlgorithmFactory::create(conf.getParameter<edm::ParameterSet>("Clusterizer")) ) {
produces< edmNew::DetSetVector<SiStripCluster> > ();
inputTokens = edm::vector_transform( inputTags, [this](edm::InputTag const & tag) { return consumes< edm::DetSetVector<SiStripDigi> >(tag);} );
useLegacyError_ = confClusterizer_.existsAs<bool>("useLegacyError") ? confClusterizer_.getParameter<bool>("useLegacyError") : false;
doRefineCluster_ = confClusterizer_.existsAs<bool>("doRefineCluster") ? confClusterizer_.getParameter<bool>("doRefineCluster") : false;
occupancyThreshold_ = confClusterizer_.existsAs<double>("occupancyThreshold") ? confClusterizer_.getParameter<double>("occupancyThreshold") : 0.05;
widthThreshold_ = confClusterizer_.existsAs<unsigned>("widthThreshold") ? confClusterizer_.getParameter<unsigned>("widthThreshold") : 4;
Expand All @@ -32,17 +30,10 @@ produce(edm::Event& event, const edm::EventSetup& es) {

algorithm->initialize(es);

edm::ESHandle<SiStripQuality> quality = 0;
SiStripDetInfoFileReader* reader = 0;
if (doRefineCluster_ &! useLegacyError_) {
es.get<SiStripQualityRcd>().get("", quality);
reader = edm::Service<SiStripDetInfoFileReader>().operator->();
}

BOOST_FOREACH( const edm::EDGetTokenT< edm::DetSetVector<SiStripDigi> >& token, inputTokens) {
if( findInput( token, inputOld, event) ) {
algorithm->clusterize(*inputOld, *output);
if (doRefineCluster_ &! useLegacyError_) refineCluster(inputOld, output, reader, quality);
if (doRefineCluster_) refineCluster(inputOld, output);
}
// else if( findInput( tag, inputNew, event) ) algorithm->clusterize(*inputNew, *output);
else edm::LogError("Input Not Found") << "[SiStripClusterizer::produce] ";// << tag;
Expand All @@ -64,9 +55,7 @@ findInput(const edm::EDGetTokenT<T>& tag, edm::Handle<T>& handle, const edm::Eve

void SiStripClusterizer::
refineCluster(const edm::Handle< edm::DetSetVector<SiStripDigi> >& input,
std::auto_ptr< edmNew::DetSetVector<SiStripCluster> >& output,
SiStripDetInfoFileReader* reader,
edm::ESHandle<SiStripQuality> quality) {
std::auto_ptr< edmNew::DetSetVector<SiStripCluster> >& output) {
if (input->size() == 0) return;

// Flag merge-prone clusters for relaxed CPE errors
Expand All @@ -75,24 +64,26 @@ refineCluster(const edm::Handle< edm::DetSetVector<SiStripDigi> >& input,
for (edmNew::DetSetVector<SiStripCluster>::const_iterator det=output->begin(); det!=output->end(); det++) {
uint32_t detId = det->id();
// Find the number of good strips in this sensor
// (from DPGAnalysis/SiStripTools/OccupancyPlots)
int nchannideal = reader->getNumberOfApvsAndStripLength(detId).first*128;
int nchannideal = SiStripDetCabling_->nApvPairs(detId) * 2 * 128;
int nchannreal = 0;
for(int strip = 0; strip < nchannideal; ++strip)
if(!quality->IsStripBad(detId,strip)) ++nchannreal;
if(!quality_->IsStripBad(detId,strip)) ++nchannreal;

edm::DetSetVector<SiStripDigi>::const_iterator digis = input->find(detId);
if (digis != input->end()) {
int ndigi = digis->size();
for (edmNew::DetSet<SiStripCluster>::iterator clust = det->begin(); clust != det->end(); clust++) {
if (ndigi > occupancyThreshold_*nchannreal && clust->amplitudes().size() >= widthThreshold_) clust->setMerged(true);
else clust->setMerged(false);
// if (clust->firstStrip() > nchannreal)
// std::cout << "firstStrip out_of_range " << clust->firstStrip() << ", " << nchannreal
// << ", " << nchannideal << ", " << clust->isMerged() << std::endl;
// std::cout << "Cluster_merged_width " << clust->isMerged() << " " << clust->amplitudes().size() << std::endl;
}
// std::cout << "Sensor:strips_occStrips_clust_merged " << nchannreal << " " << ndigi << " " << det->size() << std::endl;
// std::cout << "Sensor:strips_occStrips_clust " << nchannreal << " " << ndigi << " " << det->size() << std::endl;
}
} // traverse sensors
}

void SiStripClusterizer::beginRun(const edm::Run& run, const edm::EventSetup& es ) {
if (doRefineCluster_) {
es.get<SiStripDetCablingRcd>().get( SiStripDetCabling_);
es.get<SiStripQualityRcd>().get("", quality_);
}
}
10 changes: 6 additions & 4 deletions RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusterizer.h
Expand Up @@ -6,6 +6,8 @@
#include "RecoLocalTracker/SiStripClusterizer/interface/StripClusterizerAlgorithm.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
#include "CalibTracker/Records/interface/SiStripQualityRcd.h"

#include <vector>
#include <memory>
Expand All @@ -15,26 +17,26 @@ class SiStripClusterizer : public edm::stream::EDProducer<> {
public:

explicit SiStripClusterizer(const edm::ParameterSet& conf);
void beginRun(const edm::Run& run, const edm::EventSetup& es) override;
virtual void produce(edm::Event&, const edm::EventSetup&);

private:

edm::ParameterSet confClusterizer_;
bool useLegacyError_;
bool doRefineCluster_;
float occupancyThreshold_;
unsigned widthThreshold_;
template<class T> bool findInput(const edm::EDGetTokenT<T>&, edm::Handle<T>&, const edm::Event&);
const std::vector<edm::InputTag> inputTags;
std::auto_ptr<StripClusterizerAlgorithm> algorithm;
void refineCluster(const edm::Handle< edm::DetSetVector<SiStripDigi> >& input,
std::auto_ptr< edmNew::DetSetVector<SiStripCluster> >& output,
SiStripDetInfoFileReader* reader,
edm::ESHandle<SiStripQuality> quality);
std::auto_ptr< edmNew::DetSetVector<SiStripCluster> >& output);
typedef edm::EDGetTokenT< edm::DetSetVector<SiStripDigi> > token_t;
typedef std::vector<token_t> token_v;
token_v inputTokens;

edm::ESHandle<SiStripDetCabling> SiStripDetCabling_;
edm::ESHandle<SiStripQuality> quality_;
};

#endif
@@ -1,7 +1,5 @@
import FWCore.ParameterSet.Config as cms

from RecoLocalTracker.SiStripRecHitConverter.StripCPEfromTrackAngle_cfi import *

DefaultClusterizer = cms.PSet(
Algorithm = cms.string('ThreeThresholdAlgorithm'),
ChannelThreshold = cms.double(2.0),
Expand All @@ -13,7 +11,6 @@
QualityLabel = cms.string(""),
RemoveApvShots = cms.bool(True),
minGoodCharge = cms.double(-2069),
useLegacyError = StripCPEfromTrackAngleESProducer.parameters.useLegacyError,
doRefineCluster = cms.bool(False),
occupancyThreshold = cms.double(0.05),
widthThreshold = cms.uint32(4)
Expand Down
Expand Up @@ -38,10 +38,7 @@ localParameters( const SiStripCluster& cluster, const GeomDetUnit& det, const Lo

const unsigned N = cluster.amplitudes().size();
const float fullProjection = p.coveredStrips( track+p.drift, ltp.position());
// std::cout << cluster.firstStrip() << ", "<< cluster.isMerged() << ", legacyErr = " << legacyStripErrorSquared(N,std::abs(fullProjection))
// << ", newErr = " << stripErrorSquared( N, std::abs(fullProjection),ssdid.subDetector() ) << std::endl;
const float uerr2 = useLegacyError || cluster.isMerged() ? legacyStripErrorSquared(N,std::abs(fullProjection)) : stripErrorSquared( N, std::abs(fullProjection),ssdid.subDetector() );
// std::cout << " uerr2 = " << uerr2 << std::endl;
const float strip = cluster.barycenter() - 0.5f*(1.f-p.backplanecorrection) * fullProjection
+ 0.5f*p.coveredStrips(track, ltp.position());

Expand Down

0 comments on commit 421e3b8

Please sign in to comment.