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.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BaseSelector.h
Go to the documentation of this file.
1#ifndef BASESELECTOR_H
2#define BASESELECTOR_H
3
4#include <string>
5#include <iostream>
6#include <map>
7#include <memory>
8
9#include "TH1F.h"
10#include "json.hpp"
11
12
13// for convenience
14using json = nlohmann::json;
15
22 public:
24 BaseSelector(const std::string& inputName);
25 BaseSelector(const std::string& inputName, const std::string& cfgFile);
26 virtual ~BaseSelector();
27
33 void setCfgFile(const std::string& cfgFile);
34
40 void setDebug(bool val);
41
49 bool hasCut(const std::string& cutname) {
50 if (cuts.find(cutname) != cuts.end()) return true;
51 else return false;
52 }
53
60 bool LoadSelection();
61
68 float getCut(const std::string& cutname) {
69 if (!hasCut(cutname)) {
70 std::cout << "ERROR " << cutname << " cut not implemented" << std::endl;
71 return -999;
72 }
73 else return cuts[cutname].first;
74 }
75
81 std::map<std::string, std::pair<double,int> > getCuts(){ return cuts; }
82
87 void makeCutFlowHisto();
88
94 std::shared_ptr<TH1F> getCutFlowHisto(){ return h_cf_; };
95
105 bool passCut(const std::string& cutname, double val, double weight){ return true; };
106
116 bool passCutEq(const std::string& cutname, double val, double weight);
117
127 bool passCutLt(const std::string& cutname, double val, double weight);
128
138 bool passCutGt(const std::string& cutname, double val, double weight);
139
144 void clearSelector() { passSelection = true; }
145
146 protected:
147 typedef std::map<std::string, std::pair<double, int>>::iterator cut_it;
148 std::map<std::string,std::pair<double, int>> cuts;
149 bool debug_{false};
150
151 private:
153 std::string m_name{""};
154 std::string m_cfgFile{""};
155 //string: cutname
156 //double: cutvalue
157 //int : cut id (for cut flow book-keeping)
158 std::map<std::string,std::string> labels;
159
160 int ncuts_{0};
161 std::shared_ptr<TH1F> h_cf_;
162 bool passSelection{false};
163
164
165};
166
167#endif
nlohmann::json json
brief description
float getCut(const std::string &cutname)
Get cut values ?
std::map< std::string, std::pair< double, int > > cuts
description
json _h_selections
description
void clearSelector()
description
bool passCutLt(const std::string &cutname, double val, double weight)
description
int ncuts_
description
bool hasCut(const std::string &cutname)
description
bool passCutGt(const std::string &cutname, double val, double weight)
description
void setDebug(bool val)
Set Debug.
std::shared_ptr< TH1F > getCutFlowHisto()
Get the Cut Flow Histo.
std::map< std::string, std::pair< double, int > >::iterator cut_it
description
std::shared_ptr< TH1F > h_cf_
description
void makeCutFlowHisto()
description
std::map< std::string, std::string > labels
description
bool LoadSelection()
description
std::string m_cfgFile
description
std::map< std::string, std::pair< double, int > > getCuts()
description
std::string m_name
description
bool passSelection
description
bool passCut(const std::string &cutname, double val, double weight)
description
void setCfgFile(const std::string &cfgFile)
Set the Cfg File object.
bool debug_
description
virtual ~BaseSelector()
bool passCutEq(const std::string &cutname, double val, double weight)
description