void getlandaupeak(TH2* hist, int idsta=1, TString opt=""){ /* ROOT Macro for obtaining Landau peak values from 2d histogram (id vs Qav) input: 2d-hist option="nstop" -> wait is skipped output: landaupeak.txt -> peak values */ Int_t nbin=hist->GetXaxis()->GetNbins(); Int_t num=0; vector peak;//Landau peak value if (nbin>1000){ cout<<"Too much X-axis bins. Please check the input 2D-histogram."< num++; Int_t id = i+1; TH1 *h=MakeBanY(hist,id); Double_t p[3]; FitHist(h,p); peak.push_back(p[1]); // Draw h->Draw(); gPad->Update(); cout<<"ID="<::iterator it=peak.begin(); while(it!=peak.end()){ ofs1<<*it<GetMean(); double rms = h->GetRMS(); func->SetParameters( h->GetMaximum(), h->GetBinCenter(searchedbin[0]), h->GetRMS() ); // fitting range Double_t xmin,xmax; xmin = h->GetBinCenter(searchedbin[1]); xmax = h->GetBinCenter(searchedbin[0])+rms; h->Fit(func,"Q","",xmin,xmax); func->GetParameters(p); } //___________________________________________________________________________ void SearchBins(TH1* h, int searchedbin[]){ /* search bin at local maximum (Landau peak) and local minimum from high energy side */ const int range=20; // for taking average of contents int thre = h->GetMaximum()*0.5;// Threshold value Int_t nbin=h->GetXaxis()->GetNbins(); int isearch=0; int sum,sumold=0; for(int i=nbin;i>range;i--){ if (h->GetBinContent(i)Integral(i-range,i); if (isearch==0 && sumsumold){// Local minimum searchedbin[1]=i; break; } sumold=sum; } if (isearch==0){ searchedbin[0]=h->GetMaximumBin(); searchedbin[1]=0; } } //___________________________________________________________________________ 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"<