DAS  3.0
Das Analysis System
Darwin::Physics Namespace Reference

Classes

class  AnonymousFinalStateObject
 
class  AnonymousScalableObject
 
class  AnonymousWeightableObject
 
class  BranchFlattener
 
struct  Di
 
class  EventObjectBranchFlattener
 
class  EventTreeFlattener
 
class  GenEvent
 
class  GenJet
 
class  GenMuon
 
class  GenPhoton
 
class  GenPV
 
class  JetTreeFlattener
 
class  MuonTreeFlattener
 
class  RecEvent
 
class  RecJet
 
class  RecMuon
 
class  RecPhoton
 
class  RecPV
 
class  ScaledObject
 
class  ScaledObjectBranchFlattener
 
class  TreeFlattener
 
class  Variation
 
struct  Weight
 
class  WeightedObject
 

Typedefs

using FourVector = ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > >
 
using Weights = std::vector< Weight >
 

Enumerations

enum  VarType {
  single = 0b0000, symmetric = 0b0001, replicas = 0b0010, bits = 0b0100,
  single = 0b0000, symmetric = 0b0001, replicas = 0b0010, bits = 0b0100
}
 
enum  VarType {
  single = 0b0000, symmetric = 0b0001, replicas = 0b0010, bits = 0b0100,
  single = 0b0000, symmetric = 0b0001, replicas = 0b0010, bits = 0b0100
}
 

Functions

const Variation nominal ("", "nominal")
 
bool operator== (const Weight &w, const int v)
 
bool operator== (const Weight &w, const float v)
 
bool operator== (const Weight &w, const double v)
 
bool operator== (const Weight &l, const Weight &r)
 
double operator* (const Weight &w, const int v)
 
double operator* (const int v, const Weight &w)
 
double operator* (const Weight &w, const float v)
 
double operator* (const float v, const Weight &w)
 
double operator* (const Weight &w, const double v)
 
double operator* (const double v, const Weight &w)
 
Weightoperator*= (Weight &w, const int v)
 
Weightoperator/= (Weight &w, const int v)
 
Weightoperator*= (Weight &w, const float v)
 
Weightoperator/= (Weight &w, const float v)
 
Weightoperator*= (Weight &w, const double v)
 
Weightoperator/= (Weight &w, const double v)
 
double operator* (const Weight &w1, const Weight &w2)
 
Weightsoperator*= (Weights &wgts, const int v)
 
Weightsoperator/= (Weights &wgts, const int v)
 
Weightsoperator*= (Weights &wgts, const float v)
 
Weightsoperator/= (Weights &wgts, const float v)
 
Weightsoperator*= (Weights &wgts, const double v)
 
Weightsoperator/= (Weights &wgts, const double v)
 
bool operator== (const Weights &w1, const Weights &w2)
 
std::strong_ordering operator<=> (const Variation &lhs, const Variation &rhs)
 
template<bool DARWIN_TEST_EXCEPTIONS = false>
void example02 (const vector< fs::path > &inputs, const fs::path &output, const pt::ptree &config, const int steering, const DT::Slice slice={1, 0}, const vector< fs::path > &plugin_paths={})
 
template<bool DARWIN_TEST_EXCEPTIONS = false>
void example03 (const vector< fs::path > &inputs, const fs::path &output, const pt::ptree &config, const int steering, const DT::Slice slice={1, 0}, const vector< fs::path > &plugin_paths={})
 
void example04 (const vector< fs::path > &inputs, const fs::path &output, const pt::ptree &config, const int steering, const DT::Slice slice={1, 0})
 
template<bool DARWIN_TEST_EXCEPTIONS = false>
void example02 (const fs::path &input, const fs::path &output, const pt::ptree &config, const int steering, const DT::Slice slice={1, 0})
 
template<bool DARWIN_TEST_EXCEPTIONS = false>
void example03 (const fs::path &input, const fs::path &output, const pt::ptree &config, const int steering, const DT::Slice slice={1, 0}, const vector< fs::path > plugins={})
 
void example04 (const fs::path &input, const fs::path &output, const pt::ptree &config, const int steering, const DT::Slice slice={1, 0})
 

Detailed Description

