DAS  3.0
Das Analysis System
Di.cc File Reference
#include <boost/test/included/unit_test.hpp>
#include <iostream>
#include <map>
#include <TFile.h>
#include <TTree.h>
#include <Di.h>
#include <Jet.h>
+ Include dependency graph for Di.cc:

Macros

#define BOOST_TEST_MODULE   Di
 

Functions

vector< GenJetGetDummyGenJets ()
 
 BOOST_AUTO_TEST_CASE (dijet)
 
 BOOST_TEST (gendijet.Rapidity()==1.3573785791881385)
 
 BOOST_AUTO_TEST_CASE (variations)
 

Variables

Di< GenJet, GenJetgendijet {&genjets.at(0), &genjets.at(1)}
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   Di

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( dijet  )
52 {
53  vector<GenJet> * genjets = new vector<GenJet>;
54  auto gendijet = new Di<GenJet,GenJet>;
55  bool valid = static_cast<bool>(*gendijet);
56  BOOST_TEST(!valid);
57 
59  //cout << *gendijet << endl;
60  //*gendijet = genjets->at(0) + genjets->at(1);
61  gendijet->first = &genjets->at(0);
62  gendijet->second = &genjets->at(1);
63  valid = static_cast<bool>(*gendijet);
64  BOOST_TEST(valid);
65 
66  auto f = make_unique<TFile>("di.root", "RECREATE");
67 
68  cout << "Creating tree" << endl;
69  {
70  auto t = make_unique<TTree>("tree", "tree");
71  t->Branch("genJets", &genjets);
72  t->Branch("genDijet", &gendijet);
73  t->Fill();
74  t->Write();
75  // Note: calling `TTree:Scan()` at this stage leads to a seg
76  }
77 
78  delete genjets;
79  delete gendijet;
80  genjets = nullptr;
81  gendijet = nullptr;
82 
83  cout << "Reading tree" << endl;
84  {
85  auto t = unique_ptr<TTree>(f->Get<TTree>("tree"));
86  t->Show(0);
87  cout << "Checking genJets" << endl;
88  t->Scan("genJets.CorrPt()");
89  cout << "Checking genDijet" << endl;
90  t->Scan("genDijet.first.CorrPt():genDijet.second.CorrPt():genDijet.HT()");
91  cout << "Setting branch addresses" << endl;
92  t->SetBranchAddress("genJets", &genjets);
93  t->SetBranchAddress("genDijet", &gendijet);
94  t->GetEntry(0);
95  BOOST_TEST( genjets->at(0).CorrPt() == 1. );
96  BOOST_TEST( genjets->at(1).CorrPt() == 2. );
97  BOOST_TEST( gendijet->HT() == 1.5 );
98  gendijet->clear();
99  BOOST_TEST( gendijet->first == nullptr );
100  BOOST_TEST( gendijet->second == nullptr );
101  }
102 }

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( variations  )
124 {
125  auto genjets = GetDummyGenJets();
126  //auto gendijet = genjets.at(0) + genjets.at(1);
127  Di<GenJet,GenJet> gendijet {&genjets.at(0), &genjets.at(1)};
128 
129  using namespace Darwin::Physics;
130  cout << genjets.at(0).Weight(nominal) << ' ' << genjets.at(1).Weight(nominal) << ' ' << gendijet.Weight(nominal) << endl;
131 
132  map<int, double> bits_results {{1,1.5}, {2,1.5}, {3,1.0}};
133  for (auto bit_result: bits_results) {
134  int bit = bit_result.first;
135  double result = bit_result.second;
136  Variation v(GenJet::WeightVar, "wgtUp_stat" + to_string(bit), 1, bit);
137  cout << "1st-jet weight: " << genjets.at(0).Weight(v) << '\n'
138  << "2nd-jet weight: " << genjets.at(1).Weight(v) << '\n'
139  << "dijet weight: " << gendijet.Weight(v) << endl;
140  BOOST_TEST( gendijet.Weight(v) == result );
141  }
142 
143  for (int i = 1; i <= 2; ++i) {
144  Variation v(GenJet::ScaleVar, "scale", i);
145  cout << "1st-jet corrected pt: " << genjets.at(0).CorrPt(v) << '\n'
146  << "2nd-jet corrected pt: " << genjets.at(1).CorrPt(v) << '\n'
147  << "dijet corrected pt: " << gendijet.CorrPt(v) << '\n'
148  << "dijet corrected HT: " << gendijet.HT(v) << endl;
149  BOOST_TEST( genjets.at(0).CorrPt(i) == genjets.at(0).CorrPt(v) );
150  BOOST_TEST( genjets.at(1).CorrPt(i) == genjets.at(1).CorrPt(v) );
151  BOOST_TEST( 2*gendijet.HT(v) == genjets.at(0).CorrPt(i) + genjets.at(1).CorrPt(i) );
152  }
153 }

◆ BOOST_TEST()

BOOST_TEST ( gendijet.  Rapidity() = =1.3573785791881385)

◆ GetDummyGenJets()

vector<GenJet> GetDummyGenJets ( )
25 {
26  GenJet genjet1, genjet2;
27 
28  // 4-vectors
29  genjet1.p4 = {1,1,1,1};
30  genjet2.p4 = {2,2,2,2};
31 
32  // JES
33  genjet1.scales.push_back(1.5);
34  genjet1.scales.push_back(0.5);
35  genjet2.scales.push_back(1.5);
36  genjet2.scales.push_back(0.5);
37 
38  // weights
39  genjet1.weights.push_back({1.5,1});
40  genjet1.weights.push_back({0.5,1});
41  genjet2.weights.push_back({1.5,2});
42  genjet2.weights.push_back({0.5,2});
43 
44  // collection
45  vector<GenJet> genjets;
46  genjets.push_back(genjet1);
47  genjets.push_back(genjet2);
48  return genjets;
49 }

Variable Documentation

◆ gendijet

Di<GenJet,GenJet> gendijet {&genjets.at(0), &genjets.at(1)}
gendijet
GenDijet gendijet
Definition: Di.cc:98
GetDummyGenJets
vector< GenJet > GetDummyGenJets()
Definition: Di.cc:18
BOOST_TEST
BOOST_TEST(gendijet.Rapidity()==1.3573785791881385)
Ntupliser_cfg.f
f
Definition: Ntupliser_cfg.py:256
Darwin::Physics::GenJet
Generic generator-level jet.
Definition: Jet.h:14
Darwin::Physics::Variation
Definition: Variation.h:20
Ntupliser_cfg.genjets
genjets
Definition: Ntupliser_cfg.py:272
Darwin::Physics::GenericObject::weights
Weights weights
object weights
Definition: GenericObject.h:55
Darwin::Physics::GenJet::WeightVar
static const char *const *const WeightVar
Definition: Jet.h:21
Darwin::Physics::nominal
const Variation nominal("", "nominal")
Darwin::Physics::GenericObject::scales
std::vector< float > scales
energy scale corrections and variations
Definition: GenericObject.h:54
Darwin::Physics::Di
Definition: Di.h:37
Darwin::Physics::GenJet::ScaleVar
static const char *const ScaleVar
Definition: Jet.h:20
Darwin::Physics::GenericObject::p4
FourVector p4
raw four-momentum directly after reconstruction
Definition: GenericObject.h:53
Darwin::Physics
Everything what concerns physics analysis directly.
Definition: darwin.h:24