DAS  3.0
Das Analysis System
Darwin::Physics Namespace Reference

Classes

class  AbstractEvent
 
class  AbstractGenericObject
 
class  Di
 
class  GenericObject
 
class  GenEvent
 
class  GenJet
 
class  GenMuon
 
class  GenPhoton
 
class  RecEvent
 
class  RecJet
 
class  RecMuon
 
class  RecPhoton
 
class  Variation
 
struct  Weight
 

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

bool operator== (const GenericObject &l, const GenericObject &r)
 
bool operator< (const GenericObject &l, const GenericObject &r)
 
bool operator> (const GenericObject &l, const GenericObject &r)
 
const Variation nominal ("", "nominal")
 
std::strong_ordering operator<=> (const Variation &lhs, const Variation &rhs)
 
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)
 
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})
 
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})
 
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})
 
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} 
)
45  {1,0} )
46 {
47  example02<DARWIN_TEST_EXCEPTIONS>(vector<fs::path>{input}, output, config, steering, slice);
48 }

◆ 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} 
)

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
33  {1,0}
34  )
35 {
36  cout << __func__ << ' ' << slice << " start" << endl;
37 
38  DT::Flow flow(steering, inputs);
39  auto tIn = flow.GetInputTree(slice);
40  auto tOut = flow.GetOutputTree(output);
41 
42  DT::MetaInfo metainfo(tOut);
43  metainfo.Check(config);
44 
45  auto recEvent = flow.GetBranchReadWrite<RecEvent>("recEvent");
46 
47  const auto& corrections = config.get_child("corrections");
48  metainfo.Set<string>("corrections", "filters", corrections.get<string>("filters"));
49 
50  for (DT::Looper looper(tIn); looper(); ++looper) {
51  [[maybe_unused]]
52  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
53 
54  if constexpr (DARWIN_TEST_EXCEPTIONS)
55  if (*looper == 5)
56  BOOST_THROW_EXCEPTION(DE::AnomalousEvent("Here is an anomally", tIn));
57 
58  recEvent->weights.front() *= (*looper % 2) ? 1.1 : 0.9;
59  // \todo Rather apply the filter given from the command line
60 
61  if (steering & DT::fill) tOut->Fill();
62  }
63 
64  metainfo.Set<bool>("git", "complete", true);
65 
66  cout << __func__ << ' ' << slice << " end" << endl;
67 }

◆ 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} 
)
53  {1,0} )
54 {
55  example03<DARWIN_TEST_EXCEPTIONS>(vector<fs::path>{input}, output, config, steering, slice);
56 }

◆ 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} 
)

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
33  {1,0}
34  )
35 {
36  cout << __func__ << ' ' << slice << " start" << endl;
37 
38  DT::Flow flow(steering, inputs);
39  auto tIn = flow.GetInputTree(slice);
40  auto tOut = flow.GetOutputTree(output);
41 
42  DT::MetaInfo metainfo(tOut);
43  metainfo.Check(config);
44  metainfo.AddVars(RecJet::ScaleVar, {"JES"});
45 
46  auto recJets = flow.GetBranchReadWrite<vector<RecJet>>("recJets");
47 
48  // event loop
49  for (DT::Looper looper(tIn); looper(); ++looper) {
50  [[maybe_unused]]
51  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
52 
53  if constexpr (DARWIN_TEST_EXCEPTIONS)
54  if (*looper == 5)
55  BOOST_THROW_EXCEPTION(DE::AnomalousEvent("Here is an anomally", tIn));
56 
57  for (auto& recJet: *recJets) {
58  recJet.area = M_PI*pow(0.4,2);
59  recJet.scales = {1.1}; // nominal
60  if (steering & DT::syst) {
61  recJet.scales.push_back(1.05); // JESdn
62  recJet.scales.push_back(1.15); // JESup
63  }
64  cout << recJet << endl;
65  }
66 
67  if (steering & DT::fill) tOut->Fill();
68  }
69 
70  metainfo.Set<bool>("git", "complete", true);
71 
72  cout << __func__ << ' ' << slice << " end" << endl;
73 }

◆ 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} 
)
60  {1,0})
61 {
62  example04(vector<fs::path>{input}, output, config, steering, slice);
63 }

