Skip to content

Commit

Permalink
Modernized DetIdAssociatorESProducer
Browse files Browse the repository at this point in the history
- removed framework constructs from DetIdAssociators
- created DetIdAssociatorMakers which get configurations from
  the ParameterSet, set what EventSetup data products will be
  consumed and then create the appropriate DetIdAssociator.
  • Loading branch information
Dr15Jones committed May 30, 2019
1 parent 5b62bf9 commit f95dfae
Show file tree
Hide file tree
Showing 22 changed files with 532 additions and 80 deletions.
4 changes: 0 additions & 4 deletions TrackingTools/TrackAssociator/interface/DetIdAssociator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixStateInfo.h"
#include "TrackingTools/TrackAssociator/interface/FiducialVolume.h"
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include "TrackingTools/Records/interface/DetIdAssociatorRecord.h"
#include <set>
#include <vector>

Expand Down Expand Up @@ -116,11 +115,8 @@ class DetIdAssociator{
/// get active detector volume
const FiducialVolume& volume() const;

virtual void setGeometry(const DetIdAssociatorRecord&) = 0;
virtual const GeomDet* getGeomDet(const DetId&) const = 0;

virtual void setConditions(const DetIdAssociatorRecord&) {};

virtual const char* name() const = 0;

protected:
Expand Down
7 changes: 0 additions & 7 deletions TrackingTools/TrackAssociator/plugins/CaloDetIdAssociator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,6 @@ bool CaloDetIdAssociator::crossedElement(const GlobalPoint& point1,
return false;
}

void CaloDetIdAssociator::setGeometry(const DetIdAssociatorRecord& iRecord)
{
edm::ESHandle<CaloGeometry> geometryH;
iRecord.getRecord<CaloGeometryRecord>().get(geometryH);
setGeometry(geometryH.product());
}

void CaloDetIdAssociator::check_setup() const
{
DetIdAssociator::check_setup();
Expand Down
15 changes: 2 additions & 13 deletions TrackingTools/TrackAssociator/plugins/CaloDetIdAssociator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,17 @@
//

#include "TrackingTools/TrackAssociator/interface/DetIdAssociator.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
#include "DataFormats/DetId/interface/DetId.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "TrackingTools/Records/interface/DetIdAssociatorRecord.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

class CaloDetIdAssociator: public DetIdAssociator{
public:
CaloDetIdAssociator():DetIdAssociator(72, 70 ,0.087),geometry_(nullptr){};
CaloDetIdAssociator(const int nPhi, const int nEta, const double etaBinSize)
:DetIdAssociator(nPhi, nEta, etaBinSize),geometry_(nullptr){};

CaloDetIdAssociator(const edm::ParameterSet& pSet)
:DetIdAssociator(pSet.getParameter<int>("nPhi"),pSet.getParameter<int>("nEta"),pSet.getParameter<double>("etaBinSize")),geometry_(nullptr){};

virtual void setGeometry(const CaloGeometry* ptr) { geometry_ = ptr; };

void setGeometry(const DetIdAssociatorRecord& iRecord) override;
CaloDetIdAssociator(const int nPhi, const int nEta, const double etaBinSize, CaloGeometry const* geom)
:DetIdAssociator(nPhi, nEta, etaBinSize),geometry_(geom){};

const GeomDet* getGeomDet(const DetId& id) const override { return nullptr; };

Expand Down
55 changes: 55 additions & 0 deletions TrackingTools/TrackAssociator/plugins/CaloDetIdAssociatorMaker.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// -*- C++ -*-
//
// Package: TrackingTools/TrackAssociator
// Class : CaloDetIdAssociatorMaker
//
// Implementation:
// [Notes on implementation]
//
// Original Author: Christopher Jones
// Created: Thu, 30 May 2019 15:05:57 GMT
//

// system include files

// user include files
#include "CaloDetIdAssociatorMaker.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "TrackingTools/Records/interface/DetIdAssociatorRecord.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "CaloDetIdAssociator.h"

//
// constants, enums and typedefs
//

//
// static data member definitions
//

//
// constructors and destructor
//
CaloDetIdAssociatorMaker::CaloDetIdAssociatorMaker(edm::ParameterSet const& pSet,
edm::ESConsumesCollectorT<DetIdAssociatorRecord>&& iCollector):
geomToken_{ iCollector.consumesFrom<CaloGeometry, CaloGeometryRecord>()},
etaBinSize{pSet.getParameter<double>("etaBinSize")},
nPhi{pSet.getParameter<int>("nPhi")},
nEta{pSet.getParameter<int>("nEta")}
{
}

std::unique_ptr<DetIdAssociator>
CaloDetIdAssociatorMaker::make(const DetIdAssociatorRecord& iRecord) const {
return make(iRecord.get(geomToken_), nPhi, nEta, etaBinSize);
}

std::unique_ptr<DetIdAssociator>
CaloDetIdAssociatorMaker::make(CaloGeometry const& iGeom, int nPhi, int nEta, double etaBinSize ) const {
return std::unique_ptr<DetIdAssociator>(
new CaloDetIdAssociator(nPhi, nEta, etaBinSize, &iGeom)
);
}


55 changes: 55 additions & 0 deletions TrackingTools/TrackAssociator/plugins/CaloDetIdAssociatorMaker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#ifndef TrackingTools_TrackAssociator_CaloDetIdAssociatorMaker_h
#define TrackingTools_TrackAssociator_CaloDetIdAssociatorMaker_h
// -*- C++ -*-
//
// Package: TrackingTools/TrackAssociator
// Class : CaloDetIdAssociatorMaker
//
/**\class CaloDetIdAssociatorMaker CaloDetIdAssociatorMaker.h "CaloDetIdAssociatorMaker.h"
Description: [one line class summary]
Usage:
<usage>
*/
//
// Original Author: Christopher Jones
// Created: Thu, 30 May 2019 14:59:09 GMT
//

// system include files
#include <memory>

// user include files
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ESConsumesCollector.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "DetIdAssociatorMaker.h"

// forward declarations
class DetIdAssociator;
class DetIdAssociatorRecord;
class CaloGeometry;
class CaloGeometryRecord;

class CaloDetIdAssociatorMaker : public DetIdAssociatorMaker
{

public:
CaloDetIdAssociatorMaker(edm::ParameterSet const&,
edm::ESConsumesCollectorT<DetIdAssociatorRecord>&& );

// ---------- const member functions ---------------------
std::unique_ptr<DetIdAssociator> make(const DetIdAssociatorRecord&) const final;

private:
virtual std::unique_ptr<DetIdAssociator> make(CaloGeometry const&, int nPhi, int nEta, double etaBinSize ) const;
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geomToken_;
const double etaBinSize;
const int nPhi;
const int nEta;
};


#endif
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "TrackingTools/TrackAssociator/interface/DetIdAssociator.h"
#include "DetIdAssociatorFactory.h"
#include "DetIdAssociatorMaker.h"

#include "TrackingTools/Records/interface/DetIdAssociatorRecord.h"

Expand All @@ -43,8 +44,8 @@ class DetIdAssociatorESProducer : public edm::ESProducer {

ReturnType produce(const DetIdAssociatorRecord&);
private:
std::string cName;
edm::ParameterSet pSet;
const std::string cName;
std::unique_ptr<const DetIdAssociatorMaker> maker_;
};

//
Expand All @@ -58,11 +59,10 @@ class DetIdAssociatorESProducer : public edm::ESProducer {
//
// constructors and destructor
//
DetIdAssociatorESProducer::DetIdAssociatorESProducer(const edm::ParameterSet& iConfig)
DetIdAssociatorESProducer::DetIdAssociatorESProducer(const edm::ParameterSet& iConfig):
cName {iConfig.getParameter<std::string>("ComponentName") },
maker_{ DetIdAssociatorFactory::get()->create(cName, iConfig, setWhatProduced(this, cName) ) }
{
cName =iConfig.getParameter<std::string>("ComponentName");
pSet = iConfig;
setWhatProduced(this, cName);
}


Expand All @@ -81,9 +81,7 @@ DetIdAssociatorESProducer::produce(const DetIdAssociatorRecord& iRecord)
{
using namespace edm::es;
LogTrace("TrackAssociator") << "Making DetIdAssociatorRecord with label: " << cName;
ReturnType dia(DetIdAssociatorFactory::get()->create(cName, pSet));
dia->setGeometry(iRecord);
dia->setConditions(iRecord);
ReturnType dia = maker_->make(iRecord);
dia->buildMap();
LogTrace("TrackAssociator") << "Map id built for DetIdAssociatorRecord with label: " << cName;
return dia;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#define TrackingTools_TrackAssociator_DetIdAssociatorFactory_h

#include "FWCore/PluginManager/interface/PluginFactory.h"
#include "TrackingTools/TrackAssociator/interface/DetIdAssociator.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ESConsumesCollector.h"
#include "DetIdAssociatorMaker.h"

typedef edmplugin::PluginFactory<DetIdAssociator * ( const edm::ParameterSet& pSet )> DetIdAssociatorFactory;
typedef edmplugin::PluginFactory<DetIdAssociatorMaker * ( const edm::ParameterSet& pSet, edm::ESConsumesCollectorT<DetIdAssociatorRecord>&& )> DetIdAssociatorFactory;

#endif
53 changes: 53 additions & 0 deletions TrackingTools/TrackAssociator/plugins/DetIdAssociatorMaker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef TrackingTools_TrackAssociator_DetIdAssociatorMaker_h
#define TrackingTools_TrackAssociator_DetIdAssociatorMaker_h
// -*- C++ -*-
//
// Package: TrackingTools/TrackAssociator
// Class : DetIdAssociatorMaker
//
/**\class DetIdAssociatorMaker DetIdAssociatorMaker.h "DetIdAssociatorMaker.h"
Description: [one line class summary]
Usage:
<usage>
*/
//
// Original Author: Christopher Jones
// Created: Thu, 30 May 2019 14:52:58 GMT
//

// system include files

// user include files

// forward declarations
class DetIdAssociator;
class DetIdAssociatorRecord;

class DetIdAssociatorMaker
{

public:
DetIdAssociatorMaker() = default;
virtual ~DetIdAssociatorMaker() = default;

// ---------- const member functions ---------------------
virtual std::unique_ptr<DetIdAssociator> make(const DetIdAssociatorRecord&) const = 0;

// ---------- static member functions --------------------

// ---------- member functions ---------------------------

private:
DetIdAssociatorMaker(const DetIdAssociatorMaker&) = delete;

const DetIdAssociatorMaker& operator=(const DetIdAssociatorMaker&) = delete;

// ---------- member data --------------------------------

};


#endif
4 changes: 2 additions & 2 deletions TrackingTools/TrackAssociator/plugins/EcalDetIdAssociator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
class EcalDetIdAssociator: public CaloDetIdAssociator{
public:
EcalDetIdAssociator():CaloDetIdAssociator(360,300,0.02){};
EcalDetIdAssociator():CaloDetIdAssociator(360,300,0.02,nullptr){};

EcalDetIdAssociator(const edm::ParameterSet& pSet):CaloDetIdAssociator(pSet){};
using CaloDetIdAssociator::CaloDetIdAssociator;

const char* name() const override { return "ECAL"; }

Expand Down
43 changes: 43 additions & 0 deletions TrackingTools/TrackAssociator/plugins/EcalDetIdAssociatorMaker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef TrackingTools_TrackAssociator_EcalDetIdAssociatorMaker_h
#define TrackingTools_TrackAssociator_EcalDetIdAssociatorMaker_h
// -*- C++ -*-
//
// Package: TrackingTools/TrackAssociator
// Class : EcalDetIdAssociatorMaker
//
/**\class EcalDetIdAssociatorMaker EcalDetIdAssociatorMaker.h "EcalDetIdAssociatorMaker.h"
Description: [one line class summary]
Usage:
<usage>
*/
//
// Original Author: Christopher Jones
// Created: Thu, 30 May 2019 16:11:48 GMT
//

// system include files

// user include files

// forward declarations
#include "CaloDetIdAssociatorMaker.h"
#include "EcalDetIdAssociator.h"

class EcalDetIdAssociatorMaker : public CaloDetIdAssociatorMaker
{

public:
using CaloDetIdAssociatorMaker::CaloDetIdAssociatorMaker;

private:
std::unique_ptr<DetIdAssociator> make(CaloGeometry const& geom, int nPhi, int nEta, double etaBinSize ) const final {
return std::unique_ptr<DetIdAssociator>( new EcalDetIdAssociator(nPhi,nEta, etaBinSize, &geom) );
}

};


#endif
4 changes: 2 additions & 2 deletions TrackingTools/TrackAssociator/plugins/HODetIdAssociator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
class HODetIdAssociator: public CaloDetIdAssociator{
public:
HODetIdAssociator():CaloDetIdAssociator(72,30,0.087){};
HODetIdAssociator():CaloDetIdAssociator(72,30,0.087, nullptr){};

HODetIdAssociator(const edm::ParameterSet& pSet):CaloDetIdAssociator(pSet){};
using CaloDetIdAssociator::CaloDetIdAssociator;

const char* name() const override { return "HO"; }

Expand Down
Loading

0 comments on commit f95dfae

Please sign in to comment.