DAS  3.0
Das Analysis System
BFFillerfinal

#include <BF.h>

+ Inheritance diagram for BFFiller:
+ Collaboration diagram for BFFiller:

Public Member Functions

 BFFiller (const BF &obs, TTreeReader &reader)
 
std::list< int > fillRec (DistVariation &) override
 
void match () override
 
void fillMC (DistVariation &) override
 
- Public Member Functions inherited from Filler
virtual ~Filler ()=default
 

Public Attributes

BF obs
 
std::optional< TTreeReaderArray< GenMuon > > genMuons
 
std::optional< TTreeReaderArray< GenPhoton > > genPhotons
 
TTreeReaderArray< RecMuonrecMuons
 
TTreeReaderArray< RecPhotonrecPhotons
 
std::optional< TTreeReaderValue< GenEvent > > gEv
 
TTreeReaderValue< RecEventrEv
 

Private Attributes

std::optional< int > irecbin
 
std::optional< float > recZW
 

Constructor & Destructor Documentation

◆ BFFiller()

BFFiller ( const BF obs,
TTreeReader &  reader 
)

Constructor.

41  : obs(obs)
42  , genMuons(initOptionalBranch<decltype(genMuons)>(reader, "genMuons"))
43  , genPhotons(initOptionalBranch<decltype(genPhotons)>(reader, "genPhotons"))
44  , recMuons(reader, "recMuons")
45  , recPhotons(reader, "recPhotons")
46  , gEv(initOptionalBranch<decltype(gEv)>(reader, "genEvent"))
47  , rEv(reader, "recEvent")
48 {
49 }

Member Function Documentation

◆ fillMC()

void fillMC ( DistVariation v)
overridevirtual

See Filler::fillMC

Todo:
no weight for gen photons?

Reimplemented from Filler.

116 {
117  if (!obs.isMC)
118  BOOST_THROW_EXCEPTION( runtime_error(__func__ + " should only be called for MC"s) );
119 
120  auto rEvW = rEv ->Weight(v),
121  gEvW = (*gEv)->Weight(v);
122 
123  optional<int> igenbin;
124  optional<double> genZW;
125 
126  if (auto dimuon = selection(*genMuons, v); dimuon) {
127 
128  float mass = dimuon.CorrP4(v).M();
129  genZW = dimuon.Weight(v);
130 
131  if (goodMass(mass)) { // fill dimuon mass
132  igenbin = obs.genBinning->GetGlobalBinNumber(*obs.process, 1.);
133  if (*igenbin == 0) cerr << red << mass << '\n' << def;
134  }
135  else if (mass >= 40 && genPhotons->GetSize() > 0) {
136 
137  bool found = false;
138  FourVector p4 = dimuon.CorrP4(v);
139  // note: here, we cannot use the `DAS::Di` template
140  // since the number of additional photons is variable
141  for (size_t i = 0; i < genPhotons->GetSize(); ++i) { // issue with iterators --> loop by hand
142  const GenPhoton& p = genPhotons->At(i);
143  if (!p.zAncestor) continue;
144  if (p.p4.Pt() < 20) continue;
145  if (abs(p.p4.Eta()) >= 2.5) continue;
146 
147  p4 += p.CorrP4(v);
148  found = true;
149  }
150 
151  mass = p4.M();
152  if (found && goodMass(mass)) {
153  igenbin = obs.genBinning->GetGlobalBinNumber(*obs.process, 2.);
154  if (*igenbin == 0) cerr << red << mass << '\n' << def;
156  }
157  }
158  }
159 
160  if (igenbin) v.gen->Fill(*igenbin, gEvW * *genZW);
161 
162  if (igenbin && irecbin) {
163  // Good events
164  v.RM ->Fill(*igenbin, *irecbin, gEvW * *genZW * rEvW * *recZW);
165  v.missOut->Fill(*igenbin, gEvW * *genZW * (1 - rEvW * *recZW));
166  } else if (igenbin && !irecbin)
167  // Miss
168  v.missOut->Fill(*igenbin, gEvW * *genZW );
169  else if (!igenbin && irecbin)
170  // Fake
171  v.fakeOut->Fill( *irecbin, gEvW * rEvW * *recZW);
172 }

◆ fillRec()

list< int > fillRec ( DistVariation v)
overridevirtual

See Filler::fillRec

Reimplemented from Filler.

