hpstr
The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format.
Loading...
Searching...
No Matches
TreeCutSelector.h
Go to the documentation of this file.
1#ifndef TREECUTSELECTOR_H
2#define TREECUTSELECTOR_H
3
4#include <fstream>
5#include <iostream>
6
7#include "BaseSelector.h"
8#include "TTree.h"
9
11 public:
13 TreeCutSelector(const std::string& inputName);
14 TreeCutSelector(const std::string& inputName, const std::string& cfgFile);
15
16 virtual ~TreeCutSelector();
17
18 bool LoadSelection();
19 std::string getCutString(std::string cutname, bool forTree = false);
20 std::string getFullCutString(std::vector<std::string> cuts_to_exclude = {}, bool forTree = false);
21 std::string getCutVar(std::string cutname, bool forTree = false);
22
27 void makeCutFlowHisto();
28
33 std::map<std::string, std::pair<std::pair<double, double>, int>>* getPointerToCuts() { return &range_cuts; }
34
35 std::pair<double, double> getCutRange(std::string cutname) {
36 if (!hasCut(cutname)) {
37 std::cout << "ERROR " << cutname << " cut not implemented" << std::endl;
38 return std::make_pair(-999.9, 999.9);
39 } else
40 return range_cuts[cutname].first;
41 }
42
43 void printCuts() {
44 for (range_cut_it it = range_cuts.begin(); it != range_cuts.end(); ++it) {
45 std::cout << it->first << " [min:] =" << it->second.first.first << " [max:] =" << it->second.first.second
46 << " [id:] =" << it->second.second << std::endl;
47 }
48 }
49
50 void setCutValue(std::string cutname, std::pair<double, double> value) {
51 int id = range_cuts[cutname].second;
52 range_cuts[cutname] = std::make_pair(value, id);
53 }
54
55 bool hasCut(const std::string& cutname) {
56 if (range_cuts.find(cutname) != range_cuts.end())
57 return true;
58 else
59 return false;
60 }
61
62 void filterCuts(std::vector<std::string> cut_variable_list);
63
64 protected:
65 typedef std::map<std::string, std::pair<std::pair<double, double>, int>>::iterator range_cut_it;
66 std::map<std::string, std::pair<std::pair<double, double>, int>> range_cuts;
67
68 private:
70 std::string m_name{""};
71 std::string m_cfgFile{""};
72 std::map<std::string, std::string> labels;
73 int ncuts_{0};
74 std::shared_ptr<TH1F> h_cf_;
75};
76
77#endif // TREECUTSELECTOR_H
nlohmann::json json
std::string getCutString(std::string cutname, bool forTree=false)
std::map< std::string, std::pair< std::pair< double, double >, int > > * getPointerToCuts()
get pointer to the base class cuts
std::pair< double, double > getCutRange(std::string cutname)
json _h_selections
description
std::string getFullCutString(std::vector< std::string > cuts_to_exclude={}, bool forTree=false)
int ncuts_
description
bool hasCut(const std::string &cutname)
std::string getCutVar(std::string cutname, bool forTree=false)
void filterCuts(std::vector< std::string > cut_variable_list)
virtual ~TreeCutSelector()
std::shared_ptr< TH1F > h_cf_
description
void setCutValue(std::string cutname, std::pair< double, double > value)
std::map< std::string, std::pair< std::pair< double, double >, int > >::iterator range_cut_it
description
void makeCutFlowHisto()
description
std::map< std::string, std::pair< std::pair< double, double >, int > > range_cuts
std::string m_cfgFile
description
std::string m_name
description
std::map< std::string, std::string > labels
description