Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run3-gex99B Use ESGetToekn in some of the codes in SimTracker/Track(Vertex)Association #36208

Merged
merged 3 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion SimTracker/TrackAssociation/plugins/MCTrackMatcher.cc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.