finish implementation of and use DrawVar
This commit is contained in:
parent
0990514af4
commit
6a86a76608
@ -45,21 +45,45 @@ class DrawVar
|
||||
{
|
||||
}
|
||||
|
||||
std::string getIdentifier() {
|
||||
std::string getId()
|
||||
{
|
||||
return _identifier;
|
||||
}
|
||||
|
||||
TVar getMin() {
|
||||
const char *getIdStr()
|
||||
{
|
||||
return _identifier.c_str();
|
||||
}
|
||||
|
||||
TVar getMin()
|
||||
{
|
||||
return _min;
|
||||
}
|
||||
|
||||
TVar getMax() {
|
||||
TVar getMax()
|
||||
{
|
||||
return _max;
|
||||
}
|
||||
|
||||
TVar* getValuePointer() {
|
||||
TVar *getValuePointer()
|
||||
{
|
||||
return &_value;
|
||||
}
|
||||
|
||||
TVar getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
TH1 *getHist()
|
||||
{
|
||||
return _histogram;
|
||||
}
|
||||
|
||||
void setHist(TH1D *hist)
|
||||
{
|
||||
_histogram = hist;
|
||||
}
|
||||
};
|
||||
|
||||
int general_cuts()
|
||||
@ -84,8 +108,7 @@ int general_cuts()
|
||||
gStyle->SetOptFit(0);
|
||||
|
||||
std::vector<DrawVar<Float_t>> float_vars{
|
||||
DrawVar<Float_t>{"B0_PT", 0., 20000.}
|
||||
};
|
||||
DrawVar<Float_t>("B0_PT", 0., 20000.)};
|
||||
std::vector<DrawVar<Double_t>> double_vars{
|
||||
|
||||
};
|
||||
@ -107,16 +130,14 @@ int general_cuts()
|
||||
|
||||
for (size_t i = 0; i < float_vars.size(); i++)
|
||||
{
|
||||
auto the_var = &float_vars[i];
|
||||
chain->SetBranchAddress(the_var->identifier.c_str(), &(the_var->value));
|
||||
the_var->histogram = new TH1D(TString::Format("h1_%s", the_var->identifier.c_str()).Data(), the_var->identifier.c_str(), nBins, the_var->min, the_var->max);
|
||||
chain->SetBranchAddress(float_vars[i].getIdStr(), float_vars[i].getValuePointer());
|
||||
float_vars[i].setHist(new TH1D(TString::Format("h1_%s", float_vars[i].getIdStr()).Data(), float_vars[i].getIdStr(), nBins, float_vars[i].getMin(), float_vars[i].getMax()));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < double_vars.size(); i++)
|
||||
{
|
||||
auto the_var = &double_vars[i];
|
||||
chain->SetBranchAddress(the_var->identifier.c_str(), &(the_var->value));
|
||||
the_var->histogram = new TH1D(TString::Format("h1_%s", the_var->identifier.c_str()).Data(), the_var->identifier.c_str(), nBins, the_var->min, the_var->max);
|
||||
chain->SetBranchAddress(double_vars[i].getIdStr(), double_vars[i].getValuePointer());
|
||||
double_vars[i].setHist(new TH1D(TString::Format("h1_%s", double_vars[i].getIdStr()).Data(), double_vars[i].getIdStr(), nBins, double_vars[i].getMin(), double_vars[i].getMax()));
|
||||
}
|
||||
|
||||
unsigned int entries = chain->GetEntries();
|
||||
@ -128,12 +149,12 @@ int general_cuts()
|
||||
|
||||
for (size_t i = 0; i < float_vars.size(); i++)
|
||||
{
|
||||
float_vars[i].histogram->Fill(float_vars[i].value);
|
||||
float_vars[i].getHist()->Fill(float_vars[i].getValue());
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < double_vars.size(); i++)
|
||||
{
|
||||
double_vars[i].histogram->Fill(double_vars[i].value);
|
||||
double_vars[i].getHist()->Fill(double_vars[i].getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,28 +164,33 @@ int general_cuts()
|
||||
|
||||
c1->Draw();
|
||||
|
||||
if (float_vars.size() > 0)
|
||||
{
|
||||
TCanvas *c2 = new TCanvas("c2", "Canvas 2", 0, 0, 1200, 600);
|
||||
c2->Divide(4, 2);
|
||||
|
||||
for (size_t i = 0; i < float_vars.size(); i++)
|
||||
{
|
||||
c2->cd(i + 1);
|
||||
float_vars[i].histogram->Draw();
|
||||
float_vars[i].getHist()->Draw();
|
||||
}
|
||||
|
||||
c2->Draw();
|
||||
}
|
||||
|
||||
if (double_vars.size() > 0)
|
||||
{
|
||||
TCanvas *c3 = new TCanvas("c3", "Canvas 3", 0, 0, 1200, 600);
|
||||
c3->Divide(4, 2);
|
||||
|
||||
for (size_t i = 0; i < double_vars.size(); i++)
|
||||
{
|
||||
c3->cd(i + 1);
|
||||
double_vars[i].histogram->Draw();
|
||||
double_vars[i].getHist()->Draw();
|
||||
}
|
||||
|
||||
c3->Draw();
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user