52 {
53  irecbin.reset();
54  recZW.reset();
55 
56  auto dimuon = selection(recMuons, v);
57  if (!dimuon) return {};
58 
59  double evW = rEv->Weight(v);
60  if (obs.isMC) evW *= (*gEv)->Weight(v);
61 
62  float mass = dimuon.CorrP4(v).M();
63  recZW = dimuon.Weight(v);
64 
65  if (goodMass(mass)) { // fill dimuon mass
66  irecbin = obs.recBinning->GetGlobalBinNumber(mass, 1.);
67  if (*irecbin == 0) cerr << red << mass << '\n' << def;
68 
69  v.tmp->Fill(*irecbin, evW * *recZW);
70  v.rec->Fill(*irecbin, evW * *recZW);
71 
72  return {*irecbin};
73  }
74 
75  if (mass >= 40 && recPhotons.GetSize() > 0) { // fill dimuon+gamma mass
76 
77  bool found = false;
78  FourVector p4 = dimuon.CorrP4(v);
79  // note: here, we cannot use the `DAS::Di` template
80  // since the number of additional photons is variable
81  for (size_t i = 0; i < recPhotons.GetSize(); ++i) { // issue with iterators --> loop by hand
82  const RecPhoton& p = recPhotons.At(i);
83 
84  if (p.CorrPt(v) < 20) continue;
85  if (abs(p.p4.Eta()) > 2.5) continue;
86 
87  bool tooClose = false;
88  for (size_t j = 0; j < recMuons.GetSize(); ++j) {
89  const RecMuon& m = recMuons.At(j);
90  using ROOT::Math::VectorUtil::DeltaR;
91  tooClose |= DeltaR(p.p4,m.p4) < 0.1;
92  }
93  if (tooClose) continue;
94 
95  p4 += p.CorrP4(v);
96  *recZW *= p.Weight(v);
97  found = true;
98  }
99 
100  mass = p4.M();
101  if (found && goodMass(mass)) {
102  irecbin = obs.recBinning->GetGlobalBinNumber(mass, 2.);
103  if (*irecbin == 0) cerr << red << mass << '\n' << def;
104 
105  v.tmp->Fill(*irecbin, evW * *recZW);
106  v.rec->Fill(*irecbin, evW * *recZW);
107 
108  return {*irecbin};
109  }
110  }
111 
112  return {};
113 }

◆ match()

void match ( )
inlineoverridevirtual
Todo:
Needed?

Reimplemented from Filler.

73 {}

Member Data Documentation

◆ genMuons

std::optional<TTreeReaderArray<GenMuon> > genMuons

◆ genPhotons

std::optional<TTreeReaderArray<GenPhoton> > genPhotons

◆ gEv

std::optional<TTreeReaderValue<GenEvent> > gEv

◆ irecbin

std::optional<int> irecbin
private

◆ obs

BF obs

Backreference to the observable.

◆ recMuons

TTreeReaderArray<RecMuon> recMuons

◆ recPhotons

TTreeReaderArray<RecPhoton> recPhotons

◆ recZW

std::optional<float> recZW
private

◆ rEv

TTreeReaderValue<RecEvent> rEv

The documentation for this struct was generated from the following files:
Ntupliser_cfg.cerr
cerr
Definition: Ntupliser_cfg.py:93
selection
Di< const Jet, const Jet > selection(const TTreeReaderArray< Jet > &jets, const Uncertainties::Variation &v=Uncertainties::nominal)
Mueller-Navelet jet selection.
Definition: MNjets.cc:24
Step::def
static const char * def
Definition: Step.h:36
DAS::PhysicsObject::p4
FourVector p4
raw four-momentum directly after reconstruction
Definition: PhysicsObject.h:50
DAS::Unfolding::ZmmY::BFFiller::recPhotons
TTreeReaderArray< RecPhoton > recPhotons
Definition: BF.h:59
DAS::Unfolding::ZmmY::BFFiller::irecbin
std::optional< int > irecbin
Definition: BF.h:80
Ntupliser_cfg.p
p
Definition: Ntupliser_cfg.py:362
DAS::Unfolding::Observable::genBinning
TUnfoldBinning * genBinning
particle-level binning
Definition: Observable.h:150
DAS::RecMuon
class RecMuon
Definition: Lepton.h:25
DAS::GenPhoton
class GenPhoton
Definition: Photon.h:13
Step::red
static const char * red
Definition: Step.h:34
DAS::Unfolding::ZmmY::BFFiller::rEv
TTreeReaderValue< RecEvent > rEv
Definition: BF.h:61
DAS::Unfolding::ZmmY::BFFiller::obs
BF obs
Backreference to the observable.
Definition: BF.h:54
DAS::Unfolding::ZmmY::BFFiller::recMuons
TTreeReaderArray< RecMuon > recMuons
Definition: BF.h:58
DAS::Unfolding::ZmmY::BFFiller::recZW
std::optional< float > recZW
Definition: BF.h:81
DAS::Unfolding::Observable::isMC
static bool isMC
Definition: Observable.h:144
DAS::Unfolding::initOptionalBranch
auto initOptionalBranch(TTreeReader &reader, const char *name)
Definition: Observable.h:39
DAS::Unfolding::ZmmY::BF::process
std::optional< int > process
Definition: BF.h:36
DAS::Unfolding::ZmmY::BFFiller::genPhotons
std::optional< TTreeReaderArray< GenPhoton > > genPhotons
Definition: BF.h:57
DAS::FourVector
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector
Definition: PhysicsObject.h:15
DAS::Unfolding::Observable::recBinning
TUnfoldBinning * recBinning
detector-level binning
Definition: Observable.h:149
DAS::Unfolding::ZmmY::BFFiller::genMuons
std::optional< TTreeReaderArray< GenMuon > > genMuons
Definition: BF.h:56
DAS::RecPhoton
class RecPhoton
Definition: Photon.h:27
DAS::Unfolding::ZmmY::BFFiller::gEv
std::optional< TTreeReaderValue< GenEvent > > gEv
Definition: BF.h:60