Everything what concerns physics analysis directly.

Typedef Documentation

◆ FourVector

typedef ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector

◆ Weights

typedef std::vector< Weight > Weights

Enumeration Type Documentation

◆ VarType [1/2]

enum VarType
Enumerator
single 
symmetric 
replicas 
bits 
single 
symmetric 
replicas 
bits 
13  {
14  single = 0b0000,
15  symmetric = 0b0001,
16  replicas = 0b0010,
17  bits = 0b0100
18 };

◆ VarType [2/2]

enum VarType
Enumerator
single 
symmetric 
replicas 
bits 
single 
symmetric 
replicas 
bits 
13  {
14  single = 0b0000,
15  symmetric = 0b0001,
16  replicas = 0b0010,
17  bits = 0b0100
18 };

Function Documentation

◆ example02() [1/2]

void Darwin::Physics::example02 ( const fs::path &  input,
const fs::path &  output,
const pt::ptree &  config,
const int  steering,
const DT::Slice  slice = {1,0} 
)
46  {1,0})
47 {
48  example02<DARWIN_TEST_EXCEPTIONS>(vector<fs::path>{input}, output, config, steering, slice);
49 }

◆ example02() [2/2]

void Darwin::Physics::example02 ( const vector< fs::path > &  inputs,
const fs::path &  output,
const pt::ptree &  config,
const int  steering,
const DT::Slice  slice = {1,0},
const vector< fs::path > &  plugin_paths = {} 
)

Toy example to modify a n-tuple.

The template argument is only for the test of exceptions in unit tests.

Parameters
inputsinput ROOT files (n-tuples)
outputoutput ROOT file (n-tuple)
configconfig handled with `Darwin::Tools::options`
steeringparameters obtained from explicit options
slicenumber and index of slice
plugin_pathsany plugin to load
34  {1,0},
35  const vector<fs::path>& plugin_paths = {}
36  )
37 {
38  cout << __func__ << " start" << endl;
39 
40  DT::Flow flow(steering, inputs);
41  auto tIn = flow.GetInputTree(slice);
42  auto tOut = flow.GetOutputTree(output);
43 
44  DT::MetaInfo metainfo(tOut, config);
45 
46  auto plugins = flow.GetPlugins<DT::GenericPlugin>(plugin_paths);
48  plugin->Load(flow, metainfo, steering);
49 
50  auto recEvent = flow.GetBranchReadWrite<RecEvent>("recEvent");
51 
52  const auto& corrections = config.get_child("corrections");
53  metainfo.Set<string>("corrections", "filters", corrections.get<string>("filters"));
54 
55  for (DT::Looper looper(tIn); looper(); ++looper) {
56  [[maybe_unused]]
57  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
58 
59  if constexpr (DARWIN_TEST_EXCEPTIONS)
60  if (*looper == 5)
61  BOOST_THROW_EXCEPTION(DE::AnomalousEvent("Here is an anomally", tIn));
62 
64  plugin->ExecuteAtBegin();
65 
66  recEvent->weights.front() *= (*looper % 2) ? 1.1 : 0.9;
67  // \todo Rather apply the filter given from the command line
68 
69  for (DT::GenericPlugin * plugin: plugins | views::reverse)
70  plugin->ExecuteAtEnd();
71 
72  if (steering & DT::fill) tOut->Fill();
73  }
74 
75  metainfo.Set<bool>("git", "complete", true);
76 
77  cout << __func__ << " end" << endl;
78 }

◆ example03() [1/2]

void Darwin::Physics::example03 ( const fs::path &  input,
const fs::path &  output,
const pt::ptree &  config,
const int  steering,
const DT::Slice  slice = {1,0},
const vector< fs::path >  plugins = {} 
)
54  {1,0},
55  const vector<fs::path> plugins = {})
56 {
57  example03<DARWIN_TEST_EXCEPTIONS>(vector<fs::path>{input}, output, config, steering, slice, plugins);
58 }

◆ example03() [2/2]

void Darwin::Physics::example03 ( const vector< fs::path > &  inputs,
const fs::path &  output,
const pt::ptree &  config,
const int  steering,
const DT::Slice  slice = {1,0},
const vector< fs::path > &  plugin_paths = {} 
)

