Fixes in order to write correct raw-data on big-endian platforms (Marco)
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 22 Jun 2007 11:40:01 +0000 (11:40 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 22 Jun 2007 11:40:01 +0000 (11:40 +0000)
HMPID/AliHMPIDDigit.cxx
ITS/AliITSDDLRawData.cxx
PMD/AliPMDDDLRawData.cxx
STEER/AliCTPRawData.cxx
TOF/AliTOFDDLRawData.cxx
TRD/AliTRDrawData.cxx
VZERO/AliVZEROBuffer.cxx
VZERO/AliVZEROBuffer.h
ZDC/AliZDC.cxx

index f86f0a5..448509a 100644 (file)
@@ -21,6 +21,8 @@
 #include "AliHMPIDParam.h"
 #include <AliDAQ.h>           //WriteRaw()
 #include "Riostream.h"        //WriteRaw()
+#include "AliFstream.h"   
+
 ClassImp(AliHMPIDDigit)
 
 /*
@@ -136,14 +138,15 @@ void AliHMPIDDigit::WriteRaw(TObjArray *pDigAll)
 // Arguments: pDigAll- list of digits 
 //   Returns: none      
   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){//chambers loop
-    ofstream ddlL,ddlR;                               //output streams, 2 per chamber
+    AliFstream* ddlL;                                 //output streams, 2 per chamber
+    AliFstream* ddlR;                          
     Int_t    cntL=0,cntR=0;                           //data words counters for DDLs
     AliRawDataHeader header; header.SetAttribute(0);  //empty DDL header
 
-    ddlL.open(AliDAQ::DdlFileName("HMPID",2*iCh)); 
-    ddlR.open(AliDAQ::DdlFileName("HMPID",2*iCh+1));      //open both DDL of this chamber in parallel
-    ddlL.write((char*)&header,sizeof(header));            //write dummy header as place holder, actual 
-    ddlR.write((char*)&header,sizeof(header));            //will be rewritten later when total size of DDL is known
+    ddlL = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh)); 
+    ddlR = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh+1));      //open both DDL of this chamber in parallel
+    ddlL->WriteBuffer((char*)&header,sizeof(header));            //write dummy header as place holder, actual 
+    ddlR->WriteBuffer((char*)&header,sizeof(header));            //will be rewritten later when total size of DDL is known
   
     UInt_t w32=0;                 //32 bits data word 
     TClonesArray *pDigCh=(TClonesArray *)pDigAll->At(iCh); //list of digits for current chamber 
@@ -153,14 +156,14 @@ void AliHMPIDDigit::WriteRaw(TObjArray *pDigAll)
       Int_t ddl,r,d,a;            //32 bits data word 
       pDig->Raw(w32,ddl,r,d,a);                             
       if(ddl%2){
-        ddlL.write((char*)&w32,sizeof(w32));  cntL++;
+        ddlL->WriteBuffer((char*)&w32,sizeof(w32));  cntL++;
       }else{
-        ddlR.write((char*)&w32,sizeof(w32));  cntR++;
+        ddlR->WriteBuffer((char*)&w32,sizeof(w32));  cntR++;
       }
     }//digits  loop
 
-    header.fSize=sizeof(header)+cntL*sizeof(w32); ddlL.seekp(0); ddlL.write((char*)&header,sizeof(header)); ddlL.close(); //rewrite header with size set to
-    header.fSize=sizeof(header)+cntR*sizeof(w32); ddlR.seekp(0); ddlR.write((char*)&header,sizeof(header)); ddlR.close(); //number of bytes and close file
+    header.fSize=sizeof(header)+cntL*sizeof(w32); ddlL->Seekp(0); ddlL->WriteBuffer((char*)&header,sizeof(header)); delete ddlL; //rewrite header with size set to
+    header.fSize=sizeof(header)+cntR*sizeof(w32); ddlR->Seekp(0); ddlR->WriteBuffer((char*)&header,sizeof(header)); delete ddlR; //number of bytes and close file
   }//chambers loop
 }//WriteRaw()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
index 71b5b0f..bdf2249 100644 (file)
@@ -33,6 +33,7 @@
 #include "AliITSRawStreamSSD.h"
 #include "AliBitPacking.h"
 #include "AliDAQ.h"
+#include "AliFstream.h"
 
 ClassImp(AliITSDDLRawData)
 
@@ -491,20 +492,16 @@ Int_t AliITSDDLRawData::RawDataSPD(TBranch* branch){
 
   TClonesArray*& digits = * (TClonesArray**) branch->GetAddress();
   char fileName[15];
-  ofstream outfile;         // logical name of the output file 
+  AliFstream* outfile;         // logical name of the output file 
   AliRawDataHeader header;
 
   //loop over DDLs
   for(Int_t i=0;i<AliDAQ::NumberOfDdls("ITSSPD");i++){
     strcpy(fileName,AliDAQ::DdlFileName("ITSSPD",i)); //The name of the output file.
-#ifndef __DECCXX
-    outfile.open(fileName,ios::binary);
-#else
-    outfile.open(fileName);
-#endif
+    outfile = new AliFstream(fileName);
     //write Dummy DATA HEADER
-    UInt_t dataHeaderPosition=outfile.tellp();
-    outfile.write((char*)(&header),sizeof(header));
+    UInt_t dataHeaderPosition=outfile->Tellp();
+    outfile->WriteBuffer((char*)(&header),sizeof(header));
     //Loops over Modules of a particular DDL
     for (Int_t mod=0; mod<AliITSRawStreamSPD::kModulesPerDDL; mod++){
       Int_t moduleNumber = AliITSRawStreamSPD::GetModuleNumber(i, mod);
@@ -513,7 +510,7 @@ Int_t AliITSDDLRawData::RawDataSPD(TBranch* branch){
       //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
       GetDigitsSPD(digits,mod,i,buf);
-      outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t)));
+      outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t)));
       for(Int_t i=0;i<(fIndex+1);i++){
        buf[i]=0;
       }//end for
@@ -521,11 +518,11 @@ Int_t AliITSDDLRawData::RawDataSPD(TBranch* branch){
     }//end for
     
     //Write REAL DATA HEADER
-    UInt_t currentFilePosition=outfile.tellp();
-    outfile.seekp(dataHeaderPosition);
+    UInt_t currentFilePosition=outfile->Tellp();
+    outfile->Seekp(dataHeaderPosition);
     header.fSize=currentFilePosition-dataHeaderPosition;
-    outfile.write((char*)(&header),sizeof(header));
-    outfile.close();
+    outfile->WriteBuffer((char*)(&header),sizeof(header));
+    delete outfile;
   }//end for
 
   return 0;  
@@ -542,20 +539,16 @@ Int_t AliITSDDLRawData::RawDataSSD(TBranch* branch){
 
   TClonesArray*& digits = * (TClonesArray**) branch->GetAddress();
   char fileName[15];
-  ofstream outfile;         // logical name of the output file 
+  AliFstream* outfile;         // logical name of the output file 
   AliRawDataHeader header;
 
   //loop over DDLs  
   for(Int_t i=0;i<AliDAQ::NumberOfDdls("ITSSSD");i++){
     strcpy(fileName,AliDAQ::DdlFileName("ITSSSD",i)); //The name of the output file.
-#ifndef __DECCXX
-    outfile.open(fileName,ios::binary);
-#else
-    outfile.open(fileName);
-#endif
+    outfile = new AliFstream(fileName);
     //write Dummy DATA HEADER
-    UInt_t dataHeaderPosition=outfile.tellp();
-    outfile.write((char*)(&header),sizeof(header));
+    UInt_t dataHeaderPosition=outfile->Tellp();
+    outfile->WriteBuffer((char*)(&header),sizeof(header));
     
     //Loops over Modules of a particular DDL
     for (Int_t mod=0; mod<AliITSRawStreamSSD::kModulesPerDDL; mod++){
@@ -566,18 +559,18 @@ Int_t AliITSDDLRawData::RawDataSSD(TBranch* branch){
        //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
        GetDigitsSSD(digits,mod,moduleNumber,i,buf);
-       outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t)));
+       outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t)));
        fIndex=-1;
       }//end if
     }//end for
 
     //Write REAL DATA HEADER
-    UInt_t currentFilePosition=outfile.tellp();
-    outfile.seekp(dataHeaderPosition);
+    UInt_t currentFilePosition=outfile->Tellp();
+    outfile->Seekp(dataHeaderPosition);
     header.fSize=currentFilePosition-dataHeaderPosition;
     header.SetAttribute(0);  // valid data
-    outfile.write((char*)(&header),sizeof(header));
-    outfile.close();
+    outfile->WriteBuffer((char*)(&header),sizeof(header));
+    delete outfile;
   }//end for
 
   return 0;  
@@ -593,25 +586,21 @@ Int_t AliITSDDLRawData::RawDataSDD(TBranch* branch){
 
   TClonesArray*& digits = * (TClonesArray**) branch->GetAddress();
   char fileName[15];
-  ofstream outfile;             // logical name of the output file 
+  AliFstream* outfile;             // logical name of the output file 
   AliRawDataHeader header;
   UInt_t skippedword = AliBitPacking::PackWord(2,skippedword,0,31);
 
   //loop over DDLs  
   for(Int_t i=0;i<AliDAQ::NumberOfDdls("ITSSDD");i++){
     strcpy(fileName,AliDAQ::DdlFileName("ITSSDD",i)); //The name of the output file.
-#ifndef __DECCXX
-    outfile.open(fileName,ios::binary);
-#else
-    outfile.open(fileName);
-#endif
+    outfile = new AliFstream(fileName);
     //write Dummy DATA HEADER
-    UInt_t dataHeaderPosition=outfile.tellp();
-    outfile.write((char*)(&header),sizeof(header));
+    UInt_t dataHeaderPosition=outfile->Tellp();
+    outfile->WriteBuffer((char*)(&header),sizeof(header));
 
     //first 9 "dummy" words to be skipped
     for(Int_t iw=0;iw<9;iw++){
-       outfile.write((char*)&skippedword,sizeof(skippedword));
+       outfile->WriteBuffer((char*)(&skippedword),sizeof(skippedword));
     }
    
     //Loops over Modules of a particular DDL
@@ -625,19 +614,18 @@ Int_t AliITSDDLRawData::RawDataSDD(TBranch* branch){
        //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.write((char *)buf,((fIndex+1)*sizeof(UInt_t)));
+       outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t)));
        fIndex=-1;
       }//end if
     }//end for
     
     //Write REAL DATA HEADER
-    UInt_t currentFilePosition=outfile.tellp();
-    outfile.seekp(dataHeaderPosition);
+    UInt_t currentFilePosition=outfile->Tellp();
+    outfile->Seekp(dataHeaderPosition);
     header.fSize=currentFilePosition-dataHeaderPosition;
     header.SetAttribute(0);  // valid data
-    outfile.write((char*)(&header),sizeof(header));
-
-    outfile.close();
+    outfile->WriteBuffer((char*)(&header),sizeof(header));
+    delete outfile;
   }//end for
 
   return 0;  
index bdad782..32aaae9 100644 (file)
@@ -31,6 +31,7 @@
 #include "AliPMDRawStream.h"
 #include "AliPMDDDLRawData.h"
 #include "AliDAQ.h"
+#include "AliFstream.h"
 
 ClassImp(AliPMDDDLRawData)
 
@@ -72,7 +73,7 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
 {
   // write digits into raw data format
 
-  ofstream outfile;
+  AliFstream *outfile;
 
   TBranch *branch = treeD->GetBranch("PMDDigit");
   if (!branch)
@@ -106,11 +107,8 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
   for(Int_t iddl = 0; iddl < kDDL; iddl++)
     {
       strcpy(filename,AliDAQ::DdlFileName("PMD",iddl));
-#ifndef __DECCXX
-      outfile.open(filename,ios::binary);
-#else
-      outfile.open(filename);
-#endif
+      
+      outfile = new AliFstream(filename);
       
       if (iddl < 4)
        {
@@ -131,8 +129,8 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
 
 
       // Write the Dummy Data Header into the file
-      Int_t bHPosition = outfile.tellp();
-      outfile.write((char*)(&header),sizeof(header));
+      Int_t bHPosition = outfile->Tellp();
+      outfile->WriteBuffer((char*)(&header),sizeof(header));
 
       for (Int_t ibus = 0; ibus < 50; ibus++)
        {
@@ -240,7 +238,7 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
              dspBlockHeaderWord[2] = (UInt_t) dspBlockBRDL;
            }
 
-         outfile.write((char*)dspBlockHeaderWord,kblHLen*sizeof(UInt_t));
+         outfile->WriteBuffer((char*)dspBlockHeaderWord,kblHLen*sizeof(UInt_t));
 
          if (iblock == 0)
            {
@@ -285,7 +283,7 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
              dspHeaderWord[2] = dspRDL;
              dspHeaderWord[3] = dspno;
              if (remainder == 1) dspHeaderWord[8] = 1; // setting the padding word
-             outfile.write((char*)dspHeaderWord,kdspHLen*sizeof(UInt_t));
+             outfile->WriteBuffer((char*)dspHeaderWord,kdspHLen*sizeof(UInt_t));
 
              for (Int_t ibus = 0; ibus < 5; ibus++)
                {
@@ -309,7 +307,7 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
                    }
 
 
-                 outfile.write((char*)patchBusHeaderWord,4*sizeof(UInt_t));
+                 outfile->WriteBuffer((char*)patchBusHeaderWord,4*sizeof(UInt_t));
 
 
                  for (Int_t iword = 0; iword < patchbusRDL; iword++)
@@ -317,7 +315,7 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
                      buffer[iword] = busPatch[busno][iword];
                    }
                  
-                 outfile.write((char*)buffer,patchbusRDL*sizeof(UInt_t));
+                 outfile->WriteBuffer((char*)buffer,patchbusRDL*sizeof(UInt_t));
 
                } // End of patch bus loop
 
@@ -326,7 +324,7 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
              if (remainder == 1)
                {
                  UInt_t paddingWord = dspHeader.GetDefaultPaddingWord();
-                 outfile.write((char*)(&paddingWord),sizeof(UInt_t));
+                 outfile->WriteBuffer((char*)(&paddingWord),sizeof(UInt_t));
                }
            }
        }
@@ -335,16 +333,16 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
       // take the pointer to the beginning of the data header
       // write the total number of words per ddl and bring the
       // pointer to the current file position and close it
-      UInt_t cFPosition = outfile.tellp();
+      UInt_t cFPosition = outfile->Tellp();
       sizeRawData = cFPosition - bHPosition - sizeof(header);
 
       header.fSize = cFPosition - bHPosition;
       header.SetAttribute(0);  // valid data
-      outfile.seekp(bHPosition);
-      outfile.write((char*)(&header),sizeof(header));
-      outfile.seekp(cFPosition);
+      outfile->Seekp(bHPosition);
+      outfile->WriteBuffer((char*)(&header),sizeof(header));
+      outfile->Seekp(cFPosition);
 
-      outfile.close();
+      delete outfile;
     } // DDL Loop over
 
 
index 83d59bc..e55fa57 100644 (file)
@@ -28,6 +28,7 @@
 #include "AliRawDataHeader.h"
 #include "AliLog.h"
 #include "AliDAQ.h"
+#include "AliFstream.h"
 
 ClassImp(AliCTPRawData)
 ////////////////////////////////////////////////////////////////////////////////////////
@@ -86,17 +87,13 @@ void AliCTPRawData::RawData()
   char  fileName[15];
   strcpy(fileName,AliDAQ::DdlFileName("TRG",0));
   AliInfo(Form("Storing CTP raw data in %s",fileName));
-  ofstream outfile;         // logical name of the output file 
- #ifndef __DECCXX
-    outfile.open(fileName,ios::binary);
-#else
-    outfile.open(fileName);
-#endif
+  AliFstream* outfile;         // logical name of the output file 
+  outfile = new AliFstream(fileName);
 
   AliRawDataHeader header;
   // Write a dummy header
-  UInt_t dataHeaderPosition=outfile.tellp();
-  outfile.write((char*)(&header),sizeof(header));
+  UInt_t dataHeaderPosition=outfile->Tellp();
+  outfile->WriteBuffer((char*)(&header),sizeof(header));
 
   // Writing CTP raw data here
   // The format is taken as in
@@ -113,18 +110,18 @@ void AliCTPRawData::RawData()
   word |= 0 << 13; // BlockID = 0 in case of CTP readout
   word |= bunchCross & 0xFFF;
   AliDebug(1,Form("CTP word1 = 0x%x",word));
-  outfile.write((char*)(&word),sizeof(UInt_t));
+  outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
 
   word = 0;
   word |= 0 << 13; // BlockID = 0 in case of CTP readout
   word |= (orbitId >> 12) & 0xFFF;
   AliDebug(1,Form("CTP word2 = 0x%x",word));
-  outfile.write((char*)(&word),sizeof(UInt_t));
+  outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
   word = 0;
   word |= 0 << 13; // BlockID = 0 in case of CTP readout
   word |= orbitId & 0xFFF;
   AliDebug(1,Form("CTP word3 = 0x%x",word));
-  outfile.write((char*)(&word),sizeof(UInt_t));
+  outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
 
   // Now the 4th word
   word = 0;
@@ -134,38 +131,38 @@ void AliCTPRawData::RawData()
   word |= (l2cluster & 0x3F) << 2; // L2Cluster
   word |= (UInt_t)((l2class >> 48) & 0x3);
   AliDebug(1,Form("CTP word4 = 0x%x",word));
-  outfile.write((char*)(&word),sizeof(UInt_t));
+  outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
 
   // Then the last 4 words with the trigger classes
   word = 0;
   word |= 0 << 13; // BlockID = 0 in case of CTP readout
   word |= (UInt_t)((l2class >> 36) & 0xFFF);
   AliDebug(1,Form("CTP word5 = 0x%x",word));
-  outfile.write((char*)(&word),sizeof(UInt_t));
+  outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
   word = 0;
   word |= 0 << 13; // BlockID = 0 in case of CTP readout
   word |= (UInt_t)((l2class >> 24) & 0xFFF);
   AliDebug(1,Form("CTP word6 = 0x%x",word));
-  outfile.write((char*)(&word),sizeof(UInt_t));
+  outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
   word = 0;
   word |= 0 << 13; // BlockID = 0 in case of CTP readout
   word |= (UInt_t)((l2class >> 12) & 0xFFF);
   AliDebug(1,Form("CTP word7 = 0x%x",word));
-  outfile.write((char*)(&word),sizeof(UInt_t));
+  outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
   word = 0;
   word |= 0 << 13; // BlockID = 0 in case of CTP readout
   word |= (UInt_t)(l2class & 0xFFF);
   AliDebug(1,Form("CTP word8 = 0x%x",word));
-  outfile.write((char*)(&word),sizeof(UInt_t));
+  outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
 
   // Write the real data header
-  UInt_t currentFilePosition=outfile.tellp();
-  outfile.seekp(dataHeaderPosition);
+  UInt_t currentFilePosition=outfile->Tellp();
+  outfile->Seekp(dataHeaderPosition);
   header.fSize=currentFilePosition-dataHeaderPosition;
   header.SetAttribute(0);  // valid data
   header.SetTriggerClass(l2class);
-  outfile.write((char*)(&header),sizeof(header));
-  outfile.close();
+  outfile->WriteBuffer((char*)(&header),sizeof(header));
+  delete outfile;
 
   return;
 }
index 41983d8..a897ffd 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.18  2007/05/21 13:26:19  decaro
+Correction on matching_window control and bug fixing (R.Preghenella)
+
 Revision 1.17  2007/05/10 09:29:34  hristov
 Last moment fixes and changes from v4-05-Release (Silvia)
 
@@ -80,6 +83,7 @@ Revision 0.01  2004/6/11 A.De Caro, S.B.Sellitto, R.Silvestri
 #include "AliTOFdigit.h"
 #include "AliTOFGeometry.h"
 #include "AliTOFRawStream.h"
+#include "AliFstream.h"
 
 extern TRandom *gRandom;
 
@@ -179,7 +183,7 @@ Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch)
   fTOFdigitArray = * (TClonesArray**) branch->GetAddress();
 
   char fileName[15];
-  ofstream outfile;         // logical name of the output file 
+  AliFstream* outfile;         // logical name of the output file 
 
   //AliRawDataHeader header;
   AliRawDataHeaderSim header;
@@ -202,17 +206,13 @@ Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch)
   for (nDDL=0; nDDL<AliDAQ::NumberOfDdls("TOF"); nDDL++) {
 
     strcpy(fileName,AliDAQ::DdlFileName("TOF",nDDL)); //The name of the output file
-#ifndef __DECCXX
-    outfile.open(fileName,ios::binary);
-#else
-    outfile.open(fileName);
-#endif
 
+    outfile = new AliFstream(fileName);
     iDDL = fTOFrawStream->GetDDLnumberPerSector(nDDL);
 
     // write Dummy DATA HEADER
-    UInt_t dataHeaderPosition = outfile.tellp();
-    outfile.write((char*)(&header),sizeof(header));
+    UInt_t dataHeaderPosition = outfile->Tellp();
+    outfile->WriteBuffer((char*)(&header),sizeof(header));
 
     // DRM section: trailer
     MakeDRMtrailer(buf);
@@ -264,21 +264,21 @@ Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch)
 
     ReverseArray(buf, fIndex+1);
 
-    outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t)));
+    outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t)));
 
     for (jj=0; jj<(fIndex+1); jj++) buf[jj]=0;
     fIndex = -1;
     
     //Write REAL DATA HEADER
-    UInt_t currentFilePosition = outfile.tellp();
+    UInt_t currentFilePosition = outfile->Tellp();
     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->Seekp(dataHeaderPosition);
+    outfile->WriteBuffer((char*)(&header),sizeof(header));
+    outfile->Seekp(currentFilePosition);
 
-    outfile.close();
+    delete outfile;
 
   } //end loop on DDL file number
 
index 54aed2d..1cb00bf 100644 (file)
@@ -36,6 +36,7 @@
 #include "AliTRDRawStream.h"
 
 #include "AliTRDcalibDB.h"
+#include "AliFstream.h"
 
 ClassImp(AliTRDrawData)
 
@@ -161,16 +162,12 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager)
     char name[1024];
     sprintf(name,"TRD_%d.ddl",sect + AliTRDRawStream::kDDLOffset);
 
-#ifndef __DECCXX
-    ofstream *of = new ofstream(name, ios::binary);
-#else
-    ofstream *of = new ofstream(name);
-#endif
+    AliFstream* of = new AliFstream(name);
 
     // Write a dummy data header
     AliRawDataHeader  header;  // the event header
-    UInt_t hpos = of->tellp();
-    of->write((char *) (& header), sizeof(header));
+    UInt_t hpos = of->Tellp();
+    of->WriteBuffer((char *) (& header), sizeof(header));
 
     // Reset payload byte size (payload does not include header).
     Int_t npayloadbyte = 0;
@@ -185,7 +182,7 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager)
        if ( AliTRDcalibDB::Instance()->GetChamberStatus(iDet) )
          GtuCdh = GtuCdh | (3 << (2*plan));
       }
-      of->write((char *) (& GtuCdh), sizeof(GtuCdh));
+      of->WriteBuffer((char *) (& GtuCdh), sizeof(GtuCdh));
       npayloadbyte += 4;
     }
 
@@ -203,25 +200,23 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager)
 
         // Process A side of the chamber
        if ( fRawVersion >= 1 && fRawVersion <= 2 ) hcwords = ProduceHcDataV1andV2(digits,0,iDet,hc_buffer,kMaxHcWords);
-        of->write((char *) hc_buffer, hcwords*4);
+        of->WriteBuffer((char *) hc_buffer, hcwords*4);
         npayloadbyte += hcwords*4;
 
         // Process B side of the chamber
        if ( fRawVersion >= 1 && fRawVersion <= 2 ) hcwords = ProduceHcDataV1andV2(digits,1,iDet,hc_buffer,kMaxHcWords);
-        of->write((char *) hc_buffer, hcwords*4);
+        of->WriteBuffer((char *) hc_buffer, hcwords*4);
         npayloadbyte += hcwords*4;
 
       }
     }
 
     // Complete header
-    header.fSize = UInt_t(of->tellp()) - hpos;
+    header.fSize = UInt_t(of->Tellp()) - hpos;
     header.SetAttribute(0);  // Valid data
-    of->seekp(hpos);         // Rewind to header position
-    of->write((char *) (& header), sizeof(header));
-    of->close();
+    of->Seekp(hpos);         // Rewind to header position
+    of->WriteBuffer((char *) (& header), sizeof(header));
     delete of;
-
   }
 
   delete hc_buffer;
index cf7ed03..3a1e736 100644 (file)
@@ -47,15 +47,11 @@ AliVZEROBuffer::AliVZEROBuffer(const char* fileName):TObject(),
     fNumberOfDigits(0)
 {
   // Constructor
-#ifndef __DECCXX
-  f.open(fileName,ios::binary|ios::out);
-#else
-  f.open(fileName,ios::out);
-#endif
+  f = new AliFstream(fileName);
   // fout=new TFile(fileName,"recreate");
   // tree=new TTree("tree","Values");
   AliRawDataHeader header;
-  f.write((char*)(&header), sizeof(header));
+  f->WriteBuffer((char*)(&header), sizeof(header));
 
 }
 
@@ -63,11 +59,11 @@ AliVZEROBuffer::AliVZEROBuffer(const char* fileName):TObject(),
 AliVZEROBuffer::~AliVZEROBuffer(){
   // Destructor, it closes the IO stream
   AliRawDataHeader header;
-  header.fSize = f.tellp();
+  header.fSize = f->Tellp();
   header.SetAttribute(0);  // valid data
-  f.seekp(0);
-  f.write((char*)(&header), sizeof(header));
-  f.close();
+  f->Seekp(0);
+  f->WriteBuffer((char*)(&header), sizeof(header));
+  delete f;
   //delete tree;
   //delete fout;
 }
@@ -110,7 +106,5 @@ void AliVZEROBuffer::WriteBinary(Int_t cell,Int_t ADC, Int_t Time){
   data.Time = Time;
 
   fNumberOfDigits++;
-  f.write((char*)(&data),sizeof(data));
-
+  f->WriteBuffer((char*)(&data),sizeof(data));
 }
-
index c1c2fa5..a08972e 100644 (file)
@@ -13,6 +13,7 @@ class fstream;
 #include "Riostream.h"
 #endif
 
+#include "AliFstream.h"
 
 class AliVZEROBuffer:public TObject{
 
@@ -29,7 +30,7 @@ public:
   
 private:
   Int_t fVerbose; //Verbosity level: 0-silent, 1:cout msg, 2: txt files for checking
-  fstream f;      //The IO file name
+  AliFstream* f;      //The IO file name
   UInt_t  fNumberOfDigits; //Number of VZERO digits
   ClassDef(AliVZEROBuffer,1)
 };
index 8a6148c..12f8fe5 100644 (file)
@@ -50,6 +50,7 @@
 #include "AliZDCDigitizer.h"
 #include "AliZDCRawStream.h"
 #include "AliZDCCalibData.h"
+#include "AliFstream.h"
 
  
 ClassImp(AliZDC)
@@ -563,11 +564,8 @@ void AliZDC::Digits2Raw()
   // open the output file
   char fileName[30];
   strcpy(fileName,AliDAQ::DdlFileName("ZDC",0));
-#ifndef __DECCXX
-  ofstream file(fileName, ios::binary);
-#else
-  ofstream file(fileName);
-#endif
+
+  AliFstream* file = new AliFstream(fileName);
 
   // write the DDL data header
   AliRawDataHeader header;
@@ -581,22 +579,22 @@ void AliZDC::Digits2Raw()
   printf("sizeof header = %d, ADCHeader2 = %d, ADCData2 = %d, ADCEndBlock = %d\n",
           sizeof(header),sizeof(lADCHeader2),sizeof(lADCData2),sizeof(lADCEndBlock));*/
   header.SetAttribute(0);  // valid data
-  file.write((char*)(&header), sizeof(header));
+  file->WriteBuffer((char*)(&header), sizeof(header));
 
   // write the raw data and close the file
-  file.write((char*) &lADCHeader1, sizeof (lADCHeader1));
-  file.write((char*)(lADCData1), sizeof(lADCData1));
-  file.write((char*) &lADCEndBlock, sizeof(lADCEndBlock));
-  file.write((char*) &lADCHeader2, sizeof (lADCHeader2));
-  file.write((char*)(lADCData2), sizeof(lADCData2));
-  file.write((char*) &lADCEndBlock, sizeof(lADCEndBlock));
-  file.write((char*) &lADCHeader3, sizeof (lADCHeader3));
-  file.write((char*)(lADCData3), sizeof(lADCData3));
-  file.write((char*) &lADCEndBlock, sizeof(lADCEndBlock));
-  file.write((char*) &lADCHeader4, sizeof (lADCHeader4));
-  file.write((char*)(lADCData4), sizeof(lADCData4));
-  file.write((char*) &lADCEndBlock, sizeof(lADCEndBlock));
-  file.close();
+  file->WriteBuffer((char*) &lADCHeader1, sizeof (lADCHeader1));
+  file->WriteBuffer((char*)(lADCData1), sizeof(lADCData1));
+  file->WriteBuffer((char*) &lADCEndBlock, sizeof(lADCEndBlock));
+  file->WriteBuffer((char*) &lADCHeader2, sizeof (lADCHeader2));
+  file->WriteBuffer((char*)(lADCData2), sizeof(lADCData2));
+  file->WriteBuffer((char*) &lADCEndBlock, sizeof(lADCEndBlock));
+  file->WriteBuffer((char*) &lADCHeader3, sizeof (lADCHeader3));
+  file->WriteBuffer((char*)(lADCData3), sizeof(lADCData3));
+  file->WriteBuffer((char*) &lADCEndBlock, sizeof(lADCEndBlock));
+  file->WriteBuffer((char*) &lADCHeader4, sizeof (lADCHeader4));
+  file->WriteBuffer((char*)(lADCData4), sizeof(lADCData4));
+  file->WriteBuffer((char*) &lADCEndBlock, sizeof(lADCEndBlock));
+  delete file;
 
   // unload the digits
   fLoader->UnloadDigits();