DAS  3.0
Das Analysis System
TPSBranchFlattener

Description

Flattens the event tree into general objects suitable for machine learning input. Target branches contain basic jet information and weights, as well as all TPS observables.

+ Inheritance diagram for TPSBranchFlattener:
+ Collaboration diagram for TPSBranchFlattener:

Public Member Functions

 TPSBranchFlattener (DT::Flow &flow, const Variation &v)
 
void Fill () override
 
void Clear () override
 
- Public Member Functions inherited from BranchFlattener
virtual ~BranchFlattener ()=default
 
virtual ~BranchFlattener ()=default
 

Protected Member Functions

template<typename Ret , typename Input >
void AddEventBranch (DT::Flow &flow, const string &name, const function< Ret(const Input &)> &f)
 
template<typename Ret >
void AddJetBranch (DT::Flow &flow, const string &name, const function< Ret(const RecJet &)> &f)
 
template<typename Ret >
void AddTPSScalarBranch (DT::Flow &flow, const string &name, const function< Ret(const MultiJets< RecJet > &)> &f)
 
template<typename Ret >
void AddTPSVectorBranch (DT::Flow &flow, const string &name, const function< Ret(const MultiJets< RecJet > &, int)> &f)
 
- Protected Member Functions inherited from BranchFlattener
 BranchFlattener (const Variation &v)
 
 BranchFlattener (const Variation &v)
 

Protected Attributes

const RecEventrecEvent
 
vector< RecJet > * recJets
 
unique_ptr< MultiJets< RecJet > > hexaJets
 
list< unique_ptr< DT::SelfAwareBranch< const RecEvent & > > > eventBranches
 
list< unique_ptr< DT::SelfAwareBranch< const vector< RecJet > & > > > jetCollectionBranches
 
list< unique_ptr< DT::SelfAwareBranch< const RecJet & > > > jetBranches
 
list< unique_ptr< DT::SelfAwareBranch< const MultiJets< RecJet > & > > > tpsScalarBranches
 
list< unique_ptr< DT::SelfAwareBranch< const MultiJets< RecJet > &, int > > > tpsVectorBranches
 
- Protected Attributes inherited from BranchFlattener
Variation v
 

Constructor & Destructor Documentation

◆ TPSBranchFlattener()

