-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Add Pixel Tracks in Heavy Ions MiniAOD #30313
Merged
cmsbuild
merged 19 commits into
cms-sw:master
from
CesarBernardes:HIPackedPixelTracks_MiniAOD_112X
Jul 10, 2020
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0428785
Add EDProducer to create packed pixel tracks collection
CesarBernardes 1d2933e
To run and include pixel tracks in eras pp_on_AA_2018 and pp_on_PbPb_…
CesarBernardes 6b875a1
shorten the name of a python list
CesarBernardes c3600fb
fix code style and clang
CesarBernardes deebf67
* Move and rename .cc module to PhysicsTools/PatAlgos
CesarBernardes ed2abcd
Remove commented lines and empty/unused method(s)
CesarBernardes 311307e
remove possibility of production of copy of reco::tracks
CesarBernardes 8a0f07e
Substitute usage of original vertex collection to vertex collection f…
CesarBernardes 74d9a57
Improve code for track selections
CesarBernardes 32f0d40
Improve code to access and loop over tracks
CesarBernardes 0c32060
Simplify code in MicroEventContent_cff , modify other configs accordi…
CesarBernardes be47471
Remove older files and add 2 comments to describe parameters
CesarBernardes 6e71593
Remove unnecessary includes and simplify code
CesarBernardes 0846395
Make this EDProducer global
CesarBernardes 7af9308
Fix dxyError
CesarBernardes 77cb1ba
Add empty vertex protection
CesarBernardes 73d82c0
Remove cfi file, use auto-generated file, and add comments to .cc module
CesarBernardes f01701f
Merge branch 'master' into HIPackedPixelTracks_MiniAOD_112X
CesarBernardes eaafc66
Shorten BS definition
CesarBernardes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
209 changes: 209 additions & 0 deletions
209
PhysicsTools/PatAlgos/plugins/PATTracksToPackedCandidates.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
//Based on: PhysicsTools/PatAlgos/plugins/PATLostTracks.cc | ||
|
||
// system include files | ||
#include <memory> | ||
|
||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/global/EDProducer.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/Utilities/interface/StreamID.h" | ||
|
||
#include "DataFormats/TrackReco/interface/Track.h" | ||
#include "DataFormats/TrackReco/interface/TrackFwd.h" | ||
#include "DataFormats/VertexReco/interface/Vertex.h" | ||
#include "DataFormats/VertexReco/interface/VertexFwd.h" | ||
#include "DataFormats/BeamSpot/interface/BeamSpot.h" | ||
|
||
#include "DataFormats/Candidate/interface/Candidate.h" | ||
#include "DataFormats/PatCandidates/interface/PackedCandidate.h" | ||
#include "DataFormats/Common/interface/Association.h" | ||
|
||
#include <vector> | ||
|
||
// | ||
// class declaration | ||
// | ||
|
||
class PATTracksToPackedCandidates : public edm::global::EDProducer<> { | ||
public: | ||
explicit PATTracksToPackedCandidates(const edm::ParameterSet&); | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
||
void addPackedCandidate(std::vector<pat::PackedCandidate>& cands, | ||
const reco::Track trk, | ||
const reco::VertexRef& pvSlimmed, | ||
const reco::VertexRefProd& pvSlimmedColl, | ||
bool passPixelTrackSel) const; | ||
|
||
private: | ||
void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; | ||
|
||
// ----------member data --------------------------- | ||
const edm::EDGetTokenT<reco::TrackCollection> srcTracks_; | ||
const edm::EDGetTokenT<reco::VertexCollection> srcPrimaryVertices_; | ||
const edm::EDGetTokenT<reco::BeamSpot> srcOfflineBeamSpot_; | ||
const double dzSigCut_; | ||
const double dxySigCut_; | ||
const double dzSigHP_; | ||
const double dxySigHP_; | ||
const double ptMax_; | ||
const double ptMin_; | ||
const bool resetHP_; | ||
const int covarianceVersion_; | ||
const int covarianceSchema_; | ||
}; | ||
|
||
// | ||
// constants, enums and typedefs | ||
// | ||
|
||
// | ||
// static data member definitions | ||
// | ||
|
||
// | ||
// constructors and destructor | ||
// | ||
PATTracksToPackedCandidates::PATTracksToPackedCandidates(const edm::ParameterSet& iConfig) | ||
: srcTracks_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("srcTracks"))), | ||
srcPrimaryVertices_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("srcPrimaryVertices"))), | ||
srcOfflineBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("srcOfflineBeamSpot"))), | ||
dzSigCut_(iConfig.getParameter<double>("dzSigCut")), | ||
dxySigCut_(iConfig.getParameter<double>("dxySigCut")), | ||
dzSigHP_(iConfig.getParameter<double>("dzSigHP")), | ||
dxySigHP_(iConfig.getParameter<double>("dxySigHP")), | ||
ptMax_(iConfig.getParameter<double>("ptMax")), | ||
ptMin_(iConfig.getParameter<double>("ptMin")), | ||
resetHP_(iConfig.getParameter<bool>("resetHP")), | ||
covarianceVersion_(iConfig.getParameter<int>("covarianceVersion")), | ||
covarianceSchema_(iConfig.getParameter<int>("covarianceSchema")) { | ||
produces<std::vector<pat::PackedCandidate>>(); | ||
produces<edm::Association<pat::PackedCandidateCollection>>(); | ||
} | ||
|
||
// | ||
// member functions | ||
// | ||
|
||
// ------------ method called to produce the data ------------ | ||
void PATTracksToPackedCandidates::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { | ||
using namespace edm; | ||
using namespace std; | ||
|
||
//track collection | ||
auto tracks = iEvent.getHandle(srcTracks_); | ||
|
||
auto outPtrTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>(); | ||
|
||
//vtx collection | ||
auto pvs = iEvent.getHandle(srcPrimaryVertices_); | ||
reco::VertexRef pv(pvs.id()); | ||
reco::VertexRefProd pvRefProd(pvs); | ||
|
||
//best vertex | ||
double bestvzError; | ||
math::XYZPoint bestvtx; | ||
math::Error<3>::type vtx_cov; | ||
if (!pvs->empty()) { | ||
pv = reco::VertexRef(pvs, 0); | ||
const reco::Vertex& vtx = (*pvs)[0]; | ||
bestvzError = vtx.zError(); | ||
bestvtx = vtx.position(); | ||
vtx_cov = vtx.covariance(); | ||
} else { | ||
const auto& bs = iEvent.get(srcOfflineBeamSpot_); | ||
bestvzError = bs.z0Error(); | ||
bestvtx = bs.position(); | ||
vtx_cov = bs.covariance3D(); | ||
} | ||
|
||
std::vector<int> mapping(tracks->size(), -1); | ||
int savedCandIndx = 0; | ||
int trkIndx = -1; | ||
for (auto const& trk : *tracks) { | ||
trkIndx++; | ||
double dzvtx = std::abs(trk.dz(bestvtx)); | ||
double dxyvtx = std::abs(trk.dxy(bestvtx)); | ||
double dzerror = std::hypot(trk.dzError(), bestvzError); | ||
double dxyerror = trk.dxyError(bestvtx, vtx_cov); | ||
|
||
if (dzvtx >= dzSigCut_ * dzerror) | ||
continue; | ||
if (dxyvtx >= dxySigCut_ * dxyerror) | ||
continue; | ||
if (trk.pt() >= ptMax_ || trk.pt() <= ptMin_) | ||
continue; | ||
|
||
bool passSelection = (dzvtx < dzSigHP_ * dzerror && dxyvtx < dxySigHP_ * dxyerror); | ||
|
||
addPackedCandidate(*outPtrTrksAsCands, trk, pv, pvRefProd, passSelection); | ||
|
||
//for creating the reco::Track -> pat::PackedCandidate map | ||
mapping[trkIndx] = savedCandIndx; | ||
savedCandIndx++; | ||
} | ||
edm::OrphanHandle<pat::PackedCandidateCollection> oh = iEvent.put(std::move(outPtrTrksAsCands)); | ||
auto tk2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh); | ||
edm::Association<pat::PackedCandidateCollection>::Filler tk2pcFiller(*tk2pc); | ||
tk2pcFiller.insert(tracks, mapping.begin(), mapping.end()); | ||
tk2pcFiller.fill(); | ||
iEvent.put(std::move(tk2pc)); | ||
} | ||
|
||
void PATTracksToPackedCandidates::addPackedCandidate(std::vector<pat::PackedCandidate>& cands, | ||
const reco::Track trk, | ||
const reco::VertexRef& pvSlimmed, | ||
const reco::VertexRefProd& pvSlimmedColl, | ||
bool passPixelTrackSel) const { | ||
const float mass = 0.13957018; | ||
|
||
int id = 211 * trk.charge(); | ||
|
||
reco::Candidate::PolarLorentzVector p4(trk.pt(), trk.eta(), trk.phi(), mass); | ||
cands.emplace_back(p4, trk.vertex(), trk.pt(), trk.eta(), trk.phi(), id, pvSlimmedColl, pvSlimmed.key()); | ||
|
||
if (resetHP_) { | ||
if (passPixelTrackSel) | ||
cands.back().setTrackHighPurity(true); | ||
else | ||
cands.back().setTrackHighPurity(false); | ||
} else { | ||
if (trk.quality(reco::TrackBase::highPurity)) | ||
cands.back().setTrackHighPurity(true); | ||
else | ||
cands.back().setTrackHighPurity(false); | ||
} | ||
|
||
cands.back().setTrackProperties(trk, covarianceSchema_, covarianceVersion_); | ||
} | ||
|
||
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ | ||
void PATTracksToPackedCandidates::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
//The following says we do not know what parameters are allowed so do no validation | ||
// Please change this to state exactly what you do use, even if it is no parameters | ||
edm::ParameterSetDescription desc; | ||
desc.add<edm::InputTag>("srcTracks", {"hiConformalPixelTracks"}); | ||
desc.add<edm::InputTag>("srcPrimaryVertices", {"offlineSlimmedPrimaryVertices"}); | ||
desc.add<edm::InputTag>("srcOfflineBeamSpot", {"offlineBeamSpot"}) | ||
->setComment("use BeamSpot if empty vtx collection"); | ||
desc.add<double>("dzSigCut", 10.0); | ||
desc.add<double>("dxySigCut", 25.0); | ||
desc.add<double>("dzSigHP", 7.0)->setComment("to set HighPurity flag for pixel tracks"); | ||
desc.add<double>("dxySigHP", 20.0)->setComment("to set HighPurity flag for pixel tracks"); | ||
desc.add<double>("ptMax", 1.0)->setComment("max pT for pixel tracks - above this will use general tracks"); | ||
desc.add<double>("ptMin", 0.3)->setComment("min pT for pixel tracks"); | ||
desc.add<bool>("resetHP", true) | ||
->setComment("pixel tracks do not have HP flag set. Use False if does not want to reset HP flag"); | ||
desc.add<int>("covarianceVersion", 0)->setComment("so far: 0 is Phase0, 1 is Phase1"); | ||
desc.add<int>("covarianceSchema", 520)->setComment("use less accurate schema - reduce size of collection"); | ||
descriptions.addWithDefaultLabel(desc); | ||
} | ||
|
||
//define this as a plug-in | ||
DEFINE_FWK_MODULE(PATTracksToPackedCandidates); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from PhysicsTools.PatAlgos.patTracksToPackedCandidates_cfi import patTracksToPackedCandidates | ||
|
||
hiPixelTracks = patTracksToPackedCandidates.clone() | ||
|
||
from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel | ||
phase1Pixel.toModify(hiPixelTracks, covarianceVersion=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mind #30253
it has a change in the same lines; since it's already signed, I expect that this PR will need to be rebased after #30253 is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can do a rebase when #30253 is merged. Thanks!