26-apr-2002 NvE AddVetoSignal(AliSignal) introduced in AliCalorimeter and AliCalcluster
to provide more flexibility and allow automatic calculation of
hit association confidence level based on position uncertainties.
29-apr-2002 NvE Memberfunction GetNvalues() and copy constructor introduced in AliSignal.
25-jun-2002 NvE Memberfunction SetOwner() introduced in AliJet, AliVertex and AliEvent to allow
to set ownership of "added objects" in the case of reading data from a file.
In this way possible memory leaks can always be prevented.
Also automatic extrapolation and confidence level calculation of associated
veto hits introduced in AliCalorimeter and AliCalcluster.
fColdisp=0.;
fNvetos=0;
fVetos=0;
-}
+ }
}
///////////////////////////////////////////////////////////////////////////
Int_t AliCalcluster::GetRow()
}
}
///////////////////////////////////////////////////////////////////////////
-void AliCalcluster::AddVetoSignal(Float_t* r,TString f,Float_t s)
+void AliCalcluster::AddVetoSignal(AliSignal& s,Int_t extr)
{
-// Associate an (extrapolated) AliSignal at location r as veto to the cluster.
-// The signal value s indicates the confidence level of hit association
-// and has to be provided by the user.
-// Note : The default signal value (s) is 0
+// Associate an (extrapolated) AliSignal as veto to the cluster.
+// By default a straight line extrapolation is performed which extrapolates
+// the signal position until the length of its position vector matches that
+// of the position vector of the cluster.
+// In this extrapolation procedure the error propagation is performed
+// automatically.
+// Based on the cluster and extrapolated veto signal (x,y) positions and
+// position errors the confidence level of association is calculated
+// and stored as an additional signal value.
+// By means of the GetVetoSignal memberfunction the confidence level of
+// association can always be updated by the user.
+// In case the user wants to invoke a more detailed extrapolation procedure,
+// the automatic extrapolation can be suppressed by setting the argument
+// extr=0. In this case it is assumed that the AliSignal as entered via
+// the argument contains already the extrapolated position vector and
+// corresponding errors.
+// Note : Three additional values are added to the original AliSignal
+// to hold the chi2, ndf and confidence level values of the association.
if (!fVetos)
{
fNvetos=0;
fVetos->SetOwner();
}
- fVetos->Add(new AliSignal(1));
- fNvetos++;
+ Int_t nvalues=s.GetNvalues();
+ AliSignal* sx=new AliSignal(nvalues+3); // Additional value added
+ TString name=s.GetName();
+ name.Append(" + additional chi2, ndf and CL values");
+ sx->SetName(name);
+
+ Double_t vecc[3],vecv[3];
+ if (!extr)
+ {
+ sx->SetPosition((Ali3Vector&)s);
+ }
+ else
+ {
+ // Extrapolate the veto hit position
+ Double_t scale=1;
+ GetPosition(vecc,"sph");
+ s.GetPosition(vecv,"sph");
+ if (vecv[0]) scale=vecc[0]/vecv[0];
+ Ali3Vector r=s*scale;
+ sx->SetPosition(r);
+ }
- ((AliSignal*)fVetos->At(fNvetos-1))->SetPosition(r,f);
- ((AliSignal*)fVetos->At(fNvetos-1))->SetSignal(s);
+ Double_t sig,err;
+ for (Int_t i=1; i<=nvalues; i++)
+ {
+ sig=s.GetSignal(i);
+ err=s.GetSignalError(i);
+ sx->SetSignal(sig,i);
+ sx->SetSignalError(err,i);
+ }
+
+ // Calculate the confidence level of association
+ GetPosition(vecc,"car");
+ sx->GetPosition(vecv,"car");
+ Double_t dx=vecc[0]-vecv[0];
+ Double_t dy=vecc[1]-vecv[1];
+ GetPositionErrors(vecc,"car");
+ sx->GetPositionErrors(vecv,"car");
+ Double_t sxc2=vecc[0]*vecc[0];
+ Double_t syc2=vecc[1]*vecc[1];
+ Double_t sxv2=vecv[0]*vecv[0];
+ Double_t syv2=vecv[1]*vecv[1];
+ Double_t sumx2=sxc2+sxv2;
+ Double_t sumy2=syc2+syv2;
+ Double_t chi2=0;
+ if (sumx2>0 && sumy2>0) chi2=(dx*dx/sumx2)+(dy*dy/sumy2);
+ Int_t ndf=2;
+ AliMath m;
+ Double_t prob=m.Prob(chi2,ndf);
+ if (chi2>0) sx->SetSignal(chi2,nvalues+1);
+ if (ndf>0) sx->SetSignal(ndf,nvalues+2);
+ if (prob>0) sx->SetSignal(prob,nvalues+3);
+
+ fVetos->Add(sx);
+ fNvetos++;
}
///////////////////////////////////////////////////////////////////////////
Int_t AliCalcluster::GetNvetos()
// Provide the confidence level of best associated veto signal.
Float_t cl=0;
Float_t clmax=0;
+ AliSignal* s=0;
+ Int_t nvalues=0;
if (fVetos)
{
for (Int_t i=0; i<fNvetos; i++)
{
- cl=((AliSignal*)fVetos->At(i))->GetSignal();
- if (cl>clmax) clmax=cl;
+ s=((AliSignal*)fVetos->At(i));
+ if (s)
+ {
+ nvalues=s->GetNvalues();
+ cl=s->GetSignal(nvalues);
+ if (cl>clmax) clmax=cl;
+ }
}
}
return clmax;
// Investigate if cluster has an associated veto hit with conf. level > cl.
// Returns 1 if there is such an associated veto hit, otherwise returns 0.
// Note : This function is faster than GetVetoLevel().
+ AliSignal* s=0;
+ Int_t nvalues=0;
if (fVetos)
{
for (Int_t i=0; i<fNvetos; i++)
{
- if (((AliSignal*)fVetos->At(i))->GetSignal() > cl) return 1;
+ s=((AliSignal*)fVetos->At(i));
+ if (s)
+ {
+ nvalues=s->GetNvalues();
+ if (s->GetSignal(nvalues) > cl) return 1;
+ }
}
}
return 0;
#include "TString.h"
#include "AliCalmodule.h"
+#include "AliMath.h"
class AliCalcluster : public TObject,public AliPosition
{
Float_t GetColumnDispersion(); // Return normalised column dispersion of cluster
void Start(AliCalmodule& m); // Reset cluster data to start with module m
void Add(AliCalmodule& m); // Add module data to cluster
- void AddVetoSignal(Float_t* r,TString f,Float_t s=0); // Associate (extrapolated) signal
+ void AddVetoSignal(AliSignal& s,Int_t extr=1); // Associate (extrapolated) signal
+ void AddVetoSignal(AliSignal* s,Int_t extr=1) { AddVetoSignal(*s,extr); }
AliSignal* GetVetoSignal(Int_t j); // Access to veto signal number j
Int_t GetNvetos(); // Provide the number of veto signals
Float_t GetVetoLevel(); // Provide confidence level of best associated veto hit
Int_t fNvetos; // The number of associated veto signals
TObjArray* fVetos; // The array of associated veto signals
- ClassDef(AliCalcluster,1) // Description of a cluster of calorimeter modules.
+ ClassDef(AliCalcluster,2) // Description of a cluster of calorimeter modules.
};
#endif
// Float_t vec[3]={6,1,20};
// cal.SetPosition(2,8,vec,"car");
//
+// AliSignal s;
// Float_t loc[3]={-1,12,3};
-// cal.AddVetoSignal(loc,"car"); // Associate (extrapolated) position as a veto
+// s.SetPosition(loc,"car");
+// s.SetSignal(328);
+// cal.AddVetoSignal(s); // Associate (extrapolated) signal as a veto
//
// cal.Group(2); // Group 'fired' modules into clusters
// // Perform grouping over 2 rings around the center
// Destructor to delete memory allocated to the various arrays and matrix
if (fModules)
{
- fModules->Delete();
delete fModules;
fModules=0;
}
if (fClusters)
{
- fClusters->Delete();
delete fClusters;
fClusters=0;
}
if (fVetos)
{
- fVetos->Delete();
delete fVetos;
fVetos=0;
}
fNrows=nrow;
fNcolumns=ncol;
fNsignals=0;
+ fModules=0;
fNclusters=0;
fClusters=0;
fAttributes=new TMatrix(nrow,ncol);
(*fAttributes)(i,ncol-1)=10;
}
- fModules=new TObjArray(); // Default size, expanded automatically
- fModules->SetOwner();
-
fHmodules=0;
fHclusters=0;
AliCalmodule* m=fMatrix[row-1][col-1];
if (!m) // only count new modules
{
+ if (!fModules)
+ {
+ fModules=new TObjArray(); // Default size, expanded automatically
+ fModules->SetOwner();
+ }
fNsignals++;
- m=new AliCalmodule;
+ m=new AliCalmodule();
AliPosition* r=fPositions[row-1][col-1];
if (r) m->SetPosition(*r);
fModules->Add(m);
AliCalmodule* m=fMatrix[row-1][col-1];
if (!m) // No module existed yet at this position
{
+ if (!fModules)
+ {
+ fModules=new TObjArray(); // Default size, expanded automatically
+ fModules->SetOwner();
+ }
fNsignals++;
m=new AliCalmodule;
fModules->Add(m);
// Note : Module gains, edge and dead flags remain unchanged
if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input
-
+
fNsignals=0;
- if (fModules) fModules->Delete();
+ if (fModules)
+ {
+ delete fModules;
+ fModules=0;
+ }
for (Int_t i=0; i<fNrows; i++)
{
for (Int_t j=0; j<fNcolumns; j++)
fNclusters=0;
if (fClusters)
{
- fClusters->Delete();
delete fClusters;
fClusters=0;
}
fNvetos=0;
if (fVetos)
{
- fVetos->Delete();
delete fVetos;
fVetos=0;
}
// Clustering of modules. Start with the highest signal.
if (fClusters)
{
- fClusters->Delete();
delete fClusters;
fClusters=0;
}
}
}
///////////////////////////////////////////////////////////////////////////
-void AliCalorimeter::AddVetoSignal(Float_t* r,TString f,Float_t s)
+void AliCalorimeter::AddVetoSignal(AliSignal& s)
{
-// Associate an (extrapolated) AliSignal at location r as veto to the cal.
-// Note : The default signal value (s) is 0
+// Associate an (extrapolated) AliSignal as veto to the calorimeter.
if (!fVetos)
{
fNvetos=0;
fVetos->SetOwner();
}
- fVetos->Add(new AliSignal);
- fNvetos++;
+ Int_t nvalues=s.GetNvalues();
+ AliSignal* sx=new AliSignal(nvalues);
+ sx->SetName(s.GetName());
+
+ sx->SetPosition((Ali3Vector&)s);
- ((AliSignal*)fVetos->At(fNvetos-1))->SetPosition(r,f);
- ((AliSignal*)fVetos->At(fNvetos-1))->SetSignal(s);
+ Double_t sig,err;
+ for (Int_t i=1; i<=nvalues; i++)
+ {
+ sig=s.GetSignal(i);
+ err=s.GetSignalError(i);
+ sx->SetSignal(sig,i);
+ sx->SetSignalError(err,i);
+ }
+
+ fVetos->Add(sx);
+ fNvetos++;
}
///////////////////////////////////////////////////////////////////////////
Int_t AliCalorimeter::GetNvetos()
AliPosition* GetPosition(Int_t row,Int_t col); // Access to module position
TH2F* DrawModules(); // Draw lego plot of module signals
TH2F* DrawClusters(); // Draw lego plot of cluster signals
- void AddVetoSignal(Float_t* r,TString f,Float_t s=0); // Associate (extrapolated) signal
+ void AddVetoSignal(AliSignal& s); // Associate (extrapolated) signal
+ void AddVetoSignal(AliSignal* s) { AddVetoSignal(*s); }
AliSignal* GetVetoSignal(Int_t j); // Access to veto signal number j
Int_t GetNvetos(); // Provide the number of veto signals
void SetName(TString name); // Set the name of the calorimeter system
AliPosition ***fPositions; //! Matrix of module position pointers for internal use
TString fName; // Name of the calorimeter system
- ClassDef(AliCalorimeter,1) // Description of a modular calorimeter system.
+ ClassDef(AliCalorimeter,2) // Description of a modular calorimeter system.
};
#endif
* provided "as is" without express or implied warranty. *
**************************************************************************/
-// $Id: AliEvent.cxx,v 1.5 2002/01/18 08:46:59 nick Exp $
+// $Id: AliEvent.cxx,v 1.6 2002/04/26 11:23:37 nick Exp $
///////////////////////////////////////////////////////////////////////////
// Class AliEvent
// creating only one AliCalorimeter instance in the main programme and using the
// AliCalorimeter::Reset() and AliCalorimeter parameter setting memberfunctions.
//
+// See also the documentation provided for the memberfunction SetOwner().
+//
// Coding example to make an event consisting of a primary vertex,
// 2 secondary vertices and a calorimeter.
// --------------------------------------------------------------
// Note : All quantities are in GeV, GeV/c or GeV/c**2
//
//--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht
-//- Modified: NvE $Date: 2002/01/18 08:46:59 $ UU-SAP Utrecht
+//- Modified: NvE $Date: 2002/04/26 11:23:37 $ UU-SAP Utrecht
///////////////////////////////////////////////////////////////////////////
#include "AliEvent.h"
{
// Create an event to hold initially a maximum of n tracks
// All variables initialised to default values
+ cout << "AliEvent init with n = " << n << endl;
fDaytime.Set();
fRun=0;
fEvent=0;
// Reset all variables to default values
// The max. number of tracks is set to the initial value again
// The max. number of vertices is set to the default value again
+// Note : The CalCopy mode is maintained as it was set by the user before.
fDaytime.Set();
fRun=0;
fEvent=0;
AliVertex::Reset();
}
///////////////////////////////////////////////////////////////////////////
+void AliEvent::SetOwner(Bool_t own)
+{
+// Set ownership of all added objects.
+// The default parameter is own=kTRUE.
+//
+// Invokation of this memberfunction also sets all the copy modes
+// (e.g. TrackCopy & co.) according to the value of own.
+//
+// This function (with own=kTRUE) is particularly useful when reading data
+// from a tree/file, since Reset() will then actually remove all the
+// added objects from memory irrespective of the copy mode settings
+// during the tree/file creation process. In this way it provides a nice way
+// of preventing possible memory leaks in the reading/analysis process.
+//
+// In addition this memberfunction can also be used as a shortcut to set all
+// copy modes in one go during a tree/file creation process.
+// However, in this case the user has to take care to only set/change the
+// ownership (and copy mode) for empty objects (e.g. newly created objects
+// or after invokation of the Reset() memberfunction) otherwise it will
+// very likely result in inconsistent destructor behaviour.
+
+ Int_t mode=1;
+ if (!own) mode=0;
+ if (fCalorimeters) fCalorimeters->SetOwner(own);
+ fCalCopy=mode;
+
+ AliVertex::SetOwner(own);
+}
+///////////////////////////////////////////////////////////////////////////
void AliEvent::SetDayTime(TDatime& stamp)
{
// Set the date and time stamp for this event
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */
-// $Id: AliEvent.h,v 1.2 2001/07/04 15:59:20 nick Exp $
+// $Id: AliEvent.h,v 1.3 2002/04/26 11:23:37 nick Exp $
#include <iomanip.h>
#include <math.h>
AliEvent(); // Default constructor
AliEvent(Int_t n); // Create an event to hold initially n tracks
~AliEvent(); // Default destructor
+ virtual void SetOwner(Bool_t own=kTRUE);// Set ownership of all added objects
void SetDayTime(TDatime& stamp); // Set the date and time stamp
void SetRunNumber(Int_t run); // Set the run number
void SetEventNumber(Int_t evt); // Set the event number
TObjArray* fCalorimeters; // Array to hold the pointers to the calorimeter systems
Int_t fCalCopy; // Flag to denote creation of private copies in fCalorimeters
- ClassDef(AliEvent,2) // Creation and investigation of an Alice physics event.
+ ClassDef(AliEvent,3) // Creation and investigation of an Alice physics event.
};
#endif
// creating only one AliTrack instance in the main programme and using the
// AliTrack::Reset() and AliTrack parameter setting memberfunctions.
//
+// See also the documentation provided for the memberfunction SetOwner().
+//
// Coding example to make 2 jets j1 and j2.
// ----------------------------------------
// j1 contains the AliTracks t1 and t2
}
}
///////////////////////////////////////////////////////////////////////////
+void AliJet::SetOwner(Bool_t own)
+{
+// Set ownership of all added objects.
+// The default parameter is own=kTRUE.
+//
+// Invokation of this memberfunction also sets all the copy modes
+// (e.g. TrackCopy & co.) according to the value of own.
+//
+// This function (with own=kTRUE) is particularly useful when reading data
+// from a tree/file, since Reset() will then actually remove all the
+// added objects from memory irrespective of the copy mode settings
+// during the tree/file creation process. In this way it provides a nice way
+// of preventing possible memory leaks in the reading/analysis process.
+//
+// In addition this memberfunction can also be used as a shortcut to set all
+// copy modes in one go during a tree/file creation process.
+// However, in this case the user has to take care to only set/change the
+// ownership (and copy mode) for empty objects (e.g. newly created objects
+// or after invokation of the Reset() memberfunction) otherwise it will
+// very likely result in inconsistent destructor behaviour.
+
+ Int_t mode=1;
+ if (!own) mode=0;
+ if (fTracks) fTracks->SetOwner(own);
+ fTrackCopy=mode;
+}
+///////////////////////////////////////////////////////////////////////////
AliJet::AliJet(AliJet& j)
{
// Copy constructor
AliJet(); // Default constructor
AliJet(Int_t n); // Create a Jet to hold initially n Tracks
~AliJet(); // Default destructor
+ virtual void SetOwner(Bool_t own=kTRUE);// Set ownership of all added objects
AliJet(AliJet& j); // Copy constructor
void Reset(); // Reset all values
void AddTrack(AliTrack& t,Int_t copy=1);// Add a track to the jet
Int_t fTrackCopy; // Flag to denote creation of private copies in fTracks
Int_t fUserId; // The user defined identifier
- ClassDef(AliJet,1) // Creation and investigation of a jet of particle tracks.
+ ClassDef(AliJet,2) // Creation and investigation of a jet of particle tracks.
};
#endif
}
}
///////////////////////////////////////////////////////////////////////////
+AliSignal::AliSignal(AliSignal& s)
+{
+// Copy constructor
+ fNvalues=s.GetNvalues();
+ fSignal=0;
+ fDsignal=0;
+ fName=s.GetName();
+
+ SetPosition((Ali3Vector&)s);
+
+ Double_t sig,err;
+ for (Int_t i=1; i<=fNvalues; i++)
+ {
+ sig=s.GetSignal(i);
+ err=s.GetSignalError(i);
+ SetSignal(sig,i);
+ SetSignalError(err,i);
+ }
+}
+///////////////////////////////////////////////////////////////////////////
void AliSignal::Reset()
{
// Reset all signal and position values and errors to 0.
return fName;
}
///////////////////////////////////////////////////////////////////////////
+Int_t AliSignal::GetNvalues()
+{
+// Provide the number of values for this signal.
+ return fNvalues;
+}
+///////////////////////////////////////////////////////////////////////////
public:
AliSignal(Int_t n=1); // Default constructor
~AliSignal(); // Destructor
+ AliSignal(AliSignal& s); // Copy constructor
virtual void SetSignal(Double_t sig,Int_t j=1); // Store j-th signal value
virtual void AddSignal(Double_t sig,Int_t j=1); // Add value to j-th signal value
virtual Float_t GetSignal(Int_t j=1); // Provide j-th signal value
void Info(TString f="car"); // Print signal info for coord. frame f
void SetName(TString name); // Set the name tag to indicate the kind of signal
TString GetName(); // Provide the name tag indicating the kind of signal
+ Int_t GetNvalues(); // Provide the number of signal values
protected:
Int_t fNvalues; // The number of values per signal
TArrayF* fDsignal; // Errors on signal values
TString fName; // Name tag to identify the kind of signal
- ClassDef(AliSignal,2) // Handling of ALICE (extrapolated) signals.
+ ClassDef(AliSignal,3) // Handling of ALICE (extrapolated) signals.
};
#endif
// creating only one AliVertex instance in the main programme and using the
// AliVertex::Reset, AliVertex::AddTrack and parameter setting memberfunctions.
//
+// See also the documentation provided for the memberfunction SetOwner().
+//
// Coding example to make 3 vertices v1, v2 and v3.
// ------------------------------------------------
// v1 contains the tracks 1,2,3 and 4
}
}
///////////////////////////////////////////////////////////////////////////
+void AliVertex::SetOwner(Bool_t own)
+{
+// Set ownership of all added objects.
+// The default parameter is own=kTRUE.
+//
+// Invokation of this memberfunction also sets all the copy modes
+// (e.g. TrackCopy & co.) according to the value of own.
+//
+// This function (with own=kTRUE) is particularly useful when reading data
+// from a tree/file, since Reset() will then actually remove all the
+// added objects from memory irrespective of the copy mode settings
+// during the tree/file creation process. In this way it provides a nice way
+// of preventing possible memory leaks in the reading/analysis process.
+//
+// In addition this memberfunction can also be used as a shortcut to set all
+// copy modes in one go during a tree/file creation process.
+// However, in this case the user has to take care to only set/change the
+// ownership (and copy mode) for empty objects (e.g. newly created objects
+// or after invokation of the Reset() memberfunction) otherwise it will
+// very likely result in inconsistent destructor behaviour.
+
+ Int_t mode=1;
+ if (!own) mode=0;
+ if (fVertices) fVertices->SetOwner(own);
+ fVertexCopy=mode;
+ if (fJets) fJets->SetOwner(own);
+ fJetCopy=mode;
+
+ AliJet::SetOwner(own);
+}
+///////////////////////////////////////////////////////////////////////////
AliVertex::AliVertex(AliVertex& v)
{
// Copy constructor
AliVertex(); // Default constructor
AliVertex(Int_t n); // Create a vertex to hold initially n tracks
~AliVertex(); // Default destructor
+ virtual void SetOwner(Bool_t own=kTRUE);// Set ownership of all added objects
AliVertex(AliVertex& v); // Copy constructor
void Reset(); // Reset all values and stored vertex and jet lists
void ResetVertices(); // Reset stored vertex list
private:
void Dump(AliVertex* v,Int_t n,TString f); // Recursively print all sec. vertices
- ClassDef(AliVertex,2) // Creation and investigation of an AliVertex.
+ ClassDef(AliVertex,3) // Creation and investigation of an AliVertex.
};
#endif
Missing comment lines added in SetName() and GetName() of AliCalorimeter and AliSignal.
19-mar-2002 NvE AliVertex::Draw() introduced to enable 3D event display.
25-apr-2002 NvE Projectile and target specifications introduced in AliEvent.
+26-apr-2002 NvE AddVetoSignal(AliSignal) introduced in AliCalorimeter and AliCalcluster
+ to provide more flexibility and allow automatic calculation of
+ hit association confidence level based on position uncertainties.
+29-apr-2002 NvE Memberfunction GetNvalues() and copy constructor introduced in AliSignal.
+25-jun-2002 NvE Memberfunction SetOwner() introduced in AliJet, AliVertex and AliEvent to allow
+ to set ownership of "added objects" in the case of reading data from a file.
+ In this way possible memory leaks can always be prevented.
+ Also automatic extrapolation and confidence level calculation of associated
+ veto hits introduced in AliCalorimeter and AliCalcluster.