ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
Hello
I am trying to find all the peaks from the histogram, which should return at least 3 peaks. However the code i wrote only returns 2. Here is the code:
void analysis(int run)
{
TH1F *QzHst = new TH1F("PedHst","",4096,0,4096);
TH1F *LYSOHst = new TH1F("PedHst","",4096,0,4096);
TFile *f = new TFile(Form("run_%d.root",run),"READ");
TTree *t=(TTree*)f->Get("dataTree");
Int_t nentries=(Int_t)t->GetEntries();
cout<<nentries<<endl;
Int_t Event;
Int_t QuartzChn;
Int_t TrRightChn;
Int_t TrLeftChn;
Int_t LYSOChn;
Float_t t1;
Int_t t2;
Int_t OR;
unsigned short_t i;
t->Show(10);
t->SetBranchAddress("Event",&Event);
t->SetBranchAddress("QuartzChn",&QuartzChn);
t->SetBranchAddress("TrRightChn",&TrRightChn);
t->SetBranchAddress("TrLeftChn",&TrLeftChn);
t->SetBranchAddress("LYSOChn",&LYSOChn);
t->SetBranchAddress("t1",&t1);
t->SetBranchAddress("t2",&t2);
t->SetBranchAddress("OR",&OR);
for (i=0;i<nentries;i++){
t->GetEntry(i);
QzHst->Fill(QuartzChn);
LYSOHst->Fill(LYSOChn);
}
TCanvas *c1 = new TCanvas();
QzHst->SetLineColor(2);//red
QzHst->Draw();
c1->SetLogy();
c1->SaveAs("testgraph1.jpg");
TCanvas *c2 = new TCanvas();
LYSOHst->SetLineColor(4);//blue
// LYSOHst->Fit("gaus","","M",0,500);
// LYSOHst->Draw("SAME");
LYSOHst->Draw();
c2->SetLogy();
c2->SaveAs("testgraph2.jpg");
//Search for peaks
TSpectrum *s=new TSpectrum();
Int_t nfound=s->Search(LYSOHst);
cout<<nfound<<endl;
TH1 *hb= s->Background(LYSOHst);
if(hb) c2->Update();
c2->SaveAs("testgraph22.jpg");
}
what could i do to detect more peaks?
Thank you for reading.