]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Raw data update: to read the TOF raw data defined in UNPACKED mode
authordecaro <decaro@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 20 Feb 2007 15:57:00 +0000 (15:57 +0000)
committerdecaro <decaro@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 20 Feb 2007 15:57:00 +0000 (15:57 +0000)
20 files changed:
TOF/AliTOF.cxx
TOF/AliTOFClusterFinder.cxx
TOF/AliTOFClusterFinder.h
TOF/AliTOFDDLRawData.cxx
TOF/AliTOFDDLRawData.h
TOF/AliTOFDataDCS.cxx
TOF/AliTOFDataDCS.h
TOF/AliTOFDigitMap.cxx
TOF/AliTOFDigitMap.h
TOF/AliTOFGeometryV4.cxx
TOF/AliTOFGeometryV4.h
TOF/AliTOFRawDataRead.C
TOF/AliTOFRawMap.cxx [new file with mode: 0644]
TOF/AliTOFRawMap.h [new file with mode: 0644]
TOF/AliTOFRawStream.cxx
TOF/AliTOFRawStream.h
TOF/AliTOFrawData.cxx [new file with mode: 0644]
TOF/AliTOFrawData.h [new file with mode: 0644]
TOF/TOFbaseLinkDef.h
TOF/libTOFbase.pkg

index 853003c7d5ffd86095cceb2d588c0624c453f6fd..234515cb517d8e5e3a68cb520e7ec0f27f6c20da 100644 (file)
@@ -706,6 +706,7 @@ void AliTOF::Digits2Raw()
   AliTOFDDLRawData rawWriter(geometry);
   //AliTOFDDLRawData rawWriter;
   rawWriter.SetVerbose(0);
+  //rawWriter.SetAcquisitionMode(kFALSE);
   
   AliDebug(1,"Formatting raw data for TOF");
   digits->GetEvent(0);
index 3e1b051032b7a3b23075aff15c085adb85e3ee08..5e686a5a83e8ccf89c6560ab9e52130abd419ae2 100644 (file)
@@ -14,6 +14,7 @@
  **************************************************************************/
 
 /* 
+$Log$
 
 Revision 0.03  2005/07/28 A. De Caro
          Implement public method
@@ -50,8 +51,10 @@ Revision 0.01  2005/07/25 A. De Caro
 //                                                            //
 ////////////////////////////////////////////////////////////////
 
+#include "Riostream.h"
+
 #include "TClonesArray.h"
-#include "TFile.h"
+//#include "TFile.h"
 #include "TTree.h"
 
 #include "AliDAQ.h"
@@ -60,17 +63,18 @@ Revision 0.01  2005/07/25 A. De Caro
 #include "AliRawReader.h"
 #include "AliRunLoader.h"
 
-#include "AliTOFcalib.h"
 #include "AliTOFCal.h"
+#include "AliTOFcalib.h"
 #include "AliTOFChannel.h"
 #include "AliTOFClusterFinder.h"
 #include "AliTOFcluster.h"
 #include "AliTOFdigit.h"
-#include "AliTOFGeometryV5.h"
 #include "AliTOFGeometry.h"
+#include "AliTOFGeometryV5.h"
+#include "AliTOFrawData.h"
 #include "AliTOFRawStream.h"
 
-extern TFile *gFile;
+//extern TFile *gFile;
 
 ClassImp(AliTOFClusterFinder)
 
@@ -82,7 +86,8 @@ AliTOFClusterFinder::AliTOFClusterFinder():
   fTOFGeometry(new AliTOFGeometryV5()),
   fDigits(new TClonesArray("AliTOFdigit", 4000)),
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
-  fNumberOfTofClusters(0)
+  fNumberOfTofClusters(0),
+  fVerbose(0)
 {
 //
 // Constructor
@@ -101,7 +106,8 @@ AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader):
   fTOFGeometry(new AliTOFGeometryV5()),
   fDigits(new TClonesArray("AliTOFdigit", 4000)),
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
-  fNumberOfTofClusters(0)
+  fNumberOfTofClusters(0),
+  fVerbose(0)
 {
 //
 // Constructor
@@ -124,7 +130,8 @@ AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source)
   fTOFGeometry(new AliTOFGeometryV5()),
   fDigits(new TClonesArray("AliTOFdigit", 4000)),
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
-  fNumberOfTofClusters(0)
+  fNumberOfTofClusters(0),
+  fVerbose(0)
 {
   // copy constructor
   this->fDigits=source.fDigits;
@@ -140,6 +147,7 @@ AliTOFClusterFinder& AliTOFClusterFinder::operator=(const AliTOFClusterFinder &s
   this->fDigits=source.fDigits;
   this->fRecPoints=source.fRecPoints;
   this->fTOFGeometry=source.fTOFGeometry;
+  this->fVerbose=source.fVerbose;
   return *this;
 
 }
@@ -190,7 +198,7 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
     return;
   }
 
-  TClonesArray dummy("AliTOFdigit",10000), *digits=&dummy;
+  TClonesArray *digits = new TClonesArray("AliTOFdigit",10000);
   branch->SetAddress(&digits);
 
   ResetRecpoint();
@@ -270,8 +278,10 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
   Int_t bufsize = 32000;
   clustersTree->Branch("TOF", &fRecPoints, bufsize);
 
+  TClonesArray * clonesRawData;
+
   Int_t ii = 0;
-  Int_t indexDDL = 0;
+  Int_t dummy = -1;
 
   Int_t detectorIndex[5];
   Float_t position[3];
@@ -279,6 +289,85 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
   Float_t tToT;
   Double_t tTdcND;
 
+  ofstream ftxt;
+  if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
+
+  Int_t indexDDL = 0;
+  for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
+
+    rawReader->Reset();
+    AliTOFRawStream tofInput(rawReader);
+    tofInput.LoadRawData(indexDDL);
+
+    clonesRawData = (TClonesArray*)tofInput.GetRawData();
+
+    for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
+
+      AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
+
+      if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
+
+      if (fVerbose==2) {
+       if (indexDDL<10) ftxt << "  " << indexDDL;
+       else         ftxt << " " << indexDDL;
+       if (tofRawDatum->GetTRM()<10) ftxt << "  " << tofRawDatum->GetTRM();
+       else         ftxt << " " << tofRawDatum->GetTRM();
+       ftxt << "  " << tofRawDatum->GetTRMchain();
+       if (tofRawDatum->GetTDC()<10) ftxt << "  " << tofRawDatum->GetTDC();
+       else         ftxt << " " << tofRawDatum->GetTDC();
+       ftxt << "  " << tofRawDatum->GetTDCchannel();
+      }
+
+      tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
+                                   tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
+      dummy = detectorIndex[3];
+      detectorIndex[3] = detectorIndex[4];
+      detectorIndex[4] = dummy;
+
+      if (fVerbose==2) {
+       if (detectorIndex[0]<10) ftxt  << "  ->  " << detectorIndex[0];
+       else              ftxt  << "  -> " << detectorIndex[0];
+       ftxt << "  " << detectorIndex[1];
+       if (detectorIndex[2]<10) ftxt << "  " << detectorIndex[2];
+       else              ftxt << " " << detectorIndex[2];
+       ftxt << "  " << detectorIndex[3];
+       if (detectorIndex[4]<10) ftxt << "  " << detectorIndex[4];
+       else              ftxt << " " << detectorIndex[4];
+      }
+
+      for (ii=0; ii<3; ii++) position[ii] =  0.;
+      fTOFGeometry->GetPos(detectorIndex, position);
+
+      cylindricalPosition[0] = TMath::Sqrt(position[0]*position[0] + position[1]*position[1]);
+      cylindricalPosition[1] = TMath::ATan2(position[1], position[0]);
+      cylindricalPosition[2] = position[2];
+      cylindricalPosition[3] = tofRawDatum->GetTOF();
+      cylindricalPosition[4] = tofRawDatum->GetTOT();
+      tToT = tofRawDatum->GetTOT();
+      tTdcND = -1.;
+      AliTOFcluster *tofCluster = new AliTOFcluster(cylindricalPosition, detectorIndex);
+      tofCluster->SetToT(tToT);
+      tofCluster->SetTDCND(tTdcND);
+      InsertCluster(tofCluster);
+
+      if (fVerbose==2) {
+       if (cylindricalPosition[4]<10)                        ftxt << "        " << cylindricalPosition[4];
+       else if (cylindricalPosition[4]>=10 && cylindricalPosition[4]<100) ftxt << "       " << cylindricalPosition[4];
+       else                                     ftxt << "      " << cylindricalPosition[4];
+       if (cylindricalPosition[3]<10)                             ftxt << "      " << cylindricalPosition[3] << endl;
+       else if (cylindricalPosition[3]>=10 && cylindricalPosition[3]<100)   ftxt << "     " << cylindricalPosition[3] << endl;
+       else if (cylindricalPosition[3]>=100 && cylindricalPosition[3]<1000) ftxt << "    " << cylindricalPosition[3] << endl;
+       else                                             ftxt << "   " << cylindricalPosition[3] << endl;
+      }
+
+    } // closed loop on TOF raw data per current DDL file
+
+    clonesRawData->Clear();
+
+  } // closed loop on DDL index
+
+  /*
+  Int_t indexDDL = 0;
   for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
 
     rawReader->Reset();
@@ -322,6 +411,9 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
     } // while loop
 
   } // loop on DDL files
+  */
+
+  if (fVerbose==2) ftxt.close();
 
   AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters));
 
@@ -358,8 +450,10 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader
   Int_t bufsize = 32000;
   fTreeR->Branch("TOF", &fRecPoints, bufsize);
 
+  TClonesArray * clonesRawData;
+
   Int_t ii = 0;
-  Int_t indexDDL = 0;
+  Int_t dummy = -1;
 
   Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
   Float_t position[3];
@@ -367,50 +461,84 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader
   Float_t tToT;
   Double_t tTdcND;
 
+  ofstream ftxt;
+  if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
+
+  Int_t indexDDL = 0;
   for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
 
     rawReader->Reset();
     AliTOFRawStream tofInput(rawReader);
-    rawReader->Select("TOF", indexDDL, indexDDL);
-
-    while(tofInput.Next()) {
-
-      for (ii=0; ii<5; ii++) detectorIndex[ii] = -1;
-
-      detectorIndex[0] = (Int_t)tofInput.GetSector();
-      detectorIndex[1] = (Int_t)tofInput.GetPlate();
-      detectorIndex[2] = (Int_t)tofInput.GetStrip();
-      detectorIndex[3] = (Int_t)tofInput.GetPadZ();
-      detectorIndex[4] = (Int_t)tofInput.GetPadX();
-
-      if (detectorIndex[0]==-1 ||
-         detectorIndex[1]==-1 ||
-         detectorIndex[2]==-1 ||
-         detectorIndex[3]==-1 ||
-         detectorIndex[4]==-1) continue;
-
-      //AliInfo(Form("  %2i  %1i  %2i  %1i  %2i ",detectorIndex[0],detectorIndex[1],detectorIndex[2],detectorIndex[3],detectorIndex[4]));
+    tofInput.LoadRawData(indexDDL);
+
+    clonesRawData = (TClonesArray*)tofInput.GetRawData();
+
+    for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
+
+      AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
+
+      if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
+
+      if (fVerbose==2) {
+       if (indexDDL<10) ftxt << "  " << indexDDL;
+       else         ftxt << " " << indexDDL;
+       if (tofRawDatum->GetTRM()<10) ftxt << "  " << tofRawDatum->GetTRM();
+       else         ftxt << " " << tofRawDatum->GetTRM();
+       ftxt << "  " << tofRawDatum->GetTRMchain();
+       if (tofRawDatum->GetTDC()<10) ftxt << "  " << tofRawDatum->GetTDC();
+       else         ftxt << " " << tofRawDatum->GetTDC();
+       ftxt << "  " << tofRawDatum->GetTDCchannel();
+      }
+
+      tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
+                                   tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
+      dummy = detectorIndex[3];
+      detectorIndex[3] = detectorIndex[4];
+      detectorIndex[4] = dummy;
+
+      if (fVerbose==2) {
+       if (detectorIndex[0]<10) ftxt  << "  ->  " << detectorIndex[0];
+       else              ftxt  << "  -> " << detectorIndex[0];
+       ftxt << "  " << detectorIndex[1];
+       if (detectorIndex[2]<10) ftxt << "  " << detectorIndex[2];
+       else              ftxt << " " << detectorIndex[2];
+       ftxt << "  " << detectorIndex[3];
+       if (detectorIndex[4]<10) ftxt << "  " << detectorIndex[4];
+       else              ftxt << " " << detectorIndex[4];
+      }
 
       for (ii=0; ii<3; ii++) position[ii] =  0.;
-
       fTOFGeometry->GetPos(detectorIndex, position);
-      
-      cylindricalPosition[0] = (Double_t)TMath::Sqrt(position[0]*position[0] + position[1]*position[1]);
-      cylindricalPosition[1] = (Double_t)TMath::ATan2(position[1], position[0]);
-      cylindricalPosition[2] = (Double_t)position[2];
-      cylindricalPosition[3] = (Double_t)tofInput.GetTofBin();
-      cylindricalPosition[4] = (Double_t)tofInput.GetToTbin();
-      tToT = tofInput.GetToTbin();
+
+      cylindricalPosition[0] = TMath::Sqrt(position[0]*position[0] + position[1]*position[1]);
+      cylindricalPosition[1] = TMath::ATan2(position[1], position[0]);
+      cylindricalPosition[2] = position[2];
+      cylindricalPosition[3] = tofRawDatum->GetTOF();
+      cylindricalPosition[4] = tofRawDatum->GetTOT();
+      tToT = tofRawDatum->GetTOT();
       tTdcND = -1.;
-    
       AliTOFcluster *tofCluster = new AliTOFcluster(cylindricalPosition, detectorIndex);
       tofCluster->SetToT(tToT);
       tofCluster->SetTDCND(tTdcND);
       InsertCluster(tofCluster);
 
-    } // while loop
+      if (fVerbose==2) {
+       if (cylindricalPosition[4]<10)                        ftxt << "        " << cylindricalPosition[4];
+       else if (cylindricalPosition[4]>=10 && cylindricalPosition[4]<100) ftxt << "       " << cylindricalPosition[4];
+       else                                     ftxt << "      " << cylindricalPosition[4];
+       if (cylindricalPosition[3]<10)                             ftxt << "      " << cylindricalPosition[3] << endl;
+       else if (cylindricalPosition[3]>=10 && cylindricalPosition[3]<100)   ftxt << "     " << cylindricalPosition[3] << endl;
+       else if (cylindricalPosition[3]>=100 && cylindricalPosition[3]<1000) ftxt << "    " << cylindricalPosition[3] << endl;
+       else                                             ftxt << "   " << cylindricalPosition[3] << endl;
+      }
 
