21 #include "KVIDZAGrid.h"
22 #include "KVIDZALine.h"
23 #include "KVIDCutLine.h"
26 #include "KVIdentificationResult.h"
44 KVIDZAGrid::~KVIDZAGrid()
81 void KVIDZAGrid::init()
87 kinfi = kinf = ksup = ksups = -1;
88 dinf = dsup = dinfi = dsups = 0.;
89 winf = wsup = winfi = wsups = 0.;
90 Zinfi = Zinf = Zsup = Zsups = Ainfi = Ainf = Asup = Asups = 0;
91 fDistanceClosest = -1.;
92 fClosest = fLsups = fLsup = fLinf = fLinfi = 0;
106 gROOT->ProcessLine(
"if(gROOT->FindObject(\"gIDGridEditorCanvas\")) gIDGridEditor->Clear()");
110 if ((A > 0) && (!IsOnlyZId())) {
116 TIter next_id(tmplist);
162 UInt_t idx_max = nlines - 1;
167 while (idx_max > idx_min + 1) {
181 idx += (
Int_t)((idx_max - idx) / 2 + 0.5);
186 idx -= (
Int_t)((idx - idx_min) / 2 + 0.5);
191 if (
line->GetZ() == z) {
196 if (
line->GetZ() == z) {
227 if (
line->GetA() ==
a) {
232 if (
a >
line->GetA()) {
235 if (
line->GetZ() != z)
237 if (
line->GetA() ==
a) {
245 else if (a < line->GetA()) {
246 for (
int i = idx; i > 0; i--) {
248 if (
line->GetZ() != z)
250 if (
line->GetA() ==
a) {
340 i_other = (Zhi > -1 ? i + 1 : (Zlo > -1 ? i - 1 : -1));
344 i_other = (Zhi == Z ? i + 1 : (Zlo == Z ? i - 1 : -1));
346 if (!IsOnlyZId() && i_other < 0) {
347 i_other = (Zhi > -1 ? i + 1 : (Zlo > -1 ? i - 1 : -1));
446 _line->SetAsymWidth(D_L, D_R);
471 if (!
gPad->GetListOfPrimitives()->GetSize()) {
480 line->GetLineWithWidth()->
Draw(
"3PL");
548 kinfi = kinf = ksup = ksups = -1;
549 dinf = dsup = dinfi = dsups = 0.;
550 winf = wsup = winfi = wsups = 16000.;
551 Zinfi = Zinf = Zsup = Zsups = Ainfi = Ainf = Asup = Asups = -1;
552 fDistanceClosest = -1.;
553 fClosest = fLsups = fLsup = fLinf = fLinfi = 0;
558 if (!fClosest)
return kFALSE;
561 if (kinf > -1 && kinf == fIdxClosest) {
567 Zinf = fLinf->
GetZ();
568 Ainf = fLinf->
GetA();
574 Zsup = fLsup->
GetZ();
575 Asup = fLsup->
GetA();
579 else if (ksup > -1 && ksup == fIdxClosest) {
585 Zsup = fLsup->
GetZ();
586 Asup = fLsup->
GetA();
592 Zinf = fLinf->
GetZ();
593 Ainf = fLinf->
GetA();
599 "I do not understand the result of FindNearestEmbracingIDLine!!!");
608 if (!fLinfi) kinfi = -1;
613 Zinfi = fLinfi->
GetZ();
614 Ainfi = fLinfi->
GetA();
622 if (!fLsups) ksups = -1;
627 Zsups = fLsups->
GetZ();
628 Asups = fLsups->
GetA();
673 Int_t dA = Asup - Ainf;
713 y1 = 0.5 * (dinfi - dinf);
853 else if (kinf > -1) {
896 if (k > -1 && fICode ==
kICODE0) {
923 else if (ix2 == -ix1 * 2) {
925 if (tmp > 0 &&
dist != 0) {
926 dt = -(
y1 + 2. *
y2 -
934 else if (ix1 == -ix2 * 2) {
936 if (tmp > 0 &&
dist != 0) {
937 dt = -(
y2 + 2. *
y1 +
949 deltaA = yy * ix2 /
y2 / 2.;
955 if (
dist > -1. && dt * yy > -1.)
965 if (fICode ==
kICODE0 && (ibif > 0 && ibif < 4)) {
971 Int_t idx = fIdxClosest;
974 if (nextline->
GetZ() == Z
975 && !((
KVIDLine*)nextline)->IsBetweenEndPoints(
x,
y,
"x")) {
986 Int_t idx = fIdxClosest;
987 if (idx > -1 && --idx >= 0) {
989 if (nextline->
GetZ() == Z
990 && !((
KVIDLine*)nextline)->IsBetweenEndPoints(
x,
y,
"x")) {
1105 Int_t dZ = Zsup - Zinf;
1140 y1 = 0.5 * (dinfi - dinf);
1194 else if (kinf > -1) {
1236 if (k > -1 && fICode ==
kICODE0) {
1240 if (k > -1 && fICode ==
kICODE0) {
1262 else if (ix2 == -ix1 * 2) {
1264 if (tmp > 0. &&
dist != 0) {
1265 dt = -(
y1 + 2. *
y2 -
1273 else if (ix1 == -ix2 * 2) {
1275 if (tmp > 0. &&
dist != 0) {
1276 dt = -(
y2 + 2. *
y1 +
1288 deltaZ = yy * ix2 /
y2 / 2.;
1294 if (
dist > -1. && dt * yy > -1.)
1304 if (fICode ==
kICODE0 && (ibif > 0 && ibif < 4)) {
1311 Int_t idx = fIdxClosest;
1326 Int_t idx = fIdxClosest;
1327 if (idx > -1 && --idx >= 0) {
1400 if (!
const_cast<KVIDZAGrid*
>(
this)->FindFourEmbracingLines(
x,
y,
"above")) {
1404 idr->
SetComment(
"no identification: (x,y) out of range covered by grid");
1428 idr->
SetComment(
"slight ambiguity of Z, which could be larger");
1431 idr->
SetComment(
"slight ambiguity of Z, which could be smaller");
1434 idr->
SetComment(
"slight ambiguity of Z, which could be larger or smaller");
1437 idr->
SetComment(
"point is in between two lines of different Z, too far from either to be considered well-identified");
1440 idr->
SetComment(
"point is in between two lines of different Z, too far from either to be considered well-identified");
1443 idr->
SetComment(
"(x,y) is below first line in grid");
1446 idr->
SetComment(
"(x,y) is above last line in grid");
1449 idr->
SetComment(
"no identification: (x,y) out of range covered by grid");
1474 idr->
SetComment(
"slight ambiguity of A, which could be larger");
1477 idr->
SetComment(
"slight ambiguity of A, which could be smaller");
1480 idr->
SetComment(
"slight ambiguity of A, which could be larger or smaller");
1483 idr->
SetComment(
"point is in between two isotopes of different Z, too far from either to be considered well-identified");
1486 idr->
SetComment(
"point is in between two isotopes of different Z, too far from either to be considered well-identified");
1489 idr->
SetComment(
"(x,y) is below first line in grid");
1492 idr->
SetComment(
"(x,y) is above last line in grid");
1495 idr->
SetComment(
"no identification: (x,y) out of range covered by grid");
1523 if (fZMaxLine) fZMax = fZMaxLine->
GetZ();
1543 using isotope_t = std::map <int,int>;
1544 using grid_t = std::map<int,isotope_t>;
1545 using nuclide_t = std::pair<int,int>;
1546 using ident_t = std::map<nuclide_t,std::vector<KVIDLine*>>;
1551 auto idline =
dynamic_cast<KVIDZALine*
>(ident);
1552 ++lines[idline->GetZ()][idline->GetA()];
1553 nuclides[{idline->GetZ(),idline->GetA()}].push_back(idline);
1556 for(
auto& ll : lines)
1562 if(ll.first>last_z+1)
1565 "Grid %s has no line between Z=%d and Z=%d!",
GetName(),last_z,ll.first);
1569 for(
auto& aa : ll.second)
1574 "Grid %s has line (Z=%d,A=%d) %d times!",
GetName(),ll.first,aa.first,aa.second);
1579 nuclide_t last_nuclide;
1580 for(
auto& check_order : nuclides)
1582 for(
auto idl : check_order.second)
1586 if(std::greater{}(check_order.first,last_nuclide))
1588 if(!idl->WhereAmI(*last_line,
"above"))
1591 "Grid %s BAD ORDER: line (Z=%d,A=%d) is NOT above line (Z=%d,A=%d)!",
1592 GetName(), check_order.first.first, check_order.first.second,
1593 last_nuclide.first, last_nuclide.second);
1598 last_nuclide = check_order.first;
1619 KVError::Warning(
this,
"Streamer",
"Reading KVIDZGrid with version=%d", R__v);
1760 if (!graph_class) graph_class =
IsA();
1762 KVError::Error(
this,
"MakeSubsetGraph",
"Called with graph class %s, does not derive from KVIDGraph",
1805 TIter next(&fIdentifiers);
1808 if (
l->GetZ() >= Zmin &&
l->GetZ() <= Zmax) lines->
Add(
l);
1840 KVError::Warning(
this,
"Streamer",
"Reading KVIDZGrid with version=%d", R__v);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
char * Form(const char *fmt,...)
Base class for particle identification in a 2D map.
void Draw(Option_t *opt="") override
void RemoveIdentifier(KVIDentifier *)
Remove and destroy identifier.
void SetVarY(const char *v) override
Int_t GetNumberOfIdentifiers() const
Int_t GetMassFormula() const
const KVList * GetCuts() const
const KVList * GetInfos() const
void SetVarX(const char *v) override
virtual void ReadFromAsciiFile(std::ifstream &gridfile)
const Char_t * GetName() const override
KVIDentifier * GetIdentifierAt(Int_t index) const
const KVNumberList & GetRuns() const
void FindAxisLimits()
Calculate X/Y min/max of all objects in graph.
const KVNameValueList * GetParameters() const
void SetMassFormula(Int_t)
void AddIDTelescopes(const TList *)
Associate this graph with all ID telescopes in list.
virtual void AddIdentifier(KVIDentifier *id)
virtual void SetInfos(Double_t, Double_t, KVIdentificationResult *) const
loop over KVIDGraph::fInfoZones to set flags in KVIdentificationResult
void SetRuns(const KVNumberList &nl)
Set list of runs for which grid is valid.
void Copy(TObject &) const override
Copy this to 'obj'.
virtual void SetOnlyZId(Bool_t yes=kTRUE)
const KVList * GetIdentifiers() const
void Initialize() override
KVIDLine * FindNearestEmbracingIDLine(Double_t x, Double_t y, const Char_t *position, const Char_t *axis, Int_t &idx, Int_t &idx_min, Int_t &idx_max, Double_t &dist, Double_t &dist_min, Double_t &dist_max) const
KVIDLine * FindNextEmbracingLine(Int_t &index, Int_t inc_index, Double_t x, Double_t y, const Char_t *axis) const
Base class for lines/cuts used for particle identification in 2D data maps.
Double_t DistanceToLine(Double_t px, Double_t py, Int_t &)
Bool_t IsBetweenEndPoints(Double_t x, Double_t y, std::optional< TString > axis={}) const
void GetStartPoint(Double_t &x, Double_t &y) const
void GetEndPoint(Double_t &x, Double_t &y) const
Identification grid with lines corresponding to different nuclear isotopes (KVIDZALine)
void CalculateLineWidths() override
void ReCheckQuality(Int_t &Z, Double_t &A)
virtual KVIDZALine * GetZLine(Int_t z, Int_t &) const
void ReadFromAsciiFile(std::ifstream &gridfile) override
void DrawLinesWithWidth()
void RemoveZLines(const Char_t *ZList)
Remove and destroy identifiers.
virtual void IdentZ(Double_t x, Double_t y, Double_t &Z)
void Copy(TObject &) const override
Copy this to 'obj'.
KVIDZAGrid()
default ctor.
virtual void IdentZA(Double_t x, Double_t y, Int_t &Z, Double_t &A)
void SetManualWidth(Double_t manual_width=.3, Double_t manual_width_scaling=0.05)
KVIDGraph * MakeSubsetGraph(Int_t Zmin, Int_t Zmax, const Char_t *="")
virtual void MakeEDeltaEZGrid(Int_t Zmin, Int_t Zmax, Int_t npoints=20, Double_t gamma = 2);//*MENU*
void Initialize() override
void RemoveLine(Int_t Z, Int_t A=-1)
Remove and destroy identifier.
virtual KVIDZALine * GetZALine(Int_t z, Int_t a, Int_t &) const
void Identify(Double_t x, Double_t y, KVIdentificationResult *) const override
Base class for identification ridge lines corresponding to different nuclear species.
void SetWidth(Double_t w)
Base class for graphical cuts used in particle identification.
virtual Int_t GetA() const
virtual Int_t GetZ() const
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
Extended TList class which owns its objects by default.
Double_t GetDoubleValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
Description of properties and kinematics of atomic nuclei.
Double_t GetLifeTime(Int_t z=-1, Int_t a=-1) const
Strings used to represent a set of ranges of values.
KVSeqCollection * GetSubListWithMethod(const Char_t *retvalue, const Char_t *method) const
TObject * FindObject(const char *name) const override
TObject * Last() const override
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
static TClass * GetClass(Bool_t load=kTRUE, Bool_t silent=kFALSE)
Bool_t InheritsFrom(const char *cl) const override
void Streamer(TBuffer &) override
const char * GetVarX() const
TClass * IsA() const override
const char * GetVarY() const
void Clear(Option_t *option="") override
void Add(TObject *obj) override
const char * GetName() const override
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Draw(Option_t *option="")
void Error(UserClass p, const char *location, const char *va_(fmt),...)
void Warning(UserClass p, const char *location, const char *va_(fmt),...)
double dist(AxisAngle const &r1, AxisAngle const &r2)
Double_t Min(Double_t a, Double_t b)
Double_t Sqrt(Double_t x)
Double_t Max(Double_t a, Double_t b)