Beispiel #1
0
double* Divide(const TArrayD* array , double val){
  TArrayD* temp = new TArrayD();
  array->Copy(*temp);
  for(int i = 0 ; i < temp->GetSize() ; i++)
    temp->SetAt(array->At(i) / val , i);
  
  return temp->GetArray();  
}
Beispiel #2
0
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();
}
Beispiel #3
0
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();
	
}
Beispiel #4
0
void rose_image()
{
   // Display image in a new canvas and pad.

   TImage *img = TImage::Open("rose512.jpg");

   if (!img) {
      printf("Could not create an image... exit\n");
      return;
   }

   img->SetConstRatio(0);
   img->SetImageQuality(TAttImage::kImgBest);

   TString fp = gEnv->GetValue("Root.TTFontPath", "");
   TString bc = fp + "/BlackChancery.ttf";
   TString ar = fp + "/arial.ttf";

   // draw text over image with funny font
   img->DrawText(120, 160, "Hello World!", 32, 
                 gROOT->GetColor(4)->AsHexString(), 
                 bc, TImage::kShadeBelow);

   // draw text over image with foreground specified by pixmap
   img->DrawText(250, 350, "goodbye cruel world ...", 24, 0, 
                 ar, TImage::kPlain, "fore.xpm");

   TImage *img2 = TImage::Open("mditestbg.xpm");

   // tile image
   img2->Tile(img->GetWidth(), img->GetHeight());

   c1 = new TCanvas("rose512", "examples of image manipulations", 760, 900);
   c1->Divide(2, 3);
   c1->cd(1);
   img->Draw("xxx");
   img->SetEditable(kTRUE);

   c1->cd(2);
   // averaging with mditestbg.xpm image
   TImage *img3 = (TImage*)img->Clone("img3");
   img3->Merge(img2, "allanon");
   img3->Draw();

   // contrasting (tint with itself)
   c1->cd(3);
   TImage *img4 = (TImage*)img->Clone("img4");
   img4->Merge(img4, "tint");

   // draw filled rectangle with magenta color
   img4->FillRectangle("#FF00FF", 20, 220, 40, 40);

   // Render multipoint alpha-blended gradient (R->G->B)
   img4->Gradient(0, "#FF0000 #00FF00 #220000FF", 0, 50, 50, 100, 100);

   // draw semi-transparent 3D button
   img4->Bevel(300, 20, 160, 40, "#ffffffff", "#fe000000", 3, 0);
   img4->DrawLine(10, 100, 100, 10, "#0000ff", 4);
   img4->Draw();

   // vectorize image. Reduce palette to 256 colors
   c1->cd(4);
   TImage *img5 = (TImage*)img->Clone("img5");
   img5->Vectorize(256);
   img5->Draw();

   // quantization of the image
   c1->cd(5);
   TImage *img6 = (TImage*)img->Clone("img6");
   TImagePalette *pal = (TImagePalette *)&img5->GetPalette();
   TArrayD *arr = img6->GetArray(50, 40, pal);
   img6->SetImage(arr->GetArray(), 50, 40, pal);
   img6->Draw();

   // HSV adjustment (convert red to yellow)
   c1->cd(6);
   TImage *img7 = (TImage*)img->Clone("img7");
   img7->HSV(0, 40, 40);
   img7->Draw();
}
Beispiel #5
0
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();
}
Beispiel #6
0
double *GetDat(int evt)	        {return fDat.GetArray()+evt*(kMaxData);}