void getped(TH2* hist, int idsta=1, TString opt=""){ /* ROOT Macro for obtaining pedestal values from 2d histogram (id vs Qraw) input: 2d-hist option="nstop" -> wait is skipped output: ped_peak.txt -> peak values ped_sigma.txt -> Gaussian width */ Int_t nbin=hist->GetXaxis()->GetNbins(); Int_t num=0; vector peak; vector sigma; if (nbin>1000){ cout<<"Too much channels, STOP."< num++; Int_t id = i+1; TH1 *h=MakeBanY(hist,id); Double_t p[3]; FitHist(h,p); peak.push_back(p[1]); sigma.push_back(p[2]); // Draw h->Draw(); gPad->Update(); cout<<"ID="<::iterator it=peak.begin(); while(it!=peak.end()){ ofs1<<*it<::iterator it=sigma.begin(); while(it!=sigma.end()){ ofs2<<*it<GetMean(); double rms = h->GetRMS(); func->SetParameters( h->GetMaximum(), h->GetMean(), h->GetRMS() ); xmin = mean-3*rms; xmax = mean+3*rms; h->Fit(func,"Q","",xmin,xmax); func->GetParameters(p); while(diff>0.01){ xmin = p[1]-3*p[2]; xmax = p[1]+3*p[2]; h->Fit(func,"Q","",xmin,xmax); func->GetParameters(p); p_new=p[1]; if (abs(p_new)<0.000001){ diff=100; }else{ diff=std::abs((p_new-p_old)/p_new); } p_old=p_new; }// end of while return; } //___________________________________________________________________________ TH1* MakeBanY(TH2* hist, Int_t id){ TString str=hist->GetName(); ostringstream oss; oss<ProjectionY(str.Data(),id,id); } //___________________________________________________________________________ bool Wait(){ //check and quit if q is typed printf("[enter]:continue, [q]:quit >"); char s[1]; gets(s); if(s[0]=='q') { cout<<"Break fit loop"<