Implemented new class to read raw data and published TOF cluster class
authordecaro <decaro@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 2 Aug 2005 08:03:03 +0000 (08:03 +0000)
committerdecaro <decaro@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 2 Aug 2005 08:03:03 +0000 (08:03 +0000)
14 files changed:
TOF/AliTOF.cxx
TOF/AliTOFDDLRawData.cxx
TOF/AliTOFDDLRawData.h
TOF/AliTOFRawDataRead.C [new file with mode: 0644]
TOF/AliTOFRawStream.cxx [new file with mode: 0644]
TOF/AliTOFRawStream.h [new file with mode: 0644]
TOF/AliTOFcluster.cxx [new file with mode: 0644]
TOF/AliTOFcluster.h [new file with mode: 0644]
TOF/AliTOFtracker.cxx
TOF/AliTOFtracker.h
TOF/TOFbaseLinkDef.h
TOF/TOFrecLinkDef.h
TOF/libTOFbase.pkg
TOF/libTOFrec.pkg

index 5df4e46..dd9a846 100644 (file)
@@ -73,6 +73,7 @@
 #include "AliMC.h"
 #include "AliTOFDigitizer.h"
 #include "AliTOFDDLRawData.h"
+#include "AliTOFcluster.h"
  
 ClassImp(AliTOF)
  
@@ -231,6 +232,7 @@ AliTOF::~AliTOF()
       delete fSDigits;
       fSDigits = 0;
     }
+
   if (fReconParticles)
     {
       fReconParticles->Delete ();
@@ -311,6 +313,17 @@ void AliTOF::SetTreeAddress ()
       }
     }
 
+  if (fLoader->TreeR() ) 
+    {
+      branch = fLoader->TreeR()->GetBranch("TOF"); 
+      if (branch) 
+       {
+        if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster",  1000);
+         branch->SetAddress(&fReconParticles);
+       }
+    }
+
+  /*
   if (fLoader->TreeR() && fReconParticles) //I do not know where this array is created - skowron
     {
       branch = fLoader->TreeR()->GetBranch("TOF"); 
@@ -318,7 +331,8 @@ void AliTOF::SetTreeAddress ()
        {
          branch->SetAddress(&fReconParticles) ;
        }
-    }   
+    }
+  */
 }
 
 //_____________________________________________________________________________
@@ -624,9 +638,16 @@ void AliTOF::MakeBranch(Option_t* option)
     MakeBranchInTree(fLoader->TreeS(), branchname, &fSDigits,buffersize, 0) ;
   }
 
+  if (fLoader->TreeR() && oR){
+    if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster",  1000);
+    MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
+  }
+
+  /*
   if (fReconParticles && fLoader->TreeR() && oR){
     MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
   }
+  */
 }
 
 //____________________________________________________________________________
index d84461d..ab20eb0 100644 (file)
  **************************************************************************/
 
 /*
+Revision 0.02  2005/7/25 A.De Caro
+        Update number of bits allocated for time-of-flight
+               and 'charge' measurements
+
 Revision 0.01  2004/6/11 A.De Caro, S.B.Sellitto, R.Silvestri
         First implementation: global methods RawDataTOF
                                              GetDigits
 */
+
+//////////////////////////////////////////////////////////////////
 //
 // This class contains the methods to create the Raw Data files
 // for the TOF detector starting from the Digits.
@@ -25,6 +31,7 @@ Revision 0.01  2004/6/11 A.De Caro, S.B.Sellitto, R.Silvestri
 // of the ALICE-TOF raw data starting from the current format
 // for the TOF digits and the TOF raw data.
 //
+//////////////////////////////////////////////////////////////////
 
 #include <stdlib.h>
 #include <Riostream.h>
@@ -33,11 +40,13 @@ Revision 0.01  2004/6/11 A.De Caro, S.B.Sellitto, R.Silvestri
 #include <TMath.h>
 #include "AliLog.h"
 
+#include "AliRawDataHeader.h"
+#include "AliBitPacking.h"
+
 #include "AliTOFGeometry.h"
 #include "AliTOFdigit.h"
+#include "AliTOFRawStream.h"
 #include "AliTOFDDLRawData.h"
-#include "AliRawDataHeader.h"
-#include "AliBitPacking.h"
 
 ClassImp(AliTOFDDLRawData)
 
