1 #include "CAFAna/Core/Binning.h" 5 #include "TDirectory.h" 7 #include "TObjString.h" 32 if(&b ==
this)
return;
60 if(&b ==
this)
return *
this;
89 const std::vector<std::string>&
labels)
91 assert(labels.empty() ||
int(labels.size()) == n);
98 for (
int i = 0;
i <=
n;
i++)
108 const std::vector<std::string>&
labels)
120 std::vector<double> edges(n+1);
121 const double logSpacing =
exp( (
log(hi) -
log(lo)) / n );
122 for (
int i = 0;
i <=
n; ++
i) {
123 if (
i == 0) edges[
i] =
lo;
124 else edges[
i] = logSpacing*edges[
i-1];
136 bins.fNBins = edges.size()-1;
137 bins.fMin = edges.front();
138 bins.fMax = edges.back();
139 bins.fIsSimple =
false;
158 if (x <
fMin)
return 0;
167 if (x ==
fEdges[bin]) bin++;
178 if(!ax->GetXbins()->GetArray()){
179 bins =
SimpleHelper(ax->GetNbins(), ax->GetXmin(), ax->GetXmax());
182 std::vector<double> edges(ax->GetNbins()+1);
183 ax->GetLowEdge(&edges.front());
184 edges[ax->GetNbins()] = ax->GetBinUpEdge(ax->GetNbins());
195 TDirectory*
tmp = gDirectory;
197 dir = dir->mkdir(name.c_str());
200 TObjString(
"Binning").Write(
"type");
208 nminmax.Write(
"nminmax");
212 issimple.Write(
"issimple");
215 for(
unsigned int i = 0;
i <
fEdges.size(); ++
i)
218 edges.Write(
"edges");
220 for(
unsigned int i = 0;
i <
fLabels.size(); ++
i)
232 dir = dir->GetDirectory(name.c_str());
235 TObjString*
tag = (TObjString*)dir->Get(
"type");
237 assert(tag->GetString() ==
"Binning");
252 std::vector<double> edges(vEdges->GetNrows());
253 for(
int i = 0;
i < vEdges->GetNrows(); ++
i) edges[
i] = (*vEdges)[
i];
258 for(
unsigned int i = 0; ; ++
i){
261 ret.
fLabels.push_back(s->GetString().Data());
266 return std::make_unique<Binning>(
ret);
static std::unique_ptr< Binning > LoadFrom(TDirectory *dir, const std::string &name)
Binning & operator=(const Binning &b)
TSpline3 lo("lo", xlo, ylo, 12,"0")
Represent the binning of a Spectrum's x-axis.
Cuts and Vars for the 2020 FD DiF Study.
bool operator<(const Binning &rhs) const
static Binning FromTAxis(const TAxis *ax)
int FindBin(double x) const
std::vector< std::string > fLabels
static Binning CustomHelper(const std::vector< double > &edges)
std::vector< double > fEdges
TSpline3 hi("hi", xhi, yhi, 18,"0")
bool operator==(const Binning &rhs) const
fvar< T > exp(const fvar< T > &x)
void RegisterDependency(const T *parent, T *child)
Call from copy constructor and assignment operator.
static Binning Custom(const std::vector< double > &edges)
static Binning LogUniform(int n, double lo, double hi)
void RegisterDestruction(T *x)
Call from destructor.
void SaveTo(TDirectory *dir, const std::string &name) const
static DepMan & Instance()
assert(nhit_max >=nhit_nbins)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
void RegisterConstruction(T *x)
Call from constructor (in the success case)
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
static Binning SimpleHelper(int n, double lo, double hi, const std::vector< std::string > &labels={})