-  } // DDL Loop
+    } // closed loop on TOF raw data per current DDL file
+
+    clonesRawData->Clear();
+
+  } // closed loop on DDL index
+
+  if (fVerbose==2) ftxt.close();
 
   AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters));
 
@@ -434,6 +562,9 @@ void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
   //             (temporary solution)
   //
 
+  //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors();
+  const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors();
+
   fRunLoader->GetEvent(iEvent);
 
   fTreeD = fTOFLoader->TreeD();
@@ -445,46 +576,41 @@ void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
     fTreeD = fTOFLoader->TreeD();
     }
 
-  TClonesArray dummy("AliTOFdigit",10000), *tofDigits=&dummy;
+  TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000);
   Int_t bufsize = 32000;
   fTreeD->Branch("TOF", &tofDigits, bufsize);
 
-
-  const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors();
-
   fRunLoader->GetEvent(iEvent);
 
   AliDebug(2,Form(" Event number %2i ", iEvent));
 
-  Int_t ii = 0;
-  Int_t indexDDL = 0;
+  TClonesArray * clonesRawData;
+
+  Int_t dummy = -1;
 
   Int_t detectorIndex[5];
   Float_t digit[4];
 
+  Int_t indexDDL = 0;
   for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
 
     rawReader->Reset();
     AliTOFRawStream tofInput(rawReader);
-    rawReader->Select("TOF", indexDDL, indexDDL);
+    tofInput.LoadRawData(indexDDL);
 
-    while(tofInput.Next()) {
+    clonesRawData = (TClonesArray*)tofInput.GetRawData();
 
-      for (ii=0; ii<5; ii++) detectorIndex[ii] = -1;
+    for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
 
-      detectorIndex[0] = tofInput.GetSector();
-      detectorIndex[1] = tofInput.GetPlate();
-      detectorIndex[2] = tofInput.GetStrip();
-      detectorIndex[3] = tofInput.GetPadX();
-      detectorIndex[4] = tofInput.GetPadZ();
-      
-      //AliInfo(Form("  %2i  %1i  %2i  %1i  %2i ",detectorIndex[0],detectorIndex[1],detectorIndex[2],detectorIndex[3],detectorIndex[4]));
+      AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
 
-      if (detectorIndex[0]==-1 ||
-         detectorIndex[1]==-1 ||
-         detectorIndex[2]==-1 ||
-         detectorIndex[3]==-1 ||
-         detectorIndex[4]==-1) continue;
+      if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
+
+      tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
+                                   tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
+      dummy = detectorIndex[3];
+      detectorIndex[3] = detectorIndex[4];
+      detectorIndex[4] = dummy;
 
       digit[0] = (Float_t)tofInput.GetTofBin();
       digit[1] = (Float_t)tofInput.GetToTbin();
@@ -499,6 +625,8 @@ void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
 
     } // while loop
 
+    clonesRawData->Clear();
+
   } // DDL Loop
 
   fTreeD->Fill();
index 63610b911c27779d5b3bce51d0fe52257508b876..4f7b2d81a1791d9c8f119c3ecc6a3361acbca4bb 100644 (file)
@@ -42,6 +42,7 @@ class AliTOFClusterFinder : public TObject
   void LoadClusters();
   void UnLoad();
   void UnLoadClusters();
+  void SetVerbose(Int_t Verbose){fVerbose=Verbose;} // To set the verbose level
 
  protected:
   AliRunLoader *fRunLoader;      // Pointer to Run Loader
@@ -66,6 +67,7 @@ class AliTOFClusterFinder : public TObject
   Int_t FindClusterIndex(Double_t z) const; // Returns cluster index 
   void  CalibrateRecPoint(); // Apply calibration pars to Clusters
 
+  Int_t fVerbose;  //Verbose level (0:no msg, 1:msg, 2:digits in txt files)
 
   ClassDef(AliTOFClusterFinder,1) // To run TOF clustering
 };
index d96c94dbefd203d14169a0c36d071d286415828f..cff6cd5b208c27aa43bc041fad456a587ab863a5 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.12  2006/08/22 13:29:42  arcelli
+removal of effective c++ warnings (C.Zampolli)
+
 Revision 1.11  2006/08/10 14:46:54  decaro
 TOF raw data format: updated version
 
@@ -71,6 +74,7 @@ ClassImp(AliTOFDDLRawData)
 AliTOFDDLRawData::AliTOFDDLRawData():
   fVerbose(0),
   fIndex(-1),
+  fPackedAcquisition(kTRUE),
   fTOFgeometry(0),
   fTOFdigitMap(new AliTOFDigitMap()),
   fTOFdigitArray(0x0),
@@ -83,6 +87,7 @@ AliTOFDDLRawData::AliTOFDDLRawData():
 AliTOFDDLRawData::AliTOFDDLRawData(AliTOFGeometry *tofGeom):
   fVerbose(0),
   fIndex(-1),
+  fPackedAcquisition(kTRUE),
   fTOFgeometry(tofGeom),
   fTOFdigitMap(new AliTOFDigitMap()),
   fTOFdigitArray(0x0),
@@ -97,6 +102,7 @@ AliTOFDDLRawData::AliTOFDDLRawData(const AliTOFDDLRawData &source) :
   TObject(source),
   fVerbose(0),
   fIndex(-1),
+  fPackedAcquisition(kTRUE),
   fTOFgeometry(0),
   fTOFdigitMap(new AliTOFDigitMap()),
   fTOFdigitArray(0x0),
@@ -105,6 +111,7 @@ AliTOFDDLRawData::AliTOFDDLRawData(const AliTOFDDLRawData &source) :
   //Copy Constructor
   this->fIndex=source.fIndex;
   this->fVerbose=source.fVerbose;
+  this->fPackedAcquisition=source.fPackedAcquisition;
   this->fTOFgeometry=source.fTOFgeometry;
   this->fTOFdigitMap=source.fTOFdigitMap;
   this->fTOFdigitArray=source.fTOFdigitArray;
