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

Lepton time-life info for NanoAOD #43525

Merged
merged 7 commits into from
Feb 21, 2024
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
3 changes: 2 additions & 1 deletion DataFormats/VertexReco/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<use name="DataFormats/Common"/>
<use name="DataFormats/TrackReco"/>
<use name="DataFormats/CLHEP"/>
<use name="DataFormats/Math"/>
<use name="DataFormats/TrackReco"/>
<use name="DataFormats/TrajectorySeed"/>
<export>
<lib name="1"/>
Expand Down
81 changes: 81 additions & 0 deletions DataFormats/VertexReco/interface/TrackTimeLifeInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#ifndef DataFormats_VertexReco_TrackTimeLifeInfo_h
#define DataFormats_VertexReco_TrackTimeLifeInfo_h

/**
\class TrackTimeLifeInfo
\brief Structure to hold time-life information

\author Michal Bluj, NCBJ, Warsaw
*/

#include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/GeometryVector/interface/GlobalVector.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/VertexReco/interface/Vertex.h"

class TrackTimeLifeInfo {
public:
TrackTimeLifeInfo();
~TrackTimeLifeInfo() {}

// Secondary vertex
void setSV(reco::Vertex sv) {
sv_ = sv;
hasSV_ = true;
}
const reco::Vertex& sv() const { return sv_; }
bool hasSV() const { return hasSV_; }
void setFlightVector(GlobalVector flight_vec, GlobalError flight_cov) {
flight_vec_ = flight_vec;
flight_cov_ = flight_cov;
}
// Flight-path
const GlobalVector& flightVector() const { return flight_vec_; }
const GlobalError& flightCovariance() const { return flight_cov_; }
void setFlightLength(Measurement1D flightLength) { flightLength_ = flightLength; }
const Measurement1D& flightLength() const { return flightLength_; }
// Point of closest approach
void setPCA(GlobalPoint pca, GlobalError pca_cov) {
pca_ = pca;
pca_cov_ = pca_cov;
}
const GlobalPoint& pca() const { return pca_; }
const GlobalError& pcaCovariance() const { return pca_cov_; }
// Impact parameter
void setIP(GlobalVector ip_vec, GlobalError ip_cov) {
ip_vec_ = ip_vec;
ip_cov_ = ip_cov;
}
const GlobalVector& ipVector() const { return ip_vec_; }
const GlobalError& ipCovariance() const { return ip_cov_; }
void setIPLength(Measurement1D ipLength) { ipLength_ = ipLength; }
const Measurement1D& ipLength() const { return ipLength_; }
// Track
void setTrack(const reco::Track* track) {
if (track != nullptr) {
track_ = *track;
hasTrack_ = true;
} else {
track_ = reco::Track();
hasTrack_ = false;
}
}
const reco::Track* track() const { return &track_; }
bool hasTrack() const { return hasTrack_; }
void setBField_z(float bField_z) { bField_z_ = bField_z; }
float bField_z() const { return bField_z_; }

private:
bool hasSV_, hasTrack_;
reco::Vertex sv_;
GlobalVector flight_vec_, ip_vec_;
GlobalPoint pca_;
GlobalError flight_cov_, pca_cov_, ip_cov_;
Measurement1D flightLength_, ipLength_;
reco::Track track_;
float bField_z_;
};

#endif
16 changes: 16 additions & 0 deletions DataFormats/VertexReco/src/TrackTimeLifeInfo.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "DataFormats/VertexReco/interface/TrackTimeLifeInfo.h"

TrackTimeLifeInfo::TrackTimeLifeInfo()
: hasSV_(false),
hasTrack_(false),
sv_(reco::Vertex()),
flight_vec_(GlobalVector()),
ip_vec_(GlobalVector()),
pca_(GlobalPoint()),
flight_cov_(GlobalError()),
pca_cov_(GlobalError()),
ip_cov_(GlobalError()),
flightLength_(Measurement1D()),
ipLength_(Measurement1D()),
track_(reco::Track()),
bField_z_(0.){};
2 changes: 2 additions & 0 deletions DataFormats/VertexReco/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"

#include "DataFormats/VertexReco/interface/TrackTimeLifeInfo.h"

#include <vector>
#include <utility>
5 changes: 5 additions & 0 deletions DataFormats/VertexReco/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@
<class name="std::vector<std::pair<edm::Ref<std::vector<reco::Vertex>,reco::Vertex,edm::refhelper::FindUsingAdvance<std::vector<reco::Vertex>,reco::Vertex> >,int> >" />
<class name="std::pair<edm::Ref<std::vector<reco::Vertex>,reco::Vertex,edm::refhelper::FindUsingAdvance<std::vector<reco::Vertex>,reco::Vertex> >,int>" />

