GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PeakCreator.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2006 by Olivier Stezowski & Christian Finck *
3  * stezow(AT)ipnl.in2p3.fr, cfinck(AT)ires.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #include <Riostream.h>
24 
25 
26 #ifndef ROOT_KeySymbols
27 #include "KeySymbols.h"
28 #endif
29 
30 #ifndef ROOT_TCanvas
31 #include "TCanvas.h"
32 #endif
33 
34 #ifndef ROOT_TH1
35 #include "TH1.h"
36 #endif
37 
38 #ifndef ROOT_TList
39 #include "TList.h"
40 #endif
41 
42 #ifndef ROOT_TMath
43 #include "TMath.h"
44 #endif
45 
46 #ifndef ROOT_TROOT
47 #include "TROOT.h"
48 #endif
49 
50 #include "TContextMenu.h"
51 #include "TFrame.h"
52 
53 #ifndef Gw_PadManager
54 #include "PadManager.h"
55 #endif
56 
57 #ifndef Gw_PeakCreator
58 #include "PeakCreator.h"
59 #endif
60 
61 #include "TGraph.h"
62 
63 using namespace Gw;
64 
65 TList PeakCreator::gPeakCreatorList; TF1 *PeakCreator::gDefaultFWHM = 0x0;
66 
67 //__________________________________________________________
69  : TObject(),
70  fEfficiencyGraph(0x0),
71  fEfficiencyFunc(0x0),
72  fRefArea(1),
73  fRefAreaError(0),
74  fDefaultPeak1D(0x0),
75  fIsCollecting(false),
76  fIsGate(false),
77  fDefaultPeakFWHM(0x0),
78  fCanvas(0x0),
79  fLastX(0),
80  fLastY(0),
81  fLastMouseX(0),
82  fLastMouseY(0),
83  fIsHelpsPrintActive(true),
84  fLog("PeakCreator")
85 {
86  // default constructor
87  fDefaultPeak1D = new Peak1D();
88  // to be sure it exists
90  SetDefaultPeakFWHM("PCG_FWHM"); // PeakCreator Global _ FWHM
91 }
92 
93 //__________________________________________________________
94 PeakCreator::PeakCreator(TCanvas *c) : TObject(),
95  fEfficiencyGraph(0x0),
96  fEfficiencyFunc(0x0),
97  fRefArea(1),
98  fRefAreaError(0),
99  fDefaultPeak1D(0x0),
100  fIsCollecting(true),
101  fIsGate(false),
102  fDefaultPeakFWHM(0x0),
103  fCanvas(c),
104  fLastX(0),
105  fLastY(0),
106  fLastMouseX(0),
107  fLastMouseY(0),
108  fIsHelpsPrintActive(true),
109  fLog("PeakCreator")
110 {
111  // default constructor
112  fDefaultPeak1D = new Peak1D();
114  SetDefaultPeakFWHM("PCG_FWHM"); // PeakCreator Global _ FWHM
115 
116  // recursive delete
117  SetBit(TObject::kMustCleanup);
118 
119  Connect();
120 
121  gPeakCreatorList.Add(this);
122  // gPeakCreatorList.ls();
123 }
124 
125 //__________________________________________________________
127 {
128  if ( fLog.IsDebug(5) )
129  fLog << info << "Destroy PeakCreator " << nline;
130 
131  Disconnect();
132 
133  // default destructor
134  if (fDefaultPeak1D)
135  { delete fDefaultPeak1D; fDefaultPeak1D = 0x0; }
136  if (fDefaultPeakFWHM)
137  { delete fDefaultPeakFWHM; fDefaultPeakFWHM = 0x0; }
138 
139  if ( fLog.IsDebug(5) )
140  fLog << dolog;
141 }
142 
143 //__________________________________________________________
144 
146 {
147  if(fCanvas == 0x0)
148  {
149  if ( TVirtualPad::Pad() )
150  fCanvas = TVirtualPad::Pad()->GetCanvas();
151  else {
152  fLog.SetProcessMethod("Connect()");
153  fLog << error << "gPad not existing" << dolog;
154  return;
155  }
156  }
157 
158  fCanvas->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
159  "Gw::PeakCreator",
160  this,
161  "HandleMovement(Int_t, Int_t, Int_t, TObject*)");
162 
163  fCanvas->Connect("Closed()",
164  "Gw::PeakCreator",
165  this,
166  "Delete()");
167 }
168 
169 //__________________________________________________________
170 
172 {
173  // in case this is connected to a canvas
174  if ( fCanvas ) {
175 
176  fCanvas->Disconnect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
177  this,
178  "HandleMovement(Int_t, Int_t, Int_t, TObject*)");
179 
180  fCanvas->Disconnect("Closed()",
181  this,
182  "Delete()");
183 
184  gPeakCreatorList.Remove(this);
185  }
186 }
187 
188 //__________________________________________________________
189 
190 TVirtualPad *PeakCreator::PadforAction(TVirtualPad *pad)
191 {
192  if ( pad )
193  return pad ;
194  return TVirtualPad::Pad();
195 }
196 
198 {
199  PeakCreator *pcreator = 0x0;
200 
201  // to get the pad on which the creator is added
202  TVirtualPad *locpad = PeakCreator::PadforAction(pad);
203  if ( locpad == 0x0 )
204  return pcreator;
205 
206  TIter next(&gPeakCreatorList);
207  while ( (pcreator = (PeakCreator *)next()) ) {
208  if ( pcreator->GetCanvas() == locpad->GetCanvas() )
209  return pcreator;
210  }
211 
212  // create a PeakCreator and add it to the current canvas
213  pcreator = new PeakCreator(locpad->GetCanvas());
214  return pcreator;
215 }
216 
218 {
219  PeakCreator *pcreator = 0x0;
220 
221  // to get the pad on which the creator is added
222  TVirtualPad *locpad = PeakCreator::PadforAction(pad);
223  if ( locpad == 0x0 )
224  return pcreator;
225 
226  TIter next(&gPeakCreatorList);
227  while ( (pcreator = (PeakCreator *)next()) ) {
228  if ( pcreator->GetCanvas() == locpad->GetCanvas() ) {
229  break;
230  }
231  }
232  return pcreator;
233 }
234 
235 void PeakCreator::Clear(Option_t * opt)
236 {
237  TString o = opt;
238  TObject *obj = 0x0;
239 
240  // collect peaks in the selected canvas
241  TList listofpeaks;
242  PadManager::Collect<BasePeak>(listofpeaks,fCanvas->GetSelectedPad());
243  TIter nextp(&listofpeaks);
244  while ( (obj = nextp()) ) {
245  fCanvas->GetListOfPrimitives()->Remove(obj);
246  }
247  listofpeaks.Clear();
248 
249  PadManager::Collect<TPolyLine>(listofpeaks,fCanvas->GetSelectedPad());
250  TIter nextpo(&listofpeaks);
251  while ( (obj = nextpo()) ) {
252  fCanvas->GetListOfPrimitives()->Remove(obj);
253  }
254  listofpeaks.Clear();
255  TList listoffunctions;
256 
257  PadManager::Collect<TF1>(listoffunctions,fCanvas->GetSelectedPad());
258  TIter nextf(&listoffunctions);
259  while ( (obj = nextf()) ) {
260  fCanvas->GetListOfPrimitives()->Remove(obj);
261  }
262  listoffunctions.Clear();
263 }
264 
265 //__________________________________________________________
266 void PeakCreator::Collect(Bool_t do_collect)
267 {
268  fIsCollecting = do_collect;
269 }
270 
271 //__________________________________________________________
272 void PeakCreator::SetGateMode(Bool_t ngate)
273 {
274  if ( ngate )
275  fDefaultPeak1D->SetDrawAs(Peak1D::kGate);
276  else
277  fDefaultPeak1D->SetDrawAs(Peak1D::kPeak);
278 }
279 
280 //__________________________________________________________
281 void PeakCreator::HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* /*select*/)
282 {
283  // handle cursor mouvement
284  TVirtualPad *pad = fCanvas->GetSelectedPad();
285  if ( pad == 0x0 )
286  return;
287  if ( !pad->IsEditable() ) {
288  return ;
289  }
290  if (eventType == kMouseMotion) {
291  // to keep track of the last mouse position
292  fLastMouseX = eventX;
293  fLastMouseY = eventY;
294  }
295  if( eventType == kButton1Up ) {
296  HandleRefresh(fCanvas);
297  }
298  if( eventType == kKeyPress) {
299 
300  bool CTRL = ( eventX == eventY-96);
301  EKeySym Key = (EKeySym)eventY;
302 
303  bool LastCTRL = ( fLastX == fLastY-96);
304  EKeySym LastKey = (EKeySym)fLastY;
305 
306  if(Key == kKey_0 && !CTRL && LastKey == kKey_c && !LastCTRL)
307  {
308  fLog << info << "Current color/style for new peak is now style 0" << nline;
309  fDefaultPeak1D->SetLineColorPeak(BasePeak::gGateColor.k0);
310  fDefaultPeak1D->SetFillColorPeak(BasePeak::gGateColor.k0);
311  }
312  if(Key == kKey_1 && !CTRL && LastKey == kKey_c && !LastCTRL)
313  {
314  fLog << info << "Current color/style for new peak is now style 1" << nline;
315  fDefaultPeak1D->SetLineColorPeak(BasePeak::gGateColor.k1);
316  fDefaultPeak1D->SetFillColorPeak(BasePeak::gGateColor.k1);
317  }
318  if(Key == kKey_2 && !CTRL && LastKey == kKey_c && !LastCTRL)
319  {
320  fLog << info << "Current color/style for new peak is now style 2" << nline;
321  fDefaultPeak1D->SetLineColorPeak(BasePeak::gGateColor.k2);
322  fDefaultPeak1D->SetFillColorPeak(BasePeak::gGateColor.k2);
323  }
324  if(Key == kKey_3 && !CTRL && LastKey == kKey_c && !LastCTRL)
325  {
326  fLog << info << "Current color/style for new peak is now style 3" << nline;
327  fDefaultPeak1D->SetLineColorPeak(BasePeak::gGateColor.k3);
328  fDefaultPeak1D->SetLineColorPeak(BasePeak::gGateColor.k3);
329  }
330  if(Key == kKey_p && !CTRL && LastKey == kKey_a && !LastCTRL)
331  {
332  if ( fIsCollecting ) {
333  BasePeak *peak = CreatePeak(pad->AbsPixeltoX(fLastMouseX),"",pad);
334  if ( peak && pad->GetFrame() )
335  peak->PaintFor(pad->GetFrame()->GetX1(),pad->GetFrame()->GetX2(),pad->GetFrame()->GetY1(),pad->GetFrame()->GetY2());
336  pad->Update();
337  }
338  }
339  if(Key == kKey_P && !CTRL && LastKey == kKey_A && !LastCTRL)
340  {
341  if ( fIsCollecting ) {
342  BasePeak *peak = CreatePeak(pad->AbsPixeltoX(fLastMouseX),"bg",pad);
343  if ( peak && pad->GetFrame() )
344  peak->PaintFor(pad->GetFrame()->GetX1(),pad->GetFrame()->GetX2(),pad->GetFrame()->GetY1(),pad->GetFrame()->GetY2());
345  pad->Update();
346  }
347  }
348  if(Key == kKey_p && CTRL && LastKey == kKey_a && LastCTRL)
349  {
350  if ( fIsCollecting ) {
351  AddPointToPolyline(pad->AbsPixeltoX(fLastMouseX), pad->AbsPixeltoY(fLastMouseY),pad);
352  pad->Update();
353  }
354  }
355  if(Key == kKey_a && !CTRL && LastKey == kKey_c && !LastCTRL)
356  {
357  Clear();
358  pad->Update();
359  }
360  if(Key == kKey_m && !CTRL && LastKey == kKey_o && !LastCTRL)
361  {
362  fCanvas->GetContextMenu()->Popup(fLastMouseX,fLastMouseY,this,fCanvas,pad);
363  }
364  if(Key == kKey_h && !CTRL && fIsHelpsPrintActive)
365  {
366  fLog << info;
367  fLog << "\ta: Add a peak at mouse position" << nline;
368  fLog << "\tA: Add a peak + background point at mouse position" << nline;
369  fLog << "\tp: Add a point to the graphical polyline" << nline;
370  fLog << "\t0: Switch Color to default #0" << nline;
371  fLog << "\t1: Switch Color to default #1" << nline;
372  fLog << "\t2: Switch Color to default #2" << nline;
373  fLog << "\t3: Switch Color to default #3" << nline;
374  fLog << "\tc: Clear all (peaks + graphical polyline)" << nline;
375 
376  fLog << "\t>: Popup PeakCreator menu" << nline;
377  fLog << "\tM: Popup PeakCreator menu" << nline;
378  }
379  }
380 
381  fLastX = eventX;
382  fLastY = eventY;
383 
384  fLog << dolog;
385 }
386 
387 void PeakCreator::HandleRefresh(TCanvas *canvas)
388 {
389  TCanvas *localCanvas = canvas;
390 
391  // in this case connect the current canvas
392  if ( localCanvas == 0x0 ) {
393  if ( TVirtualPad::Pad() )
394  localCanvas = TVirtualPad::Pad()->GetCanvas();
395  }
396  if(localCanvas == 0x0) return;
397  if(localCanvas->GetSelectedPad() == 0x0) return;
398 
399  TObject *obj; TFrame *frame; BasePeak *apeak;
400  double xmin, xmax, ymin, ymax;
401 
402  // if no Frame, go out
403  if ( (frame = localCanvas->GetSelectedPad()->GetFrame()) == 0x0 )
404  return;
405 
406  xmin = frame->GetX1();
407  xmax = frame->GetX2();
408  ymin = frame->GetY1();
409  ymax = frame->GetY2();
410 
411  if(localCanvas->GetLogy())
412  {
413  ymin = TMath::Exp(frame->GetY1()*TMath::Log(10));
414  ymax = TMath::Exp(frame->GetY2()*TMath::Log(10));
415  }
416  if(localCanvas->GetLogx())
417  {
418  xmin = TMath::Exp(frame->GetX1()*TMath::Log(10));
419  xmax = TMath::Exp(frame->GetX2()*TMath::Log(10));
420  }
421 
422  // collect peaks in the selected canvas
423  TList listofpeaks;
424  PadManager::Collect<BasePeak>(listofpeaks,localCanvas->GetSelectedPad());
425 
426  // printf(" %s TEST %d \n",fCanvas->GetSelectedPad()->GetFrame()->GetName(),listofpeaks.GetSize() );
427  TIter next(&listofpeaks);
428  while ( (obj = next()) ) {
429  apeak = dynamic_cast<BasePeak *> (obj);
430 
431  if ( apeak )
432  apeak->PaintFor(xmin,xmax,ymin,ymax);
433 
434  localCanvas->GetSelectedPad()->Modified();
435  }
436  // clear the list
437  listofpeaks.Clear("nodelete");
438 }
439 
441 {
442  if ( gROOT->GetListOfFunctions()->FindObject("PCG_FWHM") == 0x0 )
443  {
444  gDefaultFWHM = new TF1("PCG_FWHM","[0]");
445  gDefaultFWHM->SetParameter(0,6.0);
446  }
447 
448  if ( gROOT->GetListOfFunctions()->FindObject("AGATA_FWHM") == 0x0 )
449  {
450  //FWHM = 1.2 keV for Egamma = 60 keV
451  double E1 = 60.;
452  double FWHM1 = 1.2;
453  //FWHM = 2.1 keV for Egamma = 1333 keV
454  double E2 = 1333.;
455  double FWHM2 = 2.1;
456 
457  new TF1("AGATA_FWHM",Form("(%lf-%lf)/(%lf-%lf)*(x-%lf)+%lf",FWHM2,FWHM1,E2,E1,E2,FWHM2));
458  }
459 
460  return gDefaultFWHM;
461 }
462 
464 {
465  return GetGlobalPeakFWHM();
466 }
467 
468 void PeakCreator::SetDefaultPeakFWHM( const char *fname )
469 {
470  TObject *o = gROOT->GetListOfFunctions()->FindObject(fname); TF1 *f;
471  if ( o == 0x0 )
472  return;
473  else
474  f = dynamic_cast<TF1 *> (o);
475 
476  if ( fDefaultPeakFWHM )
477  delete fDefaultPeakFWHM;
478 
479  fDefaultPeakFWHM = (TF1 *)(f->Clone());
480  gROOT->GetListOfFunctions()->Remove(fDefaultPeakFWHM);
481 }
482 
483 //__________________________________________________________
484 BasePeak *PeakCreator::CreatePeak(Double_t x, Option_t *opt, TVirtualPad *pad)
485 {
486  // create peak from current position in pad
487  BasePeak* peak = 0x0; TH1* h;
488 
489  // to get the pad on which the creator is added
490  TVirtualPad *locpad = PeakCreator::PadforAction(pad);
491  if ( locpad == 0x0 )
492  return peak;
493 
494  h = PadManager::GetHisto(locpad);
495  if ( h ) {
496  // look in the current pad for the list of peak that already exist
497  std::vector<Gw::Peak1D *> peaks_in_pad;
498  // collect
499  PadManager::Collect<Gw::Peak1D>(peaks_in_pad,locpad);
500  // set the name of the peak used as a cloner of the new peak to be created
501  TString pname; Int_t i = 0;
502  while ( 1 ) {
503  pname = Form("Peak_%d",i++); Bool_t is_in = false;
504  for (size_t i = 0; i < peaks_in_pad.size(); i++) {
505  if ( pname == peaks_in_pad[i]->GetName() ) {
506  is_in = true;
507  break;
508  }
509  }
510  if ( is_in == false ) {
511  fDefaultPeak1D->SetName( pname.Data() );
512  break;
513  }
514  }
515 
516  // now creates the peak
517  peak = CreatePeak(h,x,opt);
518  if ( peak ) {
519  //
520  peak->SetBit(TObject::kCanDelete);
521  peak->SetBit(TObject::kMustCleanup);
522 
523  // add peak to pad
524  locpad->GetListOfPrimitives()->Add(peak,"lm");
525  locpad->Modified();
526  }
527  }
528  return peak;
529 }
530 
531 //__________________________________________________________
532 BasePeak* PeakCreator::CreatePeak(const TH1 *histo, Double_t x, Option_t *opt)
533 {
534  // to check options
535  TString o = opt;
536 
537  // the peak to be created
538  BasePeak* peak = 0x0;
539 
540  if (histo->GetDimension() == 0 || histo->GetDimension() > 1) {
541  fLog.SetProcessMethod("CreatePeak(TH1*, Double_t)");
542  fLog << error << "Dimension not handled" << histo->GetDimension() << dolog;
543  return peak;
544  }
545  switch ( histo->GetDimension() ) {
546  case 1:
547  { // 1D :
548  // scan the histogram 6 sigma around the given position
549  Double_t width =
550  fDefaultPeakFWHM->Eval(x);
551  // in case with is greater that the full range of the spectra, reduce width to 1/10 of the range
552  if ( histo->GetXaxis()->GetXmax() < histo->GetXaxis()->GetXmin() + width )
553  width = ( histo->GetXaxis()->GetXmax() - histo->GetXaxis()->GetXmin() ) / 10.;
554 
555  Int_t binmin = histo->GetXaxis()->FindFixBin(x-3*width);
556  Int_t binmax = histo->GetXaxis()->FindFixBin(x+3*width);
557 
558  // to avoid including under/over flow
559  binmin = TMath::Max(1,binmin);
560  binmax = TMath::Min(histo->GetNbinsX(),binmax);
561 
562  Double_t yminleft, yminright, ymin, ymax, ymax_abs; Int_t bin_ymax, bin_ymax_abs;
563 
564  bin_ymax = bin_ymax_abs = histo->GetXaxis()->FindFixBin(x); ymax = ymax_abs = histo->GetBinContent(histo->GetXaxis()->FindFixBin(x));
565 
566  yminleft = histo->GetBinContent(binmin);
567  yminright = histo->GetBinContent(binmax);
568 
569  // first compute some characteritic values
570  for (Int_t i = binmin ; i < binmax; i++) {
571 
572  if ( histo->GetBinCenter(i) < x-width && histo->GetBinContent(i) < yminleft ) {
573  yminleft = histo->GetBinContent(i);
574  }
575  if ( histo->GetBinCenter(i) > x+width && histo->GetBinContent(i) < yminright ) {
576  yminright = histo->GetBinContent(i);
577  }
578  // fine maximum
579  if ( histo->GetBinContent(i) > ymax && histo->GetBinCenter(i) > (x-0.4*width) && histo->GetBinCenter(i) < (x+0.4*width) )
580  { ymax = histo->GetBinContent(i); bin_ymax = i; }
581 
582  if ( histo->GetBinContent(i) > ymax_abs )
583  { ymax_abs = histo->GetBinContent(i); bin_ymax_abs = i; }
584  }
585 
586  // set maximum ... avoid having the max in a hole
587  if ( (ymax < yminleft || ymax < yminright) && !o.Contains("ath") )
588  ymax = ymax_abs ;
589 
590  // in case of empty histogram
591  if ( ymax == 0.0 )
592  ymax = 1.0;
593 
594  /* Double_t DeltaY = TMath::Max ( TMath::Abs(ymax-yminleft) , TMath::Abs(ymax-yminright) ) ;
595  for (Int_t i = binmin; i < binmax; i++) {
596 
597 
598  } */
599  // yminleft /= width; yminright /= width;
600  ymin = (yminleft+yminright)/2;
601 
602  // Set peak properties
603  Peak1D* rpeak =
604  dynamic_cast<Gw::Peak1D*>(fDefaultPeak1D->Clone());
605 
606  rpeak->SetBackground(x-5*width,
607  x-4*width,
608  x+4*width,
609  x+5*width, yminleft, yminleft, yminright, yminright );
610  /*
611  histo->GetBinContent(histo->GetXaxis()->FindFixBin(x-3*width)),
612  histo->GetBinContent(histo->GetXaxis()->FindFixBin(x-2*width)),
613  histo->GetBinContent(histo->GetXaxis()->FindFixBin(x+2*width)),
614  histo->GetBinContent(histo->GetXaxis()->FindFixBin(x+3*width)) ); */
615 
616  if ( o.Contains("atp") ) // does not change the position
617  rpeak->SetPeak(x, ymax-ymin, width);
618  else
619  rpeak->SetPeak(histo->GetBinCenter(bin_ymax), ymax-ymin, width);
620 
621  if ( o.Contains("bg") )
622  rpeak->WithBkg(true);
623  else
624  rpeak->WithBkg(false);
625 
626  if(fEfficiencyFunc != 0x0)
627  rpeak->SetEfficiencyFunc(fEfficiencyFunc,fEffRelError);
628  else if(fEfficiencyGraph != 0x0)
629  rpeak->SetEfficiencyGraph(fEfficiencyGraph,fEffRelError);
630 
631  rpeak->SetRefArea(fRefArea,fRefAreaError);
632 
633  peak = rpeak;
634  }
635  break;
636  default:
637  break;
638  }
639 
640  return peak;
641 }
642 
643 
644 //__________________________________________________________
645 void PeakCreator::AddPointToPolyline(Double_t x, Double_t y, TVirtualPad *pad)
646 {
647  // to get the pad on which the creator is added
648  TVirtualPad *locpad = PeakCreator::PadforAction(pad);
649  if ( locpad == 0x0 )
650  return ;
651 
652  TPolyLine* line = 0x0;
653  TList* list = locpad->GetListOfPrimitives();
654  for (Int_t i = 0; i < list->GetEntries(); ++i) {
655  TString tmp(list->At(i)->ClassName());
656  if ( tmp.CompareTo("TPolyLine") == 0 )
657  line = static_cast<TPolyLine*>(list->At(i));
658  }
659 
660  if (!line) {
661  line = new TPolyLine(0);
662 
663  line->SetBit(kCanDelete, true); line->SetBit(kMustCleanup, true);
664 
665  line->SetLineWidth(2);
666  line->SetLineColor(kRed-5);
667  line->SetFillColor(kRed-5);
668  line->SetFillStyle(3010);
669  line->SetNextPoint(x,y);
670 
671  locpad->GetListOfPrimitives()->Add(line,"f");
672 
673  }
674  else line->SetNextPoint(x,y);
675 
676  locpad->Modified();
677 }
678 
679 
680 //
682 
void SetDefaultPeakFWHM(const char *fname="PCG_FWHM")
header file for PeakCreator.cpp
virtual void SetLineColorPeak(Color_t color)
Definition: Peak1D.cpp:1651
void SetEfficiencyGraph(TGraph *gr, Float_t EffRelError=0.1)
Definition: Peak1D.h:406
void SetPeak(Double_t pos, Double_t height, Double_t fwhm, Double_t intensity=0)
Set peak members.
Definition: Peak1D.cpp:519
LogMessage & error(LogMessage &)
header file for PadManager.cpp
void WithBkg(Bool_t with_bg=true)
toggle background (fit and display)
Definition: Peak1D.cpp:513
void SetRefArea(Float_t a, Float_t ea)
Definition: Peak1D.h:408
void SetEfficiencyFunc(TF1 *f, Float_t EffRelError=0.1)
Definition: Peak1D.h:407
LogMessage & nline(LogMessage &)
TH1F * histo[MaxValue]
Definition: ReadDaqAlone.C:31
static PeakCreator * AddPeakCreator(TVirtualPad *pad=0x0)
add a peak creator to the given pad. Current pad if argument is 0x0
static void HandleRefresh(TCanvas *canvas=0x0)
Handle modification of the range of the pad.
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject *select)
Handle Movement.
static GateColor gGateColor
Definition: BasePeak.h:30
virtual void PaintFor(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax)=0
Set vis attribute to be painted in the following frame.
virtual void Connect()
virtual ~PeakCreator()
const TCanvas * GetCanvas() const
Definition: PeakCreator.h:171
static const TF1 * GetConstGlobalPeakFWHM()
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
static TVirtualPad * PadforAction(TVirtualPad *pad=0x0)
Get Pad.
LogMessage fLog
Definition: PeakCreator.h:109
void SetGateMode(Bool_t ngate=true)
if true, peak are collected on key board actions (type h for help)
void Collect(Bool_t do_collect=true)
if true, peak are collected on key board actions (type h for help)
LogMessage & dolog(LogMessage &)
bool IsDebug(short debug_to_test) const
to test if the required debug level is lower that the global one
Definition: GwLogMessage.h:184
ClassImp(BaseNucleus)
virtual void Clear(Option_t *="")
Clear: delete all peaks in canvas/pad depending on PadManager.
A BasePeak is defined by a height, intensity and a dimension of the peak.
Definition: BasePeak.h:19
static PeakCreator * IsPeakCreator(TVirtualPad *pad=0x0)
Check whether or not a PeakCreator is in this canvas.
virtual void Disconnect()
A graphical interface for placing schematic peak onto a 1D histogram with a given position...
Definition: Peak1D.h:79
static TF1 * GetGlobalPeakFWHM()
virtual void SetDrawAs(EDrawAs d)
Set drawing flag.
Definition: Peak1D.cpp:1718
virtual void SetProcessMethod(const char *)
To set the current method.
static TH1 * GetHisto(TVirtualPad *pad=0x0, Option_t *op="")
look for an histogram into the pad
Definition: PadManager.cpp:67
virtual void AddPointToPolyline(Double_t x, Double_t y, TVirtualPad *pad=0x0)
It adds a point to the polyline at position x,y in the current pad.
virtual void SetFillColorPeak(Color_t color)
Set line attribute for peak.
Definition: Peak1D.cpp:1671
virtual BasePeak * CreatePeak(const TH1 *h, Double_t x, Option_t *opt="")
It creates a peak at position x for the 1D spectra.
void SetBackground(Double_t bgLeft1, Double_t bgLeft2, Double_t bgRight1, Double_t bgRight2, Double_t bgLevelLeft1, Double_t bgLevelLeft2, Double_t bgLevelRight1, Double_t bgLevelRight2)
Set background limits.
Definition: Peak1D.cpp:591