Error: base operand of ‘->’ is not a pointer

Hi

my error error: “base operand of ‘->’ is not a pointer”

and part of the code:
TFile::Open("/home/jacek/pluto_v5.42.4/macros/acc/acceptances.root");
(proton_acc = (TH3F*) gROOT->FindObject(“ProtonAcc”));
PParticle *p;
#define R2D 57;

for (int p = 0; p <= Npart; p++)
{
//pi_reco.SetXYZM(p_x,p_y,p_z,0.000139570);
//cout<<Particles_pid[p]<<endl;

		if (Particles_pid[p] == 14)
		{
			hist = proton_acc;	
			int bin = hist->FindBin(p->P()*1000,p->Theta() * R2D,int(p->Phi() * R2D + 180) % 60);
			//int bin = hist -> FindBin(x,y,z);
		//	float w1 = hist->GetBinContent(1,1);

		}

}

I have no idea where I`m making an error.

Cheers && Thanks

J.

[quote=“bfgk10”] for (int p = 0; p <= Npart; p++) { // ... int bin = hist->FindBin(p->P()*1000,p->Theta() * 57,int(p->Phi() * 57 + 180) % 60); }

my error error: “base operand of ‘->’ is not a pointer”
[/quote]

p is an int, so e.g. p->P() makes no sense. You might have been thinking of some object (from some particle class I’d say), but here p is your loop counter.