void an(TString filename = "data.root"){ TFile* file = TFile::Open(filename); if(file){ cout <<"*************************************"<Get("ntuple"); if(!tree)cout<<" Cannot find the tree successfully!!"<GetEntriesFast(); cout << " Entries number is "<SetBranchAddress("ltra",<ra,&t_ltra); tree->SetBranchAddress("cfdft",&cfdft,&t_cfdft); tree->SetBranchAddress("data",&wave,&t_data); tree->SetBranchAddress("evte",&evte,&t_evte); tree->SetBranchAddress("pileup",&pileup,&t_pileup); //--------------------------------------------------------- Int_t npeaks = 30; Int_t TwoPeakNum = 0; Int_t sumNum,sumN; //--------------------------------------------------------- TGraph* gr = new TGraph(); TGraph* gr_copy = new TGraph(); TGraph* singleWave = new TGraph(); TH1F* waveHist = new TH1F("single wave","single wave",5000,0,5000); TH1F* base = new TH1F("baseline","baseline",100,1600,1700);//baseline //TCanvas* myc = new TCanvas("dynamic wave anayzed","",700,500); //------------------------------------------------------------------------- for(int entry = 0;entry < nEntries;entry++){ waveHist->Reset(); tree->GetEntry(entry); sumNum = sumN = 0; if(pileup==1)continue; if(evte<=4000)continue; if(entry % 100 ==0) cout <SetPoint(i,i,wave[i]); waveHist->SetBinContent(i+1,wave[i]); if(entry == 6)singleWave->SetPoint(i,i,wave[i]); } /* myc->cd(); gr->SetMarkerColor(kRed); gr->SetMarkerStyle(8); gr->SetMarkerSize(0.5); gr->Draw("AP"); gr->SetTitle(Form("%d",entry)); myc->Modified(); myc->Update(); gSystem->Sleep(1000); //1s gSystem->ProcessEvents(); */ TSpectrum *s = new TSpectrum(2*npeaks); Int_t nfound = s->Search(waveHist,2,"",0.01); //-------------------------------------// // find peaks // //-------------------------------------// TGraph* graph = new TGraph(); if(nfound == 2) { for(int i=0;iSetPoint(i,i,wave[i]); } TwoPeakNum++; } } TCanvas* canvas1 = new TCanvas("canvas","canvas",700,500); canvas1->cd(); singleWave->SetMarkerColor(kBlue); singleWave->SetMarkerStyle(8); singleWave->SetMarkerSize(0.5); singleWave->SetTitle("signle;time(ns);amplitude"); singleWave->GetXaxis()->CenterTitle(); singleWave->GetYaxis()->CenterTitle(); singleWave->Draw("AP"); }