Transvers distribution fpdg=21

Hello ROOTers;

I tried to build a program that make a chain from this two root files tree.root (11.3 KB) tree2.root (20.1 KB)
and then build a histogram entries vs pt for a specific particle pdg=21. I made this:


		TFile hfile("hfile.root","recreate"); //create a root file

		TChain ch("tree");	//create a chain of tree

		TCanvas c1("c1","pt distribution pdg 21",700,500);	//create a canvas 700x500 

		ch.Add("tree.root");	//add tree to chain

		// devo creare un istogramma e riempirlo con quelle variabili
		TH1F h("h","pt distribution pdg 21",100,0,8);

		//now i need to creare a for in order to fill h 
		//and choose right particle fpdg="21"

		h.GetXaxis().SetTitle("P_t [MeV]");	//set axis names
		h.SetTitle("pt distribution pdg 21");
		h.Draw("((fPx*fPx)+(fPy*fPy))^0.5");	//draw pt
		hfile.Write();	//write on root file
		hfile.Close();	//close root file

How can I make a for cycle and fill my h with the variable ((fPxfPx)+(fPyfPy))^0.5 ? And how can i choose the particle?

Thanks for all!

_ROOT Version: 6.18
_Platform: Xubuntu 19.04
_Compiler: gcc version 7.3.0

  TChain ch("tree");
  TH1F h("h", "pt distribution pdg 21;P_{t} [MeV];Entries", 100, 0., 8.);
  h.SetDirectory(gROOT); // just a precaution
  ch.Project("h", "pow((fPx*fPx)+(fPy*fPy), 0.5)", "fPdgCode == 21");
  TFile hfile("hfile.root", "recreate");
  //; // just a precaution

1 Like

Can you explain this?

Can i do in a similar way with for? I tried this:

Float_t fPx,fPy;
  		ch.SetBranchAddress("fPx",&fPx);	//set branch address
  		for(Int_t i=0; i<=ch.GetEntries(); i++){
    	//h.Fill(); ???

If it is possible, how can i fill h and how can i put the condition for fpdg code? I ask only for improve my skills. Thanks for the fast reply.



1 Like

And what about this? Is it possible to fill ? How can I insert the option for pdg code into for cycle?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.