# Member function error of two different classes

**URL:** <https://root-forum.cern.ch/t/member-function-error-of-two-different-classes/46821>\
**Category:** Newbie\
**Created:** [September 14, 2021, 2:42am UTC](https://root-forum.cern.ch/t/member-function-error-of-two-different-classes/46821 "2021-09-14T02:42:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hrideychetri](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/b5ac83/32.png) [@hrideychetri](https://root-forum.cern.ch/u/hrideychetri)\
**Post date:** [September 14, 2021, 2:42am UTC](https://root-forum.cern.ch/t/member-function-error-of-two-different-classes/46821/1 "2021-09-14T02:42:15Z")

</div>

I have access to my data using RDataframe and stored it in a four-momentum vector of class TLoentzvector, Now I wanted to know the pdg code for each event, but I have the function GetPdgCode() in TParticle class. Can you please help me with how to get the pdg code of the events stored in a four-momentum vector using the GetPdgCode() function?

Here I have attached a small part of the code

```auto
auto angle(const std::vector<ROOT::Math::PxPyPzMVector>& ang) {

	TParticle obj;
	int pdg=obj.GetPdgCode();
	ROOT::Math::PxPyPzMVector phi, theta, rho;
	for(uint i=0; i<ang.size(); i++) {
	ROOT::Math::PxPyPzMVector prt=ang[i];
	if(fabs(pdg == 11)) {
	std::cout<<pdg<<std::endl;
	theta +=prt;
}
}
return theta.Theta();
}

```

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [September 14, 2021, 6:48am UTC](https://root-forum.cern.ch/t/member-function-error-of-two-different-classes/46821/2 "2021-09-14T06:48:42Z")

</div>

Welcome to the ROOT Forum!

> [@hrideychetri](#):
>
> ```auto
> TParticle obj;
> int pdg=obj.GetPdgCode();
> 
> ```

This cannot work. You can search for `GetPdgCode` on this forum, or look at the `${ROOTSYS}/tutorials/pythia/pythia8.C` tutorial for an example woth the `TParticle` class.
