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 if(ok_masses.empty())
159 auto last = ok_masses.rbegin();
161 if(last != ok_masses.rend())
162 Amax = (*last).first;
165 Error(
"CanIdentify",
"problem with ok_masses map...: tel=%s Z=%d A=%d E=%f", tel_name.
Data(), Z, A,
E);
166 std::cout <<
"contents of seuil_map:\n";
167 for(
auto&
p : seuil_map)
169 std::cout <<
"seuil_map[" <<
p.first <<
"] = " <<
p.second << std::endl;
174 auto first = ok_masses.begin();
175 auto Amin = (*first).first;
183 int adiff(999), near_a(-1);
184 for (
auto&
p : ok_masses) {
185 auto diff = std::abs(
p.first - A);
219 if (!other)
return 0;
248 if (
N.IsCalibrated() && ((
emin < 0) || (
N.GetEnergy() <
emin)))
emin =
N.GetEnergy();
257 std::cout <<
"\t\tA=" << A <<
"\t\t[E>" << emin <<
"]" << std::endl;
276 if (
N.GetZ() > 0) Z =
N.GetZ();
278 if (
N.IsCalibrated() && ((emin < 0) || (
N.GetEnergy() < emin))) emin =
N.GetEnergy();
279 if (
N.IsAMeasured()) {
280 isotopes[
N.GetA()].add(
N);
282 else if (
N.GetA() > 0) A =
N.GetA();
291 std::cout <<
"\tZ=" << (int)Z <<
"\t\t[E>" << emin <<
"]";
292 if (A > 0) std::cout <<
" default A=" << A;
293 if (!HasIsotopes()) {
294 std::cout << std::endl;
297 std::cout <<
"\t\tIsotopes: " << GetIsotopeList().AsString() << std::endl;
298 for (
auto i : isotopes) i.second.print();
321 if (elem.
emin > 0) emin = std::min(emin, elem.
emin);
323 else if (elem.
emin > 0) emin = elem.
emin;
324 A = std::max(A, elem.
A);
329 [&](
const std::pair<int, isotope>& isotop) {
330 if (HasIsotope(isotop.first)) {
331 isotopes[isotop.first].merge(isotop.second);
334 isotopes[isotop.first] = isotop.second;
349 if (isotopes.empty())
return 0;
350 double sum{0}, weight{0};
351 std::for_each(std::begin(isotopes), std::end(isotopes),
352 [&](
const std::pair<int, isotope>& count) {
353 sum += count.second.counts;
354 weight += count.first * count.second.counts;
357 if (
sum > 0)
return weight /
sum;
370 if (isotopes.empty())
return 0;
371 auto last = isotopes.rbegin();
372 return (*last).first;
384 if (isotopes.empty())
return 0;
385 auto first = isotopes.begin();
386 return (*first).first;
400 if (isotopes.empty())
return -1;
402 for (
auto&
p : isotopes) {
403 double myE =
p.second.emin /
p.first;
404 if ((myE > 0) && (myE < minE)) {
409 if (minE < 9999)
return minE;
425 if (isotopes.empty())
return -1;
427 for (
auto&
p : isotopes) {
428 double myE =
p.second.emin;
429 if ((myE > 0) && (myE < minE)) {
434 if (minE < 9999)
return minE;
448 std::map<double, int> seuils;
449 for (
auto& i : isotopes) {
450 seuils[i.second.GetIdThreshold()] = i.first;
465 std::for_each(std::begin(isotopes), std::end(isotopes),
466 [&](
const std::pair<int, isotope>& count) {
467 sum += count.second.counts;
470 std::map<int, double> proba;
471 for (
auto&
p : isotopes) {
472 proba[
p.first] =
p.second.counts /
sum;
483 elements[
N.GetZ()].add(
N);
492 std::cout <<
GetName() <<
" :" << std::endl;
493 std::cout <<
"Elements: " << GetElementList().AsString() << std::endl;
494 for (
auto e : elements)
e.second.print();
511 [&](
const std::pair<int, element>& elem) {
512 if (HasElement(elem.first)) {
513 elements[elem.first].merge(elem.second);
516 elements[elem.first] = elem.second;
532 std::for_each(std::begin(elements), std::end(elements),
533 [&](
const std::pair<int, element>& count) {
534 sum += count.second.counts;
537 std::map<int, double> proba;
538 for (
auto&
p : elements) {
539 proba[
p.first] =
p.second.counts /
sum;
552 double sum{0}, weight{0};
553 std::for_each(std::begin(elements), std::end(elements),
554 [&](
const std::pair<int, element>& count) {
555 sum += count.second.counts;
556 weight += count.second.counts * count.first;
570 auto last = elements.rbegin();
571 return (*last).first;
581 auto it = elements.rbegin();
582 while (it != elements.rend()) {
583 if ((*it).second.HasIsotopes())
return (*it).first;
596 auto first = elements.begin();
597 return (*first).first;
608 double sum{0}, weight{0};
609 std::for_each(std::begin(elements), std::end(elements),
610 [&](
const std::pair<int, element>& count) {
611 sum += count.second.counts;
612 weight += count.second.counts * count.second.get_mean_isotopic_mass();
627 for (
auto&
e : elements) {
628 max = std::max(
max,
e.second.get_max_isotopic_mass());
642 for (
auto&
e : elements) {
643 if (
auto other_A =
e.second.get_min_isotopic_mass())
644 min = std::min(
min, other_A);
winID h TVirtualViewer3D TVirtualGLPainter p
void Error(const char *method, const char *msgfmt,...) const override
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
const char * Data() 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 !