Toy example to modify a n-tuple.

The template argument is only for the test of exceptions in unit tests.

Parameters
inputsinput ROOT files (n-tuples)
outputoutput ROOT file (n-tuple)
configconfig handled with `Darwin::Tools::options`
steeringparameters obtained from explicit options
slicenumber and index of slice
plugin_pathsany plugin to load
34  {1,0},
35  const vector<fs::path>& plugin_paths = {}
36  )
37 {
38  cout << __func__ << " start" << endl;
39 
40  DT::Flow flow(steering, inputs);
41  auto tIn = flow.GetInputTree(slice);
42  auto tOut = flow.GetOutputTree(output);
43 
44  DT::MetaInfo metainfo(tOut, config);
45  metainfo.AddVars(RecJet::ScaleVar, {"JES"});
46 
47  auto plugins = flow.GetPlugins<DT::GenericPlugin>(plugin_paths);
49  plugin->Load(flow, metainfo, steering, config);
50 
51  auto recJets = flow.GetBranchReadWrite<vector<RecJet>>("recJets");
52 
53  // event loop
54  for (DT::Looper looper(tIn); looper(); ++looper) {
55  [[maybe_unused]]
56  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
57 
58  if constexpr (DARWIN_TEST_EXCEPTIONS)
59  if (*looper == 5)
60  BOOST_THROW_EXCEPTION(DE::AnomalousEvent("Here is an anomally", tIn));
61 
63  plugin->ExecuteAtBegin();
64 
65  for (auto& recJet: *recJets) {
66  recJet.area = M_PI*pow(0.4,2);
67  recJet.scales = {1.1}; // nominal
68  if (steering & DT::syst) {
69  recJet.scales.push_back(1.05); // JESdn
70  recJet.scales.push_back(1.15); // JESup
71  }
72  if (*looper % 100 == 0)
73  cout << recJet << endl;
74  }
75 
76  for (DT::GenericPlugin * plugin: plugins | views::reverse)
77  plugin->ExecuteAtEnd();
78 
79  if (steering & DT::fill) tOut->Fill();
80  }
81 
82  metainfo.Set<bool>("git", "complete", true);
83 
84  cout << __func__ << " end" << endl;
85 }

◆ example04() [1/2]

void Darwin::Physics::example04 ( const fs::path &  input,
const fs::path &  output,
const pt::ptree &  config,
const int  steering,
const DT::Slice  slice = {1,0} 
)
62  {1,0})
63 {
64  example04(vector<fs::path>{input}, output, config, steering, slice);
65 }

◆ example04() [2/2]

void Darwin::Physics::example04 ( const vector< fs::path > &  inputs,
const fs::path &  output,
const pt::ptree &  config,
const int  steering,
const DT::Slice  slice = {1,0} 
)

Toy example to project a n-tuple.

