1 #include "KVDataQualityAudit.h"
14 tel =
new idtelescope(
N.GetIdentifyingTelescope()->GetName());
49 while ((o = next())) {
84 if (!idtel->HasElement(Z))
87 auto& elem = idtel->GetElement(Z);
88 if (
E < elem.GetIdThreshold())
91 if (!elem.HasIsotopes()) {
93 A = elem.get_default_mass();
97 if (elem.HasIsotope(A)) {
98 if (
E > elem.GetIsotope(A).GetIdThreshold())
103 if (
E < elem.get_minimum_isotopic_threshold(a_min_thresh)) {
105 A = elem.get_default_mass();
110 if (a_min_thresh < A) {
112 while (
a >= a_min_thresh) {
113 if (elem.HasIsotope(
a) &&
E > elem.GetIsotope(
a).GetIdThreshold()) {
124 auto seuil_map = elem.get_isotopes_sorted_by_threshold();
126 for (
auto& s : seuil_map) {
147 auto seuil_map = elem.get_isotopes_sorted_by_threshold();
148 std::map<int, int> ok_masses;
149 for (
auto& s : seuil_map) {
150 if (
E > s.first) ok_masses[s.second] = 1;
154 auto last = ok_masses.rbegin();
155 auto Amax = (*last).first;
157 auto first = ok_masses.begin();
158 auto Amin = (*first).first;
166 int adiff(999), near_a(-1);
167 for (
auto&
p : ok_masses) {
168 auto diff = std::abs(
p.first - A);
202 if (!other)
return 0;
231 if (
N.IsCalibrated() && ((
emin < 0) || (
N.GetEnergy() <
emin)))
emin =
N.GetEnergy();
240 std::cout <<
"\t\tA=" << A <<
"\t\t[E>" << emin <<
"]" << std::endl;
259 if (
N.GetZ() > 0) Z =
N.GetZ();
261 if (
N.IsCalibrated() && ((emin < 0) || (
N.GetEnergy() < emin))) emin =
N.GetEnergy();
262 if (
N.IsAMeasured()) {
263 isotopes[
N.GetA()].add(
N);
265 else if (
N.GetA() > 0) A =
N.GetA();
274 std::cout <<
"\tZ=" << (int)Z <<
"\t\t[E>" << emin <<
"]";
275 if (A > 0) std::cout <<
" default A=" << A;
276 if (!HasIsotopes()) {
277 std::cout << std::endl;
280 std::cout <<
"\t\tIsotopes: " << GetIsotopeList().AsString() << std::endl;
281 for (
auto i : isotopes) i.second.print();
304 if (elem.
emin > 0) emin = std::min(emin, elem.
emin);
306 else if (elem.
emin > 0) emin = elem.
emin;
307 A = std::max(A, elem.
A);
312 [&](
const std::pair<int, isotope>& isotop) {
313 if (HasIsotope(isotop.first)) {
314 isotopes[isotop.first].merge(isotop.second);
317 isotopes[isotop.first] = isotop.second;
332 if (isotopes.empty())
return 0;
333 double sum{0}, weight{0};
334 std::for_each(std::begin(isotopes), std::end(isotopes),
335 [&](
const std::pair<int, isotope>& count) {
336 sum += count.second.counts;
337 weight += count.first * count.second.counts;
340 if (
sum > 0)
return weight /
sum;
353 if (isotopes.empty())
return 0;
354 auto last = isotopes.rbegin();
355 return (*last).first;
367 if (isotopes.empty())
return 0;
368 auto first = isotopes.begin();
369 return (*first).first;
383 if (isotopes.empty())
return -1;
385 for (
auto&
p : isotopes) {
386 double myE =
p.second.emin /
p.first;
387 if ((myE > 0) && (myE < minE)) {
392 if (minE < 9999)
return minE;
408 if (isotopes.empty())
return -1;
410 for (
auto&
p : isotopes) {
411 double myE =
p.second.emin;
412 if ((myE > 0) && (myE < minE)) {
417 if (minE < 9999)
return minE;
431 std::map<double, int> seuils;
432 for (
auto& i : isotopes) {
433 seuils[i.second.GetIdThreshold()] = i.first;
448 std::for_each(std::begin(isotopes), std::end(isotopes),
449 [&](
const std::pair<int, isotope>& count) {
450 sum += count.second.counts;
453 std::map<int, double> proba;
454 for (
auto&
p : isotopes) {
455 proba[
p.first] =
p.second.counts /
sum;
466 elements[
N.GetZ()].add(
N);
475 std::cout <<
GetName() <<
" :" << std::endl;
476 std::cout <<
"Elements: " << GetElementList().AsString() << std::endl;
477 for (
auto e : elements)
e.second.print();
494 [&](
const std::pair<int, element>& elem) {
495 if (HasElement(elem.first)) {
496 elements[elem.first].merge(elem.second);
499 elements[elem.first] = elem.second;
515 std::for_each(std::begin(elements), std::end(elements),
516 [&](
const std::pair<int, element>& count) {
517 sum += count.second.counts;
520 std::map<int, double> proba;
521 for (
auto&
p : elements) {
522 proba[
p.first] =
p.second.counts /
sum;
535 double sum{0}, weight{0};
536 std::for_each(std::begin(elements), std::end(elements),
537 [&](
const std::pair<int, element>& count) {
538 sum += count.second.counts;
539 weight += count.second.counts * count.first;
553 auto last = elements.rbegin();
554 return (*last).first;
564 auto it = elements.rbegin();
565 while (it != elements.rend()) {
566 if ((*it).second.HasIsotopes())
return (*it).first;
579 auto first = elements.begin();
580 return (*first).first;
591 double sum{0}, weight{0};
592 std::for_each(std::begin(elements), std::end(elements),
593 [&](
const std::pair<int, element>& count) {
594 sum += count.second.counts;
595 weight += count.second.counts * count.second.get_mean_isotopic_mass();
610 for (
auto&
e : elements) {
611 max = std::max(
max,
e.second.get_max_isotopic_mass());
625 for (
auto&
e : elements) {
626 if (
auto other_A =
e.second.get_min_isotopic_mass())
627 min = std::min(
min, other_A);
winID h TVirtualViewer3D TVirtualGLPainter p
Helper class used by CanIdentify() to test whether particles can be identified.
@ telescope_not_functioning
@ partial_isotopic_identification
@ A_never_measured_but_between_Amin_and_Amax
@ identification_not_possible_for_this_Z
@ below_threshold_for_Z_identification
@ A_less_than_measured_Amin
@ full_isotopic_identification
@ A_greater_than_measured_Amax
void Print(Option_t *opt="") const override
void add(const KVReconstructedNucleus &N)
std::map< int, element > elements
void merge(const idtelescope *)
double get_mean_A() const
int get_max_Z_with_isotopes() const
std::map< int, double > get_element_distribution() const
double get_mean_Z() const
Audit of experimental data identification and calibrations.
Long64_t merge(KVDataQualityAudit *)
void Print(Option_t *opt="") const override
Long64_t Merge(TCollection *)
Bool_t HasTelescope(const TString &tel_name) const
IDStatus CanIdentify(const TString &tel_name, int Z, int &A, double E) const
idtelescope * GetTelescope(const TString &tel_name) const
KVUniqueNameList telescopes
const KVSeqCollection * GetTelescopeList() const
void Add(const KVReconstructedNucleus &N)
Add this reconstructed nucleus to the audit.
void add(const idtelescope *)
Add copy of idtelescope data to this audit.
Nuclei reconstructed from data measured by a detector array .
T * get_object(const TString &name) const
void Add(TObject *obj) override
const char * GetName() const override
virtual void Print(Option_t *option="") const
double min(double x, double y)
double max(double x, double y)
void merge(const element &)
double get_mean_isotopic_mass() const
calculate and return mean mass of isotopes measured for this element
std::map< double, int > get_isotopes_sorted_by_threshold() const
double get_minimum_isotopic_threshold(int &) const
std::map< int, double > get_isotopic_distribution() const
std::map< int, isotope > isotopes
Double_t counts
watch the alignment !
int get_min_isotopic_mass() const
return min A of isotopes measured for this element
double get_minimum_isotopic_threshold_mev_per_nuc(int &) const
void add(const KVReconstructedNucleus &N)
int get_max_isotopic_mass() const
return max A of isotopes measured for this element
void add(const KVReconstructedNucleus &N)
Double_t counts
watch the alignment !