@@ -117,6 +124,7 @@ AliTOFDDLRawData& AliTOFDDLRawData::operator=(const AliTOFDDLRawData &source) {
   //Assigment operator
   this->fIndex=source.fIndex;
   this->fVerbose=source.fVerbose;
+  this->fPackedAcquisition=source.fPackedAcquisition;
   this->fTOFgeometry=source.fTOFgeometry;
   this->fTOFdigitMap=source.fTOFdigitMap;
   this->fTOFdigitArray=source.fTOFdigitArray;
@@ -667,7 +675,11 @@ void AliTOFDDLRawData::MakeTRMheader(Int_t nTRM, UInt_t *buf)
   AliBitPacking::PackWord(word,baseWord, 0, 3);
   word = 0; // event words
   AliBitPacking::PackWord(word,baseWord, 4,16);
-  word = 0; // ACQuisition mode: [0;3] see document
+
+  if (fPackedAcquisition)
+    word = 0; // ACQuisition mode: [0;3] see document
+  else
+    word = 3; // ACQuisition mode: [0;3] see document
   AliBitPacking::PackWord(word,baseWord,17,18);
   word = 0; // description of a SEU inside LUT tables for INL compensation;
             // the data are unaffected
@@ -835,6 +847,9 @@ void AliTOFDDLRawData::MakeTDCdigits(Int_t nDDL, Int_t nTRM, Int_t iChain,
   // TRM TDC digit
   //
 
+  const Double_t kOneMoreFilledCell = 1./(fTOFgeometry->NPadXSector()*fTOFgeometry->NSectors());
+  Double_t percentFilledCells = Double_t(fTOFdigitMap->GetFilledCellNumber())/(fTOFgeometry->NPadXSector()*fTOFgeometry->NSectors());
+
   if (nDDL<0 || nDDL>71) {
     AliWarning(Form(" DDL number is out of the right range [0;71] (nDDL = %3i", nDDL));
     return;
@@ -850,6 +865,10 @@ void AliTOFDDLRawData::MakeTDCdigits(Int_t nDDL, Int_t nTRM, Int_t iChain,
     return;
   }
   
+  Int_t psArray[1000];
+  UInt_t localBuffer[1000];
+  Int_t localIndex = -1;
+
   Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
 
   Int_t volume[5] = {-1, -1, -1, -1, -1};
@@ -858,6 +877,9 @@ void AliTOFDDLRawData::MakeTDCdigits(Int_t nDDL, Int_t nTRM, Int_t iChain,
   Int_t totCharge = -1;
   Int_t timeOfFlight = -1;
 
+  Int_t trailingSpurious = -1;
+  Int_t leadingSpurious = -1;
+
   AliTOFdigit *digs;
 
   UInt_t baseWord=0;
@@ -887,14 +909,80 @@ void AliTOFDDLRawData::MakeTDCdigits(Int_t nDDL, Int_t nTRM, Int_t iChain,
        
       if (volume[0]==-1 || volume[1]==-1 || volume[2]==-1 ||
          volume[3]==-1 || volume[4]==-1) continue;
-      //AliInfo(Form(" sector = %2i plate = %1i strip = %2i
-      //padX = %2i padZ = %1i", volume[0], volume[1], volume[2],
-      //volume[3], volume[4]));
 
       for (jj=0; jj<3; jj++) indexDigit[jj] = -1;
 
       fTOFdigitMap->GetDigitIndex(volume, indexDigit);
 
+      if (indexDigit[0]<0) {
+
+       trailingSpurious = Int_t(8192*gRandom->Rndm()) + Int_t(Int_t(256*gRandom->Rndm())*AliTOFGeometry::ToTBinWidth()/AliTOFGeometry::TdcBinWidth());
+       leadingSpurious = Int_t(8192*gRandom->Rndm());
+
+       if ( ( fPackedAcquisition && percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells)) ||
+            (!fPackedAcquisition && percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells)) ) {
+
+         percentFilledCells+=kOneMoreFilledCell;
+
+         Int_t dummyPS = 0;
+
+         if (HeadOrTail()) {
+           word = trailingSpurious; // trailing edge measurement
+           dummyPS = 2;
+         }
+         else {
+           word = leadingSpurious; // leading edge measurement
+           dummyPS = 1;
+         }
+
+         if (fVerbose==2) {
+           if (nDDL<10) ftxt << "  " << nDDL;
+           else         ftxt << " " << nDDL;
+           if (nTRM<10) ftxt << "  " << nTRM;
+           else         ftxt << " " << nTRM;
+           ftxt << "  " << iChain;
+           if (nTDC<10) ftxt << "  " << nTDC;
+           else         ftxt << " " << nTDC;
+           ftxt << "  " << iCH;
+           if (volume[0]<10) ftxt  << "  ->  " << volume[0];
+           else              ftxt  << "  -> " << volume[0];
+           ftxt << "  " << volume[1];
+           if (volume[2]<10) ftxt << "  " << volume[2];
+           else              ftxt << " " << volume[2];
+           ftxt << "  " << volume[4];
+           if (volume[3]<10) ftxt << "  " << volume[3];
+           else              ftxt << " " << volume[3];
+           ftxt << "       " << -1;
+           if (word<10)                     ftxt << "      " << word;// << endl;
+           else if (word>=10 && word<100)   ftxt << "     " << word;// << endl;
+           else if (word>=100 && word<1000) ftxt << "    " << word;// << endl;
+           else                             ftxt << "   " << word;// << endl;
+           ftxt << "       " << dummyPS << endl;
+         }
+
+         AliBitPacking::PackWord(word,baseWord, 0,20);
+         word = iCH; // TDC channel ID [0;7]
+         AliBitPacking::PackWord(word,baseWord,21,23);
+         word = nTDC; // TDC ID [0;14]
+         AliBitPacking::PackWord(word,baseWord,24,27);
+         word = 0; // error flag
+         AliBitPacking::PackWord(word,baseWord,28,28);
+         word = dummyPS; // Packing Status [0;3]
+         AliBitPacking::PackWord(word,baseWord,29,30);
+         word = 1; // TRM TDC digit ID
+         AliBitPacking::PackWord(word,baseWord,31,31);
+
+         localIndex++;
+         localBuffer[localIndex]=baseWord;
+         psArray[localIndex]=dummyPS;
+
+         nWordsPerTRM++;
+         baseWord=0;
+
+       } // if (fPackedAcquisition && percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells))  or ...
+
+      } // if (indexDigit[0]<0)
+
       for (jj=0; jj<3;jj++) {
 
        if (indexDigit[jj]<0) continue;
@@ -912,6 +1000,8 @@ void AliTOFDDLRawData::MakeTDCdigits(Int_t nDDL, Int_t nTRM, Int_t iChain,
        if (totCharge<0) totCharge = TMath::Abs(totCharge);
        if (totCharge>=256) totCharge = 255;
 
+       if (fPackedAcquisition) {
+
        if (fVerbose==2) {
          if (nDDL<10) ftxt << "  " << nDDL;
          else         ftxt << " " << nDDL;
@@ -950,22 +1040,323 @@ void AliTOFDDLRawData::MakeTDCdigits(Int_t nDDL, Int_t nTRM, Int_t iChain,
        AliBitPacking::PackWord(word,baseWord,24,27);
        word = 0; // error flag
        AliBitPacking::PackWord(word,baseWord,28,28);
-       word = 0; // Packing Status [0;5]
+       word = 0; // Packing Status [0;3]
+       AliBitPacking::PackWord(word,baseWord,29,30);
+       word = 1; // TRM TDC digit ID
+       AliBitPacking::PackWord(word,baseWord,31,31);
+
+       localIndex++;
+       localBuffer[localIndex]=baseWord;
+
+       nWordsPerTRM++;
+       baseWord=0;
+
+       if (percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells)) {
+
+         percentFilledCells+=kOneMoreFilledCell;
+
+         trailingSpurious = Int_t(8192*gRandom->Rndm()) + Int_t(Int_t(256*gRandom->Rndm())*AliTOFGeometry::ToTBinWidth()/AliTOFGeometry::TdcBinWidth());
+         leadingSpurious = Int_t(8192*gRandom->Rndm());
+
+         Int_t dummyPS = 0;
+
+         if (HeadOrTail()) {
+           word = trailingSpurious; // trailing edge measurement
+           dummyPS = 2;
+         }
+         else {
+           word = leadingSpurious; // leading edge measurement
+           dummyPS = 1;
+         }
+
+         if (fVerbose==2) {
+           if (nDDL<10) ftxt << "  " << nDDL;
+           else         ftxt << " " << nDDL;
+           if (nTRM<10) ftxt << "  " << nTRM;
+           else         ftxt << " " << nTRM;
+           ftxt << "  " << iChain;
+           if (nTDC<10) ftxt << "  " << nTDC;
+           else         ftxt << " " << nTDC;
+           ftxt << "  " << iCH;
+           if (volume[0]<10) ftxt  << "  ->  " << volume[0];
+           else              ftxt  << "  -> " << volume[0];
+           ftxt << "  " << volume[1];
+           if (volume[2]<10) ftxt << "  " << volume[2];
+           else              ftxt << " " << volume[2];
+           ftxt << "  " << volume[4];
+           if (volume[3]<10) ftxt << "  " << volume[3];
+           else              ftxt << " " << volume[3];
+           ftxt << "       " << -1;
+           if (word<10)                     ftxt << "      " << word;
+           else if (word>=10 && word<100)   ftxt << "     " << word;
+           else if (word>=100 && word<1000) ftxt << "    " << word;
+           else                             ftxt << "   " << word;
+           ftxt << "       " << dummyPS << endl;
+         }
+
+         AliBitPacking::PackWord(word,baseWord, 0,20);
+         word = iCH; // TDC channel ID [0;7]
+         AliBitPacking::PackWord(word,baseWord,21,23);
+         word = nTDC; // TDC ID [0;14]
+         AliBitPacking::PackWord(word,baseWord,24,27);
+         word = 0; // error flag
+         AliBitPacking::PackWord(word,baseWord,28,28);
+         word = dummyPS; // Packing Status [0;3]
+         AliBitPacking::PackWord(word,baseWord,29,30);
+         word = 1; // TRM TDC digit ID
+         AliBitPacking::PackWord(word,baseWord,31,31);
+
+         localIndex++;
+         localBuffer[localIndex]=baseWord;
+         psArray[localIndex]=dummyPS;
+
+         nWordsPerTRM++;
+         baseWord=0;
+
+       } // if (percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells))
+
+
+       } // if (fPackedAcquisition)
+       else { // if (!fPackedAcquisition)
+
+       if (percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) && HeadOrTail()) {
+
+         percentFilledCells+=kOneMoreFilledCell;
+
+         trailingSpurious = Int_t(8192*gRandom->Rndm()) + Int_t(Int_t(256*gRandom->Rndm())*AliTOFGeometry::ToTBinWidth()/AliTOFGeometry::TdcBinWidth());
+         word = trailingSpurious;
+         Int_t dummyPS = 2;
+
+         if (fVerbose==2) {
+           if (nDDL<10) ftxt << "  " << nDDL;
+           else         ftxt << " " << nDDL;
+           if (nTRM<10) ftxt << "  " << nTRM;
+           else         ftxt << " " << nTRM;
+           ftxt << "  " << iChain;
+           if (nTDC<10) ftxt << "  " << nTDC;
+           else         ftxt << " " << nTDC;
+           ftxt << "  " << iCH;
+           if (volume[0]<10) ftxt  << "  ->  " << volume[0];
+           else              ftxt  << "  -> " << volume[0];
+           ftxt << "  " << volume[1];
+           if (volume[2]<10) ftxt << "  " << volume[2];
+           else              ftxt << " " << volume[2];
+           ftxt << "  " << volume[4];
+           if (volume[3]<10) ftxt << "  " << volume[3];
+           else              ftxt << " " << volume[3];
+           ftxt << "       " << -1;
+           if (word<10)                     ftxt << "      " << word;
+           else if (word>=10 && word<100)   ftxt << "     " << word;
+           else if (word>=100 && word<1000) ftxt << "    " << word;
+           else                             ftxt << "   " << word;
+           ftxt << "       " << dummyPS << endl;
+         }
+
+         AliBitPacking::PackWord(word,baseWord, 0,20);
+         word = iCH; // TDC channel ID [0;7]
+         AliBitPacking::PackWord(word,baseWord,21,23);
+         word = nTDC; // TDC ID [0;14]
+         AliBitPacking::PackWord(word,baseWord,24,27);
+         word = 0; // error flag
+         AliBitPacking::PackWord(word,baseWord,28,28);
+         word = dummyPS; // Packing Status [0;3]
+         AliBitPacking::PackWord(word,baseWord,29,30);
+         word = 1; // TRM TDC digit ID
+         AliBitPacking::PackWord(word,baseWord,31,31);
+
+         localIndex++;
+         localBuffer[localIndex]=baseWord;
+         psArray[localIndex]=dummyPS;
+
+         nWordsPerTRM++;
+         baseWord=0;
+
+       } // if (percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells))
+
+
+       word = timeOfFlight + Int_t(totCharge*AliTOFGeometry::ToTBinWidth()/AliTOFGeometry::TdcBinWidth()); // trailing edge measurement
+
+       if (fVerbose==2) {
+         if (nDDL<10) ftxt << "  " << nDDL;
+         else         ftxt << " " << nDDL;
+         if (nTRM<10) ftxt << "  " << nTRM;
+         else         ftxt << " " << nTRM;
+         ftxt << "  " << iChain;
+         if (nTDC<10) ftxt << "  " << nTDC;
+         else         ftxt << " " << nTDC;
+         ftxt << "  " << iCH;
+         if (volume[0]<10) ftxt  << "  ->  " << volume[0];
+         else              ftxt  << "  -> " << volume[0];
+         ftxt << "  " << volume[1];
+         if (volume[2]<10) ftxt << "  " << volume[2];
+         else              ftxt << " " << volume[2];
+         ftxt << "  " << volume[4];
+         if (volume[3]<10) ftxt << "  " << volume[3];
+         else              ftxt << " " << volume[3];
+         ftxt << "       " << -1;
+         if (word<10)                     ftxt << "      " << word;
+         else if (word>=10 && word<100)   ftxt << "     " << word;
+         else if (word>=100 && word<1000) ftxt << "    " << word;
+         else                             ftxt << "   " << word;
+         ftxt << "       " << 2 << endl;
+       }
+
+       AliBitPacking::PackWord(word,baseWord, 0,20);
+
+       word = iCH; // TDC channel ID [0;7]
+       AliBitPacking::PackWord(word,baseWord,21,23);
+       word = nTDC; // TDC ID [0;14]
+       AliBitPacking::PackWord(word,baseWord,24,27);
+       word = 0; // error flag
+       AliBitPacking::PackWord(word,baseWord,28,28);
+       word = 2; // Packing Status [0;3]
        AliBitPacking::PackWord(word,baseWord,29,30);
        word = 1; // TRM TDC digit ID
        AliBitPacking::PackWord(word,baseWord,31,31);
-       fIndex++;
-       buf[fIndex]=baseWord;
+
+       localIndex++;
+       localBuffer[localIndex]=baseWord;
+       psArray[localIndex]=2;
 
        nWordsPerTRM++;
        baseWord=0;
 
+
+
+       word = timeOfFlight; // leading edge measurement
+
+       if (fVerbose==2) {
+         if (nDDL<10) ftxt << "  " << nDDL;
+         else         ftxt << " " << nDDL;
+         if (nTRM<10) ftxt << "  " << nTRM;
+         else         ftxt << " " << nTRM;
+         ftxt << "  " << iChain;
+         if (nTDC<10) ftxt << "  " << nTDC;
+         else         ftxt << " " << nTDC;
+         ftxt << "  " << iCH;
+         if (volume[0]<10) ftxt  << "  ->  " << volume[0];
+         else              ftxt  << "  -> " << volume[0];
+         ftxt << "  " << volume[1];
+         if (volume[2]<10) ftxt << "  " << volume[2];
+         else              ftxt << " " << volume[2];
+         ftxt << "  " << volume[4];
+         if (volume[3]<10) ftxt << "  " << volume[3];
+         else              ftxt << " " << volume[3];
+         ftxt << "       " << -1;
+         if (word<10)                   ftxt << "      " << word;
+         else if (word>=10 && word<100) ftxt << "     " << word;
+         else                           ftxt << "    " << word;
+         ftxt << "       " << 1 << endl;
+       }
+
+       AliBitPacking::PackWord(word,baseWord, 0,20);
+
+       word = iCH; // TDC channel ID [0;7]
+       AliBitPacking::PackWord(word,baseWord,21,23);
+       word = nTDC; // TDC ID [0;14]
+       AliBitPacking::PackWord(word,baseWord,24,27);
+       word = 0; // error flag
+       AliBitPacking::PackWord(word,baseWord,28,28);
+       word = 1; // Packing Status [0;3]
+       AliBitPacking::PackWord(word,baseWord,29,30);
+       word = 1; // TRM TDC digit ID
+       AliBitPacking::PackWord(word,baseWord,31,31);
+
+       localIndex++;
+       localBuffer[localIndex]=baseWord;
+       psArray[localIndex]=1;
+
+       nWordsPerTRM++;
+       baseWord=0;
+
+
+       if (percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) && !HeadOrTail()) {
+
+         percentFilledCells+=kOneMoreFilledCell;
+
+         leadingSpurious = Int_t(8192*gRandom->Rndm());
+         word = leadingSpurious;
+         Int_t dummyPS = 1;
+
+         if (fVerbose==2) {
+           if (nDDL<10) ftxt << "  " << nDDL;
+           else         ftxt << " " << nDDL;
+           if (nTRM<10) ftxt << "  " << nTRM;
+           else         ftxt << " " << nTRM;
+           ftxt << "  " << iChain;
+           if (nTDC<10) ftxt << "  " << nTDC;
+           else         ftxt << " " << nTDC;
+           ftxt << "  " << iCH;
+           if (volume[0]<10) ftxt  << "  ->  " << volume[0];
+           else              ftxt  << "  -> " << volume[0];
+           ftxt << "  " << volume[1];
+           if (volume[2]<10) ftxt << "  " << volume[2];
+           else              ftxt << " " << volume[2];
+           ftxt << "  " << volume[4];
+           if (volume[3]<10) ftxt << "  " << volume[3];
+           else              ftxt << " " << volume[3];
+           ftxt << "       " << -1;
+           if (word<10)                     ftxt << "      " << word;// << endl;
+           else if (word>=10 && word<100)   ftxt << "     " << word;// << endl;
+           else if (word>=100 && word<1000) ftxt << "    " << word;// << endl;
+           else                             ftxt << "   " << word;// << endl;
+           ftxt << "       " << dummyPS << endl;
+         }
+
+         AliBitPacking::PackWord(word,baseWord, 0,20);
+         word = iCH; // TDC channel ID [0;7]
+         AliBitPacking::PackWord(word,baseWord,21,23);
+         word = nTDC; // TDC ID [0;14]
+         AliBitPacking::PackWord(word,baseWord,24,27);
+         word = 0; // error flag
+         AliBitPacking::PackWord(word,baseWord,28,28);
+         word = dummyPS; // Packing Status [0;3]
+         AliBitPacking::PackWord(word,baseWord,29,30);
+         word = 1; // TRM TDC digit ID
+         AliBitPacking::PackWord(word,baseWord,31,31);
+
+         localIndex++;
+         localBuffer[localIndex]=baseWord;
+         psArray[localIndex]=dummyPS;
+
+         nWordsPerTRM++;
+         baseWord=0;
+
+       } // if (percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells))
+
+
+       } // if (!fPackedAcquisition)
+
       } //end loop on digits in the same volume
 
     } // end loop on TDC channel number
 
   } // end loop on TDC number
 
+  if (fPackedAcquisition) {
+
+    for (Int_t jj=0; jj<=localIndex; jj++) {
+      fIndex++;
+      buf[fIndex] = localBuffer[jj];
+    }
+
+  }
+  else {
+
+    for (Int_t jj=0; jj<=localIndex; jj++) {
+      if (psArray[jj]==2) {
+       fIndex++;
+       buf[fIndex] = localBuffer[jj];
+      }
+    }
+    for (Int_t jj=0; jj<=localIndex; jj++) {
+      if (psArray[jj]==1) {
+       fIndex++;
+       buf[fIndex] = localBuffer[jj];
+      }
+    }
+
+  }
 
   if (fVerbose==2) ftxt.close();
 
@@ -989,3 +1380,17 @@ void AliTOFDDLRawData::ReverseArray(UInt_t a[], Int_t n) const
   return;
 
 }