TPSBranchFlattener ( DT::Flow flow,
const Variation v 
)
inline
76  {
77  // Get input branches
78  recEvent = flow.GetBranchReadOnly<RecEvent>("recEvent");
79  recJets = flow.GetBranchReadOnly<vector<RecJet>>("recJets");
80 
81  // Add event-level branches
82  AddEventBranch<float, RecEvent>(flow, "EventWeight", [] (const RecEvent& evt) { return evt.weights.front(); });
83 
84  // Add jet collection branches
85  AddEventBranch<int, vector<RecJet>>(flow, "nJets", [] (const vector<RecJet>& jets) { return static_cast<int>(jets.size()); });
86 
87  // Add individual jet branches
88  AddJetBranch<float>(flow, "jet_pt", [this] (const RecJet& jet) { return jet.CorrP4().Pt(); });
89  AddJetBranch<float>(flow, "jet_eta", [this] (const RecJet& jet) { return jet.CorrP4().Eta(); });
90  AddJetBranch<float>(flow, "jet_phi", [this] (const RecJet& jet) { return jet.CorrP4().Phi(); });
91  AddJetBranch<float>(flow, "jet_mass", [this] (const RecJet& jet) { return jet.CorrP4().M(); });
92 
93  // Add TPS scalar branches
94  AddTPSScalarBranch<float>(flow, "S_pt", [] (const MultiJets<RecJet>& hexaJets) { return hexaJets.S_pt; });
95  AddTPSScalarBranch<float>(flow, "S_pt_min", [] (const MultiJets<RecJet>& hexaJets) { return hexaJets.S_pt_min; });
96  AddTPSScalarBranch<float>(flow, "S_phi", [] (const MultiJets<RecJet>& hexaJets) { return hexaJets.S_phi; });
97  AddTPSScalarBranch<float>(flow, "S_phi_min", [] (const MultiJets<RecJet>& hexaJets) { return hexaJets.S_phi_min; });
98 
99  // Add TPS vector branches for pairs
100  for (int i = 0; i < N_PAIRS; i++) {
101  const int pair_idx = i;
102  AddTPSVectorBranch<float>(flow, Form("pt_pair_asymm_vec_%d", i), [pair_idx] (const MultiJets<RecJet>& hexaJets, int idx) {return hexaJets.pt_pair_asymm_vec[pair_idx][idx];});
103  AddTPSVectorBranch<float>(flow, Form("pt_pair_asymm_abs_%d", i), [pair_idx] (const MultiJets<RecJet>& hexaJets, int idx) {return hexaJets.pt_pair_asymm_abs[pair_idx][idx];});
104  AddTPSVectorBranch<float>(flow, Form("Delta_eta_pair_%d", i), [pair_idx] (const MultiJets<RecJet>& hexaJets, int idx) {return hexaJets.Delta_eta_pair[pair_idx][idx];});
105  AddTPSVectorBranch<float>(flow, Form("Delta_phi_pair_%d", i), [pair_idx] (const MultiJets<RecJet>& hexaJets, int idx) {return hexaJets.Delta_phi_pair[pair_idx][idx];});
106  AddTPSVectorBranch<float>(flow, Form("m_inv_%d", i),[pair_idx] (const MultiJets<RecJet>& hexaJets, int idx) { return hexaJets.m_inv[pair_idx][idx]; });
107  }
108 
109  // Add TPS vector branches for permutations
110  AddTPSVectorBranch<float>(flow, "S_pt_perm", [] (const MultiJets<RecJet>& hexaJets, int idx) { return hexaJets.S_pt_perm[idx]; });
111  AddTPSVectorBranch<float>(flow, "S_pt_4", [] (const MultiJets<RecJet>& hexaJets, int idx) { return hexaJets.S_pt_4[idx]; });
112  AddTPSVectorBranch<float>(flow, "S_pt_4_min", [] (const MultiJets<RecJet>& hexaJets, int idx) { return hexaJets.S_pt_4_min[idx]; });
113  AddTPSVectorBranch<float>(flow, "S_phi_perm", [] (const MultiJets<RecJet>& hexaJets, int idx) { return hexaJets.S_phi_perm[idx]; });
114  AddTPSVectorBranch<float>(flow, "S_phi_4", [] (const MultiJets<RecJet>& hexaJets, int idx) { return hexaJets.S_phi_4[idx]; });
115  AddTPSVectorBranch<float>(flow, "S_phi_4_min", [] (const MultiJets<RecJet>& hexaJets, int idx) { return hexaJets.S_phi_4_min[idx]; });
116 
117  for (int i = 0; i < N_S_4_PERM; i++) {
118  const int perm_idx = i;
119  AddTPSVectorBranch<float>(
120  flow, Form("S_pt_4_perm_%d", i), [perm_idx] (const MultiJets<RecJet>& hexaJets, int idx) {
121  return hexaJets.S_pt_4_perm[perm_idx][idx];
122  });
123  AddTPSVectorBranch<float>(
124  flow, Form("S_phi_4_perm_%d", i), [perm_idx] (const MultiJets<RecJet>& hexaJets, int idx) {
125  return hexaJets.S_phi_4_perm[perm_idx][idx];
126  });
127  }
128  }

Member Function Documentation

◆ AddEventBranch()

void AddEventBranch ( DT::Flow flow,
const string &  name,
const function< Ret(const Input &)> &  f 
)
inlineprotected
47  {
48  if constexpr (is_same_v<Input, RecEvent>) {
49  eventBranches.emplace_back(make_unique<DT::SelfAwarePlainBranch<Ret, const Input&>>(flow, name, f));
50  } else if constexpr (is_same_v<Input, vector<RecJet>>) {
52  }
53  }

◆ AddJetBranch()

void AddJetBranch ( DT::Flow flow,
const string &  name,
const function< Ret(const RecJet &)> &  f 
)
inlineprotected
57  {
58  jetBranches.emplace_back(make_unique<DT::SelfAwareVectorBranch<Ret, const RecJet&>>(flow, name, f));
59  }

◆ AddTPSScalarBranch()

void AddTPSScalarBranch ( DT::Flow flow,
const string &  name,
const function< Ret(const MultiJets< RecJet > &)> &  f 
)
inlineprotected
63  {
64  tpsScalarBranches.emplace_back(make_unique<DT::SelfAwarePlainBranch<Ret, const MultiJets<RecJet>&>>(flow, name, f));
65  }

◆ AddTPSVectorBranch()

void AddTPSVectorBranch ( DT::Flow flow,
const string &  name,
const function< Ret(const MultiJets< RecJet > &, int)> &  f 
)
inlineprotected
69  {
70  tpsVectorBranches.emplace_back(make_unique<DT::SelfAwareVectorBranch<Ret, const MultiJets<RecJet>&, int>>(flow, name, f));
71  }

◆ Clear()

void Clear ( )
inlineoverridevirtual

Implements BranchFlattener.

