-
Notifications
You must be signed in to change notification settings - Fork 53
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
Added Truth flags to decoded tracks #69
Open
pviscone
wants to merge
10
commits into
p2l1pfp:14_0_X
Choose a base branch
from
pviscone:14_0_X_MCTruth
base: 14_0_X
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7e51ba4
added truth values to decoded tracks
pviscone eb87f55
added dependencies to buildfile
pviscone 5731b4e
added drops to runPerformanceNTuple
pviscone 0e1d892
format + single quote
pviscone ba593bb
undo aggressive reformatting
pviscone d61d7de
Changed truthflag type in flattable from float to int
pviscone e9eb8ec
Added runInputs131X_TrackTruth
pviscone 09eeff5
updated input filename global tag
pviscone 22241b4
Removed non-computed CrystalCluster variables and added quality bits …
pviscone 1da6539
Fixed flag type
pviscone 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
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ __init__.py | |
.#* | ||
#*# | ||
*~ | ||
*/NanoNizer |
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 |
---|---|---|
@@ -1,22 +1,24 @@ | ||
<use name="CommonTools/UtilAlgos"/> | ||
<use name="CommonTools/Utils"/> | ||
<use name="DataFormats/Candidate"/> | ||
<use name="DataFormats/PatCandidates"/> | ||
<use name="DataFormats/HepMCCandidate"/> | ||
<use name="DataFormats/JetReco"/> | ||
<use name="DataFormats/L1TrackTrigger"/> | ||
<use name="DataFormats/METReco"/> | ||
<use name="DataFormats/Math"/> | ||
<use name="DataFormats/NanoAOD"/> | ||
<use name="DataFormats/L1TParticleFlow"/> | ||
<use name="FWCore/Framework"/> | ||
<use name="FWCore/ParameterSet"/> | ||
<use name="FWCore/ServiceRegistry"/> | ||
<use name="L1Trigger/Phase2L1ParticleFlow"/> | ||
<use name="MagneticField/Engine"/> | ||
<use name="MagneticField/Records"/> | ||
<use name="PhysicsTools/NanoAOD"/> | ||
<use name="L1Trigger/L1THGCal"/> | ||
|
||
<use name="CommonTools/UtilAlgos" /> | ||
<use name="CommonTools/Utils" /> | ||
<use name="DataFormats/Candidate" /> | ||
<use name="DataFormats/PatCandidates" /> | ||
<use name="DataFormats/HepMCCandidate" /> | ||
<use name="DataFormats/JetReco" /> | ||
<use name="DataFormats/L1TrackTrigger" /> | ||
<use name="DataFormats/METReco" /> | ||
<use name="DataFormats/Math" /> | ||
<use name="DataFormats/NanoAOD" /> | ||
<use name="DataFormats/L1TParticleFlow" /> | ||
<use name="FWCore/Framework" /> | ||
<use name="FWCore/ParameterSet" /> | ||
<use name="FWCore/ServiceRegistry" /> | ||
<use name="L1Trigger/Phase2L1ParticleFlow" /> | ||
<use name="MagneticField/Engine" /> | ||
<use name="MagneticField/Records" /> | ||
<use name="PhysicsTools/NanoAOD" /> | ||
<use name="L1Trigger/L1THGCal" /> | ||
<use name="SimTracker/TrackTriggerAssociation" /> | ||
<use name="heppdt" /> | ||
<use name="hepmc" /> | ||
<!-- <use name="Utilities/General"/> --> | ||
<flags EDM_PLUGIN="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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/global/EDProducer.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
|
||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "DataFormats/Common/interface/View.h" | ||
#include "DataFormats/Common/interface/RefToPtr.h" | ||
|
||
#include "DataFormats/L1TParticleFlow/interface/PFTrack.h" | ||
#include "DataFormats/Math/interface/deltaR.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/Utilities/interface/InputTag.h" | ||
|
||
#include "DataFormats/NanoAOD/interface/FlatTable.h" | ||
|
||
#include "CommonTools/Utils/interface/StringCutObjectSelector.h" | ||
#include "CommonTools/Utils/interface/StringObjectFunction.h" | ||
|
||
#include "L1Trigger/Phase2L1ParticleFlow/interface/L1TPFUtils.h" | ||
|
||
#include "SimTracker/TrackTriggerAssociation/interface/TTTrackAssociationMap.h" | ||
|
||
#include <algorithm> | ||
|
||
class L1DecTkTruthTableProducer : public edm::global::EDProducer<> { | ||
public: | ||
explicit L1DecTkTruthTableProducer(const edm::ParameterSet&); | ||
~L1DecTkTruthTableProducer(); | ||
|
||
private: | ||
virtual void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override; | ||
//std::vector<l1t::PFTrack> | ||
|
||
std::string name_; | ||
edm::EDGetTokenT<std::vector<l1t::PFTrack>> decTks_; | ||
edm::EDGetTokenT<TTTrackAssociationMap<Ref_Phase2TrackerDigi_>> ttTrackMCTruthToken_; | ||
}; | ||
|
||
L1DecTkTruthTableProducer::L1DecTkTruthTableProducer(const edm::ParameterSet& iConfig) | ||
: name_(iConfig.getParameter<std::string>("name")), | ||
decTks_(consumes<std::vector<l1t::PFTrack>>(iConfig.getParameter<edm::InputTag>("src"))), | ||
ttTrackMCTruthToken_(consumes<TTTrackAssociationMap<Ref_Phase2TrackerDigi_>>( | ||
iConfig.getParameter<edm::InputTag>("MCTruthTrackInputTag"))) | ||
{ | ||
produces<nanoaod::FlatTable>(); | ||
} | ||
|
||
L1DecTkTruthTableProducer::~L1DecTkTruthTableProducer() {} | ||
|
||
// ------------ method called for each event ------------ | ||
void L1DecTkTruthTableProducer::produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const { | ||
edm::Handle<std::vector<l1t::PFTrack>> decTks; | ||
edm::Handle<TTTrackAssociationMap<Ref_Phase2TrackerDigi_>> MCTruthTTTrackHandle; | ||
iEvent.getByToken(decTks_, decTks); | ||
iEvent.getByToken(ttTrackMCTruthToken_, MCTruthTTTrackHandle); | ||
|
||
// create the table | ||
unsigned int ncands = decTks->size(); | ||
auto out = std::make_unique<nanoaod::FlatTable>(ncands, name_, false, true); | ||
|
||
std::vector<int> isGenuine(ncands), isLooselyGenuine(ncands), isUnknown(ncands), isCombinatoric(ncands), isReal(ncands); | ||
std::vector<unsigned int> tpmatch(ncands); | ||
|
||
for (unsigned int i = 0; i < ncands; ++i) { | ||
const auto tkPtr = edm::refToPtr((*decTks)[i].track()); | ||
isGenuine[i] = MCTruthTTTrackHandle->isGenuine(tkPtr); | ||
isLooselyGenuine[i] = MCTruthTTTrackHandle->isLooselyGenuine(tkPtr); | ||
isUnknown[i] = MCTruthTTTrackHandle->isUnknown(tkPtr); | ||
isCombinatoric[i] = MCTruthTTTrackHandle->isCombinatoric(tkPtr); | ||
tpmatch[i] = (isCombinatoric[i]) + (isUnknown[i] << 1) + (isLooselyGenuine[i] << 2) + (isGenuine[i] << 3); | ||
|
||
edm::Ptr<TrackingParticle> my_tp = MCTruthTTTrackHandle->findTrackingParticlePtr(tkPtr); | ||
int tmp_isReal; | ||
if (my_tp.isNull()) { | ||
tmp_isReal = 0; | ||
} else { | ||
int tmp = (my_tp->eventId().event()); | ||
if (tmp > 0) { | ||
tmp_isReal = 2; | ||
} else { | ||
tmp_isReal = 1; | ||
} | ||
} | ||
isReal[i] = tmp_isReal; | ||
} | ||
|
||
out->addColumn<float>("isGenuine", isGenuine, ""); | ||
out->addColumn<float>("isLooselyGenuine", isLooselyGenuine, ""); | ||
out->addColumn<float>("isUnknown", isUnknown, ""); | ||
out->addColumn<float>("isCombinatoric", isCombinatoric, ""); | ||
out->addColumn<float>("isReal", isReal, ""); | ||
out->addColumn<float>("tpmatch", tpmatch, ""); | ||
|
||
// save to the event branches | ||
iEvent.put(std::move(out)); | ||
} | ||
|
||
//define this as a plug-in | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
DEFINE_FWK_MODULE(L1DecTkTruthTableProducer); |
Oops, something went wrong.
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.
I don't know if "isReal" is an appropriate name. This variable is 0 if the track is combinatoric, 1 if the track was generated by a tracking particle produced in the hard scattering, 2 if the track is due to pileup