]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFDDLRawData.cxx
Introduce extern for the common block references
[u/mrichter/AliRoot.git] / TOF / AliTOFDDLRawData.cxx
index 6a15e372d12dd353bdbf4e5e6995b9c719ec66e0..d84461dff21ef96e3809201ac51538189f0b1315 100644 (file)
@@ -17,7 +17,6 @@
 Revision 0.01  2004/6/11 A.De Caro, S.B.Sellitto, R.Silvestri
         First implementation: global methods RawDataTOF
                                              GetDigits
-                                             (Un)PackWord
 */
 //
 // This class contains the methods to create the Raw Data files
@@ -32,11 +31,13 @@ Revision 0.01  2004/6/11 A.De Caro, S.B.Sellitto, R.Silvestri
 #include <TClonesArray.h>
 #include <TTree.h>
 #include <TMath.h>
-#include "AliTOF.h"
+#include "AliLog.h"
+
 #include "AliTOFGeometry.h"
 #include "AliTOFdigit.h"
 #include "AliTOFDDLRawData.h"
 #include "AliRawDataHeader.h"
+#include "AliBitPacking.h"
 
 ClassImp(AliTOFDDLRawData)
 
@@ -93,7 +94,7 @@ void AliTOFDDLRawData::GetDigits(TClonesArray *TOFdigits,Int_t nDDL,UInt_t *buf)
   ofstream ftxt;
   if(!ndigits) 
     {
-      Error("GetDigits", "No found TOF digits\n");      
+      AliError("No found TOF digits");
       return;
     }
 
@@ -132,23 +133,23 @@ void AliTOFDDLRawData::GetDigits(TClonesArray *TOFdigits,Int_t nDDL,UInt_t *buf)
     
     if (eureka!=digs->GetTotPad()) printf(" eureka = %d AND digs->GetTotPad() = %d",eureka,digs->GetTotPad());
     */
-    if (sector!=iSector || (Int_t)((Float_t)eureka/AliTOF::NPadXTRM()/AliTOF::NTRM())!=iDDL) continue;
+    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;
     
-    iTRM = (Int_t)((Float_t)eureka/AliTOF::NPadXTRM() - AliTOF::NTRM()*iDDL);
+    iTRM = (Int_t)((Float_t)eureka/AliTOFGeometry::NPadXTRM() - AliTOFGeometry::NTRM()*iDDL);
     
-    iTDC = (Int_t)(AliTOF::NTdc()* 
+    iTDC = (Int_t)(AliTOFGeometry::NTdc()* 
                   (
-                   (Float_t)eureka/AliTOF::NPadXTRM() -
-                   (Int_t)((Float_t)eureka/AliTOF::NPadXTRM())
+                   (Float_t)eureka/AliTOFGeometry::NPadXTRM() -
+                   (Int_t)((Float_t)eureka/AliTOFGeometry::NPadXTRM())
                    )
                   );
     
-    iCH  = (Int_t)(AliTOF::NCh() * 
+    iCH  = (Int_t)(AliTOFGeometry::NCh() * 
                   (
-                   (Float_t)eureka/AliTOF::NPadXTRM()*AliTOF::NTdc() - (Int_t)((Float_t)eureka/AliTOF::NPadXTRM()*AliTOF::NTdc()) -
-                   (Int_t)((Float_t)eureka/AliTOF::NPadXTRM()*AliTOF::NTdc() - (Int_t)((Float_t)eureka/AliTOF::NPadXTRM()*AliTOF::NTdc()))
+                   (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()))
                    )
                   );
     
@@ -157,16 +158,16 @@ void AliTOFDDLRawData::GetDigits(TClonesArray *TOFdigits,Int_t nDDL,UInt_t *buf)
     baseWord=0;
     
     word=iTRM;
-    PackWord(baseWord,word, 0, 3); // TRM ID
+    AliBitPacking::PackWord(word,baseWord, 0, 3); // TRM ID
     word=iTDC;
-    PackWord(baseWord,word, 4, 8); // TDC ID
+    AliBitPacking::PackWord(word,baseWord, 4, 8); // TDC ID
     word=iCH;
-    PackWord(baseWord,word, 9,11); // CH ID
+    AliBitPacking::PackWord(word,baseWord, 9,11); // CH ID
 
     // temporary control
     if (totCharge<0) word=TMath::Abs(totCharge);
     else word=totCharge;
-    PackWord(baseWord,word,12,31); // Charge (TOT)
+    AliBitPacking::PackWord(word,baseWord,12,31); // Charge (TOT)
     
     fIndex++;
     buf[fIndex]=baseWord;
@@ -174,9 +175,9 @@ void AliTOFDDLRawData::GetDigits(TClonesArray *TOFdigits,Int_t nDDL,UInt_t *buf)
     baseWord=0;
     
     word=error;
-    PackWord(baseWord,word,0, 7); // Error flag
+    AliBitPacking::PackWord(word,baseWord,0, 7); // Error flag
     word=timeOfFlight;
-    PackWord(baseWord,word,8,31); // time-of-flight
+    AliBitPacking::PackWord(word,baseWord,8,31); // time-of-flight
     
     fIndex++;
     buf[fIndex]=baseWord;
@@ -191,55 +192,6 @@ void AliTOFDDLRawData::GetDigits(TClonesArray *TOFdigits,Int_t nDDL,UInt_t *buf)
 
 }//end GetDigits
 