@@ -72,12 +81,14 @@ AliTOFDDLRawData& AliTOFDDLRawData::operator=(const AliTOFDDLRawData &source){
 
 void AliTOFDDLRawData::GetDigits(TClonesArray *TOFdigits,Int_t nDDL,UInt_t *buf)
 {
+
   //This method packs the TOF digits in a proper 32 bits structure
-  Int_t iDDL=(Int_t)((nDDL/4.-(Int_t)(nDDL/4.))*4);
-  Int_t iSector=(Int_t)(nDDL/4.);
-  Int_t iTRM=0;
-  Int_t iTDC=0;
-  Int_t iCH=-1;
+
+  Int_t iDDL    = nDDL%AliTOFGeometry::NDDL();//(Int_t)((nDDL/4.-(Int_t)(nDDL/4.))*4);
+  Int_t iSector = (Int_t)((Float_t)nDDL/AliTOFGeometry::NDDL());
+  Int_t iTRM = 0;
+  Int_t iTDC = 0;
+  Int_t iCH  =-1;
   Int_t sector; 
   Int_t plate;
   Int_t strip;
@@ -99,61 +110,49 @@ void AliTOFDDLRawData::GetDigits(TClonesArray *TOFdigits,Int_t nDDL,UInt_t *buf)
     }
 
   if (fVerbose==2) ftxt.open("TOFdigits.txt",ios::app);
+
   for (Int_t digit=0;digit<ndigits;digit++) {
     digs = (AliTOFdigit*)TOFdigits->UncheckedAt(digit);
-    sector=digs->GetSector(); // Sector Number (0-17)
-    plate=digs->GetPlate();   // Plate Number (0-4)
-    strip=digs->GetStrip();   // Strip Number (0-14/18/19)
-    padx=digs->GetPadx();     // Pad Number in x direction (0-47)
-    padz=digs->GetPadz();     // Pad Number in z direction (0-1)
-    eureka=digs->GetTotPad(); // Global Pad Number inside a Sector
+    sector = digs->GetSector(); // Sector Number (0-17)
+    plate  = digs->GetPlate();  // Plate Number (0-4)
+    strip  = digs->GetStrip();  // Strip Number (0-14/18/19)
+    padx   = digs->GetPadx();   // Pad Number in x direction (0-47)
+    padz   = digs->GetPadz();   // Pad Number in z direction (0-1)
+    eureka = digs->GetTotPad(); // Global Pad Number inside a Sector
     totCharge = (Int_t)digs->GetAdc();
     timeOfFlight = (Int_t)digs->GetTdc();
-    /*
-    Int_t istriPlate=0;
-    switch (plate)
-      {
-      case 0:
-       break;
-      case 1:
-       istriPlate = AliTOFGeometry::NStripC();
-       break;
-      case 2:
-       istriPlate = AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB();
-       break;
-      case 3:
-       istriPlate = AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA();
-       break;
-      case 4:
-       istriPlate = AliTOFGeometry::NStripC()+2*AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA();
-       break;
-      }
-
-    eureka=2*padx+padz+AliTOFGeometry::NpadXStrip()*(strip+istriPlate);
-    
-    if (eureka!=digs->GetTotPad()) printf(" eureka = %d AND digs->GetTotPad() = %d",eureka,digs->GetTotPad());
-    */
+
     if (sector!=iSector || (Int_t)((Float_t)eureka/AliTOFGeometry::NPadXTRM()/AliTOFGeometry::NTRM())!=iDDL) continue;
     
-    if (fVerbose==2) ftxt <<" Sector: "<<sector<<" plate: "<<plate<<" strip "<<strip<<" padx "<<padx<<" padz "<<padz<<" eureka "<<eureka<<endl;
+    if (fVerbose==2) ftxt << " Sector: " << sector << " Plate: " << plate << " Strip: " << strip << " PadZ: " << padz << " PadX: " << padx << " totPadNumber " << eureka << endl;
     
-    iTRM = (Int_t)((Float_t)eureka/AliTOFGeometry::NPadXTRM() - AliTOFGeometry::NTRM()*iDDL);
+    iTRM = (Int_t)((Float_t)eureka/AliTOFGeometry::NPadXTRM()) - iDDL*AliTOFGeometry::NTRM();
+
     
+    iTDC = (Int_t)((Float_t)eureka/AliTOFGeometry::NCh()) - (iDDL*AliTOFGeometry::NTRM() + iTRM) * AliTOFGeometry::NTdc();
+    /*
     iTDC = (Int_t)(AliTOFGeometry::NTdc()* 
                   (
                    (Float_t)eureka/AliTOFGeometry::NPadXTRM() -
                    (Int_t)((Float_t)eureka/AliTOFGeometry::NPadXTRM())
                    )
                   );
-    
+    */
+
+    iCH  = eureka - ((iDDL*AliTOFGeometry::NTRM() + iTRM) * AliTOFGeometry::NTdc() + iTDC) * AliTOFGeometry::NCh();
+    /*
     iCH  = (Int_t)(AliTOFGeometry::NCh() * 
                   (
                    (Float_t)eureka/AliTOFGeometry::NPadXTRM()*AliTOFGeometry::NTdc() - (Int_t)((Float_t)eureka/AliTOFGeometry::NPadXTRM()*AliTOFGeometry::NTdc()) -
                    (Int_t)((Float_t)eureka/AliTOFGeometry::NPadXTRM()*AliTOFGeometry::NTdc() - (Int_t)((Float_t)eureka/AliTOFGeometry::NPadXTRM()*AliTOFGeometry::NTdc()))
                    )
                   );
-    
-    if (fVerbose==2) ftxt << "DDL: "<<iDDL<<" Sector: "<<sector<<" TRM: "<<iTRM<<" TDC: "<<iTDC<<" Channel: "<<iCH<<" totCharge: "<<totCharge<<" tof: "<<timeOfFlight<<endl;
+    */
+
+    if (fVerbose==2) ftxt << "DDL: "<<nDDL<<" TRM: "<<iTRM<<" TDC: "<<iTDC<<" Channel: "<<iCH<<" totCharge: "<<totCharge<<" tof: "<<timeOfFlight<<endl;
+
+    //AliInfo(Form("%2i %2i %2i %2i   %2i %2i %2i %2i %2i %7i %8i",nDDL,iTRM,iTDC,iCH,sector,plate,strip,padz,padx,totCharge,timeOfFlight));
+    AliDebug(2,Form("%2i %2i %2i %2i   %2i %2i %2i %2i %2i %7i %8i",nDDL,iTRM,iTDC,iCH,sector,plate,strip,padz,padx,totCharge,timeOfFlight));
     
     baseWord=0;
     
@@ -167,8 +166,10 @@ void AliTOFDDLRawData::GetDigits(TClonesArray *TOFdigits,Int_t nDDL,UInt_t *buf)
     // temporary control
     if (totCharge<0) word=TMath::Abs(totCharge);
     else word=totCharge;
-    AliBitPacking::PackWord(word,baseWord,12,31); // Charge (TOT)
-    
+    AliBitPacking::PackWord(word,baseWord,12,31); // Charge (TOT) // v0.01
+    //AliBitPacking::PackWord(word,baseWord,12,19); // Charge (TOT) // v0.02
+    //AliBitPacking::PackWord(0,baseWord,20,31); // v0.02
+
     fIndex++;
     buf[fIndex]=baseWord;
     
@@ -177,7 +178,10 @@ void AliTOFDDLRawData::GetDigits(TClonesArray *TOFdigits,Int_t nDDL,UInt_t *buf)
     word=error;
     AliBitPacking::PackWord(word,baseWord,0, 7); // Error flag
     word=timeOfFlight;
-    AliBitPacking::PackWord(word,baseWord,8,31); // time-of-flight
+    AliBitPacking::PackWord(word,baseWord,8,31); // time-of-flight // v0.01
+    //AliBitPacking::PackWord(word,baseWord,8,19); // time-of-flight // v0.02
+    //AliBitPacking::PackWord(0,baseWord,20,30); // v0.02
+    //AliBitPacking::PackWord(1,baseWord,31,31); // v0.02
     
     fIndex++;
     buf[fIndex]=baseWord;
@@ -195,12 +199,15 @@ void AliTOFDDLRawData::GetDigits(TClonesArray *TOFdigits,Int_t nDDL,UInt_t *buf)
 //---------------------------------------------------------------------------------------
 
 Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch){
-  //This method creates the Raw data files for TOF detector
-  const Int_t kSize=5000; //2*AliTOFGeometry::NpadXSector() 
-                          //max number of digits per DDL file times 2
+  //
+  // This method creates the Raw data files for TOF detector
+  //
+
+  const Int_t kSize = 5000; //max number of digits per DDL file times 2
+
   UInt_t buf[kSize];
-  UInt_t baseWord;
-  UInt_t word;
+  //UInt_t baseWord; // v0.01
+  //UInt_t word; // v0.01
 
   fIndex=-1;
 
@@ -208,25 +215,33 @@ Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch){
   char fileName[15];
   ofstream outfile;         // logical name of the output file 
   AliRawDataHeader header;
+  UInt_t sizeRawData = 0;
 
   //loop over TOF DDL files
-  for(Int_t i=0;i<72;i++){
-    sprintf(fileName,"TOF_%d.ddl",i+kDDLOffset); //The name of the output file
+  for(Int_t i = 0; i<AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); i++){
+
+    sprintf(fileName,"TOF_%d.ddl",i+AliTOFRawStream::kDDLOffset); //The name of the output file
 #ifndef __DECCXX
     outfile.open(fileName,ios::binary);
 #else
     outfile.open(fileName);
 #endif
+
     //write Dummy DATA HEADER
     UInt_t dataHeaderPosition=outfile.tellp();
     outfile.write((char*)(&header),sizeof(header));
 
+    /*
+    // v0.01
     baseWord=0;
     word=i;
-    AliBitPacking::PackWord(word,baseWord,0, 31); // Number of DDL file
+    //AliBitPacking::PackWord(word,baseWord,0, 31); // Number of DDL file
+    AliBitPacking::PackWord(word,baseWord,0, 6); // Number of DDL file
+    AliBitPacking::PackWord(0,baseWord,7,31);
 
     fIndex++;
     buf[fIndex]=baseWord;
+    */
 
     branch->GetEvent();
 
@@ -240,10 +255,13 @@ Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch){
     
     //Write REAL DATA HEADER
     UInt_t currentFilePosition=outfile.tellp();
-    outfile.seekp(dataHeaderPosition);
+    sizeRawData = currentFilePosition - dataHeaderPosition - sizeof(header);
     header.fSize=currentFilePosition-dataHeaderPosition;
     header.SetAttribute(0);  // valid data
+    outfile.seekp(dataHeaderPosition);
     outfile.write((char*)(&header),sizeof(header));
+    outfile.seekp(currentFilePosition);
+
     outfile.close();
 
   }//end for
@@ -251,60 +269,4 @@ Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch){
   return 0;  
 }
 
-//-----------------------------------------------------------------------------------------
-/*
-void AliTOFDDLRawData::WriteChipHeader(Int_t ChipAddr,Int_t EventCnt,UInt_t &BaseWord)
-{
-  //This method writes a chip header 
-  BaseWord=0;
-  PackWord(BaseWord,ChipAddr,0,3);
-  PackWord(BaseWord,EventCnt,4,10);
-  PackWord(BaseWord,0x7,11,13);
-  PackWord(BaseWord,0x1,14,15);
-  return;
-}//end WriteChipHeader
-*/
-//----------------------------------------------------------------------------------------
-/*
-void AliTOFDDLRawData::ReadChipHeader(Int_t &ChipAddr,Int_t &EventCnt,UInt_t BaseWord)
-{
-  //This method reads a chip header
-  UInt_t temp=0;
-  UnpackWord(BaseWord,0,3,temp);
-  ChipAddr=(Int_t)temp;
-  UnpackWord(BaseWord,4,10,temp);
-  EventCnt=(Int_t)temp;
-  if(fVerbose)
-    Info("ReadChipHeader", "Chip:&d Half Stave module:%d",ChipAddr,EventCnt);
-  return;
-}//end ReadChipHeader
-*/
-//----------------------------------------------------------------------------------------
-/*
-void  AliTOFDDLRawData::WriteChipTrailer(UInt_t *buf,Int_t ChipHitCount,UInt_t &BaseWord)
-{
-  //This method writes a chip trailer
-  //pixel fill word
-  if((ChipHitCount%2)!=0){
-    PackWord(BaseWord,0xFEDC,0,15);
-  }
-  PackWord(BaseWord,ChipHitCount,16,28);
-  PackWord(BaseWord,0x0,30,31);
-  fIndex++;
-  buf[fIndex]=BaseWord;
-  BaseWord=0;
-  return;
-}//end WriteChipTrailer
-*/
-//------------------------------------------------------------------------------------------
-/*
-void  AliTOFDDLRawData::ReadChipTrailer(Int_t &ChipHitCount,UInt_t BaseWord)
-{
-  //This method reads a chip trailer
-  UInt_t temp=0;
-  UnpackWord(BaseWord,16,28,temp);
-  ChipHitCount=(Int_t)temp;
-  return;
-}//end ReadChipTrailer
-*/
-//------------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------
index 5a80346..8921500 100644 (file)
@@ -26,21 +26,10 @@ class AliTOFDDLRawData:public TObject{
   void  GetDigits(TClonesArray *TOFdigits, Int_t ddl,UInt_t *buf);
   //This method formats and stores in buf all the digits of a TOF module
 
-  /*
-  void  WriteChipHeader(Int_t ChipAddr,Int_t EventCnt,UInt_t &BaseWord);
-  void  WriteChipTrailer(UInt_t *buf,Int_t ChipHitCount,UInt_t &BaseWord);
-  //The three previous  methods are used to store the data according to the 
-  //TOF detector data format
-
-  void  ReadChipHeader(Int_t &ChipAddr,Int_t &EventCnt,UInt_t BaseWord);
-  void  ReadChipTrailer(Int_t &ChipHitCount,UInt_t BaseWord);
-  //Methods used for reading and dubugging TOF data files
-  */
-
   Int_t fVerbose;            //Verbose level (0:no msg, 1:msg, 2:digits in txt files)
   Int_t fIndex;              //number of 32 words to be stored into the output file
-  enum {kDDLOffset = 0x500};  //offset for DDL number
   ClassDef(AliTOFDDLRawData,1)
+
 };
     
 #endif
diff --git a/TOF/AliTOFRawDataRead.C b/TOF/AliTOFRawDataRead.C
new file mode 100644 (file)
index 0000000..912f886
--- /dev/null
@@ -0,0 +1,48 @@
+void AliTOFRawDataRead(Int_t iEvent=0)
+{
+  //
+  // To read TOF raw data
+  //
+
+  Int_t indexDDL = 0;
+
+  AliRawReaderFile reader(ievt);
+
+  for (indexDDL = 0; indexDDL < 72; indexDDL++) {
+
+    reader.Reset();
+    AliTOFRawStream stream(&reader);
+    reader.Select(5, indexDDL, indexDDL);
+
+    //FILE *fpw = fopen("TOFrawDataRead.txt","w");
+
+    while(stream.Next()) {
+
+      if (stream.GetSector()==0) {
+
+       printf("%2i %2i %2i %2i         %2i %1i %2i %1i %2i    %7i %8i\n",
+              stream.GetDDL(),stream.GetTRM(),
+              stream.GetTDC(),stream.GetChannel(),
+              stream.GetSector(),stream.GetPlate(),
+              stream.GetStrip(),stream.GetPadZ(),stream.GetPadX(),
+              stream.GetADCbin(),stream.GetTofBin());
+       /*
+         Int_t iSector = stream.GetSector();
+         Int_t iPlate  = stream.GetPlate();
+         Int_t iStrip  = stream.GetStrip();
+         Int_t iPadZ   = stream.GetPadZ();
+         Int_t iPadX   = stream.GetPadX();
+         Int_t iTof    = stream.GetTofBin();
+         Int_t iAdc    = stream.GetADCbin();
+         
+         fprintf(fpw,"%2i %1i %2i %1i %2i %8i %7i\n",
+         iSector, iPlate, iStrip, iPadZ, iPadX, iTof, iAdc);
+       */
+
+      }
+
+    }
+
+  }
+
+}
diff --git a/TOF/AliTOFRawStream.cxx b/TOF/AliTOFRawStream.cxx
new file mode 100644 (file)
index 0000000..8e35a1f
--- /dev/null
@@ -0,0 +1,295 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*
+Revision 0.02  2005/07/28 A. De Caro:
+        Update format TOF raw data
+               (temporary solution) 
+        Correction of few wrong corrispondences
+               between 'software' and 'hardware' numberings
+
+Revision 0.01  2005/07/22 A. De Caro
+        Implement methods Next()
+                         GetSector(),
+                         GetPlate(),
+                         GetStrip(),
+                         GetPadZ(),
+                         GetPadX()
+*/
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// This class provides access to TOF raw data in DDL files.
+//
+// It loops over all TOF raw data given by the AliRawReader.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliLog.h"
+#include "AliRawReader.h"
+
+#include "AliTOFGeometry.h"
+#include "AliTOFRawStream.h"
+
+ClassImp(AliTOFRawStream)
+
+
+//_____________________________________________________________________________
+AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader)
+{
+  //
+  // create an object to read TOF raw digits
+  //
+
+  fRawReader = rawReader;
+  fDDL = -1;
+  fTRM = -1;
+  fTDC = -1;
+  fTDCChannel = -1;
+  fTof = -1;
+  fADC = -1;
+  fErrorFlag = -1;
+  //fCounter = -1; // v0.01
+
+  fRawReader->Select(5);
+
+}
+
+//_____________________________________________________________________________
+AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
+  TObject(stream)
+{
+  //
+  // copy constructor
+  //
+
+  fRawReader = NULL;
+  fDDL = -1;
+  fTRM = -1;
+  fTDC = -1;
+  fTDCChannel = -1;
+  fTof = -1;
+  fADC = -1;
+  fErrorFlag = -1;
+  //fCounter = -1; // v0.01
+
+}
+
+//_____________________________________________________________________________
+AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
+{
+  //
+  // assignment operator
+  //
+
+  fRawReader = stream.fRawReader;
+  fDDL = stream.fDDL;
+  fTRM = stream.fTRM;
+  fTDC = stream.fTDC;
+  fTDCChannel = stream.fTDCChannel;
+  fTof = stream.fTof;
+  fADC = stream.fADC;
+  fErrorFlag = stream.fErrorFlag;
+  //fCounter = stream.fCounter; // v0.01
+
+  return *this;
+
+}
+
+//_____________________________________________________________________________
+AliTOFRawStream::~AliTOFRawStream()
+{
+// destructor
+
+}
+
+
+//_____________________________________________________________________________
+Bool_t AliTOFRawStream::Next()
+{
+// read the next raw digit
+// returns kFALSE if there is no digit left
+
+  //fCounter++; // v0.01
+
+  UInt_t data;
+
+  /*
+  // v0.01
+  if (fCounter==0) {
+    if (!fRawReader->ReadNextInt(data)) return kFALSE;
+    Int_t dummy = data & 0x007F; // first  7 bits
+    AliInfo(Form("This is the number of the current DDL file %2i",dummy));
+  }
+  */
+
+  if (!fRawReader->ReadNextInt(data)) return kFALSE;
+
+  fTRM         =  data        & 0x000F; // first  4 bits
+  fTDC         = (data >>  4) & 0x001F; // next   5 bits
+  fTDCChannel  = (data >>  9) & 0x0007; // next   3 bits
+  fADC         = (data >> 12) & 0x000FFFFF; // last  20 bits // v0.01
+  //fADC         = (data >> 12) & 0x00FF; // next   8 bits // v0.02
+
+  if (!fRawReader->ReadNextInt(data)) return kFALSE;
+
+  fErrorFlag   =  data        & 0x00FF; // first 8 bits
+  fTof         = (data >>  8) & 0x00FFFFFF; // last 24 bits // v0.01
+  //fTof         = (data >>  8) & 0x0FFF; // next 12 bits // v0.02
+
+  fDDL  = fRawReader->GetDDLID();
+
+  //AliInfo(Form("fDDL  %2i,fTRM %2i, fTDC %2i, fTDCChannel %1i",fDDL,fTRM,fTDC,fTDCChannel));
+
+  return kTRUE;
+}
+//_____________________________________________________________________________
+
+Int_t AliTOFRawStream::GetSector() const
+{
+  //
+  // Transform the Hardware coordinate to Software coordinate
+  // and also write it in the digit form
+  //
+
+  Int_t iSector = -1;
+  iSector = (Int_t)((Float_t)fDDL/AliTOFGeometry::NDDL());
+
+  return iSector;
+
+}
+//_____________________________________________________________________________
+
+Int_t AliTOFRawStream::GetPlate() const
+{
+  //
+  // Transform the Hardware coordinate to Software coordinate
+  // and also write it in the digit form
+  //
+
+  Int_t iPlate = -1;
+
+  Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
+  
+  Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
+
+  Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
+
+  if (iStripPerSector     < AliTOFGeometry::NStripC())
+    iPlate = 0;
+  else if (iStripPerSector>=AliTOFGeometry::NStripC() &&
+          iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())
+    iPlate = 1;
+  else if (iStripPerSector>=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB() &&
+          iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA())
+    iPlate = 2;
+  else if (iStripPerSector>=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
+          iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
+    iPlate = 3;
+  else if (iStripPerSector>=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
+          iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripC())
+    iPlate = 4;
+  else
+    iPlate = -1;
+
+  return iPlate;
+
+}
+//_____________________________________________________________________________
+
+Int_t AliTOFRawStream::GetStrip() const
+{
+  //
+  // Transform the Hardware coordinate to Software coordinate
+  // and also write it in the digit form
+  //
+
+  Int_t iStrip = -1;
+
+  Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
+
+  Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
+
+  Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
+
+  if (iStripPerSector      < AliTOFGeometry::NStripC())
+    iStrip = iStripPerSector;
+  else if (iStripPerSector >=AliTOFGeometry::NStripC() &&
+          iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())
+    iStrip = iStripPerSector-AliTOFGeometry::NStripC();
+  else if (iStripPerSector >=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB() &&
+          iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()) 
+    iStrip = iStripPerSector-AliTOFGeometry::NStripC()-AliTOFGeometry::NStripB();
+  else if (iStripPerSector >=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
+          iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
+    iStrip = iStripPerSector-AliTOFGeometry::NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA();
+  else if (iStripPerSector >=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
+          iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripC())
+    iStrip = iStripPerSector-AliTOFGeometry::NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA()-AliTOFGeometry::NStripB();
+  else
+    iStrip = -1;
+
+  return iStrip;
+
+}
+//_____________________________________________________________________________
+
+Int_t AliTOFRawStream::GetPadZ() const
+{
+  //
+  // Transform the Hardware coordinate to Software coordinate
+  // and also write it in the digit form
+  //
+
+  Int_t iPadZ = -1;
+
+  Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
+
+  Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
+  
+  Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
+
+  Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
+
+  iPadZ = iPadPerStrip%AliTOFGeometry::NpadZ();
+
+  return iPadZ;
+
+}
+//_____________________________________________________________________________
+
+Int_t AliTOFRawStream::GetPadX() const
+{
+  //
+  // Transform the Hardware coordinate to Software coordinate
+  // and also write it in the digit form
+  //
+
+  Int_t iPadX = -1;
+
+  Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
+
+  Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
+
+  Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
+
+  Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
+
+  iPadX = (Int_t)(iPadPerStrip/(Float_t)AliTOFGeometry::NpadZ());
+
+  return iPadX;
+
+}
+//_____________________________________________________________________________
diff --git a/TOF/AliTOFRawStream.h b/TOF/AliTOFRawStream.h
new file mode 100644 (file)
index 0000000..6138db4
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef ALITOFRAWSTREAM_H
+#define ALITOFRAWSTREAM_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+////////////////////////////////////////////////////////////
+//
+// This class provides the key-reading for TOF raw data.
+//
+////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+
+class AliRawReader;
+
+
+class AliTOFRawStream: public TObject {
+  public :
+
+  AliTOFRawStream(AliRawReader* rawReader);
+  virtual ~AliTOFRawStream();
+
+  virtual Bool_t   Next();
+  
+  //void  ResetCounter() {fCounter = -1;}; // v0.01
+
+  Int_t GetDDL()       const {return fDDL;};
+  Int_t GetTRM()       const {return fTRM;};
+  Int_t GetTDC()       const {return fTDC;};
+  Int_t GetChannel()   const {return fTDCChannel;};
+  
+  Int_t GetSector() const;
+  Int_t GetPlate()  const;
+  Int_t GetStrip()  const;
+  Int_t GetPadZ()   const;
+  Int_t GetPadX()   const;
+  
+  Int_t GetTofBin() const {return fTof;};
+  Int_t GetADCbin() const {return fADC;};
+    
+  enum {kDDLOffset = 0x500};      // offset for DDL numbers
+    
+  private :
+  AliTOFRawStream(const AliTOFRawStream& stream);
+  AliTOFRawStream& operator = (const AliTOFRawStream& stream);
+
+  AliRawReader*    fRawReader;  // object for reading the raw data
+
+  Int_t            fDDL;        // index of current DDL file
+  Int_t            fTRM;        // index of current TRM
+  Int_t            fTDC;        // index of current TDC
+  Int_t            fTDCChannel; // index of current channel of the TDC
+  Int_t            fTof;        // time-of-flight measurement
+  Int_t            fADC;        // 'charge' measurement
+  Int_t            fErrorFlag;  // error flag
+  
+  //Int_t            fCounter;    // counter for TOF raw data rows in DDL files // v0.01
+
+  ClassDef(AliTOFRawStream, 1)  // class for reading TOF raw digits
+};
+
+#endif
diff --git a/TOF/AliTOFcluster.cxx b/TOF/AliTOFcluster.cxx
new file mode 100644 (file)
index 0000000..66d26be
--- /dev/null
@@ -0,0 +1,116 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+/*
+Revision 0.02 2005/07/27 A. De Caro
+         Implement new ctor AliTOFcluster(Double_t *, Int_t *)
+        for cluster construction from raw data
+
+Revision 0.01 2005/07/25 A. De Caro
+         Implement new class statring from
+        class definition inside AliTOFtracker class
+        (originally implemented by S. Arcelli and C. Zampolli)
+*/
+
+// AliTOFcluster Class
+// Description: class for TOF cluster definition
+
+#include "AliTOFcluster.h"
+
+ClassImp(AliTOFcluster)
+
+AliTOFcluster::AliTOFcluster() {
+  //
+  // default ctor
+  //
+
+  Int_t ii;
+  fR   = 0.;
+  fPhi = 0.;
+  fZ   = 0.;
+  fTDC = 0.;
+  fADC = 0.;
+  for (ii=0; ii<3; ii++) fLab[ii]      = -1;
+  fIdx = -1;
+  for (ii=0; ii<5; ii++) fdetIndex[ii] = -1;
+
+}
+//-------------------------------------------------------------------------
+
+AliTOFcluster::AliTOFcluster(Double_t *h, Int_t *l, Int_t *ind, Int_t idx)
+:TObject() {
+  //
+  // constructor
+  //
+
+  Int_t ii;
+  fR   = h[0];
+  fPhi = h[1];
+  fZ   = h[2];
+  fTDC = h[3];
+  fADC = h[4];
+  for (ii=0; ii<3; ii++) fLab[ii]      = l[ii];
+  fIdx = idx;
+  for (ii=0; ii<5; ii++) fdetIndex[ii] = ind[ii];
+
+}
+//-------------------------------------------------------------------------
+
+AliTOFcluster::AliTOFcluster(Double_t *h, Int_t *ind)
+:TObject() {
+  //
+  // constructor
+  //
+
+  Int_t ii;
+  fR   = h[0];
+  fPhi = h[1];
+  fZ   = h[2];
+  fTDC = h[3];
+  fADC = h[4];
+  for (ii=0; ii<3; ii++) fLab[ii]      = -1;
+  fIdx = -1;
+  for (ii=0; ii<5; ii++) fdetIndex[ii] = ind[ii];
+
+}
+//-------------------------------------------------------------------------
+
+AliTOFcluster::AliTOFcluster(const AliTOFcluster & cluster)
+:TObject() {
+  //
+  // copy ctor for AliTOFcluster object
+  //
+
+  Int_t ii;
+  fR        = cluster.fR;
+  fPhi      = cluster.fPhi;
+  fZ        = cluster.fZ;
+  fTDC      = cluster.fTDC;
+  fADC      = cluster.fADC;
+  for (ii=0; ii<3; ii++) fLab[ii]      = cluster.fLab[ii];
+  fIdx      = cluster.fIdx;
+  for (ii=0; ii<5; ii++) fdetIndex[ii] = cluster.fdetIndex[ii];
+
+}
+//-------------------------------------------------------------------------
+
+AliTOFcluster::~AliTOFcluster() {
+  //
+  // dtor
+  //
+
+  //delete fLab;
+  //delete fdetIndex;
+
+}
diff --git a/TOF/AliTOFcluster.h b/TOF/AliTOFcluster.h
new file mode 100644 (file)
index 0000000..e89283b
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef ALITOFCLUSTER_H
+#define ALITOFCLUSTER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+// AliTOFcluster Class
+
+/* $Id $ */
+
+#include "TMath.h"
+
+#include "TObject.h"
+
+class AliTOFcluster : public TObject {
+ public:
+  AliTOFcluster(); // default ctor
+  AliTOFcluster(Double_t *h, Int_t *l, Int_t *ind, Int_t idx); // ctor
+  AliTOFcluster(Double_t *h, Int_t *ind); // new ctor
+  AliTOFcluster(const AliTOFcluster & cluster); // copy ctor
+  virtual ~AliTOFcluster(); // dtor
+
+  Double_t GetR() const   {return fR;}   // Cluster Radius
+  Double_t GetPhi() const {return fPhi;} // Cluster Phi
+  Double_t GetZ()   const {return fZ;}   // Cluster Z
+  Double_t GetTDC() const {return fTDC;} // Cluster ToF
+  Double_t GetADC() const {return TMath::Abs(fADC);}  // Cluster Charge
+  Int_t    IsUsed() const {return (fADC<0) ? 1 : 0;}  // Flagging
+  Int_t    GetLabel(Int_t n) const  {return fLab[n];} // Labels of tracks in Cluster
+  Int_t    GetDetInd(Int_t n) const {return fdetIndex[n];} // Cluster Detector Indeces
+  Int_t    GetIndex() const         {return fIdx;}         // Cluster Index
+  void     Use() {fADC=-fADC;}
+
+ private:
+
+  Int_t fLab[3];      // track labels
+  Int_t fIdx;         // index of this cluster
+  Int_t fdetIndex[5]; // Cluster detector Indeces (sector,plate,strip,padz,padx)
+  Double_t fR;        // r-coordinate
+  Double_t fPhi;      // phi-coordinate
+  Double_t fZ;        // z-coordinate
+  Double_t fTDC;      // TDC count
+  Double_t fADC;      // ADC count
+
+  ClassDef(AliTOFcluster, 1) // TOF cluster
+};
+
+#endif
index 121bad3..958e3b2 100644 (file)
 //--------------------------------------------------------------------
 
 #include <Rtypes.h>
-#include "AliTOFtracker.h"
-#include "AliTOFtrack.h"
+
 #include "TClonesArray.h"
+
 #include "AliLog.h"
-#include "AliTOFdigit.h"
-#include "AliTOFGeometry.h"
 #include "AliRun.h"
 #include "AliModule.h"
 
+#include "AliTOFdigit.h"
+#include "AliTOFcluster.h"
+#include "AliTOFtrack.h"
+#include "AliTOFGeometry.h"
+#include "AliTOFtracker.h"
+
 ClassImp(AliTOFtracker)
 
 //_____________________________________________________________________________
index d004308..0c9c4c9 100644 (file)
 
 /* $Id$ */
 
+#include "TClonesArray.h"
+
+#include "AliESD.h"
 #include "AliTracker.h"
+
 #include "AliTOFpidESD.h"
-#include "AliESD.h"
-#include "TClonesArray.h"
 
 class AliTOFGeometry;
+class AliTOFcluster;
 
 class AliTOFtracker : public AliTracker {
 
@@ -37,44 +40,6 @@ public:
   virtual void  UnloadClusters();// UnLoad Clusters
   virtual AliCluster *GetCluster(Int_t /*index*/) const {return NULL;};
 
-public:
-  class AliTOFcluster {
-  public:
-    AliTOFcluster(Double_t *h, Int_t *l, Int_t *ind, Int_t idx) {
-      fR=h[0]; fPhi=h[1]; fZ=h[2]; fTDC=h[3]; fADC=h[4];
-      fLab[0]=l[0]; fLab[1]=l[1]; fLab[2]=l[2];
-      fIdx=idx;
-      fdetIndex[0]=ind[0];
-      fdetIndex[1]=ind[1];
-      fdetIndex[2]=ind[2];
-      fdetIndex[3]=ind[3];
-      fdetIndex[4]=ind[4];
-    }
-    void Use() {fADC=-fADC;}
-
-    Double_t GetR() const {return fR;}  // Cluster Radius
-    Double_t GetPhi() const {return fPhi;} // Cluster Phi
-    Double_t GetZ()   const {return fZ;} // Cluster Z
-    Double_t GetTDC() const {return fTDC;} // Cluster ToF
-    Double_t GetADC() const {return TMath::Abs(fADC);} // Cluster Charge
-    Int_t IsUsed() const {return (fADC<0) ? 1 : 0;} // Flagging
-    Int_t GetLabel(Int_t n) const {return fLab[n];} // Labels of tracks in Cluster
-    Int_t GetDetInd(Int_t n) const {return fdetIndex[n];} //Cluster Det Indeces
-    Int_t GetIndex() const {return fIdx;} // Cluster Index
-
-  private:
-
-    Int_t fLab[3]; //track labels
-    Int_t fIdx;    //index of this cluster
-    Int_t fdetIndex[5]; //Cluster detector Indeces (plate,strip,..)
-    Double_t fR;   //r-coordinate
-    Double_t fPhi; //phi-coordinate
-    Double_t fZ;   //z-coordinate
-    Double_t fTDC; //TDC count
-    Double_t fADC; //ADC count
-
-  };
-
 private:
 
   Int_t InsertCluster(AliTOFcluster *c); // Fills TofClusters Array
index b2d4556..9d6cfc8 100644 (file)
@@ -10,5 +10,6 @@
  
 #pragma link C++ class  AliTOFGeometry+;
 #pragma link C++ class  AliTOFdigit+;
+#pragma link C++ class  AliTOFRawStream+;
 
 #endif
index 874bd61..20333a6 100644 (file)
@@ -8,6 +8,7 @@
 #pragma link off all classes;
 #pragma link off all functions;
  
+#pragma link C++ class  AliTOFcluster+;
 #pragma link C++ class  AliTOFtrack+;
 #pragma link C++ class  AliTOFtracker+;
 #pragma link C++ class  AliTOFpidESD+;
index 23605da..7def8de 100644 (file)
@@ -2,8 +2,8 @@
 # $Id$
 
 SRCS  = AliTOFGeometry.cxx  \
-        AliTOFdigit.cxx
-
+        AliTOFdigit.cxx     \
+        AliTOFRawStream.cxx
 
 HDRS:= $(SRCS:.cxx=.h)
 
index ecd01c2..df460cf 100644 (file)
@@ -1,8 +1,8 @@
 #-*- Mode: Makefile -*-
 # $Id$
 
-SRCS  = AliTOFtrack.cxx  AliTOFtracker.cxx  AliTOFpidESD.cxx  \
-       AliTOFReconstructor.cxx
+SRCS  = AliTOFcluster.cxx  AliTOFtrack.cxx  AliTOFtracker.cxx  \
+       AliTOFpidESD.cxx  AliTOFReconstructor.cxx
 
 HDRS:= $(SRCS:.cxx=.h)