◆ 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__ << ' ' << slice << " 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);
46  metainfo.Check(config);
47  auto isMC = metainfo.Get<bool>("flags", "isMC");
48  set<Variation> systs {nominal};
49  if (steering & DT::syst)
50  systs.merge(metainfo.GetVars(RecJet::ScaleVar));
51 
52  auto recEvent = flow.GetBranchReadOnly<RecEvent>("recEvent");
53  auto genEvent = isMC ? flow.GetBranchReadOnly<GenEvent>("genEvent") : nullptr;
54  auto recJets = flow.GetBranchReadOnly<vector<RecJet>>("recJets");
55  auto genJets = isMC ? flow.GetBranchReadOnly<vector<GenJet>>("genJets") : nullptr;
56 
57  map<Variation, unique_ptr<TH1D>> vars_hrecs;
58  for (auto&& syst: systs) {
59  string hname = "hrec";
60  hname += syst.Name();
61  vars_hrecs[syst] = make_unique<TH1D>(hname.c_str(), ";p_{T};N", 111, 0, 110);
62  }
63  auto hgen = make_unique<TH1D>("hgen", ";p_{T};N", 111, 0, 110);
64 
65  // event loop
66  for (DT::Looper looper(tIn); looper(); ++looper) {
67  [[maybe_unused]]
68  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
69 
70  double w = recEvent->weights.front();
71  if (isMC) w *= genEvent->weights.front();
72  for (const auto& [v, hrec]: vars_hrecs)
73  for (const auto& recJet: *recJets) {
74  hrec->Fill(recJet.CorrPt(v), w);
75  cout << "recJet: " << recJets << " " << recJet.CorrPt(v) << endl;
76  }
77 
78  if (!isMC) continue;
79 
80  if (recJets->size() != genJets->size()) cout << red;
81 
82  w = genEvent->weights.front();
83  for (const auto& genJet: *genJets) {
84  hgen->Fill(genJet.CorrPt(), w);
85  cout << "genJet: " << genJets << " " << genJet.CorrPt() << endl;
86  }
87  cout << def;
88  // here we do *NOT* fill the tree
89  }
90 
91  metainfo.Set<bool>("git", "complete", true);
92 
93  fOut->cd();
94  for (const auto& [_, hrec]: vars_hrecs)
95  hrec->Write();
96  hgen->Write();
97 
98  cout << __func__ << ' ' << slice << " end" << endl;
99 }

◆ nominal()

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

◆ operator*() [1/7]

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

◆ operator*() [2/7]

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

◆ operator*() [3/7]

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

◆ operator*() [4/7]

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

◆ operator*() [5/7]

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

◆ operator*() [6/7]

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

◆ operator*() [7/7]

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

◆ operator*=() [1/6]

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

◆ operator*=() [2/6]

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

◆ operator*=() [3/6]

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

◆ operator*=() [4/6]

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

◆ operator*=() [5/6]

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

◆ operator*=() [6/6]

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

◆ operator/=() [1/6]

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

◆ operator/=() [2/6]

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

◆ operator/=() [3/6]

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

◆ operator/=() [4/6]

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

◆ operator/=() [5/6]

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

◆ operator/=() [6/6]

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

◆ operator<()

bool operator< ( const GenericObject l,
const GenericObject r 
)
inline
84 {
85  return l.CorrPt() < r.CorrPt();
86 }

◆ operator<=>()

std::strong_ordering 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/6]

bool operator== ( const GenericObject l,
const GenericObject r 
)
inline
79 {
80  return l.p4 == r.p4 && l.scales == r.scales && l.weights == r.weights;
81 }

◆ operator==() [2/6]

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

◆ operator==() [3/6]

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

◆ operator==() [4/6]

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

◆ operator==() [5/6]

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

◆ operator==() [6/6]

bool operator== ( const Weights w1,
const Weights w2 
)
inline
51 {
52  if (w1.size() != w2.size()) return false;
53  for (std::size_t i = 0; i < w1.size(); ++i)
54  if (w1.at(i) != w2.at(i)) return false;
55  return true;
56 }

◆ operator>()

bool operator> ( const GenericObject l,
const GenericObject r 
)
inline
89 {
90  return l.CorrPt() > r.CorrPt();
91 }
Darwin::Physics::replicas
@ replicas
Definition: Variation.h:16
Darwin::Tools::fill
@ fill
activate -f to fill the tree
Definition: Options.h:27
Darwin::Tools::Flow
User-friendly handling of input and output n-tuples.
Definition: Flow.h:69
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::Physics::bits
@ bits
Definition: Variation.h:17
Darwin::Tools::Looper
Facility to loop over a n-tuple, including parallelisation and printing.
Definition: Looper.h:32
Darwin::Tools::syst
@ syst
activate -s to systematic uncertainties
Definition: Options.h:29
DAS::JetEnergy::w
static const float w
Definition: common.h:51
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:58
Darwin::Tools::MetaInfo
Generic meta-information for n-tuple (including speficities to Darwin).
Definition: MetaInfo.h:68
Step::red
static const char * red
Definition: Step.h:34
Ntupliser_cfg.config
config
Definition: Ntupliser_cfg.py:264
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
string isMC
Definition: Ntupliser_cfg.py:59
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::symmetric
@ symmetric
Definition: Variation.h:15