// ______________________________________________________________________________________
void plotVsDeltaEta_nice(const Char_t* name = "ratioVsDeltaEta") {

  gROOT->LoadMacro("include/toolsEtaNice.C++");

  SetupStyle();

  SetGlobals();

  // -----------------------------------------------------

  TFile *inFiles[nEtaSets][nDataSets][nMoments];

  TGraphErrors *graphs[nEtaSets][nDataSets][nMoments];

  for (int idxEta = 0 ; idxEta < nEtaSets; ++idxEta) 
    for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) 
      for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) { 
	inFiles[idxEta][idxDataSet][idxMoment] = TFile::Open(Form("output/%s/%s/Moments_%s.root", 
								  aEtaSets[idxEta], aDataSets[idxDataSet], aMoments[idxMoment]));
	graphs[idxEta][idxDataSet][idxMoment] = static_cast<TGraphErrors*>((inFiles[idxEta][idxDataSet][idxMoment]->Get(aMoments[idxMoment]))->Clone());
	if (inFiles[idxEta][idxDataSet][idxMoment])
	  (inFiles[idxEta][idxDataSet][idxMoment])->Close();
      }
  
  // -----------------------------------------------------
  
  TLegend *legRat[nDataSets];
  
  for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
    legRat[idxDataSet] = new TLegend(0.12, 0.12, 0.70, 0.495);
    legRat[idxDataSet]->SetTextAlign(12);
    legRat[idxDataSet]->SetTextSize(0.06);
    legRat[idxDataSet]->SetFillColor(1182);
    legRat[idxDataSet]->SetLineColor(0);
    legRat[idxDataSet]->SetBorderSize(0);
  }

  // -----------------------------------------------------

  TGraphErrors *etaGraphs[9][nDataSets][nMoments];

  for (int idxCent = 0; idxCent < nCent; idxCent++) {
    for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
      for (int idxMoment = 4 ; idxMoment < nMoments; ++idxMoment) {
	float y[nEtaSets];
	float ey[nEtaSets];
	for (int idxEta = 0 ; idxEta < nEtaSets; ++idxEta) {	
	  y[idxEta]  = graphs[idxEta][idxDataSet][idxMoment]->GetY()[idxCent];
	  ey[idxEta] = graphs[idxEta][idxDataSet][idxMoment]->GetEY()[idxCent];
	} 
	
	etaGraphs[idxCent][idxDataSet][idxMoment] = new TGraphErrors(nEtaSets, aEtaSetBinWidth, y, 0, ey);
	PrepareGraph(etaGraphs[idxCent][idxDataSet][idxMoment]);
	
      } // for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) {
    } // for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
  } // for (int idxCent = 0; idxCent < 9; idxCent++) {

  // -----------------------------------------------------

  for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
    TPad *pad = SetupCanvas(Form("canDeltaEta_Ratio_%s", aDataSets[idxDataSet]), aDataSetsTitle[idxDataSet], "#Delta#eta", 0.48);
    
    for (int idxMoment = 4 ; idxMoment < nMoments; ++idxMoment) {
      pad->cd(idxMoment-3);
      
      for (int idxCent = 0; idxCent < 9; idxCent++) {
	if (idxCent != 0 && idxCent != 1 && idxCent != 8 && idxCent != 4 )
	  continue;
	
	TGraphErrors *g = etaGraphs[idxCent][idxDataSet][idxMoment];
	
	if (idxCent == 0) 
	  ShiftGraphX(g, -0.015);
	else if (idxCent == 1) 
	  ShiftGraphX(g, -0.005);
	else if (idxCent == 4) 
	  ShiftGraphX(g, 0.005);
	else if (idxCent == 8) 
	  ShiftGraphX(g, 0.015);
	
	ConfigGraph(g, idxMoment, idxCent);
	
	if (idxCent == 0) {
	  g->Draw("AP");
	  
	  if (idxMoment == 5) {
	    // TLine *line0 = new TLine(aMinX, 0, aMaxX, 0);
	    // line0->SetLineColor(kGray+1);
	    // line0->SetLineStyle(2);
	    // line0->SetLineWidth(2);
	    // line0->Draw();
	  }
	  else if (idxMoment == 6) {
	    TLine *line1 = new TLine(aMinX, 1, aMaxX, 1);
	    line1->SetLineColor(kGray+1);
	    line1->SetLineStyle(2);
	    line1->SetLineWidth(2);
	    line1->Draw();
	    legRat[idxDataSet]->AddEntry(line1, "Poisson", "l");
	  }
	}
	
	g->Draw("PSAME");
	
	if (idxMoment == 4) 
	  legRat[idxDataSet]->AddEntry(etaGraphs[idxCent][idxDataSet][4], Form("%s", cent1[idxCent]), "pl");
	
      } // for (int idxCent = 0; idxCent < 9; idxCent++) { 
    } // for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) {
    
    pad->cd(2);
    TLatex *texb_3 = new TLatex(0.05, 0.55, "Au+Au collisions #sqrt{#it{s}_{NN}} = 14.5 GeV");
    texb_3->SetTextSize(0.07);
    texb_3->Draw("same");
    
    TLatex *texb_3a = new TLatex(0.05, 0.49, "Net-Charge, 0.2 < #it{p}_{T} (GeV/#it{c}) < 2.0, 0-5%");
    texb_3a->SetTextSize(0.07);
    texb_3a->Draw("same");
    
    TLatex *texb_3b = new TLatex(0.05,0.44, "statistical errors only");
    texb_3b->SetTextSize(0.06);
    texb_3b->Draw("same");
    
    pad->cd(1);
    TLatex *texb_4 = new TLatex(0.7, 19, "STAR Preliminary");
    texb_4->SetTextSize(0.07);
    texb_4->Draw("same");
    
    pad->cd(3);
    legRat[idxDataSet]->Draw();
    
    pad->Modified();
  } // for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
  
  // -----------------------------------------------------

  SaveCanvas(name);

  // -----------------------------------------------------
  
  TFile *fOut = TFile::Open("STAR_QM2015_Preliminary.root", "UPDATE");
  fOut->cd();
  
  TList* list = new TList;

  for (int idxMoment = 4; idxMoment < nMoments; ++idxMoment) {
    for (int idxCent = 0; idxCent < nCent; ++idxCent) {
      if (idxCent > 1) 
	continue;

      if (idxCent == 0) 
	ShiftGraphX(etaGraphs[idxCent][0][idxMoment], 0.015);
      else if (idxCent == 1) 
	ShiftGraphX(etaGraphs[idxCent][0][idxMoment], 0.005);
      else if (idxCent == 4) 
	ShiftGraphX(etaGraphs[idxCent][0][idxMoment], -0.005);
      else if (idxCent == 8) 
	ShiftGraphX(etaGraphs[idxCent][0][idxMoment], -0.015);
      
      etaGraphs[idxCent][0][idxMoment]->SetName(Form("Net-Charge_%s_DeltaEta_14.5GeV_%s_stat", aMoments[idxMoment], cent[idxCent]));
      list->Add(etaGraphs[idxCent][0][idxMoment]);
    }
  }

  list->Write("Net-Charge_VsDeltaEta", TObject::kSingleKey);
  fOut->Close();
}
Ejemplo n.º 2
0
// ______________________________________________________________________________________
void plotEnergyKaon(const Char_t* name = "ratioNetKaonVsEnergy") {

  Int_t idxNames = kNetK;

  gROOT->LoadMacro("include/toolsEnergyNice.C++");
  gROOT->LoadMacro("include/getPublished.C++");

  SetupStyle();

  SetGlobals();

  getPublished();

  // -----------------------------------------------------

  TFile *inFiles[nEnergies][nMoments];
  TFile *inFilesUrqmd[nEnergies];

  TGraphErrors *inGraphsStat[nEnergies][nMoments+1];
  TGraphErrors *inGraphsPoisson[nEnergies][nMoments];
  TGraphErrors *inGraphsUrqmd[nEnergies][nMoments];

  for (int idxEnergy = 0; idxEnergy < nEnergies; ++idxEnergy) { 

    if (idxEnergy != 2)
      inFilesUrqmd[idxEnergy]= TFile::Open(Form("URQMD/urqmd_kaon/AuAu%sGeV_Vz30_kpi1.root", exactEnergies[idxEnergy]));

    for (int idxMoment = 0; idxMoment < nMoments; ++idxMoment) { 
      // -- value and stat errors
      inFiles[idxEnergy][idxMoment] = TFile::Open(Form("%s/%sGeV/moments_ana/Moments_%s.root", 
						       aNames[idxNames], exactEnergies[idxEnergy], aMoments[idxMoment]));

      inGraphsStat[idxEnergy][idxMoment] = (idxMoment != 5) ? static_cast<TGraphErrors*>((inFiles[idxEnergy][idxMoment]->Get(aMoments[idxMoment]))->Clone()) :
      	static_cast<TGraphErrors*>((inFiles[idxEnergy][idxMoment]->Get(Form("%s_Poisson_ratio", aMoments[idxMoment])))->Clone());

      if (idxMoment == 5) // get SK also
	inGraphsStat[idxEnergy][nMoments] = static_cast<TGraphErrors*>((inFiles[idxEnergy][idxMoment]->Get(aMoments[idxMoment]))->Clone());

      // -- poisson
      inGraphsPoisson[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFiles[idxEnergy][idxMoment]->Get(Form("%s_Poisson_base", aMoments[idxMoment])))->Clone());
      
      if (inFiles[idxEnergy][idxMoment])
       	inFiles[idxEnergy][idxMoment]->Close();
      
      // -- urqmd
      if (idxEnergy != 2) {
       	if (idxMoment == 4) 
       	  inGraphsUrqmd[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFilesUrqmd[idxEnergy]->Get(Form("R21")))->Clone());
	else if (idxMoment == 5) 
       	  inGraphsUrqmd[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFilesUrqmd[idxEnergy]->Get(Form("%s_Pos_ratio", aMoments[idxMoment])))->Clone());
       	else if (idxMoment == 6) 
       	  inGraphsUrqmd[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFilesUrqmd[idxEnergy]->Get(aMoments[idxMoment]))->Clone());
      }
    }
  }

  // -----------------------------------------------------
  // -- Make graphs
  
  for (int idxEnergy = 0; idxEnergy < nEnergies; ++idxEnergy) { 
    for (int idxMoment = 4; idxMoment < nMoments+1; ++idxMoment) {   
      for (int idxCent = 0; idxCent < nCent; ++idxCent) {
	if (idxCent != 0 && idxCent != 8)
	  continue;

	Double_t xIn, yIn;
	inGraphsStat[idxEnergy][idxMoment]->GetPoint(idxCent, xIn, yIn);
	Double_t yErrorStatIn = inGraphsStat[idxEnergy][idxMoment]->GetErrorY(idxCent);

	Int_t accessCent = (idxCent == 0) ? 0 : 1;
	Int_t accessMoment = idxMoment - 4;
	Double_t yErrorSysIn  = sysErrors[accessMoment][accessCent][idxEnergy];

	for (Int_t idx = 0; idx < 2; ++idx) {
	  Double_t xBin = (idx == 0) ? snn[idxEnergy] : mub[idxEnergy];
	  graphStat[idx][idxMoment][idxCent]->SetPoint(idxEnergy, xBin, yIn);
	  graphStat[idx][idxMoment][idxCent]->SetPointError(idxEnergy, 0, yErrorStatIn);
	  graphSys[idx][idxMoment][idxCent]->SetPoint(idxEnergy, xBin, yIn);
	  graphSys[idx][idxMoment][idxCent]->SetPointError(idxEnergy, 0, yErrorSysIn);
	}
	
	if (idxMoment == nMoments)
	  continue;

	inGraphsPoisson[idxEnergy][idxMoment]->GetPoint(idxCent, xIn, yIn);    
	for (Int_t idx = 0; idx < 2; ++idx) {
	  Double_t xBin = (idx == 0) ? snn[idxEnergy] : mub[idxEnergy];
	  graphPoisson[idx][idxMoment][idxCent]->SetPoint(idxEnergy, xBin, yIn);
	}

	if (idxCent == 0 && idxEnergy != 2) {
	  Double_t yErrorUrqmdIn = inGraphsUrqmd[idxEnergy][idxMoment]->GetErrorY(idxCent);	

	  inGraphsUrqmd[idxEnergy][idxMoment]->GetPoint(idxCent, xIn, yIn);    
	  for (Int_t idx = 0; idx < 2; ++idx) {
	    Double_t xBin = (idx == 0) ? snn[idxEnergy] : mub[idxEnergy];
	    Int_t energyArrayAccess = (idxEnergy >= 2) ? idxEnergy-1 : idxEnergy;
	    graphUrqmd[idx][idxMoment][idxCent]->SetPoint(energyArrayAccess, xBin, yIn);
	    graphUrqmd[idx][idxMoment][idxCent]->SetPointError(energyArrayAccess, 0, yErrorUrqmdIn);
	  }
	}
      } // for (int idxCent = 0; idxCent < nCent; ++idxCent) {
    } // for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) {   
  } // for (int idxEnergy = 0 ; idxEnergy < nEnergies; ++idxEnergy) { 

  // -----------------------------------------------------

  SetupCanvas(name, Form("%s Ratio energy dependence", aNames[idxNames]));
  CreateLegends(2, 3, 0.4, 0.09);

  // -----------------------------------------------------

  for (int idxMoment = 4; idxMoment < nMoments; ++idxMoment) {
    pad->cd(idxMoment-3);
    gPad->SetLogx();

    for (int idxCent = 0; idxCent < nCent; ++idxCent) {
      if (idxCent != 0 && idxCent != 8)
	continue;

      DrawSet(graphStat[0][idxMoment][idxCent],  graphSys[0][idxMoment][idxCent],
	      graphUrqmd[0][idxMoment][idxCent], graphPoisson[0][idxMoment][idxCent],
	      idxMoment, idxCent);
    } // for (int idxCent = 0; idxCent < nCent; ++idxCent) {

    graphStat[0][idxMoment][0]->Draw("ZP,SAME");
    graphSys[0][idxMoment][0]->Draw("[],SAME");
  } // for (int idxMoment = 4; idxMoment < nMoments; ++idxMoment) {

  legTheo->AddEntry(graphUrqmd[0][4][0], Form("%s UrQMD", cent1[0]), "f");
      
  // -----------------------------------------------------

  LabelCanvas(aNames[idxNames], aNamesPt[idxNames]);
  SaveCanvas(name);

  // -----------------------------------------------------

  TFile *fOut = TFile::Open("STAR_QM2015_Preliminary.root", "UPDATE");
  fOut->cd();
  
  TList* list = new TList;
  
  for (int idxMoment = 4; idxMoment < nMoments+1; ++idxMoment) {
    for (int idxCent = 0; idxCent < nCent; ++idxCent) {
      if (idxCent != 0) 
	continue;
      
      graphStat[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_stat", aNames[idxNames], aMoments2[idxMoment], cent[idxCent]));
      graphSys[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_sys",  aNames[idxNames], aMoments2[idxMoment], cent[idxCent]));
      
      list->Add(graphStat[0][idxMoment][idxCent]);
      list->Add(graphSys[0][idxMoment][idxCent]);
    }
  }
  list->Write(aNames[idxNames], TObject::kSingleKey);
  fOut->Close();

  // -----------------------------------------------------

  TFile *fOutAll = TFile::Open("STAR_Preliminary.root", "UPDATE");
  fOutAll->cd();
  
  TList* listAll = new TList;

  for (int idxMoment = 4; idxMoment < nMoments+1; ++idxMoment) {
    for (int idxCent = 0; idxCent < nCent; ++idxCent) {
      if (graphStat[0][idxMoment][idxCent] && graphStat[0][idxMoment][idxCent]->GetN() > 0) {
	graphStat[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_stat", aNames[idxNames], aMoments2[idxMoment], cent[idxCent]));
	listAll->Add(graphStat[0][idxMoment][idxCent]);
      }
      if (graphSys[0][idxMoment][idxCent] && graphSys[0][idxMoment][idxCent]->GetN() > 0) {
	graphSys[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_sys", aNames[idxNames], aMoments2[idxMoment], cent[idxCent]));
	listAll->Add(graphSys[0][idxMoment][idxCent]);
      }

      if (idxMoment == nMoments)
	continue;

      if (graphUrqmd[0][idxMoment][idxCent] && graphUrqmd[0][idxMoment][idxCent]->GetN() > 0) {
	graphUrqmd[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_urqmd", aNames[idxNames], aMoments2[idxMoment], cent[idxCent]));
	listAll->Add(graphUrqmd[0][idxMoment][idxCent]);
      }
      if (graphPoisson[0][idxMoment][idxCent] && graphPoisson[0][idxMoment][idxCent]->GetN() > 0) {
	graphPoisson[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_poisson", aNames[idxNames], aMoments2[idxMoment], cent[idxCent]));
	listAll->Add(graphPoisson[0][idxMoment][idxCent]);
      }
    }
  }
  listAll->Write(aNames[idxNames], TObject::kSingleKey);
  fOutAll->Close();
}
Ejemplo n.º 3
0
static void RunEditorInternal(SOCKET &s) {
	std::vector<DWORD*> vec = std::vector<DWORD*>();
	for(int elv=0;elv<3;elv++) {
		for(int tile=0;tile<40000;tile++) {
			DWORD* obj;
			__asm {
				mov edx, tile;
				mov eax, elv;
				call obj_find_first_at_tile_;
				mov obj, eax;
			}
			while(obj) {
				DWORD otype = obj[25];
				otype = (otype&0xff000000) >> 24;
				if(otype==1) vec.push_back(obj);
				__asm {
					call obj_find_next_at_tile_;
					mov obj, eax;
				}
			}
		}
	}

	int numCritters=vec.size();

	int numGlobals=*(int*)_num_game_global_vars;
	int numMapVars=*(int*)_num_map_global_vars;
	int numSGlobals=GetNumGlobals();
	int numArrays=GetNumArrays();
	InternalSend(s, &numGlobals, 4);
	InternalSend(s, &numMapVars, 4);
	InternalSend(s, &numSGlobals, 4);
	InternalSend(s, &numArrays, 4);
	InternalSend(s, &numCritters, 4);

	sGlobalVar* sglobals=new sGlobalVar[numSGlobals];
	GetGlobals(sglobals);
	int* arrays=new int[numArrays*3];
	GetArrays(arrays);

	InternalSend(s, *(void**)_game_global_vars, 4*numGlobals);
	InternalSend(s, *(void**)_map_global_vars, 4*numMapVars);
	InternalSend(s, sglobals, sizeof(sGlobalVar)*numSGlobals);
	InternalSend(s, arrays, numArrays*3*4);
	for(int i=0;i<numCritters;i++) InternalSend(s, &vec[i][25], 4);

	while(true) {
		BYTE code;
		InternalRecv(s, &code, 1);
		if(code==CODE_EXIT) break;
		int id, val;
		switch(code) {
			case 0:
				InternalRecv(s, &id, 4);
				InternalRecv(s, &val, 4);
				(*(DWORD**)_game_global_vars)[id]=val;
				break;
			case 1:
				InternalRecv(s, &id, 4);
				InternalRecv(s, &val, 4);
				(*(DWORD**)_map_global_vars)[id]=val;
				break;
			case 2:
				InternalRecv(s, &id, 4);
				InternalSend(s, vec[id], 0x74);
				break;
			case 3:
				InternalRecv(s, &id, 4);
				InternalRecv(s, vec[id], 0x74);
				break;
			case 4:
				InternalRecv(s, &id, 4);
				InternalRecv(s, &val, 4);
				sglobals[id].val=val;
				break;
			case 9:
				{
				InternalRecv(s, &id, 4);
				DWORD *types=new DWORD[arrays[id*3+1]];
				char *data=new char[arrays[id*3+1]*arrays[id*3+2]];
				DEGetArray(arrays[id*3], types, data);
				InternalSend(s, types, arrays[id*3+1]*4);
				InternalSend(s, data, arrays[id*3+1]*arrays[id*3+2]);
				delete[] data;
				delete[] types;
				}
				break;
			case 10:
				{
				InternalRecv(s, &id, 4);
				char *data=new char[arrays[id*3+1]*arrays[id*3+2]];
				InternalRecv(s, data, arrays[id*3+1]*arrays[id*3+2]);
				DESetArray(arrays[id*3], 0, data);
				delete[] data;
				}
				break;
		}
	}

	SetGlobals(sglobals);
	delete[] sglobals;
	delete[] arrays;
}
// ______________________________________________________________________________________
void plotEnergyProtonOverview(const Char_t* name = "ratioNetProtonVsEnergyOverview") {

  Int_t idxNames = kNetP;

  gROOT->LoadMacro("include/toolsEnergyNice.C++");
  gROOT->LoadMacro("include/getPublished.C++");

  SetupStyle();

  SetGlobals();

  getPublished();

  // -----------------------------------------------------

  TFile *inFiles[nEnergies];
  TFile *inFilesUrqmd[nEnergies];

  TGraphErrors *inGraphsStat[nEnergies][nMoments];
  TGraphErrors *inGraphsSys[nEnergies][nMoments];
  TGraphErrors *inGraphsPoisson[nEnergies][nMoments];
  TGraphErrors *inGraphsUrqmd[nEnergies][nMoments];

  for (int idxEnergy  = 0 ; idxEnergy < nEnergies; ++idxEnergy) { 
    inFiles[idxEnergy] = TFile::Open(Form("Net-Proton/moments_%sGeV_preli.root", energies[idxEnergy]));

    if (idxEnergy != 2)
      inFilesUrqmd[idxEnergy]= TFile::Open(Form("URQMD/urqmd_proton/AuAu%sGeV_netp_refmult3_y0.5.root", exactEnergies[idxEnergy]));
    
    for (int idxMoment = 4 ; idxMoment < nMoments; ++idxMoment) { 

      // -- value and stat errors
      inGraphsStat[idxEnergy][idxMoment] = (idxMoment != 5) ? 
       	static_cast<TGraphErrors*>((inFiles[idxEnergy]->Get(Form("%s_stat", aMoments[idxMoment])))->Clone()) :
       	static_cast<TGraphErrors*>((inFiles[idxEnergy]->Get(Form("%s_pos_ratio_stat", aMoments[idxMoment])))->Clone());
      
      // -- sysErrors     
      inGraphsSys[idxEnergy][idxMoment] = (idxMoment != 5) ? 
       	static_cast<TGraphErrors*>((inFiles[idxEnergy]->Get(Form("%s_sys", aMoments[idxMoment])))->Clone()) :
       	static_cast<TGraphErrors*>((inFiles[idxEnergy]->Get(Form("%s_pos_ratio_sys", aMoments[idxMoment])))->Clone());
      
      // -- poisson
      if (idxMoment == 4)
	inGraphsPoisson[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFiles[idxEnergy]->Get(Form("%s_base_pos_stat", aMoments[idxMoment])))->Clone());
      
      // -- urqmd
      if (idxEnergy !=2) {
	if (idxMoment == 4) 
          inGraphsUrqmd[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFilesUrqmd[idxEnergy]->Get(Form("R21")))->Clone());
	else if (idxMoment == 5) 
          inGraphsUrqmd[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFilesUrqmd[idxEnergy]->Get(Form("%s_Pos_ratio", aMoments[idxMoment])))->Clone());
	else if (idxMoment == 6) 
	  inGraphsUrqmd[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFilesUrqmd[idxEnergy]->Get(aMoments[idxMoment]))->Clone());
      }
    }
    
    if (inFiles[idxEnergy])
      inFiles[idxEnergy]->Close();
  }
  
  // -----------------------------------------------------
  // -- Make graphs
  
  for (int idxEnergy  = 0; idxEnergy < nEnergies; ++idxEnergy) { 
    for (int idxMoment = 4; idxMoment < nMoments; ++idxMoment) {   
      for (int idxCent = 0; idxCent < nCent; ++idxCent) {
	if (idxCent != 0 && idxCent != 1 && idxCent != 8)
	  continue;

	Double_t xIn, yIn;
	inGraphsStat[idxEnergy][idxMoment]->GetPoint(idxCent, xIn, yIn);
	Double_t yErrorStatIn = inGraphsStat[idxEnergy][idxMoment]->GetErrorY(idxCent);
	Double_t yErrorSysIn  = inGraphsSys[idxEnergy][idxMoment]->GetErrorY(idxCent);

	for (Int_t idx = 0; idx < 2; ++idx) {
	  Double_t xBin = (idx == 0) ? snn[idxEnergy] : mub[idxEnergy];  
	  graphStat[idx][idxMoment][idxCent]->SetPoint(idxEnergy, xBin, yIn);
	  graphStat[idx][idxMoment][idxCent]->SetPointError(idxEnergy, 0, yErrorStatIn);
	  graphSys[idx][idxMoment][idxCent]->SetPoint(idxEnergy, xBin, yIn);
	  graphSys[idx][idxMoment][idxCent]->SetPointError(idxEnergy, 0, yErrorSysIn);
	}
	
	if (idxMoment == 4) {
	  inGraphsPoisson[idxEnergy][idxMoment]->GetPoint(idxCent, xIn, yIn);    
	  for (Int_t idx = 0; idx < 2; ++idx) {
	    Double_t xBin = (idx == 0) ? snn[idxEnergy] : mub[idxEnergy];  
	    graphPoisson[idx][idxMoment][idxCent]->SetPoint(idxEnergy, xBin, yIn);
	  }
	}

	if (idxCent == 0 && idxEnergy != 2) {
	  Double_t yErrorUrqmdIn = inGraphsUrqmd[idxEnergy][idxMoment]->GetErrorY(idxCent);	

	  inGraphsUrqmd[idxEnergy][idxMoment]->GetPoint(idxCent, xIn, yIn);    
	  for (Int_t idx = 0; idx < 2; ++idx) {
	    Double_t xBin = (idx == 0) ? snn[idxEnergy] : mub[idxEnergy];
	    Int_t energyArrayAccess = (idxEnergy >= 2) ? idxEnergy-1 : idxEnergy;
	    graphUrqmd[idx][idxMoment][idxCent]->SetPoint(energyArrayAccess, xBin, yIn);
	    graphUrqmd[idx][idxMoment][idxCent]->SetPointError(energyArrayAccess, 0, yErrorUrqmdIn);
	  }
	}

      } // for (int idxCent = 0; idxCent < nCent; ++idxCent) {
    } // for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) {   
  } // for (int idxEnergy = 0 ; idxEnergy < nEnergies; ++idxEnergy) { 

  // -----------------------------------------------------

  SetupCanvas(name, Form("%s Ratio energy dependence", aNames[idxNames]));
  CreateLegends(2, 3, 0.4, 0.28);

  // -----------------------------------------------------

  for (int idxMoment = 4; idxMoment < nMoments; ++idxMoment) {
    pad->cd(idxMoment-3);
    gPad->SetLogx();

    for (int idxCent = 0; idxCent < nCent; ++idxCent) {
      if (idxCent != 0 && idxCent != 8)
	continue;

      DrawSet(graphStat[0][idxMoment][idxCent],  graphSys[0][idxMoment][idxCent],
	      graphUrqmd[0][idxMoment][idxCent], graphPoisson[0][idxMoment][idxCent],
	      idxMoment, idxCent);
    } // for (int idxCent = 0; idxCent < nCent; ++idxCent) {

    graphStat[0][idxMoment][0]->Draw("ZP,SAME");
    graphSys[0][idxMoment][0]->Draw("[],SAME");
  } // for (int idxMoment = 4; idxMoment < nMoments; ++idxMoment) {

  legTheo->AddEntry(graphUrqmd[0][4][0], Form("%s UrQMD", cent1[0]), "f");
      
  // -----------------------------------------------------

  LabelCanvas(aNames[idxNames], aNamesPt[idxNames]);
  SaveCanvas(name);
}
Ejemplo n.º 5
0
// ______________________________________________________________________________________
void plotVsEta_nice(const Char_t* name = "ratioVsEta") {

    gROOT->LoadMacro("include/toolsEtaNice.C++");

    SetupStyle();

    SetGlobals();

    // -----------------------------------------------------

    TFile *inFiles[nEtaSets][nDataSets][nMoments];

    TGraphErrors *graphs[nEtaSets][nDataSets][nMoments];

    for (int idxEta = 0 ; idxEta < nEtaSets; ++idxEta)
        for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet)
            for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) {
                inFiles[idxEta][idxDataSet][idxMoment] = TFile::Open(Form("output/%s/%s/Moments_%s.root",
                        aEtaSets[idxEta], aDataSets[idxDataSet], aMoments[idxMoment]));
                graphs[idxEta][idxDataSet][idxMoment] = static_cast<TGraphErrors*>((inFiles[idxEta][idxDataSet][idxMoment]->Get(aMoments[idxMoment]))->Clone());
                if (inFiles[idxEta][idxDataSet][idxMoment])
                    (inFiles[idxEta][idxDataSet][idxMoment])->Close();
            }

    // -----------------------------------------------------

    TLegend *legRat[nDataSets];

    for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
        legRat[idxDataSet] = new TLegend(0.14, 0.12, 0.78, 0.27);
        legRat[idxDataSet]->SetTextAlign(12);
        legRat[idxDataSet]->SetTextSize(0.06);
        legRat[idxDataSet]->SetFillColor(1182);
        legRat[idxDataSet]->SetLineColor(0);
        legRat[idxDataSet]->SetBorderSize(0);
        legRat[idxDataSet]->SetNColumns(3);
    }

    // -----------------------------------------------------

    TGraphErrors *etaGraphs[9][nEtaSuperSets][nDataSets][nMoments];

    for (int idxCent = 0; idxCent < nCent; idxCent++) {
        for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
            for (int idxMoment = 4 ; idxMoment < nMoments; ++idxMoment) {

                int idxEta = -1;
                for (int idxEtaSuper = 0 ; idxEtaSuper < nEtaSuperSets; ++idxEtaSuper) {
                    float x[aEtaSuperSets[idxEtaSuper]];
                    float y[aEtaSuperSets[idxEtaSuper]];
                    float ex[aEtaSuperSets[idxEtaSuper]];
                    float ey[aEtaSuperSets[idxEtaSuper]];

                    for (int idxEtaSub = 0 ; idxEtaSub < aEtaSuperSets[idxEtaSuper]; ++idxEtaSub) {
                        ++idxEta;

                        x[idxEtaSub]  = aEtaSetBinCenter[idxEta];
                        ex[idxEtaSub] = aEtaSetBinWidth[idxEta]/2.;
                        y[idxEtaSub]  = graphs[idxEta][idxDataSet][idxMoment]->GetY()[idxCent];
                        ey[idxEtaSub] = graphs[idxEta][idxDataSet][idxMoment]->GetEY()[idxCent];
                    } // for (int idxEtaSub = 0 ; idxEtaSub < aEtaSuperSets[idxEtaSuper]; ++idxEtaSub) {

                    etaGraphs[idxCent][idxEtaSuper][idxDataSet][idxMoment] = new TGraphErrors(aEtaSuperSets[idxEtaSuper], x, y, ex, ey);
                    PrepareGraph(etaGraphs[idxCent][idxEtaSuper][idxDataSet][idxMoment]);
                } // for (int idxEtaSuper = 0 ; idxEtaSuper < nEtaSuperSets; ++idxEtaSuper) {

            } // for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) {
        } // for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
    } // for (int idxCent = 0; idxCent < 9; idxCent++) {

    // -----------------------------------------------------

    for (int idxCent = 0; idxCent < 1; idxCent++) {
        for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
            TPad *pad = SetupCanvas(Form("canEta_Ratio_%s_%s", aDataSets[idxDataSet], cent[idxCent]), aDataSetsTitle[idxDataSet], "#eta", 0.45);

            for (int idxEtaSuper = 0 ; idxEtaSuper < nEtaSuperSets; ++idxEtaSuper) {

                if (idxEtaSuper == 1 || idxEtaSuper == 3 || idxEtaSuper == 5 || idxEtaSuper == 7 || idxEtaSuper == 8 )
                    continue;

                for (int idxMoment = 4 ; idxMoment < nMoments; ++idxMoment) {
                    pad->cd(idxMoment-3);

                    TGraphErrors *g = etaGraphs[idxCent][idxEtaSuper][idxDataSet][idxMoment];

                    // if (idxCent == 0)
                    //   ShiftGraphX(g, -0.015);
                    // else if (idxCent == 1)
                    //   ShiftGraphX(g, -0.005);
                    // else if (idxCent == 4)
                    //   ShiftGraphX(g, 0.005);
                    // else if (idxCent == 8)
                    //   ShiftGraphX(g, 0.015);

                    ConfigGraph(g, idxMoment, idxEtaSuper);

                    if (idxEtaSuper == 0) {
                        g->Draw("AP");

                        TLine *line05 = new TLine( 0.5, aMinY[idxMoment],  0.5, aMaxY[idxMoment]);
                        line05->SetLineColor(kGray+1);
                        line05->SetLineStyle(3);
                        line05->Draw();

                        TLine *line50 = new TLine(-0.5, aMinY[idxMoment], -0.5, aMaxY[idxMoment]);
                        line50->SetLineColor(kGray+1);
                        line50->SetLineStyle(3);
                        line50->Draw();

                        TLine *line00 = new TLine(0., aMinY[idxMoment],0, aMaxY[idxMoment]);
                        line00->SetLineColor(kGray+1);
                        line00->SetLineStyle(3);
                        line00->Draw();

                        if (idxMoment == 5) {
                            // TLine *line0 = new TLine(aMinX, 0, aMaxX, 0);
                            // line0->SetLineColor(kGray+1);
                            // line0->SetLineStyle(2);
                            // line0->SetLineWidth(2);
                            // line0->Draw();
                        }
                        else if (idxMoment == 6) {
                            TLine *line1 = new TLine(aMinX, 1, aMaxX, 1);
                            line1->SetLineColor(kGray+1);
                            line1->SetLineStyle(2);
                            line1->SetLineWidth(2);
                            line1->Draw();
                        }
                    }
                    g->Draw("PSAME");

                } // for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) {

                if (idxCent == 0)  {
                    legRat[idxDataSet]->AddEntry(etaGraphs[0][idxEtaSuper][idxDataSet][4],
                                                 Form("#Delta#eta = %.1f", aEtaSuperSetsBinWidth[idxEtaSuper]), "pl");
                }
            } // for (int idxEta = 0 ; idxEta < nEta; ++idxEta) {

            TLine *linex = new TLine(-0.55, 1, 0.55, 1);
            linex->SetLineColor(kGray+1);
            linex->SetLineStyle(2);
            linex->SetLineWidth(2);
            legRat[idxDataSet]->AddEntry(linex, "Poisson", "l");

            pad->cd(1);
            TLatex *texb_3 = new TLatex(-0.49, 9.3, "Au+Au collisions #sqrt{#it{s}_{NN}} = 14.5 GeV");
            texb_3->SetTextSize(0.07);
            texb_3->Draw("same");

            TLatex *texb_3a = new TLatex(-0.49,8.9, "Net-Charge, 0.2 < #it{p}_{T} (GeV/#it{c}) < 2.0, 0-5%");
            texb_3a->SetTextSize(0.07);
            texb_3a->Draw("same");

            pad->cd(2);
            TLatex *texb_3b = new TLatex(0.49,0.42, "statistical errors only");
            texb_3b->SetTextSize(0.06);
            texb_3b->SetTextAlign(31);
            texb_3b->Draw("same");

            TLatex *texb_3c = new TLatex(0.49,0.38, "horizontal error: #Delta#eta width");
            texb_3c->SetTextSize(0.06);
            texb_3c->SetTextAlign(31);
            texb_3c->Draw("same");

            TLatex *texb_4 = new TLatex(-0.49, 0.42, "STAR Preliminary");
            texb_4->SetTextSize(0.07);
            texb_4->Draw("same");

            pad->cd(3);
            legRat[idxDataSet]->Draw("lt");

            pad->Modified();
        } // for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
    } // for (int idxCent = 0; idxCent < 9; idxCent++) {

    // -----------------------------------------------------

    SaveCanvas(name);
}