23 #include <Riostream.h>
31 #ifndef Gw_RootSpectrumPlayer
51 #ifndef ROOT_TObjArray
52 #include "TObjArray.h"
63 #ifndef ROOT_TSpectrum
64 #include "TSpectrum.h"
76 fMaxPeak(TParameter<Int_t>(
"MaxPosition", 100)),
77 fSigma(TParameter<Double_t>(
"Sigma", 2.0)),
78 fThreshold(TParameter<Double_t>(
"Threshold", 0.05)),
79 fNbIter(TParameter<Int_t>(
"NbIter", 20)),
83 fEngine1D =
new TSpectrum(fMaxPeak.GetVal(),fSigma.GetVal());
93 {
delete fEngine1D; fEngine1D = 0x0; }
109 if (strncmp(name,
"threshold", strlen(name)) == 0)
112 fThreshold = TParameter<Double_t>(name,
value);
114 if (strncmp(name,
"sigma", strlen(name)) == 0)
117 fSigma = TParameter<Double_t>(name,
value);
118 if(fEngine1D)
delete fEngine1D;
119 fEngine1D =
new TSpectrum(fMaxPeak.GetVal(),fSigma.GetVal());
134 if (strncmp(name,
"nbiter", strlen(name)) == 0)
137 fNbIter = TParameter<Int_t>(name,
value);
139 if (strncmp(name,
"maxpeak", strlen(name)) == 0)
142 fMaxPeak = TParameter<Int_t>(name,
value);
143 if(fEngine1D)
delete fEngine1D;
144 fEngine1D =
new TSpectrum(fMaxPeak.GetVal(),fSigma.GetVal());
157 if(Name ==
"nbiter")
return fNbIter;
158 else if(Name ==
"maxpeak")
return fMaxPeak;
163 return TParameter<Int_t>();
170 if(Name ==
"threshold")
return fThreshold;
171 else if(Name ==
"sigma")
return fSigma;
176 return TParameter<Double_t>();
192 if ( !opt.Contains(
"+") )
196 if ( opt.Contains(
"bg") )
202 if ( histo->GetDimension() == 1 ) {
207 result = fEngine1D->Search(histo, fSigma.GetVal(), opt.Data(), fThreshold.GetVal());
208 fEngine1D->Background(histo, fNbIter.GetVal());
210 for(Int_t i = 0; i < fEngine1D->GetNPeaks(); ++i) {
211 posx = fEngine1D->GetPositionX()[i];
216 TVirtualPad::Pad()->Update();
219 if ( histo->GetDimension() == 2) {
221 fLog <<
error <<
"Dimension not handled " << histo->GetDimension() <<
dolog;
234 if ( histo->GetDimension() == 1 ) {
236 fEngine1D->Background(histo,fNbIter.GetVal(),opt);
238 TString bgname = histo->GetName();
242 result->SetName(bgname.Data());
244 if ( histo->GetDimension() == 2) {
246 fLog <<
error <<
"Dimension not handled " << histo->GetDimension() <<
dolog;
RootSpectrumPlayer class to handle root spectra using the interface of BasePeak.
LogMessage & error(LogMessage &)
virtual Bool_t SetParameter(const char *name, Double_t value)
To change the parameters for that algorithm.
BaseSpectrumPlayer to work on spectra.
LogMessage fLog
log message
virtual TParameter< Double_t > GetDoubleParameter(TString Name)
virtual Int_t FindPeaks(TH1 *histo, Option_t *opt="")
Find peaks.
PeakCreator * fCreator
default PeakCreator
LogMessage & dolog(LogMessage &)
virtual ~RootSpectrumPlayer()
virtual void Print(Option_t *opt="") const
print current peak list
virtual std::string & GetProcessName()
To get the Process name.
header file for a general 1D peak
virtual void Print(Option_t *opt="") const
Print out informations concerning the parameters of that player.
virtual TSeqCollection * GetPeakList() const
Return the current collection of peaks.
virtual TParameter< Int_t > GetIntParameter(TString Name)
To get the parameters.
virtual TH1 * Background(const TH1 *histo, Option_t *opt="")
Compute the background for that histogram.
virtual void SetProcessMethod(const char *)
To set the current method.
virtual Bool_t SetParameter(const char *, Double_t)
To change the parameters for that algorithm.
virtual BasePeak * CreatePeak(const TH1 *h, Double_t x, Option_t *opt="")
It creates a peak at position x for the 1D spectra.