144  {
145  for (const auto& branch : eventBranches) branch->Clear();
146  for (const auto& branch : jetCollectionBranches) branch->Clear();
147  for (const auto& branch : jetBranches) branch->Clear();
148  for (const auto& branch : tpsScalarBranches) branch->Clear();
149  for (const auto& branch : tpsVectorBranches) branch->Clear();
150  hexaJets.reset();
151  }

◆ Fill()

void Fill ( )
inlineoverridevirtual

Implements BranchFlattener.

131  {
132  for (const auto& branch : eventBranches) branch->Fill(*recEvent);
133  for (const auto& branch : jetCollectionBranches) branch->Fill(*recJets);
134  for (const auto& jet : *recJets)
135  for (const auto& branch : jetBranches) branch->Fill(jet);
136 
137  hexaJets = make_unique<MultiJets<RecJet>>(*recJets, 25);
138  for (const auto& branch : tpsScalarBranches) branch->Fill(*hexaJets);
139  for (size_t i = 0; i < N_S_4_PERM; i++)
140  for (const auto& branch : tpsVectorBranches) branch->Fill(*hexaJets, i);
141  }

Member Data Documentation

◆ eventBranches

list<unique_ptr<DT::SelfAwareBranch<const RecEvent&> > > eventBranches
protected

◆ hexaJets

unique_ptr<MultiJets<RecJet> > hexaJets
protected

◆ jetBranches

list<unique_ptr<DT::SelfAwareBranch<const RecJet&> > > jetBranches
protected

◆ jetCollectionBranches

list<unique_ptr<DT::SelfAwareBranch<const vector<RecJet>&> > > jetCollectionBranches
protected

◆ recEvent

const RecEvent* recEvent
protected

◆ recJets

vector<RecJet>* recJets
protected

◆ tpsScalarBranches

list<unique_ptr<DT::SelfAwareBranch<const MultiJets<RecJet>&> > > tpsScalarBranches
protected

◆ tpsVectorBranches

list<unique_ptr<DT::SelfAwareBranch<const MultiJets<RecJet>&, int> > > tpsVectorBranches
protected

The documentation for this class was generated from the following file:
DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.name
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
DAS::TPS::TPSBranchFlattener::recEvent
const RecEvent * recEvent
Definition: TPS.cc:28
DAS::TPS::N_S_4_PERM
static const int N_S_4_PERM
Definition: TPS.cc:21
DAS::TPS::TPSBranchFlattener::recJets
vector< RecJet > * recJets
Definition: TPS.cc:29
Ntupliser_cfg.f
f
Definition: Ntupliser_cfg.py:324
Darwin::Tools::SelfAwarePlainBranch
Type for a plain-type branch that knows how to fill itself.
Definition: SelfAwareBranch.h:44
Darwin::Tools::SelfAwareVectorBranch
Type for a vector branch that knows how to fill itself.
Definition: SelfAwareBranch.h:74
DAS::TPS::TPSBranchFlattener::hexaJets
unique_ptr< MultiJets< RecJet > > hexaJets
Definition: TPS.cc:30
Ntupliser_cfg.jets
string jets
Definition: Ntupliser_cfg.py:41
Darwin::Physics::BranchFlattener::v
Variation v
Definition: Flattener.h:42
DAS::TPS::TPSBranchFlattener::jetBranches
list< unique_ptr< DT::SelfAwareBranch< const RecJet & > > > jetBranches
Definition: TPS.cc:37
DAS::TPS::TPSBranchFlattener::eventBranches
list< unique_ptr< DT::SelfAwareBranch< const RecEvent & > > > eventBranches
Definition: TPS.cc:33
DAS::TPS::TPSBranchFlattener::jetCollectionBranches
list< unique_ptr< DT::SelfAwareBranch< const vector< RecJet > & > > > jetCollectionBranches
Definition: TPS.cc:34
DAS::TPS::TPSBranchFlattener::tpsVectorBranches
list< unique_ptr< DT::SelfAwareBranch< const MultiJets< RecJet > &, int > > > tpsVectorBranches
Definition: TPS.cc:43
Darwin::Tools::Flow::GetBranchReadOnly
T * GetBranchReadOnly(const std::string &name, BranchMode mode=mandatory)
Wrapper to initialise read-only branches.
Definition: Flow.h:301
DAS::TPS::TPSBranchFlattener::tpsScalarBranches
list< unique_ptr< DT::SelfAwareBranch< const MultiJets< RecJet > & > > > tpsScalarBranches
Definition: TPS.cc:40
Darwin::Physics::BranchFlattener::BranchFlattener
BranchFlattener(const Variation &v)
Definition: Flattener.h:43
DAS::TPS::MultiJets
Definition: TPS.h:35
DAS::TPS::N_PAIRS
static const int N_PAIRS
Definition: TPS.cc:21