Regarding programming


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


I am a M.Sc. student and i am new to root.
now i need to plot the histogram of azimuthal correlation of e+e- and for this i am using pythia8 and using pythia i have saved the data regarding azimuthal angle for both e+e- in .root extension file now i need correlation between the phi so i don’t know how should i write a program

{
TH2F *phi = new TH2F("pT","Opening Angle; |#phi_{#mu1} - #phi_{#mu2}|[rad];dN/d#Delta#phi[rad^{-1}]", 200, 0., 3.5, 200, 0.0,180.0);

//TH2F *pT = new TH2F("pT","pT; pT[GeV/c];dN/dpT[c/GeV]", 200, 0., 3.5, 200, 0.0,180.0);
//TH2F *pT1 = new TH2F("pT1","pT1; pT[GeV/c];dN/dpT[c/GeV]", 200, 0., 5.5, 200, 0.0,2500.0);
//TH2F *pT2 = new TH2F("pT2","pT2; pT[GeV/c];dN/dpT[c/GeV]", 200, 0., 5.5, 200, 0.0,2500.0);

TFile f("root3.root");
TCut cut1 = "(sqrt((e1+e2)*(e1+e2)-(px1+px2)*(px1+px2)-(py1+py2)*(py1+py2)-(pz1+pz2)*(pz1+pz2)))>1.5";
TCut cut2 = "(sqrt((e1+e2)*(e1+e2)-(px1+px2)*(px1+px2)-(py1+py2)*(py1+py2)-(pz1+pz2)*(pz1+pz2)))<2.5";
TCut cut3 = "(px1*px1+py1*py1+pz1*pz1)>3 && (px2*px2+py2*py2+pz2*pz2)>3";
TCut cut4 = "abs(eta2)>1.2 && abs(eta2)<2.2";
TCut cut5 = "abs(eta1)>1.2 && abs(eta1)<2.2";
TCut cut6 =  cut3;
T->Draw("sqrt((px1+px2)*(px1+px2)+(py1+py2)*(py1+py2))");
PC->Draw("(sqrt((e1+e2)*(e1+e2)-(px1+px2)*(px1+px2)-(py1+py2)*(py1+py2)-(pz1+pz2)*(pz1+pz2)))");
TH1F *htemp = (TH1F*)gPad->GetPrimitive("htemp");
htemp->SetTitle("Pair pT; pT; count");

for(double i = 0.; i<3.5; i += 0.5)
	{
	  int bmin = htemp->FindBin(i); 
  	  int bmax = htemp->FindBin(i+0.5); 
  	  double integral = htemp->Integral(bmin,bmax);
	  double x = (i+i+0.5)/2 ;
	
	  phi->Fill( x, integral/0.5 );
	}
phi->SetMarkerStyle(20);
phi->SetMarkerColor(kBlue);
phi->Draw();

}

i know i need to apply for loop but i don’t know how
please help me

Hi,

It is not clear to me exactly what you need to do in ROOT and what your problem is, Please elaborate a bit more.

Lorenzo

actually i need azimuthal correlation of e+ and e- for this i write a program and store phi value as phi1 for e+ and phi2 for e- in two branches and create a root file. now i am not getting how to proceed with my next code. the above is the code . i asked someone about it then he said that i need to relate phi1 with each value of phi2 for every value of phi1. so for this i need a for loop but i don’t know how to proceed.
please help me

Hi,
you can check out RDataFrame to easily create branches and write them to file. The documentation comes with a crash course, and afterwards you can check out the many tutorials to see how things are done in practice.

Hope this helps!
Enrico