Skip to content

Commit

Permalink
Move time-life info structure from DataFormats/NanoAOD to DataFormats…
Browse files Browse the repository at this point in the history
…/VertexReco
  • Loading branch information
mbluj committed Dec 13, 2023
1 parent dd9dc87 commit 5a1ba08
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 42 deletions.
1 change: 0 additions & 1 deletion DataFormats/NanoAOD/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<use name="FWCore/Utilities"/>
<use name="DataFormats/CLHEP"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/Math"/>
<use name="boost"/>
Expand Down
1 change: 0 additions & 1 deletion DataFormats/NanoAOD/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
#include "DataFormats/NanoAOD/interface/FlatTable.h"
#include "DataFormats/NanoAOD/interface/MergeableCounterTable.h"
#include "DataFormats/NanoAOD/interface/UniqueString.h"
#include "DataFormats/NanoAOD/interface/LeptonTimeLifeInfo.h"
#include "DataFormats/Common/interface/Wrapper.h"
1 change: 0 additions & 1 deletion DataFormats/NanoAOD/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@
<version ClassVersion="3" checksum="2793726511"/>
</class>
<class name="edm::Wrapper<nanoaod::UniqueString>" />
<class name="LeptonTimeLifeInfo" />
</lcgdict>

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
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef DataFormats_NanoAOD_LeptonTimeLifeInfo_h
#define DataFormats_NanoAOD_LeptonTimeLifeInfo_h
#ifndef DataFormats_VertexReco_TrackTimeLifeInfo_h
#define DataFormats_VertexReco_TrackTimeLifeInfo_h

/**
\class LeptonTimeLifeInfo
\brief Structure to hold lepton life-time information
\class TrackTimeLifeInfo
\brief Structure to hold time-life information
\author Michal Bluj, NCBJ, Warsaw
*/
Expand All @@ -15,10 +15,10 @@
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/VertexReco/interface/Vertex.h"

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

