6 #include "KeySymbols.h"
7 #include "TContextMenu.h"
10 #include "BashColor.h"
11 #include "TParameter.h"
15 #include "TGraphErrors.h"
30 GSPlayerTUI::GSPlayerTUI(Bool_t verbose) :
31 TTask(
"GSPlayerTUI",
"GSPlayerTUI"),
34 fNumberIterations(20),
35 fDirection(TSpectrum::kBackDecreasingWindow),
36 fStrDirection(
"BackDecreasingWindow"),
37 fFilterOrder(TSpectrum::kBackOrder8),
38 fStrFilterOrder(
"BackOrder8"),
40 fSmoothingWindow(TSpectrum::kBackSmoothing5),
41 fStrSmoothingWindow(
"BackSmoothing5"),
48 fActiveBGAdjustment(false),
54 fFWHMFormula(
"AGATA_FWHM"),
68 fNumberIterations(20),
69 fDirection(TSpectrum::kBackDecreasingWindow),
70 fStrDirection(
"BackDecreasingWindow"),
71 fFilterOrder(TSpectrum::kBackOrder8),
72 fStrFilterOrder(
"BackOrder8"),
74 fSmoothingWindow(TSpectrum::kBackSmoothing5),
75 fStrSmoothingWindow(
"BackSmoothing5"),
82 fActiveBGAdjustment(false),
88 fFWHMFormula(
"AGATA_FWHM"),
103 if(fBashColor)
delete fBashColor;
118 if(NumberIterations==-1)
132 fDirection = TSpectrum::kBackIncreasingWindow;
135 else if(Direction == 1)
137 fDirection = TSpectrum::kBackDecreasingWindow;
143 cout<<
"Direction not valid, possible values :"<<
endl;
144 cout<<
" 0 ==> BackIncreasingWindow"<<
endl;
145 cout<<
" 1 ==> BackDecreasingWindow"<<
endl;
146 cout<<
" Default value is taken : BackDecreasingWindow"<<
endl;
147 fDirection = TSpectrum::kBackDecreasingWindow;
151 if(FilterOrder == 0)
fFilterOrder = TSpectrum::kBackOrder2;
152 else if(FilterOrder == 1)
fFilterOrder = TSpectrum::kBackOrder4;
153 else if(FilterOrder == 2)
fFilterOrder = TSpectrum::kBackOrder6;
154 else if(FilterOrder == 3)
fFilterOrder = TSpectrum::kBackOrder8;
158 cout<<
"Filter order not valid, possible values :"<<
endl;
159 cout<<
" 0 ==> BackOrder2"<<
endl;
160 cout<<
" 1 ==> BackOrder4"<<
endl;
161 cout<<
" 2 ==> BackOrder6"<<
endl;
162 cout<<
" 3 ==> BackOrder8"<<
endl;
163 cout<<
" Default value is taken : BackOrder8"<<
endl;
175 if(smoothingWindow<3 || smoothingWindow>15 || !(smoothingWindow & 1))
178 cout<<
"Smoothing window not valid, possible values : 3, 5, 7, 9, 11, 13, 15"<<
endl;
179 cout<<
" Default value is taken : BackSmoothing5"<<
endl;
181 smoothingWindow = TSpectrum::kBackSmoothing5;
203 cout<<
"*********** background parameters ***********"<<
endl;
209 cout<<
"***********************************************"<<endl<<
endl;
221 cout<<
"No background histogram built"<<
endl;
247 if(c == 0x0) c = TVirtualPad::Pad()->GetCanvas();
251 c->Connect(
"ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
254 "HandleMovement(Int_t, Int_t, Int_t, TObject*)");
263 if(ok && c) fIsConnected =
true;
278 if(c == 0x0) c = TVirtualPad::Pad()->GetCanvas();
281 c->Disconnect(
"ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
283 "HandleMovement(Int_t, Int_t, Int_t, TObject*)");
288 if(ok && c) fIsConnected =
false;
305 if(select->InheritsFrom(
"TH1"))
fCurrentHist = (TH1*)select;
307 if (eventType == kMouseMotion) {
313 bool CTRL = ( eventX == eventY-96);
314 EKeySym Key = (EKeySym)eventY;
320 if(eventType == kKeyPress)
322 if(Key == kKey_e && !CTRL && LastKey == kKey_b && !LastCTRL)
324 if(Key == kKey_s && !CTRL && LastKey == kKey_b && !LastCTRL)
330 if(eventType == kKeyPress && !fActiveBGAdjustment)
332 if(Key == kKey_b && !CTRL && LastKey == kKey_i && !LastCTRL)
339 if(eventType == kKeyPress && fActiveBGAdjustment)
342 if(Key == kKey_i && !CTRL && LastKey == kKey_s && !LastCTRL)
344 fActiveIt =
true; fActiveFilt =
false; fActivSmooth =
false;
348 if(Key == kKey_f && !CTRL && LastKey == kKey_s && !LastCTRL)
350 fActiveIt =
false; fActiveFilt =
true; fActivSmooth =
false;
354 if(Key == kKey_s && !CTRL && LastKey == kKey_s && !LastCTRL)
356 fActiveIt =
false; fActiveFilt =
false; fActivSmooth =
true;
360 if(Key == kKey_c && !CTRL && LastKey == kKey_s && !LastCTRL)
367 if(Key == kKey_d && !CTRL && LastKey == kKey_s && !LastCTRL)
375 if( (eventType == kWheelUp || eventType == kWheelDown ) && fActiveBGAdjustment && (fActiveIt || fActiveFilt || fActivSmooth))
377 cout<<eventType<<
endl;
378 Int_t
value = TMath::Nint((5.5-(
int)eventType)*2);
412 if(eventY == 0 && eventX == 0 && fActiveBGAdjustment )
419 if(eventType == kKeyPress)
421 if(Key == kKey_s && !CTRL && LastKey == kKey_a && !LastCTRL)
423 TMethod* m = Class()->GetMethodAny(
"AddSourceFromNDB");
428 if(Key == kKey_l && !CTRL && LastKey == kKey_s && !LastCTRL)
430 TMethod* m = Class()->GetMethodAny(
"SavePeakList");
435 if(Key == kKey_l && !CTRL && LastKey == kKey_l && !LastCTRL)
437 TMethod* m = Class()->GetMethodAny(
"LoadPeakList");
443 if(Key == kKey_e && !CTRL && LastKey == kKey_p && !LastCTRL)
448 if(Key == kKey_r && !CTRL && LastKey == kKey_s && !LastCTRL)
450 TMethod* m = Class()->GetMethodAny(
"SetRefpeak");
459 if(eventType == kKeyPress && Key == kKey_h && !CTRL && LastKey == kKey_p && !LastCTRL)
463 cout<<
"[GSPlayerTUI] List of keybord commands:"<<
endl;
464 cout<<
" ** Print this help : p + h"<<
endl;
466 cout<<
" ** Histogram selection **"<<
endl;
467 cout<<
" ==> Click on a histogram make it the active histogram (the default one is the first histogram in the list of primitives of the active pad)"<<
endl;
469 cout<<
" ** Histogram operations **"<<
endl;
470 cout<<
" ==> b + e : background evaluation"<<
endl;
471 cout<<
" ==> b + s : background subtraction"<<
endl;
473 cout<<
" ** background operation **"<<
endl;
474 cout<<
" ==> i + b : Starting interactive background adjustment utility"<<
endl;
475 if(fActiveBGAdjustment)
477 cout<<
" If the background adjustment utility is on:"<<
endl;
478 cout<<
" ==> s + i : active the iterator variations by mouse wheel"<<
endl;
479 cout<<
" ==> s + f : active the filter order variations by mouse wheel"<<
endl;
480 cout<<
" ==> s + s : active the Smoothing windowd variations by mouse wheel"<<
endl;
481 cout<<
" ==> s + c : active/unactive compton"<<
endl;
482 cout<<
" ==> s + d : change direction (BackDecreasingWindow/BackIncreasingWindow)"<<
endl;
483 cout<<
" Press Escape key to exit the utility"<<
endl;
486 cout<<
" ** Peaks operations **"<<
endl;
487 cout<<
" ==> h + m : Hide markers"<<
endl;
488 cout<<
" ==> s + m : Show markers"<<
endl;
489 cout<<
" ==> a + s : Adding a gamma source from the nuclear database"<<
endl;
490 cout<<
" ==> f + a : Open fit all panel menu"<<
endl;
491 cout<<
" ==> a + p : Add a peak at mouse position"<<
endl;
492 cout<<
" ==> A + P : Add a peak + background at mouse position"<<
endl;
493 cout<<
" ==> CTRL ( A + P ) : Add a point to the graphical polyline"<<
endl;
494 cout<<
" ==> s + l : Save the peaks of the current pad the database"<<
endl;
495 cout<<
" ==> l + l : Load a peak list from the data base"<<
endl;
496 cout<<
" ==> c + a : Clear all (peaks + graphical polyline)"<<
endl;
497 cout<<
" ==> o + m : Open PeakCreator menu"<<
endl;
499 cout<<
" ==> c + 0 : Switch Color to default #0"<<
endl;
500 cout<<
" ==> c + 1 : Switch Color to default #0"<<
endl;
501 cout<<
" ==> c + 2 : Switch Color to default #0"<<
endl;
502 cout<<
" ==> c + 3 : Switch Color to default #0"<<
endl;
505 cout<<
" ** efficiency **"<<
endl;
506 cout<<
" ==> p + e : Plot efficiencies"<<
endl;
528 TIter next(PeakList);
531 if(peak->InheritsFrom(
"Peak1D"))
549 fActiveBGAdjustment =
true;
551 cout<<
"[GSPlayerTUI] Starting background utility"<<
endl;
552 cout<<
"[GSPlayerTUI] Canvas connexions with other classes are closed for interferences reasons"<<
endl;
553 cout<<
" ==> s + i : active the iterator variations by mouse wheel"<<
endl;
554 cout<<
" ==> s + f : active the filter order variations by mouse wheel"<<
endl;
555 cout<<
" ==> s + s : active the Smoothing windowd variations by mouse wheel"<<
endl;
556 cout<<
" ==> s + c : active/unactive compton"<<
endl;
557 cout<<
" ==> s + d : change direction (BackDecreasingWindow/BackIncreasingWindow)"<<
endl;
558 cout<<
" Press Escape key to exit the utility"<<
endl;
565 fActiveBGAdjustment =
false;
566 fActiveIt =
false; fActiveFilt =
false; fActivSmooth =
false;
568 cout<<
"[GSPlayerTUI] Ending interactive background adjustment utility !"<<
endl;
569 cout<<
"[GSPlayerTUI] Canvas connexions with other classes have been restored"<<
endl;
585 TString Option =
"same";
587 if(
fDirection == TSpectrum::kBackDecreasingWindow) Option +=
"BackDecreasingWindow";
588 else if(
fDirection == TSpectrum::kBackIncreasingWindow) Option +=
"BackIncreasingWindow";
590 if(
fFilterOrder == TSpectrum::kBackOrder2) Option +=
"BackOrder2";
591 else if(
fFilterOrder == TSpectrum::kBackOrder4) Option +=
"BackOrder4";
592 else if(
fFilterOrder == TSpectrum::kBackOrder6) Option +=
"BackOrder6";
593 else if(
fFilterOrder == TSpectrum::kBackOrder8) Option +=
"BackOrder8";
598 if(
fSmoothingWindow == TSpectrum::kBackSmoothing3) Option +=
"BackSmoothing3";
599 else if(
fSmoothingWindow == TSpectrum::kBackSmoothing5) Option +=
"BackSmoothing5";
600 else if(
fSmoothingWindow == TSpectrum::kBackSmoothing7) Option +=
"BackSmoothing7";
601 else if(
fSmoothingWindow == TSpectrum::kBackSmoothing9) Option +=
"BackSmoothing9";
602 else if(
fSmoothingWindow == TSpectrum::kBackSmoothing11) Option +=
"BackSmoothing11";
603 else if(
fSmoothingWindow == TSpectrum::kBackSmoothing13) Option +=
"BackSmoothing13";
604 else if(
fSmoothingWindow == TSpectrum::kBackSmoothing15) Option +=
"BackSmoothing15";
605 else Option +=
"nosmoothing";
611 TH1 *OldBG = (TH1*) gPad->GetListOfPrimitives()->FindObject((TString)
fCurrentHist->GetName() +
"_BG");
612 if(OldBG)
delete OldBG;
639 TCanvas *c = ((TCanvas*)((TList*)gROOT->GetListOfClasses())->Last());
640 if(c != 0x0) gPad = c->cd(0);
641 if(gPad == 0x0)
return;
644 TString Opt = option;
648 if(GammaList.size()==0)
653 if(!gPad->GetListOfPrimitives()->FindObject(
fCurrentHist->GetName()))
657 TList *listofPeaks =
new TList;
661 for(
unsigned int i=0 ; i<GammaList.size() ; i++)
677 Peak->SetNameTitle(GammaName,GammaName);
680 listofPeaks->Add(Peak);
683 PreviousGamma = Gamma;
686 const char* tab =
"\t";
690 cout<<
"************** Gamma source "<<SourceName<<
" loaded for EGamma > "<<EMin<<
" and I > "<<IMin<<
endl;
693 cout<<
"DecayMode"<<tab<<
700 for(
int i=0 ; i<listofPeaks->GetEntries() ; i++)
708 listofPeaks->Remove(Peak);
709 gPad->GetListOfPrimitives()->Remove(Peak);
728 cout<<
"******************************************************"<<endl<<
endl;
741 TString Name = ListName;
750 vector <double> Energies;
754 TIter next(PeakList);
766 TString Name = ListName;
770 for(
unsigned int i=0 ; i<Energies.size() ; i++)
772 double E = Energies[i];
773 TString GammaName = Form(
"%s_%.0lf",Name.Data(),E);
777 if(!gPad->GetListOfPrimitives()->FindObject(
fCurrentHist->GetName()))
781 Peak->SetNameTitle(GammaName,GammaName);
784 if(Energies.size() == 0)
787 cout<<
"Empty gamma list !"<<
endl;
805 TGraphErrors *gr =
new TGraphErrors;
806 gr->SetName(
"EfficiencyPlot");
807 gr->SetMarkerStyle(20);
808 gr->SetMarkerColor(kRed);
811 TIter next(PeakList);
814 if(peak->InheritsFrom(
"Peak1D"))
830 cout<<
"Energy = "<<Energy<<
"("<<EnergyError<<
")"<<
endl;
831 cout<<
"BranchingRatio = "<<BranchingRatio<<
"("<<BranchingRatioError<<
")"<<
endl;
832 cout<<
"Area = "<<Area<<
"("<<AreaError<<
")"<<
endl;
834 gr->SetPoint(gr->GetN(),Energy,Area/(BranchingRatio/100.));
835 gr->SetPointError(gr->GetN()-1,EnergyError,AreaError/(BranchingRatio/100.));
840 new TCanvas(
"EfficiencyPlot",
"EfficiencyPlot");
void SetDefaultPeakFWHM(const char *fname="PCG_FWHM")
virtual Data_T GetError() const
return the error on the measured value
virtual Double_t GetPosition(Option_t *axis="X") const =0
Get position of peak.
header file for PeakCreator.cpp
void PrintBGParameters()
******************************************************************************************/// ...
GSPlayerTUI(Bool_t verbose=true)
*/
RootSpectrumPlayer class to handle root spectra using the interface of BasePeak.
virtual void SortPeakList(const Char_t *parName="Position", Bool_t sortDes=false)
sort peak list
virtual void Set(Data_T data)
set the measure and its error (default err=0)
LogMessage & error(LogMessage &)
void SetFWHMFormula(TString name)
******************************************************************************************/// ...
header file for PadManager.cpp
void InteractiveBGMode(bool ison)
******************************************************************************************/// ...
TH1 * RemoveBackground()
******************************************************************************************/// ...
void SetRefArea(Float_t a, Float_t ea)
GammaSourceRay * GetGammaSourceRay()
TString fStrSmoothingWindow
void SetRefArea(Float_t a, Float_t ea)
Measure< Double_t > * LifeTime
virtual void SetNbIter(int nbiter)
Bool_t Disconnect(TCanvas *c=0x0)
Connect the Canvas to this to collect events.
void SetRefpeak(Float_t area, Float_t error)
Double_t GetPeakIntegral() const
Get integral of peak after calling area method.
virtual void SetHelpsPrintActive(bool on)
virtual void SetHelpsPrintActive(bool on)
virtual PeakCreator * GetPeakCreator()
TContextMenu * fContextMenu
context menu in canvas
void LoadPeakList(const char *ListName, const char *opt="bg;ath")
******************************************************************************************/// ...
void Collect(Bool_t do_collect=true)
if true, peak are collected on key board actions (type h for help)
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject *select)
******************************************************************************************/// ...
bool ConnectCanvas(TCanvas *c=0x0)
******************************************************************************************/// ...
RootSpectrumPlayer * fRootSP
std::vector< Gw::GammaSourceRay * > GetGammaSource(TString SourceName, double EMin=100., double IMin=1., TString Opt="")
Measure< Double_t > * Energy
header file for a general 1D peak
TH1 * EvalBackground(bool verbose=true)
******************************************************************************************/// ...
ADF::LogMessage & endl(ADF::LogMessage &log)
virtual TSeqCollection * GetPeakList() const
Return the current collection of peaks.
virtual Int_t CollectPeaks(Option_t *opt="")
Collect the peaks from the current pad.
A BasePeak is defined by a height, intensity and a dimension of the peak.
Double_t GetPeakIntegralError() const
Measure< Double_t > * Intensity
virtual TH1 * Background(const TH1 *histo, Option_t *opt="")
Compute the background for that histogram.
std::vector< double > LoadGammaList(TString ListName)
virtual void Exec(const char *)
******************************************************************************************/// ...
A graphical interface for placing schematic peak onto a 1D histogram with a given position...
void SavePeakList(const char *ListName="AX")
******************************************************************************************/// ...
TObject * fLastSelectedObj
bool DisconnectCanvas(TCanvas *c=0x0)
******************************************************************************************/// ...
static TH1 * GetHisto(TVirtualPad *pad=0x0, Option_t *op="")
look for an histogram into the pad
void SaveGammaList(TString ListName, std::vector< double > Energies)
virtual ~GSPlayerTUI()
******************************************************************************************/// ...
void SetGammaSourceRay(GammaSourceRay *gsr)
RootSpectrumPlayer * GetPlayer()
Bool_t Connect(TCanvas *c=0x0)
Connect the Canvas to this to collect events.
virtual void SetError(Data_T derr)
set the error of this value
virtual BasePeak * CreatePeak(const TH1 *h, Double_t x, Option_t *opt="")
It creates a peak at position x for the 1D spectra.
void AddSourceFromNDB(const char *SourceName, double EMin=100., double IMin=1., const char *option="")
******************************************************************************************/// ...
Data_T GetValue() const
get the value, cannot be overloaded