26 {
"Limit range of fit",
false},
27 {
"PID min for fit", 0.},
28 {
"PID max for fit", 10.},
29 {
"Minimum probability [%]", 50.},
30 {
"Minimum #sigma", 1.e-2},
31 {
"Maximum #sigma", 5.e-2}
45 std::unique_ptr<KVPIDIntervalPainter> _p(p);
49 if (pright) pright->set_left_interval(pleft);
69 gROOT->ProcessLine(
Form(
"KVItvFinderDialog* _dummy_itv=(KVItvFinderDialog*)%p",
this));
74 fMain->
Connect(
"CloseWindow()",
"KVItvFinderDialog",
this,
"DoClose()");
88 delete fRootEmbeddedCanvas615->
GetCanvas();
90 fCanvas->
AddExec(
"toto",
"if(_dummy_itv)_dummy_itv->HandleKey();");
107 const char* xpms[] = {
117 "bld_colorselect.png",
123 const char* tips[] = {
124 "Save intervals in current grid",
126 "Create a new interval set",
127 "Create a new interval",
128 "Update interval lists",
129 "Remove selected intervals",
130 "Multigauss fit to isotopes in interval set",
131 "Set parameters for fit",
132 "Remove fit from selected interval set",
133 "Test identification",
134 "Set log scale on y axis",
135 "Unzoom the histogram",
153 const char* method[] = {
161 "SetFitParameters()",
179 bb->
Connect(
"Clicked()",
"KVItvFinderDialog",
this, method[i]);
207 const char* xpms[] = {
212 const char* tips[] = {
222 const char* method[] = {
238 bb->
Connect(
"Clicked()",
"KVItvFinderDialog",
this, method[i]);
275 int tmp[30] = {3, 3, 3, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6};
276 for (
int ii = 0; ii < 30; ii++)
fNpeaks[ii] = tmp[ii];
293 Int_t nSelected = list->GetSize();
294 if (nSelected == 1) {
318 if (!painter)
Info(
"SelectionITVChanged",
"%d %d not found...", zz, aa);
332 Int_t nSelected = list->GetSize();
333 if (nSelected == 1) {
365 tmp->Execute(
"SetDisplayLabel",
"1");
374 fitparams.
Set(massfit);
378 tmp->Execute(
"DeactivateIntervals",
"");
422 dummy->Connect(
"IntMod()",
"KVItvFinderDialog",
this,
"UpdatePIDList()");
441 std::vector<int> alist;
442 for (
int ii = 0; ii < itvs->
GetNPID(); ii++) {
446 alist.push_back(itv->
GetA());
488 auto available_cpu = WITH_MULTICORE_CPU;
491 std::vector<std::thread> jobs;
500 std::cout <<
"Will run " << available_cpu <<
" threads, each for " << xbins_per_cpu <<
" bins in X" << std::endl;
502 int nthreads = available_cpu;
504 std::cout <<
"Histo linearization using " << nthreads <<
" threads..." << std::endl;
506 for (
int job = 0; job < available_cpu; ++job) {
507 auto imin = 1 + job * xbins_per_cpu;
508 auto imax = (job + 1) * xbins_per_cpu;
513 grid_copy->Initialize();
514 grid_copies.
Add(grid_copy);
517 jobs.push_back(std::thread([ =, &nthreads]() {
521 bool no_mass_id_zone_defined = (grid_copy->GetInfos()->FindObject(
"MassID") ==
nullptr);
523 for (
int i = imin; i <= imax; ++i) {
526 if (poids == 0)
continue;
533 if (x0 < 4)
continue;
537 Double_t weight = (kmax == 20 ? poids / 20. : 1.);
538 for (
int k = 0; k < kmax; k++) {
541 if (grid_copy->IsIdentifiable(
x,
y)) {
543 grid_copy->KVIDZAGrid::Identify(
x,
y, &idr);
544 if (no_mass_id_zone_defined || idr.
HasFlag(grid_copy->GetName(),
"MassID")) {
553 std::cout <<
"...remaining threads: " << nthreads << std::endl;
556 for (
auto& j : jobs) {
557 if (j.joinable()) j.join();
586 if (!list->GetSize()) {
591 for (
int ii = 0; ii < list->GetSize(); ii++) {
620 "KVIDGridEditor::SaveCurrentGrid",
Form(
"Do you wat to save the grid here : %s", fn.
Data()),
630 const char* filetypes[] = {
631 "ID Grid files",
"*.dat",
642 if (!filenam.
Contains(
'.')) filenam +=
".dat";
670 if (!itvs->
GetNPID())
continue;
678 if (!itvs->
GetNPID())
continue;
698 if (!list->GetSize() || list->GetSize() > 1) {
708 double pid =
mm->GetX();
720 aa = aa_guessstimate;
746 if ((aa_guessstimate > (aa - 1)) &&
748 aa = aa_guessstimate;
766 if (pidpnt->
GetInterval() == left_interval) left_painter = pidpnt;
767 else if (pidpnt->
GetInterval() == right_interval) right_painter = pidpnt;
778 right_painter->set_left_interval(dummy);
783 dummy->Connect(
"IntMod()",
"KVItvFinderDialog",
this,
"UpdatePIDList()");
803 if (!list->GetSize() || list->GetSize() > 1) {
819 aa = aa_guessstimate;
845 if ((aa_guessstimate > (aa - 1)) &&
847 aa = aa_guessstimate;
865 if (pidpnt->
GetInterval() == left_interval) left_painter = pidpnt;
866 else if (pidpnt->
GetInterval() == right_interval) right_painter = pidpnt;
877 right_painter->set_left_interval(dummy);
882 dummy->Connect(
"IntMod()",
"KVItvFinderDialog",
this,
"UpdatePIDList()");
913 void KVItvFinderDialog::remove_interval_from_interval_set(
interval_set* itvs,
interval* itv,
bool remove_fit)
931 Int_t nSelected = list->GetSize();
934 if (nSelected == 1) {
937 nSelected = list->GetSize();
938 if (nSelected >= 1) {
939 for (
int ii = 0; ii < nSelected; ii++) {
949 else if (nSelected > 1) {
950 for (
int ii = 0; ii < nSelected; ii++) {
964 Int_t nSelected = list->GetSize();
967 if (nSelected == 1) {
971 nSelected = list->GetSize();
973 if (nSelected == 1) {
984 TIter next_itv(list.get());
986 while ((itv = (
interval*)next_itv())) {
1006 Int_t nSelected = list->GetSize();
1009 if (nSelected == 1) {
1012 nSelected = list->GetSize();
1014 if (nSelected == 1) {
1025 TIter next_itv(list.get());
1027 while ((itv = (
interval*)next_itv())) {
1048 Int_t nSelected = list->GetSize();
1050 if (nSelected == 1) {
1135 std::vector<double> pidlist;
1138 while ((intvl = (
interval*)nxt_int())) {
1140 pidlist.push_back(intvl->
GetPID());
1175 tmp->Execute(
"DeactivateIntervals",
"");
1178 int most_prob_A = 0;
1182 double delta_pid = 0.001;
1183 TList accepted_intervals;
1184 for (
double pid = fitfunc.
GetPIDmin() ; pid <= fitfunc.
GetPIDmax(); pid += delta_pid) {
1187 if (proba > min_proba) {
1189 if (Amax > most_prob_A) {
1195 while (intvl->
GetA() < most_prob_A) {
1198 accepted_intervals.
Add(intvl);
1206 while (intvl->
GetA() < most_prob_A) {
1209 accepted_intervals.
Add(intvl);
1215 else if (most_prob_A) {
1238 while ((intvl = (
interval*)nxt_int())) {
1240 while (vec_alist[ig - 1] < intvl->
GetA()) {
1244 remaining_gaussians.
Add(ig);
1245 remaining_alist.
Add(intvl->
GetA());
1277 for (ig = 1; ig <= alist.
GetNValues(); ++ig) {
1293 bool cancel =
false;
1295 dialog->EnableDependingOnBool(
"PID min for fit",
"Limit range of fit");
1296 dialog->EnableDependingOnBool(
"PID max for fit",
"Limit range of fit");
1297 dialog->DisplayDialog();
1311 std::vector<int> alist;
1314 while ((intvl = (
interval*)nxt_int())) {
1315 alist.push_back(intvl->
GetA());
1371 #if ROOT_VERSION_CODE > ROOT_VERSION(5,99,01)
1384 int zrefs[] = {1, 4, 7, 9, 11, 12, 15, 16, 19, 21, 23, 25, 27, 29, 31, 34, 35, 38, 40, 42, 44, 47, 49, 51, 53};
1385 int zref = zrefs[zz - 1];
1388 for (
int p = 0; p < nfound; p++) {
1389 if (abs(xpeaks[idx[p]] - xpeaks[0]) < .0001) idref = p;
1391 Info(
"FindPIDIntervals",
"Z=%d : idref = %d ", zz, idref);
1393 for (
int p = 0; p < nfound; p++) {
1395 double pid = xpeaks[idx[p]];
1396 itvs->
add(zref + (p - idref), pid, pid - 0.05, pid + 0.05);
1410 for (
Int_t p = 0; p < np; p++) {
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
char * StrDup(const char *str)
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
static void SetAutoAdd(Bool_t yes=kTRUE)
static Bool_t GetAutoAdd()
const KVNameValueList * GetParameters() const
const Char_t * GetName() const
void WriteAsciiFile(const Char_t *filename)
Open, write and close ascii file containing this grid.
const KVList * GetIdentifiers() const
Hybrid charge & mass identification grid.
interval_set * GetIntervalSet(int zint) const
void SetOnlyZId(Bool_t=kTRUE)
KVList * GetIntervalSets()
Base class for graphical cuts used in particle identification.
virtual Double_t GetPID() const
Full result of one attempted particle identification.
void Clear(Option_t *opt="")
Reset to initial values.
Double_t PID
= "real" Z if Zident==kTRUE and Aident==kFALSE, "real" A if Zident==Aident==kTRUE
Bool_t HasFlag(std::string grid_name, TString flag)
GUI for finding/fixing mass identification intervals.
KVListView * fIntervalListView
void DrawInterval(interval_set *itvs, bool label=0)
void ClearInterval(interval_set *itvs)
void ProcessIdentification(Int_t zmin=-1, Int_t zmax=-1)
void AddInterval(double pid)
void delete_painter_from_painter_list(KVPIDIntervalPainter *)
void Identify()
KVBase::OpenContextMenu("Identify(double,double)",this);.
void SetFitParameters()
Open dialog to modify parameters for multigauss mass fit.
interval_set * current_interval_set
void FindPIDIntervals(Int_t zz)
KVItvFinderDialog(KVIDZAFromZGrid *gg, TH2 *hh)
KVListView * fIntervalSetListView
static KVNameValueList mass_fit_parameters
for user control of multi-gaussian fit
void RemoveFit()
Remove fit of currently selected interval set from pad.
void ExportToGrid()
Write all PID intervals in grid parameters "PIDRANGE", "PIDRANGE%d", etc.
void SelectionITVChanged()
void TestIdent()
fGrid->SetOnlyZId(0);
void LinearizeHisto(int nbins)
Double_t fpeaks(Double_t *x, Double_t *par)
KVPIDIntervalPainter * last_drawn_interval
void ZoomOnCanvas()
Display the interval set for a given Z when the user double clicks on it.
Enhanced version of ROOT TGListView widget.
virtual void SetDataColumns(Int_t ncolumns)
void SetDoubleClickAction(const char *receiver_class, void *receiver, const char *slot)
virtual void Display(const TCollection *l)
TObject * GetLastSelectedObject() const
TList * GetSelectedObjects() const
void AllowContextMenu(Bool_t on=kTRUE)
virtual void SetDataColumn(Int_t index, const Char_t *name, const Char_t *method="", Int_t mode=kTextCenterX)
Extended TList class which owns its objects by default.
Function for fitting PID mass spectra.
static TString get_name_of_isotope_gaussian(int z, int a)
double GetPIDvsAfit_a1() const
static TString get_name_of_multifit(int z)
double GetGaussianWidth(int) const
double GetCentroid(int i) const
void SetSigmaLimits(double smin, double smax)
void SetFitRange(double min, double max)
Change range of fit.
double GetPIDvsAfit_a2() const
int GetMostProbableA(double PID, double &P) const
double GetBackgroundSlope() const
double GetPIDvsAfit_a0() const
double GetGaussianNorm(int i) const
double GetBackgroundConstant() const
static void UnDrawAnyGaussian(int z, TVirtualPad *pad=gPad)
void UnDraw(TVirtualPad *pad=gPad) const
Remove the graphical representation of this fit from the given pad.
static void UnDrawGaussian(int z, int a, TVirtualPad *pad=gPad)
void DrawFitWithGaussians(Option_t *opt="") const
Draw the overall fit plus the individual gaussians for each isotope.
GUI for setting KVNameValueList parameters.
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Double_t GetDoubleValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
void RemoveParameter(const Char_t *name)
Bool_t HasStringParameter(const Char_t *name) const
Bool_t GetBoolValue(const Char_t *name) const
const Char_t * GetStringValue(const Char_t *name) const
bool Set(const KVString &)
Bool_t HasParameter(const Char_t *name) const
TString GetTStringValue(const Char_t *name) const
Strings used to represent a set of ranges of values.
const Char_t * AsQuotedString() const
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 Set(const TString &l)
IntArray GetArray() const
Graphical representation of a PID interval in the KVIDZAFromZGrid mass assignation GUI.
void SetCanvas(TCanvas *cc)
KVPIDIntervalPainter * get_right_interval() const
void Draw(Option_t *option="")
void DeactivateIntervals()
interval * GetInterval() const
void SetDisplayLabel(bool dis=true)
void HighLight(bool hi=true)
KVPIDIntervalPainter * get_left_interval() const
void set_right_interval(KVPIDIntervalPainter *i)
KVSeqCollection * GetSubListWithMethod(const Char_t *retvalue, const Char_t *method) const
virtual TObject * Last() const
virtual void Clear(Option_t *option="")
virtual Int_t GetSize() const
virtual TObject * At(Int_t idx) const
virtual TObject * First() const
virtual void Execute(const char *method, const char *params, Int_t *error=0)
virtual void Add(TObject *obj)
virtual void AddAt(TObject *obj, Int_t idx)
virtual TObject * Remove(TObject *obj)
Remove object from list.
virtual TObject * FindObject(const char *name) const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
GUI for testing identification grids.
virtual void SetFillColor(Color_t fcolor)
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetBottomMargin(Float_t bottommargin)
virtual void SetLeftMargin(Float_t leftmargin)
virtual void SetRightMargin(Float_t rightmargin)
virtual void SetTopMargin(Float_t topmargin)
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Int_t GetEventX() const override
TVirtualPad * cd(Int_t subpadnumber=0) override
Int_t GetEvent() const override
virtual Int_t GetEntries() const
static const TArrayI & GetPalette()
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
virtual void SetCleanup(Int_t mode=kLocalCleanup)
virtual TGDimension GetDefaultSize() const
virtual void MapSubwindows()
virtual void Resize(TGDimension size)
void SetWindowName(const char *name=0)
virtual void CenterOnParent(Bool_t croot=kTRUE, EPlacement pos=kCenter)
virtual void RequestFocus()
virtual Int_t GetNbinsY() const
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
virtual Int_t GetNbinsX() const
virtual Int_t Fill(const char *name, Double_t w)
virtual void Draw(Option_t *option="")
virtual void SetAxisRange(Double_t xmin, Double_t xmax, Option_t *axis="X")
virtual Double_t GetBinContent(Int_t bin) const
virtual void Add(TObject *obj)
virtual TObject * Last() const
virtual const char * GetName() const
void AddExec(const char *name, const char *command) override
Double_t AbsPixeltoX(Int_t px) override
void Modified(Bool_t flag=1) override
void SetLogy(Int_t value=1) override
Int_t GetLogy() const override
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
virtual Double_t Uniform(Double_t x1, Double_t x2)
void AdoptCanvas(TCanvas *c)
TCanvas * GetCanvas() const
Int_t GetCanvasWindowId() const
virtual Int_t Search(const TH1 *hist, Double_t sigma=2, Option_t *option="", Double_t threshold=0.05)
Double_t * GetPositionX() const
const char * Data() 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)
void SetOptTitle(Int_t tit=1)
void SetOptStat(Int_t stat=1)
virtual char * ExpandPathName(const char *path)
virtual TList * GetListOfPrimitives() const=0
virtual void Modified(Bool_t flag=1)=0
virtual TObject * GetPrimitive(const char *name) const=0
virtual TObject * WaitPrimitive(const char *pname="", const char *emode="")=0
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
void add(int aa, double pid, double pidmin=-1., double pidmax=-1.)
void SetPIDmin(double pidmin)
void SetPIDmax(double pidmax)
Double_t Min(Double_t a, Double_t b)
Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE)
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)