(thanks Josh de Bever).
Typos corrected (i.e. abs() replaced by fabs() in several places) in AliHelix
to satisfy the Intel compiler (thanks Fons Rademakers).
25-jun-2004 NvE Protection introduced in AliSignal::GetNlinks.
29-jun-2004 NvE New class AliDevice introduced.
New memberfunctions and datamembers introduced in AliEvent to support investigation
and ordering of hits of various (classes of) devices.
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+// $Id$
+
+///////////////////////////////////////////////////////////////////////////
+// Class AliDevice
+// Signal (Hit) handling of a generic device.
+// Basically this class provides a user interface to group and handle
+// various instances of AliSignal objects, called generically "hits".
+// An AliDevice object itself has (in addition to hit storage) also the
+// complete functionality of the class AliSignal.
+//
+// Example :
+// =========
+//
+// AliDevice m;
+// m.SetHitCopy(1);
+// m.SetName("OM123");
+//
+// Float_t pos[3]={1,2,3};
+// m.SetPosition(pos,"car");
+//
+// AliSignal s;
+//
+// s.Reset(1);
+// s.SetName("OM123 Hit 1");
+// s.SetSlotName("ADC");
+// s.SetSignal(10);
+// s.SetSlotName("LE",2);
+// s.SetSignal(-100,2);
+// s.SetSlotName("TOT",3);
+// s.SetSignal(-1000,3);
+// m.AddHit(s);
+//
+// s.Reset(1);
+// s.SetName("OM123 Hit 2");
+// s.SetSlotName("ADC");
+// s.SetSignal(11);
+// s.SetSlotName("LE",2);
+// s.SetSignal(-101,2);
+// s.SetSlotName("TOT",3);
+// s.SetSignal(1001,3);
+// m.AddHit(s);
+//
+// s.Reset(1);
+// s.SetName("OM123 Hit 3");
+// s.SetSlotName("ADC");
+// s.SetSignal(12);
+// s.SetSlotName("LE",2);
+// s.SetSignal(-102,2);
+// s.SetSlotName("TOT",3);
+// s.SetSignal(-1002,3);
+// m.AddHit(s);
+//
+// TObjArray ordered=m.SortHits("TOT");
+// nhits=ordered.GetEntries();
+// for (Int_t i=0; i<nhits; i++)
+// {
+// AliSignal* sx=(AliSignal*)ordered.At(i);
+// if (sx) sx->Data();
+// }
+//
+//--- Author: Nick van Eijndhoven 23-jun-2004 Utrecht University
+//- Modified: NvE $Date$ Utrecht University
+///////////////////////////////////////////////////////////////////////////
+
+#include "AliDevice.h"
+#include "Riostream.h"
+
+ClassImp(AliDevice) // Class implementation to enable ROOT I/O
+
+AliDevice::AliDevice() : AliSignal()
+{
+// Default constructor.
+ fHitCopy=0;
+ fHits=0;
+}
+///////////////////////////////////////////////////////////////////////////
+AliDevice::~AliDevice()
+{
+// Default destructor.
+ if (fHits)
+ {
+ delete fHits;
+ fHits=0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+AliDevice::AliDevice(const AliDevice& dev) : AliSignal(dev)
+{
+// Copy constructor.
+ fHitCopy=dev.GetHitCopy();
+ Int_t nhits=dev.GetNhits();
+ if (nhits)
+ {
+ fHits=new TObjArray(nhits);
+ if (fHitCopy) fHits->SetOwner();
+ for (Int_t ih=1; ih<=nhits; ih++)
+ {
+ AliSignal* sx=dev.GetHit(ih);
+ if (fHitCopy)
+ {
+ fHits->Add(sx->Clone());
+ Int_t nhits=GetNhits();
+ AliSignal* s=GetHit(nhits);
+ s->ResetLinks((AliDevice*)&dev);
+ s->AddLink(this);
+ }
+ else
+ {
+ sx->AddLink(this);
+ fHits->Add(sx);
+ }
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliDevice::Reset(Int_t mode)
+{
+// Reset registered hits and AliSignal attributes.
+// See AliSignal::Reset() for further details.
+ RemoveHits();
+ AliSignal::Reset(mode);
+}
+///////////////////////////////////////////////////////////////////////////
+void AliDevice::SetHitCopy(Int_t j)
+{
+// (De)activate the creation of private copies of the AliSignals added as hits.
+// j=0 ==> No private copies are made; pointers of original hits are stored.
+// j=1 ==> Private copies of the hits are made and these pointers are stored.
+//
+// Note : Once the storage contains pointer(s) to hit(s) one cannot
+// change the HitCopy mode anymore.
+// To change the HitCopy mode for an existing AliDevice containing
+// hits one first has to invoke either RemoveHits() or Reset().
+ if (!fHits)
+ {
+ if (j==0 || j==1)
+ {
+ fHitCopy=j;
+ }
+ else
+ {
+ cout << "*AliDevice::SetHitCopy* Invalid argument : " << j << endl;
+ }
+ }
+ else
+ {
+ cout << "*AliDevice::SetHitCopy* Storage already contained hits."
+ << " ==> HitCopy mode not changed." << endl;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliDevice::GetHitCopy() const
+{
+// Provide value of the HitCopy mode.
+// 0 ==> No private copies are made; pointers of original hits are stored.
+// 1 ==> Private copies of the hits are made and these pointers are stored.
+ return fHitCopy;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliDevice::AddHit(AliSignal& s)
+{
+// Register an AliSignal object as a hit to this device.
+// Note : A (backward) link to this device is added to the first slot of
+// the AliSignal if there was no link to this device already present.
+ if (!fHits)
+ {
+ fHits=new TObjArray(1);
+ if (fHitCopy) fHits->SetOwner();
+ }
+
+ // Check if this signal is already stored for this device.
+ Int_t nhits=GetNhits();
+ for (Int_t i=0; i<nhits; i++)
+ {
+ if (&s==fHits->At(i)) return;
+ }
+
+ // Set the (backward) link to this device.
+ Int_t nlinks=GetNlinks(this);
+ if (!nlinks) s.AddLink(this);
+
+ if (fHitCopy)
+ {
+ fHits->Add(s.Clone());
+ }
+ else
+ {
+ fHits->Add(&s);
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliDevice::RemoveHit(AliSignal& s)
+{
+// Remove AliSignal object registered as a hit from this device.
+ if (fHits)
+ {
+ AliSignal* test=(AliSignal*)fHits->Remove(&s);
+ if (test)
+ {
+ fHits->Compress();
+ if (fHitCopy) delete test;
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliDevice::RemoveHits()
+{
+// Remove all AliSignal objects registered as hits from this device.
+ if (fHits)
+ {
+ delete fHits;
+ fHits=0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliDevice::GetNhits() const
+{
+// Provide the number of registered hits for this device.
+ Int_t nhits=0;
+ if (fHits) nhits=fHits->GetEntries();
+ return nhits;
+}
+///////////////////////////////////////////////////////////////////////////
+AliSignal* AliDevice::GetHit(Int_t j) const
+{
+// Provide the AliSignal object registered as hit number j.
+// Note : j=1 denotes the first hit.
+ if (!fHits) return 0;
+
+ if ((j >= 1) && (j <= GetNhits()))
+ {
+ return (AliSignal*)fHits->At(j-1);
+ }
+ else
+ {
+ return 0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+TObjArray* AliDevice::GetHits()
+{
+// Provide the references to all the registered hits.
+ return fHits;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliDevice::ShowHit(Int_t j) const
+{
+// Show data of the registered j-th hit.
+// If j=0 all associated hits will be shown.
+// The default is j=0.
+ if (!j)
+ {
+ Int_t nhits=GetNhits();
+ for (Int_t ih=1; ih<=nhits; ih++)
+ {
+ AliSignal* sx=GetHit(ih);
+ if (sx) sx->Data();
+ }
+ }
+ else
+ {
+ AliSignal* s=GetHit(j);
+ if (s) s->Data();
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliDevice::Data(TString f) const
+{
+// Print the device and all registered hit info according to the specified
+// coordinate frame.
+ AliSignal::Data(f);
+ Int_t nhits=GetNhits();
+ if (nhits)
+ {
+ cout << " The following " << nhits << " hits are registered : " << endl;
+ ShowHit();
+ }
+ else
+ {
+ cout << " No hits have been registered for this device." << endl;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+TObjArray AliDevice::SortHits(Int_t idx,Int_t mode,TObjArray* hits) const
+{
+// Order the references to an array of hits by looping over the input array "hits"
+// and checking the signal value. The ordered array is returned as a TObjArray.
+// In case hits=0 (default), the registered hits of the current device are used.
+// Note that the original hit array in not modified.
+// A "hit" represents an abstract object which is derived from AliSignal.
+// The user can specify the index of the signal slot to perform the sorting on.
+// By default the slotindex will be 1.
+// Via the "mode" argument the user can specify ordering in decreasing
+// order (mode=-1) or ordering in increasing order (mode=1).
+// The default is mode=-1.
+// Signals which were declared as "Dead" will be rejected.
+// The gain etc... corrected signals will be used in the ordering process.
+
+ TObjArray ordered;
+
+ if (!hits) hits=fHits;
+
+ if (idx<=0 || abs(mode)!=1 || !hits) return ordered;
+
+ Int_t nhits=hits->GetEntries();
+ if (!nhits)
+ {
+ return ordered;
+ }
+ else
+ {
+ ordered.Expand(nhits);
+ }
+
+ Int_t nord=0;
+ for (Int_t i=0; i<nhits; i++) // Loop over all hits of the array
+ {
+ AliSignal* s=(AliSignal*)hits->At(i);
+
+ if (!s) continue;
+
+ if (idx > s->GetNvalues()) continue; // User specified slotindex out of range for this signal
+ if (s->GetDeadValue(idx)) continue; // Only take alive signals
+
+ if (nord == 0) // store the first hit with a signal at the first ordered position
+ {
+ nord++;
+ ordered.AddAt(s,nord-1);
+ continue;
+ }
+
+ for (Int_t j=0; j<=nord; j++) // put hit in the right ordered position
+ {
+ if (j == nord) // module has smallest (mode=-1) or largest (mode=1) signal seen so far
+ {
+ nord++;
+ ordered.AddAt(s,j); // add hit at the end
+ break; // go for next hit
+ }
+
+ if (mode==-1 && s->GetSignal(idx,1) < ((AliSignal*)ordered.At(j))->GetSignal(idx,1)) continue;
+ if (mode==1 && s->GetSignal(idx,1) > ((AliSignal*)ordered.At(j))->GetSignal(idx,1)) continue;
+
+ nord++;
+ for (Int_t k=nord-1; k>j; k--) // create empty position
+ {
+ ordered.AddAt(ordered.At(k-1),k);
+ }
+ ordered.AddAt(s,j); // put hit at empty position
+ break; // go for next matrix module
+ }
+ }
+ return ordered;
+}
+///////////////////////////////////////////////////////////////////////////
+TObjArray AliDevice::SortHits(TString name,Int_t mode,TObjArray* hits) const
+{
+// Order the references to an array of hits by looping over the input array "hits"
+// and checking the signal value. The ordered array is returned as a TObjArray.
+// In case hits=0 (default), the registered hits of the current device are used.
+// Note that the input array in not modified.
+// A "hit" represents an abstract object which is derived from AliSignal.
+// The user can specify the name of the signal slot to perform the sorting on.
+// In case no matching slotname is found, the signal will be skipped.
+// Via the "mode" argument the user can specify ordering in decreasing
+// order (mode=-1) or ordering in increasing order (mode=1).
+// The default is mode=-1.
+// Signals which were declared as "Dead" will be rejected.
+// The gain etc... corrected signals will be used in the ordering process.
+
+ TObjArray ordered;
+
+ if (!hits) hits=fHits;
+
+ if (abs(mode)!=1 || !hits) return ordered;
+
+ Int_t nhits=hits->GetEntries();
+ if (!nhits)
+ {
+ return ordered;
+ }
+ else
+ {
+ ordered.Expand(nhits);
+ }
+
+ Int_t idx=0; // The signal slotindex to perform the sorting on
+
+ Int_t nord=0;
+ for (Int_t i=0; i<nhits; i++) // loop over all hits of the array
+ {
+ AliSignal* s=(AliSignal*)hits->At(i);
+
+ if (!s) continue;
+
+ // Obtain the slotindex corresponding to the user selection
+ idx=s->GetSlotIndex(name);
+ if (!idx) continue;
+
+ if (s->GetDeadValue(idx)) continue; // only take alive signals
+
+ if (nord == 0) // store the first hit with a signal at the first ordered position
+ {
+ nord++;
+ ordered.AddAt(s,nord-1);
+ continue;
+ }
+
+ for (Int_t j=0; j<=nord; j++) // put hit in the right ordered position
+ {
+ if (j == nord) // module has smallest (mode=-1) or largest (mode=1) signal seen so far
+ {
+ nord++;
+ ordered.AddAt(s,j); // add hit at the end
+ break; // go for next hit
+ }
+
+ if (mode==-1 && s->GetSignal(idx,1) < ((AliSignal*)ordered.At(j))->GetSignal(idx,1)) continue;
+ if (mode==1 && s->GetSignal(idx,1) > ((AliSignal*)ordered.At(j))->GetSignal(idx,1)) continue;
+
+ nord++;
+ for (Int_t k=nord-1; k>j; k--) // create empty position
+ {
+ ordered.AddAt(ordered.At(k-1),k);
+ }
+ ordered.AddAt(s,j); // put hit at empty position
+ break; // go for next matrix module
+ }
+ }
+ return ordered;
+}
+///////////////////////////////////////////////////////////////////////////
+TObject* AliDevice::Clone(const char* name) const
+{
+// 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 like AliEvent when adding objects in case the
+// container owns the objects. This feature allows e.g. AliEvent
+// to store either AliDevice objects or objects derived from AliDevice
+// via tha AddDevice memberfunction, provided these derived classes also have
+// a proper Clone memberfunction.
+
+ AliDevice* dev=new AliDevice(*this);
+ if (name)
+ {
+ if (strlen(name)) dev->SetName(name);
+ }
+ return dev;
+}
+///////////////////////////////////////////////////////////////////////////
--- /dev/null
+#ifndef ALIDEVICE_H
+#define ALIDEVICE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+// $Id$
+
+#include "AliSignal.h"
+
+class AliDevice : public AliSignal
+{
+ public:
+ AliDevice(); // Default constructor
+ virtual ~AliDevice(); // Default destructor
+ AliDevice(const AliDevice& dev); // Copy constructor
+ virtual TObject* Clone(const char* name="") const; // Make a deep copy and provide its pointer
+ void SetHitCopy(Int_t j); // (De)activate creation of private copies of hits
+ Int_t GetHitCopy() const; // Provide HitCopy flag value
+ void AddHit(AliSignal& s); // Register an AliSignal object as a hit to this module
+ void RemoveHit(AliSignal& s); // Remove AliSignal object as hit from this module
+ void RemoveHits(); // Remove all AliSignals as hits from this module
+ Int_t GetNhits() const; // Provide number of registered hits
+ AliSignal* GetHit(Int_t j) const; // Access to the AliSignal registered as hit number j
+ TObjArray* GetHits(); // Provide the references to all the registered hits
+ virtual void Reset(Int_t mode=0); // Reset registered hits and AliSignal attributes
+ void ShowHit(Int_t j=0) const; // Show data of the j-th hit (j=0 means all hits)
+ virtual void Data(TString f="car") const; // Print device and all signal info for coord. frame f
+ TObjArray SortHits(TString name,Int_t mode=-1,TObjArray* hits=0) const; // Sort hits by named signal value
+ TObjArray SortHits(Int_t idx=1,Int_t mode=-1,TObjArray* hits=0) const; // Sort hits by indexed signal value
+
+ protected:
+ Int_t fHitCopy; // Flag to denote making private copies of added hits
+ TObjArray* fHits; // Array to hold the associated hits
+
+ ClassDef(AliDevice,1) // Signal (Hit) handling of a generic device.
+};
+#endif
* provided "as is" without express or implied warranty. *
**************************************************************************/
-// $Id: AliEvent.cxx,v 1.20 2004/02/06 15:25:07 nick Exp $
+// $Id: AliEvent.cxx,v 1.21 2004/05/04 15:33:04 nick Exp $
///////////////////////////////////////////////////////////////////////////
// Class AliEvent
// Creation and investigation of an Alice physics event.
// An AliEvent can be constructed by adding AliTracks, Alivertices, AliJets
-// and/or devices like AliCalorimeters.
+// and/or devices like AliCalorimeters or AliDevice (derived) objects.
+//
// All objects which are derived from TObject can be regarded as a device.
+// However, AliDevice (or derived) objects profit from additional hit
+// handling facilities.
+// A "hit" is a generic name indicating an AliSignal (or derived) object.
+// Note that AliEvent does NOT own hits; it only provides references to hits
+// obtained from the various devices.
+// This implies that hits should be owned by the devices themselves.
//
// The basic functionality of AliEvent is identical to the one of AliVertex.
// So, an AliEvent may be used as the primary vertex with some additional
// which may include pointers to other objects. Therefore it is recommended to provide
// for all devices a specific copy constructor and override the default Clone()
// memberfunction using this copy constructor.
-// An example for this may be seen from AliCalorimeter.
+// Examples for this may be seen from AliCalorimeter, AliSignal and AliDevice.
//
// See also the documentation provided for the memberfunction SetOwner().
//
//
// Fill the event structure with the basic objects
//
-// AliCalorimeter emcal;
+// AliCalorimeter emcal; // Note : AliCalorimeter is NOT derived from AliDevice
// ...
// ... // code to fill the calorimeter data
// ...
//
// evt.AddDevice(emcal);
//
+// // Assume AliTOF has been derived from AliDevice
+// AliTOF tof1;
+// AliTOF tof2;
+// ...
+// ... // code to fill the tof1 and tof2 data
+// ...
+//
+// evt.AddDevice(tof1);
+// evt.AddDevice(tof2);
+//
// AliTrack* tx=new AliTrack();
// for (Int_t i=0; i<10; i++)
// {
// tx=0;
// }
//
+// Order and investigate all the hits of all the TOF devices
+//
+// TObjArray* hits=evt.GetHits("AliTOF");
+// TObjArray ordered=evt.SortHits(hits);
+// Int_t nhits=ordered.GetEntries();
+// for (Int_t i=0; i<nhits; i++)
+// {
+// AliSignal* sx=(AliSignal*)ordered.At(i);
+// if (sx) sx->Data();
+// }
+//
// Build the event structure (vertices, jets, ...) for physics analysis
// based on the basic objects from the event repository.
//
// 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: 2004/02/06 15:25:07 $ UU-SAP Utrecht
+//- Modified: NvE $Date: 2004/05/04 15:33:04 $ UU-SAP Utrecht
///////////////////////////////////////////////////////////////////////////
#include "AliEvent.h"
fIdTarg=0;
fDevices=0;
fDevCopy=0;
+ fHits=0;
}
///////////////////////////////////////////////////////////////////////////
AliEvent::AliEvent(Int_t n) : AliVertex(n)
fIdTarg=0;
fDevices=0;
fDevCopy=0;
+ fHits=0;
}
///////////////////////////////////////////////////////////////////////////
AliEvent::~AliEvent()
delete fDevices;
fDevices=0;
}
+ if (fHits)
+ {
+ delete fHits;
+ fHits=0;
+ }
}
///////////////////////////////////////////////////////////////////////////
AliEvent::AliEvent(const AliEvent& evt) : AliVertex(evt)
}
}
}
+
+ fHits=0;
+ if (evt.fHits)
+ {
+ Int_t nhits=evt.fHits->GetEntries();
+ if (nhits)
+ {
+ fHits=new TObjArray(nhits);
+ for (Int_t ih=0; ih<nhits; ih++)
+ {
+ AliSignal* sx=(AliSignal*)evt.fHits->At(ih);
+ fHits->Add(sx);
+ }
+ }
+ }
}
///////////////////////////////////////////////////////////////////////////
void AliEvent::Reset()
delete fDevices;
fDevices=0;
}
+ if (fHits)
+ {
+ delete fHits;
+ fHits=0;
+ }
}
///////////////////////////////////////////////////////////////////////////
void AliEvent::SetOwner(Bool_t own)
}
}
///////////////////////////////////////////////////////////////////////////
+Int_t AliEvent::GetNhits(const char* classname)
+{
+// Provide the number of hits registered to the specified device class.
+// The specified device class has to be derived from AliDevice.
+// It is possible to indicate with the argument "classname" a specific
+// device instead of a whole class of devices. However, in such a case
+// it is more efficient to use the GetDevice() memberfunction directly.
+ LoadHits(classname);
+ Int_t nhits=0;
+ if (fHits) nhits=fHits->GetEntries();
+ return nhits;
+}
+///////////////////////////////////////////////////////////////////////////
+TObjArray* AliEvent::GetHits(const char* classname)
+{
+// Provide the references to all the hits registered to the specified
+// device class.
+// The specified device class has to be derived from AliDevice.
+// It is possible to indicate with the argument "classname" a specific
+// device instead of a whole class of devices. However, in such a case
+// it is more efficient to use the GetDevice() memberfunction directly.
+ LoadHits(classname);
+ return fHits;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliEvent::LoadHits(const char* classname)
+{
+// Load the references to the various hits registered to the specified
+// device class.
+// The specified device class has to be derived from AliDevice.
+ if (fHits) fHits->Clear();
+
+ Int_t ndev=GetNdevices();
+ for (Int_t idev=1; idev<=ndev; idev++)
+ {
+ TObject* obj=GetDevice(idev);
+ if (!obj) continue;
+
+ if (obj->InheritsFrom(classname) && obj->InheritsFrom("AliDevice"))
+ {
+ AliDevice* dev=(AliDevice*)GetDevice(idev);
+ Int_t nhits=dev->GetNhits();
+ if (nhits)
+ {
+ if (!fHits) fHits=new TObjArray();
+ for (Int_t ih=1; ih<=nhits; ih++)
+ {
+ AliSignal* sx=dev->GetHit(ih);
+ if (sx) fHits->Add(sx);
+ }
+ }
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+TObjArray AliEvent::SortHits(TObjArray* hits,Int_t idx,Int_t mode) const
+{
+// Order the references to an array of hits by looping over the input array "hits"
+// and checking the signal value. The ordered array is returned as a TObjArray.
+// Note that the input array is not modified.
+// A "hit" represents an abstract object which is derived from AliSignal.
+// The user can specify the index of the signal slot to perform the sorting on.
+// By default the slotindex will be 1.
+// Via the "mode" argument the user can specify ordering in decreasing
+// order (mode=-1) or ordering in increasing order (mode=1).
+// The default is mode=-1.
+// Signals which were declared as "Dead" will be rejected.
+// The gain etc... corrected signals will be used in the ordering process.
+
+ if (idx<=0 || abs(mode)!=1 || !hits)
+ {
+ TObjArray ordered;
+ return ordered;
+ }
+ else
+ {
+ AliDevice dev;
+ TObjArray ordered=dev.SortHits(idx,mode,hits);
+ return ordered;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+TObjArray AliEvent::SortHits(TObjArray* hits,TString name,Int_t mode) const
+{
+// Order the references to an array of hits by looping over the input array "hits"
+// and checking the signal value. The ordered array is returned as a TObjArray.
+// Note that the input array is not modified.
+// A "hit" represents an abstract object which is derived from AliSignal.
+// The user can specify the name of the signal slot to perform the sorting on.
+// In case no matching slotname is found, the signal will be skipped.
+// Via the "mode" argument the user can specify ordering in decreasing
+// order (mode=-1) or ordering in increasing order (mode=1).
+// The default is mode=-1.
+// Signals which were declared as "Dead" will be rejected.
+// The gain etc... corrected signals will be used in the ordering process.
+
+ if (abs(mode)!=1 || !hits)
+ {
+ TObjArray ordered;
+ return ordered;
+ }
+ else
+ {
+ AliDevice dev;
+ TObjArray ordered=dev.SortHits(name,mode,hits);
+ return ordered;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
TObject* AliEvent::Clone(const char* name) const
{
// Make a deep copy of the current object and provide the pointer to the copy.
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */
-// $Id: AliEvent.h,v 1.15 2004/02/06 15:25:07 nick Exp $
+// $Id: AliEvent.h,v 1.16 2004/05/04 15:33:04 nick Exp $
#include <math.h>
#include "TTimeStamp.h"
#include "AliVertex.h"
+#include "AliDevice.h"
class AliEvent : public AliVertex
{
void ShowDevices() const; // Provide on overview of the available devices
TObject* GetDevice(Int_t i) const; // Provide i-th device of the event
TObject* GetDevice(TString name) const; // Provide device with name "name"
+ Int_t GetNhits(const char* classname); // Provide number of hits for the specified device class
+ TObjArray* GetHits(const char* classname); // Provide refs to all hits of the specified device class
+ TObjArray SortHits(TObjArray* hits,TString name,Int_t mode=-1) const; // Sort hits by named signal value
+ TObjArray SortHits(TObjArray* hits,Int_t idx=1,Int_t mode=-1) const; // Sort hits by indexed signal value
protected:
- TTimeStamp fDaytime; // The date and time stamp
- Int_t fRun; // The run number
- Int_t fEvent; // The event number
- Int_t fAproj; // The projectile A value
- Int_t fZproj; // The projectile Z value
- Double_t fPnucProj; // The projectile momentum per nucleon
- Int_t fIdProj; // User defined projectile particle ID
- Int_t fAtarg; // The target A value
- Int_t fZtarg; // The target Z value
- Double_t fPnucTarg; // The target momentum per nucleon
- Int_t fIdTarg; // User defined target particle ID
- TObjArray* fDevices; // Array to hold the pointers to the various devices
- Int_t fDevCopy; // Flag to denote creation of private copies of the devices
+ TTimeStamp fDaytime; // The date and time stamp
+ Int_t fRun; // The run number
+ Int_t fEvent; // The event number
+ Int_t fAproj; // The projectile A value
+ Int_t fZproj; // The projectile Z value
+ Double_t fPnucProj; // The projectile momentum per nucleon
+ Int_t fIdProj; // User defined projectile particle ID
+ Int_t fAtarg; // The target A value
+ Int_t fZtarg; // The target Z value
+ Double_t fPnucTarg; // The target momentum per nucleon
+ Int_t fIdTarg; // User defined target particle ID
+ TObjArray* fDevices; // Array to hold the pointers to the various devices
+ Int_t fDevCopy; // Flag to denote creation of private copies of the devices
+ void LoadHits(const char* classname); // Load references to the hits registered to the specified device class
+ TObjArray* fHits; //! Temp. array to hold references to the registered AliDevice hits
- ClassDef(AliEvent,13) // Creation and investigation of an Alice physics event.
+ ClassDef(AliEvent,14) // Creation and investigation of an Alice physics event.
};
#endif
Double_t betavec[3];
if (iaxis>0) beta.GetVector(betavec,"car");
if (iaxis<0) betaprim.GetVector(betavec,"car");
- if (TMath::Abs(betavec[TMath::Abs(iaxis)-1])/betanorm<1e-10) return;
+ if (fabs(betavec[abs(iaxis)-1])/betanorm<1e-10) return;
}
// The LAB location in which the velocity of the particle is defined
SetHelix(loc,vel,w,0,kUnchanged,bvec);
Int_t bend=0;
- if (TMath::Abs(w)>0 && TMath::Abs(fVt)>0) bend=1;
+ if (fabs(w)>0 && fabs(fVt)>0) bend=1;
// Flight time boundaries.
// The time origin t=0 is chosen to indicate the position in which
loc[0]=fX0;
loc[1]=fY0;
loc[2]=fZ0;
- tmin=(range[0]-loc[TMath::Abs(iaxis)-1])/velprim[TMath::Abs(iaxis)-1];
- tmax=(range[1]-loc[TMath::Abs(iaxis)-1])/velprim[TMath::Abs(iaxis)-1];
+ tmin=(range[0]-loc[abs(iaxis)-1])/velprim[abs(iaxis)-1];
+ tmax=(range[1]-loc[abs(iaxis)-1])/velprim[abs(iaxis)-1];
}
if (tmax<tmin)
{
// was defined is taken as the starting point.
// The endpoint is initially obtained by applying the tofmax from the start point.
tmin=0;
- if (TMath::Abs(fVz)>0) tmin=-fZ0/fVz;
+ if (fabs(fVz)>0) tmin=-fZ0/fVz;
v=beta*c;
if (rx) r1=(*rx);
r=v*tmin;
// In case this point can't be reached, the point in which the particle velocity
// was defined is taken as the starting point.
tmin=0;
- if (TMath::Abs(fVz)>0) tmin=-fZ0/fVz;
+ if (fabs(fVz)>0) tmin=-fZ0/fVz;
tmax=tmin+fTofmax;
if (tmax<tmin)
if (scale1/scale>1.1 || scale/scale1>1.1) r1*=scale1/scale;
// Re-calculate the tmin for this new starting point
r1.GetVector(vec1,"car");
- if (TMath::Abs(fVz)>0) tmin=(vec1[2]-fZ0)/fVz;
+ if (fabs(fVz)>0) tmin=(vec1[2]-fZ0)/fVz;
tmax=tmin+fTofmax;
}
if (rend)
// All coordinates in the selected unit scale
if (scale2/scale>1.1 || scale/scale2>1.1) r2*=scale2/scale;
r2.GetVector(vec2,"car");
- if (TMath::Abs(fVz)>0) tmax=(vec2[2]-fZ0)/fVz;
+ if (fabs(fVz)>0) tmax=(vec2[2]-fZ0)/fVz;
}
// Make the curve on basis of the flight time boundaries and exit
if (tmax<tmin)
}
else // User explicitly specified range
{
- vec1[TMath::Abs(iaxis)-1]=range[0];
- vec2[TMath::Abs(iaxis)-1]=range[1];
+ vec1[abs(iaxis)-1]=range[0];
+ vec2[abs(iaxis)-1]=range[1];
r1.SetVector(vec1,"car");
r2.SetVector(vec2,"car");
if (iaxis>0) // Range specified in LAB frame
Double_t test=0;
for (Int_t i=0; i<3; i++)
{
- test=TMath::Abs(vec1[i]-vec2[i]);
+ test=fabs(vec1[i]-vec2[i]);
if (test>dmax)
{
dmax=test;
//
// The default is mode=0.
- if (TMath::Abs(mode)<2) fRefresh=mode;
+ if (abs(mode)<2) fRefresh=mode;
if (fCurves) fCurves->Delete();
}
///////////////////////////////////////////////////////////////////////////
}
Double_t range[2];
- range[0]=pars[0]-TMath::Abs(pars[1])/2.;
- range[1]=pars[0]+TMath::Abs(pars[1])/2.;
+ range[0]=pars[0]-fabs(pars[1])/2.;
+ range[1]=pars[0]+fabs(pars[1])/2.;
Int_t iaxis=int(pars[2]);
// The accuracy on the impact point
Float_t err[3];
- err[0]=TMath::Abs(first[0]-last[0]);
- err[1]=TMath::Abs(first[1]-last[1]);
- err[2]=TMath::Abs(first[2]-last[2]);
+ err[0]=fabs(first[0]-last[0]);
+ err[1]=fabs(first[1]-last[1]);
+ err[2]=fabs(first[2]-last[2]);
// Take the middle point as impact location
ip=np/2;
// Parameters of the polynomial approximation
const Double_t kp1=-0.57721566, kp2=0.42278420, kp3=0.23069756,
- kp4= 3.488590e-2, kp5=2.62698e-3, kp6=1.0750e-4, kp7=7.4e-5;
+ kp4= 3.488590e-2, kp5=2.62698e-3, kp6=1.0750e-4, kp7=7.4e-6;
const Double_t kq1= 1.25331414, kq2=-7.832358e-2, kq3= 2.189568e-2,
kq4=-1.062446e-2, kq5= 5.87872e-3, kq6=-2.51540e-3, kq7=5.3208e-4;
Int_t n=0;
if (!j)
{
- n=fLinks->GetNrefs(obj);
+ if (fLinks) n=fLinks->GetNrefs(obj);
}
else
{
#include "AliAttrib.h"
#include "AliAttribObj.h"
#include "AliHelix.h"
+#include "AliDevice.h"
#pragma link C++ class AliAttrib+;
#pragma link C++ class AliAttribObj+;
#pragma link C++ class AliHelix+;
+ #pragma link C++ class AliDevice+;
#endif
12-may-2004 NvE Track reference-point introduced in AliTrack.
02-jun-2004 NvE Memberfunction GetUnprimed introduced for Ali3Vector.
17-jun-2004 NvE New class AliHelix introduced and "macgcclib" added to create ralice libs on MAC.
+24-jun-2004 NvE Coefficient kp7 changed from 7.4e-5 to 7.4e-6 in AliMath::BesselK0 to correct typo
+ (thanks Josh de Bever).
+ Typos corrected (i.e. abs() replaced by fabs() in several places) in AliHelix
+ to satisfy the Intel compiler (thanks Fons Rademakers).
+25-jun-2004 NvE Protection introduced in AliSignal::GetNlinks.
+29-jun-2004 NvE New class AliDevice introduced.
+ New memberfunctions and datamembers introduced in AliEvent to support investigation
+ and ordering of hits of various (classes of) devices.
AliMath.cxx AliPosition.cxx AliRandom.cxx AliSample.cxx AliSignal.cxx \
AliTrack.cxx AliVertex.cxx Ali3VectorObj.cxx Ali4VectorObj.cxx \
AliPositionObj.cxx AliEvent.cxx AliCollider.cxx AliObjMatrix.cxx \
- AliAttrib.cxx AliAttribObj.cxx AliHelix.cxx
+ AliAttrib.cxx AliAttribObj.cxx AliHelix.cxx AliDevice.cxx
HDRS= $(SRCS:.cxx=.h)