]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCBuffer.cxx
Fixed some coding convention violations
[u/mrichter/AliRoot.git] / TPC / AliTPCBuffer.cxx
index 43525a3bd58a5a5728cd7423d1ebdc7c365b864d..99b499382d3496633f54ec62c512b376143b024d 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
+/* $Id$ */
 
-#include "Riostream.h"
-#include "TObjArray.h"
+// Storing digits in a binary file
+// according to the DDL mapping
+// To be used in Alice Data Challenges
+// This class is used by AliTPCDDL.C macro
+// Author: D.Favretto
+
+#include <Riostream.h>
+#include <TObjArray.h>
 #include "AliTPCBuffer.h"
 #include "AliSimDigits.h"
 
 
 ClassImp(AliTPCBuffer)
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
-AliTPCBuffer::AliTPCBuffer(const char* fileName){
+AliTPCBuffer::AliTPCBuffer(const char* /*fileName*/){
+  // Constructor
+#ifndef __DECCXX
   f.open("AliTPCDDL.dat",ios::binary|ios::out);
+#else
+  f.open("AliTPCDDL.dat",ios::out);
+#endif
   // fout=new TFile(fileName,"recreate");
   // tree=new TTree("tree","Values");
-  NumberOfDigits=0;
+  fNumberOfDigits=0;
   fVerbose=0;
+  remove("TPCdigits.txt");
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 AliTPCBuffer::~AliTPCBuffer(){
+  // The destructor closes the IO stream
   f.close();
   //delete tree;
   //delete fout;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
-AliTPCBuffer::AliTPCBuffer(const AliTPCBuffer &source){
+AliTPCBuffer::AliTPCBuffer(const AliTPCBuffer &source):TObject(source){
   // Copy Constructor
+  this->fVerbose=source.fVerbose;
   return;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 AliTPCBuffer& AliTPCBuffer::operator=(const AliTPCBuffer &source){
   //Assigment operator
+  this->fVerbose=source.fVerbose;
   return *this;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -72,20 +88,20 @@ void AliTPCBuffer::WriteRow(Int_t eth,AliSimDigits *digrow,Int_t minPad,Int_t ma
       switch (flag){
       case 0:{
        tree->Fill();
-       NumberOfDigits++;
+       fNumberOfDigits++;
        break;
       }//end case 0
       case 1:{
          if((Pad>=minPad)&&(Pad<=maxPad)){
            tree->Fill();
-           NumberOfDigits++;
+           fNumberOfDigits++;
          }
        break;
       }//end case 1
       case 2:{
        if((Pad<minPad)||(Pad>maxPad)){
          tree->Fill();
-         NumberOfDigits++;
+         fNumberOfDigits++;
        }
        break;
       }//end case 2
@@ -98,9 +114,11 @@ void AliTPCBuffer::WriteRow(Int_t eth,AliSimDigits *digrow,Int_t minPad,Int_t ma
 */
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void AliTPCBuffer::WriteRowBinary(Int_t eth,AliSimDigits *digrow,Int_t minPad,Int_t maxPad,Int_t flag,Int_t sec,Int_t SubSec,Int_t row){
-  //flag=0 the whole row is written intto the file
+  //It writes TPC digits as par the flag specifications. Being called by AliTPCDDL.C
+  //flag=0 the whole row is written into the file
   //flag=1 only value in the range [minPad,MaxPasd] are written into the file
   //flag=2 complementary case of 1
+
   struct DataPad{
     Int_t Sec;
     Int_t SubSec;
@@ -114,34 +132,57 @@ void AliTPCBuffer::WriteRowBinary(Int_t eth,AliSimDigits *digrow,Int_t minPad,In
   data.SubSec=SubSec;
   data.Row=row;
   digrow->First();
+  Int_t padID=-1;
+  Int_t ddlNumber=0;
+  ofstream ftxt;
+  if (fVerbose==2){
+    ftxt.open("TPCdigits.txt",ios::app);
+    if(sec<36)
+      ddlNumber=sec*2+SubSec;
+    else
+      ddlNumber=72+(sec-36)*4+SubSec;
+  }//end if
   do{
-    data.Dig=digrow->CurrentDigit(); //adc
-    data.Time=digrow->CurrentRow(); //time
-    data.Pad =digrow->CurrentColumn(); // pad 
+    data.Dig=digrow->CurrentDigit();    //adc
+    data.Time=digrow->CurrentRow();     //time
+    data.Pad =digrow->CurrentColumn();  // pad 
+    if(fVerbose==2)
+      if (padID!=data.Pad){
+       ftxt<<"S:"<<data.Sec<<" DDL:"<<ddlNumber<<" R:"<<data.Row<<" P:"<<data.Pad<<endl;
+       padID=data.Pad;
+      }//end if
     if(data.Dig>eth){
       switch (flag){
       case 0:{
-       NumberOfDigits++;
+       fNumberOfDigits++;
        f.write((char*)(&data),sizeof(data));
+       if(fVerbose==2)
+         ftxt<<"A:"<<data.Dig<<" T:"<<data.Time<<endl; 
        break;
       }//end case 0
       case 1:{
        if((data.Pad>=minPad)&&(data.Pad<=maxPad)){
          f.write((char*)(&data),sizeof(data));
-         NumberOfDigits++;
+         if(fVerbose==2)
+           ftxt<<"A:"<<data.Dig<<" T:"<<data.Time<<endl; 
+         fNumberOfDigits++;
        }
        break;
       }//end case 1
       case 2:{
        if((data.Pad<minPad)||(data.Pad>maxPad)){
          f.write((char*)(&data),sizeof(data));
-         NumberOfDigits++;
+         if(fVerbose==2)
+           ftxt<<"A:"<<data.Dig<<" T:"<<data.Time<<endl; 
+         fNumberOfDigits++;
        }
        break;
       }//end case 2
       };//end switch
     }//end if
   }while (digrow->Next());
+  if (fVerbose==2)
+    ftxt.close();
   return;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////