]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDmcmTracklet.cxx
Make some calculations optional for HLT
[u/mrichter/AliRoot.git] / TRD / AliTRDmcmTracklet.cxx
index 9ad1e0d4cb71f8d3687691b53d5ac28098d36af3..90f7648a10b570ef51d2da35b3b7307719b1d994 100644 (file)
 #include <TMath.h>
 #include <TF1.h>
 
+#include "AliLog.h"
+
 #include "AliTRDcalibDB.h"
 #include "AliTRDCommonParam.h"
 #include "AliTRDpadPlane.h"
 #include "AliTRDgeometry.h"
-
 #include "AliTRDmcmTracklet.h"
 
 ClassImp(AliTRDmcmTracklet)
 
 //_____________________________________________________________________________
 AliTRDmcmTracklet::AliTRDmcmTracklet() 
+  :TObject()
+  ,fGeo(0)
+  ,fDetector(-1)
+  ,fRow(-1)
+  ,fTrackLabel(-1)
+  ,fNclusters(0)
+  ,fN(0)
+  ,fGPos(0)
+  ,fGAmp(0)
+  ,fTime0(0)
+  ,fRowz(0)
+  ,fSlope(0)
+  ,fOffset(0)
+  ,fPt(0)
+  ,fdQdl(0)
 {
-
   //
   // AliTRDmcmTracklet default constructor
   //
 
-  fDetector = -1;
-  fRow      = -1;
-
   for (Int_t time = 0; time < kNtimeBins; time++) {
     for (Int_t icl = 0; icl < kNclsPads; icl++) {
       fADC[time][icl] = 0;
@@ -56,33 +68,32 @@ AliTRDmcmTracklet::AliTRDmcmTracklet()
     fCol[time]    = 0;
   }
 
-  fNclusters  =  0;
-  fN          =  0;
-  fTrackLabel = -1;
-
-  fGPos = 0;
-  fGAmp = 0;
-
-  fSlope  = 0.0;
-  fOffset = 0.0;
-  fTime0  = 0.0;
-  fRowz   = 0.0;
-  fPt     = 0.0;
-  fdQdl   = 0.0;
+  fGeo = new AliTRDgeometry();
 
 }
 
 //_____________________________________________________________________________
 AliTRDmcmTracklet::AliTRDmcmTracklet(Int_t det, Int_t row, Int_t n) 
+  :TObject()
+  ,fGeo(0)
+  ,fDetector(det)
+  ,fRow(row)
+  ,fTrackLabel(-1)
+  ,fNclusters(0)
+  ,fN(n)
+  ,fGPos(0)
+  ,fGAmp(0)
+  ,fTime0(0)
+  ,fRowz(0)
+  ,fSlope(0)
+  ,fOffset(0)
+  ,fPt(0)
+  ,fdQdl(0)
 {
-
   //
   // AliTRDmcmTracklet default constructor
   //
 
-  fDetector = det;
-  fRow      = row;
-
   for (Int_t time = 0; time < kNtimeBins; time++) {
     for (Int_t icl = 0; icl < kNclsPads; icl++) {
       fADC[time][icl] = 0;
@@ -94,40 +105,74 @@ AliTRDmcmTracklet::AliTRDmcmTracklet(Int_t det, Int_t row, Int_t n)
     fCol[time]    = 0;
   }
 
-  fNclusters = 0;
+  fGPos = new TGraph(0);
+  fGAmp = new TGraph(0);
 
-  fN = n;
+  fGeo  = new AliTRDgeometry();
 
-  fTrackLabel = -1;
+}
 
-  fGPos = new TGraph(0);
-  fGAmp = new TGraph(0);
+//_____________________________________________________________________________
+AliTRDmcmTracklet::AliTRDmcmTracklet(const AliTRDmcmTracklet &t) 
+  :TObject(t)
+  ,fGeo(0)
+  ,fDetector(t.fDetector)
+  ,fRow(t.fRow)
+  ,fTrackLabel(t.fTrackLabel)
+  ,fNclusters(t.fNclusters)
+  ,fN(t.fN)
+  ,fGPos(NULL)
+  ,fGAmp(NULL)
+  ,fTime0(t.fTime0)
+  ,fRowz(t.fRowz)
+  ,fSlope(t.fSlope)
+  ,fOffset(t.fOffset)
+  ,fPt(t.fPt)
+  ,fdQdl(t.fdQdl)
+{
+  //
+  // AliTRDmcmTracklet copy constructor
+  //
 
-  fSlope  = 0.0;
-  fOffset = 0.0;
-  fTime0  = 0.0;
-  fRowz   = 0.0;
-  fPt     = 0.0;
-  fdQdl   = 0.0;
+  for (Int_t time = 0; time < kNtimeBins; time++) {
+    for (Int_t icl = 0; icl < kNclsPads; icl++) {
+      ((AliTRDmcmTracklet &) t).fADC[time][icl] = 0;
+    }
+    for (Int_t it = 0; it < kNdict; it++) {
+      ((AliTRDmcmTracklet &) t).fTrack[time][it] = -1;
+    }
+    ((AliTRDmcmTracklet &) t).fTime[time]   = 0;
+    ((AliTRDmcmTracklet &) t).fCol[time]    = 0;
+  }
+
+  if (fGeo) {
+    delete fGeo;
+  }
+  fGeo = new AliTRDgeometry();
 
 }
 
 //_____________________________________________________________________________
 AliTRDmcmTracklet::~AliTRDmcmTracklet() 
 {
-
   //
   // AliTRDmcmTracklet destructor
   //
-  delete fGPos;
-  delete fGAmp;
+
+  if (fGPos != 0) delete fGPos;
+  if (fGAmp != 0) delete fGAmp;
+
+  if (fGeo) {
+    delete fGeo;
+  }
+
 }
 
 //_____________________________________________________________________________
 AliTRDmcmTracklet &AliTRDmcmTracklet::operator=(const AliTRDmcmTracklet &t)
 {
   //
-  // assignment operator
+  // Assignment operator
   //
 
   if (this != &t) ((AliTRDmcmTracklet &) t).Copy(*this); 
@@ -139,7 +184,7 @@ AliTRDmcmTracklet &AliTRDmcmTracklet::operator=(const AliTRDmcmTracklet &t)
 void AliTRDmcmTracklet::Copy(TObject &t) const
 {
   //
-  // copy function
+  // Copy function
   //
 
   ((AliTRDmcmTracklet &) t).fDetector    = fDetector;
@@ -170,16 +215,52 @@ void AliTRDmcmTracklet::Copy(TObject &t) const
 }
 
 //_____________________________________________________________________________
-void AliTRDmcmTracklet::AddCluster(Int_t icol, Int_t itb, Float_t *adc, Int_t *track
+void AliTRDmcmTracklet::Reset(
 {
   //
+  // Reset the tracklet information
+  //
+
+  fDetector = -1;
+  fRow      = -1;
+
+  for (Int_t time = 0; time < kNtimeBins; time++) {
+    for (Int_t icl = 0; icl < kNclsPads; icl++) {
+      fADC[time][icl] = 0;
+    }
+    for (Int_t it = 0; it < kNdict; it++) {
+      fTrack[time][it] = -1;
+    }
+    fTime[time]   = 0;
+    fCol[time]    = 0;
+  }
+
+  fNclusters  =  0;
+  fN          =  0;
+  fTrackLabel = -1;
+
+  fGPos->Set(0);
+  fGAmp->Set(0);
+
+  fSlope  = 0.0;
+  fOffset = 0.0;
+  fTime0  = 0.0;
+  fRowz   = 0.0;
+  fPt     = 0.0;
+  fdQdl   = 0.0;
+
+}
+
+//_____________________________________________________________________________
+void AliTRDmcmTracklet::AddCluster(Int_t icol, Int_t itb, Float_t *adc, Int_t *track) 
+{
   //
+  // Add a cluster to the tracklet
   //
  
   if (fNclusters >= kNtimeBins) return;
 
   for (Int_t icl = 0; icl < kNclsPads; icl++) {
-    //fADC[fNclusters][icl] = (Int_t)adc[icl]; 
     fADC[fNclusters][icl] = adc[icl]; 
   }
 
@@ -196,38 +277,34 @@ void AliTRDmcmTracklet::AddCluster(Int_t icol, Int_t itb, Float_t *adc, Int_t *t
 //_____________________________________________________________________________
 void AliTRDmcmTracklet::MakeTrackletGraph(AliTRDgeometry *geo, Float_t field) 
 {
-
   //
   // Tracklet graph of positions (global coordinates, rotated [cm])
   //
   
   if (!geo) {
-    Error("MakeTrackletGraph","No geometry.");
+    AliError("No geometry.");
     return;
   }
   
-  AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
-  if (!commonParam)
-  {
-    Error("MakeTrackletGraph","No common params.");
+  if (!AliTRDCommonParam::Instance()) {
+    AliError("No common parameters.");
     return;
   }
 
   AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
-  if (!calibration)
-  {
-    Error("MakeTrackletGraph","No instance of AliTRDcalibDB.");
+  if (!calibration) {
+    AliError("No instance of AliTRDcalibDB.");
     return;
   }
 
-  Int_t iplan, icham;
+  Int_t ilayer, istack;
 
-  iplan = geo->GetPlane(fDetector);
-  icham = geo->GetChamber(fDetector);
+  ilayer = geo->GetLayer(fDetector);
+  istack = geo->GetStack(fDetector);
 
-  AliTRDpadPlane *padPlane = commonParam->GetPadPlane(iplan,icham);
+  AliTRDpadPlane *padPlane = fGeo->GetPadPlane(ilayer,istack);
 
-  Float_t samplFreq = calibration->GetSamplingFrequency();
+  Float_t samplFreq = AliTRDCommonParam::Instance()->GetSamplingFrequency();
 
   Int_t time, col;
   Float_t amp[3];
@@ -248,7 +325,7 @@ void AliTRDmcmTracklet::MakeTrackletGraph(AliTRDgeometry *geo, Float_t field)
 
     if (amp[0] < 0.0 || amp[1] < 0.0 || amp[2] < 0.0) continue;
 
-    ypos = GetClusY(amp,iplan);
+    ypos = GetClusY(amp,ilayer);
 
     colSize = padPlane->GetColSize(col);
     vDrift = calibration->GetVdrift(fDetector,col,fRow);
@@ -256,20 +333,20 @@ void AliTRDmcmTracklet::MakeTrackletGraph(AliTRDgeometry *geo, Float_t field)
     
     // From v4-03-Release to HEAD28Mar06 the sign has changed from "-" to "+" 
     // due to a change in the digitizer
-    omegaTau = +TMath::Sign(1.0,(Double_t)field)*GetOmegaTau(vDrift,TMath::Abs(field));
+    omegaTau     = TMath::Sign(1.0,(Double_t)field)*GetOmegaTau(vDrift,TMath::Abs(field));
     lorentzAngle = TMath::ATan(omegaTau)*180.0/TMath::Pi();
     
     xpos = (time+0.5) * timeBinSize;
-    xpos = geo->GetTime0(iplan) - xpos;
+    xpos = geo->GetTime0(ilayer) - xpos;
 
     ypos = padPlane->GetColPos(col) - (ypos + 0.5) * colSize;
 
     // ExB correction
-    xzero = geo->GetTime0(iplan);
+    xzero = geo->GetTime0(ilayer);
     ypos = ypos + (xpos-xzero) * omegaTau;
 
     // tilted pads correction
-    thetaSlope = - padPlane->GetRowPos(fRow)/geo->GetTime0(iplan);
+    thetaSlope = - padPlane->GetRowPos(fRow)/geo->GetTime0(ilayer);
     tiltingAngle = padPlane->GetTiltingAngle()/180.0*TMath::Pi();
     ypos = ypos - (xpos-xzero) * thetaSlope * TMath::Sin(tiltingAngle);
 
@@ -280,12 +357,16 @@ void AliTRDmcmTracklet::MakeTrackletGraph(AliTRDgeometry *geo, Float_t field)
 
   fGPos->Set(npg);
   
-  fTime0 = geo->GetTime0(iplan) - AliTRDgeometry::CdrHght() - 0.5*AliTRDgeometry::CamHght();
+  fTime0 = geo->GetTime0(ilayer) - AliTRDgeometry::CdrHght() - 0.5*AliTRDgeometry::CamHght();
   fRowz = padPlane->GetRowPos(fRow) - padPlane->GetRowSize(fRow)/2.0;
 
-  Double_t xMin = 0, xMax = 0, x, y;
-  fGPos->GetPoint(0    ,x,y); xMax = x + 0.1;
-  fGPos->GetPoint(npg-1,x,y); xMin = x - 0.1;
+  Double_t xMin = 0;
+  Double_t xMax = 0;
+  Double_t x, y;
+  fGPos->GetPoint(0    ,x,y); 
+  xMax = x + 0.1;
+  fGPos->GetPoint(npg-1,x,y); 
+  xMin = x - 0.1;
   
   TF1 *line = new TF1("line","[0]+x*[1]",xMin,xMax);
   fGPos->Fit(line,"WRQ0");
@@ -299,8 +380,8 @@ void AliTRDmcmTracklet::MakeTrackletGraph(AliTRDgeometry *geo, Float_t field)
   Float_t fy = fOffset;
   
   Float_t infSlope = TMath::ATan(fy/fx)/TMath::Pi()*180.0;    
-  Float_t alpha = fSlope - infSlope;
-  Float_t r = TMath::Sqrt(fx*fx + fy*fy)/(2.0*TMath::Sin(alpha/180.0*TMath::Pi()));
+  Float_t alpha    = fSlope - infSlope;
+  Float_t r        = TMath::Sqrt(fx*fx + fy*fy)/(2.0*TMath::Sin(alpha/180.0*TMath::Pi()));
 
   fPt = 0.3 * field * 0.01 * r;
   
@@ -315,16 +396,10 @@ void AliTRDmcmTracklet::MakeClusAmpGraph()
   // Tracklet graph of cluster charges
   //
 
-  AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
-  if (!calibration)
-  {
-    Error("MakeClusAmpGraph","No instance of AliTRDcalibDB.");
-    return;
-  }
-
-  Int_t time;
+  Int_t   time;
   Float_t amp[3];
-  Int_t npg = 0;
+  Int_t   npg = 0;
+
   fdQdl = 0.0;
   for (Int_t icl = 0; icl < fNclusters; icl++) {
 
@@ -350,7 +425,7 @@ void AliTRDmcmTracklet::MakeClusAmpGraph()
 }
 
 //_____________________________________________________________________________
-Float_t AliTRDmcmTracklet::GetClusY(Float_t *adc, Int_t pla) const
+Float_t AliTRDmcmTracklet::GetClusY(Float_t *adc, Int_t layer) const
 {
   //
   // Cluster position in the phi direction in pad units (relative to the pad border)
@@ -368,7 +443,7 @@ Float_t AliTRDmcmTracklet::GetClusY(Float_t *adc, Int_t pla) const
 
   Float_t sigma = 0.0;
 
-  switch(pla) {
+  switch(layer) {
   case 0:
     sigma = 0.515; break;
   case 1:
@@ -382,7 +457,7 @@ Float_t AliTRDmcmTracklet::GetClusY(Float_t *adc, Int_t pla) const
   case 5:
     sigma = 0.463; break;
   default:
-    Error("GetClusY","Wrong plane number.");
+    AliError("Wrong layer number.");
     return 0.0;
   }
 
@@ -447,7 +522,7 @@ void AliTRDmcmTracklet::CookLabel(Float_t frac)
        trackCount[nTracks]++;
        nTracks++;
        if (nTracks == kMaxTracks) {
-         Warning("CookLabel","Too many tracks for this tracklet.");
+         AliWarning("Too many tracks for this tracklet.");
          nTracks--;
          break;
        }
@@ -490,9 +565,9 @@ Float_t AliTRDmcmTracklet::GetOmegaTau(Float_t vdrift, Float_t field) const
   ib       = TMath::Min(kNb,ib);
 
   Float_t alphaL = p0[ib] 
-      + p1[ib] * vdrift
-      + p2[ib] * vdrift*vdrift
-      + p3[ib] * vdrift*vdrift*vdrift;
+                 + p1[ib] * vdrift
+                 + p2[ib] * vdrift*vdrift
+                 + p3[ib] * vdrift*vdrift*vdrift;
 
   return TMath::Tan(alphaL);