// Secondary vertex
void setSV(reco::Vertex sv) {
Expand All @@ -39,7 +39,7 @@ class LeptonTimeLifeInfo {
// Point of closest approach
void setPCA(GlobalPoint pca, const GlobalError& pca_cov) {
pca_ = pca;
pca_cov_ = pca_cov_;
pca_cov_ = pca_cov;
}
const GlobalPoint& pca() const { return pca_; }
const GlobalError& pcaCovariance() const { return pca_cov_; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "DataFormats/NanoAOD/interface/LeptonTimeLifeInfo.h"
#include "DataFormats/VertexReco/interface/TrackTimeLifeInfo.h"

LeptonTimeLifeInfo::LeptonTimeLifeInfo()
TrackTimeLifeInfo::TrackTimeLifeInfo()
: hasSV_(false),
sv_(reco::Vertex()),
flight_vec_(GlobalVector()),
Expand Down
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>
1 change: 1 addition & 0 deletions DataFormats/VertexReco/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@
<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" />
</lcgdict>
55 changes: 27 additions & 28 deletions PhysicsTools/NanoAOD/plugins/LeptonTimeLifeInfoTableProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,20 @@
#include "CommonTools/UtilAlgos/interface/StringCutObjectSelector.h"
#include "Utilities/General/interface/ClassName.h"
#include "PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h"
#include "DataFormats/NanoAOD/interface/LeptonTimeLifeInfo.h"
#include "DataFormats/VertexReco/interface/TrackTimeLifeInfo.h"

#include <cstring>

namespace {
typedef FuncVariable<LeptonTimeLifeInfo, StringObjectFunction<LeptonTimeLifeInfo>, int32_t> IntLeptonTimeLifeInfoVar;
typedef FuncVariable<LeptonTimeLifeInfo, StringObjectFunction<LeptonTimeLifeInfo>, uint32_t> UIntLeptonTimeLifeInfoVar;
typedef FuncVariable<LeptonTimeLifeInfo, StringObjectFunction<LeptonTimeLifeInfo>, float> FloatLeptonTimeLifeInfoVar;
typedef FuncVariable<LeptonTimeLifeInfo, StringObjectFunction<LeptonTimeLifeInfo>, double> DoubleLeptonTimeLifeInfoVar;
typedef FuncVariable<LeptonTimeLifeInfo, StringObjectFunction<LeptonTimeLifeInfo>, int8_t> Int8LeptonTimeLifeInfoVar;
typedef FuncVariable<LeptonTimeLifeInfo, StringObjectFunction<LeptonTimeLifeInfo>, uint8_t> UInt8LeptonTimeLifeInfoVar;
typedef FuncVariable<LeptonTimeLifeInfo, StringObjectFunction<LeptonTimeLifeInfo>, int16_t> Int16LeptonTimeLifeInfoVar;
typedef FuncVariable<LeptonTimeLifeInfo, StringObjectFunction<LeptonTimeLifeInfo>, uint16_t>
UInt16LeptonTimeLifeInfoVar;
typedef FuncVariable<LeptonTimeLifeInfo, StringCutObjectSelector<LeptonTimeLifeInfo>, bool> BoolLeptonTimeLifeInfoVar;
typedef FuncVariable<TrackTimeLifeInfo, StringObjectFunction<TrackTimeLifeInfo>, int32_t> IntTrackTimeLifeInfoVar;
typedef FuncVariable<TrackTimeLifeInfo, StringObjectFunction<TrackTimeLifeInfo>, uint32_t> UIntTrackTimeLifeInfoVar;
typedef FuncVariable<TrackTimeLifeInfo, StringObjectFunction<TrackTimeLifeInfo>, float> FloatTrackTimeLifeInfoVar;
typedef FuncVariable<TrackTimeLifeInfo, StringObjectFunction<TrackTimeLifeInfo>, double> DoubleTrackTimeLifeInfoVar;
typedef FuncVariable<TrackTimeLifeInfo, StringObjectFunction<TrackTimeLifeInfo>, int8_t> Int8TrackTimeLifeInfoVar;
typedef FuncVariable<TrackTimeLifeInfo, StringObjectFunction<TrackTimeLifeInfo>, uint8_t> UInt8TrackTimeLifeInfoVar;
typedef FuncVariable<TrackTimeLifeInfo, StringObjectFunction<TrackTimeLifeInfo>, int16_t> Int16TrackTimeLifeInfoVar;
typedef FuncVariable<TrackTimeLifeInfo, StringObjectFunction<TrackTimeLifeInfo>, uint16_t> UInt16TrackTimeLifeInfoVar;
typedef FuncVariable<TrackTimeLifeInfo, StringCutObjectSelector<TrackTimeLifeInfo>, bool> BoolTrackTimeLifeInfoVar;
} // namespace

template <typename T>
Expand All @@ -62,8 +61,8 @@ class LeptonTimeLifeInfoTableProducer : public edm::stream::EDProducer<> {
private:
//--- private utility methods
const reco::Track* getTrack(const T&);
void produceAndFillIPInfo(const T&, const TransientTrackBuilder&, const reco::Vertex&, LeptonTimeLifeInfo&);
void produceAndFillSVInfo(const T&, const TransientTrackBuilder&, const reco::Vertex&, LeptonTimeLifeInfo&);
void produceAndFillIPInfo(const T&, const TransientTrackBuilder&, const reco::Vertex&, TrackTimeLifeInfo&);
void produceAndFillSVInfo(const T&, const TransientTrackBuilder&, const reco::Vertex&, TrackTimeLifeInfo&);
static bool fitVertex(const std::vector<reco::TransientTrack>& transTrk, TransientVertex& transVtx) {
if (transTrk.size() < 2)
return false;
Expand All @@ -80,7 +79,7 @@ class LeptonTimeLifeInfoTableProducer : public edm::stream::EDProducer<> {
bool extension_;
const StringCutObjectSelector<T> selector_;
int pvChoice_;
std::vector<std::unique_ptr<Variable<LeptonTimeLifeInfo>>> vars_;
std::vector<std::unique_ptr<Variable<TrackTimeLifeInfo>>> vars_;

enum PVChoice { useFront = 0, useClosestInDz };
};
Expand All @@ -101,23 +100,23 @@ LeptonTimeLifeInfoTableProducer<T>::LeptonTimeLifeInfoTableProducer(const edm::P
const auto& varPSet = varsPSet.getParameter<edm::ParameterSet>(vname);
const std::string& type = varPSet.getParameter<std::string>("type");
if (type == "int")
vars_.push_back(std::make_unique<IntLeptonTimeLifeInfoVar>(vname, varPSet));
vars_.push_back(std::make_unique<IntTrackTimeLifeInfoVar>(vname, varPSet));
else if (type == "uint")
vars_.push_back(std::make_unique<UIntLeptonTimeLifeInfoVar>(vname, varPSet));
vars_.push_back(std::make_unique<UIntTrackTimeLifeInfoVar>(vname, varPSet));
else if (type == "float")
vars_.push_back(std::make_unique<FloatLeptonTimeLifeInfoVar>(vname, varPSet));
vars_.push_back(std::make_unique<FloatTrackTimeLifeInfoVar>(vname, varPSet));
else if (type == "double")
vars_.push_back(std::make_unique<DoubleLeptonTimeLifeInfoVar>(vname, varPSet));
vars_.push_back(std::make_unique<DoubleTrackTimeLifeInfoVar>(vname, varPSet));
else if (type == "int8")
vars_.push_back(std::make_unique<Int8LeptonTimeLifeInfoVar>(vname, varPSet));
vars_.push_back(std::make_unique<Int8TrackTimeLifeInfoVar>(vname, varPSet));
else if (type == "uint8")
vars_.push_back(std::make_unique<UInt8LeptonTimeLifeInfoVar>(vname, varPSet));
vars_.push_back(std::make_unique<UInt8TrackTimeLifeInfoVar>(vname, varPSet));
else if (type == "int16")
vars_.push_back(std::make_unique<Int16LeptonTimeLifeInfoVar>(vname, varPSet));
vars_.push_back(std::make_unique<Int16TrackTimeLifeInfoVar>(vname, varPSet));
else if (type == "uint16")
vars_.push_back(std::make_unique<UInt16LeptonTimeLifeInfoVar>(vname, varPSet));
vars_.push_back(std::make_unique<UInt16TrackTimeLifeInfoVar>(vname, varPSet));
else if (type == "bool")
vars_.push_back(std::make_unique<BoolLeptonTimeLifeInfoVar>(vname, varPSet));
vars_.push_back(std::make_unique<BoolTrackTimeLifeInfoVar>(vname, varPSet));
else
throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + vname);
}
Expand All @@ -137,11 +136,11 @@ void LeptonTimeLifeInfoTableProducer<T>::produce(edm::Event& evt, const edm::Eve
// Get transient track builder
const TransientTrackBuilder& transTrackBuilder = es.getData(transTrackBuilderToken_);

std::vector<const LeptonTimeLifeInfo*> infos;
std::vector<const TrackTimeLifeInfo*> infos;
infos.reserve(leptons->size());

for (const auto& lepton : *leptons) {
LeptonTimeLifeInfo* info = new LeptonTimeLifeInfo();
TrackTimeLifeInfo* info = new TrackTimeLifeInfo();

// Do nothing for lepton not passing selection
if (!selector_(lepton)) {
Expand Down Expand Up @@ -205,7 +204,7 @@ template <typename T>
void LeptonTimeLifeInfoTableProducer<T>::produceAndFillIPInfo(const T& lepton,
const TransientTrackBuilder& transTrackBuilder,
const reco::Vertex& pv,
LeptonTimeLifeInfo& info) {
TrackTimeLifeInfo& info) {
const reco::Track* track = getTrack(lepton);
if (track != nullptr) {
info.setTrack(track);
Expand Down Expand Up @@ -236,13 +235,13 @@ template <typename T>
void LeptonTimeLifeInfoTableProducer<T>::produceAndFillSVInfo(const T& lepton,
const TransientTrackBuilder& transTrackBuilder,
const reco::Vertex& pv,
LeptonTimeLifeInfo& info) {}
TrackTimeLifeInfo& info) {}

template <>
void LeptonTimeLifeInfoTableProducer<pat::Tau>::produceAndFillSVInfo(const pat::Tau& tau,
const TransientTrackBuilder& transTrackBuilder,
const reco::Vertex& pv,
LeptonTimeLifeInfo& info) {
TrackTimeLifeInfo& info) {
// Fit SV with tracks of charged tau decay products
int fitOK = 0;
if (tau.signalChargedHadrCands().size() + tau.signalLostTracks().size() > 1) {
Expand Down

0 comments on commit 5a1ba08

Please sign in to comment.