Hello!
I have created a class which inherits from TLorentzVector and another which inherits from TObject. I can compil this class into a .o file easily but when I try to link this object when creating an executable I get an error
undefined reference to vtable for ZEvent
The class is all contained in the .hpp file which is as follows:
class ZJet : public TLorentzVector
{
public:
explicit ZJet() : TLorentzVector() { Clear(); }
//virtual ~ZJet() { Clear(); }
ZJet::~ZJet() { Clear(); }
//ZJet(ZJet const&) { } //copy constructor???
//float ntrk;
void Clear( const Option_t* = "" )
{
(*this) *= 0.; // this will reset the TLorentzVector to (0.,0.,0.,0.)
//ntrk=-999;
for(size_t i = 14; i < 22; ++i ) ResetBit(BIT(i));
}
friend std::ostream &operator << ( std::ostream &s, const ZJet &d )
{ d.Dump(); return s; }
ClassDef(ZJet,1)
};
class ZEvent : public TObject
{
public:
typedef std::vector<float> Vfloat;
typedef ZJet Jet;
//-- PV
float npvs, pv_x, pv_y, pv_z, pv_mbprob, pv_ntracks, pv_sumpt;
protected:
//-- the -> flag in comments helps to improve TCLonesArray I/O operations
TClonesArray *fJets; //->
public:
explicit ZEvent() :
TObject()
{
fJets = new TClonesArray( Jet::Class()->GetName(),10 );
Clear();
}
//virtual ~ZEvent()
ZEvent::~ZEvent()
{
Clear();
SafeDelete( fJets );
}
Jet& AddJet() { return *( new ( (*fJets) [ NbJet() ] ) Jet() ); }
size_t NbJet() const { return fJets->GetEntriesFast(); }
const Jet& GetJet( size_t i ) const { return *( (Jet*) fJets->At( i ) ); }
Jet& GetJet( size_t i ) { return *( (Jet*) fJets->At( i ) ); }
size_t GetNJets( CStr& option ) { return GetJets( option ).size(); }
std::vector<int>
GetJets( CStr& option )
{
std::vector<int> jets;
if( option == "loose" ) {
for( size_t i = 0; i < NbJet(); ++i ) { if( GetJet(i).IsLoose() ) jets.push_back(i); }
} else if( option == "tight" ) {
for( size_t i = 0; i < NbJet(); ++i ) { if( GetJet(i).IsTight() ) jets.push_back(i); }
} else {
for( size_t i = 0; i < NbJet(); ++i ) { jets.push_back(i ); }
}
return jets;
}
// Clean-up whole event
void Clear( Option_t * = "" )
{
// Rest all variables to default values
npvs = pv_x = pv_y = pv_z = pv_mbprob = pv_ntracks = pv_sumpt = 0.;
//-- The "C" option will force each TClonesArray elements to call their own
// Clear() method. So we have full control of the event cleaning from here
if( fJets ) fJets ->Clear("C");
}
friend std::ostream &operator << ( std::ostream &s, const ZEvent &d )
{ d.Dump(); return s; }
ClassDef(ZEvent,1)
};
I do not have any virtual functions that can be causing this vtable error. Any ideas?
Thanks!