Init();
Reset();
SetNtinit();
- SetName("Unspecified");
- SetTitle("Unspecified");
}
///////////////////////////////////////////////////////////////////////////
void AliJet::Init()
cout << endl;
SetNtinit();
}
- SetName("Unspecified");
- SetTitle("Unspecified");
}
///////////////////////////////////////////////////////////////////////////
AliJet::~AliJet()
AliTrack* tx=j.GetTrack(i);
if (fTrackCopy)
{
- fTracks->Add(new AliTrack(*tx));
+ fTracks->Add(tx->Clone());
}
else
{
// space will be extended to hold an additional amount of tracks as
// was initially reserved.
// See SetTrackCopy() to tailor the functionality of the stored structures.
+//
+// Note :
+// In case a private copy is made, this is performed via the Clone() memberfunction.
+// All AliTrack and derived classes have the default TObject::Clone() memberfunction.
+// However, derived classes generally contain an internal data structure which may
+// include pointers to other objects. Therefore it is recommended to provide
+// for all derived classes a specific copy constructor and override the default Clone()
+// memberfunction using this copy constructor.
+// An example for this may be seen from AliTrack.
+
AddTrack(t,1);
}
///////////////////////////////////////////////////////////////////////////
// of the TrackCopy flag.
// This allows a proper treatment of automatically generated connecting
// tracks between vertices.
+//
+// Note :
+// In case a private copy is made, this is performed via the Clone() memberfunction.
+
if (!fTracks)
{
fTracks=new TObjArray(fNtmax);
fNtrk++;
if (fTrackCopy && copy)
{
- fTracks->Add(new AliTrack(t));
+ fTracks->Add(t.Clone());
}
else
{
void AliJet::Data(TString f)
{
// Provide jet information within the coordinate frame f
- cout << " *AliJet::Data* Name : " << GetName() << " Title : " << GetTitle() << endl;
+ const char* name=GetName();
+ const char* title=GetTitle();
+
+ cout << " *AliJet::Data*";
+ if (strlen(name)) cout << " Name : " << GetName();
+ if (strlen(title)) cout << " Title : " << GetTitle();
+ cout << endl;
cout << " Id : " << fUserId << " Invmass : " << GetInvmass() << " Charge : " << fQ
<< " Momentum : " << GetMomentum() << " Ntracks : " << fNtrk << endl;
return fUserId;
}
///////////////////////////////////////////////////////////////////////////
+TObject* AliJet::Clone(char* name)
+{
+// Make a deep copy of the current object and provide the pointer to the copy.
+// This memberfunction enables automatic creation of new objects of the
+// correct type depending on the object type, a feature which may be very useful
+// for containers when adding objects in case the container owns the objects.
+// This feature allows e.g. AliVertex to store either AliJet objects or
+// objects derived from AliJet via the AddJet memberfunction, provided
+// these derived classes also have a proper Clone memberfunction.
+
+ AliJet* jet=new AliJet(*this);
+ if (name)
+ {
+ if (strlen(name)) jet->SetName(name);
+ }
+ return jet;
+}
+///////////////////////////////////////////////////////////////////////////