23 #include <Riostream.h>
50 #ifndef ROOT_KeySymbols
51 #include "KeySymbols.h"
62 #ifndef ROOT_TPolyLine
63 #include "TPolyLine.h"
82 #ifndef ROOT_TVirtualPad
83 #include "TVirtualPad.h"
95 fLog.GetProcessName() =
"GSPlayer";
128 Int_t xBinMin = histo->GetXaxis()->GetFirst();
129 Int_t xBinMax = histo->GetXaxis()->GetLast();
130 Double_t xMin = histo->GetXaxis()->GetBinCenter(xBinMin);
131 Double_t xMax = histo->GetXaxis()->GetBinCenter(xBinMax);
132 Double_t xMin0 = xMin;
133 Double_t xMax0 = xMax;
134 Double_t yMax = histo->GetMaximum()*1.05;
135 Double_t yMin = histo->GetMinimum()*0.95;
137 Double_t range = xMax - xMin;
139 Int_t nSpec = int(range/width + 0.5);
143 Int_t eventType = 0;;
147 if ( !opt.Contains(
"+") )
151 if ( opt.Contains(
"bg") )
159 if ( histo->GetDimension() == 1 ) {
162 gSystem->ProcessEvents();
163 eventType = TVirtualPad::Pad()->GetEvent();
164 }
while(eventType != kButton1Down);
167 for (Int_t k = 0; k < nSpec; ++k) {
169 histo->SetAxisRange(xMin, xMax);
172 xBinMin = histo->GetXaxis()->GetFirst();
173 xBinMax = histo->GetXaxis()->GetLast();
174 yMax = histo->GetMaximum();
175 yMin = histo->GetMinimum();
178 for (Int_t i = xBinMin; i < xBinMax; ++i) {
180 xBin = int(histo->GetXaxis()->GetBinCenter(i) + 0.5);
183 line.SetX1(xBin); line.SetY1(yMin);
184 line.SetX2(xBin); line.SetY2(yMax);
186 TVirtualPad::Pad()->Update();
189 gSystem->ProcessEvents();
191 if (TVirtualPad::Pad()->GetEvent() == kKeyPress) {
192 Int_t keysym = TVirtualPad::Pad()->GetEventY();
193 if ( (EKeySym)keysym == kKey_s) {
195 TVirtualPad::Pad()->Update();
201 gSystem->ProcessEvents();
202 eventType = TVirtualPad::Pad()->GetEvent();
203 kk = TVirtualPad::Pad()->GetEventY();
204 }
while((EKeySym)kk == kKey_s);
209 histo->SetAxisRange(xMin0, xMax0);
210 TVirtualPad::Pad()->Update();
213 if ( histo->GetDimension() == 2) {
231 TPolyLine* line = 0x0;
233 TList* list = TVirtualPad::Pad()->GetListOfPrimitives();
234 for (Int_t i = 0; i < list->GetEntries(); ++i) {
235 TObject* o = list->At(i);
236 const char* name = o->ClassName();
240 if ( tmp.CompareTo(
"TPolyLine") == 0 )
241 line = static_cast<TPolyLine*>(o);
244 if ( o->InheritsFrom(
"TH1")) {
245 bkg =
static_cast<TH1*
>(o);
246 tmp = bkg->GetName();
247 if (tmp.Contains(
"Bkg"))
260 Double_t* x = line->GetX();
261 Double_t* y = line->GetY();
262 Int_t n = line->Size();
264 bkg = (TH1*)histo->Clone();
265 Int_t xBinMin = bkg->FindBin(x[0]);
266 Int_t xBinMax = bkg->FindBin(x[n-1]);
269 TSpline3 spline(
"Bkg", x, y, n);
272 for (Int_t i = xBinMin; i < xBinMax; ++i) {
273 Double_t xBin = histo->GetXaxis()->GetBinCenter(i);
274 bkg->SetBinContent(i, spline.Eval(xBin));
LogMessage & error(LogMessage &)
virtual Int_t FindPeaks(TH1 *histo, Option_t *opt="")
Find peak in current histo graphically.
BaseSpectrumPlayer to work on spectra.
LogMessage fLog
log message
virtual Bool_t SetParameter(const char *name, Double_t value)
To change the parameters for that algorithm.
PeakCreator * fCreator
default PeakCreator
LogMessage & dolog(LogMessage &)
Most of the methods relies on graphical approach.
virtual TH1 * Background(const TH1 *histo, Option_t *)
Compute the background for that histogram.
virtual const TF1 * GetDefaultPeakWidth() const
Get formula that gives the with as a function of energy.
header file for a general 1D peak
virtual TSeqCollection * GetPeakList() const
Return the current collection of peaks.
virtual Int_t CollectPeaks(Option_t *opt="")
Collect the peaks from the current pad.
ClassImp(GSPlayer) GSPlayer
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.