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  unique_ptr<TChain> tIn = DT::GetChain(inputs);
94  unique_ptr<TFile> fOut(DT_GetOutput(output));
95  auto tOut = unique_ptr<TTree>(tIn->CloneTree(0));
96 
97  DT::MetaInfo metainfo(tOut);
98  auto isMC = metainfo.Get<bool>("flags", "isMC");
99  auto year = metainfo.Get<int>("flags", "year");
100 
101  MET * met = nullptr;
102  RecEvent * recEvt = nullptr;
103  GenEvent * genEvt = nullptr;
104  vector<RecJet> * recJets = nullptr;
105  tIn->SetBranchAddress("recEvent", &recEvt);
106  if (isMC)
107  tIn->SetBranchAddress("genEvent", &genEvt);
108  tIn->SetBranchAddress("met", &met);
109  tIn->SetBranchAddress("recJets", &recJets);
110 
111  metainfo.Set<bool>("corrections", "METfilters", true);
112  MissingET::Filters metfilters(year);
113 
114  /**** declaring a few histograms to control effect of filters ****/
115 
116  MissingET::FractionCut beforeCut("beforeMETcut"),
117  afterCut("afterMETcut");
118 
119  ControlPlots METbefore("METbefore"),
120  METafterAllMETfilters("METafterAllMETfilters"),
121  METafterMETfraction("METafterMETfraction"),
122  METafterAllMETfiltersAndMETfraction("METafterAllMETfiltersAndMETfraction");
123 
124  vector<ControlPlots> METfilters;
125  for (TString METname: metfilters.METnames)
126  METfilters.push_back(ControlPlots(METname));
127 
128  auto totRecWgt = [&](size_t i) {
129  return (isMC ? genEvt->weights.front().v : 1) * recEvt->weights.at(i).v;
130  };
131 
132  for (DT::Looper looper(tIn, slice); looper(); ++looper) {
133  [[ maybe_unused ]]
134  static auto& cout = (steering & DT::verbose) == DT::verbose ? ::cout : DT::dev_null;
135 
136  beforeCut.Fill(met, recJets, totRecWgt(0));
137  METbefore(*recJets, totRecWgt(0));
138 
139  if (met->Et < 0.3 * met->SumEt){
140  afterCut.Fill(met, recJets, totRecWgt(0));
141  METafterMETfraction(*recJets, totRecWgt(0));
142  }
143 
144  for (size_t ibit = 0; ibit < metfilters.METbitsToApply.size(); ++ibit) {
145  bool bit = met->Bit.at(ibit);
146  if (!bit) continue;
147  METfilters.at(ibit)(*recJets, totRecWgt(0));
148  }
149 
150  // IMPORTANT NOTE:
151  // in case the MET fraction based cut would be used,
152  // the description of the MET class should be changed!!
153 
154  metfilters(met, recEvt);
155 
156  METafterAllMETfilters(*recJets, totRecWgt(0));
157 
158  if (met->Et < 0.3 * met->SumEt)
159  METafterAllMETfiltersAndMETfraction(*recJets, totRecWgt(0));
160 
161  if ((steering & DT::fill) == DT::fill) tOut->Fill();
162  }
163 
164  beforeCut.Write(fOut.get());
165  afterCut.Write(fOut.get());
166  METbefore.Write(fOut.get());
167  METafterMETfraction.Write(fOut.get());
168  METafterAllMETfilters.Write(fOut.get());
169  METafterAllMETfiltersAndMETfraction.Write(fOut.get());
170 
171  for (auto& filt: METfilters)
172  filt.Write(fOut.get());
173 
174  metainfo.Set<bool>("git", "complete", true);
175  fOut->cd();
176  tOut->Write();
177 
178  cout << __func__ << ' ' << slice << " end" << endl;
179 }
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:33
Darwin::Tools::GetChain
std::unique_ptr< TChain > GetChain(std::vector< std::filesystem::path > inputs, const char *name="events")
Load chain from a list of files.
Definition: FileUtils.cc:67
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
Darwin::Tools::fill
@ fill
activate -f to fill the tree
Definition: Options.h:28
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
DT_GetOutput
#define DT_GetOutput(output)
Definition: FileUtils.h:96