233 lines
5.0 KiB
C++
233 lines
5.0 KiB
C++
#include "TH1D.h"
|
|
#include "TH2D.h"
|
|
#include "THStack.h"
|
|
#include "TGraph.h"
|
|
#include "TTree.h"
|
|
#include "TChain.h"
|
|
#include "TFile.h"
|
|
#include "TCanvas.h"
|
|
#include "TROOT.h"
|
|
#include "TStyle.h"
|
|
#include "TColor.h"
|
|
#include "TLorentzVector.h"
|
|
#include "TRandom3.h"
|
|
#include "TLorentzVector.h"
|
|
#include "TString.h"
|
|
|
|
#include "RooDataHist.h"
|
|
#include "RooRealVar.h"
|
|
#include "RooPlot.h"
|
|
#include "RooGaussian.h"
|
|
#include "RooExponential.h"
|
|
#include "RooRealConstant.h"
|
|
#include "RooAddPdf.h"
|
|
#include "RooFitResult.h"
|
|
#include "RooProduct.h"
|
|
#include "RooCrystalBall.h"
|
|
#include "RooBreitWigner.h"
|
|
#include "RooArgSet.h"
|
|
#include "RooFFTConvPdf.h"
|
|
#include "RooNovosibirsk.h"
|
|
|
|
#include <string>
|
|
#include <iostream>
|
|
#include <cmath>
|
|
#include <vector>
|
|
|
|
template <typename T>
|
|
class Cut {
|
|
public:
|
|
virtual bool Check(T y) = 0;
|
|
virtual std::string ToString() = 0;
|
|
};
|
|
|
|
template <typename T>
|
|
class LT : public Cut<T> {
|
|
private:
|
|
T value;
|
|
|
|
public:
|
|
LT(T val) : value{val} {
|
|
|
|
}
|
|
|
|
bool Check(T y) {
|
|
return y < value;
|
|
}
|
|
|
|
std::string ToString() {
|
|
return TString::Format("(x < %s)", std::to_string(value).c_str()).Data();
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
class GT : public Cut<T> {
|
|
private:
|
|
T value;
|
|
|
|
public:
|
|
GT(T val) : value{val} {}
|
|
|
|
bool Check(T y) {
|
|
return y > value;
|
|
}
|
|
|
|
std::string ToString() {
|
|
return TString::Format("(x > %s)", std::to_string(value).c_str()).Data();
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
class EQ : public Cut<T> {
|
|
private:
|
|
T value;
|
|
|
|
public:
|
|
EQ(T val) : value{val} {}
|
|
|
|
bool Check(T y) {
|
|
return y == value;
|
|
}
|
|
|
|
std::string ToString() {
|
|
return TString::Format("(x == %s)", std::to_string(value).c_str()).Data();
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
class BT : public Cut<T> {
|
|
private:
|
|
T low;
|
|
T up;
|
|
|
|
public:
|
|
BT(T lower, T upper) : low{lower}, up{upper} {}
|
|
|
|
bool Check(T y) {
|
|
return low < y && y < up;
|
|
}
|
|
|
|
std::string ToString() {
|
|
return TString::Format("(x in [%s, %s])", std::to_string(low).c_str(), std::to_string(up).c_str()).Data();
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
class Variable {
|
|
private:
|
|
const char* name;
|
|
std::vector<Cut<T>*> cuts;
|
|
|
|
T value;
|
|
|
|
public:
|
|
|
|
Variable() {
|
|
}
|
|
|
|
Variable(const char* name, std::vector<Cut<T>*> cuts) {
|
|
this->name = name;
|
|
this->cuts = cuts;
|
|
}
|
|
|
|
T* GetValuePtr() {
|
|
return &value;
|
|
}
|
|
|
|
T GetValue() const {
|
|
return value;
|
|
}
|
|
};
|
|
|
|
class VariableCollection {
|
|
private:
|
|
std::map<std::string, Variable<Double_t>> doubles;
|
|
std::map<std::string, Variable<Float_t>> floats;
|
|
std::map<std::string, Variable<Int_t>> ints;
|
|
std::map<std::string, Variable<Bool_t>> bools;
|
|
|
|
public:
|
|
VariableCollection() {
|
|
doubles = std::map<std::string, Variable<Double_t>>{};
|
|
floats = std::map<std::string, Variable<Float_t>>{};
|
|
ints = std::map<std::string, Variable<Int_t>>{};
|
|
bools = std::map<std::string, Variable<Bool_t>>{};
|
|
}
|
|
|
|
void Connect(TChain *chain) {
|
|
for (auto& [key, var] : doubles) {
|
|
chain->SetBranchAddress(key.c_str(), var.GetValuePtr());
|
|
}
|
|
|
|
for (auto& [key, var] : floats) {
|
|
chain->SetBranchAddress(key.c_str(), var.GetValuePtr());
|
|
}
|
|
|
|
for (auto& [key, var] : ints) {
|
|
chain->SetBranchAddress(key.c_str(), var.GetValuePtr());
|
|
}
|
|
|
|
for (auto& [key, var] : bools) {
|
|
chain->SetBranchAddress(key.c_str(), var.GetValuePtr());
|
|
}
|
|
}
|
|
|
|
void AddDouble(const char* name, const std::vector<Cut<Double_t>*>& cuts) {
|
|
doubles[name] = Variable<Double_t>(name, cuts);
|
|
}
|
|
|
|
void AddFloat(const char* name, const std::vector<Cut<Float_t>*>& cuts) {
|
|
floats[name] = Variable<Float_t>(name, cuts);
|
|
}
|
|
|
|
void AddInt(const char* name, const std::vector<Cut<Int_t>*>& cuts) {
|
|
ints[name] = Variable<Int_t>(name, cuts);
|
|
}
|
|
|
|
void AddBool(const char* name, const std::vector<Cut<Bool_t>*>& cuts) {
|
|
bools[name] = Variable<Bool_t>(name, cuts);
|
|
}
|
|
|
|
void PrintValues() {
|
|
for (const auto& [key, var] : doubles) {
|
|
std::cout << key << ": " << var.GetValue() << std::endl;
|
|
}
|
|
|
|
for (const auto& [key, var] : floats) {
|
|
std::cout << key << ": " << var.GetValue() << std::endl;
|
|
}
|
|
|
|
for (const auto& [key, var] : ints) {
|
|
std::cout << key << ": " << var.GetValue() << std::endl;
|
|
}
|
|
|
|
for (const auto& [key, var] : bools) {
|
|
std::cout << key << ": " << var.GetValue() << std::endl;
|
|
}
|
|
}
|
|
};
|
|
|
|
int do_all() {
|
|
|
|
VariableCollection col{};
|
|
col.AddDouble("B_M", {});
|
|
col.AddDouble("Jpsi_M", {});
|
|
col.AddFloat("Kplus_PT", {});
|
|
col.AddBool("muminus_ISMUON", {});
|
|
col.AddInt("muplus_Q", {});
|
|
|
|
TChain *data_chain = new TChain(TString::Format("%s/DecayTree", "Hlt2RD_BuToKpMuMu").Data());
|
|
data_chain->Add("/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/Collision23_Beam6800GeV-VeloClosed-MagDown-Excl-UT_RealData_SprucingPass23r1_94000000_RD.root");
|
|
|
|
col.Connect(data_chain);
|
|
|
|
data_chain->GetEntry(1);
|
|
|
|
col.PrintValues();
|
|
|
|
data_chain->GetEntry(2);
|
|
|
|
col.PrintValues();
|
|
|
|
return 0;
|
|
} |