Graphical Cut

From: Boris Skorodumov <bskorodo_at_nd.edu>
Date: Tue, 01 Feb 2005 21:55:20 -0500


Dear Rooters,

Since my last update to root 4.03.01, code below not working anymore.(this code was working in root 4.08) I cannot draw lines on the gPad to get closed region. It seems to me problem with _cut = (TCutG*) gPad -> WaitPrimitive("CUTG");

//-----------------------------------------------------------------------
_
void cut()
{

  gROOT->Reset();  

  TCanvas *c1 = new TCanvas("c1","",20,20,600,600);  

  TFile *f = gROOT->FindObject("204.root"); if(f) f->Close();   f = new TFile("204.root","READ");  

  TCut cut1 = "(epsd+depsd) < 2700 && (epsd+depsd) > 1400";   TCut cut2 = "trf > 330 && trf <900";
  t->Draw("(epsd+depsd):trf",cut2 && cut1);  

  TCutG *cut = new TCutG();
  cout << "You can do a cut now ...." << endl;   cut = (TCutG*) gPad -> WaitPrimitive("CUTG");   cut -> SetName("cut");
  cout << "Cut is in memory" << endl;  

  t->Draw("epsd+depsd",cut);

}

Thank you,
Boris.
P.S i did not attach 204.root file because of its size.


| Boris Skorodumov, Graduate Student |
| Physics Department                 |
| University of Notre Dame           |
| Indiana 46556, USA                 |
| WWW:   http://www.nd.edu/~bskorodo |
--------------------------------------




Rene BRUN wrote:

> Hi Boris,
>
> The current version of TSpectrum::Search looks for peaks in the full
> histogram range. In your case teh first bin of your histogram is
> around 650000 while the other visible peaks are around 100.
> With your version of ROOT simply call h1->SetBinContent(1,0)
> and Search will find the 6 peaks.
>
> In the CVS version, I have added support for a bin range such that you
> do not need the SetBinContent(1,0).
>
> Rene Brun
>
> Boris Skorodumov wrote:
>
>> Dear rooters,
>>
>> I was trying to change example program peaks.C to force it working
>> with real spectrum (for example, detector calbration, Gaus fitter
>> should work with it). I was trying to use the next procedure to find
>> peaks:
>> .....
>> TSpectrum *s = new TSpectrum(npeaks);
>> Int_t nfound = s->Search(h2,1,"");
>> printf("Found %d candidate peaks to fit\n",nfound);
>> .....
>> but i always getting 0. to tell you the truth, i do not know what the
>> problem, maybe with resolutions of the peaks, maybe with sigma
>> settings, maybe something more.
>>
>> I attached source file and test.root with test histogram.
>> Thank you for the help,
>> Boris.
>>
>>
>> ------------------------------------------------------------------------
>>
>> #include "TCanvas.h"
>> #include "TH1.h"
>> #include "TF1.h"
>> #include "TRandom.h"
>> #include "TSpectrum.h"
>> #include "TVirtualFitter.h"
>> Int_t npeaks = 30;
>>
>> Double_t fpeaks(Double_t *x, Double_t *par) {
>> // Double_t result = par[0] + par[1]*x[0];
>> Double_t result =0.0;
>> for (Int_t p=0;p<npeaks;p++) {
>> Double_t norm = par[3*p];
>> Double_t mean = par[3*p+1];
>> Double_t sigma = par[3*p+2];
>> result += norm*TMath::Gaus(x[0],mean,sigma);
>> }
>> return result;
>> }
>>
>>
>> void d1_fit(Int_t np=10) {
>>
>> npeaks = np;
>> Double_t par[3000];
>> TFile *hfile = gROOT->FindObject("test.root"); if (hfile)
>> hfile->Close();
>> hfile = new TFile("test.root","READ","Test Calibration");
>> TCanvas *c1 = new TCanvas("c1","c1",10,10,700,700);
>> c1->Divide(1,2);
>> c1->cd(1);
>> h1->GetXaxis()->SetRange(50,500);
>> h1->Draw(); // TH1F *h = new TH1F("h","test",1000,0,2000);
>> TH1F *h2 = (TH1F*)h1->Clone("h2");
>>
>> // cout << npeaks; TSpectrum *s = new TSpectrum(npeaks);
>> // s->SetResolution(0.1);
>> Int_t nfound = s->Search(h2,1,"");
>> printf("Found %d candidate peaks to fit\n",nfound);
>> npeaks = nfound;
>> c1->Update();
>> c1->cd(2);
>> printf("Now fitting: Be patient\n");
>> TF1 *fit = new TF1("fit",fpeaks,0,2000,3*npeaks);
>> TVirtualFitter::Fitter(h2,10+3*npeaks); fit->SetParameters(par);
>> fit->SetNpx(2000);
>> h2->Fit("fit"); }
>> // t->Draw()
>> // TH1F *h1 = new TH1F("h1","h1 title",2000,0,2000);("epsd >> h1");
>> // h1->GetXaxis()->SetRange(50,500) ; h1->Draw();
>
>
Received on Wed Feb 02 2005 - 03:55:32 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:04 MET