Skip to content

Commit

Permalink
Merge pull request cms-sw#2844 from dr4kan/GlobalTT_to_consumes
Browse files Browse the repository at this point in the history
RecoMuon -- migration to "consumes" of RecoMuon/GlobalTrackingTools
  • Loading branch information
nclopezo committed Mar 17, 2014
2 parents bd94f60 + b7dd481 commit 71873e9
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 65 deletions.
3 changes: 2 additions & 1 deletion FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ FastTSGFromL2Muon::beginRun(edm::Run const& run, edm::EventSetup const& es)
//region builder
edm::ParameterSet regionBuilderPSet =
theConfig.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet,theService);
edm::ConsumesCollector iC = consumesCollector();
theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet,theService,iC);

/*
if(useTFileService_) {
Expand Down
2 changes: 1 addition & 1 deletion RecoHI/HiMuonAlgos/plugins/HIMuonTrackingRegionProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class HIMuonTrackingRegionProducer : public TrackingRegionProducer {

// initialize region builder
edm::ParameterSet regionBuilderPSet = cfg.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet);
theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet,iC);

// initialize muon service proxy
edm::ParameterSet servicePSet = cfg.getParameter<edm::ParameterSet>("ServiceParameters");
Expand Down
6 changes: 3 additions & 3 deletions RecoMuon/GlobalMuonProducer/src/TevMuonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ TevMuonProducer::TevMuonProducer(const ParameterSet& parameterSet) {

// the services
theService = new MuonServiceProxy(serviceParameters);

edm::ConsumesCollector iC = consumesCollector();

// TrackRefitter parameters
ParameterSet refitterParameters = parameterSet.getParameter<ParameterSet>("RefitterParameters");
theRefitter = new GlobalMuonRefitter(refitterParameters, theService);
theRefitter = new GlobalMuonRefitter(refitterParameters, theService, iC);

// TrackLoader parameters
ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
edm::ConsumesCollector iC = consumesCollector();
theTrackLoader = new MuonTrackLoader(trackLoaderParameters,iC,theService);

theRefits = parameterSet.getParameter< std::vector<std::string> >("Refits");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ using namespace edm;
GlobalMuonTrajectoryBuilder::GlobalMuonTrajectoryBuilder(const edm::ParameterSet& par,
const MuonServiceProxy* service,
edm::ConsumesCollector& iC
) : GlobalTrajectoryBuilderBase(par, service)
) : GlobalTrajectoryBuilderBase(par, service, iC)

{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@
#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
#include "DataFormats/CSCRecHit/interface/CSCSegment.h"
#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"


class ChamberSegmentUtility {

public:

ChamberSegmentUtility(const edm::Event&, const edm::EventSetup&);
ChamberSegmentUtility();

void initCSU(const edm::Handle<DTRecSegment4DCollection>&, const edm::Handle<CSCSegmentCollection>&);

// Get the 4D segments in a CSC chamber
std::vector<CSCSegment> getCSCSegmentsInChamber(CSCDetId);
Expand Down Expand Up @@ -62,6 +65,9 @@ class ChamberSegmentUtility {
edm::ESHandle<DTGeometry> dtGeom;
edm::Handle<DTRecSegment4DCollection> all4DSegments;

// edm::EDGetTokenT<CSCSegmentCollection> CSCSegmentsToken;
// edm::EDGetTokenT<DTRecSegment4DCollection> all4DSegmentsToken;

std::vector<DTRecSegment4D> dtseg;
std::vector<CSCSegment> cscseg;
std::map<int, std::vector<DTRecSegment4D> > dtsegMap;
Expand Down
8 changes: 7 additions & 1 deletion RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
#include "RecoMuon/Navigation/interface/DirectMuonNavigation.h"
#include "Alignment/MuonAlignment/interface/MuonAlignment.h"
#include "RecoMuon/GlobalTrackingTools/interface/ChamberSegmentUtility.h"


class DynamicTruncation {
Expand All @@ -53,6 +54,11 @@ class DynamicTruncation {

~DynamicTruncation();

void setProd(const edm::Handle<DTRecSegment4DCollection>& DTSegProd,
const edm::Handle<CSCSegmentCollection>& CSCSegProd) {
getSegs->initCSU(DTSegProd, CSCSegProd);
}

// Just one thr for DT and one for CSC
void setThr(int, int, int);

Expand Down Expand Up @@ -92,7 +98,7 @@ class DynamicTruncation {
const edm::EventSetup* theSetup;
std::vector<double> estimators;
TrajectoryStateOnSurface currentState;

ChamberSegmentUtility* getSegs;
std::map<DTChamberId, GlobalError> dtApeMap;
std::map<CSCDetId, GlobalError> cscApeMap;
};
Expand Down
14 changes: 11 additions & 3 deletions RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@
*/

