DAS  3.0
Das Analysis System
DAS::MissingET Namespace Reference

Classes

struct  Filters
 
struct  FractionCut
 

Functions

void applyMETfilters (const vector< fs::path > &inputs, const fs::path &output, const int steering, const DT::Slice slice={1, 0})
 

Function Documentation

◆ applyMETfilters()

void DAS::MissingET::applyMETfilters ( const vector< fs::path > &  inputs,
const fs::path &  output,
const int  steering,
const DT::Slice  slice = {1,0} 
)

Apply MET filters, both for MC and Data following the official recommendations

Parameters
inputsinput ROOT file (n-tuple)
outputoutput ROOT file (n-tuple)
steeringparameters obtained from explicit options
slicenumber and index of slice
88  {1,0}
89  )
90 {
91  cout << __func__ << ' ' << slice << " start" << endl;
92 
93  DT::Flow flow(steering);
94  auto tIn = flow.GetInputTree(inputs, slice);
95  auto [fOut, tOut] = flow.GetOutput(output);
96 
97  DT::MetaInfo metainfo(tOut);
98  auto isMC = metainfo.Get<bool>("flags", "isMC");
99  auto year = metainfo.Get<int>("flags", "year");
100 
101  auto gEv = isMC ? flow.GetBranchReadOnly<GenEvent>("genEvent") : nullptr;
102  auto rEv = flow.GetBranchReadOnly<RecEvent>("recEvent");
103  auto met = flow.GetBranchReadOnly<MET >("met" );
104  auto recJets = flow.GetBranchReadOnly<vector<RecJet>>("recJets");
105 
106  metainfo.Set<bool>("corrections", "METfilters", true);
107  MissingET::Filters metfilters(year);
108 
109  /**** declaring a few histograms to control effect of filters ****/
110 
111  MissingET::FractionCut beforeCut("beforeMETcut"),
112  afterCut("afterMETcut");
113 
114  ControlPlots METbefore("METbefore"),
115  METafterAllMETfilters("METafterAllMETfilters"),
116  METafterMETfraction("METafterMETfraction"),
117  METafterAllMETfiltersAndMETfraction("METafterAllMETfiltersAndMETfraction");
118 
119  vector<ControlPlots> METfilters;
120  for (TString METname: metfilters.METnames)
121  METfilters.push_back(ControlPlots(METname));
122 
123  auto totRecWgt = [&](size_t i) {
124  return (isMC ? gEv->weights.front().v : 1) * rEv->weights.at(i).v;
125  };
126 
127  for (DT::Looper looper(tIn); looper(); ++looper) {
128  [[ maybe_unused ]]
129  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
130 
131  beforeCut.Fill(met, recJets, totRecWgt(0));
132  METbefore(*recJets, totRecWgt(0));
133 
134  if (met->Et < 0.3 * met->SumEt){
135  afterCut.Fill(met, recJets, totRecWgt(0));
136  METafterMETfraction(*recJets, totRecWgt(0));
137  }
138 
139  for (size_t ibit = 0; ibit < metfilters.METbitsToApply.size(); ++ibit) {
140  bool bit = met->Bit.at(ibit);
141  if (!bit) continue;
142  METfilters.at(ibit)(*recJets, totRecWgt(0));
143  }
144 
145  // IMPORTANT NOTE:
146  // in case the MET fraction based cut would be used,
147  // the description of the MET class should be changed!!
148 
149  metfilters(met, rEv);
150 
151  METafterAllMETfilters(*recJets, totRecWgt(0));
152 
153  if (met->Et < 0.3 * met->SumEt)
154  METafterAllMETfiltersAndMETfraction(*recJets, totRecWgt(0));
155 
156  if (steering & DT::fill) tOut->Fill();
157  }
158 
159  beforeCut.Write(fOut);
160  afterCut.Write(fOut);
161  METbefore.Write(fOut);
162  METafterMETfraction.Write(fOut);
163  METafterAllMETfilters.Write(fOut);
164  METafterAllMETfiltersAndMETfraction.Write(fOut);
165 
166  for (auto& filt: METfilters)
167  filt.Write(fOut);
168 
169  metainfo.Set<bool>("git", "complete", true);
170 
171  cout << __func__ << ' ' << slice << " end" << endl;
172 }
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:55
Step::verbose
static bool verbose
Definition: Step.h:40
Ntupliser_cfg.year
int year
Definition: Ntupliser_cfg.py:63
Darwin::Tools::Looper
Facility to loop over a n-tuple, including parallelisation and printing.
Definition: Looper.h:32
DAS::MET::Et
float Et
transverse energy
Definition: Event.h:85
Darwin::Tools::MetaInfo
Generic meta-information for n-tuple (including speficities to Darwin).
Definition: MetaInfo.h:65
DAS::MET::Bit
std::vector< bool > Bit
flags for application of MET filters (see n-tupliser config file)
Definition: Event.h:89
met
DAS::MET met
Definition: classes.h:28
Ntupliser_cfg.isMC
string isMC
Definition: Ntupliser_cfg.py:59
jercExample.inputs
def inputs
Definition: jercExample.py:118
Darwin::Tools::dev_null
static std::ostream dev_null(nullptr)
to redirect output stream to nowhere
DAS::MET::SumEt
float SumEt
sum of the transverse energies of all the components (jet, leptons, etc.) present in the event
Definition: Event.h:86