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)
 
template<typename Muon >
bool selection (const TTreeReaderArray< Muon > &muons, const DistVariation &v)
 
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.

21  : obs(obs)
22  , genMuons(initOptionalBranch<decltype(genMuons)>(reader, "genMuons"))
23  , genPhotons(initOptionalBranch<decltype(genPhotons)>(reader, "genPhotons"))
24  , recMuons(reader, "recMuons")
25  , recPhotons(reader, "recPhotons")
26  , gEv(initOptionalBranch<decltype(gEv)>(reader, "genEvent"))
27  , rEv(reader, "recEvent")
28 {
29 }

Member Function Documentation

◆ fillMC()

void fillMC ( DistVariation v)
overridevirtual

See Filler::fillMC

Todo:
no weight for gen photons?

Reimplemented from Filler.

109 {
110  if (!obs.isMC)
111  BOOST_THROW_EXCEPTION( runtime_error(__func__ + " should only be called for MC"s) );
112 
113  auto rEvW = v.getCorrection(RecEvent::WeightVar, rEv->weights),
114  gEvW = v.getCorrection(GenEvent::WeightVar, (*gEv)->weights);
115 
116  optional<int> igenbin;
117  optional<double> genZW;
118 
119  if (selection(*genMuons, v)) {
120 
121  const auto& m0 = genMuons->At(0),
122  m1 = genMuons->At(1);
123 
124  FourVector Z = v.getCorrP4(m0) + v.getCorrP4(m1);
125  float mass = Z.M();
126 
127  genZW = v.getWeight(m0) * v.getWeight(m1);
128 
129  if (goodMass(mass)) { // fill dimuon mass
130  igenbin = obs.genBinning->GetGlobalBinNumber(*obs.process, 1.);
131  if (*igenbin == 0) cerr << red << mass << '\n' << def;
132  }
133  else if (mass >= 40 && genPhotons->GetSize() > 0) {
134 
135  bool found = false;
136  for (const auto& p: *genPhotons) {
137  if (!p.zAncestor) continue;
138  if (p.p4.Pt() < 20) continue;
139  if (abs(p.p4.Eta()) >= 2.5) continue;
140 
141  Z = Z + p.p4;
142  found = true;
143  }
144  if (found && goodMass(Z.M())) {
145  igenbin = obs.genBinning->GetGlobalBinNumber(*obs.process, 2.);
146  if (*igenbin == 0) cerr << red << mass << '\n' << def;
148  }
149  }
150  }
151 
152  if (igenbin) v.gen->Fill(*igenbin, gEvW * *genZW);
153 
154  if (igenbin && irecbin) {
155  // Good events
156  v.RM ->Fill(*igenbin, *irecbin, gEvW * *genZW * rEvW * *recZW);
157  v.missOut->Fill(*igenbin, gEvW * *genZW * (1 - rEvW * *recZW));
158  } else if (igenbin && !irecbin)
159  // Miss
160  v.missOut->Fill(*igenbin, gEvW * *genZW );
161  else if (!igenbin && irecbin)
162  // Fake
163  v.fakeOut->Fill( *irecbin, gEvW * rEvW * *recZW);
164 }

◆ fillRec()

list< int > fillRec ( DistVariation v)
overridevirtual

See Filler::fillRec

Todo:
use corrected 4-vec

Reimplemented from Filler.

