]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
10-may-2005 NvE Support for timestamps introduced in AliTrack and AliPosition.
authornick <nick@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 May 2005 09:35:25 +0000 (09:35 +0000)
committernick <nick@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 May 2005 09:35:25 +0000 (09:35 +0000)
                Memberfunction GetX introduced in Ali3Vector for easy component access.
                Picosecond support and calculation of time difference introduced in AliTimestamp
                to enable investigation of both very short (i.e. time of flight analysis in
                particle physics experiments) and very long (i.e. astrophysical phenomena)
                time intervals.

RALICE/Ali3Vector.cxx
RALICE/Ali3Vector.h
RALICE/AliPosition.cxx
RALICE/AliPosition.h
RALICE/AliSignal.cxx
RALICE/AliTimestamp.cxx
RALICE/AliTimestamp.h
RALICE/AliTrack.cxx
RALICE/AliTrack.h
RALICE/history.txt

index 853b43921c91160dac7ee5fec9e12db6ac4cccaf..cef914845100c784057a1378b495f6c6b701c703 100644 (file)
@@ -879,3 +879,25 @@ Ali3Vector Ali3Vector::GetUnprimed(TRotMatrix* m) const
  return v;
 }
 ///////////////////////////////////////////////////////////////////////////
+Double_t Ali3Vector::GetX(Int_t i,TString f)
+{
+// Provide i-th vector component according to reference frame f.
+// The vector components are addressed via the generic x1,x2,x3 notation.
+// So, i=1 denotes the first vector component.
+// The error on the selected component can be obtained via the
+// usual GetResultError() facility.
+ fDresult=0;
+
+ if (i<1 || i>3) return 0;
+
+ Double_t vec[3];
+ Double_t err[3];
+ GetVector(vec,f);
+ GetErrors(err,f);
+
+ fDresult=err[i-1];
+
+ return vec[i-1];
+}
+///////////////////////////////////////////////////////////////////////////
index c00fc5af2900e5df69923c80ae491ec8b28d2be5..9cba116857fae221f4de7b43b291ff49c62cb611 100644 (file)
@@ -45,12 +45,13 @@ class Ali3Vector
   Ali3Vector GetVecLong() const;                 // Provide longitudinal vector w.r.t. z-axis
   Ali3Vector GetPrimed(TRotMatrix* m) const;     // Provide vector components in a rotated frame
   Ali3Vector GetUnprimed(TRotMatrix* m) const;   // Provide original vector components from a rotated one
+  Double_t GetX(Int_t i,TString f);              // Provide i-th vector component in frame f
 
  protected:
   Double_t fV,fTheta,fPhi;    // Vector in spherical coordinates
   Double_t fDx,fDy,fDz;       // Errors on Cartesian coordinates
   Double_t fDresult;          // Error on scalar result (e.g. norm or dotproduct)
 
- ClassDef(Ali3Vector,8) // Handling of 3-vectors in various reference frames.
+ ClassDef(Ali3Vector,9) // Handling of 3-vectors in various reference frames.
 };
 #endif
index a960fbc86dcfe53b4574fb4793a1502b57c9af47..d992b45795313ae7fa56bd07a86844b2fef59076 100644 (file)
@@ -71,17 +71,24 @@ AliPosition::AliPosition()
 // Creation of an AliPosition object and initialisation of parameters.
 // The unit scale for position coordinates is initialised to cm.
  fScale=0.01;