Parameters
inputsinput ROOT files (n-tuple)
outputoutput ROOT file (histograms)
configconfig handled with `Darwin::Tools::Options`
steeringparameters obtained from explicit options
slicenumber and index of slice
36  {1,0}
37  )
38 {
39  cout << __func__ << " start" << endl;
40 
41  DT::Flow flow(steering, inputs);
42  auto tIn = flow.GetInputTree(slice);
43  auto [fOut, tOut] = flow.GetOutput(output);
44 
45  DT::MetaInfo metainfo(tOut, config);
46  auto isMC = metainfo.Get<bool>("flags", "isMC");
47  set<Variation> systs {nominal};
48  if (steering & DT::syst)
49  systs.merge(metainfo.GetVars(RecJet::ScaleVar));
50 
51  auto recEvent = flow.GetBranchReadOnly<RecEvent>("recEvent");
52  auto genEvent = isMC ? flow.GetBranchReadOnly<GenEvent>("genEvent") : nullptr;
53  auto recJets = flow.GetBranchReadOnly<vector<RecJet>>("recJets");
54  auto genJets = isMC ? flow.GetBranchReadOnly<vector<GenJet>>("genJets") : nullptr;
55 
56  map<Variation, unique_ptr<TH1D>> vars_hrecs;
57  for (auto&& syst: systs) {
58  string hname = "hrec";
59  hname += syst.Name();
60  vars_hrecs[syst] = make_unique<TH1D>(hname.c_str(), ";p_{T};N", 111, 0, 110);
61  }
62  auto hgen = make_unique<TH1D>("hgen", ";p_{T};N", 111, 0, 110);
63 
64  // event loop
65  for (DT::Looper looper(tIn); looper(); ++looper) {
66  [[maybe_unused]]
67  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
68 
69  double w = recEvent->weights.front();
70  if (isMC) w *= genEvent->weights.front();
71  for (const auto& [v, hrec]: vars_hrecs)
72  for (const auto& recJet: *recJets) {
73  hrec->Fill(recJet.CorrPt(v), w);
74  cout << "recJet: " << recJets << " " << recJet.CorrPt(v) << endl;
75  }
76 
77  if (!isMC) continue;
78 
79  if (recJets->size() != genJets->size()) cout << red;
80 
81  w = genEvent->weights.front();
82  for (const auto& genJet: *genJets) {
83  hgen->Fill(genJet.CorrPt(), w);
84  cout << "genJet: " << genJets << " " << genJet.CorrPt() << endl;
85  }
86  cout << def;
87  // here we do *NOT* fill the tree
88  }
89 
90  metainfo.Set<bool>("git", "complete", true);
91 
92  fOut->cd();
93  for (const auto& [_, hrec]: vars_hrecs)
94  hrec->Write();
95  hgen->Write();
96 
97  cout << __func__ << " end" << endl;
98 }

◆ nominal()

const Variation nominal ( ""  ,
"nominal"   
)
inline

◆ operator*() [1/7]

double operator* ( const double  v,
const Weight w 
)
inline
36 { return w.v * v; }

◆ operator*() [2/7]

double operator* ( const float  v,
const Weight w 
)
inline
34 { return w.v * v; }

◆ operator*() [3/7]

double operator* ( const int  v,
const Weight w 
)
inline
32 { return w.v * v; }

◆ operator*() [4/7]

double operator* ( const Weight w,
const double  v 
)
inline
35 { return w.v * v; }

◆ operator*() [5/7]

double operator* ( const Weight w,
const float  v 
)
inline
33 { return w.v * v; }

◆ operator*() [6/7]

double operator* ( const Weight w,
const int  v 
)
inline
31 { return w.v * v; }

◆ operator*() [7/7]

double operator* ( const Weight w1,
const Weight w2 
)
inline
43 { return w1.v * w2.v; }

◆ operator*=() [1/6]

Weight & operator*= ( Weight w,
const double  v 
)
inline
41 { w.v *= v; return w; }

◆ operator*=() [2/6]

Weight & operator*= ( Weight w,
const float  v 
)
inline
39 { w.v *= v; return w; }

◆ operator*=() [3/6]

Weight & operator*= ( Weight w,
const int  v 
)
inline
37 { w.v *= v; return w; }

◆ operator*=() [4/6]

Weights & operator*= ( Weights wgts,
const double  v 
)
inline
51 { for (auto& w: wgts) w *= v; return wgts; }

◆ operator*=() [5/6]

Weights & operator*= ( Weights wgts,
const float  v 
)
inline
49 { for (auto& w: wgts) w *= v; return wgts; }

◆ operator*=() [6/6]

Weights & operator*= ( Weights wgts,
const int  v 
)
inline
47 { for (auto& w: wgts) w *= v; return wgts; }

◆ operator/=() [1/6]

Weight & operator/= ( Weight w,
const double  v 
)
inline
42 { w.v /= v; return w; }

◆ operator/=() [2/6]

Weight & operator/= ( Weight w,
const float  v 
)
inline
40 { w.v /= v; return w; }

◆ operator/=() [3/6]

Weight & operator/= ( Weight w,
const int  v 
)
inline
38 { w.v /= v; return w; }

◆ operator/=() [4/6]

Weights & operator/= ( Weights wgts,
const double  v 
)
inline
52 { for (auto& w: wgts) w /= v; return wgts; }

◆ operator/=() [5/6]

Weights & operator/= ( Weights wgts,
const float  v 
)
inline
50 { for (auto& w: wgts) w /= v; return wgts; }

