]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFSDigit.cxx
Merge from EVE-dev to HEAD.
[u/mrichter/AliRoot.git] / TOF / AliTOFSDigit.cxx
index f4b7b345610c2d5808da9b08e8e25809672b11b2..dba17762599bb3e362b71919833a869e37447003 100644 (file)
  * provided "as is" without express or implied warranty.                  * 
  **************************************************************************/
 
+/* $Id$ */
+
+//_________________________________________________________________________//
+//                                                                         //
+//  TOF sdigit: member variables                                           //
+//  fSector  : TOF sector                                                  //
+//  fPlate   : TOF plate                                                   //
+//  fStrip   : strips number                                               //
+//  fPadx    : pad number along x                                          //
+//  fPadz    : pad number along z                                          //
+//  fTdc     : TArrayF of TDC values                                       //
+//  fAdc     : TArrayF of ADC values                                       //
+//                                                                         //
+//  Getters, setters and member functions  defined here                    //
+//                                                                         //
+// -- Authors: F. Pierella, A. Seganti, D. Vicinanza                       //
+//_________________________________________________________________________//
 
-//_________________________________________________________________________
-//  TOF sdigit: member variables 
-//  fSector  : TOF sector
-//  fPlate   : TOF plate
-//  fStrip   : strips number
-//  fPadx    : pad number along x
-//  fPadz    : pad number along z
-//  fTdc     : TArrayF of TDC values
-//  fAdc     : TArrayF of ADC values
-//              
-//  Getters, setters and member functions  defined here
-//
-//*-- Authors: F. Pierella, A. Seganti, D. Vicinanza
-
-#include <iostream.h>
 #include "TArrayF.h"
 #include "TArrayI.h"
 
-#include "AliTOF.h"
+#include "AliLog.h"
+
+#include "AliTOFGeometry.h"
 #include "AliTOFSDigit.h"
-#include "AliTOFConstants.h"
-#include "AliRun.h"
-#include "AliMC.h"
 
 ClassImp(AliTOFSDigit)
 
@@ -54,10 +55,12 @@ ClassImp(AliTOFSDigit)
 
 ////////////////////////////////////////////////////////////////////////
 AliTOFSDigit::AliTOFSDigit(Int_t tracknum, Int_t *vol,Float_t *digit)
+:TObject()
 {
   //
   // Constructor of digit object
   //
+
   fSector = vol[0];
   fPlate  = vol[1];
   fStrip  = vol[2];
@@ -77,6 +80,7 @@ AliTOFSDigit::AliTOFSDigit(Int_t tracknum, Int_t *vol,Float_t *digit)
 
 ////////////////////////////////////////////////////////////////////////
 AliTOFSDigit::AliTOFSDigit(const AliTOFSDigit & digit)
+:TObject()
 {
   // 
   // copy ctor for AliTOFSDigit object
@@ -92,6 +96,25 @@ AliTOFSDigit::AliTOFSDigit(const AliTOFSDigit & digit)
   fTracks = new TArrayI(*digit.fTracks);
 }
 
+////////////////////////////////////////////////////////////////////////
+AliTOFSDigit& AliTOFSDigit::operator=(const AliTOFSDigit & digit)
+{
+  // 
+  // copy ctor for AliTOFSDigit object
+  //
+  this->fSector = digit.fSector;
+  this->fPlate  = digit.fPlate;
+  this->fStrip  = digit.fStrip;
+  this->fPadx   = digit.fPadx;
+  this->fPadz   = digit.fPadz;
+  this->fNDigits = digit.fNDigits;
+  this->fTdc = digit.fTdc;
+  this->fAdc = digit.fAdc;
+  this->fTracks = digit.fTracks;
+  return *this;
+
+}
+
 ////////////////////////////////////////////////////////////////////////
 AliTOFSDigit::AliTOFSDigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx,
                           Int_t padz, Float_t tdc, Float_t adc)
@@ -132,16 +155,16 @@ void AliTOFSDigit::GetLocation(Int_t *Loc) const
 }
 
 ////////////////////////////////////////////////////////////////////////
-void AliTOFSDigit::Update(Int_t tdc, Int_t adc, Int_t track)
+void AliTOFSDigit::Update(Float_t tdcbin, Int_t tdc, Int_t adc, Int_t track)
 {
   //
   // Add charge and track
   //
   
   Int_t sameTime = -1;
-  
+  Float_t tdcwindow=((Float_t)AliTOFGeometry::TimeDiff())/tdcbin;
   for (Int_t i = 0; i < fNDigits; i++) {
-    if (TMath::Abs(tdc-fTdc->At(i)) < AliTOFConstants::fgkTimeDiff) {
+    if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
       sameTime = i;
       break;
     }
@@ -158,9 +181,8 @@ void AliTOFSDigit::Update(Int_t tdc, Int_t adc, Int_t track)
       }
       // write warning about many tracks going to this pad
       if (iTrack == kMAXDIGITS) {
-       cerr<<"WARNING: AliTOFSDigit::Update  Many hits in the padhit"<<endl;
-       cerr<<"         ";
-       //      PrintPad();
+       AliWarning("Many hits in the padhit");
+       //      ToAliWarning(PrintPad());
       }
     }
   } else {
@@ -178,6 +200,66 @@ void AliTOFSDigit::Update(Int_t tdc, Int_t adc, Int_t track)
   }
   
 }
