Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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 @@ -4,7 +4,7 @@
from RecoLocalMuon.Configuration.RecoLocalMuon_cff import *
from RecoLocalCalo.Configuration.RecoLocalCalo_cff import *
from RecoLocalFastTime.Configuration.RecoLocalFastTime_cff import *
from RecoMTD.Configuration.RecoMTD_cff import *
from RecoMTD.Configuration.mtdGlobalReco_cff import *
from RecoTracker.Configuration.RecoTracker_cff import *
from RecoParticleFlow.PFClusterProducer.particleFlowCluster_cff import *
from TrackingTools.Configuration.TrackingTools_cff import *
Expand Down
12 changes: 6 additions & 6 deletions DataFormats/FTLRecHit/interface/FTLCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <cassert>
#include <algorithm>
#include <numeric>
#include <functional>

#include "DataFormats/DetId/interface/DetId.h"

Expand Down Expand Up @@ -220,9 +219,8 @@ class FTLCluster {

uint8_t seed_;

float weighted_sum(const std::vector<float>& weights,
const std::function<float(unsigned int i)>& sumFunc,
const std::function<float(float, float)>& outFunc) const {
template <typename SumFunc, typename OutFunc>
float weighted_sum(const std::vector<float>& weights, SumFunc&& sumFunc, OutFunc&& outFunc) const {
float tot = 0;
float sumW = 0;
for (unsigned int i = 0; i < weights.size(); ++i) {
Expand All @@ -232,7 +230,8 @@ class FTLCluster {
return outFunc(tot, sumW);
}

float weighted_mean(const std::vector<float>& weights, const std::function<float(unsigned int)>& value) const {
template <typename Value>
float weighted_mean(const std::vector<float>& weights, Value&& value) const {
auto sumFunc = [&weights, value](unsigned int i) { return weights[i] * value(i); };
auto outFunc = [](float x, float y) {
if (y > 0)
Expand All @@ -243,7 +242,8 @@ class FTLCluster {
return weighted_sum(weights, sumFunc, outFunc);
}

float weighted_mean_error(const std::vector<float>& weights, const std::function<float(unsigned int)>& err) const {
template <typename Err>
float weighted_mean_error(const std::vector<float>& weights, Err&& err) const {
auto sumFunc = [&weights, err](unsigned int i) { return weights[i] * weights[i] * err(i) * err(i); };
auto outFunc = [](float x, float y) {
if (y > 0)
Expand Down
1 change: 0 additions & 1 deletion DataFormats/FTLRecHit/src/FTLCluster.cc

This file was deleted.

1 change: 0 additions & 1 deletion RecoLocalFastTime/FTLClusterizer/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<use name="Geometry/MTDGeometryBuilder"/>
<use name="DataFormats/Common"/>
<use name="TrackingTools/TrajectoryState"/>
<use name="clhep"/>
<export>
<lib name="1"/>
</export>
5 changes: 0 additions & 5 deletions RecoLocalFastTime/FTLClusterizer/interface/MTDCPEBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class MTDCPEBase : public MTDClusterParameterEstimator {
inline ReturnType getParameters(const FTLCluster& cl, const GeomDetUnit& det) const override {
DetParam const& dp = detParam(det);
ClusterParam cp(cl);
setTheClu(dp, cp);
auto tuple =
std::make_tuple(localPosition(dp, cp), localError(dp, cp), clusterTime(dp, cp), clusterTimeError(dp, cp));
return tuple;
Expand All @@ -81,8 +80,6 @@ class MTDCPEBase : public MTDClusterParameterEstimator {
virtual TimeValue clusterTime(DetParam const& dp, ClusterParam& cp) const;
virtual TimeValueError clusterTimeError(DetParam const& dp, ClusterParam& cp) const;

void fillDetParams();

protected:
//---------------------------------------------------------------------------
// Data members
Expand All @@ -92,8 +89,6 @@ class MTDCPEBase : public MTDClusterParameterEstimator {
const MTDGeometry& geom_; // geometry

protected:
void setTheClu(DetParam const& dp, ClusterParam& cp) const;

//---------------------------------------------------------------------------
// Cluster-level services.
//---------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MTDThresholdClusterizer : public MTDClusterizerBase {
const MTDTopology* topo,
FTLClusterCollection& output) override;

static void fillDescriptions(edm::ParameterSetDescription& desc);
static void fillPSetDescription(edm::ParameterSetDescription& desc);

private:
std::vector<FTLCluster::FTLHitPos> theSeeds; // cached seed pixels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ MTDClusterProducer::MTDClusterProducer(edm::ParameterSet const& conf)
etlHits_(consumes<FTLRecHitCollection>(conf.getParameter<edm::InputTag>("srcEndcap"))),
ftlbInstance_(conf.getParameter<std::string>("BarrelClusterName")),
ftleInstance_(conf.getParameter<std::string>("EndcapClusterName")),
clusterMode_(conf.getParameter<std::string>("ClusterMode")),
clusterizer_(nullptr) // the default, in case we fail to make one
{
clusterMode_(conf.getParameter<std::string>("ClusterMode")) {
//--- Declare to the EDM what kind of collections we will be making.
produces<FTLClusterCollection>(ftlbInstance_);
produces<FTLClusterCollection>(ftleInstance_);
Expand Down Expand Up @@ -104,7 +102,7 @@ void MTDClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& descri
desc.add<std::string>("BarrelClusterName", "FTLBarrel");
desc.add<std::string>("EndcapClusterName", "FTLEndcap");
desc.add<std::string>("ClusterMode", "MTDThresholdClusterizer");
MTDThresholdClusterizer::fillDescriptions(desc);
MTDThresholdClusterizer::fillPSetDescription(desc);
descriptions.add("mtdClusterProducer", desc);
}

Expand Down
15 changes: 4 additions & 11 deletions RecoLocalFastTime/FTLClusterizer/src/MTDCPEBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ using namespace std;
// A constructor run for generic and templates
//
//-----------------------------------------------------------------------------
MTDCPEBase::MTDCPEBase(edm::ParameterSet const& conf, const MTDGeometry& geom) : geom_(geom) { fillDetParams(); }

//-----------------------------------------------------------------------------
// Fill all variables which are constant for an event (geometry)
//-----------------------------------------------------------------------------
void MTDCPEBase::fillDetParams() {
MTDCPEBase::MTDCPEBase(edm::ParameterSet const& conf, const MTDGeometry& geom) : geom_(geom) {
//-----------------------------------------------------------------------------
// Fill all variables which are constant for an event (geometry)
//-----------------------------------------------------------------------------
auto const& dus = geom_.detUnits();
unsigned detectors = dus.size();
m_DetParams.resize(detectors);
Expand Down Expand Up @@ -58,11 +56,6 @@ void MTDCPEBase::fillDetParams() {
}
}

//-----------------------------------------------------------------------------
// One function to cache the variables common for one DetUnit.
//-----------------------------------------------------------------------------
void MTDCPEBase::setTheClu(DetParam const& dp, ClusterParam& cp) const {}

//------------------------------------------------------------------------
MTDCPEBase::DetParam const& MTDCPEBase::detParam(const GeomDetUnit& det) const { return m_DetParams.at(det.index()); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ MTDThresholdClusterizer::MTDThresholdClusterizer(edm::ParameterSet const& conf)
MTDThresholdClusterizer::~MTDThresholdClusterizer() {}

// Configuration descriptions
void MTDThresholdClusterizer::fillDescriptions(edm::ParameterSetDescription& desc) {
void MTDThresholdClusterizer::fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<double>("HitThreshold", 0.);
desc.add<double>("SeedThreshold", 0.);
desc.add<double>("ClusterThreshold", 0.);
Expand Down
115 changes: 49 additions & 66 deletions RecoLocalFastTime/FTLRecProducers/plugins/MTDTrackingRecHitProducer.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/Framework/interface/Event.h"
Expand All @@ -19,31 +19,18 @@

#include "FWCore/MessageLogger/interface/MessageLogger.h"

//#define DEBUG_ENABLED
#ifdef DEBUG_ENABLED
#define DEBUG(x) \
do { \
std::cout << x << std::endl; \
} while (0)
#else
#define DEBUG(x)
#endif

class MTDTrackingRecHitProducer : public edm::stream::EDProducer<> {
class MTDTrackingRecHitProducer : public edm::global::EDProducer<> {
public:
explicit MTDTrackingRecHitProducer(const edm::ParameterSet& ps);
~MTDTrackingRecHitProducer() override = default;
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

void produce(edm::Event& evt, const edm::EventSetup& es) override;
void run(edm::Handle<edmNew::DetSetVector<FTLCluster> > inputHandle, MTDTrackingDetSetVector& output);
void produce(edm::StreamID, edm::Event& evt, const edm::EventSetup& es) const override;

private:
const edm::EDGetTokenT<FTLClusterCollection> ftlbClusters_; // collection of barrel digis
const edm::EDGetTokenT<FTLClusterCollection> ftleClusters_; // collection of endcap digis

const MTDGeometry* geom_;
const MTDClusterParameterEstimator* cpe_;
edm::ESGetToken<MTDGeometry, MTDDigiGeometryRecord> mtdgeoToken_;
edm::ESGetToken<MTDClusterParameterEstimator, MTDCPERecord> cpeToken_;
};
Expand All @@ -64,70 +51,66 @@ void MTDTrackingRecHitProducer::fillDescriptions(edm::ConfigurationDescriptions&
descriptions.add("mtdTrackingRecHitProducer", desc);
}

void MTDTrackingRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& es) {
auto geom = es.getTransientHandle(mtdgeoToken_);
geom_ = geom.product();
void MTDTrackingRecHitProducer::produce(edm::StreamID, edm::Event& evt, const edm::EventSetup& es) const {
auto const& geom = es.getData(mtdgeoToken_);

auto cpe = es.getTransientHandle(cpeToken_);
cpe_ = cpe.product();
auto const& cpe = es.getData(cpeToken_);

edm::Handle<FTLClusterCollection> inputBarrel;
evt.getByToken(ftlbClusters_, inputBarrel);

edm::Handle<FTLClusterCollection> inputEndcap;
evt.getByToken(ftleClusters_, inputEndcap);

std::array<edm::Handle<FTLClusterCollection>, 2> inputHandle{{inputBarrel, inputEndcap}};

auto outputhits = std::make_unique<MTDTrackingDetSetVector>();
auto& theoutputhits = *outputhits;

run(inputBarrel, theoutputhits);
run(inputEndcap, theoutputhits);
//---------------------------------------------------------------------------
//! Iterate over DetUnits, then over Clusters and invoke the CPE on each,
//! and make a RecHit to store the result.
//---------------------------------------------------------------------------

for (auto const& theInput : inputHandle) {
const edmNew::DetSetVector<FTLCluster>& input = *theInput;

LogDebug("MTDTrackingRecHitProducer") << "inputCollection " << input.size();
for (const auto& DSVit : input) {
unsigned int detid = DSVit.detId();
DetId detIdObject(detid);
const auto genericDet = geom.idToDetUnit(detIdObject);
if (genericDet == nullptr) {
throw cms::Exception("MTDTrackingRecHitProducer")
<< "GeographicalID: " << std::hex << detid << " is invalid!" << std::dec << std::endl;
}

MTDTrackingDetSetVector::FastFiller recHitsOnDet(theoutputhits, detid);

for (const auto& clustIt : DSVit) {
LogDebug("MTDTrackingRcHitProducer") << "Cluster: size " << clustIt.size() << " " << clustIt.x() << ","
<< clustIt.y() << " " << clustIt.energy() << " " << clustIt.time();
MTDClusterParameterEstimator::ReturnType tuple = cpe.getParameters(clustIt, *genericDet);
LocalPoint lp(std::get<0>(tuple));
LocalError le(std::get<1>(tuple));

// Create a persistent edm::Ref to the cluster
edm::Ref<edmNew::DetSetVector<FTLCluster>, FTLCluster> cluster = edmNew::makeRefTo(theInput, &clustIt);
// Make a RecHit and add it to the DetSet
MTDTrackingRecHit hit(lp, le, *genericDet, cluster);
LogDebug("MTDTrackingRcHitProducer")
<< "MTD_TRH: " << hit.localPosition().x() << "," << hit.localPosition().y() << " : "
<< hit.localPositionError().xx() << "," << hit.localPositionError().yy() << " : " << hit.time() << " : "
<< hit.timeError();
// Now save it =================
recHitsOnDet.push_back(hit);
} // <-- End loop on Clusters
} // <-- End loop on DetUnits
LogDebug("MTDTrackingRcHitProducer") << "outputCollection " << theoutputhits.size();
}

evt.put(std::move(outputhits));
}

//---------------------------------------------------------------------------
//! Iterate over DetUnits, then over Clusters and invoke the CPE on each,
//! and make a RecHit to store the result.
//---------------------------------------------------------------------------
void MTDTrackingRecHitProducer::run(edm::Handle<FTLClusterCollection> inputHandle, MTDTrackingDetSetVector& output) {
const edmNew::DetSetVector<FTLCluster>& input = *inputHandle;
edmNew::DetSetVector<FTLCluster>::const_iterator DSViter = input.begin();

DEBUG("inputCollection " << input.size());
for (; DSViter != input.end(); DSViter++) {
unsigned int detid = DSViter->detId();
DetId detIdObject(detid);
const auto genericDet = geom_->idToDetUnit(detIdObject);
if (genericDet == nullptr) {
throw cms::Exception("MTDTrackingRecHitProducer")
<< "GeographicalID: " << std::hex << detid << " is invalid!" << std::dec << std::endl;
}

MTDTrackingDetSetVector::FastFiller recHitsOnDet(output, detid);

edmNew::DetSet<FTLCluster>::const_iterator clustIt = DSViter->begin(), clustEnd = DSViter->end();

for (; clustIt != clustEnd; clustIt++) {
DEBUG("Cluster: size " << clustIt->size() << " " << clustIt->x() << "," << clustIt->y() << " "
<< clustIt->energy() << " " << clustIt->time());
MTDClusterParameterEstimator::ReturnType tuple = cpe_->getParameters(*clustIt, *genericDet);
LocalPoint lp(std::get<0>(tuple));
LocalError le(std::get<1>(tuple));

// Create a persistent edm::Ref to the cluster
edm::Ref<edmNew::DetSetVector<FTLCluster>, FTLCluster> cluster = edmNew::makeRefTo(inputHandle, clustIt);
// Make a RecHit and add it to the DetSet
MTDTrackingRecHit hit(lp, le, *genericDet, cluster);
DEBUG("MTD_TRH: " << hit.localPosition().x() << "," << hit.localPosition().y() << " : "
<< hit.localPositionError().xx() << "," << hit.localPositionError().yy() << " : " << hit.time()
<< " : " << hit.timeError());
// Now save it =================
recHitsOnDet.push_back(hit);
} // <-- End loop on Clusters
} // <-- End loop on DetUnits
DEBUG("outputCollection " << output.size());
}

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(MTDTrackingRecHitProducer);
12 changes: 8 additions & 4 deletions RecoMTD/MeasurementDet/interface/MTDDetLayerMeasurements.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef MeasurementDet_MTDDetLayerMeasurements_H
#define MeasurementDet_MTDDetLayerMeasurements_H
#ifndef RecoMTD_MeasurementDet_MTDDetLayerMeasurements_H
#define RecoMTD_MeasurementDet_MTDDetLayerMeasurements_H

/** \class MTDDetLayerMeasurements
* The class to access recHits and TrajectoryMeasurements from DetLayer.
Expand Down Expand Up @@ -33,7 +33,7 @@ class MTDDetLayerMeasurements {
typedef std::pair<const GeomDet*, TrajectoryStateOnSurface> DetWithState;
typedef std::vector<GenericTransientTrackingRecHit::RecHitPointer> MTDRecHitContainer;

MTDDetLayerMeasurements(edm::InputTag mtdlabel, edm::ConsumesCollector& iC);
MTDDetLayerMeasurements(const edm::InputTag& mtdlabel, edm::ConsumesCollector& iC);

virtual ~MTDDetLayerMeasurements();

Expand Down Expand Up @@ -99,7 +99,11 @@ class MTDDetLayerMeasurements {
/// check that the event is set, and throw otherwise
void checkEvent() const;

edm::EDGetTokenT<MTDTrackingRecHit> mtdToken_;
// sort functions for containers provided by measurements methods
template <class T>
T sortResult(T&);

edm::EDGetTokenT<MTDTrackingRecHit> theMTDToken;

// caches that should get filled once per event
edm::Handle<edmNew::DetSetVector<MTDTrackingRecHit>> theMTDRecHits;
Expand Down
Loading