+ fTstamp=0;
 }
 ///////////////////////////////////////////////////////////////////////////
 AliPosition::~AliPosition()
 {
 // Destructor to delete dynamically allocated memory
+ if (fTstamp)
+ {
+  delete fTstamp;
+  fTstamp=0;
+ }
 }
 ///////////////////////////////////////////////////////////////////////////
 AliPosition::AliPosition(const AliPosition& p) : Ali3Vector(p)
 {
 // Copy constructor
  fScale=p.fScale;
+ if (p.fTstamp) fTstamp=new AliTimestamp(*(p.fTstamp));
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliPosition::SetPosition(Double_t* r,TString f)
@@ -211,3 +218,33 @@ Float_t AliPosition::GetUnitScale() const
  return fScale;
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliPosition::SetTimestamp(AliTimestamp& t)
+{
+// Store the timestamp for this position.
+ if (fTstamp) delete fTstamp;
+ fTstamp=new AliTimestamp(t);
+}
+///////////////////////////////////////////////////////////////////////////
+AliTimestamp* AliPosition::GetTimestamp()
+{
+// Provide the timestamp of this position.
+ return fTstamp;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliPosition::RemoveTimestamp()
+{
+// Remove the timestamp from this postion.
+ if (fTstamp)
+ {
+  delete fTstamp;
+  fTstamp=0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliPosition::Data(TString f) const
+{
+// Provide all position/time information within the coordinate frame f.
+ Ali3Vector::Data(f);
+ if (fTstamp) fTstamp->Date(1);
+} 
+///////////////////////////////////////////////////////////////////////////
index 206f8840d49306895a89e9059e5b2b26d661d358..1107b03b43f41bb15cb2c73914bf6282285f0d39 100644 (file)
@@ -11,6 +11,7 @@
 #include "TString.h"
 
 #include "Ali3Vector.h"
+#include "AliTimestamp.h"
  
 class AliPosition : public Ali3Vector
 {
@@ -33,10 +34,15 @@ class AliPosition : public Ali3Vector
   void ResetPosition();                                  // Reset position and errors to 0
   void SetUnitScale(Float_t s);                          // Set unit scale for the position coordinates
   Float_t GetUnitScale() const;                          // Provide unit scale for the position coordinates
+  void SetTimestamp(AliTimestamp& t);                    // Set the timestamp for this position
+  AliTimestamp* GetTimestamp();                          // Provide the timestamp for this position
+  void RemoveTimestamp();                                // Remove the timestamp from this position
+  virtual void Data(TString f="car") const;              // Print all position/time info for coord. frame f
 
  protected:
-  Float_t fScale; // The unit scale used for the position coordinates
+  Float_t fScale;        // The unit scale used for the position coordinates
+  AliTimestamp* fTstamp; // The timestamp for this position
 
- ClassDef(AliPosition,6) // Handling of positions in various reference frames.
+ ClassDef(AliPosition,7) // Handling of positions (with timestamps) in various reference frames.
 };
 #endif
index b1c9ac10b2465c0db172ae25a6bd1ce9d9bdf3ca..a53f2d4e584b3e12910366c6386aacda25ab9f78 100644 (file)
@@ -565,7 +565,7 @@ void AliSignal::Data(TString f) const
  if (strlen(title)) cout << " Title : " << title;
  cout << endl;
  cout << "   Position";
- Ali3Vector::Data(f);
+ AliPosition::Data(f);
  if (fDevice)
  {
   const char* devname=fDevice->GetName();
index 8fa245415a019fb53fa3ee798d0df67595475145..010b54e726a96b90e02446985a2632a5931ca25b 100644 (file)
 // they provide an absolute timescale irrespective of timezone or daylight
 // saving time (DST).
 //
-// This AliTimestamp facility allows for nanosecond precision.
-// However, when the fractional JD, MJD and TJD counts are used instead
+// This AliTimestamp facility allows for picosecond precision, in view
+// of time of flight analyses for particle physics experiments.
+// For normal date/time indication the standard nanosecond precision
+// will in general be sufficient.
+// Note that when the fractional JD, MJD and TJD counts are used instead
 // of the integer (days,sec,ns) specification, the nanosecond precision
 // may be lost due to computer accuracy w.r.t. floating point operations.
 //
@@ -134,6 +137,7 @@ AliTimestamp::AliTimestamp() : TTimeStamp()
 // in the docs of TTimeStamp.
 
  FillJulian();
+ fJps=0;
 }
 ///////////////////////////////////////////////////////////////////////////
 AliTimestamp::AliTimestamp(TTimeStamp& t) : TTimeStamp(t)
@@ -142,6 +146,7 @@ AliTimestamp::AliTimestamp(TTimeStamp& t) : TTimeStamp(t)
 // All attributes are initialised to the values of the input TTimeStamp.
 
  FillJulian();
+ fJps=0;
 }
 ///////////////////////////////////////////////////////////////////////////
 AliTimestamp::~AliTimestamp()
@@ -156,6 +161,7 @@ AliTimestamp::AliTimestamp(const AliTimestamp& t) : TTimeStamp(t)
  fMJD=t.fMJD;
  fJsec=t.fJsec;
  fJns=t.fJns;
+ fJps=t.fJps;
  fCalcs=t.fCalcs;
  fCalcns=t.fCalcns;
 }
@@ -552,7 +558,7 @@ Double_t AliTimestamp::GetJE()
  return je;
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliTimestamp::SetMJD(Int_t mjd,Int_t sec,Int_t ns)
+void AliTimestamp::SetMJD(Int_t mjd,Int_t sec,Int_t ns,Int_t ps)
 {
 // Set the Modified Julian Date (MJD) and time and update the TTimeStamp
 // parameters accordingly (if possible).
@@ -577,8 +583,11 @@ void AliTimestamp::SetMJD(Int_t mjd,Int_t sec,Int_t ns)
 // mjd : The modified Julian date.
 // sec : The number of seconds elapsed within the MJD.
 // ns  : The remaining fractional number of seconds (in ns) elapsed within the MJD.
+// ps  : The remaining fractional number of nanoseconds (in ps) elapsed within the MJD.
+//
+// Note : ps=0 is the default value.
 
- if (sec<0 || ns<0)
+ if (sec<0 || sec>=24*3600 || ns<0 || ns>=1e9 || ps<0 || ps>=1000)
  {
   cout << " *AliTimestamp::SetMJD* Invalid input."
        << " sec : " << sec << " ns : " << ns << endl; 
@@ -588,6 +597,7 @@ void AliTimestamp::SetMJD(Int_t mjd,Int_t sec,Int_t ns)
  fMJD=mjd;
  fJsec=sec;
  fJns=ns;
+ fJps=ps;
 
  Int_t epoch=40587;
  
@@ -649,7 +659,7 @@ void AliTimestamp::SetMJD(Double_t mjd)
  SetMJD(days,secs,ns);
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliTimestamp::SetJD(Int_t jd,Int_t sec,Int_t ns)
+void AliTimestamp::SetJD(Int_t jd,Int_t sec,Int_t ns,Int_t ps)
 {
 // Set the Julian Date (JD) and time and update the TTimeStamp
 // parameters accordingly (if possible).
@@ -674,6 +684,9 @@ void AliTimestamp::SetJD(Int_t jd,Int_t sec,Int_t ns)
 // jd  : The Julian date.
 // sec : The number of seconds elapsed within the JD.
 // ns  : The remaining fractional number of seconds (in ns) elapsed within the JD.
+// ps  : The remaining fractional number of nanoseconds (in ps) elapsed within the JD.
+//
+// Note : ps=0 is the default value.
 
  Int_t mjd=jd-2400000;
  sec-=12*3600;
@@ -683,7 +696,7 @@ void AliTimestamp::SetJD(Int_t jd,Int_t sec,Int_t ns)
   mjd-=1;
  }
 
- SetMJD(mjd,sec,ns);
+ SetMJD(mjd,sec,ns,ps);
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliTimestamp::SetJD(Double_t jd)
@@ -721,7 +734,7 @@ void AliTimestamp::SetJD(Double_t jd)
  SetJD(days,secs,ns);
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliTimestamp::SetTJD(Int_t tjd,Int_t sec,Int_t ns)
+void AliTimestamp::SetTJD(Int_t tjd,Int_t sec,Int_t ns,Int_t ps)
 {
 // Set the Truncated Julian Date (TJD) and time and update the TTimeStamp
 // parameters accordingly (if possible).
@@ -746,6 +759,9 @@ void AliTimestamp::SetTJD(Int_t tjd,Int_t sec,Int_t ns)
 // tjd : The Truncated Julian date.
 // sec : The number of seconds elapsed within the JD.
 // ns  : The remaining fractional number of seconds (in ns) elapsed within the JD.
+// ps  : The remaining fractional number of nanoseconds (in ps) elapsed within the JD.
+//
+// Note : ps=0 is the default value.
 
  Int_t mjd=tjd+40000;
 
@@ -787,3 +803,87 @@ void AliTimestamp::SetTJD(Double_t tjd)
  SetTJD(days,secs,ns);
 }
 ///////////////////////////////////////////////////////////////////////////
+Int_t AliTimestamp::GetPicoSec() const
+{
+// Provide remaining fractional number of nanoseconds in picoseconds.
+// This memberfunction supports time of flight analysis for particle physics
+// experiments.
+
+ return fJps; 
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliTimestamp::GetDifference(AliTimestamp& t,Int_t& d,Int_t& s,Int_t& ns,Int_t& ps) const
+{
+// Provide the time difference w.r.t the AliTimestamp specified on the input.
+// This memberfunction supports both very small (i.e. time of flight analysis
+// for particle physics experiments) and very long (i.e. investigation of
+// astrophysical phenomena) timescales.
+//
+// The time difference is returned via the following output arguments :
+// d  : elapsed number of days
+// s  : remaining elapsed number of seconds
+// ns : remaining elapsed number of nanoseconds
+// ps : remaining elapsed number of picoseconds
+//
+// The integer return argument indicates whether the AliTimestamp specified
+// on the input argument occurred earlier (-1), simultaneously (0) or later (1).
+
+ Int_t tmjd=0;
+ Int_t tsec=0;
+ Int_t tnsec=0;
+ t.GetMJD(tmjd,tsec,tnsec);
+ Int_t tpsec=t.GetPicoSec();
+
+ // Convert all stamps to seconds, nanoseconds and picoseconds
+ // to simplify the algebra.
+ tsec+=tmjd*24*3600;
+ Int_t sec=fJsec+fMJD*24*3600;
+
+ d=0;
+ s=tsec-sec;
+ ns=tnsec-fJns;
+ ps=tpsec-fJps;
+
+ if (!d && !s && !ns && !ps) return 0;
+
+ Int_t sign=0;
+
+ if (s>0) sign=1;
+ if (s<0) sign=-1;
+
+ if (!sign && ns>0) sign=1; 
+ if (!sign && ns<0) sign=-1;
+
+ if (!sign && ps>0) sign=1; 
+ if (!sign && ps<0) sign=-1;
+
+ // In case the input stamp was earlier, take the reverse difference
+ // to simplify the algebra.
+ if (sign<0)
+ {
+  s=-s;
+  ns=-ns;
+  ps=-ps;
+ }
+
+ // Here we always have a positive time difference
+ // and can now unambiguously correct for other negative values
+ // and determine the resulting daycount.
+ if (ps<0)
+ {
+  ns-=1;
+  ps+=1000;
+ }
+
+ if (ns<0)
+ {
+  s-=1;
+  ns+=1e9;
+ }
+
+ d=s/(24*3600);
+ s=s%(24*3600);
+
+ return sign;
+}
+///////////////////////////////////////////////////////////////////////////
index fe26b0afa8eab9fcae605f2fbcfbeeff799f7541..0d89176b1aed7d4bb2d86590b904196f3e070b52 100644 (file)
@@ -29,23 +29,26 @@ class AliTimestamp : public TTimeStamp
   void GetJD(Int_t& jd,Int_t& sec,Int_t& ns);   // Provide corresponding Julian Date and time
   Double_t GetJD();                             // Provide corresponding Julian Date in fractional days
   Double_t GetJE();                             // Provide corresponding Julian Epoch
-  void SetMJD(Int_t mjd,Int_t sec,Int_t ns);    // Set Modified Julian Date and time
-  void SetMJD(Double_t mjd);                    // Set Modified Julian Date and time
-  void SetJD(Int_t jd,Int_t sec,Int_t ns);      // Set Julian Date and time
-  void SetJD(Double_t jd);                      // Set Julian Date and time
-  void SetTJD(Int_t mjd,Int_t sec,Int_t ns);    // Set Modified Julian Date and time
-  void SetTJD(Double_t mjd);                    // Set Modified Julian Date and time
+  void SetMJD(Int_t mjd,Int_t sec,Int_t ns,Int_t ps=0); // Set Modified Julian Date and time
+  void SetMJD(Double_t mjd);                            // Set Modified Julian Date and time
+  void SetJD(Int_t jd,Int_t sec,Int_t ns,Int_t ps=0);   // Set Julian Date and time
+  void SetJD(Double_t jd);                              // Set Julian Date and time
+  void SetTJD(Int_t tjd,Int_t sec,Int_t ns,Int_t ps=0); // Set Truncated Julian Date and time
+  void SetTJD(Double_t tjd);                            // Set Truncated Julian Date and time
+  Int_t GetPicoSec() const;                     // Provide remaining fractional number of ns in picoseconds
+  Int_t GetDifference(AliTimestamp& t,Int_t& days,Int_t& sec,Int_t& ns,Int_t& ps) const; // Provide time difference
 
  protected:
   Int_t fMJD;  // Modified Julian Date
   Int_t fJsec; // Number of seconds elapsed within the MJD
   Int_t fJns;  // Remaining fractional number of seconds (in nanoseconds) elapsed within the MJD
+  Int_t fJps;  // Remaining fractional number of nanoseconds (in picoseconds) elapsed within the MJD
 
  private:
   void FillJulian(); // Calculation and setting of the corresponding Julian parameters  
   Int_t fCalcs;      // The TTimeStamp seconds counter value at Julian parameter calculation
   Int_t fCalcns;     // The TTimeStamp nanoseconds counter value at Julian parameter calculation
 
- ClassDef(AliTimestamp,1) // Handling of timestamps for (astro)particle physics research.
+ ClassDef(AliTimestamp,2) // Handling of timestamps for (astro)particle physics research.
 };
 #endif
index 7ba7a349a345d220ebf457bc5be4e2fbe59506a1..8efa659d72871795c0f59b2e9b7e4fca67b5c5cb 100644 (file)
@@ -117,6 +117,7 @@ void AliTrack::Init()
  fClosest=0;
  fParent=0;
  fFit=0;
+ fTstamp=0;
 }
 ///////////////////////////////////////////////////////////////////////////
 AliTrack::~AliTrack()
@@ -188,6 +189,11 @@ AliTrack::~AliTrack()
   delete fFit;
   fFit=0;
  }
+ if (fTstamp)
+ {
+  delete fTstamp;
+  fTstamp=0;
+ }
 }
 ///////////////////////////////////////////////////////////////////////////
 AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t)