+
+////////////////////////////////////////////////////////////////////////
+void AliTOFSDigit::Update(AliTOFSDigit* sdig)
+{
+
+  //
+  // Perform the sum with sdig
+  //
+
+  // start loop on all sdig locations
+  Int_t nlocations=sdig->GetNDigits();
+
+  for (Int_t j = 0; j < nlocations; j++) {
+    Float_t tdcbin = AliTOFGeometry::TdcBinWidth();// [ps] hardwired for the time being
+    Int_t tdc=(Int_t)sdig->GetTdc(j);
+    Int_t adc=(Int_t)sdig->GetAdc(j);
+    // getting here only the first track number
+    Int_t track=GetTrack(j,0);
+    
+    
+    Int_t sameTime = -1;
+    Float_t tdcwindow=((Float_t)AliTOFGeometry::TimeDiff())/tdcbin;
+    for (Int_t i = 0; i < fNDigits; i++) {
+      if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
+       sameTime = i;
+       break;
+      }
+    }
+    
+    if (sameTime >= 0) {
+      (*fAdc)[sameTime] += static_cast<Float_t>(adc);
+      // update track - find the first -1  value and replace it by the
+      // track number
+      for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
+       if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
+         (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
+         break;
+       }
+       // write warning about many tracks going to this pad
+       if (iTrack == kMAXDIGITS) {
+         AliWarning("Many hits in the padhit");
+         //    ToAliWarning(PrintPad());
+       }
+      }
+    } else {
+      // add new time slot
+      fNDigits++;
+      fTdc->Set(fNDigits);
+      (*fTdc)[fNDigits-1] = tdc;
+      fAdc->Set(fNDigits);
+      (*fAdc)[fNDigits-1] = adc;
+      fTracks->Set(fNDigits*kMAXDIGITS);
+      (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
+      for (Int_t i = 1; i <kMAXDIGITS; i++) {
+       (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
+      } // for (Int_t i = 1; i <kMAXDIGITS; i++)
+    } // if (sameTime >= 0)
+  } // end loop on sdig locations
+}
+
 ////////////////////////////////////////////////////////////////////////
 AliTOFSDigit::~AliTOFSDigit()
 {
@@ -191,40 +273,36 @@ AliTOFSDigit::~AliTOFSDigit()
 
 ////////////////////////////////////////////////////////////////////////
 
-Int_t AliTOFSDigit::GetTotPad() const
+Int_t AliTOFSDigit::GetTotPad(AliTOFGeometry *tofGeom) const
 {
   //
   // Get the "total" index of the pad inside a Sector
   // starting from the digits data.
   //
   
-  AliTOF* tof;
-  
-  if(gAlice){
-    tof =(AliTOF*) gAlice->GetDetector("TOF");
-  }else{
-    printf("AliTOFSDigit::GetTotPad - No AliRun object present, exiting");
-    return 0;
-  }
-  
-  Int_t pad = fPadx+tof->GetNpadX()*(fPadz-1);
+  Int_t pad = 2*fPadx + fPadz;
+  //Int_t pad = fPadx+AliTOFGeometry::NpadX()*fPadz;
   Int_t before=0;
   
   switch(fPlate){ 
-  case 1: before = 0;
+  case 0:
+    //before = 0;
     break;
-  case 2: before = tof->GetNStripC();
+  case 1:
+    before = tofGeom->NStripC();
     break;
-  case 3: before = tof->GetNStripB() + tof->GetNStripC();
+  case 2:
+    before = AliTOFGeometry::NStripB() +   tofGeom->NStripC();
     break;
-  case 4: before = tof->GetNStripA() + tof->GetNStripB() + tof->GetNStripC();
+  case 3:
+    before = AliTOFGeometry::NStripA() +   AliTOFGeometry::NStripB() + tofGeom->NStripC();
     break;
-  case 5: before = tof->GetNStripA() + 2*tof->GetNStripB() + tof->GetNStripC();
+  case 4:
+    before = AliTOFGeometry::NStripA() + 2*AliTOFGeometry::NStripB() + tofGeom->NStripC();
     break;
   }
   
-  Int_t strip = fStrip+before;
-  Int_t padTot = tof->GetPadXStr()*(strip-1)+pad;
+  Int_t strip = fStrip + before;
+  Int_t padTot = AliTOFGeometry::NpadXStrip()*strip + pad;
   return padTot;
 }
-