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 pt::ptree &config, 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 pt::ptree &  config,
const int  steering,
const DT::Slice  slice = {1,0} 
)

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

Note
In case the MET fraction based cut would be used, the description of the MET class should be changed!!
Parameters
inputsinput ROOT file (n-tuple)
outputoutput ROOT file (n-tuple)
configconfig handled with `Darwin::Tools::options`
steeringparameters obtained from explicit options
slicenumber and index of slice
98  {1,0}
99  )
100 {
101  cout << __func__ << ' ' << slice << " start" << endl;
102 
103  DT::Flow flow(steering, inputs);
104  auto tIn = flow.GetInputTree(slice);
105  auto [fOut, tOut] = flow.GetOutput(output);
106 
107  DT::MetaInfo metainfo(tOut);
108  auto isMC = metainfo.Get<bool>("flags", "isMC");
109  auto year = metainfo.Get<int>("flags", "year");
110 
111  auto gEv = isMC ? flow.GetBranchReadOnly<GenEvent>("genEvent") : nullptr;
112  auto rEv = flow.GetBranchReadOnly<RecEvent>("recEvent");
113  auto met = flow.GetBranchReadOnly<MET >("met" );
114  auto recJets = flow.GetBranchReadOnly<vector<RecJet>>("recJets");
115 
116  if (!metainfo.Find("corrections", "METfilters"))
117  BOOST_THROW_EXCEPTION( DE::BadInput("No MET filters in this tree", tOut) );
118 
119  fs::path p_METfilters = config.get<fs::path>("corrections.METfilters");
120  if (metainfo.Get<fs::path>("corrections", "METfilters") != p_METfilters) {
121  cerr << orange << "You are now using a different list of MET filters w.r.t. n-tuplisation.\n" << def;
122  metainfo.Set<bool>("git", "reproducible", false);
123  }
124  MissingET::Filters metfilters(p_METfilters);
125 
126  /**** declaring a few histograms to control effect of filters ****/
127 
128  MissingET::FractionCut beforeCut("beforeMETcut"),
129  afterCut("afterMETcut");
130 
131  ControlPlots METbefore("METbefore"),
132  METafterAllMETfilters("METafterAllMETfilters"),
133  METafterMETfraction("METafterMETfraction"),
134  METafterAllMETfiltersAndMETfraction("METafterAllMETfiltersAndMETfraction");
135 
136  vector<ControlPlots> METfilters;
137  for (const string& METname: metfilters.names)
138  METfilters.emplace_back(METname);
139 
140  auto totRecWgt = [&](size_t i) {
141  return (isMC ? gEv->weights.front().v : 1) * rEv->weights.at(i).v;
142  };
143 
144  for (DT::Looper looper(tIn); looper(); ++looper) {
145  [[ maybe_unused ]]
146  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
147 
148  beforeCut.Fill(met, recJets, totRecWgt(0));
149  METbefore(*recJets, totRecWgt(0));
150 
151  if (met->Et < 0.3 * met->SumEt){
152  afterCut.Fill(met, recJets, totRecWgt(0));
153  METafterMETfraction(*recJets, totRecWgt(0));
154  }
155 
158 
159  metfilters(*met, *rEv);
160 
161  METafterAllMETfilters(*recJets, totRecWgt(0));
162 
163  if (met->Et < 0.3 * met->SumEt)
164  METafterAllMETfiltersAndMETfraction(*recJets, totRecWgt(0));
165 
166  if (steering & DT::fill) tOut->Fill();
167  }
168 
169  cout << "Saving MET variables before and after the MET fraction cut" << endl;
170  auto dMETcut = fOut->mkdir("METfraction");
171  beforeCut.Write(dMETcut);
172  afterCut.Write(dMETcut);
173 
174  cout << "Saving control observables before and after the MET fraction cut and/or MET filters" << endl;
175  auto dCP = fOut->mkdir("controlplots");
176  METbefore.Write(dCP);
177  METafterMETfraction.Write(dCP);
178  METafterAllMETfilters.Write(dCP);
179  METafterAllMETfiltersAndMETfraction.Write(dCP);
180 
181  cout << "Saving control observables for each MET filter individually" << endl;
182  auto dMETfilters = fOut->mkdir("METfilters");
183  for (auto& filt: METfilters)
184  filt.Write(dMETfilters);
185 
186  metainfo.Set<bool>("git", "complete", true);
187 
188  cout << __func__ << ' ' << slice << " end" << endl;
189 }
Ntupliser_cfg.cerr
cerr
Definition: Ntupliser_cfg.py:98
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:78
Step::verbose
static bool verbose
Definition: Step.h:40
Step::def
static const char * def
Definition: Step.h:36
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:22
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:68
Ntupliser_cfg.config
config
Definition: Ntupliser_cfg.py:297
orange
static const char * orange
Definition: colours.h:6
met
DAS::MET met
Definition: classes.h:28
Ntupliser_cfg.isMC
string isMC
Definition: Ntupliser_cfg.py:59
Ntupliser_cfg.METfilters
METfilters
Definition: Ntupliser_cfg.py:149
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
Darwin::Exceptions::BadInput
Generic exception for ill-defined input (before the event loop).
Definition: exceptions.h:83