DAS  3.0
Das Analysis System
Filters.h
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include <system_error>
4 #include <vector>
5 
9 
10 #include <boost/property_tree/info_parser.hpp>
11 
12 #include <darwin.h>
13 
14 namespace DAS::MissingET {
15 
20 struct Filters {
21 
22  std::vector<std::string> names;
23  std::vector<size_t> bitsToTest;
24 
25  Filters (const std::filesystem::path& file
26  )
27  {
28  using namespace std;
29  namespace pt = boost::property_tree;
30  namespace fs = filesystem;
31 
32  if (!fs::exists(file))
33  BOOST_THROW_EXCEPTION(fs::filesystem_error("Bad MET filter list", file,
34  make_error_code(errc::no_such_file_or_directory)));
35 
36  pt::ptree tree;
37  pt::read_info(file, tree);
38 
39  cout << "MET / noise filters:";
40  size_t ibit = 0;
41  for (auto& [name, child]: tree) {
42  auto bit = child.get_value<bool>();
43 
44  // printout
45  cout << (bit ? green : red) << ' ' << name;
46 
47  // save
48  names.push_back(name);
49  if (bit) bitsToTest.push_back(ibit);
50  ++ibit;
51  }
52  cout << def << endl;
53  }
54 
55  void operator() (const MET& met, RecEvent& event)
56  {
57  if (met.Bit.size() != names.size())
58  BOOST_THROW_EXCEPTION( std::runtime_error("Inconsistent lengths of MET bits between file and event") );
59 
60  for (size_t ibit: bitsToTest) {
61  if (met.Bit.at(ibit)) continue;
62  event.weights *= 0;
63  return;
64  }
65  }
66 };
67 
68 }
DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.name
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
jmarExample.pt
pt
Definition: jmarExample.py:19
Step::def
static const char * def
Definition: Step.h:36
DAS::RecEvent
Definition: Event.h:52
Event.h
DAS::MET
Definition: Event.h:84
Jet.h
binnings.h
Step::red
static const char * red
Definition: Step.h:34
DAS::MissingET::Filters::Filters
Filters(const std::filesystem::path &file)
Definition: Filters.h:25
DAS::MET::Bit
std::vector< bool > Bit
flags for application of MET filters (see n-tupliser config file)
Definition: Event.h:89
Step::green
static const char * green
Definition: Step.h:33
met
DAS::MET met
Definition: classes.h:28
DAS::MissingET::Filters::bitsToTest
std::vector< size_t > bitsToTest
indices of the bits to test in DAS::MET::Bit
Definition: Filters.h:23
DAS::MissingET::Filters::names
std::vector< std::string > names
full name of MET filter
Definition: Filters.h:22
DAS::MissingET::Filters
Definition: Filters.h:20
DAS::MissingET::Filters::operator()
void operator()(const MET &met, RecEvent &event)
Definition: Filters.h:55
DAS::MissingET
Definition: applyMETfilters.cc:28