]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Converts Digits in Memory to Altro like back linked list and stores them
authorloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Apr 2002 08:21:53 +0000 (08:21 +0000)
committerloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Apr 2002 08:21:53 +0000 (08:21 +0000)
in Hexadezimal 16 Bit numbers. Ascii or Binary files are supported.

HLT/misc/AliL3AltroMemHandler.cxx [new file with mode: 0644]
HLT/misc/AliL3AltroMemHandler.h [new file with mode: 0644]

diff --git a/HLT/misc/AliL3AltroMemHandler.cxx b/HLT/misc/AliL3AltroMemHandler.cxx
new file mode 100644 (file)
index 0000000..c5f4883
--- /dev/null
@@ -0,0 +1,130 @@
+/* $Id$
+Author: Constantin Loizides <mailto: loizides@ikf.physik.uni-frankfurt.de>
+*/
+
+#include <iostream.h>
+#include <stdio.h>
+#include <string.h>
+#include "AliL3AltroMemHandler.h"
+
+AliL3AltroMemHandler::AliL3AltroMemHandler(){
+  Clear();
+};
+
+Bool_t AliL3AltroMemHandler::Write(UShort_t row, UChar_t pad, UShort_t charge, UShort_t time)
+{
+  Bool_t redo=kFALSE;
+
+  if((counter==0)||(tcounter==0)){ //new package or new sequence
+    ltime=time;
+    lpad=pad;
+    lrow=row;
+    altromem[counter]=charge;
+    counter++;
+    tcounter++;
+  } else if ((row==lrow)&&(pad==lpad)) {
+    if(time-ltime==1){ //add charge to sequence
+      ltime=time;
+      altromem[counter]=charge;
+      counter++;
+      tcounter++;
+
+      if(counter==MAX_VALS){
+       WriteFinal();
+       Clear();
+      }    
+    } else { //finish old sequence
+      altromem[counter]=ltime;
+      counter++;
+      altromem[counter]=tcounter+2;
+      counter++;
+
+      //start new sequence
+      if(counter==MAX_VALS){ 
+       WriteTrailer();
+       Clear();
+      } else tcounter=0;
+      
+      redo=kTRUE; 
+    }
+  } else { //finish old package
+    WriteFinal();
+    Clear();
+
+    //start new package
+    redo=kTRUE;
+  }
+
+  if(redo==kTRUE) Write(row,pad,charge,time);
+  return kTRUE;
+};
+
+void AliL3AltroMemHandler::Clear(){
+  memset(altromem,0,ALTRO_SIZE);
+  counter=0;
+  tcounter=0;
+  lpad=0;
+  ltime=0;
+  lrow=0;
+  flag=kFALSE;
+};
+
+Bool_t AliL3AltroMemHandler::WriteFinal(){
+ if(counter>0){
+   altromem[counter]=ltime;
+   counter++;
+   altromem[counter]=tcounter+2;
+   counter++;
+   WriteTrailer();
+ }
+ return kTRUE;
+}
+
+void AliL3AltroMemHandler::WriteTrailer(){
+
+  UShort_t savecounter=counter;
+  while(counter%4!=0){
+    altromem[counter]=0x2AA;
+    counter++;
+  } 
+  altromem[counter++]=0x2AA;
+  altromem[counter++]=savecounter;
+  altromem[counter++]=lpad;
+  altromem[counter++]=lrow;
+
+  UShort_t *ptr=altromem+counter;
+  for (int i=0;i<counter;i++) {
+    ptr--;
+    if(flag==kTRUE) fwrite(ptr,sizeof(UShort_t),1,fOutBinary);
+    else fprintf(fOutBinary,"%X ",*ptr);
+  }
+  if(flag==kFALSE) fprintf(fOutBinary,"\n");
+
+}
+
+/*
+Bool_t AliL3AltroMemHandler::SetBinaryInput(FILE *file){
+  fInBinary = file;
+  if(!fInBinary){
+    //LOG(AliL3Log::kWarning,"AliL3AltroMem::SetBinaryInput","File Open")<<"Pointer to File = 0x0 "<<ENDLOG;
+    return kFALSE;
+  }
+  return kTRUE;
+}
+*/
+
+Bool_t AliL3AltroMemHandler::SetBinaryOutput(FILE *file){
+  fOutBinary = file;
+  if(!fOutBinary){
+    LOG(AliL3Log::kWarning,"AliL3AltroMemHandler::SetBinaryOutput","File Open") <<"Pointer to File = 0x0 "<<ENDLOG;
+    return kFALSE;
+  }
+  return kTRUE;
+}
+
+
+
+
+
+
+
diff --git a/HLT/misc/AliL3AltroMemHandler.h b/HLT/misc/AliL3AltroMemHandler.h
new file mode 100644 (file)
index 0000000..4bca40d
--- /dev/null
@@ -0,0 +1,55 @@
+/* $id$
+Author: Constantin Loizides <mailto: loizides@ikf.physik.uni-frankfurt.de>
+*/
+
+#ifndef ALIL3ALTROMEMHANDLER_H
+#define ALIL3ALTROMEMHANDLER_H
+
+#include "AliL3RootTypes.h"
+#include "AliL3Logging.h"
+
+//Maximum Size of Altro Packet equals 1000 Bit
+#define ALTRO_SIZE 125
+//Maximum 10Bit ADCs to be stored in one Packet
+#define MAX_VALS 94
+
+class AliL3AltroMemHandler {
+
+  public: 
+   AliL3AltroMemHandler();
+   Bool_t Write(UShort_t row, UChar_t pad, UShort_t charge, UShort_t time);
+   Bool_t WriteFinal();
+   Bool_t SetBinaryOutput(FILE *file);
+   //Bool_t SetBinaryInput(FILE *file);
+   void SetBinary(Bool_t flag_=kTRUE){flag=flag_;};
+
+  private:
+   UShort_t altromem[ALTRO_SIZE];
+   //FILE *fInBinary;
+   FILE *fOutBinary;
+   UShort_t lrow;
+   UChar_t lpad;
+   UShort_t ltime;
+   UShort_t counter;
+   UShort_t tcounter;
+   Bool_t flag;
+   void WriteTrailer();
+   void Clear();
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+