@@ -205,6 +211,7 @@ AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t)
  if (t.fImpactYZ) fImpactYZ=new AliPositionObj(*(t.fImpactYZ));
  if (t.fClosest) fClosest=new AliPositionObj(*(t.fClosest));
  if (t.fFit) fFit=t.fFit->Clone();
+ if (t.fTstamp) fTstamp=new AliTimestamp(*(t.fTstamp));
  fUserId=t.fUserId;
  fChi2=t.fChi2;
  fNdf=t.fNdf;
@@ -315,6 +322,11 @@ void AliTrack::Reset()
   delete fFit;
   fFit=0;
  }
+ if (fTstamp)
+ {
+  delete fTstamp;
+  fTstamp=0;
+ }
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliTrack::Set3Momentum(Ali3Vector& p)
@@ -363,6 +375,7 @@ void AliTrack::Data(TString f)
  if (strlen(name))  cout << " Name : " << name;
  if (strlen(title)) cout << " Title : " << title;
  cout << endl;
+ if (fTstamp) fTstamp->Date(1);
  cout << " Id : " << fUserId << " Code : " << fCode
       << " m : " << m << " dm : " << dm << " Charge : " << fQ
       << " p : " << GetMomentum() << endl;
@@ -1262,6 +1275,29 @@ TObject* AliTrack::GetFitDetails()
  return fFit;
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetTimestamp(AliTimestamp& t)
+{
+// Store the timestamp for this track.
+ if (fTstamp) delete fTstamp;
+ fTstamp=new AliTimestamp(t);
+}
+///////////////////////////////////////////////////////////////////////////
+AliTimestamp* AliTrack::GetTimestamp()
+{
+// Provide the timestamp of this track.
+ return fTstamp;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::RemoveTimestamp()
+{
+// Remove the timestamp from this track.
+ if (fTstamp)
+ {
+  delete fTstamp;
+  fTstamp=0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
 TObject* AliTrack::Clone(const char* name) const
 {
 // Make a deep copy of the current object and provide the pointer to the copy.
index 9cb401bab0d1158b9574ea7665d80f3f88a5e6df..c4eda078a254de1f577a4d3eb2f88d8f9684fcb3 100644 (file)
@@ -15,6 +15,7 @@
 #include "AliSignal.h"
 #include "AliBoost.h"
 #include "AliPositionObj.h"
+#include "AliTimestamp.h"
  
 class AliTrack : public TNamed,public Ali4Vector
 {
@@ -83,7 +84,9 @@ class AliTrack : public TNamed,public Ali4Vector
   void SetFitDetails(TObject* obj);       // Enter the object containing the fit details
   void SetFitDetails(TObject& obj) { SetFitDetails(&obj); }
   TObject* GetFitDetails();               // Provide pointer to the object containing the fit details
-
+  void SetTimestamp(AliTimestamp& t);     // Set the track timestamp
+  AliTimestamp* GetTimestamp();           // Provide the track timestamp
+  void RemoveTimestamp();                 // Remove timestamp from this track
  
  protected:
   void Init();               // Initialisation of pointers etc...
@@ -105,10 +108,11 @@ class AliTrack : public TNamed,public Ali4Vector
   AliTrack* fParent;         // Pointer to the parent track
   Float_t fProb;             // Probability for this track as a hypothesis
   TObject* fFit;             // Object containing details of the fit
+  AliTimestamp* fTstamp;     // The track timestamp
 
  private:
   void Dumps(AliTrack* t,Int_t n,TString f); // Recursively print all decay levels
  
- ClassDef(AliTrack,13) // Handling of the attributes of a reconstructed particle track.
+ ClassDef(AliTrack,14) // Handling of the attributes of a reconstructed particle track.
 };
 #endif
index 71a608da1c739b326d672dd7fec02773bfa5d06a..eefc920e5ad0ae843ae26b9fb9e80a5ec9969206 100644 (file)
 18-apr-2005 NvE New memberfunction GetTracks introduced in AliJet to provide various track selections.
 19-apr-2005 NvE Memberfunctions GetNtracks and GetTracks of AliJet extended in functionality.
 20-apr-2005 NvE Id of owning device added to the output of AliSignal::Data().
+10-may-2005 NvE Support for timestamps introduced in AliTrack and AliPosition.
+                Memberfunction GetX introduced in Ali3Vector for easy component access.
+                Picosecond support and calculation of time difference introduced in AliTimestamp 
+                to enable investigation of both very short (i.e. time of flight analysis in
+                particle physics experiments) and very long (i.e. astrophysical phenomena)
+                time intervals.
\ No newline at end of file