<class name="TrackTimeLifeInfo" />
<class name="std::vector<TrackTimeLifeInfo>"/>
<class name="edm::Wrapper<std::vector<TrackTimeLifeInfo> >"/>
<class name="edm::ValueMap<TrackTimeLifeInfo>"/>
<class name="edm::Wrapper<edm::ValueMap<TrackTimeLifeInfo> >"/>
</lcgdict>
12 changes: 6 additions & 6 deletions PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ValueMapVariableBase : public ExtVariable<ObjType> {
if (vmap.isValid() || !skipNonExistingSrc_) {
vals.resize(selptrs.size());
for (unsigned int i = 0, n = vals.size(); i < n; ++i) {
// calls the overloade method to either get the valuemap value directly, or a function of the object value.
// calls the overloaded method to either get the valuemap value directly, or a function of the object value.
vals[i] = this->eval(vmap, selptrs[i]);
}
}
Expand All @@ -121,7 +121,7 @@ class ValueMapVariable : public ValueMapVariableBase<ObjType, TIn, ValType> {
edm::ConsumesCollector &&cc,
bool skipNonExistingSrc = false)
: ValueMapVariableBase<ObjType, TIn, ValType>(aname, cfg, std::move(cc), skipNonExistingSrc) {}
ValType eval(const edm::Handle<edm::ValueMap<TIn>> &vmap, const edm::Ptr<ObjType> &op) const {
ValType eval(const edm::Handle<edm::ValueMap<TIn>> &vmap, const edm::Ptr<ObjType> &op) const override {
mbluj marked this conversation as resolved.
Show resolved Hide resolved
ValType val = (*vmap)[op];
return val;
}
Expand All @@ -139,7 +139,7 @@ class TypedValueMapVariable : public ValueMapVariableBase<ObjType, TIn, ValType>
precisionFunc_(cfg.existsAs<std::string>("precision") ? cfg.getParameter<std::string>("precision") : "23",
true) {}

ValType eval(const edm::Handle<edm::ValueMap<TIn>> &vmap, const edm::Ptr<ObjType> &op) const {
ValType eval(const edm::Handle<edm::ValueMap<TIn>> &vmap, const edm::Ptr<ObjType> &op) const override {
ValType val = func_((*vmap)[op]);
if constexpr (std::is_same<ValType, float>()) {
if (this->precision_ == -2) {
Expand Down Expand Up @@ -333,7 +333,7 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase<T, edm::View<
edm::ParameterDescription<std::string>("precision",
true,
edm::Comment("the precision with which to store the value in the "
"flat table, as a fucntion of the object evaluated")),
"flat table, as a function of the object evaluated")),
false);

edm::ParameterSetDescription extvariables;
Expand Down Expand Up @@ -452,7 +452,7 @@ class SimpleTypedExternalFlatTableProducer : public SimpleFlatTableProducer<T> {
edm::ParameterDescription<std::string>("precision",
true,
edm::Comment("the precision with which to store the value in the "
"flat table, as a fucntion of the object evaluated")),
"flat table, as a function of the object evaluated")),
false);

edm::ParameterSetDescription extvariables;
Expand Down Expand Up @@ -577,7 +577,7 @@ class FirstObjectSimpleFlatTableProducer : public SimpleFlatTableProducerBase<T,
~FirstObjectSimpleFlatTableProducer() override {}

static void fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
edm::ParameterSetDescription desc = desc = SimpleFlatTableProducerBase<T, edm::View<T>>::baseDescriptions();
edm::ParameterSetDescription desc = SimpleFlatTableProducerBase<T, edm::View<T>>::baseDescriptions();
mbluj marked this conversation as resolved.
Show resolved Hide resolved
descriptions.addWithDefaultLabel(desc);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ typedef SimpleFlatTableProducer<Run3ScoutingElectron> SimpleRun3ScoutingElectron
#include "DataFormats/Scouting/interface/Run3ScoutingTrack.h"
typedef SimpleFlatTableProducer<Run3ScoutingTrack> SimpleRun3ScoutingTrackFlatTableProducer;

#include "DataFormats/VertexReco/interface/Vertex.h"
typedef SimpleFlatTableProducer<reco::Vertex> SimpleVertexFlatTableProducer;

#include "DataFormats/VertexReco/interface/TrackTimeLifeInfo.h"
typedef SimpleTypedExternalFlatTableProducer<reco::Candidate, TrackTimeLifeInfo>
SimpleCandidate2TrackTimeLifeInfoFlatTableProducer;

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(SimpleCandidateFlatTableProducer);
DEFINE_FWK_MODULE(SimpleCandidate2CandidateFlatTableProducer);
Expand All @@ -81,3 +88,5 @@ DEFINE_FWK_MODULE(SimpleRun3ScoutingPhotonFlatTableProducer);
DEFINE_FWK_MODULE(SimpleRun3ScoutingMuonFlatTableProducer);
DEFINE_FWK_MODULE(SimpleRun3ScoutingElectronFlatTableProducer);
DEFINE_FWK_MODULE(SimpleRun3ScoutingTrackFlatTableProducer);
DEFINE_FWK_MODULE(SimpleVertexFlatTableProducer);
DEFINE_FWK_MODULE(SimpleCandidate2TrackTimeLifeInfoFlatTableProducer);
5 changes: 4 additions & 1 deletion PhysicsTools/NanoAOD/python/autoNANO.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ def expandNanoMapping(seqList, mapping, key):
'customize': 'DPGAnalysis/MuonTools/muNtupleProducerBkg_cff.muDPGNanoBkgCustomize'},
# PromptReco config: PHYS+L1
'Prompt' : {'sequence': '@PHYS',
'customize': '@PHYS+@L1'}
'customize': '@PHYS+@L1'},
# Add lepton time-life info tables through customize combined with PHYS
'LepTimeLife' : {'sequence': '@PHYS',
'customize': '@PHYS+PhysicsTools/NanoAOD/leptonTimeLifeInfo_common_cff.addTimeLifeInfo'},
}
Loading