1 #include "KVIDZAFromZGridBatchMassCorrector.h"
2 #include "KVIDZAFromZGrid.h"
3 #include "KVIDZAFromZGridMassCorrector.h"
4 #include "KVGaussFitMassModifier.h"
5 #include "KVMultiGaussIsotopeFit.h"
14 const TString& bad_grids_id_map_file
16 : reference_id_maps{bad_grids_id_map_file}
26 reference_grids.
SetName(ref_grids_file);
28 "Read %d reference grids from file %s",
34 "Could not read file %s",
35 ref_grids_file.
Data());
40 grids_to_correct.
SetName(bad_grids_file);
42 "Read %d grids to correct from file %s",
48 "Could not read file %s",
49 bad_grids_file.
Data());
59 : reference_id_maps{ref_id_map_file}
68 reference_grids.
SetName(ref_grids_file);
70 "Read %d reference grids from file %s",
76 "Could not read file %s",
77 ref_grids_file.
Data());
85 std::function<
KVString (
const KVString&)> deduce_ref_grid_name_from_bad_grid_name,
92 auto ref_grid_name = deduce_ref_grid_name_from_bad_grid_name(bad_grid->
GetName());
99 "No reference grid %s in file %s to compare with grid %s",
100 ref_grid_name.Data(), reference_grids.
GetName(), bad_grid->
GetName());
119 if(apply_corrections)
122 auto h2d =
dynamic_cast<TH2*
>(reference_id_maps.
Get(deduce_bad_histo_name(bad_grid->
GetName())));
126 "No reference idmap with name %s found for bad grid %s",
127 deduce_bad_histo_name(bad_grid->
GetName()).Data(),bad_grid->
GetName());
148 "No grid %s defined in file %s",
156 "No reference grid %s in file %s to compare with grid %s",
168 std::function<
KVString (
const KVString&)> deduce_ref_grid_name_from_bad_grid_name,
176 "No grid %s defined in file %s",
180 CorrectGrid(bad_grid,deduce_ref_grid_name_from_bad_grid_name,mass_fit_parameters,min_yield_cutoff,deduce_bad_histo_name);
190 double min_yield_cutoff,
199 CorrectGrid(bad_grid,deduce_ref_grid_name_from_bad_grid_name,mass_fit_parameters,min_yield_cutoff,deduce_bad_histo_name);
226 RefitReferenceGridToData(
gr->
GetName(),mass_fit_params);
234 void KVIDZAFromZGridBatchMassCorrector::RefitReferenceGridToData(
const TString& ref_grid_name,
const KVNameValueList& mass_fit_params)
239 if(!
gr->GetFits() ||
gr->GetFits()->IsEmpty())
244 auto pid_dist =
gr->LinearizeHistoToPID(hdata,100);
255 KVError::Info(
this,
"RefitReferenceGridToData",
"...Z=%d", z);
257 gfmm.Modify(0, pid_dist, mass_fit_params);
282 auto fit = grid->GetMultiGaussFit(Z);
285 KVError::Error(
this,
"DrawReferenceFit",
"No fit for Z=%d in grid %s", Z, grid_name.
Data());
288 fit->DrawFitWithGaussians();
303 auto fit = grid->GetMultiGaussFit(Z);
306 KVError::Error(
this,
"DrawOtherFit",
"No fit for Z=%d in grid %s", Z, grid_name.
Data());
309 fit->DrawFitWithGaussians();
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 filename
Change isotope masses in a multi-gauss fit by fixed offset.
static void SetAutoAdd(Bool_t yes=kTRUE)
const Char_t * GetName() const override
KVIDGraph * GetGrid(const Char_t *name) const
Return pointer to grid with name "name".
Int_t WriteAsciiFile(const Char_t *filename, const TCollection *selection=0)
void AddLastReadGrids()
Add all grids read the last time ReadAsciiFile() was called to the grid manager.
Bool_t ReadAsciiFile(const Char_t *filename)
const KVSeqCollection * GetGrids() const
Modify/refit all multi-gauss fits in all grids in a file.
void CorrectGrids(std::function< KVString(const KVString &)> deduce_ref_grid_name_from_bad_grid_name, const KVNameValueList &mass_fit_parameters, double min_yield_cutoff=0.8, std::function< KVString(const KVString &)> deduce_bad_histo_name=[](const KVString &n){ return n;})
loop over all grids to correct
void CorrectGrid(const TString &bad_grid_name, std::function< KVString(const KVString &)> deduce_ref_grid_name_from_bad_grid_name, const KVNameValueList &mass_fit_parameters, double min_yield_cutoff=0.8, std::function< KVString(const KVString &)> deduce_bad_histo_name=[](const KVString &n){ return n;})
void RefitAllReferenceGridsToData(const KVNameValueList &mass_fit_params)
void SaveCorrectedGrids(const TString &filename)
void DrawReferenceFit(const TString &grid_name, Int_t Z) const
void DrawOtherFit(const TString &grid_name, Int_t Z) const
KVIDZAFromZGridBatchMassCorrector(const TString &ref_grids_file, const TString &bad_grids_file, const TString &bad_grids_id_map_file)
void SaveReferenceGrids(const TString &filename)
void CorrectGridToReference(KVIDZAFromZGrid *bad_grid, KVIDZAFromZGrid *ref_grid, const KVNameValueList &mass_fit_parameters, double min_yield_cutoff=0.8, std::function< KVString(const KVString &)> deduce_bad_histo_name=[](const KVString &n){ return n;})
determine & apply corrections for grid
Modify masses used in multi-gauss fits of an id-grid to be conform to those of a 'reference' grid.
void ApplyCorrections(const std::vector< KVIDZAFromZGridMassCorrector::mass_correction_t > &, TH1 *pid_dist, const KVNameValueList &mass_fit_parameters)
std::vector< mass_correction_t > DetermineMassCorrections(double min_yield)
Hybrid charge & mass identification grid.
TH1 * LinearizeHistoToPID(const TH2 *hdata, int nbins=100) const override
Function for fitting PID mass spectra.
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Strings used to represent a set of ranges of values.
void Add(Int_t)
Add value 'n' to the list.
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
virtual Int_t GetEntries() const
T * Get(const char *namecycle)
const char * GetName() const override
virtual void SetName(const char *name)
void ls(Option_t *option="") const override
const char * Data() const
void Error(UserClass p, const char *location, const char *va_(fmt),...)
void Warning(UserClass p, const char *location, const char *va_(fmt),...)
void Info(UserClass p, const char *location, const char *va_(fmt),...)
fit(model, train_loader, val_loader, num_epochs, batch_size, optimizer, criterion, save_best, scheduler)