42 void AddParticle(
const ParticleFit& particle, uint
id) { species_[id] = particle; }
43 void AddParticles(std::map<int, ParticleFit>&& species) { species_ = species; }
45 std::map<int, double> GetBayesianProbability(
double p,
double m2);
46 void SetRange(
double min,
double max) { minx_ = min, maxx_ = max; }
48 std::map<uint, double> GetSigma(
double p,
double m2) {
49 std::map<uint, double> sigma{};
51 if (p > maxx_ || p < minx_)
54 for (
auto& specie : species_) {
55 sigma[specie.first] = abs(m2 - specie.second.GetMean(p)) / specie.second.GetSigma(p);
60 int GetPid(
double p,
double m2,
double purity)
override {
61 auto prob = GetBayesianProbability(p, m2);
62 for (
auto& pid_prob : prob)
63 if (pid_prob.second >= purity)
return pid_prob.first;
67 double GetWeight(
double var1,
double var2,
int pid)
override {
71 std::map<int, double> GetWeights(
double var1,
double var2)
override {
72 return GetBayesianProbability(var1, var2);
76 auto it = species_.find(pid);
77 if (it != species_.end()) {
80 throw std::runtime_error(
"Particle " + std::to_string(pid) +
" is not found!");
84 std::map<int, ParticleFit> species_{};
85 double minx_{-100000.};
86 double maxx_{100000.};
88 ClassDefOverride(
Getter, 1);
97 void AddParticle(TCutG* cut,
int pdgId) {
99 auto insert_result = species_.insert({pdgId, {cut}});
100 if (!insert_result.second) {
101 (*insert_result.first).second.push_back(cut);
106 throw std::logic_error(
"empty TCutG object");
109 int GetPid(
double var1,
double var2,
double)
override {
111 for (
const auto& specie : species_) {
112 int pdgId = specie.first;
113 auto specieCuts = specie.second;
115 for (
auto cut : specieCuts) {
116 if (cut->IsInside(var1, var2)) {
125 double GetWeight(
double var1,
double var2,
int pid)
override {
126 return 1.0 * (GetPid(var1, var2, 1) == pid);
129 std::map<int, double> GetWeights(
double var1,
double var2)
override {
130 std::map<int, double> result;
132 for (
const auto& specie : species_) {
133 result.insert({specie.first, GetWeight(var1, var2, specie.first)});
139 void Draw(Option_t* option =
"")
override {
140 TObject::Draw(option);
142 TMultiGraph mg(
"mg",
"");
145 for (
const auto& specie : species_) {
146 auto specieCuts = specie.second;
147 for (
auto cut : specieCuts) mg.Add(cut);
150 mg.DrawClone(option);
152 for (
const auto& specie : species_) {
153 int pdgId = specie.first;
154 auto specieCuts = specie.second;
157 for (
auto cut : specieCuts) {
159 pdgLabel.DrawText(xc, yc, Form(
"%d", pdgId));
165 std::map<int, std::vector<TCutG*>> species_{};
Class to store fit resuls for particle specie.
Definition ParticleFit.h:19