4 #include "KVIDZAFromZGrid.h"
6 #include "KVIDZALine.h"
27 fIgnoreMassID =
false;
52 i.fPIDRange = fPIDRange;
53 i.fPIDRangeZList = fPIDRangeZList;
54 fTables.
Copy(i.fTables);
56 i.fIgnoreMassID = fIgnoreMassID;
79 fIgnoreMassID =
false;
81 check_pidranges_and_massfits();
100 fPIDRangeZList.
Clear();
117 double pidmin, pidmax, pid;
119 else if (
type == 2) {
124 itv->
add(aa, pid, pidmin, pidmax);
128 fPIDRangeZList.
Add(zz);
143 fPIDRangeZList.
Clear();
176 fPIDRangeZList.
Add(ivs->
GetZ());
199 auto z_int = itvs->
GetZ();
200 fPIDRangeZList.
Remove(z_int);
230 fPIDRangeZList.
Clear();
232 for (
int ii = 1; ii < 50; ii++) {
248 int KVIDZAFromZGrid::is_inside(
double pid)
const
265 if (it && it->
is_inside(pid))
return zint + 1;
270 if (it && it->
is_inside(pid))
return zint - 1;
305 for (
auto z : zlist) {
309 fitparams.
Set(massfit);
323 void KVIDZAFromZGrid::check_pidranges_and_massfits()
330 if(fPar.HasParameter(
"MASSFITS"))
336 auto massfits_copy = massfits;
337 massfits.Inter(pidrange);
338 if(massfits != massfits_copy)
340 KVError::Error(
this,
"KVIDZAFromZGrid::check_pidranges_and_massfits",
341 "Grid %s has inconsistent MASSFITS (%s) and PIDRANGE (%s) - correcting...",
342 GetName(), massfits_copy.AsString(), pidrange.AsString());
345 for(
auto z : massfits)
350 "Grid %s : removing fit for Z=%d...",
359 for (
auto z : massfits) {
360 if(pidrange.Contains(z))
365 fitparams.
Set(massfit);
378 auto pipi = pidr.
Next();
380 pidalist.
Add(pipi.Next().Atoi());
382 auto alist_orig = alist;
383 alist.Inter(pidalist);
384 if(alist != alist_orig)
387 "Grid %s has inconsistent masses for Z=%d for MASSFIT (%s) and PIDRANGE (%s)",
402 auto A = fitfunc->GetA(idr->
PID, P);
405 idr->
PID = fitfunc->GetInterpolatedA(idr->
PID);
448 if (!idr->
IDOK)
return;
450 bool have_pid_range_for_Z = fPIDRange && fPIDRangeZList.
Contains(idr->
Z);
452 bool have_mass_fit_for_Z = (mass_fit_for_Z !=
nullptr);
453 bool mass_id_success =
false;
455 if ((have_mass_fit_for_Z || have_pid_range_for_Z)
458 if (have_mass_fit_for_Z)
462 if (mass_id_success) {
487 if (mass_id_success) idr->
SetComment(
"slight ambiguity of A, which could be larger");
488 else idr->
SetComment(
"slight ambiguity of Z, which could be larger");
491 if (mass_id_success) idr->
SetComment(
"slight ambiguity of A, which could be smaller");
492 else idr->
SetComment(
"slight ambiguity of Z, which could be smaller");
495 if (mass_id_success) idr->
SetComment(
"slight ambiguity of A, which could be larger or smaller");
496 else idr->
SetComment(
"slight ambiguity of Z, which could be larger or smaller");
499 if (mass_id_success) idr->
SetComment(
"point is outside of mass identification range");
500 else idr->
SetComment(
"Z identification correct but no mass identification");
503 if (mass_id_success) idr->
SetComment(
"point is in between two isotopes A & A+2 (e.g. 5He, 8Be, 9B)");
504 else idr->
SetComment(
"point is in between two lines of different Z, too far from either to be considered well-identified");
507 idr->
SetComment(
"(x,y) is below first line in grid");
510 idr->
SetComment(
"(x,y) is above last line in grid");
513 idr->
SetComment(
"no identification: (x,y) out of range covered by grid");
533 int zint = is_inside(idr->
PID);
534 if (!zint)
return -1;
535 if (zint != idr->
Z) idr->
Z = zint;
539 if (it) res = it->
eval(idr);
555 if (!itvs->
GetNPID())
continue;
556 fPIDRangeZList.
Add(itvs->
GetZ());
563 if (!itvs->
GetNPID())
continue;
571 KVError::Error(
this,
"ExportToGrid",
"Grid %s has interval set for Z=%d including resonance %s",
581 auto massfits_copy = massfits;
582 massfits.
Inter(fPIDRangeZList);
583 if(massfits != massfits_copy)
585 ::Info(
"KVIDZAFromZGrid::ExportToGrid()",
586 "Grid %s : will correct MASSFITS(%s) to be same as PIDRANGE(%s)",
589 massfits = fPIDRangeZList;
592 for(
auto z : massfits)
596 ::Info(
"KVIDZAFromZGrid::ExportToGrid()",
597 "Grid %s : removing fit for Z=%d for which no PIDRANGE exists (%s)",
613 double pid = idr->
PID;
614 if (pid < 0.5)
return 0.;
624 interval* left_int(
nullptr), *right_int(
nullptr);
629 ares = inter->
GetA();
652 if (!right_int || !left_int) {
660 int dA = right_int->
GetA() - left_int->GetA();
750 std::map<double,int> toto;
754 auto it = std::begin(toto);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char * Form(const char *fmt,...)
virtual void WriteToAsciiFile(std::ofstream &gridfile)
const Char_t * GetName() const override
const KVNameValueList * GetParameters() const
const KVList * GetIdentifiers() const
Hybrid charge & mass identification grid.
const KVList * GetIntervalSets() const
bool MassIdentificationFromMultiGaussFit(KVMultiGaussIsotopeFit *, KVIdentificationResult *) const
void Initialize() override
interval_set * GetIntervalSet(int zint) const
void WriteToAsciiFile(std::ofstream &gridfile) override
void Identify(Double_t x, Double_t y, KVIdentificationResult *) const override
virtual double DeduceAfromPID(KVIdentificationResult *idr) const
void AddIntervalSet(interval_set *)
add an interval set to the grid, updating the corresponding parameters
KVMultiGaussIsotopeFit * GetMultiGaussFit(int z) const
void SetOnlyZId(Bool_t=kTRUE) override
void RemoveIntervalSet(int zint)
Remove interval set for given Z from grid.
void ReadFromAsciiFile(std::ifstream &gridfile) override
void Copy(TObject &obj) const override
void ReadFromAsciiFile(std::ifstream &gridfile) override
void Copy(TObject &) const override
Copy this to 'obj'.
void Initialize() override
void Identify(Double_t x, Double_t y, KVIdentificationResult *) const override
Base class for graphical cuts used in particle identification.
Full result of one attempted particle identification.
Bool_t IDOK
general quality of identification, =kTRUE if acceptable identification made
void SetComment(const Char_t *c)
Bool_t Aident
= kTRUE if A of particle established
Double_t PID
= "real" Z if Zident==kTRUE and Aident==kFALSE, "real" A if Zident==Aident==kTRUE
Int_t A
A of particle found (if Aident==kTRUE)
Int_t Z
Z of particle found (if Zident==kTRUE)
Int_t IDquality
specific quality code returned by identification procedure
Bool_t HasFlag(std::string grid_name, TString flag)
Bool_t Zident
=kTRUE if Z of particle established
Function for fitting PID mass spectra.
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
void SetValue(const Char_t *name, value_type value)
void RemoveParameter(const Char_t *name)
const Char_t * GetStringValue(const Char_t *name) const
bool Set(const KVString &)
TString GetTStringValue(const Char_t *name) const
Description of properties and kinematics of atomic nuclei.
const Char_t * GetSymbol(Option_t *opt="") const
Bool_t IsResonance() const
Strings used to represent a set of ranges of values.
void Inter(const KVNumberList &list)
Bool_t Contains(Int_t val) const
returns kTRUE if the value 'val' is contained in the ranges defined by the number list
void Clear(Option_t *="") override
Empty number list, reset it to initial state.
const Char_t * AsString(Int_t maxchars=0) const
void Remove(Int_t)
Remove value 'n' from the list.
void Add(Int_t)
Add value 'n' to the list.
void Copy(TObject &obj) const override
TObject * Remove(TObject *obj) override
Remove object from list.
void Add(TObject *obj) override
void AddLast(TObject *obj) override
void Clear(Option_t *option="") override
TObject * At(Int_t idx) const override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
void Add(TObject *obj) override
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
virtual Double_t Eval(Double_t x, TSpline *spline=nullptr, Option_t *option="") const
virtual void SetName(const char *name)
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
Bool_t IsWhitespace() const
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
TString GetListOfMasses()
bool is_inside(double pid)
bool is_above(double pid)
void add(int aa, double pid, double pidmin=-1., double pidmax=-1.)
double eval(KVIdentificationResult *idr)
interval_set(int zz, int type)
bool is_right_of(double pid)
bool is_left_of(double pid)
bool is_inside(double pid)
void Error(UserClass p, const char *location, const char *va_(fmt),...)
void Warning(UserClass p, const char *location, const char *va_(fmt),...)