NBD(TString datastr, TString Glauberstr,TString histonamev){ dataname.SetString(datastr.Data()); Glaubername.SetString(Glauberstr.Data()); histoname.SetString(histonamev.Data()); mubest.ResizeTo(1); kbest.ResizeTo(1); chis.ResizeTo(1); Ndf.ResizeTo(1); };
// ------------ method called once each job just before starting event loop ------------ void LYZ::beginJob() { double Vmax[nbin], eps[nbin]; for(int ibin=0; ibin<nbin ; ibin++) { Vmax[ibin]=0.065*(trkbin[ibin]+30); eps[ibin]=0.00025*(trkbin[ibin]+30); } Nevent.ResizeTo(nbin); totmultall.ResizeTo(nbin), tottrk.ResizeTo(nbin);; Nevent.Zero(); totmultall.Zero(), tottrk.Zero(); for(int ibin=0; ibin<nbin; ibin++) { for(int iptbin=0; iptbin<nptV; iptbin++) { Qx2[ibin][iptbin]=0; Qy2[ibin][iptbin]=0; } } for(int itheta=0; itheta<ntheta; itheta++) { theta[itheta]=itheta*TMath::Pi()/ntheta/nn; for(int ibin=0; ibin<nbin; ibin++) { for(int iptbin=0; iptbin<nptV; iptbin++) { GRe[ibin][iptbin][itheta].ResizeTo(nstepr); GRe[ibin][iptbin][itheta].Zero(); GIm[ibin][iptbin][itheta].ResizeTo(nstepr); GIm[ibin][iptbin][itheta].Zero(); } } } for(int ibin=0; ibin<nbin; ibin++) { for(int ir=0; ir<nstepr; ir++) if(isSimple==0) r[ibin][ir]=j01/(Vmax[ibin]-eps[ibin]*ir); else r[ibin][ir]=0.00025*20*(ir+1); Qx1[ibin].ResizeTo(nptV); Qy1[ibin].ResizeTo(nptV); Q2[ibin].ResizeTo(nptV); Qx1[ibin].Zero(); Qy1[ibin].Zero(); Q2[ibin].Zero(); totmult[ibin].ResizeTo(nptv); totmult[ibin].Zero(); totpt[ibin].ResizeTo(nptv); totpt[ibin].Zero(); dDRe[ibin].ResizeTo(ntheta); dDRe[ibin].Zero(); dDIm[ibin].ResizeTo(ntheta); dDIm[ibin].Zero(); for(int itheta=0; itheta<ntheta; itheta++) { dNRe[ibin][itheta].ResizeTo(nptv); dNRe[ibin][itheta].Zero(); dNIm[ibin][itheta].ResizeTo(nptv); dNIm[ibin][itheta].Zero(); } } }
void merge(){ TVectorD Nevent; Nevent.ResizeTo(nbin); Nevent.Zero(); // TVectorD totmultall; totmultall.ResizeTo(nbin); totmultall.Zero(); // TVectorD avgmultall; avgmultall.ResizeTo(nbin); avgmultall.Zero(); TVectorD tottrk; tottrk.ResizeTo(nbin); tottrk.Zero(); // TVectorD totptall; totptall.ResizeTo(nbin); totptall.Zero(); // TVectorD totetaall; totetaall.ResizeTo(nbin); totetaall.Zero(); TVectorD avgtrk; avgtrk.ResizeTo(nbin); avgtrk.Zero(); // TVectorD avgmult; avgmult.ResizeTo(nbin); TH2F* s[nbin]; TH2F* b[nbin]; for(int ibin=0;ibin<nbin;ibin++){ s[ibin] = new TH2F(Form("s_%d",ibin),Form("signal",ibin),detastep,detamin,detamax,dphistep,dphimin,dphimax); s[ibin]->Sumw2(); b[ibin] = new TH2F(Form("b_%d",ibin), "background",detastep,detamin,detamax,dphistep,dphimin,dphimax); b[ibin]->Sumw2(); } TFile *fout = new TFile(Form("Anav3_merged.root"),"Recreate"); TFile *f[nFileAll]; for(int ifile=; ifile<63; ifile++){ f[ifile] = TFile::Open(Form("%s/Anav3_%d.root",outdir.Data(),ifile)); if(!f[ifile]) continue; TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get(Form("Nevent")); // TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get(Form("totmultall")); TVectorD* tottrk_t = (TVectorD*)f[ifile]->Get(Form("tottrk")); // TVectorD* totptall_t = (TVectorD*)f[ifile]->Get(Form("totptall")); // TVectorD* totetaall_t = (TVectorD*)f[ifile]->Get(Form("totetaall")); for(int ibin=0;ibin<nbin;ibin++){ // totptall[ibin] += (*totptall_t)[ibin]; // totetaall[ibin] += (*totetaall_t)[ibin]; Nevent[ibin] += (*Nevent_t)[ibin]; // totmultall[ibin] += (*totmultall_t)[ibin]; tottrk[ibin] += (*tottrk_t)[ibin]; TH1D* s_t = (TH1D*)f[ifile]->Get(Form("signal_%d",ibin)); TH1D* b_t = (TH1D*)f[ifile]->Get(Form("background_%d",ibin)); s[ibin]->Add(s_t); b[ibin]->Add(b_t); } f[ifile]->Close(); } for(int ibin=0;ibin<nbin;ibin++){ avgtrk[ibin] = tottrk[ibin]/Nevent[ibin]; TH1D* hr = (TH1D*)s[ibin]->Clone("hr"); hr->Divide(b[ibin]); hr->Scale(b[ibin]->GetBinContent(b[ibin]->FindBin(0,0))); fout->cd(); Nevent.Write("Nevent"); avgtrk.Write("avgtrk"); TDirectory *dir0 = (TDirectory*)fout->mkdir(Form("D_%d",ibin)); dir0->cd(); s[ibin]->Write("s"); b[ibin]->Write("b"); hr->Write(); } }
void loadVectorsFromFile(const char *filename, const char *scanfmt, TVectorD& v1, TVectorD& v2, TVectorD& v3) { char linein[LINELEN]; vector<double> v; if (TString(scanfmt).Contains("%f")) { cerr << "Must use %lf format for doubles, sorry " << endl; exit(-1); } FILE *fp = fopen(filename, "r"); if (!fp) { cerr << "File failed to open, " << filename << endl; exit(-1); } if (gl_verbose) cout << "Loading vectors from file " << filename << " with scan format \"" << scanfmt << "\"" << endl; while (!feof(fp) && fgets(linein,LINELEN,fp)) { double x1, x2, x3; if( linein[0]=='#' ) continue; // comments are welcome if( sscanf(linein, scanfmt, &x1, &x2, &x3) != 3 ) { cerr << "scan failed, file " << filename << ", line = " << linein; cerr << ", scanfmt = " << scanfmt; cerr << ", skipping" << endl; //return; continue; } else { v.push_back(x1); v.push_back(x2); v.push_back(x3); } } int vecsize = v.size()/3; v1.ResizeTo(vecsize); v2.ResizeTo(vecsize); v3.ResizeTo(vecsize); if (gl_verbose) cout << "; read " << vecsize << " lines" << endl; for (int i=0; i<vecsize; i++) { v1[i] = v[3*i]; v2[i] = v[3*i+1]; v3[i] = v[3*i+2]; } fclose(fp); } // loadVectorsFromFile
void loadVectorsFromFile(const char *filename, const char *scanfmt, TVectorD& vx, TVectorD& vy, char xheader[], char yheader[]) { char linein[LINELEN]; vector<double> v; FILE *fp = fopen(filename, "r"); if (!fp) { cerr << "File failed to open, " << filename << endl; return; } if (gl_verbose) cout << "Loading vectors from file " << filename; while (!feof(fp) && fgets(linein,LINELEN,fp)) { double x, y; if( linein[0]=='#' ) { if (!v.size()) { // first line, try to read headers TString hscanfmt(scanfmt); hscanfmt.ReplaceAll("lf","s"); if( sscanf(&linein[1],hscanfmt.Data(),xheader,yheader) != 2 ) { cerr << "failed to read in column headers" << endl; } } continue; // comments are welcome } if( sscanf(linein, scanfmt, &x, &y) != 2 ) { cerr << "scan failed, file " << filename << ", line = " << linein << endl; return; } else { v.push_back(x); v.push_back(y); } } int vecsize = v.size()/2; vx.ResizeTo(vecsize); vy.ResizeTo(vecsize); if (gl_verbose) cout << "; read " << vecsize << " lines" << endl; for (int i=0; i<vecsize; i++) { vx[i] = v[2*i]; vy[i] = v[2*i+1]; } } // loadVectorsFromFile
void loadVectorsFromFile(const char *filename, TVectorD& vx, TVectorD& vy, TVectorD& vz) { char linein[LINELEN]; vector<double> v; FILE *fp = fopen(filename, "r"); if (!fp) { cerr << "File failed to open, " << filename << endl; return; } if (gl_verbose) cout << "Loading vectors from file " << filename; while (!feof(fp) && fgets(linein,LINELEN,fp)) { double x, y, z; if( linein[0]=='#' ) continue; // comments are welcome if (sscanf(linein, "%lf %lf %lf", &x, &y, &z) != 3) { cerr << "scan failed, file " << filename << ", line = " << linein << endl; return; } else { v.push_back(x); v.push_back(y); v.push_back(z); } } int vecsize = v.size()/3; vx.ResizeTo(vecsize); vy.ResizeTo(vecsize); vz.ResizeTo(vecsize); if (gl_verbose) cout << "; read " << vecsize << " lines" << endl; for (int i=0; i<vecsize; i++) { vx[i] = v[2*i]; vy[i] = v[2*i+1]; vz[i] = v[2*i+2]; } } // loadVectorsFromFile
void FillVar(){ /// npoints =tree->Draw("side",cutA+cut1+cut2); vside.ResizeTo(npoints); vside.SetElements(tree->GetV1()); // npoints =tree->Draw("z",cutA+cut1+cut2); vz.ResizeTo(npoints); vz.SetElements(tree->GetV1()); // npoints =tree->Draw("dr",cutA+cut1+cut2); vdr.ResizeTo(npoints); vdr.SetElements(tree->GetV1()); // npoints =tree->Draw("tl",cutA+cut1+cut2); vtl.ResizeTo(npoints); vtl.SetElements(tree->GetV1()); // npoints =tree->Draw("sa",cutA+cut1+cut2); vsa.ResizeTo(npoints); vsa.SetElements(tree->GetV1()); // npoints =tree->Draw("ca",cutA+cut1+cut2); vca.ResizeTo(npoints); vca.SetElements(tree->GetV1()); // npoints =tree->Draw("dz",cutA+cut1+cut2); vdz.ResizeTo(npoints); vdz.SetElements(tree->GetV1()); // npoints =tree->Draw("dtl",cutA+cut1+cut2); vdtl.ResizeTo(npoints); vdtl.SetElements(tree->GetV1()); // npoints =tree->Draw("ez",cutA+cut1+cut2); vez.ResizeTo(npoints); vez.SetElements(tree->GetV1()); // npoints =tree->Draw("etl*0.5",cutA+cut1+cut2); vetl.ResizeTo(npoints); vetl.SetElements(tree->GetV1()); // npoints = tree->Draw("run","run>0"); Int_t *np=new Int_t[npoints]; for (Int_t i=0;i<npoints;i++) np[i]=tree->GetV1()[i]; Int_t *nsort=new Int_t[npoints]; Int_t nruns = toolkit.Freq(npoints,np,nsort,kTRUE); }
void DumpRecenterParv2(){ TString pro = "Pro104"; int taxi = 8583; TFile *fin; int nrun = GetTotalRun(); if(nrun<0) exit("Empty run list file!"); TFile *fout = new TFile(Form("Recentering.root"),"Recreate"); TVectorD vecmean; TVectorD vecrms; vecmean.ResizeTo(ncent*nbbcz*nhar*nsub*nxy); vecrms.ResizeTo(ncent*nbbcz*nhar*nsub*nxy); for(int irun=0;irun<nrun;irun++){ cout<<irun<<" of total "<<nrun<<" runs"<<endl; int RunNumber=GetRun(irun); fin = TFile::Open(Form("Run15pAu200MinBias/output_fvtxwithcntrecenter_%d.root",RunNumber)); //ofstream fout(Form("Calibration/%s/Recentering_%d.dat",dataset.Data(),GetRun(irun))); for(int icent=0;icent<ncent;icent++){ for(int ibbcz=0;ibbcz<nbbcz;ibbcz++){ for(int ihar=0;ihar<nhar;ihar++){ for(int isub=0;isub<nsub;isub++){ for(int ixy=0;ixy<nxy;ixy++){ TH1F* q = (TH1F*)fin->Get(Form("q_%d_%d_%d_%d_%d",icent,ibbcz,ihar,isub,ixy)); float mean = q->GetMean(); float rms = q->GetRMS(); vecmean[icent*nbbcz*nhar*nsub*nxy+ibbcz*nhar*nsub*nxy+ihar*nsub*nxy+isub*nxy+ixy] = mean; vecrms[icent*nbbcz*nhar*nsub*nxy+ibbcz*nhar*nsub*nxy+ihar*nsub*nxy+isub*nxy+ixy] = rms; } } } } } fout->cd(); vecmean.Write(Form("mean_%d",RunNumber)); vecrms.Write(Form("rms_%d",RunNumber)); fin->Close(); } }
void initN(double *binv, int Nv, double methodv){ centbin.ResizeTo(Nv); kpoint.ResizeTo(Nv); centbin_.ResizeTo(Nv); kpoint_.ResizeTo(Nv); method.ResizeTo(1); if(methodv==0){ centbin=TVectorD(Nv,binv); centbin_=TVectorD(Nv,binv); } else{ kpoint=TVectorD(Nv,binv); kpoint_=TVectorD(Nv,binv); } N=Nv-1; method[0]=methodv; NpartAver.ResizeTo(N); NcollAver.ResizeTo(N);BAver.ResizeTo(N); Npartdis = new TObjArray(0); };
void MultiGaus(const TVectorD& parMeans, const TMatrixDSym& covMatrix, TVectorD& genPars) { TRandom3 rnd(0); int nPars = parMeans.GetNrows(); if(nPars <= 0) { Error("MultiGaus", "Must have >0 pars"); return; } if(covMatrix.GetNrows() != nPars) { Error("MultiGaus", "parMeans.GetNrows() != covMatrix.GetNrows()"); return; } // Check that covMatrix is symmetric for(int iRow = 0; iRow < nPars; iRow++) { for(int iCol = iRow; iCol < nPars; iCol++) { if(covMatrix(iRow, iCol) != covMatrix(iCol, iRow)) { Error("MultiGaus", "malformed cov matrix at row %d, col %d", iRow, iCol); return; } } } genPars.ResizeTo(nPars); TMatrixDSymEigen eigenvariances(covMatrix); TMatrixD V = eigenvariances.GetEigenVectors(); TVectorD rotParMeans = V * parMeans; for(int iPar = 0; iPar < nPars; iPar++) { double variance = eigenvariances.GetEigenValues()[iPar]; // check for positive-definiteness of covMatrix if(variance < 0) { Error("MultiGaus", "Got a negative eigenvariance (%f) on iPar = %d", variance, iPar); } genPars[iPar] = rnd.Gaus(rotParMeans[iPar], sqrt(variance)); } V.Invert(); genPars = V * genPars; }
void loadVectorsFromFile(const char *filename, const char *scanfmt, TVectorD& vx, TVectorD& vy, TVectorD& exl,TVectorD& exh, TVectorD& eyl,TVectorD& eyh) { char linein[LINELEN]; vector<double> v; FILE *fp = fopen(filename, "r"); if (!fp) { cerr << "File failed to open, " << filename << endl; return; } if (gl_verbose) cout << "Loading vectors from file " << filename; while (!feof(fp) && fgets(linein,LINELEN,fp)) { double x, y, ymin,ymax; if( linein[0]=='#' ) continue; // comments are welcome if (sscanf(linein, scanfmt, &x, &ymin, &ymax, &y) != 4) { cerr << "scan failed, file " << filename << ", line = " << linein << endl; return; } else { v.push_back(x); v.push_back(y); v.push_back(0); v.push_back(0); v.push_back(y-ymin); v.push_back(ymax-y); } } int vecsize = v.size()/6; vx.ResizeTo(vecsize); vy.ResizeTo(vecsize); exl.ResizeTo(vecsize); exh.ResizeTo(vecsize); eyl.ResizeTo(vecsize); eyh.ResizeTo(vecsize); if (gl_verbose) cout << "; read " << vecsize << " lines" << endl; for (int i=0; i<vecsize; i++) { vx[i] = v[6*i]; vy[i] = v[6*i+1]; exl[i] = v[6*i+2]; exh[i] = v[6*i+3]; eyl[i] = v[6*i+4]; eyh[i] = v[6*i+5]; } } // loadVectorsFromFile
// ------------ method called once each job just before starting event loop ------------ void LYZ::beginJob(int ispt_) { double Vmax[nbin], eps[nbin]; for(int ibin=0; ibin<nbin ;ibin++){ Vmax[ibin]=0.065*(trkbin[ibin]+30); eps[ibin]=0.00025*(trkbin[ibin]+30); } ispt = ispt_; if(ispt_){ nvv = nptv; binv = ptbinv;} else{ nvv = netav; binv = etabinv;} Nevent.ResizeTo(nbin); totmultall.ResizeTo(nbin), tottrk.ResizeTo(nbin), totptall.ResizeTo(nbin), totetaall.ResizeTo(nbin); totwall.ResizeTo(nbin); Qx1.ResizeTo(nbin); Qy1.ResizeTo(nbin); Q2.ResizeTo(nbin); Nevent.Zero(); totmultall.Zero(); totwall.Zero(); tottrk.Zero(); totptall.Zero(); totetaall.Zero(); Qx1.Zero(); Qy1.Zero(); Q2.Zero(); for(int ibin=0; ibin<nbin; ibin++){ Qx2[ibin]=0; Qy2[ibin]=0; } for(int itheta=0;itheta<ntheta;itheta++){ theta[itheta]=itheta*TMath::Pi()/ntheta/nn; for(int ibin=0; ibin<nbin; ibin++){ GRe[ibin][itheta].ResizeTo(nstepr); GRe[ibin][itheta].Zero(); GIm[ibin][itheta].ResizeTo(nstepr); GIm[ibin][itheta].Zero(); } } for(int ibin=0; ibin<nbin; ibin++){ for(int ir=0; ir<nstepr; ir++) if(isSimple==0) r[ibin][ir]=j01/(Vmax[ibin]-eps[ibin]*ir); else r[ibin][ir]=0.00025*20*(ir+1); totmultv[ibin].ResizeTo(nvv); totmultv[ibin].Zero(); totptv[ibin].ResizeTo(nvv); totptv[ibin].Zero(); totetav[ibin].ResizeTo(nvv); totetav[ibin].Zero(); dDRe[ibin].ResizeTo(ntheta); dDRe[ibin].Zero(); dDIm[ibin].ResizeTo(ntheta); dDIm[ibin].Zero(); for(int itheta=0;itheta<ntheta;itheta++){ dNRe[ibin][itheta].ResizeTo(nvv); dNRe[ibin][itheta].Zero(); dNIm[ibin][itheta].ResizeTo(nvv); dNIm[ibin][itheta].Zero(); } } }
// ------------ method called once each job just before starting event loop ------------ void qfit::beginJob(int ispt_) { ispt = ispt_; if(ispt_){ nvv = nptv; binv = ptbinv;} else{ nvv = netav; binv = etabinv;} Nevent.ResizeTo(nbin); totmultall.ResizeTo(nbin), tottrk.ResizeTo(nbin), totptall.ResizeTo(nbin), totptall2.ResizeTo(nbin); totetaall.ResizeTo(nbin); Nevent.Zero(); totmultall.Zero(), tottrk.Zero(); totptall.Zero(); totptall2.Zero(); totetaall.Zero(); q22.ResizeTo(nbin);q24.ResizeTo(nbin); q22.Zero();q24.Zero(); for(int itheta=0;itheta<ntheta;itheta++){ theta[itheta]=itheta*TMath::Pi()/ntheta/nn; } for(int ibin=0; ibin<nbin; ibin++){ totmultv[ibin].ResizeTo(nvv); totmultv[ibin].Zero(); totptv[ibin].ResizeTo(nvv); totptv[ibin].Zero(); totetav[ibin].ResizeTo(nvv); totetav[ibin].Zero(); for(int itheta=0;itheta<ntheta;itheta++){ hq[ibin][itheta] = new TH1D(Form("hq_%d_%d",ibin,itheta),Form("hq_%d_%d",ibin,itheta),1000,0,10); hq[ibin][itheta]->Sumw2(); } hqx[ibin] = new TH1D(Form("hqx_%d",ibin),Form("hqx_%d",ibin),1000,0,10); hqy[ibin] = new TH1D(Form("hqy_%d",ibin),Form("hqy_%d",ibin),1000,0,10); hq2[ibin] = new TH1D(Form("hq2_%d",ibin),Form("hq2_%d",ibin),1000,0,10); hvq2[ibin] = new TH1D(Form("hvq2_%d",ibin),Form("hvq2_%d",ibin),1000,0,1); hq2nonf[ibin] = new TH1D(Form("hq2nonf_%d",ibin),Form("hq2nonf_%d",ibin),1000,0,10); hqx[ibin]->Sumw2(); hqy[ibin]->Sumw2(); hq2[ibin]->Sumw2(); hvq2[ibin]->Sumw2(); hq2nonf[ibin]->Sumw2(); } }
void initx(double xminv, double xmaxv){ xmin.ResizeTo(1); xmax.ResizeTo(1); xmin[0]=xminv; xmax[0]=xmaxv; };
void Reducer() { gSystem->Load("libactar.sl"); Bool_t simuFlag; Bool_t gasflag; Char_t *simname; Char_t *digname; Char_t *gasname; //simname="./root_files/simFile_12Cpp12C_D2_80MeV.root"; //simname="./root_files/simFile_12C_pp_dp_D2_80MeV.root"; //simname="./root_files/simFile_12C_pp_dp_D2_80MeV_vertex10to128.root"; //simname="./root_files/simFile_80MeV_12C_aa_a3he_CC_pp_HeiC4h10_9to1_vertex10to128.root"; //simname="./root_files/simFile_80MeV_12C_aa_aHe3_CC_pp_HeiC4H10_9to1_noAlMAYA.root"; //simname="./root_files/simFile_80MeV_12C_aa_aHe3_HeiC4H10_9to1.root"; //simname="./root_files/simFile_80MeV_He4.root"; //simname="./root_files/simFile_80MeV_13C_He4.root"; //simname="./root_files/simFile_60MeV_12C_He4.root"; //simname="./root_files/simFile_60MeV_He4_He4.root"; //simname="./root_files/simFile_40MeV_He4_He4.root"; //simname="./root_files/simFile_30MeV_He4_He4.root"; //simname="./root_files/simFile_40MeV_He3_He3.root"; //simname="./root_files/simFile_40MeV_He3He3_He4He4.root"; simname="./root_files/simFile_40MeV_He3He3_He4He4_iongasmod.root"; //simname="./root_files/simFile_100MeV_He4_He4.root"; //Event info; TFile *simFile=new TFile(simname); //getting the trees TTree *simTree=(TTree*)simFile->Get("The_ACTAR_Event_Tree"); Int_t nentries=simTree->GetEntries(); cout<<"Number of sim event : "<<nentries<<endl; //TTree *T=(TTree*)simFile->Get("digiTree"); //ClonesArray to the silicon Hits TClonesArray *silHitsCA=new TClonesArray("ActarSimSilHit",200); TBranch *branchSilHits=simTree->GetBranch("silHits"); branchSilHits->SetAddress(&silHitsCA); branchSilHits->SetAutoDelete(kTRUE); ActarSimSilHit *silHit=new ActarSimSilHit; //cout<<"digFile to use: "; //cin >> digname; //digname="./dig_files/digFile_12Cpp12C_D2_80MeV.root"; //digname="./dig_files/digFile_12C_pp_dp_D2_80MeV.root"; //digname="./dig_files/digFile_12C_pp_dp_D2_80MeV_vertex10to128.root"; //digname="./dig_files/digFile_80MeV_12C_aa_a3he_CC_pp_HeiC4h10_9to1_vertex10to128.root"; //digname="./dig_files/digFile_80MeV_12C_aa_aHe3_CC_pp_HeiC4H10_9to1_noAlMAYA.root"; //digname="./dig_files/digFile_80MeV_12C_aa_aHe3_HeiC4H10_9to1.root"; //digname="./dig_files/digFile_80MeV_He4.root"; //digname="./dig_files/digFile_80MeV_13C_He4.root"; //digname="./dig_files/digFile_60MeV_12C_He4.root"; //digname="./dig_files/digFile_60MeV_He4_He4.root"; //digname="./dig_files/digFile_40MeV_He4_He4.root"; //digname="./dig_files/digFile_30MeV_He4_He4.root"; //digname="./dig_files/digFile_40MeV_He3_He3.root"; //digname="./dig_files/digFile_40MeV_He3He3_He4He4_noPolya.root"; digname="./dig_files/digFile_40MeV_He3He3_He4He4_iongasmod.root"; //digname="./dig_files/digFile_100MeV_He4_He4.root"; // cout<<"Gas: isobutane (1) or deuterium gas (0)? "; // cin >> gasflag; // if(gasflag==1)gasname="isobutane"; // if(gasflag==0)gasname="deuterium"; gROOT->ProcessLine(".L digit_piotr.h+"); //gROOT->ProcessLine(".L digit.h+"); padsGeometry thePadsGeometry; thePadsGeometry.SetGeometryValues(37.,85.,69.,2.,5.,5.);//digit+ //thePadsGeometry.SetGeometryValues(32.,85.,64.,2.,0.,0.);//digit+ //thePadsGeometry.SetGeometryValues(0,0,0,32.,85.,64.,100.,2); driftManager theDriftManager; Char_t dummy[256]; Char_t gas[256]; Double_t v_drift,sigma_trans,sigma_long; ifstream *gasfile=new ifstream(gasname); gasfile->getline(gas,256); cout<<gas<<endl; gasfile->getline(dummy,256); cout<<dummy<<endl; *gasfile>>dummy>>dummy>>v_drift; //cout<<dummy<<endl; *gasfile>>dummy>>dummy>>sigma_trans; //cout<<dummy<<endl; *gasfile>>dummy>>dummy>>sigma_long; //cout<<dummy<<endl; //theDriftManager.SetDriftParameters(2015.,170.,147.5,gasname); //theDriftManager.SetDriftParameters(2015.,170.,980.66,gasname); //Magboltz Drift paramters for Deuterium Gas //theDriftManager.SetDriftVelocity(4.7e-3); //theDriftManager.SetDiffusionParameters(1.146e-5,2.342e-5); //Magboltz Drift paramters for HeiC4H10 (9:1) Gas theDriftManager.SetDriftVelocity(9.084e-3); theDriftManager.SetDiffusionParameters(2.356e-5,3.105e-5); cout<<"Drift Parameters are:"<<endl; cout<<"v_drift---------> "<<theDriftManager.GetDriftVelocity()<<"mm/ns"<<endl; cout<<"D_long----------> "<<theDriftManager.GetLongitudinalDiffusion()<<"mm^2/ns"<<endl; cout<<"D_trans---------> "<<theDriftManager.GetTransversalDiffusion()<<"mm^2/ns"<<endl; Double_t padSize = thePadsGeometry.GetPadSize(); Double_t xLength = thePadsGeometry.GetXLength(); Double_t yLength = thePadsGeometry.GetYLength(); Double_t zLength = thePadsGeometry.GetZLength(); cout<<"X length===> "<<xLength<<endl; cout<<"Y length===> "<<yLength<<endl; cout<<"Z length===> "<<zLength<<endl; const Int_t numberOfRows = thePadsGeometry.GetNumberOfRows(); const Int_t numberOfColumns= thePadsGeometry.GetNumberOfColumns(); cout<<"Number of Rows: "<<numberOfRows<<", number of Columns: "<<numberOfColumns<<endl; Double_t driftVelocity = theDriftManager.GetDriftVelocity(); //digname="./dig_files/digFile_alpha_z80_ionGas.root"; TFile *digFile=new TFile(digname); cout<<"Opening digitization file: "<<digname<<endl; TTree *digiTree=(TTree*)digFile->Get("digiTree"); Int_t dentries=digiTree->GetEntries(); cout<<"Number of digit event : "<<dentries<<endl; //Int_t digentries=digiTree->GetEntries(); //cout<<"Number of digit event : "<<digentries<<endl; //ClonesArray to the signal TClonesArray *padSignalCA=new TClonesArray("ActarPadSignal",4000); digiTree->SetBranchAddress("padSignals",&padSignalCA); ActarPadSignal *padSignal=new ActarPadSignal; Double_t PI=3.1415926535897932384626433; Double_t deg=180./PI; Double_t rad=PI/180.; //==================================================================================// //read the Tree generated by tree1w and fill two histograms //note that we use "new" to create the TFile and TTree objects ! //because we want to keep these objects alive when we leave this function. //Flags Bool_t ReadWriteFlag=0;// 0: Read, 1: Write //Root file to fill //TFile *outfile = new TFile("./output/Output_test.root","RECREATE"); //TFile *outfile = new TFile("./output/Output_100MeV_He4_He4.root","RECREATE"); TFile *outfile = new TFile("./output/Output_40MeV_He3He3_He4He4_iongasmod.root","RECREATE"); //TFile *outfile = new TFile("./output/Output_40MeV_He3He3_He4He4_noPolya.root","RECREATE"); //TFile *outfile = new TFile("./output/Output_40MeV_He3_He3.root","RECREATE"); //TFile *outfile = new TFile("./output/Output_30MeV_He4_He4.root","RECREATE"); //TFile *outfile = new TFile("./output/Output_40MeV_He4_He4.root","RECREATE"); //TFile *outfile = new TFile("./output/Output_60MeV_He4_He4.root","RECREATE"); //TFile *outfile = new TFile("./output/Output_60MeV_12C_He4.root","RECREATE"); //TFile *outfile = new TFile("./output/Output_80MeV_13C_He4.root","RECREATE"); //TFile *outfile = new TFile("./output/Output_80MeV_He4.root","RECREATE"); //TFile *outfile = new TFile("./output/Output_80MeV_12C_aa_aHe3_HeiC4H10_9to1.root.root","RECREATE"); //TFile *outfile = new TFile("./output/Sim_Output_v2_39_25MHz_posy43_matrix.root","RECREATE"); TTree *out_tree = new TTree("out_tree","out_tree"); /////////////////////////////////////////////// Double_t Energy_in_silicon=0.; Double_t EnergySil; Int_t detectorID; Double_t SilPosX; Double_t SilPosY; Double_t SilPosZ; Double_t Qtot; TSpline3 *bragX; TSpline3 *bragY; TSpline3 *bragZ; Int_t Rmin=0, Rmax=31; Int_t Cmin=0, Cmax=63; Double_t threshold = 0; Double_t Tthreshold = 1.; Double_t charge, Ccharge; Double_t Rm,Cm,Zcor,Zm; //Matrix for the charge map Double_t **padCharge=new Double_t*[numberOfRows]; Double_t **padTime=new Double_t*[numberOfRows]; Double_t **padHeight=new Double_t*[numberOfRows]; for(Int_t j=0;j<numberOfRows;j++){ padCharge[j]=new Double_t[numberOfColumns]; padTime[j]=new Double_t[numberOfColumns]; } //Double_t *padChargeTest=new Double_t[numberOfRows]; //Double_t *padTimeTest=new Double_t[numberOfRows]; //TMatrixD *padCharge=0; //TMatrixD *padTime=0; //TMatrixD *padHeight=0; //TMatrixD padCharge(32,64,2000); //TMatrixD padTime(32,64,2000); //TMatrixD padHeight(32,64,2000); //TMatrixD *padChargeTest=0; //TMatrixD *padTimeTest=0; TMatrixD padChargeTest; TMatrixD padTimeTest; TMatrixD a(32,64); padChargeTest.ResizeTo(a); padTimeTest.ResizeTo(a); TMatrixD *pointerCharge = &padChargeTest; TMatrixD *pointerTime = &padTimeTest; //Silicon charge //Double_t SilCharge[16]; //Int_t SilID[16]; TVectorD SilCharge; SilCharge.ResizeTo(16); TVectorD SilID; SilID.ResizeTo(16); TVectorD *pointerSilCharge=&SilCharge; TVectorD *pointerSilID=&SilID; //Double_t *SilChargePointer=&SilCharge; //Branching the out tree //out_tree->Branch("PadCharge","TMatrixD",&padCharge,64000,0); //out_tree->Branch("PadTime","TMatrixD",&padTime,64000,0); //out_tree->Branch("SilCharge",&SilCharge,64000,0); out_tree->Branch("PadCharge","TMatrixD",&pointerCharge,64000,0); out_tree->Branch("PadTime","TMatrixD",&pointerTime,64000,0); out_tree->Branch("SilCharge","TVectorD",&pointerSilCharge,64000,0); out_tree->Branch("SilID","TVectorD",&pointerSilID,64000,0); //out_tree->Branch("SilCharge",&SilCharge,"energy/D"); // out_tree->Branch("Energy",&Qtot,"energy/D"); // out_tree->Branch("HAngle",&HAngle,"angle/D"); // out_tree->Branch("VAngle",&VAngle,"angle/D"); // out_tree->Branch("range",&track_range,"rangeProj/D"); // out_tree->Branch("rangeXY",&track_rangeXY,"rangeProjXY/D"); // out_tree->Branch("sourceX",&SourcePosX,"sourceX/D"); // out_tree->Branch("sourceY",&SourcePosY,"sourceY/D"); // out_tree->Branch("sourceZ",&SourcePosZ,"sourceZ/D"); // out_tree->Branch("range_calcX",&range_calcX,"range_calcX/D"); // out_tree->Branch("range_calcY",&range_calcY,"range_calcY/D"); // out_tree->Branch("range_calcZ",&range_calcZ,"range_calcZ/D"); //Char_t *dname="./dig_files/digFile_alpha_z80_ionGas.root"; //Char_t *gasname="isobutane"; //ReadDig(&dname, &gasname); //ReadDig(dname, gasname); //ReadDig("./dig_files/digFile_alpha_z80_ionGas.root", "isobutane"); //ReadDig("./dig_files/digFile_alpha_z80_ionGas.root", "isobutane",&&padCharge,&&padTime); //ReadDig("./dig_files/digFile_alpha_z80_ionGas.root", "isobutane",padChargeTest,padTimeTest,i); //ReadDig("./dig_files/digFile_alpha_z80_ionGas.root", "isobutane",padCharge,padTime); //*********************************************************************************************************// //*********************************************************************************************************// //** **// //** Event Loop **// //** **// //*********************************************************************************************************// //*********************************************************************************************************// for (Long64_t jentry=0;jentry<nentries;jentry++) { //for (Long64_t jentry=0;jentry<1000;jentry++) { //for (Long64_t jentry=5000;jentry<nentries;jentry++) { //for (Long64_t jentry=15000;jentry<nentries;jentry++) { if(jentry%500==0)cout<<jentry<<endl; //if(jentry%2==0)cout<<"¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ NEW (2nd) EVENT : "<<jentry<<" !!!!!!!!!!!!!!!!!!!!"<<endl; if(jentry%2==0) { for(Int_t u=0;u<numberOfRows;u++){ for(Int_t k=0;k<numberOfColumns;k++){ padChargeTest(u,k)=0.; padTimeTest(u,k)=0.; } } } silHitsCA->Clear(); simTree->GetEvent(jentry); Int_t nbsilicon= silHitsCA->GetEntries(); //cout<<" SILICON "<<nbsilicon<<endl; //if(simuFlag==1)ReadDig(padSignalCA,padSignal,padCharge,padTime); //if(simuFlag==1)ReadDig(digFile,padCharge,padTime); padSignalCA->Clear(); digiTree->GetEvent(jentry); Int_t numberofpads=padSignalCA->GetEntries(); //cout<<"# Pads fired "<< numberofpads<<endl; if(numberofpads>0){ for(Int_t k=0;k<numberofpads;k++){ padSignal=(ActarPadSignal*)padSignalCA->At(k); Double_t thisCharge = padSignal->GetChargeDeposited(); Double_t thisTime = (padSignal->GetInitTime()+padSignal->GetFinalTime())/2.; Double_t thisSigmaTime=padSignal->GetSigmaTime(); Int_t PadRow=padSignal->GetPadRow(); Int_t PadColumn=padSignal->GetPadColumn(); //if(k%20==0)cout<<"thisSigmaTime: "<<thisSigmaTime<<endl; if (thisCharge!=0){ padChargeTest(padSignal->GetPadRow()-1,padSignal->GetPadColumn()-1)+= thisCharge; padTimeTest(padSignal->GetPadRow()-1,padSignal->GetPadColumn()-1)+= thisCharge*thisTime; // padCharge[padSignal->GetPadRow()-1][padSignal->GetPadColumn()-1] // += thisCharge; // padTime[padSignal->GetPadRow()-1][padSignal->GetPadColumn()-1] // += thisCharge*thisTime; } }//Loop on ActarPadSignals if(jentry%2==1)//To have the 2 parts of the reaction { // Loop on rows & columns for(Int_t c=0;c<numberOfColumns;c++){ //LOOP on Columns for(Int_t r=0;r<numberOfRows;r++){ //LOOP on Rows padTimeTest(r,c)=padTimeTest(r,c)/padChargeTest(r,c); //padTime[r][c]=padTime[r][c]/padCharge[r][c]; //padTime[r][c]=gRandom->Gaus(padTime[r][c],sigma_time); } }//End of Loop on rows & columns } } if(jentry%2!=0){ ///////////Getting the Silicon Hits//////////////// for(Int_t s=0;s<16;s++){//Loop on the 12 MAYA Si & 4 DSSD //SilCharge[s]=0.; SilCharge(s)=0.; SilID(s)=0.; } Int_t SilHitID; Energy_in_silicon=0.; Int_t nbsiliconhits=silHitsCA->GetEntries(); //cout<<"SilHits->"<<nbsiliconhits<<endl; if(nbsiliconhits>2)cout<<"SilHits-> "<<nbsiliconhits<<" Event "<<jentry<<endl; if(nbsiliconhits>0){ for(Int_t h=0;h<nbsiliconhits;h++){ SilHitID=0; silHit=(ActarSimSilHit*)silHitsCA->At(h); //cout<<"SilHits->ParticleID: "<< silHit->GetParticleID()<<", SilHits->ParticleMass: "<< silHit->GetParticleMass()<<", SilHits->DetectorID: "<<silHit->GetDetectorID()<<endl; EnergySil=silHit->GetEnergy(); Energy_in_silicon=EnergySil; //if(silHit->GetDetectorID()<5)Energy_in_silicon=gRandom->Gaus(EnergySil,0.004*EnergySil); //else if(silHit->GetDetectorID()>4)Energy_in_silicon=gRandom->Gaus(EnergySil,0.00167*EnergySil); //Energy_in_silicon=gRandom->Gaus(EnergySil,0.008*EnergySil); detectorID=silHit->GetDetectorID(); SilPosX=silHit->GetXPos(); SilPosY=silHit->GetYPos(); SilPosZ=silHit->GetXPos(); //cout<<"Detector "<< detectorID<<" hit Energy "<<EnergySil<<" Energy Before "<<silHit->GetEBeforeSil()<<" Energy After "<<silHit->GetEAfterSil()<<" Energy in Silicium "<<Energy_in_silicon<<endl; //cout<<"Energy in silicon: "<<Energy_in_silicon<<endl; //SilCharge[detectorID-1]=Energy_in_silicon; SilCharge(detectorID-1)=Energy_in_silicon; //SilID(detectorID-1)=silHit->GetDetectorID(); if(silHit->GetParticleID()==2212)SilID(detectorID-1)=1;//p else if(silHit->GetParticleID()==1000020030)SilID(detectorID-1)=2;//3He else if(silHit->GetParticleID()==1000020040)SilID(detectorID-1)=3;//4He else if(silHit->GetParticleID()==1000060120)SilID(detectorID-1)=4;//12C else if(silHit->GetParticleID()==1000060130)SilID(detectorID-1)=5;//13C //break; //cout<<" SilFront "<<SilFront<<" SilLeft "<<SilLeft<<" SilRight "<<SilRight<<endl; } } if(nbsiliconhits!=0)out_tree->Fill(); } } out_tree->Write(); outfile->Close(); //*********************************************************************************************************// //*********************************************************************************************************// //** **// //** End of Event Loop **// //** **// //*********************************************************************************************************// //*********************************************************************************************************// }
void plotqfit(int fixv2=0,int fixg2=0){ const int nbin24 = 12; const double avgtrkbin[nbin24]={44.36,54.33,68.63,88.39,108.2,131.3,162.1,196.6,227.5,247.2,269.2,301.2}; const double V24[nbin24]={0.02965,0.03913,0.04832,0.04941,0.04822,0.04955,0.049,0.04805,0.04709,0.04665,0.04772,0.04797}; int xtheta=0; gStyle->SetOptStat(1011); gStyle->SetOptFit(1111); TFile *f = TFile::Open("mergedV_Sum.root"); TFile *fout = TFile::Open("qfitV.root","Update"); TVectorD *vecDNevent = (TVectorD*)f->Get(Form("Nevent")); TVectorD *vecDavgmult = (TVectorD*)f->Get(Form("avgmultall")); TVectorD *vecDtotmult = (TVectorD*)f->Get(Form("totmultall")); TVectorD *vecDavgpt = (TVectorD*)f->Get(Form("avgpt")); TVectorD *vecDavgpt2 = (TVectorD*)f->Get(Form("avgpt2")); TVectorD *vecDavgtrk = (TVectorD*)f->Get(Form("avgtrk")); TVectorD *vecDq22 = (TVectorD*)f->Get(Form("q22")); TVectorD *vecDq24 = (TVectorD*)f->Get(Form("q24")); double avgmultall = vecDtotmult->Sum()/vecDNevent->Sum(); double *avgmult = vecDavgmult->GetMatrixArray(); double *avgtrk = vecDavgtrk->GetMatrixArray(); double *avgpt = vecDavgpt->GetMatrixArray(); double *avgpt2 = vecDavgpt2->GetMatrixArray(); double *q22 = vecDq22->GetMatrixArray(); double *q24 = vecDq24->GetMatrixArray(); TLatex *t= new TLatex(); t->SetNDC(); t->SetTextSize(0.04); t->SetTextFont(42); /* if(fixg2){ TH1D* hq2all = new TH1D("hq2all","hq2all",1000,0,10); for(int ibin=0;ibin<nbin;ibin++){ //ibin<1 TH1D* hq2 = (TH1D*)f->Get(Form("D_%d/hq2",ibin)); hq2all->Add(hq2); } TF1 *ffit = new TF1(Form("ffit"),"1./(0.5*(1+[0]))*TMath::Exp(-([1]*[1]*[2]+x*x)/(1+[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/(0.5*(1+[0])))",0,10); TF1* f1fit = new TF1(Form("f1fit"),"x/(0.5*(1+[0]))*TMath::Exp(-([1]*[1]*[2]+x*x)/(1+[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/(0.5*(1+[0])))",0,10); TH1D* hq2all_cp = (TH1D*)hq2all->Clone("hq2all_cp"); hq2all->Scale(1./hq2all->Integral(0,-1,"width")); hq2all->Draw(); divideByBinCenter(hq2all_cp); ffit->SetParameters(1,0.05,avgmultall); f1fit->SetParameters(1,0.05,avgmultall); ffit->FixParameter(2,avgmultall); f1fit->FixParameter(2,avgmultall); hq2all->Fit(Form("f1fit"),"R","",0,10); double g2all = f1fit->GetParameter(0); } */ for(int ibin=0;ibin<nbin;ibin++){ //ibin<1 // if(ibin!=100) continue; TH1D* hq = (TH1D*)f->Get(Form("D_%d/D_%d/hq",ibin,xtheta)); TH1D* hqx = (TH1D*)f->Get(Form("D_%d/hqx",ibin)); TH1D* hqy = (TH1D*)f->Get(Form("D_%d/hqy",ibin)); TH1D* hq2 = (TH1D*)f->Get(Form("D_%d/hq2",ibin)); TH1D* hq2nonf = (TH1D*)f->Get(Form("D_%d/hq2nonf",ibin)); int k; for(k=0;k<nbin24;k++){ if(avgtrk[ibin]>avgtrkbin[k]&& avgtrk[ibin]<=avgtrkbin[k+1]) break; } //multiplyByBinCenter(hq); hq->Scale(1./hq->Integral(0,-1,"width")); //normalizeByBinWidth(hq); //multiplyByBinCenter(hqx); hqx->Scale(1./hqx->Integral(0,-1,"width")); //normalizeByBinWidth(hqx); //multiplyByBinCenter(hqy); hqy->Scale(1./hqy->Integral(0,-1,"width")); //normalizeByBinWidth(hqy); hq2->Scale(1./hq2->Integral(0,-1,"width")); hq2nonf->Scale(1./hq2nonf->Integral(0,-1,"width")); TF1 *ffit = new TF1(Form("ffit"),"1./(0.5*(1+[0]))*TMath::Exp(-([1]*[1]*[2]+x*x)/(1+[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/(0.5*(1+[0])))",0,10); TF1* f1fit = new TF1(Form("f1fit"),"x/(0.5*(1+[0]))*TMath::Exp(-([1]*[1]*[2]+x*x)/(1+[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/(0.5*(1+[0])))",0,10); //ffit = new TF1(Form("ffit"),"1./([0])*TMath::Exp(-([1]*[1]*[2]+x*x)/(2*[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/([0]))",0,10); //f1fit = new TF1(Form("f1fit"),"x/([0])*TMath::Exp(-([1]*[1]*[2]+x*x)/(2*[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/([0]))",0,10); ffit->SetParNames("g2","v2","M"); f1fit->SetParNames("g2","v2","M"); //ffit->SetParNames("#sigma2","v2","M"); //f1fit->SetParNames("sigma2","v2","M"); ffit->SetParameters(0.1,0.05,avgmult[ibin]); f1fit->SetParameters(0.1,0.05,avgmult[ibin]); if(fixv2){ ffit->FixParameter(1,V24[k]); f1fit->FixParameter(1,V24[k]); } if(fixg2){ double sigma2 = avgpt2[ibin]/2./avgpt[ibin]/avgpt[ibin]; double g2all = 2*sigma2-1; ffit->FixParameter(0,g2all); f1fit->FixParameter(0,g2all); } //f1fit->FixParameter(0,0); //f1fit->FixParameter(0,0); ffit->FixParameter(2,avgmult[ibin]); f1fit->FixParameter(2,avgmult[ibin]); /* hq->Fit(Form("f1fit"),"R","P",0,10); TCanvas *c2 = new TCanvas("c2","c2",1000,500); c2->Divide(2,1); c2->cd(1)->SetLogy(); fixedFontHist(hqx,1.0,2.0); hqx->SetTitle(""); hqx->GetXaxis()->SetTitle("q_{x}"); hqx->GetYaxis()->SetTitle("#frac{dN}{dq_{x}}"); hqx->GetYaxis()->SetRangeUser(1e-10,1); hqx->Fit(Form("f1fit"),"R","",0,10); c2->cd(2)->SetLogy(); TH1D* hqx_cp = (TH1D*)hqx->Clone("hqx_cp"); fixedFontHist(hqx_cp,1.0,2.0); divideByBinCenter(hqx_cp); hqx_cp->GetYaxis()->SetTitle("#frac{dN}{q_{x}dq_{x}}"); hqx_cp->GetYaxis()->SetRangeUser(1e-10,10); hqx_cp->Fit(Form("ffit"),"R","",0,10); t->DrawLatex(0.5,0.2,Form("N_{trk}^{offline} = %.2f", avgtrk[ibin])); TCanvas *c3 = new TCanvas("c3","c3",1000,500); c3->Divide(2,1); c3->cd(1); fixedFontHist(hqy,1.0,2.0); hqy->SetTitle(""); hqy->GetXaxis()->SetTitle("q_{y}"); hqy->GetYaxis()->SetTitle("#frac{dN}{dq_{y}}"); hqy->GetYaxis()->SetRangeUser(0,1); hqy->SetMarkerStyle(24); hqy->SetMarkerSize(0.5); hqy->Fit(Form("f1fit"),"R","",0,10); hqy->Draw("Psame"); c3->cd(2)->SetLogy(); TH1D* hqy_cp = (TH1D*)hqy->Clone("hqy_cp"); fixedFontHist(hqy_cp,1.0,2.0); divideByBinCenter(hqy_cp); hqy_cp->GetYaxis()->SetTitle("#frac{dN}{q_{y}dq_{y}}"); hqy_cp->GetYaxis()->SetRangeUser(1e-10,10); hqy_cp->SetMarkerStyle(24); hqy_cp->SetMarkerSize(0.5); hqy_cp->Fit(Form("ffit"),"R","",0,10); hqy_cp->Draw("Psame"); t->DrawLatex(0.5,0.2,Form("N_{trk}^{offline} = %.2f",avgtrk[ibin])); */ TCanvas *c4 = new TCanvas("c4","c4",1000,500); c4->Divide(2,1); c4->cd(1)->SetLeftMargin(0.18); fixedFontHist(hq2,1.0,2.0); hq2->SetTitle(""); hq2->GetXaxis()->SetTitle("q_{2}"); hq2->GetYaxis()->SetTitle("#frac{dN}{dq_{2}}"); hq2->GetYaxis()->SetRangeUser(0,1); hq2->SetMarkerStyle(24); hq2->SetMarkerColor(4); hq2->SetLineColor(4); hq2->SetMarkerSize(0.5); hq2->Fit(Form("f1fit"),"R","",0,10); TVectorD vecr; vecr.ResizeTo(8); vecr[0]=f1fit->GetParameter(0); vecr[1]=f1fit->GetParError(0); vecr[2]=f1fit->GetParameter(1); vecr[3]=f1fit->GetParError(1); vecr[4]=avgmult[ibin]; vecr[5]=avgtrk[ibin]; hq2->Draw("Psame"); c4->cd(2)->SetLogy(); c4->cd(2)->SetLeftMargin(0.2); TH1D* hq2_cp = (TH1D*)hq2->Clone("hq2_cp"); fixedFontHist(hq2_cp,1.0,2.0); divideByBinCenter(hq2_cp); hq2_cp->GetYaxis()->SetTitle("#frac{dN}{q_{2}dq_{2}}"); hq2_cp->GetYaxis()->SetRangeUser(1e-10,10); hq2_cp->SetMarkerStyle(24); hq2_cp->SetMarkerColor(4); hq2_cp->SetLineColor(4); hq2_cp->SetMarkerSize(0.5); hq2_cp->Fit(Form("ffit"),"R","",0,10); hq2_cp->Draw("Psame"); t->DrawLatex(0.5,0.2,Form("N_{trk}^{offline} = %.2f", avgtrk[ibin])); TCanvas *c5 = new TCanvas("c5","c5",1000,500); c5->Divide(2,1); c5->cd(1); fixedFontHist(hq2nonf,1.0,2.0); hq2nonf->SetTitle(""); hq2nonf->GetXaxis()->SetTitle("q_{2}"); hq2nonf->GetYaxis()->SetTitle("#frac{dN}{dq_{2}}"); hq2nonf->GetYaxis()->SetRangeUser(0,1); hq2nonf->SetMarkerStyle(24); hq2nonf->SetMarkerColor(4); hq2nonf->SetLineColor(4); hq2nonf->SetMarkerSize(0.5); ffit->SetParameters(1.5,0.05,avgmult[ibin]*2); f1fit->SetParameters(1.5,0.05,avgmult[ibin]*2); ffit->FixParameter(2,avgmult[ibin]*2); f1fit->FixParameter(2,avgmult[ibin]*2); if(fixv2){ ffit->FixParameter(1,V24[k]); f1fit->FixParameter(1,V24[k]); } if(fixg2){ ffit->FixParameter(0,g2all+1); f1fit->FixParameter(0,g2all+1); } //ffit->FixParameter(0,1); //f1fit->FixParameter(0,1); hq2nonf->Fit(Form("f1fit"),"R","",0,10); TVectorD vecrnonf; vecrnonf.ResizeTo(8); vecrnonf[0]=f1fit->GetParameter(0); vecrnonf[1]=f1fit->GetParError(0); vecrnonf[2]=f1fit->GetParameter(1); vecrnonf[3]=f1fit->GetParError(1); vecrnonf[4]=avgmult[ibin]; vecrnonf[5]=avgtrk[ibin]; hq2nonf->Draw("Psame"); c5->cd(2)->SetLogy(); TH1D* hq2nonf_cp = (TH1D*)hq2nonf->Clone("hq2nonf_cp"); fixedFontHist(hq2nonf_cp,1.0,2.0); divideByBinCenter(hq2nonf_cp); hq2nonf_cp->GetYaxis()->SetTitle("#frac{dN}{q_{2}dq_{2}}"); hq2nonf_cp->GetYaxis()->SetRangeUser(1e-10,10); hq2nonf_cp->SetMarkerStyle(24); hq2nonf_cp->SetMarkerColor(4); hq2nonf_cp->SetLineColor(4); hq2nonf_cp->SetMarkerSize(0.5); hq2nonf_cp->Fit(Form("ffit"),"R","",0,10); hq2nonf_cp->Draw("Psame"); t->DrawLatex(0.5,0.2,Form("N_{trk}^{offline} = %.2f", avgtrk[ibin]*2)); double v2calc = TMath::Sqrt(TMath::Sqrt(2*q22[ibin]*q22[ibin]-q24[ibin])/avgmult[ibin]); double g2calc = q22[ibin]-TMath::Sqrt(2*q22[ibin]*q22[ibin]-q24[ibin])-1; vecr[6]=v2calc; vecr[7]=g2calc; fout->cd(); vecr.Write(Form("r_%d_%d_%d",ibin,fixv2,fixg2),TObject::kOverwrite); vecrnonf.Write(Form("rnonf_%d_%d_%d",ibin,fixv2,fixg2),TObject::kOverwrite); //if(ibin==15) //c4->Print("hq2_fit_15.png"); } //c5->Print("hq2nonf_fit.png"); }
void getResv(){ double theta[ntheta]; TFile *f[nFileAlltrack]; for(int itheta=0;itheta<ntheta;itheta++) theta[itheta]=itheta*TMath::Pi()/ntheta/nn; string SumorProd = getenv("SUMORPROD"); string mdir = getenv("DIR"); ofstream fstrv; if(SumorProd=="Sum")fstrv.open("v.txt"); else fstrv.open("v_2.txt"); TVectorD totmult[nbin], totpt[nbin]; TVectorD Nevent, totmultall, totmultall_; TVectorD totmulthisto[nbin], totmulthistocorr[nbin]; TVectorD V_int, V_interr; TVectorD V_intcorr, V_intcorrerr; TVectorD* V_mean; TVectorD* deltaV_mean; TVectorD* V[nbin]; TVectorD* chi[nbin]; TVectorD* dDRe[nbin]; TVectorD* dDIm[nbin]; TVectorD* dNRe[nbin][ntheta]; TVectorD* dNIm[nbin][ntheta]; TComplex dD[nbin][ntheta], dN[nbin][ntheta][nptv]; TVectorD avgmult[nbin]; TVectorD avgmultall; TVectorD avgpt[nbin]; TVectorD v[nbin][ntheta],vmean[nbin],deltav[nbin][ntheta],deltavmean[nbin]; if(SumorProd=="Sum") TFile *infile = TFile::Open("mergedV_Sum.root"); else TFile *infile = TFile::Open("mergedV_Prod.root"); Nevent.ResizeTo(nbin); Nevent.Zero(); totmultall.ResizeTo(nbin); totmultall.Zero(); totmultall_.ResizeTo(nbin); totmultall_.Zero(); avgmultall.ResizeTo(nbin); V_int.ResizeTo(nbin); V_int.Zero(); V_interr.ResizeTo(nbin); V_interr.Zero(); V_intcorr.ResizeTo(nbin); V_intcorr.Zero(); V_intcorrerr.ResizeTo(nbin); V_intcorrerr.Zero(); for(int ibin=0;ibin<nbin;ibin++){ totmult[ibin].ResizeTo(nptv); totmult[ibin].Zero(); totmulthisto[ibin].ResizeTo(nptv); totmulthistocorr[ibin].ResizeTo(nptv); avgmult[ibin].ResizeTo(nptv); avgpt[ibin].ResizeTo(nptv); totpt[ibin].ResizeTo(nptv); totpt[ibin].Zero(); vmean[ibin].ResizeTo(nptv); deltavmean[ibin].ResizeTo(nptv); V[ibin] = (TVectorD*) infile->Get(Form("D_%d/D_0/V",ibin)); chi[ibin] = (TVectorD*) infile->Get(Form("D_%d/chi",ibin)); V_mean = (TVectorD*) infile->Get(Form("D_%d/Vmean",ibin)); deltaV_mean = (TVectorD*) infile->Get(Form("D_%d/deltaVmean",ibin)); for(int itheta=0;itheta<ntheta;itheta++){ v[ibin][itheta].ResizeTo(nptv); deltav[ibin][itheta].ResizeTo(nptv); dD[ibin][itheta]=0; for(int iptbin=0;iptbin<nptv;iptbin++){ dN[ibin][itheta][iptbin]=0; } } } for(int ifile=0; ifile<nFileAlltrack; ifile++){ if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/lio/lfs/cms/store/user/qixu/flow/pbsjoboutput/PFcandpt01to10tracknormcpt03to6/%s/Anav_Prod_%d.root",mdir.c_str(),ifile)); else f[ifile] = TFile::Open(Form("/lio/lfs/cms/store/user/qixu/flow/pbsjoboutput/PFcandpt01to10tracknormcpt03to6/%s/Anav_Prod2_%d.root",mdir.c_str(),ifile)); TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get("Nevent"); TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get("totmultall"); for(int ibin=0;ibin<nbin;ibin++){ TVectorD* totmult_t = (TVectorD*)f[ifile]->Get(Form("totmult_%d",ibin)); TVectorD* totpt_t = (TVectorD*)f[ifile]->Get(Form("totpt_%d",ibin)); dDRe[ibin] = (TVectorD*)f[ifile]->Get(Form("dDRe_%d",ibin)); dDIm[ibin] = (TVectorD*)f[ifile]->Get(Form("dDIm_%d",ibin)); Nevent[ibin]+=(*Nevent_t)[ibin]; totmultall[ibin]+=(*totmultall_t)[ibin]; for(int iptbin=0;iptbin<nptv;iptbin++){ totmult[ibin][iptbin]+=(*totmult_t)[iptbin]; totpt[ibin][iptbin]+=(*totpt_t)[iptbin]; } for(int itheta=0;itheta<ntheta;itheta++){ dNRe[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNRe_%d_%d",ibin,itheta)); dNIm[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNIm_%d_%d",ibin,itheta)); dD[ibin][itheta]+=TComplex((*dDRe[ibin])[itheta],(*dDIm[ibin])[itheta]); for(int iptbin=0;iptbin<nptv;iptbin++) dN[ibin][itheta][iptbin]+=TComplex((*dNRe[ibin][itheta])[iptbin],(*dNIm[ibin][itheta])[iptbin]); } } f[ifile]->Close(); } TH1D* hpt[nbin]; TH1D* hpteffcorr[nbin]; TFile *fhisto = TFile::Open("histomerged.root"); TFile *feff = TFile::Open("/home/xuq7/HI/flow/LYZ/v2/TrackCorrections_HIJING_538_OFFICIAL_Mar24.root"); TH2F* heff = (TH2F*)feff->Get("rTotalEff3D"); TH1D* hpteff = (TH1D*)heff->ProjectionY("hpteff",heff->GetXaxis()->FindBin(-2.4),heff->GetXaxis()->FindBin(2.4)-1,"o"); TArrayD *ptarr = (TArrayD*)heff->GetYaxis()->GetXbins(); double *ptbinhisto = ptarr->GetArray(); int NbinX = heff->GetXaxis()->GetNbins(); int NbinY = heff->GetYaxis()->GetNbins(); hpteff->Scale(1.0/NbinX); for(int ibin=0;ibin<nbin;ibin++) for(int itheta=0;itheta<ntheta;itheta++) dD[ibin][itheta]*=TComplex::Power(TComplex::I(),mm-1)/(Double_t)Nevent[ibin]; for(int ibin=0;ibin<nbin;ibin++){ avgmultall[ibin]=1.0*totmultall[ibin]/Nevent[ibin]; hpt[ibin] = (TH1D*)fhisto->Get(Form("D_%d/hpt",ibin)); TH1D* hptre = (TH1D*)hpt[ibin]->Rebin(NbinY,"hptre",ptbinhisto); hpteffcorr[ibin] = (TH1D*)hptre->Clone(Form("hpteffcorr_%d",ibin)); hpteffcorr[ibin]->Divide(hpteff); for(int iptbin=0;iptbin<nptv; iptbin++){ vmean[ibin][iptbin]=0; deltavmean[ibin][iptbin]=0; avgmult[ibin][iptbin]=1.0*totmult[ibin][iptbin]/Nevent[ibin]; avgpt[ibin][iptbin]=1.0*totpt[ibin][iptbin]/totmult[ibin][iptbin]; for(int itheta=0;itheta<ntheta;itheta++){ dN[ibin][itheta][iptbin]/=totmult[ibin][iptbin]; TComplex Res=dN[ibin][itheta][iptbin]/dD[ibin][itheta]; v[ibin][itheta][iptbin]=(*V[ibin])[itheta]*avgmultall[ibin]*TMath::BesselJ1(j01)/Besselj01(mm)*Res.Re(); vmean[ibin][iptbin]+=v[ibin][itheta][iptbin]; deltav[ibin][itheta][iptbin]=TMath::Cos(mm*nn*theta[itheta])/totmult[ibin][iptbin]*(TMath::Exp(j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Power(-1,mm)*TMath::Exp(-j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.))); deltavmean[ibin][iptbin]+=deltav[ibin][itheta][iptbin]; // fstrv<<itheta<<"\t"<<v[ibin][itheta][iptbin]<<"\t"<<deltav[ibin][itheta][iptbin]<<endl; } deltavmean[ibin][iptbin]=TMath::Sqrt(deltavmean[ibin][iptbin])/2./Besselj01(mm); //fstrv<<endl; vmean[ibin][iptbin]/=ntheta; deltavmean[ibin][iptbin]/=TMath::Sqrt(ntheta); fstrv<<ptbinv[iptbin]<<"-"<<ptbinv[iptbin+1]<<"\t"<<vmean[ibin][iptbin]<<"\t"<<deltavmean[ibin][iptbin]<<endl; if(ptbinv[iptbin+1]>3.0) continue; totmulthisto[ibin][iptbin]=hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(ptbinv[iptbin]),hpt[ibin]->GetXaxis()->FindBin(ptbinv[iptbin+1])-1); totmulthistocorr[ibin][iptbin]=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(ptbinv[iptbin]),hpteffcorr[ibin]->GetXaxis()->FindBin(ptbinv[iptbin+1])-1); V_int[ibin]+=vmean[ibin][iptbin]*totmult[ibin][iptbin]; V_interr[ibin]+=deltavmean[ibin][iptbin]*totmult[ibin][iptbin]; V_intcorr[ibin]+=vmean[ibin][iptbin]*totmulthistocorr[ibin][iptbin]; V_intcorrerr[ibin]+=deltavmean[ibin][iptbin]*totmulthistocorr[ibin][iptbin]; totmultall_[ibin]+=totmult[ibin][iptbin]; } V_int[ibin]/=totmultall_[ibin]; V_interr[ibin]/=totmultall_[ibin]; V_intcorr[ibin]/=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(ptbinv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1); V_intcorrerr[ibin]/=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(ptbinv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1); } fstrv<<endl<<"pt range\t\t"<<"totmult"<<"\t\t"<<"totmult from histo"<<"\t"<<"totmult corrected"<<endl; for(int ibin=0;ibin<nbin;ibin++){ for(int iptbin=0;iptbin<nptv; iptbin++){ fstrv<<ptbinv[iptbin]<<"-"<<ptbinv[iptbin+1]<<"\t\t"<<totmult[ibin][iptbin]<<"\t"<<totmulthisto[ibin][iptbin]<<"\t"<<totmulthistocorr[ibin][iptbin]<<endl; } fstrv<<"Integral\t\t"<<totmultall[ibin]<<"\t"<<hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(ptbinv[0]),hpt[ibin]->GetXaxis()->FindBin(3.0)-1)<<"\t"<<hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(ptbinv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1)<<endl; fstrv<<"V ref="<<(*V_mean)[ibin]<<"\t"<<"V int="<<V_int[ibin]<<"\t"<<"V int corr="<<V_intcorr[ibin]<<endl; fstrv<<"V ref err="<<(*deltaV_mean)[ibin]<<"\t"<<"V int err="<<V_interr[ibin]<<"\t"<<"V int corr err="<<V_intcorrerr[ibin]<<endl; } if(SumorProd=="Sum")TFile *fout = new TFile("mergedv_Prod.root","Recreate"); else TFile *fout = new TFile("mergedv_Prod2.root","Recreate"); for(ibin=0;ibin<nbin;ibin++){ Nevent.Write("Nevent"); V_int.Write("V_int"); V_interr.Write("V_interr"); V_intcorr.Write("V_intcorr"); V_intcorrerr.Write("V_intcorrerr"); TDirectory *dir = fout->mkdir(Form("D_%d",ibin)); dir->cd(); avgpt[ibin].Write("avgpt"); totmult[ibin].Write("totmult"); vmean[ibin].Write("vmean"); deltavmean[ibin].Write("deltavmean"); } infile->Close(); fout->Close(); }
void getResv(int ispt){ double theta[ntheta]; TFile *f[nFileAll]; for(int itheta=0;itheta<ntheta;itheta++) theta[itheta]=itheta*TMath::Pi()/ntheta/nn; int nvv; const double *binv; if(ispt){ nvv = nptv; binv = ptbinv;} else{ nvv = netav; binv = etabinv;} string SumorProd = getenv("SUMORPROD"); ofstream fstrv; if(ispt){ if(SumorProd=="Sum")fstrv.open("v.txt"); else fstrv.open("v_2.txt"); } else{ if(SumorProd=="Sum")fstrv.open("v_finer_eta.txt"); else fstrv.open("v_2_finer_eta.txt"); } TVectorD totmult[nbin],totpt[nbin], toteta[nbin]; TVectorD Nevent, totmultall, tottrkall,totmultall_, totmultallcorr; TVectorD V_int, V_interr; TVectorD* V_mean; TVectorD* deltaV_mean; TVectorD* V[nbin]; TVectorD* chi; TVectorD V_intcorr, V_intcorrerr; TVectorD totmulthisto_f[nbin][netav]; TVectorD totmulthisto[nbin], totmulthistocorr[nbin]; TVectorD* dDRe[nbin]; TVectorD* dDIm[nbin]; TVectorD* dNRe[nbin][ntheta]; TVectorD* dNIm[nbin][ntheta]; TComplex dD[nbin][ntheta], dN[nbin][ntheta][nvv]; TVectorD avgmult[nbin]; TVectorD avgmultall; TVectorD avgtrk[nbin]; TVectorD avgtrkall; TVectorD avgpt[nbin], avgeta[nbin]; TVectorD v[nbin][ntheta],vmean[nbin],deltav[nbin][ntheta],deltavmean[nbin]; if(SumorProd=="Sum") TFile *infile = TFile::Open("mergedV_Sum.root"); else TFile *infile = TFile::Open("mergedV_Prod.root"); Nevent.ResizeTo(nbin); Nevent.Zero(); totmultall.ResizeTo(nbin); totmultall.Zero(); tottrkall.ResizeTo(nbin); tottrkall.Zero(); totmultall_.ResizeTo(nbin); totmultall_.Zero(); totmultallcorr.ResizeTo(nbin); totmultallcorr.Zero(); avgmultall.ResizeTo(nbin); avgtrkall.ResizeTo(nbin); V_int.ResizeTo(nbin); V_int.Zero(); V_interr.ResizeTo(nbin); V_interr.Zero(); if(ispt){ V_intcorr.ResizeTo(nbin); V_intcorr.Zero(); V_intcorrerr.ResizeTo(nbin); V_intcorrerr.Zero(); } for(int ibin=0;ibin<nbin;ibin++){ totmult[ibin].ResizeTo(nvv); totmult[ibin].Zero(); if(ispt){ for(int ietabin=0;ietabin<netav;ietabin++){ totmulthisto_f[ibin][ietabin].ResizeTo(nvv); totmulthisto_f[ibin][ietabin].Zero(); } totmulthisto[ibin].ResizeTo(nvv); totmulthisto[ibin].Zero(); totmulthistocorr[ibin].ResizeTo(nvv); totmulthistocorr[ibin].Zero(); } avgmult[ibin].ResizeTo(nvv); avgpt[ibin].ResizeTo(nvv); avgeta[ibin].ResizeTo(nvv); totpt[ibin].ResizeTo(nvv); totpt[ibin].Zero(); toteta[ibin].ResizeTo(nvv); toteta[ibin].Zero(); vmean[ibin].ResizeTo(nvv); deltavmean[ibin].ResizeTo(nvv); V[ibin] = (TVectorD*) infile->Get(Form("D_%d/V",ibin)); chi = (TVectorD*) infile->Get(Form("chi")); V_mean = (TVectorD*) infile->Get(Form("Vmean")); deltaV_mean = (TVectorD*) infile->Get(Form("deltaVmean")); for(int itheta=0;itheta<ntheta;itheta++){ v[ibin][itheta].ResizeTo(nvv); deltav[ibin][itheta].ResizeTo(nvv); dD[ibin][itheta]=0; for(int ivbin=0;ivbin<nvv;ivbin++){ dN[ibin][itheta][ivbin]=0; } } } for(int ifile=0; ifile<nFileAll; ifile++){ if(ispt){ if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/PbPb2011MB/Anav_Prod_%d.root",ifile)); else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/PbPb2011MB/Anav_Prod2_%d.root",ifile)); } else{ if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/PbPb2011MB/finereta/Anaveta_Prod_%d.root",ifile)); else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/PbPb2011MB/finereta/Anaveta_Prod2_%d.root",ifile)); } TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get("Nevent"); TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get("totmultall"); TVectorD* tottrkall_t = (TVectorD*)f[ifile]->Get("tottrk"); for(int ibin=0;ibin<nbin;ibin++){ TVectorD* totmult_t = (TVectorD*)f[ifile]->Get(Form("totmult_%d",ibin)); TVectorD* totpt_t = (TVectorD*)f[ifile]->Get(Form("totpt_%d",ibin)); TVectorD* toteta_t = (TVectorD*)f[ifile]->Get(Form("toteta_%d",ibin)); dDRe[ibin] = (TVectorD*)f[ifile]->Get(Form("dDRe_%d",ibin)); dDIm[ibin] = (TVectorD*)f[ifile]->Get(Form("dDIm_%d",ibin)); Nevent[ibin]+=(*Nevent_t)[ibin]; totmultall[ibin]+=(*totmultall_t)[ibin]; tottrkall[ibin]+=(*tottrkall_t)[ibin]; for(int ivbin=0;ivbin<nvv;ivbin++){ totmult[ibin][ivbin]+=(*totmult_t)[ivbin]; totpt[ibin][ivbin]+=(*totpt_t)[ivbin]; toteta[ibin][ivbin]+=(*toteta_t)[ivbin]; } for(int itheta=0;itheta<ntheta;itheta++){ dNRe[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNRe_%d_%d",ibin,itheta)); dNIm[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNIm_%d_%d",ibin,itheta)); dD[ibin][itheta]+=TComplex((*dDRe[ibin])[itheta],(*dDIm[ibin])[itheta]); for(int ivbin=0;ivbin<nvv;ivbin++) dN[ibin][itheta][ivbin]+=TComplex((*dNRe[ibin][itheta])[ivbin],(*dNIm[ibin][itheta])[ivbin]); } } f[ifile]->Close(); } double eff[netav]; if(ispt){ TH2F* hetapt[nbin]; TH1D* hpt[nbin]; TH2F* hetapteffcorr[nbin]; TFile *fhisto = TFile::Open("histomerged.root"); //TFile *feff = TFile::Open("/home/xuq7/HI/dNchdeta/Correction/trkEff_pp_all_42X_origin.root"); TFile *feff = TFile::Open("/home/xuq7/HI/flow/LYZ/v2/TrackCorrections_HYDJET_442_OFFICIAL_Mar25.root"); TH2F* heff = (TH2F*)feff->Get("rTotalEff3D"); //TH1D* hpteff = (TH1D*)heff->ProjectionY("hpteff",heff->GetXaxis()->FindBin(-2.4),heff->GetXaxis()->FindBin(2.4)-1,"o"); //TGraphError* hpteff = (TGraphErrors*)feff->Get("gEffPt"); TArrayD *ptarr = (TArrayD*)heff->GetYaxis()->GetXbins(); double *ptbinhisto = ptarr->GetArray(); int NbinX = heff->GetXaxis()->GetNbins(); int NbinY = heff->GetYaxis()->GetNbins(); //hpteff->Scale(1.0/NbinX); } for(int ibin=0;ibin<nbin;ibin++) for(int itheta=0;itheta<ntheta;itheta++) dD[ibin][itheta]*=TComplex::Power(TComplex::I(),mm-1)/(Double_t)Nevent[ibin]; for(int ibin=0;ibin<nbin;ibin++){ avgmultall[ibin]=1.0*totmultall[ibin]/Nevent[ibin]; avgtrkall[ibin]=1.0*tottrkall[ibin]/Nevent[ibin]; if(ispt){ hetapt[ibin] = (TH2F*)fhisto->Get(Form("D_%d/hetapt",ibin)); hpt[ibin] = (TH1D*)fhisto->Get(Form("D_%d/hpt",ibin)); //TH1D* hptre = (TH1D*)hpt[ibin]->Rebin(NbinY,Form("hptre_%d",ibin),ptbinhisto); //TH1D* hptre = (TH1D*)hpt[ibin]->Rebin(NbinY,Form("hptre_%d",ibin),ptbinhisto); hetapteffcorr[ibin] = (TH2F*)hetapt[ibin]->Clone(Form("hetapteffcorr_%d",ibin)); //hpteffcorr[ibin]->Divide(hpteff); } for(int ivbin=0;ivbin<nvv; ivbin++){ vmean[ibin][ivbin]=0; deltavmean[ibin][ivbin]=0; avgmult[ibin][ivbin]=1.0*totmult[ibin][ivbin]/Nevent[ibin]; avgpt[ibin][ivbin]=1.0*totpt[ibin][ivbin]/totmult[ibin][ivbin]; avgeta[ibin][ivbin]=1.0*toteta[ibin][ivbin]/totmult[ibin][ivbin]; for(int itheta=0;itheta<ntheta;itheta++){ dN[ibin][itheta][ivbin]/=totmult[ibin][ivbin]; TComplex Res=dN[ibin][itheta][ivbin]/dD[ibin][itheta]; v[ibin][itheta][ivbin]=(*V[ibin])[itheta]*avgmultall[ibin]*TMath::BesselJ1(j01)/Besselj01(mm)*Res.Re(); vmean[ibin][ivbin]+=v[ibin][itheta][ivbin]; deltav[ibin][itheta][ivbin]=TMath::Cos(mm*nn*theta[itheta])/totmult[ibin][ivbin]*(TMath::Exp(j01*j01/2./(*chi)[ibin]/(*chi)[ibin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Power(-1,mm)*TMath::Exp(-j01*j01/2./(*chi)[ibin]/(*chi)[ibin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.))); deltavmean[ibin][ivbin]+=deltav[ibin][itheta][ivbin]; // fstrv<<itheta<<"\t"<<v[ibin][itheta][ivbin]<<"\t"<<deltav[ibin][itheta][ivbin]<<endl; } deltavmean[ibin][ivbin]=TMath::Sqrt(deltavmean[ibin][ivbin])/2./Besselj01(mm); //fstrv<<endl; vmean[ibin][ivbin]/=ntheta; deltavmean[ibin][ivbin]/=TMath::Sqrt(ntheta); fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t"<<vmean[ibin][ivbin]<<"\t"<<deltavmean[ibin][ivbin]<<endl; if(ispt){ for(int ietabin=0;ietabin<netav;ietabin++){ eff[ietabin] = heff->GetBinContent(heff->FindBin((etabinv[ietabin]+etabinv[ietabin+1])/2,(binv[ivbin]+binv[ivbin+1])/2)); totmulthisto_f[ibin][ietabin][ivbin]=hetapt[ibin]->Integral(hetapt[ibin]->GetXaxis()->FindBin(etabinv[ietabin]+1e-4),hetapt[ibin]->GetXaxis()->FindBin(etabinv[ietabin+1]-1e-4),hetapt[ibin]->GetYaxis()->FindBin(binv[ivbin]+1e-4),hetapt[ibin]->GetYaxis()->FindBin(binv[ivbin+1]+1e-4)); totmulthisto[ibin][ivbin]+=totmulthisto_f[ibin][ietabin][ivbin]; } } V_int[ibin]+=vmean[ibin][ivbin]*totmult[ibin][ivbin]; V_interr[ibin]+=deltavmean[ibin][ivbin]*totmult[ibin][ivbin]; totmultall_[ibin]+=totmult[ibin][ivbin]; if(ispt){ if(binv[ivbin+1]>3.0) continue; for(int ietabin=0;ietabin<netav;ietabin++) totmulthistocorr[ibin][ivbin]+=totmulthisto_f[ibin][ietabin][ivbin]/eff[ietabin]; V_intcorr[ibin]+=vmean[ibin][ivbin]*totmulthistocorr[ibin][ivbin]; V_intcorrerr[ibin]+=deltavmean[ibin][ivbin]*totmulthistocorr[ibin][ivbin]; totmultallcorr[ibin]+=totmulthistocorr[ibin][ivbin]; } } V_int[ibin]/=totmultall_[ibin]; V_interr[ibin]/=totmultall_[ibin]; if(ispt){ V_intcorr[ibin]/=totmultallcorr[ibin]; V_intcorrerr[ibin]/=totmultallcorr[ibin]; } } if(ispt){ fstrv<<endl<<"pt range\t\t"<<"totmult"<<"\t\t"<<"totmult from histo"<<"\t"<<"totmult corrected"<<endl; for(int ibin=0;ibin<nbin;ibin++){ for(int ivbin=0;ivbin<nvv; ivbin++){ fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t\t"<<totmult[ibin][ivbin]<<"\t"<<totmulthisto[ibin][ivbin]<<"\t"<<totmulthistocorr[ibin][ivbin]<<endl; } fstrv<<"Integral\t\t"<<totmultall_[ibin]<<"\t"<<hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(binv[0]),hpt[ibin]->GetXaxis()->FindBin(3.0)-1)<<"\t"<<totmultallcorr[ibin]<<endl; fstrv<<"V ref="<<(*V_mean)[ibin]<<"\t"<<"V int="<<V_int[ibin]<<"\t"<<"V int corr="<<V_intcorr[ibin]<<endl; fstrv<<"V ref err="<<(*deltaV_mean)[ibin]<<"\t"<<"V int err="<<V_interr[ibin]<<"\t"<<"V int corr err="<<V_intcorrerr[ibin]<<endl; } } else for(int ibin=0;ibin<nbin;ibin++){ for(int ivbin=0;ivbin<nvv; ivbin++){ fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t\t"<<totmult[ibin][ivbin]<<endl; } fstrv<<"V ref="<<(*V_mean)[ibin]<<"\t"<<"V int="<<V_int[ibin]<<endl; fstrv<<"V ref err="<<(*deltaV_mean)[ibin]<<"\t"<<"V int err="<<V_interr[ibin]<<endl; } if(ispt){ if(SumorProd=="Sum")TFile *fout = new TFile("mergedv_Prod.root","Recreate"); else TFile *fout = new TFile("mergedv_Prod2.root","Recreate"); } else{ if(SumorProd=="Sum")TFile *fout = new TFile("mergedv_Prod_finer_eta.root","Recreate"); else TFile *fout = new TFile("mergedv_Prod2_finer_eta.root","Recreate"); } for(ibin=0;ibin<nbin;ibin++){ Nevent.Write("Nevent"); avgtrkall.Write("avgtrk"); V_int.Write("V_int"); V_interr.Write("V_interr"); if(ispt){ V_intcorr.Write("V_intcorr"); V_intcorrerr.Write("V_intcorrerr"); } TDirectory *dir0 = fout->mkdir(Form("D_%d",ibin)); dir0->cd(); avgpt[ibin].Write("avgpt"); avgeta[ibin].Write("avgeta"); totmult[ibin].Write("totmult"); vmean[ibin].Write("vmean"); deltavmean[ibin].Write("deltavmean"); for(int itheta=0;itheta<ntheta;itheta++){ TDirectory *dir1 = dir0->mkdir(Form("D_%d",itheta));dir1->cd(); v[ibin][itheta].Write("v"); deltav[ibin][itheta].Write("deltav"); } } infile->Close(); fout->Close(); }
void getResV(){ //------------------------Deal with the number and get the output stored in txt files and root files double Vmax[nbin], eps[nbin]; for(int ibin=0; ibin<nbin ;ibin++){ Vmax[ibin]=0.065*(trkbin[ibin]+30); eps[ibin]=0.00025*(trkbin[ibin]+30); } ofstream fstrV; double theta[ntheta]; TVectorD Gmod2[nbin][ntheta]; TVectorD sigma2[nbin],deltaV[nbin]; TVectorD r[nbin]; TVectorD r0[nbin], r01[nbin], V[nbin], chi[nbin]; TVectorD GRe[nbin][ntheta]; TVectorD* GRe_t[nbin][ntheta]; TVectorD GIm[nbin][ntheta]; TVectorD* GIm_t[nbin][ntheta]; TComplex G[nbin][ntheta][nstepr]; TF1 *ffit[nbin]; TF1 *ffit0[nbin][ntheta]; if(isSum) fstrV.open("V_Sum.txt"); else fstrV.open("V_Prod.txt"); TFile *f[nFileAll]; for(int ibin=0; ibin<nbin; ibin++){ r[ibin].ResizeTo(nstepr); for(int ir=0; ir<nstepr; ir++){ if(isSimple==0) r[ibin][ir]=j01/(Vmax[ibin]-eps[ibin]*ir); else r[ibin][ir]=0.00025*20*(ir+1); } } TVectorD Nevent; Nevent.ResizeTo(nbin); Nevent.Zero(); TVectorD totmultall; totmultall.ResizeTo(nbin); totmultall.Zero(); TVectorD avgmultall; avgmultall.ResizeTo(nbin); avgmultall.Zero(); TVectorD tottrk; tottrk.ResizeTo(nbin); tottrk.Zero(); TVectorD totptall; totptall.ResizeTo(nbin); totptall.Zero(); TVectorD totetaall; totetaall.ResizeTo(nbin); totetaall.Zero(); TVectorD avgtrk; avgtrk.ResizeTo(nbin); avgtrk.Zero(); TVectorD deltaVmean; deltaVmean.ResizeTo(nbin); TVectorD Vmean; Vmean.ResizeTo(nbin); TVectorD avgpt; avgpt.ResizeTo(nbin); TVectorD avgeta; avgeta.ResizeTo(nbin); TVectorD Qx1; Qx1.ResizeTo(nbin); Qx1.Zero(); TVectorD Qy1; Qy1.ResizeTo(nbin); Qy1.Zero(); TVectorD Q2; Q2.ResizeTo(nbin); Q2.Zero(); TVectorD sigma2_; sigma2_.ResizeTo(nbin); sigma2_.Zero(); TVectorD chi_; chi_.ResizeTo(nbin); chi_.Zero(); TH1D* hq[nbin][ntheta]; TH1D* hqx[nbin]; TH1D* hqy[nbin]; TH1D* hq2[nbin]; TH1D* hq2nonf[nbin]; for(int itheta=0;itheta<ntheta;itheta++) theta[itheta]=itheta*TMath::Pi()/ntheta/nn; for(int ibin=0;ibin<nbin;ibin++){ r0[ibin].ResizeTo(ntheta); r01[ibin].ResizeTo(ntheta); sigma2[ibin].ResizeTo(ntheta); V[ibin].ResizeTo(ntheta); deltaV[ibin].ResizeTo(ntheta); chi[ibin].ResizeTo(ntheta); for(int itheta=0;itheta<ntheta;itheta++){ Gmod2[ibin][itheta].ResizeTo(nstepr); GRe[ibin][itheta].ResizeTo(nstepr); GRe[ibin][itheta].Zero(); GIm[ibin][itheta].ResizeTo(nstepr); GIm[ibin][itheta].Zero(); hq[ibin][itheta] = new TH1D(Form("hq"),Form("hq"),1000,0,10); } hqx[ibin] = new TH1D(Form("hqx"),Form("hqx"),1000,0,10); hqy[ibin] = new TH1D(Form("hqy"),Form("hqy"),1000,0,10); hq2[ibin] = new TH1D(Form("hq2"),Form("hq2"),1000,0,10); hq2nonf[ibin] = new TH1D(Form("hq2nonf"),Form("hq2nonf"),1000,0,10); } for(int ifile=0; ifile<nFileAll; ifile++){ if(isSum) f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/Bessfun/pPbDataV200m30/AnaV_Sum_%d.root",ifile)); else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/Bessfun/pPbDataV200m30/AnaV_Prod_%d.root",ifile)); TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get(Form("Nevent")); TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get(Form("totmultall")); TVectorD* tottrk_t = (TVectorD*)f[ifile]->Get(Form("tottrk")); TVectorD* totptall_t = (TVectorD*)f[ifile]->Get(Form("totptall")); TVectorD* totetaall_t = (TVectorD*)f[ifile]->Get(Form("totetaall")); TVectorD* Qx1_t = (TVectorD*)f[ifile]->Get(Form("Qx1")); TVectorD* Qy1_t = (TVectorD*)f[ifile]->Get(Form("Qy1")); TVectorD* Q2_t = (TVectorD*)f[ifile]->Get(Form("Q2")); for(int ibin=0;ibin<nbin;ibin++){ TH1D* hqx_t = (TH1D*)f[ifile]->Get(Form("hqx_%d",ibin)); hqx[ibin]->Add(hqx_t); TH1D* hqy_t = (TH1D*)f[ifile]->Get(Form("hqy_%d",ibin)); hqy[ibin]->Add(hqy_t); TH1D* hq2_t = (TH1D*)f[ifile]->Get(Form("hq2_%d",ibin)); hq2[ibin]->Add(hq2_t); TH1D* hq2nonf_t = (TH1D*)f[ifile]->Get(Form("hq2nonf_%d",ibin)); hq2nonf[ibin]->Add(hq2nonf_t); for(int itheta=0;itheta<ntheta;itheta++){ GRe_t[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("GRe_%d_%d",ibin,itheta)); GIm_t[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("GIm_%d_%d",ibin,itheta)); TH1D* hq_t = (TH1D*)f[ifile]->Get(Form("hq_%d_%d",ibin,itheta)); hq[ibin][itheta]->Add(hq_t); for(ir=0; ir<nstepr; ir++){ GRe[ibin][itheta][ir] += (*GRe_t[ibin][itheta])[ir]; GIm[ibin][itheta][ir] += (*GIm_t[ibin][itheta])[ir]; } } Qx1[ibin] += (*Qx1_t)[ibin]; Qy1[ibin] += (*Qy1_t)[ibin]; Q2[ibin] += (*Q2_t)[ibin]; totptall[ibin] += (*totptall_t)[ibin]; totetaall[ibin] += (*totetaall_t)[ibin]; Nevent[ibin] += (*Nevent_t)[ibin]; totmultall[ibin] += (*totmultall_t)[ibin]; tottrk[ibin] += (*tottrk_t)[ibin]; } f[ifile]->Close(); } fstrV<<setprecision(4)<<fixed; fstrV<<"ibin"<<"\t"<<"itheta"<<"\t"<<"r0"<<"\t"<<"V"<<"\t"<<"sigma2"<<"\t"<<"chi"<<"\t"<<"Vn Errors"<<endl; for(int ibin=0;ibin<nbin;ibin++){ avgmultall[ibin]=totmultall[ibin]/Nevent[ibin]; avgtrk[ibin]=tottrk[ibin]/Nevent[ibin]; for(int itheta=0;itheta<ntheta;itheta++){ for(ir=0; ir<nstepr; ir++){ G[ibin][itheta][ir]=TComplex(GRe[ibin][itheta][ir],GIm[ibin][itheta][ir]); G[ibin][itheta][ir]/=Nevent[ibin]; Gmod2[ibin][itheta][ir]=TMath::Power(TComplex::Abs(G[ibin][itheta][ir]),2); } for(ir=0; ir<nstepr-1; ir++) if(ir!=0 && Gmod2[ibin][itheta][ir]<=Gmod2[ibin][itheta][ir-1] && Gmod2[ibin][itheta][ir]<=Gmod2[ibin][itheta][ir+1]) break; if(ir!=0 && ir<nstepr-1) r01[ibin][itheta]=r[ibin][ir]; else if(ir==0) {cout<<"ibin="<<ibin<<"\t"<<"itheta="<<itheta<<"\tminimum lies on ir = 0, please select proper range!"<<endl; continue;} else {cout<<"ibin="<<ibin<<"\t"<<"itheta="<<itheta<<"\tminimum lies on ir = maximum "<<nstepr-1<<", please select proper range!"<<endl; continue;} avgpt[ibin]=1.0*totptall[ibin]/totmultall[ibin]; avgeta[ibin]=1.0*totetaall[ibin]/totmultall[ibin]; if(isSimple==0) V[ibin][itheta]=Vmax[ibin]-ir*eps[ibin]+eps[ibin]*(Gmod2[ibin][itheta][ir+1]-Gmod2[ibin][itheta][ir-1])/2./(Gmod2[ibin][itheta][ir-1]-2*Gmod2[ibin][itheta][ir]+Gmod2[ibin][itheta][ir+1]); else V[ibin][itheta]=j01/r01[ibin][itheta]; //simple method r0[ibin][itheta]=j01/V[ibin][itheta]; V[ibin][itheta]/=avgmultall[ibin]; sigma2[ibin][itheta]=Q2[ibin]/Nevent[ibin]-(Qx1[ibin]/Nevent[ibin])*(Qx1[ibin]/Nevent[ibin])-(Qy1[ibin]/Nevent[ibin])*(Qy1[ibin]/Nevent[ibin]); sigma2_[ibin]+=sigma2[ibin][itheta]; Vmean[ibin]+=V[ibin][itheta]; chi[ibin][itheta]=V[ibin][itheta]*avgmultall[ibin]/TMath::Sqrt(sigma2[ibin][itheta]); } //deltaVmean[ibin]+=TMath::Exp(j01*j01/2./chi[ibin][itheta]/chi[ibin][itheta]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Exp(-j01*j01/2./chi[ibin][itheta]/chi[ibin][itheta]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)); sigma2_[ibin]/=ntheta; Vmean[ibin]/=ntheta; sigma2_[ibin]-=TMath::Power(Vmean[ibin]*avgmultall[ibin],2); chi_[ibin]=Vmean[ibin]*avgmultall[ibin]/TMath::Sqrt(sigma2_[ibin]); for(int itheta=0;itheta<ntheta;itheta++){ deltaV[ibin][itheta]=V[ibin][itheta]/j01/TMath::BesselJ1(j01)*TMath::Sqrt((TMath::Exp(j01*j01/2./chi_[ibin]/chi_[ibin])+TMath::Exp(-j01*j01/2./chi_[ibin]/chi_[ibin])*TMath::BesselJ0(2*j01))/2./Nevent[ibin]); deltaVmean[ibin]+=TMath::Exp(j01*j01/2./chi_[ibin]/chi_[ibin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Exp(-j01*j01/2./chi_[ibin]/chi_[ibin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)); fstrV<<ibin<<"\t"<<itheta<<"\t"<<r0[ibin][itheta]<<"\t"<<V[ibin][itheta]<<"\t"<<sigma2[ibin][itheta]<<"\t"<<chi[ibin][itheta]<<"\t"<<deltaV[ibin][itheta]<<endl; } fstrV<<"\t\t\t\t\t"<<sigma2_[ibin]<<"\t"<<chi_[ibin]<<endl; deltaVmean[ibin]=Vmean[ibin]/j01/TMath::BesselJ1(j01)*TMath::Sqrt(deltaVmean[ibin]/ntheta/2./Nevent[ibin]); fstrV<<endl; } fstrV<<"ibin"<<"\t"<<"avgmult"<<"\t"<<"avgpt"<<"\t"<<"avgeta"<<"\t"<<"Vn mean"<<"\t"<<"Vn mean Error"<<endl; for(int ibin=0;ibin<nbin;ibin++){ fstrV<<ibin<<"\t"<<avgmultall[ibin]<<"\t"<<avgpt[ibin]<<"\t"<<avgeta[ibin]<<"\t"<<Vmean[ibin]<<"\t"<<deltaVmean[ibin]<<endl; fstrV<<endl; } fstrV<<"ibin"<<"\t"<<"Nevent"<<"\t"<<"totmultall"<<"\t"<<"avgmultall"<<"\t"<<"avgtrk"<<endl; for(int ibin=0;ibin<nbin;ibin++){ fstrV<<ibin<<"\t"<<Nevent[ibin]<<"\t"<<totmultall[ibin]<<"\t"<<avgmultall[ibin]<<"\t"<<avgtrk[ibin]<<endl; fstrV<<endl; } if(isSum) TString outname = "mergedV_Sum.root"; else TString outname="mergedV_Prod.root"; TFile *outf = new TFile(outname,"Recreate"); Nevent.Write("Nevent"); totmultall.Write("totmultall"); avgmultall.Write("avgmultall"); tottrk.Write("tottrk"); avgtrk.Write("avgtrk"); Qx1.Write("Qx1"); Qy1.Write("Qy1"); Q2.Write("Q2"); avgpt.Write("avgpt"); avgeta.Write("avgeta"); Vmean.Write("Vmean"); deltaVmean.Write("deltaVmean"); chi_.Write("chi"); sigma2_.Write("sigma2"); for(int ibin=0;ibin<nbin;ibin++){ TDirectory *dir0 = outf->mkdir(Form("D_%d",ibin));dir0->cd(); r[ibin].Write("r"); sigma2[ibin].Write("sigma2"); chi[ibin].Write("chi0"); deltaV[ibin].Write("deltaV"); r0[ibin].Write("r0"); r01[ibin].Write("r01"); V[ibin].Write("V"); hqx[ibin]->Write(); hqy[ibin]->Write();hq2[ibin]->Write();hq2nonf[ibin]->Write(); for(int itheta=0;itheta<ntheta;itheta++){ TDirectory *dir1 = dir0->mkdir(Form("D_%d",itheta));dir1->cd(); GRe[ibin][itheta].Write(Form("GRe")); GIm[ibin][itheta].Write(Form("GIm")); Gmod2[ibin][itheta].Write(Form("G2")); hq[ibin][itheta]->Write(); } } outf->Close(); }
void getResvsub(int ispt=1){ double theta[ntheta]; TFile *f[nFileAll]; for(int itheta=0;itheta<ntheta;itheta++) theta[itheta]=itheta*TMath::Pi()/ntheta/nn; int nvv; const double *binv; if(ispt){ nvv = nptv; binv = ptbinv;} else{ nvv = netav; binv = etabinv;} string SumorProd = getenv("SUMORPROD"); string mdir = getenv("DIR"); ofstream fstrv; if(ispt){ if(SumorProd=="Sum")fstrv.open("v_sub.txt"); else fstrv.open("v_2_sub.txt"); } else{ if(SumorProd=="Sum")fstrv.open("v_eta_sub.txt"); else fstrv.open("v_2_coarse_eta_sub.txt"); } TVectorD Nevent[nbin], totmultall[nbin], totmultall_[nbin]; TVectorD totmult[nbin], totpt[nbin],toteta[nbin]; TVectorD totmulthisto[nbin], totmulthistocorr[nbin]; TVectorD V_int[nbin], V_interr[nbin]; TVectorD V_intcorr[nbin], V_intcorrerr[nbin]; TVectorD* V_mean; TVectorD* deltaV_mean; TVectorD vmeanmean[nbin], deltavmeanmean[nbin], sigmavmeanmean[nbin], avgavgpt[nbin], avgavgeta[nbin]; TVectorD* V[nbin]; TVectorD* chi[nbin]; TVectorD* dDRe[nbin]; TVectorD* dDIm[nbin]; TVectorD* dNRe[nbin][ntheta]; TVectorD* dNIm[nbin][ntheta]; TComplex dD[nbin][ntheta], dN[nbin][ntheta][nvv]; TVectorD avgmult[nbin]; TVectorD avgmultall; TVectorD avgpt[nbin],avgeta[nbin]; TVectorD v[nbin][ntheta],vmean[nbin],deltav[nbin][ntheta],deltavmean[nbin]; TVectorD IFILE[nbin]; if(SumorProd=="Sum") TFile *infile = TFile::Open("mergedV_Sum.root"); else TFile *infile = TFile::Open("mergedV_Prod.root"); if(ispt){ if(SumorProd=="Sum")TFile *fout = new TFile("mergedv_Prod_sub.root","Recreate"); else TFile *fout = new TFile("mergedv_Prod2_sub.root","Recreate"); } else{ if(SumorProd=="Sum")TFile *fout = new TFile("mergedv_Prod_eta_sub.root","Recreate"); else TFile *fout = new TFile("mergedv_Prod2_coarse_eta_sub.root","Recreate"); } TVectorD Nevent_; Nevent_.ResizeTo(nbin); Nevent_.Zero(); TH1D* hpt[nbin]; TH1D* hpteffcorr[nbin]; for(int ibin=0;ibin<nbin;ibin++){ for(int ifile=0; ifile<nFileAll; ifile++){ if(ispt){ if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/%s/Anav_Prod_%d.root",mdir.c_str(),ifile)); else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/%s/Anav_Prod2_%d.root",mdir.c_str(),ifile)); } else{ if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6c/coarsebins/%s/Anaveta_Prod_%d.root",mdir.c_str(),ifile)); else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/coarsebins/%s/Anaveta_Prod2_%d.root",mdir.c_str(),ifile)); } TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get(Form("Nevent")); Nevent_[ibin]+=(*Nevent_t)[ibin]; f[ifile]->Close(); } IFILE[ibin].ResizeTo(nsamples); Nevent[ibin].ResizeTo(nsamples); Nevent[ibin].Zero(); totmultall[ibin].ResizeTo(nsamples); totmultall[ibin].Zero(); totmultall_[ibin].ResizeTo(nsamples); totmultall_[ibin].Zero(); TDirectory *dir0 = fout->mkdir(Form("D_%d",ibin)); vmeanmean[ibin].ResizeTo(nvv); vmeanmean[ibin].Zero(); deltavmeanmean[ibin].ResizeTo(nvv); deltavmeanmean[ibin].Zero(); sigmavmeanmean[ibin].ResizeTo(nvv); sigmavmeanmean[ibin].Zero(); avgavgpt[ibin].ResizeTo(nvv); avgavgpt[ibin].Zero(); avgavgeta[ibin].ResizeTo(nvv); avgavgeta[ibin].Zero(); V_interr[ibin].ResizeTo(nsamples); V_interr[ibin].Zero(); V_int[ibin].ResizeTo(nsamples); V_int[ibin].Zero(); if(ispt){ V_intcorr[ibin].ResizeTo(nsamples); V_intcorr[ibin].Zero(); V_intcorrerr[ibin].ResizeTo(nsamples); V_intcorrerr[ibin].Zero(); } for(int isample=0;isample<nsamples;isample++){ TVectorD Nevent0; Nevent0.ResizeTo(nbin); Nevent0.Zero(); avgmultall.ResizeTo(nbin); totmult[ibin].ResizeTo(nvv); totmult[ibin].Zero(); if(ispt){ totmulthisto[ibin].ResizeTo(nvv); totmulthisto[ibin].Zero(); totmulthistocorr[ibin].ResizeTo(nvv);totmulthistocorr[ibin].Zero(); } avgmult[ibin].ResizeTo(nvv); avgpt[ibin].ResizeTo(nvv); avgeta[ibin].ResizeTo(nvv); totpt[ibin].ResizeTo(nvv); totpt[ibin].Zero(); toteta[ibin].ResizeTo(nvv); toteta[ibin].Zero(); vmean[ibin].ResizeTo(nvv); deltavmean[ibin].ResizeTo(nvv); V[ibin] = (TVectorD*) infile->Get(Form("D_%d/V",ibin,isample)); chi[ibin] = (TVectorD*) infile->Get(Form("chi",ibin,isample)); V_mean = (TVectorD*) infile->Get(Form("Vmean",ibin,isample)); deltaV_mean = (TVectorD*) infile->Get(Form("deltaVmean",ibin,isample)); for(int itheta=0;itheta<ntheta;itheta++){ v[ibin][itheta].ResizeTo(nvv); deltav[ibin][itheta].ResizeTo(nvv); dD[ibin][itheta]=0; for(int ivbin=0;ivbin<nvv;ivbin++){ dN[ibin][itheta][ivbin]=0; } } for(int ifile=0; ifile<nFileAll; ifile++){ if(ispt){ if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/%s/Anav_Prod_%d.root",mdir.c_str(),ifile)); else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/%s/Anav_Prod2_%d.root",mdir.c_str(),ifile)); } else{ if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/coarsebins/%s/Anaveta_Prod_%d.root",mdir.c_str(),ifile)); else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/coarsebins/%s/Anaveta_Prod2_%d.root",mdir.c_str(),ifile)); } TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get("Nevent"); TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get("totmultall"); Nevent0[ibin] += (*Nevent_t)[ibin]; double start=isample*Nevent_[ibin]/nsamples; double end=(isample+1)*Nevent_[ibin]/nsamples; if(Nevent0[ibin]>start && Nevent0[ibin]<=end){ IFILE[ibin][isample]=(double)ifile; Nevent[ibin][isample] += (*Nevent_t)[ibin]; TVectorD* totmult_t = (TVectorD*)f[ifile]->Get(Form("totmult_%d",ibin)); TVectorD* totpt_t = (TVectorD*)f[ifile]->Get(Form("totpt_%d",ibin)); TVectorD* toteta_t = (TVectorD*)f[ifile]->Get(Form("toteta_%d",ibin)); dDRe[ibin] = (TVectorD*)f[ifile]->Get(Form("dDRe_%d",ibin)); dDIm[ibin] = (TVectorD*)f[ifile]->Get(Form("dDIm_%d",ibin)); totmultall[ibin][isample]+=(*totmultall_t)[ibin]; for(int ivbin=0;ivbin<nvv;ivbin++){ totmult[ibin][ivbin]+=(*totmult_t)[ivbin]; totpt[ibin][ivbin]+=(*totpt_t)[ivbin]; toteta[ibin][ivbin]+=(*toteta_t)[ivbin]; } for(int itheta=0;itheta<ntheta;itheta++){ dNRe[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNRe_%d_%d",ibin,itheta)); dNIm[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNIm_%d_%d",ibin,itheta)); dD[ibin][itheta]+=TComplex((*dDRe[ibin])[itheta],(*dDIm[ibin])[itheta]); for(int ivbin=0;ivbin<nvv;ivbin++){ if(ifile<188) dN[ibin][itheta][ivbin]+=TComplex((*dNRe[ibin][itheta])[ivbin],(*dNIm[ibin][itheta])[ivbin]); else dN[ibin][itheta][nvv-ivbin-1]+=TComplex((*dNRe[ibin][itheta])[ivbin],(*dNIm[ibin][itheta])[ivbin]); } } } f[ifile]->Close(); } TFile *fhisto = TFile::Open("histomerged.root"); TFile *feff = TFile::Open("/home/xuq7/HI/flow/LYZ/v2/TrackCorrections_HIJING_538_OFFICIAL_Mar24.root"); TH2F* heff = (TH2F*)feff->Get("rTotalEff3D"); TH1D* hpteff = (TH1D*)heff->ProjectionY("hpteff",heff->GetXaxis()->FindBin(-2.4),heff->GetXaxis()->FindBin(2.4)-1,"o"); TArrayD *ptarr = (TArrayD*)heff->GetYaxis()->GetXbins(); double *ptbinhisto = ptarr->GetArray(); int NbinX = heff->GetXaxis()->GetNbins(); int NbinY = heff->GetYaxis()->GetNbins(); hpteff->Scale(1.0/NbinX); for(int itheta=0;itheta<ntheta;itheta++) dD[ibin][itheta]*=TComplex::Power(TComplex::I(),mm-1)/(Double_t)Nevent[ibin][isample]; avgmultall[ibin]=1.0*totmultall[ibin][isample]/Nevent[ibin][isample]; hpt[ibin] = (TH1D*)fhisto->Get(Form("D_%d/hpt",ibin)); //TH1D* hptre = (TH1D*)hpt[ibin]->Rebin(NbinY,"hptre",ptbinhisto); //hpteffcorr[ibin] = (TH1D*)hptre->Clone(Form("hpteffcorr_%d",ibin)); //hpteffcorr[ibin]->Divide(hpteff); for(int ivbin=0;ivbin<nvv; ivbin++){ vmean[ibin][ivbin]=0; deltavmean[ibin][ivbin]=0; avgmult[ibin][ivbin]=1.0*totmult[ibin][ivbin]/Nevent[ibin][isample]; avgpt[ibin][ivbin]=1.0*totpt[ibin][ivbin]/totmult[ibin][ivbin]; avgeta[ibin][ivbin]=1.0*toteta[ibin][ivbin]/totmult[ibin][ivbin]; for(int itheta=0;itheta<ntheta;itheta++){ dN[ibin][itheta][ivbin]/=totmult[ibin][ivbin]; TComplex Res=dN[ibin][itheta][ivbin]/dD[ibin][itheta]; v[ibin][itheta][ivbin]=(*V[ibin])[itheta]*avgmultall[ibin]*TMath::BesselJ1(j01)/Besselj01(mm)*Res.Re(); vmean[ibin][ivbin]+=v[ibin][itheta][ivbin]; deltav[ibin][itheta][ivbin]=TMath::Cos(mm*nn*theta[itheta])/totmult[ibin][ivbin]*(TMath::Exp(j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Power(-1,mm)*TMath::Exp(-j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.))); deltavmean[ibin][ivbin]+=deltav[ibin][itheta][ivbin]; // fstrv<<itheta<<"\t"<<v[ibin][itheta][ivbin]<<"\t"<<deltav[ibin][itheta][ivbin]<<endl; } deltavmean[ibin][ivbin]=TMath::Sqrt(deltavmean[ibin][ivbin])/2./Besselj01(mm); //fstrv<<endl; vmean[ibin][ivbin]/=ntheta; deltavmean[ibin][ivbin]/=TMath::Sqrt(ntheta); fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t"<<vmean[ibin][ivbin]<<"\t"<<deltavmean[ibin][ivbin]<<endl; if(ispt){ if(binv[ivbin+1]>3.0) continue; totmulthisto[ibin][ivbin]=hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(binv[ivbin]),hpt[ibin]->GetXaxis()->FindBin(binv[ivbin+1])-1); // totmulthistocorr[ibin][ivbin]=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[ivbin]),hpteffcorr[ibin]->GetXaxis()->FindBin(binv[ivbin+1])-1); totmulthistocorr[ibin][ivbin]=totmulthisto[ibin][ivbin]/hpteff->GetBinContent(hpteff->FindBin((binv[ivbin]+binv[ivbin+1])/2)); V_int[ibin][isample]+=vmean[ibin][ivbin]*totmult[ibin][ivbin]; V_interr[ibin][isample]+=deltavmean[ibin][ivbin]*totmult[ibin][ivbin]; V_intcorr[ibin][isample]+=vmean[ibin][ivbin]*totmulthistocorr[ibin][ivbin]; V_intcorrerr[ibin][isample]+=deltavmean[ibin][ivbin]*totmulthistocorr[ibin][ivbin]; } totmultall_[ibin][isample]+=totmult[ibin][ivbin]; } V_int[ibin][isample]/=totmultall_[ibin][isample]; V_interr[ibin][isample]/=totmultall_[ibin][isample]; //V_intcorr[ibin][isample]/=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1); //V_intcorr[ibin][isample]/=totmulthistocorr[ibin]; //V_intcorrerr[ibin][isample]/=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1); if(ispt){ fstrv<<endl<<"pt range\t\t"<<"totmult"<<"\t\t"<<"totmult from histo"<<"\t"<<"totmult corrected"<<endl; for(int ivbin=0;ivbin<nvv; ivbin++){ fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t\t"<<totmult[ibin][ivbin]<<"\t"<<totmulthisto[ibin][ivbin]<<"\t"<<totmulthistocorr[ibin][ivbin]<<endl; } //fstrv<<"Integral\t\t"<<totmultall[ibin][isample]<<"\t"<<hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(binv[0]),hpt[ibin]->GetXaxis()->FindBin(3.0)-1)<<"\t"<<hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1)<<endl; fstrv<<"V ref="<<(*V_mean)[ibin]<<"\t"<<"V int="<<V_int[ibin][isample]<<"\t"<<"V int corr="<<V_intcorr[ibin][isample]<<endl; fstrv<<"V ref err="<<(*deltaV_mean)[ibin]<<"\t"<<"V int err="<<V_interr[ibin][isample]<<"\t"<<"V int corr err="<<V_intcorrerr[ibin][isample]<<endl; } TDirectory *dirsample = dir0->mkdir(Form("s_%d",isample)); dirsample->cd(); avgpt[ibin].Write("avgpt"); avgeta[ibin].Write("avgeta"); totmult[ibin].Write("totmult"); vmean[ibin].Write("vmean"); deltavmean[ibin].Write("deltavmean"); for(int ivbin=0;ivbin<nvv; ivbin++){ avgavgpt[ibin][ivbin]+=avgpt[ibin][ivbin]*Nevent[ibin][isample]; avgavgeta[ibin][ivbin]+=avgeta[ibin][ivbin]*Nevent[ibin][isample]; vmeanmean[ibin][ivbin]+=vmean[ibin][ivbin]/nsamples; deltavmeanmean[ibin][ivbin]+=deltavmean[ibin][ivbin]/nsamples; sigmavmeanmean[ibin][ivbin]+=TMath::Power(vmean[ibin][ivbin]/nsamples,2); } }//subsample loop dir0->cd(); IFILE[ibin].Write("IFILE"); V_int[ibin].Write("V_int"); V_interr[ibin].Write("V_interr"); V_intcorr[ibin].Write("V_intcorr"); V_intcorrerr[ibin].Write("V_intcorrerr"); Nevent[ibin].Write("Nevent"); totmultall[ibin].Write("totmultall"); for(int ivbin=0;ivbin<nvv; ivbin++){ avgavgpt[ibin][ivbin]/=Nevent_[ibin]; avgavgeta[ibin][ivbin]/=Nevent_[ibin]; sigmavmeanmean[ibin][ivbin]=TMath::Sqrt(sigmavmeanmean[ibin][ivbin]*nsamples-vmeanmean[ibin][ivbin]*vmeanmean[ibin][ivbin])/TMath::Sqrt(nsamples); } avgavgpt[ibin].Write("avgavgpt"); avgavgeta[ibin].Write("avgavgeta"); vmeanmean[ibin].Write("vmeanmean"); deltavmeanmean[ibin].Write("deltavmeanmean"); sigmavmeanmean[ibin].Write("sigmavmeanmean"); }//ntrk bin loop infile->Close(); fout->Close(); }
void getResv2() { ifstream f_("merged.root"); if(!f_.good()) { system("hadd merged.root /scratch/xuq7/flow/EPAnalyzer/pPbDataV205m150/AnaEP_*.root"); } TFile *fmerged = TFile::Open("merged.root"); TH1D* hEPPhip[nbin][neta]; TH1D* hEPPhim[nbin][neta]; TH1D* hEPPhic[nbin][neta]; for(int ibin=0; ibin<nbin; ibin++) { for(int ieta=0; ieta<neta; ieta++) { hEPPhip[ibin][ieta] = (TH1D*)fmerged->Get(Form("hEPPhip_%d_%d",ibin,ieta)); hEPPhim[ibin][ieta] = (TH1D*)fmerged->Get(Form("hEPPhim_%d_%d",ibin,ieta)); hEPPhic[ibin][ieta] = (TH1D*)fmerged->Get(Form("hEPPhic_%d_%d",ibin,ieta)); } } ofstream fstrV; fstrV.open("v2.txt"); TFile *f[nFileAll]; TVectorD Nevent; Nevent.ResizeTo(nbin); Nevent.Zero(); TVectorD totmultall; totmultall.ResizeTo(nbin); totmultall.Zero(); TVectorD EPR[nbin], EPRpc[nbin], EPRpm[nbin], EPRcm[nbin]; for(int ibin=0; ibin<nbin; ibin++) { EPR[ibin].ResizeTo(neta); EPR[ibin].Zero(); EPRpc[ibin].ResizeTo(neta); EPRpc[ibin].Zero(); EPRpm[ibin].ResizeTo(neta); EPRpm[ibin].Zero(); EPRcm[ibin].ResizeTo(neta); EPRcm[ibin].Zero(); } TVectorD avgmult; avgmult.ResizeTo(nbin); TVectorD totmult[nbin], totpt[nbin], avgpt[nbin]; TVectorD Vobs[nbin][neta], Vcorr[nbin][neta], Vcorr3[nbin][neta]; for(int ibin=0; ibin<nbin; ibin++) { totmult[ibin].ResizeTo(npt); totmult[ibin].Zero(); totpt[ibin].ResizeTo(npt); totpt[ibin].Zero(); avgpt[ibin].ResizeTo(npt); avgpt[ibin].Zero(); for(int ieta=0; ieta<neta; ieta++) { Vobs[ibin][ieta].ResizeTo(npt); Vobs[ibin][ieta].Zero(); Vcorr[ibin][ieta].ResizeTo(npt); Vcorr[ibin][ieta].Zero(); Vcorr3[ibin][ieta].ResizeTo(npt); Vcorr3[ibin][ieta].Zero(); } } for(int ifile=0; ifile<nFileAll; ifile++) { f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/EPAnalyzer/pPbDataV205m150/AnaEP_%d.root",ifile)); TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get(Form("Nevent")); TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get(Form("totmultall")); for(int ibin=0; ibin<nbin; ibin++) { TVectorD* EPR_t = (TVectorD*)f[ifile]->Get(Form("EPR_%d",ibin)); TVectorD* EPRpc_t = (TVectorD*)f[ifile]->Get(Form("EPRpc_%d",ibin)); TVectorD* EPRpm_t = (TVectorD*)f[ifile]->Get(Form("EPRpm_%d",ibin)); TVectorD* EPRcm_t = (TVectorD*)f[ifile]->Get(Form("EPRcm_%d",ibin)); TVectorD* totmult_t = (TVectorD*)f[ifile]->Get(Form("totmult_%d",ibin)); TVectorD* totpt_t = (TVectorD*)f[ifile]->Get(Form("totpt_%d",ibin)); Nevent[ibin] += (*Nevent_t)[ibin]; totmultall[ibin] += (*totmultall_t)[ibin]; for(int iptbin=0; iptbin<npt; iptbin++) { totmult[ibin][iptbin] += (*totmult_t)[iptbin]; totpt[ibin][iptbin] += (*totpt_t)[iptbin]; } for(int ieta=0; ieta<neta; ieta++) { EPR[ibin][ieta] += (*EPR_t)[ieta]; EPRpc[ibin][ieta] += (*EPRpc_t)[ieta]; EPRpm[ibin][ieta] += (*EPRpm_t)[ieta]; EPRcm[ibin][ieta] += (*EPRcm_t)[ieta]; TVectorD* Vobs_t = (TVectorD*)f[ifile]->Get(Form("v2obs_%d_%d",ibin,ieta)); for(int iptbin=0; iptbin<npt; iptbin++) { Vobs[ibin][ieta][iptbin] += (*Vobs_t)[iptbin]; } } } f[ifile]->Close(); } TFile *outf = new TFile("mergedVobs.root","Recreate"); Nevent.Write("Nevent"); totmultall.Write("totmultall"); for(int ibin=0; ibin<nbin; ibin++) { for(int ieta=0; ieta<neta; ieta++) { hEPPhip[ibin][ieta]->Write(); hEPPhim[ibin][ieta]->Write(); hEPPhic[ibin][ieta]->Write(); } } fstrV<<setprecision(4)<<fixed; fstrV<<"ibin"<<"\t"<<"ieta"<<"\t"<<"iptbin"<<"\t"<<"avgpt"<<"\t"<<"v2obs"<<"\t"<<"v2corr"<<"\t"<<"v2corr3"<<endl; for(int ibin=0; ibin<nbin; ibin++) { avgmult[ibin]=(double)totmultall[ibin]/Nevent[ibin]; for(int iptbin=0; iptbin<npt; iptbin++) { avgpt[ibin][iptbin]=totpt[ibin][iptbin]/totmult[ibin][iptbin]; } for(int ieta=0; ieta<neta; ieta++) { //EPR[ibin][ieta]=EPR[ibin][ieta]/Nevent[ibin]; EPR[ibin][ieta]=TMath::Sqrt(EPR[ibin][ieta]/Nevent[ibin]); EPRpc[ibin][ieta]=EPRpc[ibin][ieta]/Nevent[ibin]; EPRcm[ibin][ieta]=EPRcm[ibin][ieta]/Nevent[ibin]; EPRpm[ibin][ieta]=EPRpm[ibin][ieta]/Nevent[ibin]; for(int iptbin=0; iptbin<npt; iptbin++) { Vobs[ibin][ieta][iptbin]/=totmult[ibin][iptbin]; Vcorr[ibin][ieta][iptbin]=Vobs[ibin][ieta][iptbin]/EPR[ibin][ieta]; Vcorr3[ibin][ieta][iptbin]=Vobs[ibin][ieta][iptbin]/sqrt(EPRpc[ibin][ieta]*EPRpm[ibin][ieta]/EPRcm[ibin][ieta]); fstrV<<trkbin[ibin+1]<<"-"<<trkbin[ibin]<<"\t"<<etap[ieta]<<"-"<<etan[ieta]<<"\t"<<ptbin[iptbin]<<"-"<<ptbin[iptbin+1]<<"\t"<<avgpt[ibin][iptbin]<<"\t"<<Vobs[ibin][ieta][iptbin]<<"\t"<<Vcorr[ibin][ieta][iptbin]<<"\t"<<Vcorr3[ibin][ieta][iptbin]<<endl; } fstrV<<endl; } TDirectory *dir0 = outf->mkdir(Form("D_%d",ibin)); dir0->cd(); totmult[ibin].Write("totmult"); avgpt[ibin].Write("avgpt"); EPR[ibin].Write("EPR"); EPRpc[ibin].Write("EPRpc"); EPRpm[ibin].Write("EPRpm"); EPRcm[ibin].Write("EPRcm"); for(int ieta=0; ieta<neta; ieta++) { TDirectory *dir1 = dir0->mkdir(Form("E_%d",ieta)); dir1->cd(); Vobs[ibin][ieta].Write("v2obs"); Vcorr[ibin][ieta].Write("v2"); Vcorr3[ibin][ieta].Write("v23sub"); } } outf->cd(); avgmult.Write("avgmult"); outf->Close(); remove("merged.root"); }
void Analyze(const TString mode="CLOSED", UShort_t maxH=6, Bool_t /*doLoops*/=false, Int_t ifile=0 ) { #ifdef __CINT__ gROOT->LoadMacro("correlations/Types.hh++"); gROOT->LoadMacro("correlations/Result.hh++"); gROOT->LoadMacro("correlations/QVector.hh++"); gROOT->LoadMacro("correlations/recursive/FromQVector.hh++"); gROOT->LoadMacro("correlations/recurrence/FromQVector.hh++"); gROOT->LoadMacro("correlations/closed/FromQVector.hh++"); gROOT->LoadMacro("correlations/test/ReadData.hh++"); #endif // --- Setup of harmonics, etc ------------------------------------- gRandom->SetSeed(54321); UShort_t emode = 0; if (mode.EqualTo("closed", TString::kIgnoreCase)) emode = 0; else if (mode.EqualTo("recurrence", TString::kIgnoreCase)) emode = 1; else if (mode.EqualTo("recursive", TString::kIgnoreCase)) emode = 2; else Warning("Analyze", "Mode %s unknown, assuming CLOSED", mode.Data()); correlations::QVector q[nbin]; correlations::FromQVector* c[nbin]; correlations::HarmonicVector h(maxH); for (UShort_t i = 0; i < maxH; i++) { // Generate random harmonicx // h[i] = -6 + gRandom->Integer(12); h[0] = 2; h[1] = -2; h[2] = 2; h[3] = -2; h[4] = 2; h[5] = -2; h[6] = -2; h[7] = 2; // Printf("h_%d:\t%d", i, h[i]); } // Resize the Q-vector to fit the harmonics for(int ibin=0;ibin<nbin;ibin++){ q[ibin] = correlations::QVector(0,0,false); q[ibin].resize(h); switch (emode) { case 0: c[ibin] = new correlations::closed::FromQVector(q[ibin]); break; case 1: c[ibin] = new correlations::recurrence::FromQVector(q[ibin]); break; case 2: c[ibin] = new correlations::recursive::FromQVector(q[ibin]); break; } } //Printf("Correlator: %s", c->name()); // --- Some histograms --------------------------------------------- TH1* sumreals[nbin]; TH1* sumimags[nbin]; TH1* weights[nbin]; TVectorD tottrk; TVectorD Nevent; tottrk.ResizeTo(nbin); tottrk.Zero(); Nevent.ResizeTo(nbin); Nevent.Zero(); //TH1* reals = new TH1D("reals", "Re(C{n})", maxH-2+1, 2+.5, maxH+1+.5); //TH1* imags = static_cast<TH1*>(reals->Clone("imags")); for(int ibin=0;ibin<nbin;ibin++){ sumreals[ibin] = new TH1D(Form("sumreals_%d",ibin), "Re(C{n})", maxH-2+1, 2+.5, maxH+1+.5); sumimags[ibin] = static_cast<TH1*>(sumreals[ibin]->Clone(Form("sumimags_%d",ibin))); weights[ibin] = static_cast<TH1*>(sumreals[ibin]->Clone(Form("weights_%d",ibin))); } TProfile* timing = new TProfile("timing", "Timing", maxH-2+1, 2+.5,maxH+1+.5); TH1* hs = new TH1I("harmonics", "Harmonics", maxH, 1.5, maxH+1.5); /*reals->SetFillColor(kGreen+1); reals->SetFillStyle(3001); reals->SetStats(0); imags->SetTitle("Im(C{n})"); imags->SetFillColor(kBlue+1); imags->SetFillStyle(3001); imags->SetStats(0); timing->SetFillColor(kRed+1); timing->SetFillStyle(3001); timing->SetStats(0); hs->SetFillColor(kMagenta+1); hs->SetFillStyle(3001); hs->SetStats(0);*/ for (UShort_t i = 0; i < maxH-1; i++) { TString label = TString::Format("C{%d}", i+2); // reals->GetXaxis()->SetBinLabel(i+1, label); // imags->GetXaxis()->SetBinLabel(i+1, label); timing->GetXaxis()->SetBinLabel(i+1, label); hs->GetXaxis()->SetBinLabel(i+1,Form("h_{%d}", i+1)); hs->SetBinContent(i+1, h[i]); } hs->GetXaxis()->SetBinLabel(maxH,Form("h_{%d}", maxH)); hs->SetBinContent(maxH, h[maxH-1]); TStopwatch timer; // --- Setup input ------------------------------------------------ TFile* file = TFile::Open(Form("%s/vndata_50k_%d.root",dir.Data(),ifile), "READ"); TTree* tree = static_cast<TTree*>(file->Get("tree")); // TArrayD phis(0); Int_t M; Float_t phi[10000],pt[10000],eta[10000]; // TArrayD weights(0); // Double_t phiR = 0; // TArrayD* pPhis = &phis; // TArrayD* pWeights = &weights; tree->SetBranchAddress("phig", phi); tree->SetBranchAddress("ptg",pt); tree->SetBranchAddress("etag",eta); tree->SetBranchAddress("n", &M); // tree->SetBranchAddress("weight", &pWeights); // tree->SetBranchAddress("event", &phiR); // --- The results ------------------------------------------------- const UShort_t nQ = maxH - 1; correlations::ResultVector qs[nbin]; for(int ibin=0;ibin<nbin;ibin++) qs[ibin] = correlations::ResultVector(nQ); // --- Event loop -------------------------------------------------- Int_t nEvents = tree->GetEntries(); for (Int_t event = 0; event < nEvents; event++) { tree->GetEntry(event); int ntrk = M; int xbin=-1; for(int j=0;j<nbin;j++) if(ntrk<trkbin[j]&&ntrk>=trkbin[j+1]) xbin=j; if(xbin<0 || xbin==nbin) continue; tottrk[xbin]+=ntrk; q[xbin].reset(); // printf("Event # %4u %4d particles ", event++, phis.GetSize()); for (UShort_t pa = 0; pa < M; pa++){ if(fabs(eta[pa])>etamax) continue; if(pt[pa]<ptmin||pt[pa]>ptmax) continue; //event selection // phis.Set(n,pPhis); q[xbin].fill(phi[pa], 1.); } for (UShort_t i = 0; i < nQ; i++) { UShort_t n = i + 2; // printf("%s%d", i == 0 ? "" : "..", n); timer.Reset(); timer.Start(); qs[xbin][i] += c[xbin]->calculate(n, h); timer.Stop(); timing->Fill(n+.5, timer.RealTime()); } // printf(" done\n"); Nevent[xbin]++; } file->Close(); for(int ibin=0;ibin<nbin;ibin++){ for (UShort_t i = 0; i < nQ; i++) { // UShort_t iq = i+2; // Double_t t = timing->GetBinContent(i+1); // correlations::Complex rc = qs[i].eval(); // Printf("QC{%2d}: %12g + %12gi <t>: %10gs", // iq, rc.real(), rc.imag(), t); // if(i==0)Printf("v2{%2d}: %3g\n",2,sqrt(qs[0].eval().real())); // if(i==2)Printf("v2{%2d}: %3g\n",4,TMath::Power(fabs(qs[2].eval().real()),1./4)); // if(i==4)Printf("v2{%2d}: %3g\n",6,TMath::Power(fabs(qs[4].eval().real()),1./6)); sumreals[ibin]->SetBinContent(i+1,qs[ibin][i]._sum.real()); sumimags[ibin]->SetBinContent(i+1,qs[ibin][i]._sum.imag()); weights[ibin]->SetBinContent(i+1,qs[ibin][i]._weights); //reals->SetBinContent(i+1, rc.real()); //imags->SetBinContent(i+1, rc.imag()); } } /* TCanvas* can = new TCanvas("C", "C"); can->SetTopMargin(0.15); can->SetBottomMargin(0.15); can->SetRightMargin(0.03); can->Divide(1,3, 0, 0); DrawInPad(can, 3, timing, true); DrawInPad(can, 1, reals); DrawInPad(can, 2, imags); can->cd(0); TLatex* ltx = new TLatex(0.5,0.995,c->name()); ltx->SetNDC(true); ltx->SetTextAlign(23); ltx->SetTextSize(0.04); ltx->Draw(); can->Modified(); can->Update(); can->cd(); */ TString out(mode); out.ToLower(); file = TFile::Open(Form("%s/%s_%d.root",outdir.Data(),out.Data(),ifile), "RECREATE"); for(int ibin=0;ibin<nbin;ibin++){ sumimags[ibin]->Write(); sumreals[ibin]->Write(); weights[ibin]->Write(); } Nevent.Write("Nevent"); tottrk.Write("tottrk"); timing->Write(); hs->Write(); file->Write(); file->Close(); for(int ibin=0;ibin<nbin;ibin++){ delete sumimags[ibin]; delete sumreals[ibin]; delete weights[ibin]; } delete timing; delete hs; }
void merge(){ TVectorD Nevent; Nevent.ResizeTo(nbin); Nevent.Zero(); // TVectorD totmultall; totmultall.ResizeTo(nbin); totmultall.Zero(); // TVectorD avgmultall; avgmultall.ResizeTo(nbin); avgmultall.Zero(); TVectorD tottrk; tottrk.ResizeTo(nbin); tottrk.Zero(); // TVectorD totptall; totptall.ResizeTo(nbin); totptall.Zero(); // TVectorD totetaall; totetaall.ResizeTo(nbin); totetaall.Zero(); TVectorD avgtrk; avgtrk.ResizeTo(nbin); avgtrk.Zero(); // TVectorD avgmult; avgmult.ResizeTo(nbin); TVectorD qc22, qc24, qc26, qc28; qc22.ResizeTo(nbin); qc22.Zero(); qc24.ResizeTo(nbin); qc24.Zero(); qc26.ResizeTo(nbin); qc26.Zero(); qc28.ResizeTo(nbin); qc28.Zero(); TVectorD c22, c24, c26, c28; c22.ResizeTo(nbin); c22.Zero(); c24.ResizeTo(nbin); c24.Zero(); c26.ResizeTo(nbin); c26.Zero(); c28.ResizeTo(nbin); c28.Zero(); TVectorD v22, v24, v26, v28; v22.ResizeTo(nbin); v22.Zero(); v24.ResizeTo(nbin); v24.Zero(); v26.ResizeTo(nbin); v26.Zero(); v28.ResizeTo(nbin); v28.Zero(); TH1* sumreals[nbin]; TH1* sumimags[nbin]; TH1* weights[nbin]; for(int ibin=0;ibin<nbin;ibin++){ sumreals[ibin] = new TH1D(Form("sumreals",ibin), "Re(C{n})", maxN-2+1, 2+.5, maxN+1+.5); sumimags[ibin] = static_cast<TH1*>(sumreals[ibin]->Clone(Form("sumimags",ibin))); weights[ibin] = static_cast<TH1*>(sumreals[ibin]->Clone(Form("weights",ibin))); } TFile *fout = new TFile(Form("%s_merged.root",method.Data()),"Recreate"); TFile *f[nFileAll]; for(int ifile=0; ifile<nFileAll; ifile++){ f[ifile] = TFile::Open(Form("%s/%s_%d.root",outdir.Data(),method.Data(),ifile)); TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get(Form("Nevent")); // TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get(Form("totmultall")); TVectorD* tottrk_t = (TVectorD*)f[ifile]->Get(Form("tottrk")); // TVectorD* totptall_t = (TVectorD*)f[ifile]->Get(Form("totptall")); // TVectorD* totetaall_t = (TVectorD*)f[ifile]->Get(Form("totetaall")); for(int ibin=0;ibin<nbin;ibin++){ // totptall[ibin] += (*totptall_t)[ibin]; // totetaall[ibin] += (*totetaall_t)[ibin]; Nevent[ibin] += (*Nevent_t)[ibin]; // totmultall[ibin] += (*totmultall_t)[ibin]; tottrk[ibin] += (*tottrk_t)[ibin]; TH1D* sumreals_t = (TH1D*)f[ifile]->Get(Form("sumreals_%d",ibin)); TH1D* sumimags_t = (TH1D*)f[ifile]->Get(Form("sumimags_%d",ibin)); TH1D* weights_t = (TH1D*)f[ifile]->Get(Form("weights_%d",ibin)); sumreals[ibin]->Add(sumreals_t); sumimags[ibin]->Add(sumimags_t); weights[ibin]->Add(weights_t); } f[ifile]->Close(); } cout<<"v2{gen} = "<<inV2<<endl; for(int ibin=0;ibin<nbin;ibin++){ avgtrk[ibin] = tottrk[ibin]/Nevent[ibin]; TH1D* hQCr = (TH1D*)sumreals[ibin]->Clone("hQCr"); TH1D* hQCi = (TH1D*)sumimags[ibin]->Clone("hQCi"); hQCr->Divide(weights[ibin]); hQCi->Divide(weights[ibin]); complex<double> qc22com(hQCr->GetBinContent(1),hQCi->GetBinContent(1)); complex<double> qc24com(hQCr->GetBinContent(3),hQCi->GetBinContent(3)); complex<double> qc26com(hQCr->GetBinContent(5),hQCi->GetBinContent(5)); qc22[ibin] = abs(qc22com); qc24[ibin] = abs(qc24com); qc26[ibin] = abs(qc26com); c22[ibin] = qc22[ibin]; c24[ibin] = qc24[ibin] - 2*qc22[ibin]*qc22[ibin]; c26[ibin] = qc26[ibin] - 9*qc22[ibin]*qc24[ibin] + 12*qc22[ibin]*qc22[ibin]*qc22[ibin]; v22[ibin] = sqrt(c22[ibin]); v24[ibin] = TMath::Power(-c24[ibin],1./4); v26[ibin] = TMath::Power(1./4*c26[ibin],1./6); //v24[ibin] = TMath::Power(qc24[ibin],1./4); //v26[ibin] = TMath::Power(qc26[ibin],1./6); cout<<"avgtrk = "<<avgtrk[ibin]<<endl; cout<<"v2{2} = "<<v22[ibin]<<endl; cout<<"v2{4} = "<<v24[ibin]<<endl; cout<<"v2{6} = "<<v26[ibin]<<endl; fout->cd(); Nevent.Write("Nevent"); avgtrk.Write("avgtrk"); qc22.Write("qc22"); qc24.Write("qc24"); qc26.Write("qc26"); qc28.Write("qc28"); c22.Write("c22"); c24.Write("c24"); c26.Write("c26"); c28.Write("c28"); v22.Write("v22"); v24.Write("v24"); v26.Write("v26"); v28.Write("v28"); TDirectory *dir0 = (TDirectory*)fout->mkdir(Form("D_%d",ibin)); dir0->cd(); sumreals[ibin]->Write(); sumimags[ibin]->Write(); weights[ibin]->Write(); } }
void plotqfit() { int xtheta=0; gStyle->SetOptStat(1011); gStyle->SetOptFit(1111); TFile *f = TFile::Open("mergedV_Sum.root"); TFile *fout = TFile::Open("qfitV.root","Recreate"); TVectorD *vecDavgmult = f->Get(Form("avgmultall")); TVectorD *vecDavgtrk = f->Get(Form("avgtrk")); double *avgmult = vecDavgmult->GetMatrixArray(); double *avgtrk = vecDavgtrk->GetMatrixArray(); TLatex *t= new TLatex(); t->SetNDC(); t->SetTextSize(0.04); t->SetTextFont(42); for(int ibin=0; ibin<nbin; ibin++) { //ibin<1 TH1D* hq = (TH1D*)f->Get(Form("D_%d/D_%d/hq",ibin,xtheta)); TH1D* hqx = (TH1D*)f->Get(Form("D_%d/hqx",ibin)); TH1D* hqy = (TH1D*)f->Get(Form("D_%d/hqy",ibin)); TH1D* hq2 = (TH1D*)f->Get(Form("D_%d/hq2",ibin)); TH1D* hq2nonf = (TH1D*)f->Get(Form("D_%d/hq2nonf",ibin)); //multiplyByBinCenter(hq); hq->Scale(1./hq->Integral(0,-1,"width")); //normalizeByBinWidth(hq); //multiplyByBinCenter(hqx); hqx->Scale(1./hqx->Integral(0,-1,"width")); //normalizeByBinWidth(hqx); //multiplyByBinCenter(hqy); hqy->Scale(1./hqy->Integral(0,-1,"width")); //normalizeByBinWidth(hqy); hq2->Scale(1./hq2->Integral(0,-1,"width")); hq2nonf->Scale(1./hq2nonf->Integral(0,-1,"width")); ffit = new TF1(Form("ffit"),"1./(0.5*(1+[0]))*TMath::Exp(-([1]*[1]*[2]+x*x)/(1+[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/(0.5*(1+[0])))",0,10); f1fit = new TF1(Form("f1fit"),"x/(0.5*(1+[0]))*TMath::Exp(-([1]*[1]*[2]+x*x)/(1+[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/(0.5*(1+[0])))",0,10); //ffit = new TF1(Form("ffit"),"1./([0])*TMath::Exp(-([1]*[1]*[2]+x*x)/(2*[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/([0]))",0,10); //f1fit = new TF1(Form("f1fit"),"x/([0])*TMath::Exp(-([1]*[1]*[2]+x*x)/(2*[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/([0]))",0,10); ffit->SetParNames("g2","v2","M"); f1fit->SetParNames("g2","v2","M"); //ffit->SetParNames("#sigma2","v2","M"); //f1fit->SetParNames("sigma2","v2","M"); ffit->SetParameters(0.1,0.05,avgmult[ibin]); f1fit->SetParameters(0.1,0.05,avgmult[ibin]); //ffit->FixParameter(1,0); //f1fit->FixParameter(1,0); //f1fit->FixParameter(0,0); ffit->FixParameter(2,avgmult[ibin]); f1fit->FixParameter(2,avgmult[ibin]); hq->Fit(Form("f1fit"),"R","P",0,10); TCanvas *c2 = new TCanvas("c2","c2",500,1000); c2->Divide(1,2); c2->cd(1)->SetLogy(); fixedFontHist(hqx,1.6,2.0); hqx->SetTitle(""); hqx->GetXaxis()->SetTitle("q_{x}"); hqx->GetYaxis()->SetTitle("#frac{dN}{dq_{x}}"); hqx->GetYaxis()->SetRangeUser(1e-10,1); hqx->Fit(Form("f1fit"),"R","",0,10); c2->cd(2)->SetLogy(); TH1D* hqx_cp = (TH1D*)hqx->Clone("hqx_cp"); fixedFontHist(hqx_cp,1.6,2.0); divideByBinCenter(hqx_cp); hqx_cp->GetYaxis()->SetTitle("#frac{dN}{q_{x}dq_{x}}"); hqx_cp->GetYaxis()->SetRangeUser(1e-10,10); hqx_cp->Fit(Form("ffit"),"R","",0,10); t->DrawLatex(0.5,0.2,Form("N_{trk}^{offline} = %.2f", avgtrk[ibin])); TCanvas *c3 = new TCanvas("c3","c3",500,1000); c3->Divide(1,2); c3->cd(1); fixedFontHist(hqy,1.6,2.0); hqy->SetTitle(""); hqy->GetXaxis()->SetTitle("q_{y}"); hqy->GetYaxis()->SetTitle("#frac{dN}{dq_{y}}"); hqy->GetYaxis()->SetRangeUser(0,1); hqy->SetMarkerStyle(24); hqy->SetMarkerSize(0.5); hqy->Fit(Form("f1fit"),"R","",0,10); hqy->Draw("Psame"); c3->cd(2)->SetLogy(); TH1D* hqy_cp = (TH1D*)hqy->Clone("hqy_cp"); fixedFontHist(hqy_cp,1.6,2.0); divideByBinCenter(hqy_cp); hqy_cp->GetYaxis()->SetTitle("#frac{dN}{q_{y}dq_{y}}"); hqy_cp->GetYaxis()->SetRangeUser(1e-10,10); hqy_cp->SetMarkerStyle(24); hqy_cp->SetMarkerSize(0.5); hqy_cp->Fit(Form("ffit"),"R","",0,10); hqy_cp->Draw("Psame"); t->DrawLatex(0.5,0.2,Form("N_{trk}^{offline} = %.2f",avgtrk[ibin])); TCanvas *c4 = new TCanvas("c4","c4",500,1000); c4->Divide(1,2); c4->cd(1); fixedFontHist(hq2,1.6,2.0); hq2->SetTitle(""); hq2->GetXaxis()->SetTitle("q_{2}"); hq2->GetYaxis()->SetTitle("#frac{dN}{dq_{2}}"); hq2->GetYaxis()->SetRangeUser(0,1); hq2->SetMarkerStyle(24); hq2->SetMarkerColor(4); hq2->SetLineColor(4); hq2->SetMarkerSize(0.5); hq2->Fit(Form("f1fit"),"R","",0,10); TVectorD vecr; vecr.ResizeTo(6); vecr[0]=f1fit->GetParameter(0); vecr[1]=f1fit->GetParError(0); vecr[2]=f1fit->GetParameter(1); vecr[3]=f1fit->GetParError(1); vecr[4]=avgmult[ibin]; vecr[5]=avgtrk[ibin]; hq2->Draw("Psame"); c4->cd(2)->SetLogy(); TH1D* hq2_cp = (TH1D*)hq2->Clone("hq2_cp"); fixedFontHist(hq2_cp,1.6,2.0); divideByBinCenter(hq2_cp); hq2_cp->GetYaxis()->SetTitle("#frac{dN}{q_{2}dq_{2}}"); hq2_cp->GetYaxis()->SetRangeUser(1e-10,10); hq2_cp->SetMarkerStyle(24); hq2_cp->SetMarkerColor(4); hq2_cp->SetLineColor(4); hq2_cp->SetMarkerSize(0.5); hq2_cp->Fit(Form("ffit"),"R","",0,10); hq2_cp->Draw("Psame"); t->DrawLatex(0.5,0.2,Form("N_{trk}^{offline} = %.2f", avgtrk[ibin])); TCanvas *c5 = new TCanvas("c5","c5",500,1000); c5->Divide(1,2); c5->cd(1); fixedFontHist(hq2nonf,1.6,2.0); hq2nonf->SetTitle(""); hq2nonf->GetXaxis()->SetTitle("q_{2}"); hq2nonf->GetYaxis()->SetTitle("#frac{dN}{dq_{2}}"); hq2nonf->GetYaxis()->SetRangeUser(0,1); hq2nonf->SetMarkerStyle(24); hq2nonf->SetMarkerColor(4); hq2nonf->SetLineColor(4); hq2nonf->SetMarkerSize(0.5); ffit->SetParameters(1.5,0.05,avgmult[ibin]*2); f1fit->SetParameters(1.5,0.05,avgmult[ibin]*2); ffit->FixParameter(2,avgmult[ibin]*2); f1fit->FixParameter(2,avgmult[ibin]*2); //ffit->FixParameter(1,0); //f1fit->FixParameter(1,0); //ffit->FixParameter(0,1); //f1fit->FixParameter(0,1); hq2nonf->Fit(Form("f1fit"),"R","",0,10); TVectorD vecrnonf; vecrnonf.ResizeTo(6); vecrnonf[0]=f1fit->GetParameter(0); vecrnonf[1]=f1fit->GetParError(0); vecrnonf[2]=f1fit->GetParameter(1); vecrnonf[3]=f1fit->GetParError(1); vecrnonf[4]=avgmult[ibin]; vecrnonf[5]=avgtrk[ibin]; hq2nonf->Draw("Psame"); c5->cd(2)->SetLogy(); TH1D* hq2nonf_cp = (TH1D*)hq2nonf->Clone("hq2nonf_cp"); fixedFontHist(hq2nonf_cp,1.6,2.0); divideByBinCenter(hq2nonf_cp); hq2nonf_cp->GetYaxis()->SetTitle("#frac{dN}{q_{2}dq_{2}}"); hq2nonf_cp->GetYaxis()->SetRangeUser(1e-10,10); hq2nonf_cp->SetMarkerStyle(24); hq2nonf_cp->SetMarkerColor(4); hq2nonf_cp->SetLineColor(4); hq2nonf_cp->SetMarkerSize(0.5); hq2nonf_cp->Fit(Form("ffit"),"R","",0,10); hq2nonf_cp->Draw("Psame"); t->DrawLatex(0.5,0.2,Form("N_{trk}^{offline} = %.2f", avgtrk[ibin]*2)); fout->cd(); vecr.Write(Form("r_%d",ibin)); vecrnonf.Write(Form("rnonf_%d",ibin)); } /* c2->Print("hqx_fit.png"); c3->Print("hqy_fit.png"); c4->Print("hq2_fit.png"); c5->Print("hq2nonf_fit.png"); */ }
void getResv(){ double theta[ntheta]; TFile *f[nFileAll]; for(int itheta=0;itheta<ntheta;itheta++) theta[itheta]=itheta*TMath::Pi()/ntheta/nn; ofstream fstrv; if(isSum)fstrv.open("v.txt"); else fstrv.open("v_2.txt"); TVectorD totmult[nbin], totpt[nbin]; TVectorD Nevent, totmultall; TVectorD* V[nbin]; TVectorD* chi[nbin]; TVectorD* dDRe[nbin]; TVectorD* dDIm[nbin]; TVectorD* dNRe[nbin][ntheta]; TVectorD* dNIm[nbin][ntheta]; TComplex dD[nbin][ntheta], dN[nbin][ntheta][nptv]; TVectorD avgmult[nbin]; TVectorD avgmultall; TVectorD avgpt[nbin]; TVectorD v[nbin][ntheta],vmean[nbin],deltav[nbin][ntheta],deltavmean[nbin]; if(isSum) TFile *infile = TFile::Open("mergedV_Sum.root"); else TFile *infile = TFile::Open("mergedV_Prod.root"); Nevent.ResizeTo(nbin); Nevent.Zero(); totmultall.ResizeTo(nbin); totmultall.Zero(); avgmultall.ResizeTo(nbin); for(int ibin=0;ibin<nbin;ibin++){ totmult[ibin].ResizeTo(nptv); totmult[ibin].Zero(); avgmult[ibin].ResizeTo(nptv); avgpt[ibin].ResizeTo(nptv); totpt[ibin].ResizeTo(nptv); totpt[ibin].Zero(); vmean[ibin].ResizeTo(nptv); deltavmean[ibin].ResizeTo(nptv); V[ibin] = (TVectorD*) infile->Get(Form("D_%d/D_0/V",ibin)); chi[ibin] = (TVectorD*) infile->Get(Form("D_%d/D_0/chi",ibin)); for(int itheta=0;itheta<ntheta;itheta++){ v[ibin][itheta].ResizeTo(nptv); deltav[ibin][itheta].ResizeTo(nptv); dD[ibin][itheta]=0; for(int iptbin=0;iptbin<nptv;iptbin++){ dN[ibin][itheta][iptbin]=0; } } } for(int ifile=0; ifile<nFileAll; ifile++){ if(isSum) f[ifile] = TFile::Open(Form("./jobout/Anav_Prod_%d.root",ifile)); else f[ifile] = TFile::Open(Form("./jobout/Anav_Prod2_%d.root",ifile)); TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get("Nevent"); TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get("totmultall"); for(int ibin=0;ibin<nbin;ibin++){ TVectorD* totmult_t = (TVectorD*)f[ifile]->Get(Form("totmult_%d",ibin)); TVectorD* totpt_t = (TVectorD*)f[ifile]->Get(Form("totpt_%d",ibin)); dDRe[ibin] = (TVectorD*)f[ifile]->Get(Form("dDRe_%d",ibin)); dDIm[ibin] = (TVectorD*)f[ifile]->Get(Form("dDIm_%d",ibin)); Nevent[ibin]+=(*Nevent_t)[ibin]; totmultall[ibin]+=(*totmultall_t)[ibin]; for(int iptbin=0;iptbin<nptv;iptbin++){ totmult[ibin][iptbin]+=(*totmult_t)[iptbin]; totpt[ibin][iptbin]+=(*totpt_t)[iptbin]; } for(int itheta=0;itheta<ntheta;itheta++){ dNRe[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNRe_%d_%d",ibin,itheta)); dNIm[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNIm_%d_%d",ibin,itheta)); dD[ibin][itheta]+=TComplex((*dDRe[ibin])[itheta],(*dDIm[ibin])[itheta]); for(int iptbin=0;iptbin<nptv;iptbin++) dN[ibin][itheta][iptbin]+=TComplex((*dNRe[ibin][itheta])[iptbin],(*dNIm[ibin][itheta])[iptbin]); } } f[ifile]->Close(); } for(int ibin=0;ibin<nbin;ibin++) for(int itheta=0;itheta<ntheta;itheta++) dD[ibin][itheta]*=TComplex::Power(TComplex::I(),mm-1)/(Double_t)Nevent[ibin]; for(int ibin=0;ibin<nbin;ibin++){ avgmultall[ibin]=1.0*totmultall[ibin]/Nevent[ibin]; for(int iptbin=0;iptbin<nptv; iptbin++){ vmean[ibin][iptbin]=0; deltavmean[ibin][iptbin]=0; avgmult[ibin][iptbin]=1.0*totmult[ibin][iptbin]/Nevent[ibin]; avgpt[ibin][iptbin]=1.0*totpt[ibin][iptbin]/totmult[ibin][iptbin]; for(int itheta=0;itheta<ntheta;itheta++){ dN[ibin][itheta][iptbin]/=totmult[ibin][iptbin]; TComplex Res=dN[ibin][itheta][iptbin]/dD[ibin][itheta]; v[ibin][itheta][iptbin]=(*V[ibin])[itheta]*avgmultall[ibin]*TMath::BesselJ1(j01)/Besselj01(mm)*Res.Re(); vmean[ibin][iptbin]+=v[ibin][itheta][iptbin]; deltav[ibin][itheta][iptbin]=TMath::Cos(mm*nn*theta[itheta])/totmult[ibin][iptbin]*(TMath::Exp(j01*j01/2./(*chi[ibin])[itheta]/(*chi[ibin])[itheta]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Power(-1,mm)*TMath::Exp(-j01*j01/2./(*chi[ibin])[itheta]/(*chi[ibin])[itheta]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.))); deltavmean[ibin][iptbin]+=deltav[ibin][itheta][iptbin]; // fstrv<<itheta<<"\t"<<v[ibin][itheta][iptbin]<<"\t"<<deltav[ibin][itheta][iptbin]<<endl; } deltavmean[ibin][iptbin]=TMath::Sqrt(deltavmean[ibin][iptbin])/2./Besselj01(mm); //fstrv<<endl; vmean[ibin][iptbin]/=ntheta; deltavmean[ibin][iptbin]/=ntheta; fstrv<<ptbinv[iptbin]<<"-"<<ptbinv[iptbin+1]<<"\t"<<vmean[ibin][iptbin]<<"\t"<<deltavmean[ibin][iptbin]<<endl; } } if(isSum)TFile *fout = new TFile("mergedv_Prod.root","Recreate"); else TFile *fout = new TFile("mergedv_Prod2.root","Recreate"); for(ibin=0;ibin<nbin;ibin++){ Nevent.Write("Nevent"); TDirectory *dir = fout->mkdir(Form("D_%d",ibin)); dir->cd(); avgpt[ibin].Write("avgpt"); vmean[ibin].Write("vmean"); deltavmean[ibin].Write("deltavmean"); } infile->Close(); fout->Close(); }
void getResV(){ //------------------------Deal with the number and get the output stored in txt files and root files TF1 *ffit[nbin]; TF1 *ffit0[nbin][ntheta]; TFile *f[nFileAll]; double theta[ntheta]; TVectorD Nevent; Nevent.ResizeTo(nbin); Nevent.Zero(); TVectorD totmultall; totmultall.ResizeTo(nbin); totmultall.Zero(); TVectorD avgmultall; avgmultall.ResizeTo(nbin); avgmultall.Zero(); TVectorD tottrk; tottrk.ResizeTo(nbin); tottrk.Zero(); TVectorD totptall; totptall.ResizeTo(nbin); totptall.Zero(); TVectorD totetaall; totetaall.ResizeTo(nbin); totetaall.Zero(); TVectorD avgtrk; avgtrk.ResizeTo(nbin); avgtrk.Zero(); TVectorD avgpt; avgpt.ResizeTo(nbin); TVectorD avgeta; avgeta.ResizeTo(nbin); TH1D* hq[nbin][ntheta]; TH1D* hqx[nbin]; TH1D* hqy[nbin]; TH1D* hq2[nbin]; TH1D* hq2nonf[nbin]; string dir = getenv("DIR"); for(int itheta=0;itheta<ntheta;itheta++) theta[itheta]=itheta*TMath::Pi()/ntheta/nn; for(int ibin=0;ibin<nbin;ibin++){ for(int itheta=0;itheta<ntheta;itheta++){ hq[ibin][itheta] = new TH1D(Form("hq"),Form("hq"),1000,0,10); } hqx[ibin] = new TH1D(Form("hqx"),Form("hqx"),1000,0,10); hqy[ibin] = new TH1D(Form("hqy"),Form("hqy"),1000,0,10); hq2[ibin] = new TH1D(Form("hq2"),Form("hq2"),1000,0,10); hq2nonf[ibin] = new TH1D(Form("hq2nonf"),Form("hq2nonf"),1000,0,10); } for(int ifile=0; ifile<nFileAll; ifile++){ f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/qfit/tracknormcpt03to6/%s/AnaV_Sum_%d.root",dir.c_str(),ifile)); TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get(Form("Nevent")); TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get(Form("totmultall")); TVectorD* tottrk_t = (TVectorD*)f[ifile]->Get(Form("tottrk")); TVectorD* totptall_t = (TVectorD*)f[ifile]->Get(Form("totptall")); TVectorD* totetaall_t = (TVectorD*)f[ifile]->Get(Form("totetaall")); for(int ibin=0;ibin<nbin;ibin++){ TH1D* hqx_t = (TH1D*)f[ifile]->Get(Form("hqx_%d",ibin)); hqx[ibin]->Add(hqx_t); TH1D* hqy_t = (TH1D*)f[ifile]->Get(Form("hqy_%d",ibin)); hqy[ibin]->Add(hqy_t); TH1D* hq2_t = (TH1D*)f[ifile]->Get(Form("hq2_%d",ibin)); hq2[ibin]->Add(hq2_t); TH1D* hq2nonf_t = (TH1D*)f[ifile]->Get(Form("hq2nonf_%d",ibin)); hq2nonf[ibin]->Add(hq2nonf_t); for(int itheta=0;itheta<ntheta;itheta++){ TH1D* hq_t = (TH1D*)f[ifile]->Get(Form("hq_%d_%d",ibin,itheta)); hq[ibin][itheta]->Add(hq_t); } totptall[ibin] += (*totptall_t)[ibin]; totetaall[ibin] += (*totetaall_t)[ibin]; Nevent[ibin] += (*Nevent_t)[ibin]; totmultall[ibin] += (*totmultall_t)[ibin]; tottrk[ibin] += (*tottrk_t)[ibin]; } f[ifile]->Close(); } for(int ibin=0;ibin<nbin;ibin++){ avgmultall[ibin]=totmultall[ibin]/Nevent[ibin]; avgtrk[ibin]=tottrk[ibin]/Nevent[ibin]; for(int itheta=0;itheta<ntheta;itheta++){ avgpt[ibin]=1.0*totptall[ibin]/totmultall[ibin]; avgeta[ibin]=1.0*totetaall[ibin]/totmultall[ibin]; } } TString outname = "mergedV_Sum.root"; TFile *outf = new TFile(outname,"Recreate"); Nevent.Write("Nevent"); totmultall.Write("totmultall"); avgmultall.Write("avgmultall"); tottrk.Write("tottrk"); avgtrk.Write("avgtrk"); avgpt.Write("avgpt"); avgeta.Write("avgeta"); for(int ibin=0;ibin<nbin;ibin++){ TDirectory *dir0 = outf->mkdir(Form("D_%d",ibin));dir0->cd(); hqx[ibin]->Write(); hqy[ibin]->Write();hq2[ibin]->Write();hq2nonf[ibin]->Write(); for(int itheta=0;itheta<ntheta;itheta++){ TDirectory *dir1 = dir0->mkdir(Form("D_%d",itheta));dir1->cd(); hq[ibin][itheta]->Write(); } } outf->Close(); }
void runBATCalculator() { // Definiton of a RooWorkspace containing the statistics model. Later the // information for BATCalculator is retrieved from the workspace. This is // certainly a bit of overhead but better from an educative point of view. cout << "preparing the RooWorkspace object" << endl; RooWorkspace* myWS = new RooWorkspace("myWS", true); // combined prior for signal contribution myWS->factory("Product::signal({sigma_s[0,20],L[5,15],epsilon[0,1]})"); myWS->factory("N_bkg[0,3]"); // define prior functions // uniform prior for signal crosssection myWS->factory("Uniform::prior_sigma_s(sigma_s)"); // (truncated) prior for efficiency myWS->factory("Gaussian::prior_epsilon(epsilon,0.51,0.0765)"); // (truncated) Gaussian prior for luminosity myWS->factory("Gaussian::prior_L(L,10,1)"); // (truncated) Gaussian prior for bkg crosssection myWS->factory("Gaussian::prior_N_bkg(N_bkg,0.52,0.156)"); // Poisson distribution with mean signal+bkg myWS->factory("Poisson::model(n[0,300],sum(signal,N_bkg))"); // define the global prior function myWS->factory("PROD::prior(prior_sigma_s,prior_epsilon,prior_L,prior_N_bkg)"); // Definition of observables and parameters of interest myWS->defineSet("obsSet", "n"); myWS->defineSet("poiSet", "sigma_s"); myWS->defineSet("nuisanceSet", "N_bkg,L,epsilon"); // ->model complete (Additional information can be found in the // RooStats manual) // feel free to vary the parameters, but don't forget to choose reasonable ranges for the // variables. Currently the Bayesian methods will often not work well if the variable ranges // are either too short (for obvious reasons) or too large (for technical reasons). // A ModelConfig object is used to associate parts of your workspace with their statistical // meaning (it is also possible to initialize BATCalculator directly with elements from the // workspace but if you are sharing your workspace with others or if you want to use several // different methods the use of ModelConfig will most often turn out to be the better choice.) // setup the ModelConfig object cout << "preparing the ModelConfig object" << endl; ModelConfig modelconfig("modelconfig", "ModelConfig for this example"); modelconfig.SetWorkspace(*myWS); modelconfig.SetPdf(*(myWS->pdf("model"))); modelconfig.SetParametersOfInterest(*(myWS->set("poiSet"))); modelconfig.SetPriorPdf(*(myWS->pdf("prior"))); modelconfig.SetNuisanceParameters(*(myWS->set("nuisanceSet"))); modelconfig.SetObservables(*(myWS->set("obsSet"))); // use BATCalculator to the derive credibility intervals as a function of the observed number of // events in the hypothetical experiment // define vector with tested numbers of events TVectorD obsEvents; // define vectors which will be filled with the lower and upper limits for each tested number // of observed events TVectorD BATul; TVectorD BATll; // fix upper limit of tested observed number of events int obslimit = 10; obsEvents.ResizeTo(obslimit); BATul.ResizeTo(obslimit); BATll.ResizeTo(obslimit); cout << "starting the calculation of Bayesian credibility intervals with BATCalculator" << endl; // loop over observed number of events in the hypothetical experiment for (int obs = 1; obs <= obslimit; obs++) { obsEvents[obs - 1] = (static_cast<double>(obs)); // prepare data input for the the observed number of events // adjust number of observed events in the workspace. This is communicated to ModelConfig! myWS->var("n")->setVal(obs); // create data RooDataSet data("data", "", *(modelconfig.GetObservables())); data.add( *(modelconfig.GetObservables())); // prepare BATCalulator BATCalculator batcalc(data, modelconfig); // give the BATCalculator a unique name (always a good idea in ROOT) TString namestring = "mybatc_"; namestring += obs; batcalc.SetName(namestring); // fix amount of posterior probability in the calculated interval. // the name confidence level is incorrect here batcalc.SetConfidenceLevel(0.90); // fix length of the Markov chain. (in general: the longer the Markov chain the more // precise will be the results) batcalc.SetnMCMC(20000); // retrieve SimpleInterval object containing the information about the interval (this // triggers the actual calculations) SimpleInterval* interval = batcalc.GetInterval1D("sigma_s"); std::cout << "BATCalculator: 90% credibility interval: [ " << interval->LowerLimit() << " - " << interval->UpperLimit() << " ] or 95% credibility upper limit\n"; // add the interval borders for the current number of observed events to the vectors // containing the lower and upper limits BATll[obs - 1] = interval->LowerLimit(); BATul[obs - 1] = interval->UpperLimit(); // clean up for next loop element batcalc.CleanCalculatorForNewData(); delete interval; } cout << "all limits calculated" << endl; // summarize the results in a plot TGraph* grBATll = new TGraph(obsEvents, BATll); grBATll->SetLineColor(kGreen); grBATll->SetLineWidth(200); grBATll->SetFillStyle(3001); grBATll->SetFillColor(kGreen); TGraph* grBATul = new TGraph(obsEvents, BATul); grBATul->SetLineColor(kGreen); grBATul->SetLineWidth(-200); grBATul->SetFillStyle(3001); grBATul->SetFillColor(kGreen); // create and draw multigraph TMultiGraph* mg = new TMultiGraph("BayesianLimitsBATCalculator", "BayesianLimitsBATCalculator"); mg->SetTitle("example of Bayesian credibility intervals derived with BATCAlculator "); mg->Add(grBATll); mg->Add(grBATul); mg->Draw("AC"); mg->GetXaxis()->SetTitle ("# observed events"); mg->GetYaxis()->SetTitle("limits on signal S (size of test: 0.1)"); mg->Draw("AC"); }
void getResV(){ //------------------------Deal with the number and get the output stored in txt files and root files string SumorProd = getenv("SUMORPROD"); double Vmax[nbin], eps[nbin]; for(int ibin=0; ibin<nbin ;ibin++){ //Vmax[ibin]=0.065*(trkbin[ibin]+30); Vmax[ibin]=0.065*avgmultIn; //eps[ibin]=0.00025*(trkbin[ibin]+30); eps[ibin]=0.00025*avgmultIn; } ofstream fstrV; double theta[ntheta]; TVectorD avgmult[nbin], avgpt[nbin], totmult[nbin], totpt[nbin]; TVectorD Qx1[nbin], Qy1[nbin], Q2[nbin]; TVectorD Gmod2[nbin][nptV][ntheta]; TVectorD sigma2[nbin][nptV],deltaV[nbin][nptV]; TVectorD sigma2_[nbin],chi_[nbin]; TVectorD deltaVmean[nbin], Vmean[nbin]; TVectorD r[nbin]; TVectorD r0[nbin][nptV], V[nbin][nptV], chi[nbin][nptV]; TVectorD GRe[nbin][nptV][ntheta]; TVectorD* GRe_t[nbin][nptV][ntheta]; TVectorD GIm[nbin][nptV][ntheta]; TVectorD* GIm_t[nbin][nptV][ntheta]; TComplex G[nbin][nptV][ntheta][nstepr]; if(SumorProd=="Sum") fstrV.open("V_Sum.txt"); else fstrV.open("V_Prod.txt"); TFile *f[nFileAll]; for(int ibin=0; ibin<nbin; ibin++){ r[ibin].ResizeTo(nstepr); for(int ir=0; ir<nstepr; ir++){ if(isSimple==0) r[ibin][ir]=j01/(Vmax[ibin]-eps[ibin]*ir); else r[ibin][ir]=0.00025*20*(ir+1); } } TVectorD Nevent; Nevent.ResizeTo(nbin); Nevent.Zero(); TVectorD totmultall; totmultall.ResizeTo(nbin); totmultall.Zero(); TVectorD avgmultall; avgmultall.ResizeTo(nbin); avgmultall.Zero(); TVectorD tottrk; tottrk.ResizeTo(nbin); tottrk.Zero(); TVectorD avgtrk; avgtrk.ResizeTo(nbin); avgtrk.Zero(); for(int itheta=0;itheta<ntheta;itheta++) theta[itheta]=itheta*TMath::Pi()/ntheta/nn; for(int ibin=0;ibin<nbin;ibin++){ for(int iptbin=0;iptbin<nptV;iptbin++){ r0[ibin][iptbin].ResizeTo(ntheta); sigma2[ibin][iptbin].ResizeTo(ntheta); V[ibin][iptbin].ResizeTo(ntheta); deltaV[ibin][iptbin].ResizeTo(ntheta); chi[ibin][iptbin].ResizeTo(ntheta); for(int itheta=0;itheta<ntheta;itheta++){ Gmod2[ibin][iptbin][itheta].ResizeTo(nstepr); GRe[ibin][iptbin][itheta].ResizeTo(nstepr); GRe[ibin][iptbin][itheta].Zero(); GIm[ibin][iptbin][itheta].ResizeTo(nstepr); GIm[ibin][iptbin][itheta].Zero(); } } avgmult[ibin].ResizeTo(nptV); deltaVmean[ibin].ResizeTo(nptV); Vmean[ibin].ResizeTo(nptV); totpt[ibin].ResizeTo(nptV); totpt[ibin].Zero(); totmult[ibin].ResizeTo(nptV); totmult[ibin].Zero(); avgpt[ibin].ResizeTo(nptV); Qx1[ibin].ResizeTo(nptV); Qx1[ibin].Zero(); Qy1[ibin].ResizeTo(nptV); Qy1[ibin].Zero(); Q2[ibin].ResizeTo(nptV); Q2[ibin].Zero(); sigma2_[ibin].ResizeTo(nptV);sigma2_[ibin].Zero(); chi_[ibin].ResizeTo(nptV);chi_[ibin].Zero(); } for(int ifile=0; ifile<nFileAll; ifile++){ if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/lio/lfs/cms/store/user/qixu/flow/pbsjoboutput/PFcandpt03to6/M300260/AnaV_Sum_%d.root",ifile)); else f[ifile] = TFile::Open(Form("/lio/lfs/cms/store/user/qixu/flow/pbsjoboutput/PFcandpt03to6/M300260/AnaV_Prod_%d.root",ifile)); TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get(Form("Nevent")); TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get(Form("totmultall")); TVectorD* tottrk_t = (TVectorD*)f[ifile]->Get(Form("tottrk")); for(int ibin=0;ibin<nbin;ibin++){ for(int iptbin=0;iptbin<nptV;iptbin++){ for(int itheta=0;itheta<ntheta;itheta++){ GRe_t[ibin][iptbin][itheta] = (TVectorD*)f[ifile]->Get(Form("GRe_%d_%d_%d",ibin,iptbin,itheta)); GIm_t[ibin][iptbin][itheta] = (TVectorD*)f[ifile]->Get(Form("GIm_%d_%d_%d",ibin,iptbin,itheta)); for(ir=0; ir<nstepr; ir++){ GRe[ibin][iptbin][itheta][ir] += (*GRe_t[ibin][iptbin][itheta])[ir]; GIm[ibin][iptbin][itheta][ir] += (*GIm_t[ibin][iptbin][itheta])[ir]; } } } TVectorD* Qx1_t = (TVectorD*)f[ifile]->Get(Form("Qx1_%d",ibin)); TVectorD* Qy1_t = (TVectorD*)f[ifile]->Get(Form("Qy1_%d",ibin)); TVectorD* Q2_t = (TVectorD*)f[ifile]->Get(Form("Q2_%d",ibin)); TVectorD* totmult_t = (TVectorD*)f[ifile]->Get(Form("totmult_%d",ibin)); TVectorD* totpt_t = (TVectorD*)f[ifile]->Get(Form("totpt_%d",ibin)); for(int iptbin=0;iptbin<nptV;iptbin++){ Qx1[ibin][iptbin] += (*Qx1_t)[iptbin]; Qy1[ibin][iptbin] += (*Qy1_t)[iptbin]; Q2[ibin][iptbin] += (*Q2_t)[iptbin]; totmult[ibin][iptbin] += (*totmult_t)[iptbin]; totpt[ibin][iptbin] += (*totpt_t)[iptbin]; } Nevent[ibin] += (*Nevent_t)[ibin]; totmultall[ibin] += (*totmultall_t)[ibin]; tottrk[ibin] += (*tottrk_t)[ibin]; } f[ifile]->Close(); } fstrV<<setprecision(4)<<fixed; fstrV<<"ibin"<<"\t"<<"iptbin"<<"\t"<<"itheta"<<"\t"<<"r0"<<"\t"<<"V"<<"\t"<<"sigma2"<<"\t"<<"chi"<<"\t"<<"Vn Errors"<<endl; for(int ibin=0;ibin<nbin;ibin++){ avgmultall[ibin]=totmultall[ibin]/Nevent[ibin]; avgtrk[ibin]=tottrk[ibin]/Nevent[ibin]; for(int iptbin=0;iptbin<nptV;iptbin++){ for(int itheta=0;itheta<ntheta;itheta++){ for(ir=0; ir<nstepr; ir++){ G[ibin][iptbin][itheta][ir]=TComplex(GRe[ibin][iptbin][itheta][ir],GIm[ibin][iptbin][itheta][ir]); G[ibin][iptbin][itheta][ir]/=Nevent[ibin]; Gmod2[ibin][iptbin][itheta][ir]=TMath::Power(TComplex::Abs(G[ibin][iptbin][itheta][ir]),2); } for(ir=0; ir<nstepr-1; ir++) if(ir!=0 && Gmod2[ibin][iptbin][itheta][ir]<=Gmod2[ibin][iptbin][itheta][ir-1] && Gmod2[ibin][iptbin][itheta][ir]<=Gmod2[ibin][iptbin][itheta][ir+1]) break; if(ir!=0 && ir<nstepr-1) r0[ibin][iptbin][itheta]=r[ibin][ir]; else if(ir==0) {cout<<"ibin="<<ibin<<"\t"<<"iptbin="<<iptbin<<"\t"<<"itheta="<<itheta<<"\tminimum lies on ir = 0, please select proper range!"<<endl; continue;} else {cout<<"ibin="<<ibin<<"\t"<<"iptbin="<<iptbin<<"\t"<<"itheta="<<itheta<<"\tminimum lies on ir = maximum "<<nstepr-1<<", please select proper range!"<<endl; continue;} avgmult[ibin][iptbin]=1.0*totmult[ibin][iptbin]/Nevent[ibin]; avgpt[ibin][iptbin]=1.0*totpt[ibin][iptbin]/totmult[ibin][iptbin]; if(isSimple==0) V[ibin][iptbin][itheta]=Vmax[ibin]-ir*eps[ibin]+eps[ibin]*(Gmod2[ibin][iptbin][itheta][ir+1]-Gmod2[ibin][iptbin][itheta][ir-1])/2./(Gmod2[ibin][iptbin][itheta][ir-1]-2*Gmod2[ibin][iptbin][itheta][ir]+Gmod2[ibin][iptbin][itheta][ir+1]); else V[ibin][iptbin][itheta]=j01/r0[ibin][iptbin][itheta]; //simple method V[ibin][iptbin][itheta]/=avgmult[ibin][iptbin]; sigma2[ibin][iptbin][itheta]=Q2[ibin][iptbin]/Nevent[ibin]-(Qx1[ibin][iptbin]/Nevent[ibin])*(Qx1[ibin][iptbin]/Nevent[ibin])-(Qy1[ibin][iptbin]/Nevent[ibin])*(Qy1[ibin][iptbin]/Nevent[ibin])-(V[ibin][iptbin][itheta]*avgmult[ibin][iptbin])*(V[ibin][iptbin][itheta]*avgmult[ibin][iptbin]); sigma2_[ibin][iptbin]+=sigma2[ibin][iptbin][itheta]; Vmean[ibin][iptbin]+=V[ibin][iptbin][itheta]; chi[ibin][iptbin][itheta]=V[ibin][iptbin][itheta]*avgmult[ibin][iptbin]/TMath::Sqrt(sigma2[ibin][iptbin][itheta]); deltaV[ibin][iptbin][itheta]=V[ibin][iptbin][itheta]/j01/TMath::BesselJ1(j01)*TMath::Sqrt((TMath::Exp(j01*j01/2./chi[ibin][iptbin][itheta]/chi[ibin][iptbin][itheta])+TMath::Exp(-j01*j01/2./chi[ibin][iptbin][itheta]/chi[ibin][iptbin][itheta])*TMath::BesselJ0(2*j01))/2./Nevent[ibin]); fstrV<<ibin<<"\t"<<iptbin<<"\t"<<itheta<<"\t"<<r0[ibin][iptbin][itheta]<<"\t"<<V[ibin][iptbin][itheta]<<"\t"<<sigma2[ibin][iptbin][itheta]<<"\t"<<chi[ibin][iptbin][itheta]<<"\t"<<deltaV[ibin][iptbin][itheta]<<endl; } //deltaVmean[ibin][iptbin]+=TMath::Exp(j01*j01/2./chi[ibin][iptbin][itheta]/chi[ibin][iptbin][itheta]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Exp(-j01*j01/2./chi[ibin][iptbin][itheta]/chi[ibin][iptbin][itheta]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)); sigma2_[ibin][iptbin]/=ntheta; Vmean[ibin][iptbin]/=ntheta; sigma2_[ibin][iptbin]-=TMath::Power(Vmean[ibin][iptbin]*avgmult[ibin][iptbin],2); chi_[ibin][iptbin]=Vmean[ibin][iptbin]*avgmult[ibin][iptbin]/TMath::Sqrt(sigma2_[ibin][iptbin]); for(int itheta=0;itheta<ntheta;itheta++){ deltaVmean[ibin][iptbin]+=TMath::Exp(j01*j01/2./chi_[ibin][iptbin]/chi_[ibin][iptbin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Exp(-j01*j01/2./chi_[ibin][iptbin]/chi_[ibin][iptbin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)); } fstrV<<endl; deltaVmean[ibin][iptbin]=Vmean[ibin][iptbin]/j01/TMath::BesselJ1(j01)*TMath::Sqrt(deltaVmean[ibin][iptbin]/ntheta/2./Nevent[ibin]); } fstrV<<endl; } fstrV<<"ibin"<<"\t"<<"iptbin"<<"\t"<<"avgmult"<<"\t"<<"avgpt"<<"\t"<<"Vn mean"<<"\t"<<"Vn mean Error"<<endl; for(int ibin=0;ibin<nbin;ibin++){ for(int iptbin=0;iptbin<nptV;iptbin++){ fstrV<<ibin<<"\t"<<iptbin<<"\t"<<avgmult[ibin][iptbin]<<"\t"<<avgpt[ibin][iptbin]<<"\t"<<Vmean[ibin][iptbin]<<"\t"<<deltaVmean[ibin][iptbin]<<endl; } fstrV<<endl; } fstrV<<"ibin"<<"\t"<<"Nevent"<<"\t"<<"totmultall"<<"\t"<<"avgmultall"<<"\t"<<"avgtrk"<<endl; for(int ibin=0;ibin<nbin;ibin++){ fstrV<<ibin<<"\t"<<Nevent[ibin]<<"\t"<<totmultall[ibin]<<"\t"<<avgmultall[ibin]<<"\t"<<avgtrk[ibin]<<endl; fstrV<<endl; } if(SumorProd=="Sum") TString outname = "mergedV_Sum.root"; else TString outname="mergedV_Prod.root"; TFile *outf = new TFile(outname,"Recreate"); Nevent.Write("Nevent"); totmultall.Write("totmultall"); avgmultall.Write("avgmultall"); tottrk.Write("tottrk"); avgtrk.Write("avgtrk"); for(int ibin=0;ibin<nbin;ibin++){ TDirectory *dir0 = outf->mkdir(Form("D_%d",ibin,itheta));dir0->cd(); r[ibin].Write("r"); Qx1[ibin].Write("Qx1"); Qy1[ibin].Write("Qy1"); Q2[ibin].Write("Q2"); totmult[ibin].Write("totmult"); totpt[ibin].Write("totpt"); avgmult[ibin].Write("avgmult"); avgpt[ibin].Write("avgpt"); Vmean[ibin].Write("Vmean"); deltaVmean[ibin].Write("deltaVmean"); for(int iptbin=0;iptbin<nptV;iptbin++){ TDirectory *dir1 = dir0->mkdir(Form("D_%d",iptbin));dir1->cd(); sigma2[ibin][iptbin].Write("sigma2"); chi[ibin][iptbin].Write("chi"); deltaV[ibin][iptbin].Write("deltaV"); r0[ibin][iptbin].Write("r0"); V[ibin][iptbin].Write("V"); for(int itheta=0;itheta<ntheta;itheta++){ TDirectory *dir2 = dir1->mkdir(Form("D_%d",itheta));dir2->cd(); GRe[ibin][iptbin][itheta].Write(Form("GRe")); GIm[ibin][iptbin][itheta].Write(Form("GIm")); Gmod2[ibin][iptbin][itheta].Write(Form("G2")); } } } outf->Close(); }
//------------------------Deal with the number and get the output stored in txt files and root files void getResVsub(){ double Vmax[nbin], eps[nbin]; for(int ibin=0; ibin<nbin ;ibin++){ Vmax[ibin]=0.065*(trkbin[ibin]+30); eps[ibin]=0.00025*(trkbin[ibin]+30); } ofstream fstrV; double theta[ntheta]; TVectorD avgmult, avgpt, totptall; TVectorD Qx1, Qy1, Q2; TVectorD Gmod2[nbin][ntheta]; TVectorD sigma2[nbin],deltaV[nbin]; TVectorD sigma2_,chi_; TVectorD deltaVmean, Vmean; TVectorD deltaVmeanmean, Vmeanmean, sigmaVmeanmean; TVectorD r[nbin]; TVectorD r0[nbin], r01[nbin], V[nbin], chi[nbin]; TVectorD GRe[nbin][ntheta]; TVectorD* GRe_t[nbin][ntheta]; TVectorD GIm[nbin][ntheta]; TVectorD* GIm_t[nbin][ntheta]; TComplex G[nbin][ntheta][nstepr]; if(isSum) fstrV.open("V_Sum_sub.txt"); else fstrV.open("V_Prod_sub.txt"); if(isSum) TString outname = "mergedV_Sum_sub.root"; else TString outname="mergedV_Prod_sub.root"; TFile *outf = new TFile(outname,"Recreate"); int subsample = (int)(nFileAll/nsamples); TFile *f[nFileAll]; for(int ibin=0; ibin<nbin; ibin++){ r[ibin].ResizeTo(nstepr); for(int ir=0; ir<nstepr; ir++){ if(isSimple==0) r[ibin][ir]=j01/(Vmax[ibin]-eps[ibin]*ir); else r[ibin][ir]=0.00025*20*(ir+1); } } Vmeanmean.ResizeTo(nbin); Vmeanmean.Zero(); deltaVmeanmean.ResizeTo(nbin); deltaVmeanmean.Zero(); sigmaVmeanmean.ResizeTo(nbin); sigmaVmeanmean.Zero(); for(int isample=0;isample<nsamples;isample++){ cout<<"start with "<<isample<<"\t"; int start=isample*subsample; int end=(isample+1)*subsample; TVectorD Nevent; Nevent.ResizeTo(nbin); Nevent.Zero(); TVectorD totmultall; totmultall.ResizeTo(nbin); totmultall.Zero(); for(int itheta=0;itheta<ntheta;itheta++) theta[itheta]=itheta*TMath::Pi()/ntheta/nn; for(int ibin=0;ibin<nbin;ibin++){ r0[ibin].ResizeTo(ntheta); r01[ibin].ResizeTo(ntheta); sigma2[ibin].ResizeTo(ntheta); V[ibin].ResizeTo(ntheta); deltaV[ibin].ResizeTo(ntheta); chi[ibin].ResizeTo(ntheta); for(int itheta=0;itheta<ntheta;itheta++){ Gmod2[ibin][itheta].ResizeTo(nstepr); GRe[ibin][itheta].ResizeTo(nstepr); GRe[ibin][itheta].Zero(); GIm[ibin][itheta].ResizeTo(nstepr); GIm[ibin][itheta].Zero(); } } avgmult.ResizeTo(nbin); deltaVmean.ResizeTo(nbin); Vmean.ResizeTo(nbin); deltaVmean.Zero(); Vmean.Zero(); deltaVmean.Zero(); totptall.ResizeTo(nbin); totptall.Zero(); avgpt.ResizeTo(nbin); Qx1.ResizeTo(nbin); Qx1.Zero(); Qy1.ResizeTo(nbin); Qy1.Zero(); Q2.ResizeTo(nbin); Q2.Zero(); sigma2_.ResizeTo(nbin);sigma2_.Zero(); chi_.ResizeTo(nbin);chi_.Zero(); for(int ifile=start; ifile<end; ifile++){ if(isSum) f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/ToyMCHole/pPbDataV205m185/AnaV_Sum_%d.root",ifile)); else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/ToyMCHole/pPbDataV205m185/AnaV_Prod_%d.root",ifile)); TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get(Form("Nevent")); TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get(Form("totmultall")); TVectorD* Qx1_t = (TVectorD*)f[ifile]->Get(Form("Qx1")); TVectorD* Qy1_t = (TVectorD*)f[ifile]->Get(Form("Qy1")); TVectorD* Q2_t = (TVectorD*)f[ifile]->Get(Form("Q2")); TVectorD* totptall_t = (TVectorD*)f[ifile]->Get(Form("totptall")); for(int ibin=0;ibin<nbin;ibin++){ for(int itheta=0;itheta<ntheta;itheta++){ GRe_t[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("GRe_%d_%d",ibin,itheta)); GIm_t[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("GIm_%d_%d",ibin,itheta)); for(ir=0; ir<nstepr; ir++){ GRe[ibin][itheta][ir] += (*GRe_t[ibin][itheta])[ir]; GIm[ibin][itheta][ir] += (*GIm_t[ibin][itheta])[ir]; } } Qx1[ibin] += (*Qx1_t)[ibin]; Qy1[ibin] += (*Qy1_t)[ibin]; Q2[ibin] += (*Q2_t)[ibin]; totptall[ibin] += (*totptall_t)[ibin]; Nevent[ibin] += (*Nevent_t)[ibin]; totmultall[ibin] += (*totmultall_t)[ibin]; } f[ifile]->Close(); } fstrV<<setprecision(4)<<fixed; fstrV<<"ibin"<<"\t"<<"itheta"<<"\t"<<"r0"<<"\t"<<"V"<<"\t"<<"sigma2"<<"\t"<<"chi"<<"\t"<<"Vn Errors"<<endl; for(int ibin=0;ibin<nbin;ibin++){ for(int itheta=0;itheta<ntheta;itheta++){ for(ir=0; ir<nstepr; ir++){ G[ibin][itheta][ir]=TComplex(GRe[ibin][itheta][ir],GIm[ibin][itheta][ir]); G[ibin][itheta][ir]/=Nevent[ibin]; Gmod2[ibin][itheta][ir]=TMath::Power(TComplex::Abs(G[ibin][itheta][ir]),2); } for(ir=0; ir<nstepr-1; ir++) if(ir!=0 && Gmod2[ibin][itheta][ir]<=Gmod2[ibin][itheta][ir-1] && Gmod2[ibin][itheta][ir]<=Gmod2[ibin][itheta][ir+1]) break; if(ir!=0 && ir<nstepr-1) r01[ibin][itheta]=r[ibin][ir]; else if(ir==0) {cout<<"ibin="<<ibin<<"\t"<<"itheta="<<itheta<<"\tminimum lies on ir = 0, please select proper range!"<<endl; continue;} else {cout<<"ibin="<<ibin<<"\t"<<"itheta="<<itheta<<"\tminimum lies on ir = maximum "<<nstepr-1<<", please select proper range!"<<endl; continue;} avgmult[ibin]=1.0*totmultall[ibin]/Nevent[ibin]; avgpt[ibin]=1.0*totptall[ibin]/totmultall[ibin]; if(isSimple==0) V[ibin][itheta]=Vmax[ibin]-ir*eps[ibin]+eps[ibin]*(Gmod2[ibin][itheta][ir+1]-Gmod2[ibin][itheta][ir-1])/2./(Gmod2[ibin][itheta][ir-1]-2*Gmod2[ibin][itheta][ir]+Gmod2[ibin][itheta][ir+1]); else V[ibin][itheta]=j01/r0[ibin][itheta]; //simple method r0[ibin][itheta]=j01/V[ibin][itheta]; V[ibin][itheta]/=avgmult[ibin]; //sigma2[ibin][itheta]=Q2[ibin]/Nevent[ibin]-(Qx1[ibin]/Nevent[ibin])*(Qx1[ibin]/Nevent[ibin])-(Qy1[ibin]/Nevent[ibin])*(Qy1[ibin]/Nevent[ibin])-(V[ibin][itheta]*avgmult[ibin])*(V[ibin][itheta]*avgmult[ibin]); sigma2[ibin][itheta]=Q2[ibin]/Nevent[ibin]-(Qx1[ibin]/Nevent[ibin])*(Qx1[ibin]/Nevent[ibin])-(Qy1[ibin]/Nevent[ibin])*(Qy1[ibin]/Nevent[ibin]); sigma2_[ibin]+=sigma2[ibin][itheta]; Vmean[ibin]+=V[ibin][itheta]; chi[ibin][itheta]=V[ibin][itheta]*avgmult[ibin]/TMath::Sqrt(sigma2[ibin][itheta]); //deltaV[ibin][itheta]=V[ibin][itheta]/j01/TMath::BesselJ1(j01)*TMath::Sqrt((TMath::Exp(j01*j01/2./chi[ibin][itheta]/chi[ibin][itheta])+TMath::Exp(-j01*j01/2./chi[ibin][itheta]/chi[ibin][itheta])*TMath::BesselJ0(2*j01))/2./Nevent[ibin]); } sigma2_[ibin]/=ntheta; Vmean[ibin]/=ntheta; sigma2_[ibin]-=TMath::Power(Vmean[ibin]*avgmult[ibin],2); chi_[ibin]=Vmean[ibin]*avgmult[ibin]/TMath::Sqrt(sigma2_[ibin]); //deltaVmean[ibin]+=TMath::Exp(j01*j01/2./chi[ibin][itheta]/chi[ibin][itheta]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Exp(-j01*j01/2./chi[ibin][itheta]/chi[ibin][itheta]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)); for(int itheta=0;itheta<ntheta;itheta++){ deltaV[ibin][itheta]=V[ibin][itheta]/j01/TMath::BesselJ1(j01)*TMath::Sqrt((TMath::Exp(j01*j01/2./chi_[ibin]/chi_[ibin])+TMath::Exp(-j01*j01/2./chi_[ibin]/chi_[ibin])*TMath::BesselJ0(2*j01))/2./Nevent[ibin]); deltaVmean[ibin]+=TMath::Exp(j01*j01/2./chi_[ibin]/chi_[ibin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Exp(-j01*j01/2./chi_[ibin]/chi_[ibin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)); fstrV<<ibin<<"\t"<<itheta<<"\t"<<r0[ibin][itheta]<<"\t"<<V[ibin][itheta]<<"\t"<<sigma2[ibin][itheta]<<"\t"<<chi[ibin][itheta]<<"\t"<<deltaV[ibin][itheta]<<endl; } fstrV<<endl; deltaVmean[ibin]=Vmean[ibin]/j01/TMath::BesselJ1(j01)*TMath::Sqrt(deltaVmean[ibin]/ntheta/2./Nevent[ibin]); } fstrV<<endl; fstrV<<"ibin"<<"\t"<<"avgmult"<<"\t"<<"avgpt"<<"\t"<<"Vn mean"<<"\t"<<"Vn mean Error"<<endl; for(int ibin=0;ibin<nbin;ibin++){ fstrV<<ibin<<"\t"<<avgmult[ibin]<<"\t"<<avgpt[ibin]<<"\t"<<Vmean[ibin]<<"\t"<<deltaVmean[ibin]<<endl; } fstrV<<endl; TDirectory *dirsample = outf->mkdir(Form("s_%d",isample)); dirsample->cd(); Nevent.Write("Nevent"); totmultall.Write("totmultall"); Qx1.Write("Qx1"); Qy1.Write("Qy1"); Q2.Write("Q2"); totptall.Write("totptall"); avgmult.Write("avgmult"); avgpt.Write("avgpt"); Vmean.Write("Vmean"); deltaVmean.Write("deltaVmean"); chi_.Write("chi"); for(int ibin=0;ibin<nbin;ibin++){ TDirectory *dir0 = dirsample->mkdir(Form("D_%d",ibin));dir0->cd(); r[ibin].Write("r"); Vmeanmean[ibin]+=Vmean[ibin]/nsamples; deltaVmeanmean[ibin]+=deltaVmean[ibin]/nsamples; sigmaVmeanmean[ibin]+=TMath::Power(Vmean[ibin]/nsamples,2); sigma2[ibin].Write("sigma2"); chi[ibin].Write("chi0"); deltaV[ibin].Write("deltaV"); r0[ibin].Write("r0"); r01[ibin].Write("r01"); V[ibin].Write("V"); for(int itheta=0;itheta<ntheta;itheta++){ TDirectory *dir1 = dir0->mkdir(Form("D_%d",itheta));dir1->cd(); GRe[ibin][itheta].Write(Form("GRe")); GIm[ibin][itheta].Write(Form("GIm")); Gmod2[ibin][itheta].Write(Form("G2")); } } } fstrV<<"ibin"<<"\t"<<"Vn mean mean"<<"\t"<<"Vn mean mean Error"<<"\t"<<"Vn mean deviation"<<endl; for(int ibin=0;ibin<nbin;ibin++){ sigmaVmeanmean[ibin]=TMath::Sqrt(sigmaVmeanmean[ibin]*nsamples-Vmeanmean[ibin]*Vmeanmean[ibin]); fstrV<<endl<<ibin<<"\t"<<Vmeanmean[ibin]<<"\t"<<deltaVmeanmean[ibin]<<"\t"<<sigmaVmeanmean[ibin]<<endl; } outf->cd(); Vmeanmean.Write("Vmeanmean"); deltaVmeanmean.Write("deltaVmeanmean"); sigmaVmeanmean.Write("sigmaVmeanmean"); cout<<endl; outf->Close(); }