◆ operator/=() [6/6]

Weights & operator/= ( Weights wgts,
const int  v 
)
inline
48 { for (auto& w: wgts) w /= v; return wgts; }

◆ operator<=>()

std::strong_ordering Darwin::Physics::operator<=> ( const Variation lhs,
const Variation rhs 
)
11 {
12  int c = strnatcmp(lhs.Name().data(), rhs.Name().data()); // natural sortering
13  auto tlhs = make_tuple(lhs.Group(), lhs.Index(), 0, lhs.Bit());
14  auto trhs = make_tuple(rhs.Group(), rhs.Index(), c, rhs.Bit());
15  return tlhs <=> trhs;
16 }

◆ operator==() [1/5]

bool operator== ( const Weight l,
const Weight r 
)
inline
30 { return l.v == r.v && l.i == r.i; }

◆ operator==() [2/5]

bool operator== ( const Weight w,
const double  v 
)
inline
29 { return w.v == v; }

◆ operator==() [3/5]

bool operator== ( const Weight w,
const float  v 
)
inline
28 { return w.v == v; }

◆ operator==() [4/5]

bool operator== ( const Weight w,
const int  v 
)
inline
27 { return w.v == v; }

◆ operator==() [5/5]

bool operator== ( const Weights w1,
const Weights w2 
)
inline
54 {
55  if (w1.size() != w2.size()) return false;
56  for (std::size_t i = 0; i < w1.size(); ++i)
57  if (w1.at(i) != w2.at(i)) return false;
58  return true;
59 }
Darwin::Physics::replicas
@ replicas
Definition: Variation.h:16
Darwin::Tools::fill
@ fill
activate -f to fill the tree
Definition: Options.h:32
Darwin::Physics::Variation::Index
size_t Index() const
Definition: Variation.h:70
Darwin::Tools::Flow
User-friendly handling of input and output n-tuples.
Definition: Flow.h:80
Step::verbose
static bool verbose
Definition: Step.h:40
Step::def
static const char * def
Definition: Step.h:36
strnatcmp
int strnatcmp(nat_char const *a, nat_char const *b)
Definition: strnatcmp.c:168
Darwin::Tools::GenericPlugin
Generic plugin class.
Definition: GenericPlugin.h:42
Darwin::Physics::bits
@ bits
Definition: Variation.h:17
Darwin::Tools::Looper
Facility to loop over a n-tuple, including parallelisation and printing.
Definition: Looper.h:22
Darwin::Tools::syst
@ syst
activate -s to systematic uncertainties
Definition: Options.h:34
Darwin::Physics::example04
void example04(const fs::path &input, const fs::path &output, const pt::ptree &config, const int steering, const DT::Slice slice={1, 0})
Definition: main.cc:60
Darwin::Physics::Variation::Group
std::string_view Group() const
Definition: Variation.h:68
Darwin::Tools::MetaInfo
Generic meta-information for n-tuple (including speficities to Darwin).
Definition: MetaInfo.h:68
Darwin::Tools::plugin
@ plugin
activate -p to run a plugin
Definition: Options.h:35
Darwin::Physics::Variation::Bit
int Bit() const
Definition: Variation.h:71
plugins
PluginsVec * plugins()
Definition: IPlugin.h:77
Step::red
static const char * red
Definition: Step.h:34
Ntupliser_cfg.config
config
Definition: Ntupliser_cfg.py:333
DAS::Uncertainties::nominal
const Variation nominal
Definition: Variation.h:55
DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.input
input
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:35
Darwin::Physics::single
@ single
Definition: Variation.h:14
Ntupliser_cfg.isMC
dictionary isMC
Definition: Ntupliser_cfg.py:62
jercExample.inputs
def inputs
Definition: jercExample.py:118
Darwin::Exceptions::AnomalousEvent
Generic exception for problematic event (during event loop).
Definition: exceptions.h:63
Darwin::Tools::dev_null
static std::ostream dev_null(nullptr)
to redirect output stream to nowhere
Darwin::Physics::Variation::Name
std::string_view Name() const
Definition: Variation.h:69
Darwin::Physics::symmetric
@ symmetric
Definition: Variation.h:15