+
+//----------------------------------------------------------------------------
+Bool_t AliTOFDDLRawData::HeadOrTail() const
+{
+  //
+  // Returns the result of a 'pitch and toss'
+  //
+
+  Double_t dummy = gRandom->Rndm();
+
+  if (dummy<0.5) return kFALSE;
+  else return kTRUE;
+
+}
index 3eeb84254c59e13c2d209b7fb4a02f3e207232df..e14683b288696623d6a8b9d89775732e2fe037b6 100644 (file)
@@ -33,6 +33,8 @@ class AliTOFDDLRawData:public TObject {
 
   Int_t RawDataTOF(TBranch* branch); 
 
+  void SetAcquisitionMode(Bool_t mode) {fPackedAcquisition=mode;};
+
  private:
 
   void  GetDigits();
@@ -53,8 +55,11 @@ class AliTOFDDLRawData:public TObject {
 
   UInt_t  MakeFiller();
 
+  Bool_t HeadOrTail() const;
+
   Int_t fVerbose;                 //Verbose level (0:no msg, 1:msg, 2:digits in txt files)
   Int_t fIndex;                   //number of 32-bit words to be stored into the output file
+  Bool_t fPackedAcquisition;      //flag for packed/no packed acquisition
 
   AliTOFGeometry *fTOFgeometry;   //Pointer to the TOF geometry
 
index 2638847d41224f8dc20b0b4be93c882024bdd413..8936022bfbb5989cd0c9653448953858a616560c 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.4  2007/02/19 15:41:55  decaro
+Coding convention: few corrections
+
 Revision 1.3  2007/01/24 11:19:58  arcelli
 Modify ProcessData to return a logical (CZ)
 
@@ -770,7 +773,7 @@ void AliTOFDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)const
 }
 
 //---------------------------------------------------------------
-void AliTOFDataDCS::Draw(const Option_t* /*option*/) const
+void AliTOFDataDCS::Draw(const Option_t* /*option*/) /*const*/
 {
 // Draw all histos and graphs
 
index c77bc3da7126b4843fd3a7bb9a97966a90accddd..c3ba219af0adb58f1d3cf7b4c490a26c97968004 100644 (file)
@@ -66,7 +66,7 @@ public:
   void SetInterceptP(Float_t interceptP) {fP[1]=interceptP;}
   void SetMaxP(Float_t maxP) {fP[2]=maxP;}
   
-  void Draw(const Option_t* option) const;
+  void Draw(const Option_t* option) /*const*/;
   
   AliTOFFormatDCS* GetHVvp(Int_t pos) const
     {return pos<kNHV ? fHVvp[pos] : 0;}
index 7f8690dc74172ed886d7eb6c6e56d9d17f3e5b2a..56c47786e9c11b9d9ec4104f132967878c42aef8 100644 (file)
@@ -13,6 +13,9 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+/*
+$Log$
+*/
 
 ////////////////////////////////////////////////////////////////////////
 //
@@ -220,3 +223,33 @@ AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/)
 // Dummy assignment operator
     return *this;
 }
+////////////////////////////////////////////////////////////////////////
+Int_t AliTOFDigitMap::GetFilledCellNumber() const
+{
+  //
+  // Returns the number of filled cells of the TOF digit map
+  //
+
+  Int_t volume[5] = {-1, -1, -1, -1, -1};
+  Int_t counter = 0;
+
+  for (Int_t iSector=0; iSector<fNSector; iSector++)
+    for (Int_t iPlate=0; iPlate<fNplate; iPlate++)
+      for (Int_t iStrip=0; iStrip<fNstrip; iStrip++)
+       for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
+         for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
+           {
+
+             volume[0] = iSector;
+             volume[1] = iPlate;
+             volume[2] = iStrip;
+             volume[3] = iPadX;
+             volume[4] = iPadZ;
+
+             //if (CheckedIndex(volume)!=-1) counter++;
+             if (GetDigitIndex(volume, 0)>0) counter++;
+           }
+
+  return counter;
+
+}
index 855990c07777003dea06f197ec344e69b5414500..64bfdf4b5e64fab0d3b7750a7acc0d3f6ecbc6d0 100644 (file)
@@ -47,6 +47,8 @@ class AliTOFDigitMap : public TObject
     // Assignment operator
     AliTOFDigitMap& operator = (const AliTOFDigitMap& rhs);
     
+    Int_t GetFilledCellNumber() const;
+
  private:
     // Check index
     Int_t CheckedIndex(Int_t *vol) const;
index 852af052e2a11f5c2ee78f00c1958c3cf8a05410..2c15d098e3920c8095d1ef974019442fa704c191 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.5  2006/04/20 22:30:50  hristov
+Coding conventions (Annalisa)
+
 Revision 1.4  2006/04/16 22:29:05  hristov
 Coding conventions (Annalisa)
 
@@ -840,6 +843,99 @@ void AliTOFGeometryV4::GetVolumePath(Int_t *ind, Char_t *path ) {
 
 }
 
