-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinning.h
50 lines (42 loc) · 1.16 KB
/
Binning.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef BINNING_H
#define BINNING_H
//!
//! \brief provides bin ids
//!
//! \author Hartmut Stadie
//! \date 2008/12/12
//! $Id: Binning.h,v 1.2 2010/10/20 11:28:16 stadie Exp $
// ----------------------------------------------------------------
#include <string>
#include <map>
#include <set>
#include <vector>
#include <boost/thread/mutex.hpp>
class JetBin;
class ConfigFile;
class Binning
{
public:
Binning(const ConfigFile* configfile);
JetBin* operator()(double x1, double x2 = 0, double x3 = 0, double x4 = 0) const
{
BinMap::const_iterator jbi = jetbins_.find(findBin(x1,x2,x3,x4));
if(jbi == jetbins_.end()) return 0;
return jbi->second;
}
JetBin* setBin(JetBin* jb, double x1, double x2 = 0, double x3 = 0, double x4 = 0) {
jetbins_.insert(std::make_pair(findBin(x1,x2,x3,x4),jb));
return (*this)(x1,x2,x3,x4);
}
typedef std::map<int,JetBin*> BinMap;
const BinMap& bins() const { return jetbins_;}
void clear() {
jetbins_.clear();
}
int findBin(double x1, double x2, double x3, double x4) const;
private:
typedef std::vector<std::set<double> > BorderSets;
BorderSets borders_;
BinMap jetbins_;
};
#endif