void plotchpeak(const int iEntry = 1, int chip = 0,const int runnb = 1, const char *path = "") { char name[100]; Char_t iChan; // Channel number Char_t iChip; // Channel number UShort_t iClLength; //number of samples UInt_t iEventnb; Int_t iMax = 0; Int_t sMax = 0; Int_t iSamples[1024]; // Samples // TH1F* hSignal; TCanvas *c1 = new TCanvas("c1","Single cluster",600,600); sprintf(name, "%s/root/readout-%i_0.root", path,runnb); TFile *inFile = new TFile(name); TTree *tree = (TTree*) inFile->Get("tree"); if(!tree) { cerr << "Tree SALTRO events was not found: " << name << "\n"; return; } tree->Show(iEntry); tree->SetBranchAddress("iEventnb",&iEventnb); tree->SetBranchAddress("iSamples",&iSamples); tree->SetBranchAddress("iChan",&iChan); tree->SetBranchAddress("iChip",&iChip); tree->SetBranchAddress("iClLength",&iClLength); tree->GetEntry(iEntry); sprintf(name, "hSignal_%d", iChan); TH1F* hSignal = ((TH1F *)(gROOT->FindObject(name))); if (hSignal) delete hSignal; hSignal = new TH1F(name, "", iClLength, -0.5, iClLength - 0.5); // hSignal = new TH1F(name, "", 500, -0.5, 499.5); gStyle->SetOptStat(0); for(Int_t l = 0; l < iClLength; l++) { if (iSamples[l] > iMax) { sMax = l; iMax = iSamples[l]; } } Int_t lMin = sMax - 40; Int_t lMax = sMax + 10; cout << sMax << " " << iMax << " " << lMin << "-" << lMax << "\n"; if ((lMin > 0) && (lMax < iClLength)) { for(Int_t l = lMin; l < lMax; l++) { hSignal->SetBinContent(lMax-l, iSamples[l]); } } // hSignal->SetMinimum(0); // hSignal->SetMaximum(50); hSignal->SetAxisRange(0,50, "X"); hSignal->SetAxisRange(0, 800, "Y"); sprintf(name, "Run %d Event %d Chip %d Channel_%d_%d",runnb,iEventnb,chip,iChip,iChan); hSignal->SetTitle(name); hSignal->GetXaxis()->SetTitle("Sample #"); hSignal->GetYaxis()->SetTitle("ADC value"); hSignal->Draw(); sprintf(name,"ch%d-%d-%d-%d.pdf",iChan,chip,iEventnb,runnb); c1->SaveAs(name); }