]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCRawStream.cxx
Some of the coding violations corrected
[u/mrichter/AliRoot.git] / TPC / AliTPCRawStream.cxx
index 53c74756d33bf0af80e0babeccdae29107e349b3..57701c8f6847a18f1dbfbfb22cbd38b691124853 100644 (file)
 ClassImp(AliTPCRawStream)
 
 //_____________________________________________________________________________
-AliTPCRawStream::AliTPCRawStream(AliRawReader* rawReader) :
-  AliAltroRawStream(rawReader)
+AliTPCRawStream::AliTPCRawStream(AliRawReader* rawReader, AliAltroMapping **mapping) :
+  AliAltroRawStream(rawReader),
+  fSector(-1),
+  fPrevSector(-1),
+  fRow(-1),
+  fPrevRow(-1),
+  fPad(-1),
+  fPrevPad(-1),
+  fIsMapOwner(kFALSE)
 {
   // create an object to read TPC raw digits
 
-  fRawReader->Select(0);
-
-  TString path = gSystem->Getenv("ALICE_ROOT");
-  path += "/TPC/mapping/Patch";
-  TString path2;
-  for(Int_t i = 0; i < 6; i++) {
-    path2 = path;
-    path2 += i;
-    path2 += ".data";
-    fMapping[i] = new AliTPCAltroMapping(path2.Data());
+  SelectRawData("TPC");
+
+  if (mapping == NULL) {
+    TString path = gSystem->Getenv("ALICE_ROOT");
+    path += "/TPC/mapping/Patch";
+    TString path2;
+    for(Int_t i = 0; i < 6; i++) {
+      path2 = path;
+      path2 += i;
+      path2 += ".data";
+      fMapping[i] = new AliTPCAltroMapping(path2.Data());
+    }
+    fIsMapOwner = kTRUE;
   }
-
-  fNoAltroMapping = kFALSE;
+  else {
+    for(Int_t i = 0; i < 6; i++)
+      fMapping[i] = mapping[i];
+  }
+    
 }
 
 //_____________________________________________________________________________
 AliTPCRawStream::AliTPCRawStream(const AliTPCRawStream& stream) :
-  AliAltroRawStream(stream)
+  AliAltroRawStream(stream),
+  fSector(stream.fSector),
+  fPrevSector(stream.fPrevSector),
+  fRow(stream.fRow),
+  fPrevRow(stream.fPrevRow),
+  fPad(stream.fPad),
+  fPrevPad(stream.fPrevPad),
+  fIsMapOwner(kFALSE)
 {
-  Fatal("AliTPCRawStream", "copy constructor not implemented");
+  for(Int_t i = 0; i < 6; i++) fMapping[i] = stream.fMapping[i];
 }
 
 //_____________________________________________________________________________
-AliTPCRawStream& AliTPCRawStream::operator = (const AliTPCRawStream& 
-                                             /* stream */)
+AliTPCRawStream& AliTPCRawStream::operator = (const AliTPCRawStream& stream)
 {
-  Fatal("operator =", "assignment operator not implemented");
+  if(&stream == this) return *this;
+
+  ((AliAltroRawStream *)this)->operator=(stream);
+
+  fSector = stream.fSector;
+  fPrevSector = stream.fPrevSector;
+  fRow = stream.fRow;
+  fPrevRow = stream.fPrevRow;
+  fPad = stream.fPad;
+  fPrevPad = stream.fPrevPad;
+  fIsMapOwner = kFALSE;
+
+  for(Int_t i = 0; i < 6; i++) fMapping[i] = stream.fMapping[i];
+
   return *this;
 }
 
@@ -76,7 +108,8 @@ AliTPCRawStream::~AliTPCRawStream()
 {
 // destructor
 
-  for(Int_t i = 0; i < 6; i++) delete fMapping[i];
+  if (fIsMapOwner)
+    for(Int_t i = 0; i < 6; i++) delete fMapping[i];
 }
 
 //_____________________________________________________________________________
@@ -84,15 +117,34 @@ void AliTPCRawStream::Reset()
 {
   // reset tpc raw stream params
   AliAltroRawStream::Reset();
+  fSector = fPrevSector = fRow = fPrevRow = fPad = fPrevPad = -1;
+}
+
+//_____________________________________________________________________________
+Bool_t AliTPCRawStream::Next()
+{
+  // Read next TPC signal
+  // Apply the TPC altro mapping to get
+  // the sector,pad-row and pad indeces
+  fPrevSector = fSector;
+  fPrevRow = fRow;
+  fPrevPad = fPad;
+  if (AliAltroRawStream::Next()) {
+    if (IsNewHWAddress())
+      ApplyAltroMapping();
+    return kTRUE;
+  }
+  else
+    return kFALSE;
 }
 
 //_____________________________________________________________________________
 void AliTPCRawStream::ApplyAltroMapping()
 {
-  // Reads the DDL index, loads
+  // Take the DDL index, load
   // the corresponding altro mapping
-  // object and fills the sector,row and pad indeces
-  Int_t ddlNumber = fRawReader->GetDDLID();
+  // object and fill the sector,row and pad indeces
+  Int_t ddlNumber = GetDDLNumber();
   Int_t patchIndex;
   if (ddlNumber < 72) {
     fSector = ddlNumber / 2;
@@ -103,7 +155,10 @@ void AliTPCRawStream::ApplyAltroMapping()
     patchIndex = (ddlNumber - 72) % 4 + 2;
   }
 
-  fRow = fMapping[patchIndex]->GetPadRow(fHWAddress);
-  fPad = fMapping[patchIndex]->GetPad(fHWAddress);
+  Short_t hwAddress = GetHWAddress();
+  fRow = fMapping[patchIndex]->GetPadRow(hwAddress);
+  fPad = fMapping[patchIndex]->GetPad(hwAddress);
 
+  if ((fRow < 0) || (fPad < 0))
+    AddMappingErrorLog(Form("hw=%d",hwAddress)); 
 }