Skip to content

Commit

Permalink
Merge pull request #36208 from bsunanda/Run3-gex99B
Browse files Browse the repository at this point in the history
Run3-gex99B Use ESGetToekn in some of the codes in SimTracker/Track(Vertex)Association
  • Loading branch information
cmsbuild committed Nov 23, 2021
2 parents d232381 + aad6e71 commit 9583b99
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 142 deletions.
1 change: 0 additions & 1 deletion SimTracker/TrackAssociation/plugins/MCTrackMatcher.cc
Expand Up @@ -36,7 +36,6 @@ class MCTrackMatcher : public edm::global::EDProducer<> {
};

#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/EDMException.h"
Expand Down
Expand Up @@ -14,8 +14,6 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/Framework/interface/ESHandle.h"

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

#include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h"
Expand Down
1 change: 0 additions & 1 deletion SimTracker/TrackAssociation/plugins/TrackMCQuality.cc
Expand Up @@ -27,7 +27,6 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h"
Expand Down
1 change: 0 additions & 1 deletion SimTracker/TrackAssociation/src/ParametersDefinerForTP.cc
Expand Up @@ -7,7 +7,6 @@
#include "TrackingTools/PatternTools/interface/TSCBLBuilderNoMaterial.h"
#include "TrackingTools/PatternTools/interface/TSCPBuilderNoMaterial.h"
#include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
#include <FWCore/Framework/interface/ESHandle.h>
class TrajectoryStateClosestToBeamLineBuilder;

ParametersDefinerForTP::ParametersDefinerForTP(const edm::InputTag &beamspot, edm::ConsumesCollector iC)
Expand Down
33 changes: 26 additions & 7 deletions SimTracker/TrackAssociation/test/testTrackAssociator.cc
@@ -1,22 +1,43 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"

#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
#include "SimTracker/TrackAssociation/test/testTrackAssociator.h"

#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h"

#include <iostream>
#include <map>
#include <memory>
#include <set>
#include <string>

// class TrackAssociator;
class TrackAssociatorByHits;
class TrackerHitAssociator;

namespace reco {
class TrackToTrackingParticleAssociator;
}

class testTrackAssociator : public edm::one::EDAnalyzer<> {
public:
testTrackAssociator(const edm::ParameterSet &conf);
~testTrackAssociator() override = default;
void beginJob() override {}
void analyze(const edm::Event &, const edm::EventSetup &) override;

private:
reco::TrackToTrackingParticleAssociator const *associatorByChi2;
reco::TrackToTrackingParticleAssociator const *associatorByHits;
edm::InputTag tracksTag, tpTag, simtracksTag, simvtxTag;
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> tokenMF_;
};

using namespace reco;
using namespace std;
using namespace edm;
Expand All @@ -26,13 +47,11 @@ testTrackAssociator::testTrackAssociator(edm::ParameterSet const &conf) {
tpTag = conf.getParameter<edm::InputTag>("tpTag");
simtracksTag = conf.getParameter<edm::InputTag>("simtracksTag");
simvtxTag = conf.getParameter<edm::InputTag>("simvtxTag");
tokenMF_ = esConsumes<MagneticField, IdealMagneticFieldRecord>();
}

testTrackAssociator::~testTrackAssociator() {}

