]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added method to write the SDD raw data for simulated events in the new compressed...
authorprino <prino@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Aug 2008 21:39:30 +0000 (21:39 +0000)
committerprino <prino@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Aug 2008 21:39:30 +0000 (21:39 +0000)
ITS/AliITSDDLRawData.cxx
ITS/AliITSDDLRawData.h

index 343a5dead82e09df295ae480f6a0385d755ce3fa..42025756ba26582d44d8cd7347a53b1808304e5f 100644 (file)
@@ -44,7 +44,8 @@ ClassImp(AliITSDDLRawData)
 AliITSDDLRawData::AliITSDDLRawData():
 fVerbose(0),
 fIndex(-1),
-fHalfStaveModule(-1){
+fHalfStaveModule(-1),
+fUseCompressedSDDFormat(0){
   //Default constructor
 
 }
@@ -55,7 +56,8 @@ AliITSDDLRawData::AliITSDDLRawData(const AliITSDDLRawData &source) :
     TObject(source),
 fVerbose(source.fVerbose),
 fIndex(source.fIndex),
-fHalfStaveModule(source.fHalfStaveModule){
+fHalfStaveModule(source.fHalfStaveModule),
+fUseCompressedSDDFormat(source.fUseCompressedSDDFormat){
   //Copy Constructor
 }
 
@@ -66,6 +68,7 @@ AliITSDDLRawData& AliITSDDLRawData::operator=(const AliITSDDLRawData &source){
   this->fIndex=source.fIndex;
   this->fHalfStaveModule=source.fHalfStaveModule;
   this->fVerbose=source.fVerbose;
+  this->fUseCompressedSDDFormat=source.fUseCompressedSDDFormat;
   return *this;
 }
 
@@ -125,6 +128,41 @@ void AliITSDDLRawData::GetDigitsSSD(TClonesArray *ITSdigits,Int_t mod,Int_t modR
 //Silicon Drift Detector
 //
 
+void AliITSDDLRawData::GetDigitsSDDCompressed(TClonesArray *ITSdigits, Int_t mod, UInt_t *buf){ 
+//This method packs the SDD digits in the compressed format (32 bit per digit)
+// see AliITSRawStreamSDDCompressed for details on the dta format
+
+  UInt_t dataWord=0;
+  Int_t ndigits = ITSdigits->GetEntries();
+  AliITSdigit *digs;
+  if(ndigits){
+    for (Int_t digit=0;digit<ndigits;digit++) {
+      digs = (AliITSdigit*)ITSdigits->UncheckedAt(digit);
+      Int_t iz=digs->GetCoord1();  // Anode
+      Int_t ix=digs->GetCoord2();  // Time
+      Int_t is=digs->GetSignal();  // ADC Signal - 10 bit
+      dataWord=mod<<27;
+      Int_t sid=0;
+      if(iz>=256){
+       sid=1;
+       iz-=256;
+      }
+      dataWord+=sid<<26;
+      dataWord+=iz<<18;
+      dataWord+=ix<<10;
+      dataWord+=is;
+      fIndex++;
+      buf[fIndex]=dataWord;
+    }
+  }
+  UInt_t finalWord=15<<28;
+  finalWord+=mod;
+  fIndex++;
+  buf[fIndex]=finalWord;  
+}
+
+//______________________________________________________________________
+
 void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod,Int_t modR,Int_t ddl,UInt_t *buf){  
   //This method packs the SDD digits in a proper 32 bits structure
   Int_t ix;
@@ -606,8 +644,10 @@ Int_t AliITSDDLRawData::RawDataSDD(TBranch* branch, AliITSDDLModuleMapSDD* ddlsd
 
 
     //first 1 "dummy" word to be skipped
-    retcode = AliBitPacking::PackWord(0xFFFFFFFF,skippedword,0,31);
-    outfile->WriteBuffer((char*)(&skippedword),sizeof(skippedword));
+    if(!fUseCompressedSDDFormat){
+      retcode = AliBitPacking::PackWord(0xFFFFFFFF,skippedword,0,31);
+      outfile->WriteBuffer((char*)(&skippedword),sizeof(skippedword));
+    }
 
     //Loops over Modules of a particular DDL
     for (Int_t mod=0; mod<AliITSRawStreamSDD::kModulesPerDDL; mod++){
@@ -619,17 +659,22 @@ Int_t AliITSDDLRawData::RawDataSDD(TBranch* branch, AliITSDDLModuleMapSDD* ddlsd
        //For each Module, buf contains the array of data words in Binary format          
        //fIndex gives the number of 32 bits words in the buffer for each module
        //      cout<<"MODULE NUMBER:"<<mapSDD[i][mod]<<endl;
-       GetDigitsSDD(digits,mod,moduleNumber,i,buf);
-       outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t)));
-       for(Int_t iw=0;iw<3;iw++) outfile->WriteBuffer((char*)(&carlosFooterWord),sizeof(carlosFooterWord));
+       if(fUseCompressedSDDFormat){
+         GetDigitsSDDCompressed(digits,mod,buf);
+         outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t)));
+       }else{
+         GetDigitsSDD(digits,mod,moduleNumber,i,buf);
+         outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t)));
+         for(Int_t iw=0;iw<3;iw++) outfile->WriteBuffer((char*)(&carlosFooterWord),sizeof(carlosFooterWord));
+       }
        fIndex=-1;
       }//end if
     }//end for
     // 12 words with FIFO footers (=4 FIFO x 3 3F1F1F1F words per DDL)
