Skip to content

Commit

Permalink
Merge pull request #39720 from stahlleiton/HGCAL_DIGI_LocalTime_CMSSW…
Browse files Browse the repository at this point in the history
…_12_6_0_pre3

HGCAL: Change ToA to global time in DIGI
  • Loading branch information
cmsbuild authored Oct 19, 2022
2 parents f3513b1 + 9e5fdf5 commit 9166b25
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
tdcNbits = cms.uint32(12),
tdcOnset = cms.double(60),
tdcSaturation = cms.double(10000),
tofDelay = cms.double(-9),
toaLSB_ns = cms.double(0.0244)
),
HGCEEdigiCollection = cms.InputTag("hgcalDigisL1Seeded","EE"),
Expand All @@ -17,10 +18,11 @@
adcNbits = cms.uint32(10),
adcSaturation = cms.double(68.75),
fCPerMIP = cms.vdouble(1.0, 1.0, 1.0),
isSiFE = cms.bool(True),
isSiFE = cms.bool(False),
tdcNbits = cms.uint32(12),
tdcOnset = cms.double(55),
tdcSaturation = cms.double(1000),
tofDelay = cms.double(-14),
toaLSB_ns = cms.double(0.0244)
),
HGCHEBdigiCollection = cms.InputTag("hgcalDigisL1Seeded","HEback"),
Expand All @@ -33,6 +35,7 @@
tdcNbits = cms.uint32(12),
tdcOnset = cms.double(60),
tdcSaturation = cms.double(10000),
tofDelay = cms.double(-11),
toaLSB_ns = cms.double(0.0244)
),
HGCHEFdigiCollection = cms.InputTag("hgcalDigisL1Seeded","HEfront"),
Expand All @@ -45,6 +48,7 @@
tdcNbits = cms.uint32(12),
tdcOnset = cms.double(60),
tdcSaturation = cms.double(10000),
tofDelay = cms.double(-33),
toaLSB_ns = cms.double(0.0244)
),
HGCHFNosedigiCollection = cms.InputTag("hfnoseDigis","HFNose"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
tdcNbits = cms.uint32(12),
tdcOnset = cms.double(60),
tdcSaturation = cms.double(10000),
tofDelay = cms.double(-9),
toaLSB_ns = cms.double(0.0244)
),
HGCEEdigiCollection = cms.InputTag("hgcalDigis","EE"),
Expand All @@ -17,10 +18,11 @@
adcNbits = cms.uint32(10),
adcSaturation = cms.double(68.75),
fCPerMIP = cms.vdouble(1.0, 1.0, 1.0),
isSiFE = cms.bool(True),
isSiFE = cms.bool(False),
tdcNbits = cms.uint32(12),
tdcOnset = cms.double(55),
tdcSaturation = cms.double(1000),
tofDelay = cms.double(-14),
toaLSB_ns = cms.double(0.0244)
),
HGCHEBdigiCollection = cms.InputTag("hgcalDigis","HEback"),
Expand All @@ -33,6 +35,7 @@
tdcNbits = cms.uint32(12),
tdcOnset = cms.double(60),
tdcSaturation = cms.double(10000),
tofDelay = cms.double(-11),
toaLSB_ns = cms.double(0.0244)
),
HGCHEFdigiCollection = cms.InputTag("hgcalDigis","HEfront"),
Expand All @@ -45,6 +48,7 @@
tdcNbits = cms.uint32(12),
tdcOnset = cms.double(60),
tdcSaturation = cms.double(10000),
tofDelay = cms.double(-33),
toaLSB_ns = cms.double(0.0244)
),
HGCHFNosedigiCollection = cms.InputTag("hfnoseDigis","HFNose"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,27 @@ class HGCalUncalibRecHitRecWeightsAlgo {

void set_tdcOnsetfC(const double tdcOnset) { tdcOnsetfC_ = tdcOnset; }

void set_tofDelay(const double tofDelay) { tofDelay_ = tofDelay; }

void set_fCPerMIP(const std::vector<double>& fCPerMIP) {
if (std::any_of(fCPerMIP.cbegin(), fCPerMIP.cend(), [](double conv) { return conv <= 0.0; })) {
throw cms::Exception("BadConversionFactor") << "At least one of fCPerMIP is zero!" << std::endl;
}
fCPerMIP_ = fCPerMIP;
}

void setGeometry(const HGCalGeometry* geom) {
if (geom)
ddd_ = &(geom->topology().dddConstants());
bool setGeometry(const edm::ESHandle<HGCalGeometry>& geom) {
geom_ = geom.isValid() ? geom.product() : nullptr;
if (isSiFESim_ && geom_)
ddd_ = &(geom_->topology().dddConstants());
else
ddd_ = nullptr;
return geom_ != nullptr;
}

/// Compute HGCUncalibratedRecHit from DataFrame
virtual HGCUncalibratedRecHit makeRecHit(const C& dataFrame) {
double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
double amplitude_(-1.), pedestal_(-1.), jitter_(-99.), chi2_(-1.);
uint32_t flag = 0;

constexpr int iSample = 2; //only in-time sample
Expand All @@ -68,23 +72,21 @@ class HGCalUncalibRecHitRecWeightsAlgo {
// LG (11/04/2016):
// offset the TDC upwards to reflect the bin center
amplitude_ = (std::floor(tdcOnsetfC_ / adcLSB_) + 1.0) * adcLSB_ + (double(sample.data()) + 0.5) * tdcLSB_;

if (sample.getToAValid()) {
jitter_ = double(sample.toa()) * toaLSBToNS_;
}
} else {
amplitude_ = double(sample.data()) * adcLSB_; // why do we not have +0.5 here ?
if (sample.getToAValid()) {
jitter_ = double(sample.toa()) * toaLSBToNS_;
}
} //isSiFESim_
} //mode()
} //isSiFESim_
} //mode()

// trivial digitization, i.e. no signal shape
else {
amplitude_ = double(sample.data()) * adcLSB_;
}

if (sample.getToAValid()) {
const auto& dist2center = geom_ ? geom_->getPosition(dataFrame.id()).mag() : 0;
jitter_ = double(sample.toa()) * toaLSBToNS_ - dist2center / c_cm_ns - tofDelay_;
}

int thickness = (ddd_ != nullptr) ? ddd_->waferType(dataFrame.id()) : 0;
amplitude_ = amplitude_ / fCPerMIP_[thickness];

Expand All @@ -100,9 +102,11 @@ class HGCalUncalibRecHitRecWeightsAlgo {
}

private:
double adcLSB_, tdcLSB_, toaLSBToNS_, tdcOnsetfC_;
static constexpr float c_cm_ns = CLHEP::c_light * CLHEP::ns / CLHEP::cm;
double adcLSB_, tdcLSB_, toaLSBToNS_, tdcOnsetfC_, tofDelay_;
bool isSiFESim_;
std::vector<double> fCPerMIP_;
const HGCalDDDConstants* ddd_;
const HGCalGeometry* geom_;
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h"
#include "DataFormats/HGCDigi/interface/HGCDigiCollections.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"

namespace edm {
class Event;
Expand All @@ -18,22 +19,24 @@ class HGCalUncalibRecHitWorkerBaseClass {
HGCalUncalibRecHitWorkerBaseClass(const edm::ParameterSet& ps, edm::ConsumesCollector iC) {}
virtual ~HGCalUncalibRecHitWorkerBaseClass() {}

// do event setup things
virtual void set(const edm::EventSetup& es) = 0;

// run HGC-EE things
virtual bool runHGCEE(const HGCalDigiCollection::const_iterator& digi, HGCeeUncalibratedRecHitCollection& result) = 0;
virtual bool runHGCEE(const edm::ESHandle<HGCalGeometry>& geom,
const HGCalDigiCollection& digis,
HGCeeUncalibratedRecHitCollection& result) = 0;

// run HGC-FH things
virtual bool runHGCHEsil(const HGCalDigiCollection::const_iterator& digi,
virtual bool runHGCHEsil(const edm::ESHandle<HGCalGeometry>& geom,
const HGCalDigiCollection& digis,
HGChefUncalibratedRecHitCollection& result) = 0;

// run HGC-BH things
virtual bool runHGCHEscint(const HGCalDigiCollection::const_iterator& digi,
virtual bool runHGCHEscint(const edm::ESHandle<HGCalGeometry>& geom,
const HGCalDigiCollection& digis,
HGChebUncalibratedRecHitCollection& result) = 0;

// run HFNose things
virtual bool runHGCHFNose(const HGCalDigiCollection::const_iterator& digi,
virtual bool runHGCHFNose(const edm::ESHandle<HGCalGeometry>& geom,
const HGCalDigiCollection& digis,
HGChfnoseUncalibratedRecHitCollection& result) = 0;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void HGCalLayerClusterProducer::produce(edm::Event& evt, const edm::EventSetup&
//check on timeError to exclude scintillator
if (rhTimeE < 0.)
continue;
timeClhits.push_back(rechit->time() - timeOffset);
timeClhits.push_back(rechit->time());
timeErrorClhits.push_back(1. / (rhTimeE * rhTimeE));
}
hgcalsimclustertime::ComputeClusterTime timeEstimator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ bool HGCalRecHitWorkerSimple::run(const edm::Event& evt,
float SoN = new_E / sigmaNoiseGeV;
myrechit.setSignalOverSigmaNoise(SoN);

if (detid.det() == DetId::HGCalHSc || myrechit.time() < 0.) {
if (detid.det() == DetId::HGCalHSc || myrechit.time() == -99.) {
myrechit.setTimeError(-1.);
} else {
float timeError = timeEstimatorSi_.getTimeError("recHit", SoN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ HGCalUncalibRecHitProducer::HGCalUncalibRecHitProducer(const edm::ParameterSet&
hefDigiCollection_(consumes<HGCalDigiCollection>(ps.getParameter<edm::InputTag>("HGCHEFdigiCollection"))),
hebDigiCollection_(consumes<HGCalDigiCollection>(ps.getParameter<edm::InputTag>("HGCHEBdigiCollection"))),
hfnoseDigiCollection_(consumes<HGCalDigiCollection>(ps.getParameter<edm::InputTag>("HGCHFNosedigiCollection"))),
ee_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalEESensitive"))),
hef_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalHESiliconSensitive"))),
heb_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalHEScintillatorSensitive"))),
hfnose_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalHFNoseSensitive"))),
eeHitCollection_(ps.getParameter<std::string>("HGCEEhitCollection")),
hefHitCollection_(ps.getParameter<std::string>("HGCHEFhitCollection")),
hebHitCollection_(ps.getParameter<std::string>("HGCHEBhitCollection")),
Expand All @@ -31,53 +35,31 @@ HGCalUncalibRecHitProducer::~HGCalUncalibRecHitProducer() {}
void HGCalUncalibRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& es) {
using namespace edm;

// tranparently get things from event setup
worker_->set(es);

// prepare output
auto eeUncalibRechits = std::make_unique<HGCeeUncalibratedRecHitCollection>();
auto hefUncalibRechits = std::make_unique<HGChefUncalibratedRecHitCollection>();
auto hebUncalibRechits = std::make_unique<HGChebUncalibratedRecHitCollection>();
auto hfnoseUncalibRechits = std::make_unique<HGChfnoseUncalibratedRecHitCollection>();

// loop over HGCEE digis
edm::Handle<HGCalDigiCollection> pHGCEEDigis;
evt.getByToken(eeDigiCollection_, pHGCEEDigis);
const HGCalDigiCollection* eeDigis = pHGCEEDigis.product();
eeUncalibRechits->reserve(eeDigis->size());
for (auto itdg = eeDigis->begin(); itdg != eeDigis->end(); ++itdg) {
worker_->runHGCEE(itdg, *eeUncalibRechits);
}
const auto& pHGCEEDigis = evt.getHandle(eeDigiCollection_);
if (pHGCEEDigis.isValid())
worker_->runHGCEE(es.getHandle(ee_geometry_token_), *pHGCEEDigis, *eeUncalibRechits);

// loop over HGCHEsil digis
edm::Handle<HGCalDigiCollection> pHGCHEFDigis;
evt.getByToken(hefDigiCollection_, pHGCHEFDigis);
const HGCalDigiCollection* hefDigis = pHGCHEFDigis.product();
hefUncalibRechits->reserve(hefDigis->size());
for (auto itdg = hefDigis->begin(); itdg != hefDigis->end(); ++itdg) {
worker_->runHGCHEsil(itdg, *hefUncalibRechits);
}
const auto& pHGCHEFDigis = evt.getHandle(hefDigiCollection_);
if (pHGCHEFDigis.isValid())
worker_->runHGCHEsil(es.getHandle(hef_geometry_token_), *pHGCHEFDigis, *hefUncalibRechits);

// loop over HGCHEscint digis
edm::Handle<HGCalDigiCollection> pHGCHEBDigis;
evt.getByToken(hebDigiCollection_, pHGCHEBDigis);
const HGCalDigiCollection* hebDigis = pHGCHEBDigis.product();
hebUncalibRechits->reserve(hebDigis->size());
for (auto itdg = hebDigis->begin(); itdg != hebDigis->end(); ++itdg) {
worker_->runHGCHEscint(itdg, *hebUncalibRechits);
}
const auto& pHGCHEBDigis = evt.getHandle(hebDigiCollection_);
if (pHGCHEBDigis.isValid())
worker_->runHGCHEscint(es.getHandle(heb_geometry_token_), *pHGCHEBDigis, *hebUncalibRechits);

// loop over HFNose digis
edm::Handle<HGCalDigiCollection> pHGCHFNoseDigis;
evt.getByToken(hfnoseDigiCollection_, pHGCHFNoseDigis);
if (pHGCHFNoseDigis.isValid()) {
const HGCalDigiCollection* hfnoseDigis = pHGCHFNoseDigis.product();
if (!(hfnoseDigis->empty())) {
hfnoseUncalibRechits->reserve(hfnoseDigis->size());
for (auto itdg = hfnoseDigis->begin(); itdg != hfnoseDigis->end(); ++itdg)
worker_->runHGCHFNose(itdg, *hfnoseUncalibRechits);
}
}
const auto& pHGCHFNoseDigis = evt.getHandle(hfnoseDigiCollection_);
if (pHGCHFNoseDigis.isValid())
worker_->runHGCHFNose(es.getHandle(hfnose_geometry_token_), *pHGCHFNoseDigis, *hfnoseUncalibRechits);

// put the collection of recunstructed hits in the event
evt.put(std::move(eeUncalibRechits), eeHitCollection_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ class HGCalUncalibRecHitProducer : public edm::stream::EDProducer<> {
void produce(edm::Event& evt, const edm::EventSetup& es) override;

private:
const edm::EDGetTokenT<HGCalDigiCollection> eeDigiCollection_; // collection of HGCEE digis
const edm::EDGetTokenT<HGCalDigiCollection> hefDigiCollection_; // collection of HGCHEF digis
edm::EDGetTokenT<HGCalDigiCollection> hebDigiCollection_; // collection of HGCHEB digis
edm::EDGetTokenT<HGCalDigiCollection> hfnoseDigiCollection_; // collection of HGCHFNose digis
const edm::EDGetTokenT<HGCalDigiCollection> eeDigiCollection_; // collection of HGCEE digis
const edm::EDGetTokenT<HGCalDigiCollection> hefDigiCollection_; // collection of HGCHEF digis
const edm::EDGetTokenT<HGCalDigiCollection> hebDigiCollection_; // collection of HGCHEB digis
const edm::EDGetTokenT<HGCalDigiCollection> hfnoseDigiCollection_; // collection of HGCHFNose digis

const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> ee_geometry_token_;
const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> hef_geometry_token_;
const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> heb_geometry_token_;
const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> hfnose_geometry_token_;

const std::string eeHitCollection_; // instance name of HGCEE collection of hits
const std::string hefHitCollection_; // instance name of HGCHEF collection of hits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ void configureIt(const edm::ParameterSet& conf, HGCalUncalibRecHitRecWeightsAlgo
} else {
maker.set_fCPerMIP(std::vector<double>({1.0}));
}

maker.set_tofDelay(conf.getParameter<double>("tofDelay"));
}

HGCalUncalibRecHitWorkerWeights::HGCalUncalibRecHitWorkerWeights(const edm::ParameterSet& ps, edm::ConsumesCollector iC)
: HGCalUncalibRecHitWorkerBaseClass(ps, iC),
ee_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalEESensitive"))),
hef_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalHESiliconSensitive"))),
hfnose_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalHFNoseSensitive"))) {
: HGCalUncalibRecHitWorkerBaseClass(ps, iC) {
const edm::ParameterSet& ee_cfg = ps.getParameterSet("HGCEEConfig");
const edm::ParameterSet& hef_cfg = ps.getParameterSet("HGCHEFConfig");
const edm::ParameterSet& heb_cfg = ps.getParameterSet("HGCHEBConfig");
Expand All @@ -72,41 +71,39 @@ HGCalUncalibRecHitWorkerWeights::HGCalUncalibRecHitWorkerWeights(const edm::Para
configureIt(hfnose_cfg, uncalibMaker_hfnose_);
}

void HGCalUncalibRecHitWorkerWeights::set(const edm::EventSetup& es) {
if (uncalibMaker_ee_.isSiFESim()) {
uncalibMaker_ee_.setGeometry(&es.getData(ee_geometry_token_));
}
if (uncalibMaker_hef_.isSiFESim()) {
uncalibMaker_hef_.setGeometry(&es.getData(hef_geometry_token_));
}
uncalibMaker_heb_.setGeometry(nullptr);
if (uncalibMaker_hfnose_.isSiFESim()) {
uncalibMaker_hfnose_.setGeometry(&es.getData(hfnose_geometry_token_));
}
bool HGCalUncalibRecHitWorkerWeights::run(const edm::ESHandle<HGCalGeometry>& geom,
const HGCalDigiCollection& digis,
HGCalUncalibRecHitRecWeightsAlgo<HGCalDataFrame>& uncalibMaker,
edm::SortedCollection<HGCUncalibratedRecHit>& result) {
uncalibMaker.setGeometry(geom);
result.reserve(result.size() + digis.size());
for (const auto& digi : digis)
result.push_back(uncalibMaker.makeRecHit(digi));
return true;
}

bool HGCalUncalibRecHitWorkerWeights::runHGCEE(const HGCalDigiCollection::const_iterator& itdg,
bool HGCalUncalibRecHitWorkerWeights::runHGCEE(const edm::ESHandle<HGCalGeometry>& geom,
const HGCalDigiCollection& digis,
HGCeeUncalibratedRecHitCollection& result) {
result.push_back(uncalibMaker_ee_.makeRecHit(*itdg));
return true;
return run(geom, digis, uncalibMaker_ee_, result);
}

bool HGCalUncalibRecHitWorkerWeights::runHGCHEsil(const HGCalDigiCollection::const_iterator& itdg,
bool HGCalUncalibRecHitWorkerWeights::runHGCHEsil(const edm::ESHandle<HGCalGeometry>& geom,
const HGCalDigiCollection& digis,
HGChefUncalibratedRecHitCollection& result) {
result.push_back(uncalibMaker_hef_.makeRecHit(*itdg));
return true;
return run(geom, digis, uncalibMaker_hef_, result);
}

bool HGCalUncalibRecHitWorkerWeights::runHGCHEscint(const HGCalDigiCollection::const_iterator& itdg,
bool HGCalUncalibRecHitWorkerWeights::runHGCHEscint(const edm::ESHandle<HGCalGeometry>& geom,
const HGCalDigiCollection& digis,
HGChebUncalibratedRecHitCollection& result) {
result.push_back(uncalibMaker_heb_.makeRecHit(*itdg));
return true;
return run(geom, digis, uncalibMaker_heb_, result);
}

bool HGCalUncalibRecHitWorkerWeights::runHGCHFNose(const HGCalDigiCollection::const_iterator& itdg,
bool HGCalUncalibRecHitWorkerWeights::runHGCHFNose(const edm::ESHandle<HGCalGeometry>& geom,
const HGCalDigiCollection& digis,
HGChfnoseUncalibratedRecHitCollection& result) {
result.push_back(uncalibMaker_hfnose_.makeRecHit(*itdg));
return true;
return run(geom, digis, uncalibMaker_hfnose_, result);
}

#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down
Loading

0 comments on commit 9166b25

Please sign in to comment.