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

Add index to primary vertex in scouting particle collection #11033

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions DataFormats/Scouting/interface/ScoutingParticle.h
Expand Up @@ -10,24 +10,26 @@ class ScoutingParticle
public:
//constructor with values for all data fields
ScoutingParticle(float pt, float eta, float phi, float m,
int pdgId):
pt_(pt), eta_(eta), phi_(phi), m_(m), pdgId_(pdgId) {}
int pdgId, int vertex):
pt_(pt), eta_(eta), phi_(phi), m_(m), pdgId_(pdgId), vertex_(vertex) {}
//default constructor
ScoutingParticle():pt_(0), eta_(0), phi_(0), m_(0), pdgId_(0) {}
ScoutingParticle():pt_(0), eta_(0), phi_(0), m_(0), pdgId_(0), vertex_(0) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given 0 is a valid index, how about using max int instead? That way reading old data one can spot if the variable is not filled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or -1 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dr15Jones, you mean changing it to vertex_(2147483647)? Or should I use a smaller value in case there maximum int is 32 bit?

-1 is a valid value for this member. The producer sets it to -1 when no vertex is matched.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given when reading old data there would be no match, then -1 makes the most sense.


//accessor functions
float pt() const { return pt_; }
float eta() const { return eta_; }
float phi() const { return phi_; }
float m() const { return m_; }
int pdgId() const { return pdgId_; }
int vertex() const { return vertex_; }

private:
float pt_;
float eta_;
float phi_;
float m_;
int pdgId_;
int vertex_;
};

typedef std::vector<ScoutingParticle> ScoutingParticleCollection;
Expand Down
3 changes: 2 additions & 1 deletion DataFormats/Scouting/src/classes_def.xml
Expand Up @@ -5,8 +5,9 @@
<class name="ScoutingPFJet" ClassVersion="2">
<version ClassVersion="2" checksum="2507658732"/>
</class>
<class name="ScoutingParticle" ClassVersion="2">
<class name="ScoutingParticle" ClassVersion="3">
<version ClassVersion="2" checksum="2803573918"/>
<version ClassVersion="3" checksum="3020184314"/>
</class>
<class name="ScoutingVertex" ClassVersion="2">
<version ClassVersion="2" checksum="2969738609"/>
Expand Down
18 changes: 16 additions & 2 deletions HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc
Expand Up @@ -150,13 +150,27 @@ void HLTScoutingPFProducer::produce(edm::StreamID sid, edm::Event & iEvent, edm:
if(doCandidates){
for(auto &cand : *pfCandidateCollection){
if(cand.pt() > pfCandidatePtCut){
int vertex_index = -1;
int index_counter = 0;
double dr2 = 0.0001;
for (auto &vtx: *outVertices) {
double tmp_dr2 = pow(vtx.x() - cand.vx(), 2) + pow(vtx.y() - cand.vy(), 2)
+ pow(vtx.z() - cand.vz(), 2);
if (tmp_dr2 < dr2) {
dr2 = tmp_dr2;
vertex_index = index_counter;
}
if (dr2 == 0.0)
break;
++index_counter;
}
outPFCandidates->emplace_back(
cand.pt(), cand.eta(), cand.phi(), cand.mass(), cand.pdgId()
cand.pt(), cand.eta(), cand.phi(), cand.mass(), cand.pdgId(), vertex_index
);
}
}
}

//produce PF jets
std::auto_ptr<ScoutingPFJetCollection> outPFJets(new ScoutingPFJetCollection());
for(auto &jet : *pfJetCollection){
Expand Down