TCanvas *c; double par[6]; double *epar; float mpvInc; // this is ugly char A='A'; char B='B'; char C='C'; char D='D'; char E='E'; char P='P'; char Q='Q'; char R='R'; FILE *fd=fopen("out1.dat","w"); fd=stdout; TH1F *hs=0; getTGains( ) { gStyle->SetStatW(0.22); gStyle->SetStatH(0.22); fprintf(fd,"# UxV MIP results \n# name MPV MPVerr SIG SIGerr sum5-40\n"); f=new TFile("PQR.hist.root"); char core[100],name[100]; c=new TCanvas("aa","aa",500,500); const float feta[]= {1.95,1.855,1.765,1.675,1.59,1.51,1.435,1.365,1.3,1.235,1.17,1.115}; //int sec=5; for(int sec=5;sec<=8;sec++) for(char sub='A';sub<='E';sub++) for(int eta=1;eta<=12;eta++){ //if(eta!=4 || sec!=5 || sub!='A') continue; sprintf(core,"0%dT%c%02d",sec,sub,eta); //if(!strstr(core,"05TC04")) continue; TString coreT=core; h=(TH1F*)f->Get("d"+coreT); h->SetAxisRange(-10.,100.); int bcent=h->GetMaximumBin(); ax= h->GetXaxis(); float xcent=ax->GetBinCenter(bcent); //float max=hmax+20; //float min=hmax-20; //printf("%d %f %f\n",bcent,xcent,1); //continue; //cout<Draw(); char *func="gaus"; h->Fit(func,"QRW","",xcent-15,xcent+15); //h->Fit(func,"QW"); TF1* gaus1=h->GetFunction(func); gaus1->SetLineColor(2); float mean=gaus1->GetParameter(1); float error=gaus1->GetParError(1); int ieta = eta-1; float gain=mean*2.89*TMath::TanH(feta[ieta]); float gerr=error*2.89*TMath::TanH(feta[ieta]); printf("%s %f %f\n",core,mean,error); //printf("%s %f %f\n",core,gain,gerr); //break; //c->Print(nameT+".ps"); //c->Print(coreT+".gif"); } }