void plotallwidthx(int chip = 0,const char *title = "", int runnb = 0) { char name[100]; Char_t iChan; // Channel number Char_t iChip; // Channel number UShort_t iClLength; //number of samples UInt_t iEventnb; Int_t iSamples[1024]; // Samples Int_t iMax = 0; Int_t lMax = 0; Int_t iMax2; Int_t iWidth; TH1F* hSignal[16]; TCanvas *c1 = new TCanvas("c1","Single cluster",600,600); sprintf(name, "readout-%i_0.root", runnb); TFile *inFile = new TFile(name); TTree *ch = (TTree*) inFile->Get("tree"); if(!ch) { cerr << "Tree SALTRO events was not found: " << name << "\n"; return; } printf("Run: %s",name); // Assign variables to branches ch->SetBranchAddress("iEventnb",&iEventnb); ch->SetBranchAddress("iSamples",&iSamples); ch->SetBranchAddress("iChan",&iChan); ch->SetBranchAddress("iChip",&iChip); ch->SetBranchAddress("iClLength",&iClLength); c1->Divide(4,4); Int_t nentries = ch->GetEntries(); printf("ENTRIES %d\n",nentries); for (Int_t j = 0; j < 16; j++) { sprintf(name, "hSignal_%d", j); hSignal[j] = ((TH1F *)(gROOT->FindObject(name))); if (hSignal[j]) delete hSignal[j]; hSignal[j] = new TH1F(name, "",1024,-0.5,1023.5); hSignal[j]->SetMinimum(0); // hSignal[j]->SetMaximum(1024); } gStyle->SetOptStat(1100); for (Int_t j = 0; j < nentries; j++) { ch->GetEntry(j); iMax = 0; lMax = 0; for(Int_t l = 30; l < iClLength - 30; l++) { if(iSamples[l] > iMax) { iMax = iSamples[l]; lMax = l; } } if (iMax > 200) { // printf("EVT: %d IMAX= %d LMAX=%d\n",iEventnb,iMax,lMax); iMax2 = iMax / 3.0; // iMax2 = iMax - 200; // iMax2 = iMax - (iMax - 80) / 2.0; iWidth = 0; for(Int_t l = 30; l < iClLength - 30; l++) { if(iSamples[l] > iMax2) iWidth++; } hSignal[iChan]->Fill(iWidth); } } for (Int_t j = 0; j < 16; j++) { c1->cd(j+1); sprintf(name, "Width ch %d chip %d %s", j,chip,title); hSignal[j]->SetTitle(name); hSignal[j]->GetYaxis()->SetTitle("Entries"); hSignal[j]->GetXaxis()->SetTitle("ADC value"); hSignal[j]->SetAxisRange(0, 10, "X"); hSignal[j]->Draw(); printf("%d\t%5.2f\t%5.3f\t%5.1f\n",j,hSignal[j]->GetMean(),hSignal[j]->GetRMS(),hSignal[j]->GetEntries()); } sprintf(name,"ch-all-chip%d-width-%d-%s.pdf",iChip,runnb,title); c1->SaveAs(name); }