Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class SiStripHitEffFromCalibTree : public ConditionDBWriter<SiStripBadStrip> {
float _effPlotMin;
TString _title;

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> _tkGeomToken;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> _tTopoToken;

unsigned int nTEClayers;

TH1F* bxHisto;
Expand Down Expand Up @@ -205,6 +208,8 @@ SiStripHitEffFromCalibTree::SiStripHitEffFromCalibTree(const edm::ParameterSet&
_tkMapMin = conf.getUntrackedParameter<double>("TkMapMin", 0.9);
_effPlotMin = conf.getUntrackedParameter<double>("EffPlotMin", 0.9);
_title = conf.getParameter<std::string>("Title");
_tkGeomToken = esConsumes();
_tTopoToken = esConsumes();
reader = new SiStripDetInfoFileReader(FileInPath_.fullPath());

nTEClayers = 9; // number of wheels
Expand All @@ -226,14 +231,8 @@ void SiStripHitEffFromCalibTree::algoEndJob() {
}

void SiStripHitEffFromCalibTree::algoAnalyze(const edm::Event& e, const edm::EventSetup& c) {
edm::ESHandle<TrackerGeometry> tracker;
c.get<TrackerDigiGeometryRecord>().get(tracker);
const TrackerGeometry* tkgeom = &(*tracker);

//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHandle;
c.get<TrackerTopologyRcd>().get(tTopoHandle);
const TrackerTopology* const tTopo = tTopoHandle.product();
const auto& tkgeom = c.getData(_tkGeomToken);
const auto& tTopo = c.getData(_tTopoToken);

// read bad modules to mask
ifstream badModules_file;
Expand Down Expand Up @@ -305,7 +304,7 @@ void SiStripHitEffFromCalibTree::algoAnalyze(const edm::Event& e, const edm::Eve
cout << "A module is bad if efficiency < the avg in layer - " << threshold << " and has at least " << nModsMin
<< " nModsMin." << endl;

unsigned int run, evt, bx;
unsigned int run, evt, bx{0};
double instLumi, PU;

//Open the ROOT Calib Tree
Expand Down Expand Up @@ -493,7 +492,7 @@ void SiStripHitEffFromCalibTree::algoAnalyze(const edm::Event& e, const edm::Eve
stripCluster = ClusterLocX / Pitch + nstrips / 2.0;
} else {
DetId ClusterDetId(id);
const StripGeomDetUnit* stripdet = (const StripGeomDetUnit*)tkgeom->idToDetUnit(ClusterDetId);
const StripGeomDetUnit* stripdet = (const StripGeomDetUnit*)tkgeom.idToDetUnit(ClusterDetId);
const StripTopology& Topo = stripdet->specificTopology();
nstrips = Topo.nstrips();
Pitch = stripdet->surface().bounds().width() / Topo.nstrips();
Expand Down Expand Up @@ -713,31 +712,31 @@ void SiStripHitEffFromCalibTree::algoAnalyze(const edm::Event& e, const edm::Eve
//TIB
//&&&&&&&&&&&&&&&&&

component = tTopo->tibLayer(BC[i].detid);
component = tTopo.tibLayer(BC[i].detid);
SetBadComponents(0, component, BC[i], ssV, NBadComponent);

} else if (a.subdetId() == SiStripDetId::TID) {
//&&&&&&&&&&&&&&&&&
//TID
//&&&&&&&&&&&&&&&&&

component = tTopo->tidSide(BC[i].detid) == 2 ? tTopo->tidWheel(BC[i].detid) : tTopo->tidWheel(BC[i].detid) + 3;
component = tTopo.tidSide(BC[i].detid) == 2 ? tTopo.tidWheel(BC[i].detid) : tTopo.tidWheel(BC[i].detid) + 3;
SetBadComponents(1, component, BC[i], ssV, NBadComponent);

} else if (a.subdetId() == SiStripDetId::TOB) {
//&&&&&&&&&&&&&&&&&
//TOB
//&&&&&&&&&&&&&&&&&

component = tTopo->tobLayer(BC[i].detid);
component = tTopo.tobLayer(BC[i].detid);
SetBadComponents(2, component, BC[i], ssV, NBadComponent);

} else if (a.subdetId() == SiStripDetId::TEC) {
//&&&&&&&&&&&&&&&&&
//TEC
//&&&&&&&&&&&&&&&&&

component = tTopo->tecSide(BC[i].detid) == 2 ? tTopo->tecWheel(BC[i].detid) : tTopo->tecWheel(BC[i].detid) + 9;
component = tTopo.tecSide(BC[i].detid) == 2 ? tTopo.tecWheel(BC[i].detid) : tTopo.tecWheel(BC[i].detid) + 9;
SetBadComponents(3, component, BC[i], ssV, NBadComponent);
}
}
Expand All @@ -758,16 +757,16 @@ void SiStripHitEffFromCalibTree::algoAnalyze(const edm::Event& e, const edm::Eve
SiStripDetId a(detid);
if (a.subdetId() == 3) {
subdet = 0;
component = tTopo->tibLayer(detid);
component = tTopo.tibLayer(detid);
} else if (a.subdetId() == 4) {
subdet = 1;
component = tTopo->tidSide(detid) == 2 ? tTopo->tidWheel(detid) : tTopo->tidWheel(detid) + 3;
component = tTopo.tidSide(detid) == 2 ? tTopo.tidWheel(detid) : tTopo.tidWheel(detid) + 3;
} else if (a.subdetId() == 5) {
subdet = 2;
component = tTopo->tobLayer(detid);
component = tTopo.tobLayer(detid);
} else if (a.subdetId() == 6) {
subdet = 3;
component = tTopo->tecSide(detid) == 2 ? tTopo->tecWheel(detid) : tTopo->tecWheel(detid) + 9;
component = tTopo.tecSide(detid) == 2 ? tTopo.tecWheel(detid) : tTopo.tecWheel(detid) + 9;
}

SiStripQuality::Range sqrange =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/Common/interface/DetSetVector.h"
Expand Down Expand Up @@ -31,19 +31,21 @@ class SiStripClusterToDigiProducer : public edm::stream::EDProducer<> {

private:
void process(const ClusterCollection& input, std::vector<DetDigiCollection>& output_base);
void initialize(const edm::EventSetup& es);
void setDetId(const uint32_t id);
float gain(const uint16_t& strip) const { return gainHandle->getStripGain(strip, gainRange); }
uint16_t applyGain(const uint16_t& strip, const uint16_t& adc);

edm::EDGetTokenT<ClusterCollection> token;
SiStripApvGain::Range gainRange;
edm::ESHandle<SiStripGain> gainHandle;
uint32_t gain_cache_id, detId;
edm::ESGetToken<SiStripGain, SiStripGainRcd> gainToken_;
edm::ESWatcher<SiStripGainRcd> gainWatcher_;
const SiStripGain* gainHandle;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This not being a "handle" any more, it could be probably better renamed without "Handle" in it

uint32_t detId;
};

SiStripClusterToDigiProducer::SiStripClusterToDigiProducer(const edm::ParameterSet& conf) {
token = consumes<ClusterCollection>(conf.getParameter<edm::InputTag>("ClusterProducer"));
gainToken_ = esConsumes();

produces<DigiCollection>("ZeroSuppressed");
produces<DigiCollection>("VirginRaw");
Expand All @@ -52,7 +54,9 @@ SiStripClusterToDigiProducer::SiStripClusterToDigiProducer(const edm::ParameterS
}

void SiStripClusterToDigiProducer::produce(edm::Event& event, const edm::EventSetup& es) {
initialize(es);
if (gainWatcher_.check(es)) {
gainHandle = &es.getData(gainToken_);
}

std::vector<DetDigiCollection> output_base;
edm::Handle<ClusterCollection> input;
Expand Down Expand Up @@ -97,15 +101,6 @@ void SiStripClusterToDigiProducer::process(const ClusterCollection& input,
}
}

void SiStripClusterToDigiProducer::initialize(const edm::EventSetup& es) {
uint32_t g_cache_id = es.get<SiStripGainRcd>().cacheIdentifier();

if (g_cache_id != gain_cache_id) {
es.get<SiStripGainRcd>().get(gainHandle);
gain_cache_id = g_cache_id;
}
}

inline void SiStripClusterToDigiProducer::setDetId(const uint32_t id) {
gainRange = gainHandle->getRange(id);
detId = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h"
#include "CondFormats/DataRecord/interface/SiStripThresholdRcd.h"

#include <vector>
class SiStripNoises;
Expand All @@ -17,9 +21,14 @@ class SiStripFedZeroSuppression {
friend class SiStripRawProcessingFactory;

public:
SiStripFedZeroSuppression(uint16_t fedalgo, bool trunc = true, bool trunc10bits = false)
: noise_cache_id(0),
threshold_cache_id(0),
SiStripFedZeroSuppression(uint16_t fedalgo,
edm::ConsumesCollector* iC = nullptr,
bool trunc = true,
bool trunc10bits = false)
: noiseToken_{iC ? decltype(noiseToken_){iC->esConsumes<SiStripNoises, SiStripNoisesRcd>()}
: decltype(noiseToken_){}},
thresholdToken_{iC ? decltype(thresholdToken_){iC->esConsumes<SiStripThreshold, SiStripThresholdRcd>()}
: decltype(thresholdToken_){}},
theFEDalgorithm(fedalgo),
doTruncate(trunc),
doTruncate10bits(trunc10bits) {}
Expand All @@ -41,9 +50,12 @@ class SiStripFedZeroSuppression {
};

private:
edm::ESHandle<SiStripNoises> noiseHandle;
edm::ESHandle<SiStripThreshold> thresholdHandle;
uint32_t noise_cache_id, threshold_cache_id;
edm::ESGetToken<SiStripNoises, SiStripNoisesRcd> noiseToken_;
edm::ESGetToken<SiStripThreshold, SiStripThresholdRcd> thresholdToken_;
const SiStripNoises* noiseHandle_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also these two are not "handles" any more

const SiStripThreshold* thresholdHandle_;
edm::ESWatcher<SiStripNoisesRcd> noiseWatcher_;
edm::ESWatcher<SiStripThresholdRcd> thresholdWatcher_;

uint16_t theFEDalgorithm;
bool isAValidDigi();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SiStripRawProcessingFactory {
public:
static std::unique_ptr<SiStripRawProcessingAlgorithms> create(const edm::ParameterSet&, edm::ConsumesCollector);

static std::unique_ptr<SiStripFedZeroSuppression> create_Suppressor(const edm::ParameterSet&);
static std::unique_ptr<SiStripFedZeroSuppression> create_Suppressor(const edm::ParameterSet&, edm::ConsumesCollector);
static std::unique_ptr<SiStripPedestalsSubtractor> create_SubtractorPed(const edm::ParameterSet&,
edm::ConsumesCollector);
static std::unique_ptr<SiStripCommonModeNoiseSubtractor> create_SubtractorCMN(const edm::ParameterSet&,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,18 @@
using namespace std;

void SiStripFedZeroSuppression::init(const edm::EventSetup& es) {
uint32_t n_cache_id = es.get<SiStripNoisesRcd>().cacheIdentifier();
uint32_t t_cache_id = es.get<SiStripThresholdRcd>().cacheIdentifier();

if (n_cache_id != noise_cache_id) {
es.get<SiStripNoisesRcd>().get(noiseHandle);
noise_cache_id = n_cache_id;
if (noiseWatcher_.check(es)) {
noiseHandle_ = &es.getData(noiseToken_);
}
if (t_cache_id != threshold_cache_id) {
es.get<SiStripThresholdRcd>().get(thresholdHandle);
threshold_cache_id = t_cache_id;
if (thresholdWatcher_.check(es)) {
thresholdHandle_ = &es.getData(thresholdToken_);
}
}

void SiStripFedZeroSuppression::suppress(const std::vector<SiStripDigi>& in,
std::vector<SiStripDigi>& selectedSignal,
uint32_t detID) {
suppress(in, selectedSignal, detID, *noiseHandle, *thresholdHandle);
suppress(in, selectedSignal, detID, *noiseHandle_, *thresholdHandle_);
}

void SiStripFedZeroSuppression::suppress(const std::vector<SiStripDigi>& in,
Expand Down Expand Up @@ -133,8 +128,8 @@ void SiStripFedZeroSuppression::suppress(const std::vector<SiStripDigi>& in,

void SiStripFedZeroSuppression::suppress(const edm::DetSet<SiStripRawDigi>& in, edm::DetSet<SiStripDigi>& out) {
const uint32_t detID = out.id;
SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detID);
SiStripThreshold::Range detThRange = thresholdHandle->getRange(detID);
SiStripNoises::Range detNoiseRange = noiseHandle_->getRange(detID);
SiStripThreshold::Range detThRange = thresholdHandle_->getRange(detID);
#ifdef DEBUG_SiStripZeroSuppression_
if (edm::isDebugEnabled())
LogTrace("SiStripZeroSuppression")
Expand All @@ -152,10 +147,11 @@ void SiStripFedZeroSuppression::suppress(const edm::DetSet<SiStripRawDigi>& in,
#endif
adc = in_iter->adc();

SiStripThreshold::Data thresholds = thresholdHandle->getData(strip, detThRange);
theFEDlowThresh = static_cast<int16_t>(thresholds.getLth() * noiseHandle->getNoiseFast(strip, detNoiseRange) + 0.5);
SiStripThreshold::Data thresholds = thresholdHandle_->getData(strip, detThRange);
theFEDlowThresh =
static_cast<int16_t>(thresholds.getLth() * noiseHandle_->getNoiseFast(strip, detNoiseRange) + 0.5);
theFEDhighThresh =
static_cast<int16_t>(thresholds.getHth() * noiseHandle->getNoiseFast(strip, detNoiseRange) + 0.5);
static_cast<int16_t>(thresholds.getHth() * noiseHandle_->getNoiseFast(strip, detNoiseRange) + 0.5);

adcPrev = -9999;
adcNext = -9999;
Expand All @@ -171,11 +167,11 @@ void SiStripFedZeroSuppression::suppress(const edm::DetSet<SiStripRawDigi>& in,
theNextFEDhighThresh = 9999;
} else {
adcNext = (in_iter + 1)->adc();
SiStripThreshold::Data thresholds_1 = thresholdHandle->getData(strip + 1, detThRange);
SiStripThreshold::Data thresholds_1 = thresholdHandle_->getData(strip + 1, detThRange);
theNextFEDlowThresh =
static_cast<int16_t>(thresholds_1.getLth() * noiseHandle->getNoiseFast(strip + 1, detNoiseRange) + 0.5);
static_cast<int16_t>(thresholds_1.getLth() * noiseHandle_->getNoiseFast(strip + 1, detNoiseRange) + 0.5);
theNextFEDhighThresh =
static_cast<int16_t>(thresholds_1.getHth() * noiseHandle->getNoiseFast(strip + 1, detNoiseRange) + 0.5);
static_cast<int16_t>(thresholds_1.getHth() * noiseHandle_->getNoiseFast(strip + 1, detNoiseRange) + 0.5);
}
/*
Similarily, for the first strip
Expand All @@ -187,11 +183,11 @@ void SiStripFedZeroSuppression::suppress(const edm::DetSet<SiStripRawDigi>& in,
thePrevFEDhighThresh = 9999;
} else {
adcPrev = (in_iter - 1)->adc();
SiStripThreshold::Data thresholds_1 = thresholdHandle->getData(strip - 1, detThRange);
SiStripThreshold::Data thresholds_1 = thresholdHandle_->getData(strip - 1, detThRange);
thePrevFEDlowThresh =
static_cast<int16_t>(thresholds_1.getLth() * noiseHandle->getNoiseFast(strip - 1, detNoiseRange) + 0.5);
static_cast<int16_t>(thresholds_1.getLth() * noiseHandle_->getNoiseFast(strip - 1, detNoiseRange) + 0.5);
thePrevFEDhighThresh =
static_cast<int16_t>(thresholds_1.getHth() * noiseHandle->getNoiseFast(strip - 1, detNoiseRange) + 0.5);
static_cast<int16_t>(thresholds_1.getHth() * noiseHandle_->getNoiseFast(strip - 1, detNoiseRange) + 0.5);
}
if (adcNext < adcPrev) {
adcMaxNeigh = adcPrev;
Expand All @@ -213,17 +209,17 @@ void SiStripFedZeroSuppression::suppress(const edm::DetSet<SiStripRawDigi>& in,
theNext2FEDlowThresh = 9999;
} else if (strip % 128 < 126) {
adcNext2 = (in_iter + 2)->adc();
theNext2FEDlowThresh = static_cast<int16_t>(thresholdHandle->getData(strip + 2, detThRange).getLth() *
noiseHandle->getNoiseFast(strip + 2, detNoiseRange) +
theNext2FEDlowThresh = static_cast<int16_t>(thresholdHandle_->getData(strip + 2, detThRange).getLth() *
noiseHandle_->getNoiseFast(strip + 2, detNoiseRange) +
0.5);
}
if (strip % 128 <= 1) {
adcPrev2 = 0;
thePrev2FEDlowThresh = 9999;
} else if (strip % 128 > 1) {
adcPrev2 = (in_iter - 2)->adc();
thePrev2FEDlowThresh = static_cast<int16_t>(thresholdHandle->getData(strip - 2, detThRange).getLth() *
noiseHandle->getNoiseFast(strip - 2, detNoiseRange) +
thePrev2FEDlowThresh = static_cast<int16_t>(thresholdHandle_->getData(strip - 2, detThRange).getLth() *
noiseHandle_->getNoiseFast(strip - 2, detNoiseRange) +
0.5);
}
//GB 23/6/08: truncation should be done at the very beginning
Expand All @@ -233,8 +229,8 @@ void SiStripFedZeroSuppression::suppress(const edm::DetSet<SiStripRawDigi>& in,
}

void SiStripFedZeroSuppression::fillThresholds_(const uint32_t detID, size_t size) {
SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detID);
SiStripThreshold::Range detThRange = thresholdHandle->getRange(detID);
SiStripNoises::Range detNoiseRange = noiseHandle_->getRange(detID);
SiStripThreshold::Range detThRange = thresholdHandle_->getRange(detID);

if (highThr_.size() != size) {
highThr_.resize(size);
Expand All @@ -244,8 +240,8 @@ void SiStripFedZeroSuppression::fillThresholds_(const uint32_t detID, size_t siz
lowThrSN_.resize(size);
}

noiseHandle->allNoises(noises_, detNoiseRange);
thresholdHandle->allThresholds(lowThrSN_, highThrSN_, detThRange); // thresholds as S/N
noiseHandle_->allNoises(noises_, detNoiseRange);
thresholdHandle_->allThresholds(lowThrSN_, highThrSN_, detThRange); // thresholds as S/N
for (size_t strip = 0; strip < size; ++strip) {
float noise = noises_[strip];
// uncomment line below to check bluk noise decoding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ std::unique_ptr<SiStripRawProcessingAlgorithms> SiStripRawProcessingFactory::cre
new SiStripRawProcessingAlgorithms(iC,
create_SubtractorPed(conf, iC),
create_SubtractorCMN(conf, iC),
create_Suppressor(conf),
create_Suppressor(conf, iC),
create_Restorer(conf, iC),
conf.getParameter<bool>("doAPVRestore"),
conf.getParameter<bool>("useCMMeanMap")));
Expand Down Expand Up @@ -61,8 +61,8 @@ std::unique_ptr<SiStripCommonModeNoiseSubtractor> SiStripRawProcessingFactory::c
return std::unique_ptr<SiStripCommonModeNoiseSubtractor>(new MedianCMNSubtractor());
}

std::unique_ptr<SiStripFedZeroSuppression> SiStripRawProcessingFactory::create_Suppressor(
const edm::ParameterSet& conf) {
std::unique_ptr<SiStripFedZeroSuppression> SiStripRawProcessingFactory::create_Suppressor(const edm::ParameterSet& conf,
edm::ConsumesCollector iC) {
const uint32_t mode = conf.getParameter<uint32_t>("SiStripFedZeroSuppressionMode");
const bool trunc = conf.getParameter<bool>("TruncateInSuppressor");
const bool trunc10bits = conf.getParameter<bool>("Use10bitsTruncation");
Expand All @@ -71,11 +71,11 @@ std::unique_ptr<SiStripFedZeroSuppression> SiStripRawProcessingFactory::create_S
case 2:
case 3:
case 4:
return std::make_unique<SiStripFedZeroSuppression>(mode, trunc, trunc10bits);
return std::make_unique<SiStripFedZeroSuppression>(mode, &iC, trunc, trunc10bits);
default:
edm::LogError("SiStripRawProcessingFactory::createSuppressor")
<< "Unregistered mode: " << mode << ". Use one of {1,2,3,4}.";
return std::make_unique<SiStripFedZeroSuppression>(4, true, trunc10bits);
return std::make_unique<SiStripFedZeroSuppression>(4, &iC, true, trunc10bits);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ DigiSimLinkAlgorithm::DigiSimLinkAlgorithm(const edm::ParameterSet& conf) : conf
theDigiSimLinkPileUpSignals = new DigiSimLinkPileUpSignals();
theSiNoiseAdder = new SiGaussianTailNoiseAdder(theThreshold);
theSiDigitalConverter = new SiTrivialDigitalConverter(theElectronPerADC, PreMixing_);
theSiZeroSuppress = new SiStripFedZeroSuppression(theFedAlgo);
theSiZeroSuppress = new SiStripFedZeroSuppression(theFedAlgo, nullptr);
}

DigiSimLinkAlgorithm::~DigiSimLinkAlgorithm() {
Expand Down
Loading