-    for(Int_t iw=0;iw<12;iw++) outfile->WriteBuffer((char*)(&fifoFooterWord),sizeof(fifoFooterWord));
-   
-    outfile->WriteBuffer((char*)(&jitterWord),sizeof(jitterWord));      
-    
+    if(!fUseCompressedSDDFormat){
+      for(Int_t iw=0;iw<12;iw++) outfile->WriteBuffer((char*)(&fifoFooterWord),sizeof(fifoFooterWord));
+      outfile->WriteBuffer((char*)(&jitterWord),sizeof(jitterWord));      
+    }
     //Write REAL DATA HEADER
     UInt_t currentFilePosition=outfile->Tellp();
     outfile->Seekp(dataHeaderPosition);
index 657d5574b5ff6f548f0f0242bcbad8bd5af4ac56..5f7cb979960d7d06758812afa377d4322d82623e 100644 (file)
@@ -28,9 +28,13 @@ class AliITSDDLRawData:public TObject{
   // This method generates the files with the Silicon pixel detector data
   void SetVerbose(Int_t Verbose){fVerbose=Verbose;}
   // To set the verbose level
+  void SetUseCompressedSDDFormat(Bool_t opt=kFALSE){
+    fUseCompressedSDDFormat=opt;
+  }
  private: 
   void  GetDigitsSPD(TClonesArray *ITSdigits, Int_t mod,Int_t ddl,UInt_t *buf);
   //This method formats and stores in buf all the digits of a SPD module
+  void  GetDigitsSDDCompressed(TClonesArray *ITSdigits, Int_t mod,UInt_t *buf);
   void  GetDigitsSDD(TClonesArray *ITSdigits, Int_t mod,Int_t modR,Int_t ddl,UInt_t *buf);
   //This method formats and stores in buf all the digits of a SDD module
   void  GetDigitsSSD(TClonesArray *ITSdigits, Int_t mod,Int_t modR,Int_t ddl,UInt_t *buf);
@@ -43,7 +47,9 @@ class AliITSDDLRawData:public TObject{
   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
   Int_t fHalfStaveModule;     //first or second half of an Half Stave module
-  ClassDef(AliITSDDLRawData,1)
+  Bool_t fUseCompressedSDDFormat;  // flag for use the compressed SDD raw data format
+
+  ClassDef(AliITSDDLRawData,2)
 };
     
 #endif