void testTrackAssociator::analyze(const edm::Event &event, const edm::EventSetup &setup) {
edm::ESHandle<MagneticField> theMF;
setup.get<IdealMagneticFieldRecord>().get(theMF);
//const auto &theMF = setup.getHandle(tokenMF_);
edm::Handle<reco::TrackToTrackingParticleAssociator> theChiAssociator;
event.getByLabel("trackAssociatorByChi2", theChiAssociator);
associatorByChi2 = theChiAssociator.product();
Expand Down
33 changes: 0 additions & 33 deletions SimTracker/TrackAssociation/test/testTrackAssociator.h

This file was deleted.

90 changes: 84 additions & 6 deletions SimTracker/VertexAssociation/test/testVertexAssociator.cc
@@ -1,4 +1,8 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"

Expand All @@ -9,14 +13,89 @@
#include "SimDataFormats/Associations/interface/VertexToTrackingVertexAssociator.h"
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
#include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h"
#include "SimTracker/VertexAssociation/test/testVertexAssociator.h"

#include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
#include "DataFormats/Math/interface/Vector.h"
#include "DataFormats/Math/interface/LorentzVector.h"
#include <Math/GenVector/PxPyPzE4D.h>
#include <Math/GenVector/PxPyPzM4D.h>

#include "TFile.h"
#include "TH1F.h"
#include "TMath.h"
#include "TROOT.h"
#include "TTree.h"

#include <cmath>
#include <iostream>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>

namespace reco {
class TrackToTrackingParticleAssociator;
class VertexToTrackingVertexAssociator;
} // namespace reco

class testVertexAssociator : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
testVertexAssociator(const edm::ParameterSet &conf);
~testVertexAssociator() override = default;
void beginJob() override;
void endJob() override;
void analyze(const edm::Event &, const edm::EventSetup &) override;

private:
const reco::TrackToTrackingParticleAssociator *associatorByChi2;
const reco::TrackToTrackingParticleAssociator *associatorByHits;
const reco::VertexToTrackingVertexAssociator *associatorByTracks;

edm::InputTag vertexCollection_;
edm::EDGetTokenT<reco::VertexToTrackingVertexAssociator> associatorByTracksToken;
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> tokenMF_;

int n_event_;
int n_rs_vertices_;
int n_rs_vtxassocs_;
int n_sr_vertices_;
int n_sr_vtxassocs_;

//--------- RecoToSim Histos -----

TH1F *rs_resx;
TH1F *rs_resy;
TH1F *rs_resz;
TH1F *rs_pullx;
TH1F *rs_pully;
TH1F *rs_pullz;
TH1F *rs_dist;
TH1F *rs_simz;
TH1F *rs_recz;
TH1F *rs_nrectrk;
TH1F *rs_nsimtrk;
TH1F *rs_qual;
TH1F *rs_chi2norm;
TH1F *rs_chi2prob;

//--------- SimToReco Histos -----

TH1F *sr_resx;
TH1F *sr_resy;
TH1F *sr_resz;
TH1F *sr_pullx;
TH1F *sr_pully;
TH1F *sr_pullz;
TH1F *sr_dist;
TH1F *sr_simz;
TH1F *sr_recz;
TH1F *sr_nrectrk;
TH1F *sr_nsimtrk;
TH1F *sr_qual;
TH1F *sr_chi2norm;
TH1F *sr_chi2prob;
};

// class TrackAssociator;
class TrackAssociatorByHits;
Expand All @@ -29,7 +108,9 @@ using namespace edm;
testVertexAssociator::testVertexAssociator(edm::ParameterSet const &conf)
: associatorByTracksToken(consumes<reco::VertexToTrackingVertexAssociator>(
conf.getUntrackedParameter<edm::InputTag>("vertexAssociation"))) {
usesResource(TFileService::kSharedResource);
vertexCollection_ = conf.getUntrackedParameter<edm::InputTag>("vertexCollection");
tokenMF_ = esConsumes<MagneticField, IdealMagneticFieldRecord>();

n_event_ = 0;
n_rs_vertices_ = 0;
Expand All @@ -38,8 +119,6 @@ testVertexAssociator::testVertexAssociator(edm::ParameterSet const &conf)
n_sr_vtxassocs_ = 0;
}

testVertexAssociator::~testVertexAssociator() {}

void testVertexAssociator::beginJob() {
edm::Service<TFileService> fs;

Expand Down Expand Up @@ -91,8 +170,7 @@ void testVertexAssociator::analyze(const edm::Event &event, const edm::EventSetu
using namespace edm;
using namespace reco;

edm::ESHandle<MagneticField> theMF;
setup.get<IdealMagneticFieldRecord>().get(theMF);
//const auto &theMF = setup.getHandle(tokenMF_);

edm::Handle<VertexToTrackingVertexAssociator> theTracksAssociator;
event.getByToken(associatorByTracksToken, theTracksAssociator);
Expand Down
91 changes: 0 additions & 91 deletions SimTracker/VertexAssociation/test/testVertexAssociator.h

This file was deleted.

0 comments on commit 9583b99

Please sign in to comment.