]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFSDigit.cxx
Merging added and test macro
[u/mrichter/AliRoot.git] / TOF / AliTOFSDigit.cxx
index 5d34990a4ec27a66034091f52d47a850b02c4225..9b77a7b2cce749090e64cc36ab9fb4992e87d497 100644 (file)
@@ -178,6 +178,67 @@ void AliTOFSDigit::Update(Float_t tdcbin, 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=50.; // [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)AliTOFConstants::fgkTimeDiff)/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) {
+         cerr<<"WARNING: AliTOFSDigit::Update  Many hits in the padhit"<<endl;
+         cerr<<"         ";
+         //    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()
 {