I am trying to set a private class member after I have created the object with a constructor. This constructor set a bunch of public members but doesn't touch the private member.
class Tower {
std::vector<Tower> jtowers;
public:
Double_t E;
Double_t Et;
void SetJTowers( std::vector<Tower> );
std::vector<Tower> GetJTowers() { return jtowers; }
Tower ();
Tower (TLorentzVector,std::vector<Double_t>); //For jTowers
Tower (TLorentzVector,std::vector<Double_t>,std::pair<bool,bool>); //For gTowers
Tower (TLorentzVector,std::vector<Double_t>,std::pair<bool,bool>,std::vector<Tower>); //For seed gTowers
};
The constructor looks like this:
Tower::Tower (TLorentzVector FourVec,
std::vector<Double_t> otherTowerInfo,
std::pair<bool,bool> SeedRho_info) {
E = FourVec.E();
Et = FourVec.Et();
};
void Tower::SetJTowers (std::vector<Tower> constJTowers) {
jtowers = constJTowers;
};
I then call a function that accepts a reference to a Tower object, does some fun stuff, and then attempts to set the jtowers member.
void AngularResolution :: ConstituentJTowers ( Tower& gT ) {
// Find constituent jTowers
std::vector<Tower> constJTowers;
// code to fill constJTowers
std::cout << constJTowers.size() << std::endl; // This will a nonzero size
gT.SetJTowers(constJTowers);
std::cout << gT.GetJTowers().size() << std::endl; // As will this
}
But when I attempt to check the contents of gT.GetJTowers() later in my code, I still find that it is empty, as if the original object is not being modified.
Any help is appreciated thanks!
Aucun commentaire:
Enregistrer un commentaire