#include "DataFormats/Common/interface/Handle.h"

#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "RecoMuon/TrackingTools/interface/MuonTrajectoryBuilder.h"
#include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
#include "TrackingTools/TrackRefitter/interface/TrackTransformer.h"
#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"

namespace edm {class Event;}
namespace reco {class TransientTrack;}
Expand Down Expand Up @@ -57,7 +58,7 @@ class GlobalMuonRefitter {
public:

/// constructor with Parameter Set and MuonServiceProxy
GlobalMuonRefitter(const edm::ParameterSet&, const MuonServiceProxy*);
GlobalMuonRefitter(const edm::ParameterSet&, const MuonServiceProxy*, edm::ConsumesCollector&);

/// destructor
virtual ~GlobalMuonRefitter();
Expand Down Expand Up @@ -131,6 +132,8 @@ class GlobalMuonRefitter {
edm::InputTag theCSCRecHitLabel;
edm::Handle<DTRecHitCollection> theDTRecHits;
edm::Handle<CSCRecHit2DCollection> theCSCRecHits;
edm::EDGetTokenT<DTRecHitCollection> theDTRecHitToken;
edm::EDGetTokenT<CSCRecHit2DCollection> theCSCRecHitToken;

int theSkipStation;
int theTrackerSkipSystem;
Expand Down Expand Up @@ -159,5 +162,10 @@ class GlobalMuonRefitter {

const MuonServiceProxy* theService;
const edm::Event* theEvent;

edm::EDGetTokenT<CSCSegmentCollection> CSCSegmentsToken;
edm::EDGetTokenT<DTRecSegment4DCollection> all4DSegmentsToken;
edm::Handle<CSCSegmentCollection> CSCSegments;
edm::Handle<DTRecSegment4DCollection> all4DSegments;
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "RecoMuon/TrackingTools/interface/MuonTrajectoryBuilder.h"
#include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

class RectangularEtaPhiTrackingRegion;
class TrajectoryStateOnSurface;
Expand Down Expand Up @@ -65,7 +66,7 @@ class GlobalTrajectoryBuilderBase : public MuonTrajectoryBuilder {
public:

/// constructor with Parameter Set and MuonServiceProxy
GlobalTrajectoryBuilderBase(const edm::ParameterSet&, const MuonServiceProxy*);
GlobalTrajectoryBuilderBase(const edm::ParameterSet&, const MuonServiceProxy*, edm::ConsumesCollector&);

/// destructor
virtual ~GlobalTrajectoryBuilderBase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"

class MuonServiceProxy;
class RectangularEtaPhiTrackingRegion;
Expand All @@ -30,9 +33,10 @@ class MuonTrackingRegionBuilder {
public:

/// constructor
MuonTrackingRegionBuilder(const edm::ParameterSet&);
MuonTrackingRegionBuilder(const edm::ParameterSet&, edm::ConsumesCollector&);
MuonTrackingRegionBuilder(const edm::ParameterSet&par,
const MuonServiceProxy*service){ build(par);init(service);}
const MuonServiceProxy*service,
edm::ConsumesCollector& iC){ build(par, iC);init(service);}
void init(const MuonServiceProxy*);

/// destructor
Expand All @@ -48,7 +52,7 @@ class MuonTrackingRegionBuilder {
virtual void setEvent(const edm::Event&);

private:
void build(const edm::ParameterSet&);
void build(const edm::ParameterSet&, edm::ConsumesCollector&);

edm::InputTag theBeamSpotTag; // beam spot
edm::InputTag theVertexCollTag; // vertex collection
Expand Down Expand Up @@ -76,5 +80,7 @@ class MuonTrackingRegionBuilder {

double theOnDemand;
std::string theMeasurementTrackerName;
edm::EDGetTokenT<reco::BeamSpot> bsHandleToken;
edm::EDGetTokenT<reco::VertexCollection> vertexCollectionToken;
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@

#include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
#include "TrackingTools/PatternTools/interface/Trajectory.h"
#include "DataFormats/MuonReco/interface/MuonQuality.h"
#include "DataFormats/MuonReco/interface/MuonTrackLinks.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"

#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"

Expand All @@ -36,16 +32,20 @@ GlobalTrackQualityProducer::GlobalTrackQualityProducer(const edm::ParameterSet&
theService = new MuonServiceProxy(serviceParameters);

// TrackRefitter parameters
edm::ConsumesCollector iC = consumesCollector();
edm::ParameterSet refitterParameters = iConfig.getParameter<edm::ParameterSet>("RefitterParameters");
theGlbRefitter = new GlobalMuonRefitter(refitterParameters, theService);
theGlbRefitter = new GlobalMuonRefitter(refitterParameters, theService, iC);

edm::ParameterSet trackMatcherPSet = iConfig.getParameter<edm::ParameterSet>("GlobalMuonTrackMatcher");
theGlbMatcher = new GlobalMuonTrackMatcher(trackMatcherPSet,theService);

double maxChi2 = iConfig.getParameter<double>("MaxChi2");
double nSigma = iConfig.getParameter<double>("nSigma");
theEstimator = new Chi2MeasurementEstimator(maxChi2,nSigma);


glbMuonsToken=consumes<reco::TrackCollection>(inputCollection_);
linkCollectionToken=consumes<reco::MuonTrackLinksCollection>(inputLinksCollection_);

produces<edm::ValueMap<reco::MuonQuality> >();
}

Expand All @@ -69,10 +69,10 @@ GlobalTrackQualityProducer::produce(edm::Event& iEvent, const edm::EventSetup& i

// Take the GLB muon container(s)
edm::Handle<reco::TrackCollection> glbMuons;
iEvent.getByLabel(inputCollection_,glbMuons);
iEvent.getByToken(glbMuonsToken,glbMuons);

edm::Handle<reco::MuonTrackLinksCollection> linkCollectionHandle;
iEvent.getByLabel(inputLinksCollection_, linkCollectionHandle);
iEvent.getByToken(linkCollectionToken,linkCollectionHandle);

//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/MuonReco/interface/MuonQuality.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"
#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
#include "RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h"
#include "RecoMuon/GlobalTrackingTools/interface/GlobalMuonTrackMatcher.h"

#include "DataFormats/MuonReco/interface/MuonTrackLinks.h"
#include "TrackingTools/DetLayers/interface/MeasurementEstimator.h"
#include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"

Expand All @@ -37,6 +38,8 @@ class GlobalTrackQualityProducer : public edm::EDProducer {

edm::InputTag inputCollection_;
edm::InputTag inputLinksCollection_;
edm::EDGetTokenT<reco::TrackCollection> glbMuonsToken;
edm::EDGetTokenT<reco::MuonTrackLinksCollection> linkCollectionToken;
MuonServiceProxy* theService;
GlobalMuonRefitter* theGlbRefitter;
GlobalMuonTrackMatcher* theGlbMatcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# second int --> CSC threshold
# third int --> if 1 APEs are used
DYTthrs = cms.vint32(25, 10, 1),

# muon station to be skipped
SkipStation = cms.int32(-1),

Expand Down
16 changes: 7 additions & 9 deletions RecoMuon/GlobalTrackingTools/src/ChamberSegmentUtility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ using namespace edm;
using namespace std;
using namespace reco;

ChamberSegmentUtility::ChamberSegmentUtility(const edm::Event& Event, const edm::EventSetup& Setup)
{
ChamberSegmentUtility::ChamberSegmentUtility()
{}

Setup.get<MuonGeometryRecord>().get(cscGeometry);
Event.getByLabel("cscSegments", CSCSegments);
Setup.get<MuonGeometryRecord>().get(dtGeom);
Event.getByLabel("dt4DSegments", all4DSegments);
void ChamberSegmentUtility::initCSU(const edm::Handle<DTRecSegment4DCollection>& DTSegProd,
const edm::Handle<CSCSegmentCollection>& CSCSegProd) {

all4DSegments = DTSegProd;
CSCSegments = CSCSegProd;

unsigned int index = 0;
for ( CSCSegmentCollection::id_iterator chamberId = CSCSegments->id_begin();
Expand All @@ -65,15 +66,12 @@ ChamberSegmentUtility::ChamberSegmentUtility(const edm::Event& Event, const edm:

for (DTRecSegment4DCollection::const_iterator segment = range.first;
segment!=range.second; ++segment){

if ((*chamberIdIt).station() == 1) dtsegMap[1].push_back(*segment);
if ((*chamberIdIt).station() == 2) dtsegMap[2].push_back(*segment);
if ((*chamberIdIt).station() == 3) dtsegMap[3].push_back(*segment);
if ((*chamberIdIt).station() == 4) dtsegMap[4].push_back(*segment);
}
}


}


Expand Down
16 changes: 7 additions & 9 deletions RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h"
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
#include "TrackingTools/TrackFitters/interface/RecHitLessByDet.h"
#include "RecoMuon/GlobalTrackingTools/interface/ChamberSegmentUtility.h"
#include "TrackingTools/Records/interface/TransientRecHitRecord.h"
#include "RecoMuon/DetLayers/interface/MuonDetLayerGeometry.h"
#include "RecoMuon/Records/interface/MuonRecoGeometryRecord.h"
Expand All @@ -27,7 +26,6 @@
#include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
#include "DataFormats/TrackingRecHit/interface/AlignmentPositionError.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"

#include "CondFormats/Alignment/interface/Alignments.h"
#include "CondFormats/Alignment/interface/AlignTransform.h"
#include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h"
Expand Down Expand Up @@ -58,6 +56,7 @@ DynamicTruncation::DynamicTruncation(const edm::Event& event, const MuonServiceP
theService.eventSetup().get<MuonRecoGeometryRecord>().get(navMuon);
theService.eventSetup().get<IdealMagneticFieldRecord>().get(magfield);
navigation = new DirectMuonNavigation(theService.detLayerGeometry());
getSegs = new ChamberSegmentUtility();
}


Expand Down Expand Up @@ -203,7 +202,6 @@ void DynamicTruncation::compatibleDets(TrajectoryStateOnSurface& tsos, map<int,


void DynamicTruncation::filteringAlgo(map<int, std::vector<DetId> >& detMap) {
ChamberSegmentUtility getSegs(*theEvent, *theSetup);
for (unsigned int iDet = 0; iDet < detMap.size(); ++iDet) {
double bestLayerValue = MAX_THR;
bool isDTorCSC = false;
Expand All @@ -218,8 +216,8 @@ void DynamicTruncation::filteringAlgo(map<int, std::vector<DetId> >& detMap) {
DTChamberId DTid(id);

std::vector<DTRecSegment4D> allDTsegs;
std::map<int, std::vector<DTRecSegment4D> >::const_iterator dtIter = getSegs.getDTlist().find(DTid.station());
if (dtIter != getSegs.getDTlist().end()){
std::map<int, std::vector<DTRecSegment4D> >::const_iterator dtIter = getSegs->getDTlist().find(DTid.station());
if (dtIter != getSegs->getDTlist().end()){
allDTsegs = dtIter->second;
}
std::vector<DTRecSegment4D>::size_type sz = allDTsegs.size();
Expand All @@ -241,7 +239,7 @@ void DynamicTruncation::filteringAlgo(map<int, std::vector<DetId> >& detMap) {
if (bestChamberValue >= DTThr || bestChamberValue > bestLayerValue) continue;
layerRH.clear(); layerSEG.clear();
layerSEG.push_back(theMuonRecHitBuilder->build(&bestDTSeg));
std::vector<DTRecHit1D> DTrh = getSegs.getDTRHmap(bestDTSeg);
std::vector<DTRecHit1D> DTrh = getSegs->getDTRHmap(bestDTSeg);
for (std::vector<DTRecHit1D>::iterator it = DTrh.begin(); it != DTrh.end(); it++) {
layerRH.push_back(theMuonRecHitBuilder->build(&*it));
}
Expand All @@ -252,8 +250,8 @@ void DynamicTruncation::filteringAlgo(map<int, std::vector<DetId> >& detMap) {
CSCDetId CSCid(id);

std::vector<CSCSegment> allCSCsegs;
std::map<int, std::vector<CSCSegment> >::const_iterator cscIter = getSegs.getCSClist().find(CSCid.station());
if (cscIter != getSegs.getCSClist().end()){
std::map<int, std::vector<CSCSegment> >::const_iterator cscIter = getSegs->getCSClist().find(CSCid.station());
if (cscIter != getSegs->getCSClist().end()){
allCSCsegs = cscIter->second;
}

Expand All @@ -276,7 +274,7 @@ void DynamicTruncation::filteringAlgo(map<int, std::vector<DetId> >& detMap) {
if (bestChamberValue >= CSCThr || bestChamberValue > bestLayerValue) continue;
layerRH.clear(); layerSEG.clear();
layerSEG.push_back(theMuonRecHitBuilder->build(&bestCSCSeg));
std::vector<CSCRecHit2D> CSCrh = getSegs.getCSCRHmap(bestCSCSeg);
std::vector<CSCRecHit2D> CSCrh = getSegs->getCSCRHmap(bestCSCSeg);
for (std::vector<CSCRecHit2D>::iterator it = CSCrh.begin(); it != CSCrh.end(); ++it) {
layerRH.push_back(theMuonRecHitBuilder->build(&*it));
}
Expand Down
Loading

0 comments on commit 71873e9

Please sign in to comment.