コード例 #1
0
ファイル: BoundingBox.cpp プロジェクト: shrekshao/RayTracer
BoundingBox::BoundingBox(const Point & pmin,const Point & pmax, const Affine3f & t)
{
	Vector3f offset(pmin - pmax);
	Vector3f offset_x(offset(0),0,0);
	Vector3f offset_y(0,offset(1),0);
	Vector3f offset_z(0,0,offset(2));
	Vector3f v[8];

	v[0] = pmin;

	v[1] = pmin + offset_x;
	v[2] = pmin + offset_y;
	v[3] = pmin + offset_z;
	
	v[4] = pmax - offset_x;
	v[5] = pmax - offset_y;
	v[6] = pmax - offset_z;

	v[7] = pmax;

	int i;
	for (i =0;i<8;i++)
	{
		v[i] = t * (v[i].colwise().homogeneous());
	}

	float min_x = (v[0]).x();
	float min_y = (v[0]).y();
	float min_z = (v[0]).z();

	float max_x = (v[0]).x();
	float max_y = (v[0]).y();
	float max_z = (v[0]).z();

	for (i =1;i<8;i++)
	{
		min_x = min(min_x,(v[i]).x());
		min_y = min(min_y,(v[i]).y());
		min_z = min(min_z,(v[i]).z());

		max_x = max(max_x,(v[i]).x());
		max_y = max(max_y,(v[i]).y());
		max_z = max(max_z,(v[i]).z());
	}

	min_pos = Point(min_x,min_y,min_z);
	max_pos = Point(max_x,max_y,max_z);
}
コード例 #2
0
ファイル: Pic.cpp プロジェクト: sappel/patric_mti
void Pic::nonlinear_SC_kick(double xrms, double yrms, double dQxm, double dQym,
			    double tunex, double tuney, Grid1D& ldy, double ldy0,
			    double circum, double ds){
  double R = circum/(2.0*PI);
  double scfact;
  double offsetx = offset_x();
  double offsety = offset_y();

  for(long j=0; j<pics.size(); ++j){
    scfact = ldy.Field2Pic(pics[j].z)/ldy0;

  //if( pow(pics[j].x-offsetx, 2)+pow(pics[j].y-offsety, 2) < 6.0*(pow(xrms, 2)+pow(yrms, 2)) )
  //{
    pics[j].xs-= scfact*2.0*ds*tunex*dQxm/pow(R, 2)*
      (pics[j].x-offsetx)*
      (1.0-1.0/18.0*(2.0*xrms+yrms)/(xrms*xrms*(xrms+yrms))*pow(pics[j].x-offsetx, 2)-1.0/(6.0*yrms*(xrms+yrms))*pow(pics[j].y-offsety, 2));
    pics[j].ys-= scfact*2.0*ds*tuney*dQym/pow(R, 2)*
      (pics[j].y-offsety)*(1.0-1.0/18.0*(2.0*yrms+xrms)/(yrms*yrms*(xrms+yrms))
			   *pow(pics[j].y-offsety, 2)-1.0/(6.0*xrms*(xrms+yrms))*pow(pics[j].x-offsetx, 2));
  //}
  }
}
コード例 #3
0
ファイル: comp_All.C プロジェクト: marrbnl/STAR
//================================================
void All(const int compCount = 1, const int compEff = 1, const int compRef = 1, const int savePlot = 1)
{
  const char* dataType[2] = {"New","Old"};
  // Jpsi efficiency vs. pT
  const int nPtBins         = nPtBins_pt;
  const double* ptBins_low  = ptBins_low_pt;
  const double* ptBins_high = ptBins_high_pt;
  const char** ptName       = pt_Name_pt;
  const int nCentBins       = nCentBins_pt; 
  const int* centBins_low   = centBins_low_pt;
  const int* centBins_high  = centBins_high_pt;
  const char** cent_Name    = cent_Name_pt;
  const char** cent_Title   = cent_Title_pt;
  const int kNCent = nCentBins_npart[0];

  const int nbins = nPtBins -1;
  double xbins[nbins+1];
  for(int i=0; i<nbins; i++)
    xbins[i] = ptBins_low[i+1];
  xbins[nbins] = ptBins_high[nbins];

  TList *list = new TList;

  if(compCount)
    {
      TFile *fSig[2];
      fSig[0] = TFile::Open(Form("Rootfiles/%s.JpsiYield.pt%1.1f.pt%1.1f.root",run_type,pt1_cut,pt2_cut),"read");
      fSig[1] = TFile::Open(Form("Rootfiles/old.%s.JpsiYield.pt%1.1f.pt%1.1f.root",run_type,pt1_cut,pt2_cut),"read");
      TH1F *hJpsiCounts[2][7];
      TCanvas *c = new TCanvas("comp_JpsiCounts", "comp_JpsiCounts", 1100, 500);
      c->Divide(4,2);
      TLegend *leg = new TLegend(0.3,0.3,0.6,0.6);
      leg->SetBorderSize(0);
      leg->SetFillColor(0);
      leg->SetTextFont(62);
      leg->SetTextSize(0.08);
      for(int k=0; k<7; k++)
	{
	  for(int j=0; j<2; j++)
	    {
	      if(k<5) hJpsiCounts[j][k] = (TH1F*)fSig[j]->Get(Form("Jpsi_FitYield_cent%s_weight",cent_Title[k]));
	      else    hJpsiCounts[j][k] = (TH1F*)fSig[j]->Get(Form("Jpsi_FitYield_pt%s_weight",pt_Name_npart[k-5]));
	      hJpsiCounts[j][k]->SetName(Form("%s_%d",hJpsiCounts[j][k]->GetName(),j));
	      hJpsiCounts[j][k]->SetMarkerStyle(21+j*4);
	      hJpsiCounts[j][k]->SetMarkerColor(j+1);
	      hJpsiCounts[j][k]->SetLineColor(j+1);

	      c->cd(k+1);
	      gPad->SetLogy();
	      if(k==2 || k==3) hJpsiCounts[j][k]->GetXaxis()->SetRangeUser(0.5,10);
	      if(k==4) hJpsiCounts[j][k]->GetXaxis()->SetRangeUser(0.5,6);
	      hJpsiCounts[j][k]->SetTitle(";;Counts");
	      if(k<5) hJpsiCounts[j][k]->SetXTitle("p_{T} [GeV/c]");
	      if(j==0) hJpsiCounts[j][k]->Draw();
	      else     hJpsiCounts[j][k]->Draw("sames");
	      if(k==0) leg->AddEntry(hJpsiCounts[j][k], dataType[j], "P");
	    }
	  if(k<5) TPaveText *t1 = GetTitleText(Form("%s: %s%%",run_type,cent_Name[k]),0.06);
	  else    TPaveText *t1 = GetTitleText(Form("%s: %s",run_type,pt_Title_npart[k-5]),0.06);
	  t1->Draw();
	}
      c->cd(8);
      leg->Draw();
      if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_CompAll/Compare_JpsiCounts.pdf",run_type));
    }
  if(compEff)
    {
      const char *trkEffType[6] = {"MC","Tpc","MtdMth","MuonPid","MtdTrig","TrigUnit"};
      TFile *fEff[2];
      fEff[0] = TFile::Open(Form("Rootfiles/%s.EmbJpsiEff.pt%1.1f.pt%1.1f.root",run_type,pt1_cut,pt2_cut),"read");
      fEff[1] = TFile::Open(Form("Rootfiles/old.%s.EmbJpsiEff.pt%1.1f.pt%1.1f.root",run_type,pt1_cut,pt2_cut),"read");

      const int nHistos = 6;
      TH1F *hJpsiPt[2][nHistos][nCentBins];
      TH1F *hJpsiPtEffs[2][nHistos][nCentBins];
      for(int j=0; j<2; j++)
	{
	  for(int i=0; i<nHistos; i++)
	    {
	      for(int k=0; k<nCentBins; k++)
		{
		  hJpsiPt[j][i][k] = (TH1F*)fEff[j]->Get(Form("hJpsiPt_%s_cent%s",trkEffType[i],cent_Title[k]));
		  hJpsiPt[j][i][k]->SetName(Form("%s_file%d",hJpsiPt[j][i][k]->GetName(),j));
		  hJpsiPt[j][i][k]->Rebin(4);
		  int index = i-1;
		  if(i==0) index = 0;
		  hJpsiPtEffs[j][i][k] = DivideTH1ForEff(hJpsiPt[j][i][k],hJpsiPt[j][index][k],Form("hJpsiPtEff_%s_cent%s_file%d",trkEffType[i],cent_Title[k],j));
		}
	    }
	}

      // various efficiency
      const int kcent = 0;
      for(int i=1; i<nHistos; i++)
	{
	  hJpsiPtEffs[0][i][kcent]->Divide(hJpsiPtEffs[1][i][kcent]);
	  list->Add(hJpsiPtEffs[0][i][kcent]);
	}
      TString legName2[5] = {"TPC tracking + p_{T,#mu} cut","MTD acceptance & response","Muon PID","MTD triggering","Trigger unit"};
      c = drawHistos(list,"JpsiEff_AllEffs",Form("%s: efficiencies for J/#psi ;p_{T} (GeV/c);New/Old",run_type),true,0,15,true,0.8,1.2,false,kTRUE,legName2,true,Form("%s%%",cent_Name[kcent]),0.2,0.4,0.63,0.88,kTRUE,0.04,0.035);
      if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_CompAll/Compare_JpsiEff_AllTypes.pdf",run_type));
      list->Clear();
    }

  if(compRef)
    {
      TFile *fpp[2];
      fpp[0] = TFile::Open(Form("Rootfiles/Paper.%s.Jpsi.root",run_type),"read");
      fpp[1] = TFile::Open(Form("Rootfiles/Comb2.Paper.%s.Jpsi.root",run_type),"read");
      TGraphAsymmErrors	*hppJpsiVsPt[2];
      TGraphAsymmErrors	*hppJpsiVsCent[2];
      double x, y, x1, y1;
      for(int j=0; j<2; j++)
	{
	  hppJpsiVsPt[j]   = (TGraphAsymmErrors*)fpp[j]->Get("hpp200JpsiVsPtFinalSys");
	  hppJpsiVsPt[j]->SetName(Form("%s_%d",hppJpsiVsPt[j]->GetName(),j));
	  hppJpsiVsPt[j]->SetMarkerStyle(21+j*4);
	  hppJpsiVsPt[j]->SetMarkerColor(j+1);
	  hppJpsiVsPt[j]->SetLineColor(j+1);
	  offset_x(hppJpsiVsPt[j], 0.1*j);
	  hppJpsiVsCent[j] = (TGraphAsymmErrors*)fpp[j]->Get("hpp200JpsiVsCentFinalSys");
	  hppJpsiVsCent[j]->SetName(Form("%s_%d",hppJpsiVsCent[j]->GetName(),j));
	  hppJpsiVsCent[j]->SetMarkerStyle(21+j*4);
	  hppJpsiVsCent[j]->SetMarkerColor(j+1);
	  hppJpsiVsCent[j]->SetLineColor(j+1);
	  offset_x(hppJpsiVsCent[j], 0.1*j);
	}

      for(int j=0; j<2; j++)
	{
	  for(int ipoint=0; ipoint<hppJpsiVsPt[j]->GetN(); ipoint++)
	    {
	      hppJpsiVsPt[1]->GetPoint(ipoint, x, y);
	      hppJpsiVsPt[j]->GetPoint(ipoint, x1, y1);
	      hppJpsiVsPt[j]->SetPoint(ipoint, x1, y1/y);
	      hppJpsiVsPt[j]->SetPointError(ipoint, hppJpsiVsPt[j]->GetErrorXlow(ipoint), hppJpsiVsPt[j]->GetErrorXhigh(ipoint),
					    hppJpsiVsPt[j]->GetErrorYlow(ipoint)/y, hppJpsiVsPt[j]->GetErrorYhigh(ipoint)/y);
	    }

	  for(int ipoint=0; ipoint<hppJpsiVsCent[j]->GetN(); ipoint++)
	    {
	      hppJpsiVsCent[1]->GetPoint(ipoint, x, y);
	      hppJpsiVsCent[j]->GetPoint(ipoint, x1, y1);
	      hppJpsiVsCent[j]->SetPoint(ipoint, x1, y1/y);
	      hppJpsiVsCent[j]->SetPointError(ipoint, hppJpsiVsCent[j]->GetErrorXlow(ipoint), hppJpsiVsCent[j]->GetErrorXhigh(ipoint),
					    hppJpsiVsCent[j]->GetErrorYlow(ipoint)/y, hppJpsiVsCent[j]->GetErrorYhigh(ipoint)/y);
	    }
	}
      hppJpsiVsPt[1]->GetYaxis()->SetRangeUser(0.5,1.5);
      c = drawGraph(hppJpsiVsPt[1],"Ratio of pp reference;p_{T} [GeV/c];Ratio");
      hppJpsiVsPt[0]->Draw("samesPEZ");
      TLegend *leg = new TLegend(0.6,0.7,0.8,0.85);
      leg->SetBorderSize(0);
      leg->SetFillColor(0);
      leg->SetTextFont(62);
      leg->SetTextSize(0.035);
      leg->AddEntry(hppJpsiVsPt[0], "(STAR+PHENIX)/STAR", "P");
      leg->AddEntry(hppJpsiVsPt[1], "STAR/STAR", "P");
      leg->Draw();
      if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_CompAll/Compare_ppRefVsPt.pdf",run_type));

      hppJpsiVsCent[1]->GetXaxis()->SetRangeUser(-0.5,6.5);
      hppJpsiVsCent[1]->GetYaxis()->SetRangeUser(0.5,1.5);
      c = drawGraph(hppJpsiVsCent[1],"Ratio of pp reference;;Ratio");
      hppJpsiVsCent[0]->Draw("samesPEZ");
      leg->Draw();
      if(savePlot) c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_CompAll/Compare_ppRefVsCent.pdf",run_type));
    }
}