-//-------------------------------------------------------------------------------------
-
-void AliTOFDDLRawData::PackWord(UInt_t &BaseWord, UInt_t Word, Int_t StartBit, Int_t StopBit)
-{
-  //This method packs a word into the Baseword buffer starting form the "StartBit" 
-  //and tacking StopBit-StartBit+1 bits
-  UInt_t dummyWord,offSet;
-  Int_t  length;
-  UInt_t sum;
-  //The BaseWord is being filled with 1 from StartBit to StopBit
-  length=StopBit-StartBit+1;
-  sum=(UInt_t)TMath::Power(2,length)-1;
-
-  if(Word > sum){
-    Error("PackWord", "Word to be filled is not within desired length\n"
-         "Word:%d Start bit:%d Stop Bit:%d",Word,StartBit,StopBit);
-    return;
-  }
-  offSet=sum;
-  offSet<<=StartBit;
-  BaseWord=BaseWord|offSet;
-
-  //The Word to be filled is shifted to the position StartBit
-  //and the remaining  Left and Right bits are filled with 1
-  sum=(UInt_t)TMath::Power(2,StartBit)-1;
-  dummyWord=0xFFFFFFFF<<length;
-  dummyWord +=Word;
-  dummyWord<<=StartBit;
-  dummyWord+=sum;
-  BaseWord=BaseWord&dummyWord;
-
-  return;
-}
-
-//------------------------------------------------------------------------------------------------
-
-void AliTOFDDLRawData::UnpackWord(UInt_t PackedWord, Int_t StartBit, Int_t StopBit, UInt_t &Word)
-{
-  //This method unpacks a words of StopBit-StartBit+1 bits starting from "StopBits"  
-  UInt_t offSet;
-  Int_t length;
-  length=StopBit-StartBit+1;
-  offSet=(UInt_t)TMath::Power(2,length)-1;
-  offSet<<=StartBit;
-  Word=PackedWord&offSet;
-  Word>>=StartBit;
-  return;
-}
-
 //---------------------------------------------------------------------------------------
 
 Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch){
@@ -259,7 +211,7 @@ Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch){
 
   //loop over TOF DDL files
   for(Int_t i=0;i<72;i++){
-    sprintf(fileName,"TOF_%d.ddl",i); //The name of the output file
+    sprintf(fileName,"TOF_%d.ddl",i+kDDLOffset); //The name of the output file
 #ifndef __DECCXX
     outfile.open(fileName,ios::binary);
 #else
@@ -271,7 +223,7 @@ Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch){
 
     baseWord=0;
     word=i;
-    PackWord(baseWord,word,0, 31); // Number of DDL file
+    AliBitPacking::PackWord(word,baseWord,0, 31); // Number of DDL file
 
     fIndex++;
     buf[fIndex]=baseWord;