48 {
49  irecbin.reset();
50  recZW.reset();
51 
52  if (!selection(recMuons, v)) return {};
53 
54  double evW = v.getCorrection(RecEvent::WeightVar, rEv->weights);
55  if (obs.isMC) evW *= v.getCorrection(GenEvent::WeightVar, (*gEv)->weights);
56 
57  const auto& m0 = recMuons.At(0),
58  m1 = recMuons.At(1);
59 
60  FourVector Z = v.getCorrP4(m0) + v.getCorrP4(m1);
61  float mass = Z.M();
62 
63  recZW = v.getWeight(m0) * v.getWeight(m1);
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  for (const auto& p: recPhotons) {
79 
80  if (p.p4.Pt() < 20) continue;
81  if (abs(p.p4.Eta()) > 2.5) continue;
82 
83  bool tooClose = false;
84  for (const auto& m: recMuons)
85  tooClose |= DeltaR(p.p4,m.p4) < 0.1;
86  if (tooClose) continue;
87 
88  Z = Z + p.CorrP4();
89  *recZW *= v.getWeight(p);
90  found = true;
91  }
92 
93  mass = Z.M();
94  if (found && goodMass(mass)) {
95  irecbin = obs.recBinning->GetGlobalBinNumber(mass, 2.);
96  if (*irecbin == 0) cerr << red << mass << '\n' << def;
97 
98  v.tmp->Fill(*irecbin, evW * *recZW);
99  v.rec->Fill(*irecbin, evW * *recZW);
100 
101  return {*irecbin};
102  }
103  }
104 
105  return {};
106 }

◆ match()

void match ( )
inlineoverridevirtual
Todo:
Needed?

Reimplemented from Filler.

78 {}

◆ selection()

bool selection ( const TTreeReaderArray< Muon > &  muons,
const DistVariation v 
)

Makes selection on muons, but not on the dimuon system.

34 {
35  if (muons.GetSize() < 2) return false;
36 
37  const auto& m0 = muons.At(0),
38  m1 = muons.At(1);
39 
40  return (m0.Q * m1.Q == -1) // opposite charges
41  && (v.getCorrP4(m0).Pt() >= 20) // trigger efficiency
42  && (v.getCorrP4(m1).Pt() >= 15) // trigger efficiency
43  && (abs(m0.p4.Eta()) < 2.4) // muon chamber acceptance
44  && (abs(m1.p4.Eta()) < 2.4); // muon chamber acceptance
45 }

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
Step::def
static const char * def
Definition: Step.h:36
DAS::Unfolding::ZmmY::BFFiller::recPhotons
TTreeReaderArray< RecPhoton > recPhotons
Definition: BF.h:58
DAS::Unfolding::ZmmY::BFFiller::irecbin
std::optional< int > irecbin
Definition: BF.h:85
Ntupliser_cfg.muons
string muons
Definition: Ntupliser_cfg.py:43
Ntupliser_cfg.p
p
Definition: Ntupliser_cfg.py:358
DAS::Unfolding::Observable::genBinning
TUnfoldBinning * genBinning
particle-level binning
Definition: Observable.h:150
DAS::GenEvent::WeightVar
static const char *const WeightVar
Definition: Event.h:39
Step::red
static const char * red
Definition: Step.h:34
DAS::Unfolding::ZmmY::BFFiller::rEv
TTreeReaderValue< RecEvent > rEv
Definition: BF.h:60
DAS::Unfolding::ZmmY::BFFiller::obs
BF obs
Backreference to the observable.
Definition: BF.h:53
DAS::Unfolding::ZmmY::BFFiller::recMuons
TTreeReaderArray< RecMuon > recMuons
Definition: BF.h:57
DAS::Unfolding::ZmmY::BFFiller::recZW
std::optional< float > recZW
Definition: BF.h:86
DAS::Unfolding::Observable::isMC
static bool isMC
Definition: Observable.h:144
DAS::RecEvent::WeightVar
static const char *const WeightVar
Definition: Event.h:53
DAS::Unfolding::ZmmY::BFFiller::selection
bool selection(const TTreeReaderArray< Muon > &muons, const DistVariation &v)
Makes selection on muons, but not on the dimuon system.
Definition: BF.cc:32
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:35
DAS::Unfolding::ZmmY::BFFiller::genPhotons
std::optional< TTreeReaderArray< GenPhoton > > genPhotons
Definition: BF.h:56
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:55
DAS::Unfolding::ZmmY::BFFiller::gEv
std::optional< TTreeReaderValue< GenEvent > > gEv
Definition: BF.h:59