+//_____________________________________________________________________________
+void AliTOFGeometryV4::GetVolumePath(Int_t sector, Char_t *path ) {
+  //--------------------------------------------------------------------
+  // This function returns the colume path of a given sector 
+  //--------------------------------------------------------------------
+  Char_t string[100];
+  
+  Int_t icopy=-1;
+  
+  if(sector<3){
+    icopy=sector+1;
+    sprintf(string,"/ALIC_1/B077_1/B075_%i/BTO3_1",icopy);
+  }
+  else if(sector<11){
+    // icopy=sector-2;
+    icopy=sector+3;
+    sprintf(string,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
+  }
+  else if(sector==11 || sector==12){
+    icopy=sector-10;
+    sprintf(string,"/ALIC_1/B077_1/B074_%i/BTO2_1",icopy);
+  }
+  else {
+    // icopy=sector-4;
+    icopy=sector-12;
+    sprintf(string,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
+  }
+  
+  sprintf(path,"%s",string); 
+
+}
+//_____________________________________________________________________________
+void AliTOFGeometryV4::GetVolumePath(Int_t sector, Int_t plate, Int_t strip, Char_t *path ) {
+  //--------------------------------------------------------------------
+  // This function returns the colume path of a given strip 
+  //--------------------------------------------------------------------
+  Char_t string1[100];
+  Char_t string2[100];
+  Char_t string3[100];
+  Int_t nstrB = NStripB();
+  Int_t nstrC = NStripC();
+  
+  Int_t icopy=-1;
+  
+  if(sector<3){
+    icopy=sector+1;
+    sprintf(string1,"/ALIC_1/B077_1/B075_%i/BTO3_1",icopy);
+  }
+  else if(sector<11){
+    // icopy=sector-2;
+    icopy=sector+3;
+    sprintf(string1,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
+  }
+  else if(sector==11 || sector==12){
+    icopy=sector-10;
+    sprintf(string1,"/ALIC_1/B077_1/B074_%i/BTO2_1",icopy);
+  }
+  else {
+    // icopy=sector-4;
+    icopy=sector-12;
+    sprintf(string1,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
+  }
+  
+  if( plate ==0){
+    sprintf(string2,"FTOC_1/FLTC_0");
+    icopy = nstrC - strip;
+    sprintf(string3,"FSTR_%i",icopy);
+  }    
+  else if( plate ==1){
+    sprintf(string2,"FTOB_1/FLTB_0");
+    icopy = nstrB - strip;
+      sprintf(string3,"FSTR_%i",icopy);
+  }
+  else if( plate ==2){
+    sprintf(string2,"FTOA_0/FLTA_0");
+    icopy = strip+1;
+    sprintf(string3,"FSTR_%i",icopy);
+  }
+  else if( plate ==3){
+    sprintf(string2,"FTOB_2/FLTB_0");
+    icopy = strip+1;
+    sprintf(string3,"FSTR_%i",icopy);
+  }
+  else if( plate ==4){
+    sprintf(string2,"FTOC_2/FLTC_0");
+    icopy = strip+1;
+    sprintf(string3,"FSTR_%i",icopy);
+  }
+
+  sprintf(path,"%s/%s/%s/FSEN_0",string1,string2,string3); 
+
+}
+
 //_____________________________________________________________________________
 void AliTOFGeometryV4::GetPos(Int_t *det, Float_t *pos) 
 {
index a082f1a456648621b2e4966ff10e4a042a2d3a63..6ce9802fdaa5840107f718172046860864214665 100644 (file)
@@ -25,6 +25,8 @@ class AliTOFGeometryV4: public AliTOFGeometry {
   Bool_t  IsInsideThePadPar(Int_t *det, Float_t *pos) const ; 
   Float_t DistanceToPadPar(Int_t *det, Float_t *pos, Float_t *dist3d=0) const ;
   void    GetVolumePath(Int_t *ind, Char_t *path );
+  void    GetVolumePath(Int_t sector, Char_t *path );
+  void    GetVolumePath(Int_t sector, Int_t plate, Int_t strip, Char_t *path );
   Int_t   GetPlate(Float_t *pos) const ;
   Int_t   GetStrip(Float_t *pos) const ;
   Int_t   GetSector(Float_t *pos) const ;
index 90457bf4ab141eea8e2425363003ef4bc2ac6fe2..94ed79fe75ea1438f65b9131a196438fa22f92e6 100644 (file)
-void AliTOFRawDataRead(Int_t iEvent=0)
+// gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/RAW -I$ALICE_ROOT/TOF")
+// .L AliTOFRawDataRead.C++
+// AliTOFRawDataRead()
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+// Root include files
+#include "TClonesArray.h"
+
+// AliRoot include files
+#include "AliDAQ.h"
+#include "AliHitMap.h"
+
+#include "AliRawReader.h"
+#include "AliRawReaderFile.h"
+
+#include "AliTOFrawData.h"
+#include "AliTOFRawMap.h"
+#include "AliTOFRawStream.h"
+
+#endif
+
+void AliTOFRawDataRead(Int_t iEvent=0);
+
+void AliTOFRawDataRead(Int_t iEvent)
 {
   //
   // To read TOF raw data
   //
 
-  Int_t ii = 0;
+  TClonesArray *fTOFrawData = new TClonesArray("AliTOFrawData",1000);
+  Int_t fPackedDigits=0;
+
   Int_t indexDDL = 0;
   Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
+  Int_t dummy = -1;
 
   AliRawReaderFile reader(iEvent);
   reader.RewindEvents();
 
+  ofstream ftxt;
+  ftxt.open("TOFrawDataReading.txt",ios::app);
+
   while (reader.NextEvent()) {
 
-    for (indexDDL = 0; indexDDL < AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
+    AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData);
+
+    Int_t slot[4] = {-1, -1, -1, -1};
+
+   for (indexDDL = 0; indexDDL < AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
+
+     rawMap->Clear();
+     fTOFrawData->Clear();
+     fPackedDigits = 0;
+
+     printf(" \n \n \n DRM number %2i \n \n \n ", indexDDL);
+
+     reader.Reset();
+     AliTOFRawStream stream(&reader);
 
-      reader.Reset();
-      AliTOFRawStream stream(&reader);
-      reader.Select("TOF", indexDDL, indexDDL);
+     reader.Select("TOF", indexDDL, indexDDL);
+     Bool_t signal = kFALSE;
 
-      //FILE *fpw = fopen("TOFrawDataRead.txt","w");
+     while(stream.Next()) {
 
-      while(stream.Next()) {
+       signal = (stream.GetSector()!=-1 &&
+                stream.GetPlate()!=-1 &&
+                stream.GetStrip()!=-1 &&
+                stream.GetPadZ()!=-1 &&
+                stream.GetPadX()!=-1);
 
-       for (ii=0; ii<5; ii++) detectorIndex[ii] = -1;
+       if (signal) {
+        printf("  %2i  %1i  %2i  %1i  %2i  \n", stream.GetSector(), stream.GetPlate(), stream.GetStrip(), stream.GetPadZ(), stream.GetPadX());
 
-       detectorIndex[0] = (Int_t)stream.GetSector();
-       detectorIndex[1] = (Int_t)stream.GetPlate();
-       detectorIndex[2] = (Int_t)stream.GetStrip();
-       detectorIndex[3] = (Int_t)stream.GetPadZ();
-       detectorIndex[4] = (Int_t)stream.GetPadX();
+        slot[0] = stream.GetTRM();
+        slot[1] = stream.GetTRMchain();
+        slot[2] = stream.GetTDC();
+        slot[3] = stream.GetTDCchannel();
 
-       if (detectorIndex[0]==-1 ||
-           detectorIndex[1]==-1 ||
-           detectorIndex[2]==-1 ||
-           detectorIndex[3]==-1 ||
-           detectorIndex[4]==-1) continue;
-       else {
+        if (rawMap->TestHit(slot) != kEmpty) {
 
-         printf("%2i  %2i  %2i  %2i  %2i      %2i  %1i  %2i  %1i  %2i    %7i  %8i\n",
-                stream.GetDDL(),stream.GetTRM(),stream.GetTRMchain(),
-                stream.GetTDC(),stream.GetTDCchannel(),
-                stream.GetSector(),stream.GetPlate(),
-                stream.GetStrip(),stream.GetPadZ(),stream.GetPadX(),
-                stream.GetToTbin(),stream.GetTofBin());
+          AliTOFrawData *rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
+          rawDigit->Update(stream.GetTofBin(), stream.GetToTbin(), stream.GetLeadingEdge(), stream.GetTrailingEdge(), stream.GetPSbit(), stream.GetACQ(), stream.GetErrorFlag());
 
-       } // end else
+        }
+        else {
 
-      } // end while loop on next stream
+          TClonesArray &arrayTofRawData =  *fTOFrawData;
+          new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(stream.GetTRM(), stream.GetTRMchain(), stream.GetTDC(), stream.GetTDCchannel(),
+                                                               stream.GetTofBin(), stream.GetToTbin(), stream.GetLeadingEdge(), stream.GetTrailingEdge(),
+                                                               stream.GetPSbit(), stream.GetACQ(), stream.GetErrorFlag());
 
-    } // endl loop on DDL files
+          rawMap->SetHit(slot);
 
-    iEvent++;
+          printf("  %6i \n", rawMap->GetHitIndex(slot));
+
+        }
+
+       } // end if (signal)
+
+     } // closed loop on TOF raw data per current DDL file
+
+     printf("\n \n \n end of reading DRM number %2i\n", indexDDL);
+     printf("                                     packed data %5i\n \n \n ", fTOFrawData->GetEntriesFast());
+
+     for (Int_t iRawData = 0; iRawData<fTOFrawData->GetEntriesFast(); iRawData++) {
+
+       AliTOFrawData *tofRawDatum = (AliTOFrawData*)fTOFrawData->UncheckedAt(iRawData);
+
+       if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
+
+       if (indexDDL<10) ftxt << "  " << indexDDL;
+       else             ftxt << " " << indexDDL;
+       if (tofRawDatum->GetTRM()<10) ftxt << "  " << tofRawDatum->GetTRM();
+       else                          ftxt << " " << tofRawDatum->GetTRM();
+       ftxt << "  " << tofRawDatum->GetTRMchain();
+       if (tofRawDatum->GetTDC()<10) ftxt << "  " << tofRawDatum->GetTDC();
+       else                          ftxt << " " << tofRawDatum->GetTDC();
+       ftxt << "  " << tofRawDatum->GetTDCchannel();
+
+       stream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
+                                  tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
+       dummy = detectorIndex[3];
+       detectorIndex[3] = detectorIndex[4];
+       detectorIndex[4] = dummy;
+
+       if (detectorIndex[0]<10) ftxt  << "  ->  " << detectorIndex[0];
+       else                     ftxt  << "  -> " << detectorIndex[0];
+       ftxt << "  " << detectorIndex[1];
+       if (detectorIndex[2]<10) ftxt << "  " << detectorIndex[2];
+       else                     ftxt << " " << detectorIndex[2];
+       ftxt << "  " << detectorIndex[3];
+       if (detectorIndex[4]<10) ftxt << "  " << detectorIndex[4];
+       else                     ftxt << " " << detectorIndex[4];
+
+       if (tofRawDatum->GetTOT()<10)                                    ftxt << "        " << tofRawDatum->GetTOT();
+       else if (tofRawDatum->GetTOT()>=10 && tofRawDatum->GetTOT()<100) ftxt << "       " << tofRawDatum->GetTOT();
+       else                                                             ftxt << "      " << tofRawDatum->GetTOT();
+       if (tofRawDatum->GetTOF()<10)                                      ftxt << "      " << tofRawDatum->GetTOF() << endl;
+       else if (tofRawDatum->GetTOF()>=10 && tofRawDatum->GetTOF()<100)   ftxt << "     " << tofRawDatum->GetTOF() << endl;
+       else if (tofRawDatum->GetTOF()>=100 && tofRawDatum->GetTOF()<1000) ftxt << "    " << tofRawDatum->GetTOF() << endl;
+       else                                                               ftxt << "   " << tofRawDatum->GetTOF() << endl;
+
+     } // end loop
+
+   } // endl loop on DDL files
+
+   iEvent++;
 
   } // end while loop on event
 
+  ftxt.close();
+
 }
diff --git a/TOF/AliTOFRawMap.cxx b/TOF/AliTOFRawMap.cxx
new file mode 100644 (file)
index 0000000..d5fee23
--- /dev/null
@@ -0,0 +1,200 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+/////////////////////////////////////////////////////////////////////////
+//                                                                     //
+// AliTOFRawMap class                                                  //
+//                                                                     //
+// It enables fast check if the TDC channel was already engaged        //
+// for a measurement.                                                  //
+// The index of a AliTOFrawData is saved in the each rawdatamap "cell" //
+// (there is an offset +1, because the index can be zero and           //
+// zero means empty cell.                                              //
+//                                                                     //
+/////////////////////////////////////////////////////////////////////////
+
+#include "TClonesArray.h"
+
+#include "AliLog.h"
+
+#include "AliTOFGeometry.h"
+#include "AliTOFRawMap.h"
+
+ClassImp(AliTOFRawMap)
+
+AliTOFRawMap::AliTOFRawMap():
+  fNtrm(-1),
+  fNtrmChain(-1),
+  fNtdc(-1),
+  fNtdcChannel(-1),
+  fRawData(0x0),
+  fMaxIndex(-1),
+  fRawMap(0x0)
+{
+//
+// Default ctor
+//
+}
+
+////////////////////////////////////////////////////////////////////////
+AliTOFRawMap::AliTOFRawMap(TClonesArray *dig)://, AliTOFGeometry *tofGeom):
+  fNtrm(-1),
+  fNtrmChain(-1),
+  fNtdc(-1),
+  fNtdcChannel(-1),
+  fRawData(dig),
+  fMaxIndex(-1),
+  fRawMap(0x0)
+{
+//
+// ctor
+//
+
+// of course, these constants must not be hardwired
+// change later
+
+  fNtrm = AliTOFGeometry::NTRM()+2;
+  fNtrmChain = AliTOFGeometry::NChain();
+  fNtdc = AliTOFGeometry::NTdc();
+  fNtdcChannel = AliTOFGeometry::NCh();
+  fMaxIndex = fNtrm*fNtrmChain*fNtdc*fNtdcChannel;
+  fRawMap = new Int_t[fMaxIndex];
+  Clear();
+}
+
+////////////////////////////////////////////////////////////////////////
+AliTOFRawMap::AliTOFRawMap(const AliTOFRawMap & /*rawMap*/)
+  :TObject(),
+  fNtrm(-1),
+  fNtrmChain(-1),
+  fNtdc(-1),
+  fNtdcChannel(-1),
+  fRawData(0x0),
+  fMaxIndex(-1),
+  fRawMap(0x0)
+{
+//
+// Dummy copy constructor
+//
+
+}
+
+////////////////////////////////////////////////////////////////////////
+AliTOFRawMap::~AliTOFRawMap()
+{
+//
+// Destructor
+//
+  delete[] fRawMap;
+
+}
+
+////////////////////////////////////////////////////////////////////////
+void AliTOFRawMap::Clear(const char *)
+{
+//
+// Clear hitmap
+//
+    memset(fRawMap,0,sizeof(int)*fMaxIndex);
+}
+
+////////////////////////////////////////////////////////////////////////
+Int_t AliTOFRawMap::CheckedIndex(Int_t *slot) const
+{
+//
+// Return checked indices for vol
+//
+  Int_t index =
+    slot[0]*fNtrmChain*fNtdc*fNtdcChannel + // TRM
+    slot[1]*fNtdc*fNtdcChannel +            // TRM chain
+    slot[2]*fNtdcChannel +                  // TDC
+    slot[3];                                // TDC channel
+
+    if (index >= fMaxIndex) {
+      AliError("CheckedIndex - input outside bounds");
+       return -1;
+    } else {
+       return index;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////
+void  AliTOFRawMap::SetHit(Int_t *slot, Int_t idigit)
+{
+//
+// Assign digit to pad vol
+//
+
+// 0 means empty pad, we need to shift indeces by 1
+    fRawMap[CheckedIndex(slot)]=idigit+1;
+}
+
+////////////////////////////////////////////////////////////////////////
+void  AliTOFRawMap::SetHit(Int_t *slot)
+{
+//
+// Assign last digit to channel slot
+//
+
+// 0 means empty pad, we need to shift indeces by 1
+    fRawMap[CheckedIndex(slot)]=fRawData->GetLast()+1;
+}
+
+////////////////////////////////////////////////////////////////////////
+Int_t AliTOFRawMap::GetHitIndex(Int_t *slot) const
+{
+//
+// Get contents of channel slot
+//
+
+// 0 means empty pad, we need to shift indeces by 1
+    return fRawMap[CheckedIndex(slot)]-1;
+}
+
+////////////////////////////////////////////////////////////////////////
+TObject* AliTOFRawMap::GetHit(Int_t *slot) const
+{
+//
+// Get pointer to object at alot
+// return 0 if vol out of bounds
+    Int_t index = GetHitIndex(slot);
+    return (index <0) ? 0 : fRawData->UncheckedAt(index);
+}
+
+////////////////////////////////////////////////////////////////////////
+FlagType AliTOFRawMap::TestHit(Int_t *slot) const
+{
+//
+// Check if hit cell is empty, used or unused
+//
+    Int_t inf = fRawMap[CheckedIndex(slot)];
+    if (inf > 0) {
+       return kUsed;
+    } else if (inf == 0) {
+       return kEmpty;
+    } else {
+       return kUnused;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////
+AliTOFRawMap & AliTOFRawMap::operator = (const AliTOFRawMap & /*rhs*/) 
+{
+// Dummy assignment operator
+    return *this;
+}
diff --git a/TOF/AliTOFRawMap.h b/TOF/AliTOFRawMap.h
new file mode 100644 (file)
index 0000000..96eff08
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef ALITOFRAWMAP_H
+#define ALITOFRAWMAP_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+////////////////////////////////////////////////
+//                                            //
+//   AliTOFRawMap class                       //
+//                                            //
+//   It enables fast check                    //
+//   if the TDC channel was already engaged   //
+//   for a measurement                        //
+//                                            //
+////////////////////////////////////////////////
+
+#include "TObject.h"
+
+#include "AliHitMap.h"
+
+class TClonesArray;
+
+class AliTOFRawMap : public TObject
+{
+ public:
+    AliTOFRawMap();
+    AliTOFRawMap(TClonesArray *sdig);
+    AliTOFRawMap(const AliTOFRawMap & rawMap);
+    
+    virtual ~AliTOFRawMap();
+    // Clear the raw map
+    virtual  void  Clear(const char *opt = "");
+    // Set a single raw
+    virtual  void  SetHit(Int_t *slot, Int_t idigit);
+    virtual  void  SetHit(Int_t *slot);
+    // Get index of hit in the list of digits
+    virtual Int_t  GetHitIndex(Int_t *vol) const;
+    // Get pointer to digit
+    virtual TObject*  GetHit(Int_t *vol) const;
+    // Test hit status
+    virtual FlagType TestHit(Int_t *vol) const;
+    // Assignment operator
+    AliTOFRawMap& operator = (const AliTOFRawMap& rhs);
+    
+ private:
+    // Check index
+    Int_t CheckedIndex(Int_t *slot) const;
+ private:
+    Int_t fNtrm;            // Number of TRM
+    Int_t fNtrmChain;       // Number of TRM chains per TRM
+    Int_t fNtdc;            // Number of TDCs per TRM
+    Int_t fNtdcChannel;     // Number of TDC channels per TDC
+
+    TClonesArray *fRawData; // Pointer to raw data
+    Int_t fMaxIndex;        // maximum index in hit map
+    Int_t *fRawMap;         // ! [fMaxIndex]         
+
+    ClassDef(AliTOFRawMap,0) // Implements RawMap as a 1-dim array
+};
+#endif 
index 506a40bf3c73a84ff5c8b94f4b996e3c4017b777..e5922f3d4f490740bef3c7909a0d94535352bc51 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.10  2006/12/15 14:01:38  cvetan
+Memory leak fixed
+
 Revision 1.9  2006/10/13 11:22:27  arcelli
 remove warnings due to uninitialized AliTOFtdcDigit data members
 
@@ -58,11 +61,17 @@ Revision 0.01  2005/07/22 A. De Caro
 //                                                                    //
 ////////////////////////////////////////////////////////////////////////
 
+
+#include "TClonesArray.h"
+
+#include "AliDAQ.h"
 #include "AliLog.h"
 #include "AliRawReader.h"
 
 #include "AliTOFGeometry.h"
 #include "AliTOFGeometryV5.h"
+#include "AliTOFrawData.h"
+#include "AliTOFRawMap.h"
 #include "AliTOFRawStream.h"
 
 
@@ -251,6 +260,13 @@ TRM DATA FORMAT
 #define TRM_PS_BITS_MASK 0x60000000
 #define TRM_PS_BITS_POSITION 29
 
+#define TRM_FIRST_SLOT_ID 3
+
+//define hptdc time bin width
+#define TIME_BIN_WIDTH 24.4e-3 //ns
+
+//define hptdc tot bin width
+#define TOT_BIN_WIDTH 48.4e-3 //ns
 
 //TRM errors
 
@@ -365,184 +381,134 @@ ClassImp(AliTOFRawStream)
 
 //_____________________________________________________________________________
 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
-  fRawReader(0x0),
+  fRawReader(rawReader),
+  fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
   fDDL(-1),
   fTRM(-1),
-  fTDC(-1),
   fTRMchain(-1),
+  fTDC(-1),
   fTDCchannel(-1),
-  fTof(-1),
+  fTime(-1),
   fToT(-1),
+  fLeadingEdge(-1),
+  fTrailingEdge(-1),
   fErrorFlag(-1),
-
   fSector(-1),
   fPlate(-1),
   fStrip(-1),
   fPadX(-1),
   fPadZ(-1),
   fTOFGeometry(new AliTOFGeometryV5()),
+  fPackedDigits(0),
   fWordType(-1),
   fSlotID(-1),
   fACQ(-1),
   fPSbit(-1),
-  fTime(-1),
   fTDCerrorFlag(-1),
   fInsideDRM(kFALSE),
   fInsideTRM(kFALSE),
   fInsideLTM(kFALSE),
   fInsideTRMchain0(kFALSE),
-  fInsideTRMchain1(kFALSE),
-  fLeadingOrphane(kFALSE)
+  fInsideTRMchain1(kFALSE)
 {
   //
   // create an object to read TOF raw digits
   //
 
-  fRawReader = rawReader;
-  /*
-  fDDL = -1;
-  fTRM = -1;
-  fTDC = -1;
-  fTRMchain = -1;
-  fTDCchannel = -1;
-  fTof = -1;
-  fToT = -1;
-  fErrorFlag = -1;
-
-  fSector = -1;
-  fPlate = -1;
-  fStrip = -1;
-  fPadX = -1;
-  fPadZ = -1;
-  fTOFGeometry = new AliTOFGeometryV5();
-  */
+  fRawReader->Reset();
   fRawReader->Select("TOF");
-  /*
-  fWordType = -1;
-  fSlotID = -1;
-  fACQ = -1;
-  fPSbit = -1;
-  fTime = -1;
-  fTDCerrorFlag = -1;
-  fInsideDRM = kFALSE;
-  fInsideTRM = kFALSE;
-  fInsideLTM = kFALSE;
-  fInsideTRMchain0 = kFALSE;
-  fInsideTRMchain1 = kFALSE;
-  fLeadingOrphane = kFALSE;
-  */
+
 }
 
 //_____________________________________________________________________________
 AliTOFRawStream::AliTOFRawStream():
   fRawReader(0x0),
+  fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
   fDDL(-1),
   fTRM(-1),
-  fTDC(-1),
   fTRMchain(-1),
+  fTDC(-1),
   fTDCchannel(-1),
-  fTof(-1),
+  fTime(-1),
   fToT(-1),
+  fLeadingEdge(-1),
+  fTrailingEdge(-1),
   fErrorFlag(-1),
-
   fSector(-1),
   fPlate(-1),
   fStrip(-1),
   fPadX(-1),
   fPadZ(-1),
   fTOFGeometry(new AliTOFGeometryV5()),
+  fPackedDigits(0),
   fWordType(-1),
   fSlotID(-1),
   fACQ(-1),
   fPSbit(-1),
-  fTime(-1),
   fTDCerrorFlag(-1),
   fInsideDRM(kFALSE),
   fInsideTRM(kFALSE),
   fInsideLTM(kFALSE),
   fInsideTRMchain0(kFALSE),
-  fInsideTRMchain1(kFALSE),
-  fLeadingOrphane(kFALSE)
+  fInsideTRMchain1(kFALSE)
 {
   //
   // default ctr
   //
-  /*
-  fRawReader = 0x0;
-  fDDL = -1;
-  fTRM = -1;
-  fTDC = -1;
-  fTRMchain = -1;
-  fTDCchannel = -1;
-  fTof = -1;
-  fToT = -1;
-  fErrorFlag = -1;
-
-  fSector = -1;
-  fPlate = -1;
-  fStrip = -1;
-  fPadX = -1;
-  fPadZ = -1;
-  fTOFGeometry = new AliTOFGeometryV5();
-  fWordType = -1;
-  fSlotID = -1;
-  fACQ = -1;
-  fPSbit = -1;
-  fTime = -1;
-  fTDCerrorFlag = -1;
-  fInsideDRM = kFALSE;
-  fInsideTRM = kFALSE;
-  fInsideLTM = kFALSE;
-  fInsideTRMchain0 = kFALSE;
-  fInsideTRMchain1 = kFALSE;
-  fLeadingOrphane = kFALSE;
-  */
+
 }
 
 //_____________________________________________________________________________
 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
   TObject(stream),
   fRawReader(0x0),
+  fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
   fDDL(-1),
   fTRM(-1),
-  fTDC(-1),
   fTRMchain(-1),
+  fTDC(-1),
   fTDCchannel(-1),
-  fTof(-1),
+  fTime(-1),
   fToT(-1),
+  fLeadingEdge(-1),
+  fTrailingEdge(-1),
   fErrorFlag(-1),
-
   fSector(-1),
   fPlate(-1),
   fStrip(-1),
   fPadX(-1),
   fPadZ(-1),
   fTOFGeometry(new AliTOFGeometryV5()),
+  fPackedDigits(0),
   fWordType(-1),
   fSlotID(-1),
   fACQ(-1),
   fPSbit(-1),
-  fTime(-1),
   fTDCerrorFlag(-1),
   fInsideDRM(kFALSE),
   fInsideTRM(kFALSE),
   fInsideLTM(kFALSE),
   fInsideTRMchain0(kFALSE),
-  fInsideTRMchain1(kFALSE),
-  fLeadingOrphane(kFALSE)
+  fInsideTRMchain1(kFALSE)
 {
   //
   // copy constructor
   //
 
   fRawReader = stream.fRawReader;
+
+  fTOFrawData = stream.fTOFrawData;
+
   fDDL = stream.fDDL;
   fTRM = stream.fTRM;
-  fTDC = stream.fTDC;
   fTRMchain = stream.fTRMchain;
+  fTDC = stream.fTDC;
   fTDCchannel = stream.fTDCchannel;
-  fTof = stream.fTof;
+  fTime = stream.fTime;
   fToT = stream.fToT;
+  fLeadingEdge = stream.fLeadingEdge;
+  fTrailingEdge = stream.fTrailingEdge;
+
   fErrorFlag = stream.fErrorFlag;
 
   fSector = stream.fSector;
@@ -553,18 +519,18 @@ AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
 
   fTOFGeometry = stream.fTOFGeometry;
 
+  fPackedDigits = stream.fPackedDigits;
+
   fWordType = stream.fWordType;
   fSlotID = stream.fSlotID;
   fACQ = stream.fACQ;
   fPSbit = stream.fPSbit;
-  fTime = stream.fTime;
   fTDCerrorFlag = stream.fTDCerrorFlag;
   fInsideDRM = stream.fInsideDRM;
   fInsideTRM = stream.fInsideTRM;
   fInsideLTM = stream.fInsideLTM;
   fInsideTRMchain0 = stream.fInsideTRMchain0;
   fInsideTRMchain1 = stream.fInsideTRMchain1;
-  fLeadingOrphane = stream.fLeadingOrphane;
 
 }
 
@@ -576,13 +542,18 @@ AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
   //
 
   fRawReader = stream.fRawReader;
+
+  fTOFrawData = stream.fTOFrawData;
+
   fDDL = stream.fDDL;
   fTRM = stream.fTRM;
-  fTDC = stream.fTDC;
   fTRMchain = stream.fTRMchain;
+  fTDC = stream.fTDC;
   fTDCchannel = stream.fTDCchannel;
-  fTof = stream.fTof;
+  fTime = stream.fTime;
   fToT = stream.fToT;
+  fLeadingEdge = stream.fLeadingEdge;
+  fTrailingEdge = stream.fTrailingEdge;
   fErrorFlag = stream.fErrorFlag;
 
   fSector = stream.fSector;
@@ -593,18 +564,18 @@ AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
 
   fTOFGeometry = stream.fTOFGeometry;
 
+  fPackedDigits = stream.fPackedDigits;
+
   fWordType = stream.fWordType;
   fSlotID = stream.fSlotID;
   fACQ = stream.fACQ;
   fPSbit = stream.fPSbit;
-  fTime = stream.fTime;
   fTDCerrorFlag = stream.fTDCerrorFlag;
   fInsideDRM = stream.fInsideDRM;
   fInsideTRM = stream.fInsideTRM;
   fInsideLTM = stream.fInsideLTM;
   fInsideTRMchain0 = stream.fInsideTRMchain0;
   fInsideTRMchain1 = stream.fInsideTRMchain1;
-  fLeadingOrphane = stream.fLeadingOrphane;
 
   return *this;
 
@@ -615,11 +586,120 @@ AliTOFRawStream::~AliTOFRawStream()
 {
 // destructor
 
+  fPackedDigits = 0;
+
   delete fTOFGeometry;
 
+  delete fTOFrawData;
+
 }
 
 
+//_____________________________________________________________________________
+
+void AliTOFRawStream::LoadRawData(Int_t indexDDL)
+{
+
+  /*
+    for (Int_t indexDDL = 0;
+    indexDDL < AliDAQ::NumberOfDdls("TOF");
+    indexDDL++) {
+  */
+
+  fTOFrawData->Clear();
+  fPackedDigits = 0;
+
+  // create raw data map
+  AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData);
+  rawMap->Clear();
+
+  Int_t slot[4] = {-1, -1, -1, -1};
+
+  fRawReader->Reset();
+  fRawReader->Select("TOF", indexDDL, indexDDL);
+    
+  Bool_t signal = kFALSE;
+
+  while(Next()) {
+
+    signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
+    if (signal) {
+      //printf("  %2i  %1i  %2i  %1i  %2i  \n", fSector, fPlate, fStrip, fPadZ, fPadX);
+
+      slot[0] = fTRM;
+      slot[1] = fTRMchain;
+      slot[2] = fTDC;
+      slot[3] = fTDCchannel;
+
+      if (rawMap->TestHit(slot) != kEmpty) {
+
+       AliTOFrawData *rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
+
+       if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
+           fLeadingEdge==-1 && fTrailingEdge!=-1) {
+
+         rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
+       }
+       else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
+                  (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
+
+/*     else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
+                  (fTime!=-1 || fLeadingEdge!=-1 || fTrailingEdge!=-1))*/  /*||
+                 (rawDigit->GetLeading()==-1 && rawDigit->GetTrailing()!=-1 &&
+                 fLeadingEdge!=-1 && fTrailingEdge==-1) */)
+         {
+
+         TClonesArray &arrayTofRawData =  *fTOFrawData;
+         new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
+
+       rawMap->SetHit(slot);
+
+       }
+
+
+      }
+      else {
+
+       TClonesArray &arrayTofRawData =  *fTOFrawData;
+       new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
+
+       rawMap->SetHit(slot);
+
+      } // else if (rawMap->TestHit(slot) == kEmpty)
+
+    } // if (signal)
+
+  } // closed -> while (Next())
+
+    /*
+      fDDL  = fRawReader->GetDDLID();
+
+      for (Int_t ii=0; ii<fTOFrawData->GetEntriesFast(); ii++) {
+
+      AliTOFrawData *dummy = (AliTOFrawData*)fTOFrawData->UncheckedAt(ii);
+
+      fTRM = dummy->GetTRM();
+      fTRMchain = dummy->GetTRMchain();
+      fTDC = dummy->GetTDC();
+      fTDCchannel = dummy->GetTDCchannel();
+
+      SetSector();
+      SetPlate();
+      SetStrip();
+      SetPadZ();
+      SetPadX();
+
+      printf("  %2i, %2i %1i, %2i, %1i  -->  %2i, %1i, %2i, %1i, %2i  \n",
+            fDDL, fTRM, fTRMchain, fTDC, fTDCchannel,
+            fSector, fPlate, fStrip, fPadZ, fPadX);
+
+            } // closed loop on TOF raw data TClonesArray
+    */
+
+    //} // closed loop on indexDDL
+
+}
+
 //_____________________________________________________________________________
 Bool_t AliTOFRawStream::Next()
 {
@@ -634,18 +714,18 @@ Bool_t AliTOFRawStream::Next()
 
   if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
     fSector = -1;
-    fPlate = -1;
-    fStrip = -1;
-    fPadZ = -1;
-    fPadX = -1;
+    fPlate  = -1;
+    fStrip  = -1;
+    fPadZ   = -1;
+    fPadX   = -1;
+    fTime   = -1;
+    fToT    = -1;
+    fLeadingEdge  = -1;
+    fTrailingEdge = -1;
   }
 
-
   fDDL  = fRawReader->GetDDLID();
 
-  // orphane digits
-  AliTOFtdcDigit orphaneLeadingDigit={0,0,0,0,0,0,0};
-
   fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
 
   switch (fWordType) { // switch word type
@@ -711,23 +791,23 @@ Bool_t AliTOFRawStream::Next()
       fInsideLTM = kFALSE;
       fInsideTRMchain0 = kFALSE;
       fInsideTRMchain1 = kFALSE;
-      fLeadingOrphane = kFALSE;
       fSector = -1;
-      fPlate = -1;
-      fStrip = -1;
-      fPadZ = -1;
-      fPadX = -1;
-      fDDL = -1;
-      fTRM = -1;
-      fTDC = -1;
-      fTRMchain = -1;
+      fPlate  = -1;
+      fStrip  = -1;
+      fPadZ   = -1;
+      fPadX   = -1;
+      fDDL        = -1;
+      fTRM        = -1;
+      fTDC        = -1;
+      fTRMchain   = -1;
       fTDCchannel = -1;
-      fTof = -1;
-      fToT = -1;
+      fTime = -1;
+      fToT  = -1;
+      fLeadingEdge  = -1;
+      fTrailingEdge = -1;
       fErrorFlag = -1;
-      fACQ = -1;
+      fACQ   = -1;
       fPSbit = -1;
-      fTime = -1;
       fTDCerrorFlag = -1;
       break;
     case LTM_ID_NUMBER: // LTM global trailer
@@ -751,7 +831,7 @@ Bool_t AliTOFRawStream::Next()
 
 
   case ERROR_TYPE: // TDC error
-    fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
+    fTDC          = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
     fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
     break;
 
@@ -803,84 +883,50 @@ Bool_t AliTOFRawStream::Next()
        && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
        && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
        ){ // inside TRM chains
-      fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
-      fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
+
+      fPSbit      = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
+      fTDC        = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
       fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
+      fErrorFlag  = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
+
+      SetSector();
+      SetPlate();
+      SetStrip();
+      SetPadZ();
+      SetPadX();
+
 
       switch (fPSbit) { // switch fPSbit bits inside TRM chains
-      case 0: // packing ok, digit time and tot
-       fToT = GetField(data,TRM_TOT_WIDTH_MASK,TRM_TOT_WIDTH_POSITION);
+
+      case 0: // packing ok, digit time and TOT
+       fToT  = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
        fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
-       fTof = fTime;
-       SetSector();
-       SetPlate();
-       SetStrip();
-       SetPadZ();
-       SetPadX();
        break;
 
       case 1: // leading edge digit, long digit time, no TOT
-       fToT = -1;
-       fTime = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
-       fTof = fTime;
-       SetSector();
-       SetPlate();
-       SetStrip();
-       SetPadZ();
-       SetPadX();
-       // always set it as orphane leading
-       fLeadingOrphane=1;
-       orphaneLeadingDigit.fSlotID = fSlotID;
-       orphaneLeadingDigit.fChain = fTRMchain;
-       orphaneLeadingDigit.fPS = fPSbit;
-       orphaneLeadingDigit.fTDC = fTDC;
-       orphaneLeadingDigit.fChannel = fTDCchannel;
-       orphaneLeadingDigit.fTOT = fToT;
-       orphaneLeadingDigit.fTime = fTime;
+       //fToT  = -1;
+       //fTime  = -1;
+       fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
        break;
 
       case 2: // trailing edge digit, long digit time, no TOT
-       fToT = -1;
-       fTime = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
-       fTof = fTime;
-       SetSector();
-       SetPlate();
-       SetStrip();
-       SetPadZ();
-       SetPadX();
-       if (fACQ!=3) // check if packing is disabled
-         break;
-       if (!fLeadingOrphane) // check for a orphane leading edge
-         break;
-       if (orphaneLeadingDigit.fSlotID != fSlotID ||
-           orphaneLeadingDigit.fChain != fTRMchain ||
-           orphaneLeadingDigit.fTDC != fTDC ||
-           orphaneLeadingDigit.fChannel != fTDCchannel) // check leading edge compatibility (fSlotID, fTRMchain, fTDC, fTDCchannel)
-         break;
-       fLeadingOrphane = 0; // orphane leading is no longer orphane
-       SetSector();
-       SetPlate();
-       SetStrip();
-       SetPadZ();
-       SetPadX();
+       //fToT  = -1;
+       //fTime  = -1;
+       fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
        break;
+
       case 3: // TOT overflow
-       fToT = GetField(data,TRM_TOT_WIDTH_MASK,TRM_TOT_WIDTH_POSITION);
+       fToT  = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
        fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
-       fTof = fTime;
-       SetSector();
-       SetPlate();
-       SetStrip();
-       SetPadZ();
-       SetPadX();
        break;
-      } // end switch fPSbit bits inside TRM chains
 
+      } // end switch PS bits inside TRM chains
 
     } // end if is inside TRM chains
 
   } // end switch on fWordType
 
+
   return kTRUE;
 
 }
@@ -893,7 +939,7 @@ void AliTOFRawStream::SetSector()
   // corresponding to the TOF equipment IDs:
   //                                  fDDL        -> [ 0;71]
   //                                  fTRM        -> [ 3;12]
-  //                                  fTRMchain   -> [0;  1]
+  //                                  fTRMchain   -> [ 0; 1]
   //                                  fTDC        -> [ 0;14]
   //                                  fTDCchannel -> [ 0; 7]
   //
@@ -915,7 +961,7 @@ void AliTOFRawStream::SetPlate()
   // corresponding to the TOF equipment IDs:
   //                                  fDDL        -> [ 0;71]
   //                                  fTRM        -> [ 3;12]
-  //                                  fTRMchain   -> [0;  1]
+  //                                  fTRMchain   -> [ 0; 1]
   //                                  fTDC        -> [ 0;14]
   //                                  fTDCchannel -> [ 0; 7]
   //
@@ -937,7 +983,7 @@ void AliTOFRawStream::SetStrip()
   // corresponding to the TOF equipment IDs:
   //                                  fDDL        -> [ 0;71]
   //                                  fTRM        -> [ 3;12]
-  //                                  fTRMchain   -> [0;  1]
+  //                                  fTRMchain   -> [ 0; 1]
   //                                  fTDC        -> [ 0;14]
   //                                  fTDCchannel -> [ 0; 7]
   //
@@ -960,7 +1006,7 @@ void AliTOFRawStream::SetPadZ()
   // corresponding to the TOF equipment IDs:
   //                                  fDDL        -> [ 0;71]
   //                                  fTRM        -> [ 3;12]
-  //                                  fTRMchain   -> [0;  1]
+  //                                  fTRMchain   -> [ 0; 1]
   //                                  fTDC        -> [ 0;14]
   //                                  fTDCchannel -> [ 0; 7]
   //
@@ -987,7 +1033,7 @@ void AliTOFRawStream::SetPadX()
   // corresponding to the TOF equipment IDs:
   //                                  fDDL        -> [ 0;71]
   //                                  fTRM        -> [ 3;12]
-  //                                  fTRMchain   -> [0;  1]
+  //                                  fTRMchain   -> [ 0; 1]
   //                                  fTDC        -> [ 0;14]
   //                                  fTDCchannel -> [ 0; 7]
   //
index 45c30be16d2455035d1dfd082df4020faa94f08f..8fb228ace7d35910be2eeb45f0e94040f3aa8f85 100644 (file)
 
 #include "TObject.h"
 
+class TClonesArray;
+
 class AliRawReader;
+class AliTOFGeometry;
+class AliTOFrawData;
 
 class AliTOFRawStream: public TObject {
  public:
@@ -22,8 +26,10 @@ class AliTOFRawStream: public TObject {
   AliTOFRawStream(AliRawReader* rawReader); // ctr
   virtual ~AliTOFRawStream(); // default dtr
 
-  virtual Bool_t   Next();
+  virtual Bool_t Next();
   
+  virtual void   LoadRawData(Int_t indexDDL);
+
   Int_t GetDDL()        const {return fDDL;};
   Int_t GetTRM()        const {return fTRM;};
   Int_t GetTDC()        const {return fTDC;};
@@ -36,15 +42,24 @@ class AliTOFRawStream: public TObject {
   Int_t GetPadZ()   const {return fPadZ;};
   Int_t GetPadX()   const {return fPadX;};
   
-  Int_t GetTofBin() const {return fTof;};
+  Int_t GetTofBin() const {return fTime;};
   Int_t GetToTbin() const {return fToT;};
+  Float_t GetLeadingEdge() const {return fLeadingEdge;};
+  Float_t GetTrailingEdge() const {return fTrailingEdge;};
+
+  Int_t GetPSbit()  const {return fPSbit;};
+  Int_t GetACQ()    const {return fACQ;};
     
+  Int_t GetErrorFlag()  const {return fErrorFlag;};
+
   void SetDDL(Int_t nDDL)            {fDDL = nDDL;};
   void SetTRM(Int_t nTRM)            {fTRM = nTRM;};
   void SetTDC(Int_t nTDC)            {fTDC = nTDC;};
   void SetTRMchain(Int_t nChain)     {fTRMchain = nChain;};
   void SetTDCchannel(Int_t nChannel) {fTDCchannel = nChannel;};
 
+  TClonesArray *GetRawData() const {return fTOFrawData;};
+
   void SetSector();
   void SetPlate();
   void SetStrip();
@@ -68,14 +83,18 @@ class AliTOFRawStream: public TObject {
 
   AliRawReader*  fRawReader; // object for reading the raw data
 
-  Int_t         fDDL;        // DDL file number [0;71]
-  Int_t         fTRM;        // TRM number [1;12]
-  Int_t         fTDC;        // TDC number [0;14]
-  Int_t         fTRMchain;   // TRM chain number [0;1]
-  Int_t         fTDCchannel; // TDC channel number [0;7]
-  Int_t         fTof;        // time-of-flight measurement [0;8191]
-  Int_t         fToT;        // time-over-threshould measurement [0;255]
-  Int_t         fErrorFlag;  // error flag
+  TClonesArray *fTOFrawData; // pointer to AliTOFrawData TClonesArray
+
+  Int_t         fDDL;          // DDL file number [0;71]
+  Int_t         fTRM;          // TRM number [1;12]
+  Int_t         fTRMchain;     // TRM chain number [0;1]
+  Int_t         fTDC;          // TDC number [0;14]
+  Int_t         fTDCchannel;   // TDC channel number [0;7]
+  Int_t         fTime;         // time-of-flight measurement [0;8191]
+  Int_t         fToT;          // time-over-threshould measurement [0;255]
+  Float_t       fLeadingEdge;  // leading edge measurement
+  Float_t       fTrailingEdge; // trailing edge measurement
+  Int_t         fErrorFlag;    // error flag
   
   Int_t         fSector;     // sector number [0;17]
   Int_t         fPlate;      // plate number [0;4]
@@ -85,30 +104,18 @@ class AliTOFRawStream: public TObject {
 
   AliTOFGeometry *fTOFGeometry; // pointer to the TOF geometry
 
+  Int_t fPackedDigits;       // counter for packed digits
+
   Int_t fWordType;           // word type
   Int_t fSlotID;             // crate slot ID number
   Int_t fACQ;                // flag to identify the aquisition kind
   Int_t fPSbit;              // flag for packing 
-  Int_t fTime;               // time-of-light measurement
   Int_t fTDCerrorFlag;       // TDC error flag
   Bool_t fInsideDRM;         // inside/outside DRM
   Bool_t fInsideTRM;         // inside/outside TRM
   Bool_t fInsideLTM;         // inside/outside LTM
   Bool_t fInsideTRMchain0;   // inside/outside chain 0
   Bool_t fInsideTRMchain1;   // inside/outside chain 1
-  Bool_t fLeadingOrphane;    // flag for leading orphane digit
-
-  struct AliTOFtdcDigit {
-    // TOF TDC digit data struct
-    Int_t fSlotID;  // TRM slot ID
-    Int_t fChain;   // Chain ID
-    Int_t fPS;      // Packing bit
-    Int_t fTDC;     // TDC number 
-    Int_t fChannel; // TDC channel number
-    Int_t fTOT;     // Time-Over-Threashould
-    Int_t fTime;    // Time
-  };
-
 
   ClassDef(AliTOFRawStream, 1)  // class for reading TOF raw digits
 };
diff --git a/TOF/AliTOFrawData.cxx b/TOF/AliTOFrawData.cxx
new file mode 100644 (file)
index 0000000..7b78996
--- /dev/null
@@ -0,0 +1,178 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/*
+$Log$
+Revision 0.1  2006/12/15 A.De Caro
+   Introuction
+*/
+
+//////////////////////////////////////////////////////
+//                                                  //
+//  This class provides the TOF raw data object     //
+//                                                  //
+//////////////////////////////////////////////////////
+
+#include "AliLog.h"
+
+#include "AliTOFGeometry.h"
+#include "AliTOFrawData.h"
+
+ClassImp(AliTOFrawData)
+
+//_____________________________________________________________________________
+AliTOFrawData::AliTOFrawData() :
+  TObject(),
+  fACQflag(-1),
+  fPSbit(-1),
+  fTRM(-1),
+  fTRMchain(-1),
+  fTDC(-1),
+  fTDCchannel(-1),
+  fLeading(-1),
+  fTrailing(-1),
+  fToT(-1),
+  fTime(-1),
+  fError(-1)
+{
+
+  // default ctr
+
+}
+
+//_____________________________________________________________________________
+AliTOFrawData::AliTOFrawData(Int_t a, Int_t b, Int_t c, Int_t d, Int_t e,
+                            Int_t f, Int_t g, Int_t h, Int_t l) :
+  TObject(),
+  fACQflag(h),
+  fPSbit(g),
+  fTRM(a),
+  fTRMchain(b),
+  fTDC(c),
+  fTDCchannel(d),
+  fLeading(-1),
+  fTrailing(-1),
+  fToT(f),
+  fTime(e),
+  fError(l)
+{
+
+// ctr
+
+}
+
+//_____________________________________________________________________________
+AliTOFrawData::AliTOFrawData(Int_t a, Int_t b, Int_t c, Int_t d, Int_t e,
+                            Int_t f, Float_t ee, Float_t ff, Int_t g, Int_t h, Int_t l) :
+  TObject(),
+  fACQflag(h),
+  fPSbit(g),
+  fTRM(a),
+  fTRMchain(b),
+  fTDC(c),
+  fTDCchannel(d),
+  fLeading(ee),
+  fTrailing(ff),
+  fToT(f),
+  fTime(e),
+  fError(l)
+{
+
+  // ctr
+
+}
+
+//_____________________________________________________________________________
+AliTOFrawData::AliTOFrawData(const AliTOFrawData& r) :
+  TObject(),
+  fACQflag(-1),
+  fPSbit(-1),
+  fTRM(-1),
+  fTRMchain(-1),
+  fTDC(-1),
+  fTDCchannel(-1),
+  fLeading(-1),
+  fTrailing(-1),
+  fToT(-1),
+  fTime(-1),
+  fError(-1)
+{
+
+  // dummy copy constructor
+
+  fACQflag    = r.fACQflag;
+  fPSbit      = r.fPSbit;
+  fTRM        = r.fTRM;
+  fTRMchain   = r.fTRMchain;
+  fTDC        = r.fTDC;
+  fTDCchannel = r.fTDCchannel;
+  fLeading    = r.fLeading;
+  fTrailing   = r.fTrailing;
+  fToT        = r.fToT;
+  fTime       = r.fTime;
+  fError      = r.fError;
+
+}
+
+//_____________________________________________________________________________
+AliTOFrawData& AliTOFrawData::operator=(const AliTOFrawData& r)
+{
+
+  // dummy assignment operator
+
+  this->fACQflag    = r.fACQflag;
+  this->fPSbit      = r.fPSbit;
+  this->fTRM        = r.fTRM;
+  this->fTRMchain   = r.fTRMchain;
+  this->fTDC        = r.fTDC;
+  this->fTDCchannel = r.fTDCchannel;
+  this->fLeading    = r.fLeading;
+  this->fTrailing   = r.fTrailing;
+  this->fToT        = r.fToT;
+  this->fTime       = r.fTime;
+  this->fError      = r.fError;
+  return *this;
+
+}
+
+//_____________________________________________________________________________
+void AliTOFrawData::Update(Float_t tof, Float_t tot, Float_t leading, Float_t trailing, Int_t psBit, Int_t acq, Int_t errorFlag)
+{
+  //
+  // To update a raw data object:
+  //  if there is just a leading edge measurement,
+  //  this method adds the trailing edge measurement
+  //  to evaluate the time-of-flight and time-over-threshold measurements
+  //
+
+  AliDebug(2,Form(" %10.0f %10.0f %10.0f %1i %1i %1i",tof, tot, leading, psBit, acq, errorFlag));
+
+  if (fLeading!=-1 && fTime==-1 && fToT==-1 && trailing!=-1) {
+
+    fTrailing = trailing;
+    fTime = fLeading;
+    fToT = Int_t((trailing - fLeading)*AliTOFGeometry::TdcBinWidth()/AliTOFGeometry::ToTBinWidth());
+    
+  }
+  /*
+  else if (fLeading!=-1 && fTime==-1 && fToT==-1 && leading==-1 && trailing!=-1) {
+
+    fTime = fLeading;
+    fToT = Int_t((trailing - fLeading)*AliTOFGeometry::TdcBinWidth()/AliTOFGeometry::ToTBinWidth());
+    
+  }
+  */
+
+}
diff --git a/TOF/AliTOFrawData.h b/TOF/AliTOFrawData.h
new file mode 100644 (file)
index 0000000..6c66428
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef ALITOFRAWDATA_H
+#define ALITOFRAWDATA_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+////////////////////////////////////////////////////
+//                                                //
+//   This class provides the TOF raw data object  //
+//                                                //
+////////////////////////////////////////////////////
+
+#include "TObject.h"
+
+class AliTOFrawData : public TObject {
+  // TOF rawData class
+ public:
+  AliTOFrawData(); // default ctr
+  AliTOFrawData(Int_t a, Int_t b, Int_t c, Int_t d, Int_t e, Int_t f, Int_t g, Int_t h, Int_t l); // ctr
+  AliTOFrawData(Int_t a, Int_t b, Int_t c, Int_t d, Int_t e, Int_t f, Float_t ee, Float_t ff, Int_t g, Int_t h, Int_t l); // ctr
+  ~AliTOFrawData() {}; // default dtr
+  AliTOFrawData(const AliTOFrawData& r);     // dummy copy constructor
+  AliTOFrawData& operator=(const AliTOFrawData& r); // dummy assignment operator
+  void Update(Float_t tof, Float_t tot, Float_t leading, Float_t trailing, Int_t psBit, Int_t acq, Int_t errorFlag);
+
+  Int_t GetTRM()        const {return fTRM;};
+  Int_t GetTRMchain()   const {return fTRMchain;};
+  Int_t GetTDC()        const {return fTDC;};
+  Int_t GetTDCchannel() const {return fTDCchannel;};
+  
+  Float_t GetTOF() const {return fTime;};
+  Float_t GetTOT() const {return fToT;};
+  Float_t GetLeading() const {return fLeading;};
+  Float_t GetTrailing() const {return fTrailing;};
+  
+ private:
+  Int_t fACQflag;    // ACQ flag
+  Int_t fPSbit;      // Packing bit
+  
+  Int_t fTRM;        // TRM ID
+  Int_t fTRMchain;   // TRM Chain ID
+  Int_t fTDC;        // TDC number 
+  Int_t fTDCchannel; // TDC channel number
+  
+  Float_t fLeading;  // Leading Edge
+  Float_t fTrailing; // Trailing Edge
+  Float_t fToT;      // Time-Over-Threashould
+  Float_t fTime;     // Time
+  
+  Int_t fError;      // Error flag
+  
+  ClassDef(AliTOFrawData, 0)  // class for TOF raw data
+};
+
+#endif
index 2a06b7f4a82053481624a340d6b053add70b413c..58bcd823ce7b8b0ddc0b824f0a7b21090de79ab5 100644 (file)
@@ -12,6 +12,8 @@
 #pragma link C++ class  AliTOFGeometryV4+;
 #pragma link C++ class  AliTOFGeometryV5+;
 #pragma link C++ class  AliTOFdigit+;
+#pragma link C++ class  AliTOFRawMap+;
+#pragma link C++ class  AliTOFrawData+;
 #pragma link C++ class  AliTOFRawStream+;
 #pragma link C++ class  AliTOFChannel+;
 #pragma link C++ class  AliTOFChannelOnline+;
index c8162b691447f76137c6d2d3f0f38dda961b6f7e..70da0dc996a77de9896795147202f08e31e162d7 100644 (file)
@@ -5,6 +5,8 @@ SRCS  = AliTOFGeometry.cxx  \
        AliTOFGeometryV4.cxx  \
        AliTOFGeometryV5.cxx  \
         AliTOFdigit.cxx  \
+        AliTOFRawMap.cxx\
+        AliTOFrawData.cxx\
         AliTOFRawStream.cxx\
        AliTOFChannel.cxx  \
        AliTOFChannelOnline.cxx  \