]> jspc29.x-matter.uni-frankfurt.de Git - mvd_soft.git/commitdiff
add makefile
authorSamir Amar-Youcef <samir@ikf>
Mon, 23 Mar 2015 09:09:29 +0000 (10:09 +0100)
committerSamir Amar-Youcef <samir@ikf>
Mon, 23 Mar 2015 09:09:29 +0000 (10:09 +0100)
s-curves/cpp_sam/Makefile [new file with mode: 0644]
s-curves/cpp_sam/main.C [new file with mode: 0644]
s-curves/cpp_sam/run.C [deleted file]
s-curves/cpp_sam/rungui.C [deleted file]
s-curves/cpp_sam/unpacker.C
s-curves/cpp_sam/unpacker.h

diff --git a/s-curves/cpp_sam/Makefile b/s-curves/cpp_sam/Makefile
new file mode 100644 (file)
index 0000000..a31dd25
--- /dev/null
@@ -0,0 +1,16 @@
+CC=g++
+CFLAGS=-c -g -Wall -std=c++11 `root-config --cflags`
+LDFLAGS=`root-config --glibs`
+CLDFLAGS = -std=c++11 `root-config --cflags --glibs` -lboost_system -lboost_filesystem 
+SOURCES= main.C unpacker.C unpacker.h help.h header.h
+OBJECTS=$(subst .cc,.o,$(SOURCES))
+EXECUTABLE=unpacker
+
+all: $(SOURCES) $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+       $(CC) $(CLDFLAGS) $(OBJECTS) -o $@
+
+
+clean:
+       rm -f $(OBJS)
\ No newline at end of file
diff --git a/s-curves/cpp_sam/main.C b/s-curves/cpp_sam/main.C
new file mode 100644 (file)
index 0000000..8fba989
--- /dev/null
@@ -0,0 +1,22 @@
+// #include "TApplication.h"
+#include <sstream>
+#include <TString.h>
+#include "unpacker.h"
+#include "TROOT.h"
+
+//####################################################################
+
+
+int main(int argc, char** argv) {
+       
+       gROOT->Reset();
+       
+       TString         Dir;
+       TString         File;
+       
+       if (argc>1) { Dir       = argv[1]; }
+       if (argc>2) { File      = argv[2]; }
+       
+       unpacker* a=new unpacker(Dir, File);
+       delete a;
+}
\ No newline at end of file
diff --git a/s-curves/cpp_sam/run.C b/s-curves/cpp_sam/run.C
deleted file mode 100644 (file)
index fb6782f..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "unpacker.C"
-
-void run()
-{
-//     unpacker* a=new unpacker("/local/samir/data/normalmode/","60s_blank.hld");
-       
-       
-       unpacker* a=new unpacker("/local/samir/data","te15036113837");
-//     unpacker* a=new unpacker("/local/samir/data","te15021111151");
-
-       
-//     unpacker* a=new unpacker("/local/samir/data","te15021111151.hld");
-//     unpacker* a=new unpacker("/local/samir/data","test");
-//     unpacker* a=new unpacker("/local/samir/data","test.hld");
-       delete a;
-}
\ No newline at end of file
diff --git a/s-curves/cpp_sam/rungui.C b/s-curves/cpp_sam/rungui.C
deleted file mode 100755 (executable)
index 937efa5..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "config.h"
-#include "unpack.C"
-
-
-//####################################################################
-
-void rungui()
-{
-       unpacker* a=new unpacker("/local/samir/data/te15021111151.hld");
-       a->scanFrames(0,10000000);
-       delete a;
-
-}
\ No newline at end of file
index 8979de111a0ca151f12fbb9e12d72341a09cfc32..3b938253bd924e0777898850c62ab5aa2a679317 100644 (file)
@@ -5,9 +5,10 @@
 
 //-----------------
 #include "unpacker.h"
+#include "header.h"
 
 #include <dirent.h>
-#include <help.h>
+// #include <help.h>
 // #include <time.h>
 // #include <sys/stat.h>
 //-----------------
 unpacker::unpacker(TString Dir, TString File)  {
        
        fPixelProb      = new Float_t   [1152*576];
-       fRowCount       = new UInt_t    [576];
+       fRowCount       = new UShort_t  [576];
        for(int i=0;i<1152*576;i++)     {       fPixelProb      [i]=0;  }
        for(int i=0;i<576;i++)          {       fRowCount       [i]=0;  }
        
 //     fWrongRowNumber = 0;
        fWrongRunNumber = 0;
-       fWrongThreshold = 0;
        fHeaderVer              = 0;
        
        fRunNumber_tmp  = 0;
@@ -38,6 +38,16 @@ unpacker::unpacker(TString Dir, TString File)  {
        
 // Init
        if( !openFiles(Dir, File) )     { cerr << "ERROR: No Files found!" << endl << "-- Exit --" << endl; exit(-1);   }
+       
+       if( fDataTree==0 )
+       {
+               cout<<"\r Tree started:  "<<fOutFileName<<"                                    "<<endl;
+               fOutFile = new TFile(fOutFileName,"RECREATE");
+               fDataTree = new TTree("scurvesall", "scurvesall");
+               fDataTree->Branch("threshold"   , &fThreshold_tmp       , "threshold/s"                 , 32000);
+               fDataTree->Branch("pixelprob"   ,  fPixelProb           , "pixelprob[663552]/F" , 32000);
+               fDataTree->Branch("frames"              ,  fRowCount            , "frames[576]/s"               , 32000);
+       }
        scanFiles();
        
 }
@@ -78,20 +88,20 @@ void unpacker::scanFiles() {
        int     subEventNr              = 0;
        int     subSubEventNr   = 0;
        
-       UInt_t HDRver;
+//     UInt_t HDRver;
        UInt_t DATAver          = 0;
 //     UInt_t HDRsize;
        
 // Progress bar
-//     ULong_t progress_tmp=-1;
-//     Float_t         progress;
+       ULong_t progress_tmp=-1;
+       Float_t         progress;
        
        while( getNextEvent()           !=0 ) { eventNr++;              subEventNr              = 0;
        while( getNextSubEvent()        !=0 ) { subEventNr++;   subSubEventNr   = 0;
        while( getNextSubSubEvent()     !=0 ) { subSubEventNr++;
 // Progress bar
-//     progress = (Int_t)(((fPosGlo)*100.)/(fLength-1)*1);
-//     if(progress!=progress_tmp)      { print_progress( (((fPosGlo)*100.)/(fLength-1)) ); progress_tmp=progress; }
+       progress = (Int_t)(((fPosGlo)*100.)/(fLength-1)*1);
+       if(progress!=progress_tmp)      { print_progress( (((fPosGlo)*100.)/(fLength-1)) ); progress_tmp=progress; }
 // --------------------
 // fRawData                    : allocates the event data
 // fPosInData          : points to the position of the subsubevent in the data, beginning with the subsubevent hld-header
@@ -99,32 +109,30 @@ void unpacker::scanFiles() {
 // --------------------
                if(fSubSubEventSize>4)
                {
-                       HDRver  = bigEndian8(fRawData,fPosInData+4);
-                       DATAver = bigEndian8(fRawData,fPosInData+5);
+//                     HDRver  = bigEndian8(fRawData,fPosInData+4);
+//                     DATAver = bigEndian8(fRawData,fPosInData+5);
 //                     HDRsize = bigEndian8(fRawData,fPosInData+7);
                        
-                       if              ( DATAver==0x01)
-                       {
-                               
-                       }
-                       else if ( DATAver==0x02 )
-                       {
-                               
-                       }
-                       else if ( DATAver==0xC0 )
-                       {
-                               if( !fHeaderVer && fSubSubEventSize==164 )      { fHeaderVer=1; cout<<"\r 'Frame Timestamp' missing in Header! Sub-Sub-Event Length: "<<fSubSubEventSize/4<<"                  "<<endl; }
+//                     if              ( DATAver==0x01)
+//                     {
+//                     }
+//                     else if ( DATAver==0x02 )
+//                     {
+//                     }
+//                     else if ( DATAver==0xC0 )
+//                     {
+//                             if( !fHeaderVer && fSubSubEventSize==164 )      { fHeaderVer=1; cout<<"\r 'Frame Timestamp' missing in Header! Sub-Sub-Event Length: "<<fSubSubEventSize/4<<"                  "<<endl; }
                                anaScurves();
-                       }
+//                     }
                }
                
 //     }}if(eventNr==600){exit(-1);}}
        }}}
 
-       if( DATAver==0xC0 )
-       {
+//     if( DATAver==0xC0 )
+//     {
                saveScurveData();
-       }
+//     }
        
        cout<<"----------"<<endl;
        cout<<"Fertig!"<<endl;
@@ -135,10 +143,10 @@ void unpacker::scanFiles() {
 
 void unpacker::anaScurves()    {
        
-       UInt_t Threshold        = bigEndian8 (fRawData,fPosInData+16);
+       UShort_t Threshold      = (UShort_t) (bigEndian8 (fRawData,fPosInData+16));
        UInt_t Bank                     = (fRawData[fPosInData+17]>>4) & 0xF;
        UInt_t Row                      = ((Int_t)(UChar_t)fRawData[fPosInData+17]& 0xF)*TMath::Power(2,8) +  (Int_t)(UChar_t)fRawData[fPosInData+18];
-       UInt_t RunNumber        = bigEndian8 (fRawData,fPosInData+19);
+//     UInt_t RunNumber        = bigEndian8 (fRawData,fPosInData+19);
        UInt_t Data;
        
 //     cout<<Threshold<<"\t"<<Bank<<"\t"<<Row<<"\t"<<RunNumber<<"\t"<<endl;
@@ -171,18 +179,11 @@ void unpacker::anaScurves()       {
        
        fFirstOut = 1;
 // -------------------------------
-// Check: whether next threshold starts after one whole frame
-       if( fRow_count!=0 && fThreshold_tmp!=Threshold )
-       {
-               if( !fWrongThreshold )
-               {
-                       fWrongThreshold=1; cout<<"\r Wrong Threshold changing(s) found!                                    "<<endl;
-               }
-       }
-// -------------------------------
 // Fill: fPixelProb array
        for(UInt_t dataword=0; dataword<36; dataword++)
        {
+               if( dataword>=9*Bank && dataword<9*(Bank+1) )
+               {       
                Data    = bigEndian32 (fRawData,fPosInData+20+dataword);
                
                if                      (Data == 0)
@@ -192,28 +193,24 @@ void unpacker::anaScurves()       {
                {
                        for(int pixel=0;pixel<32;pixel++)
                        {
-                               fPixelProb[1152*(fRow_count+1)+32*dataword+pixel ] ++;
+                               fPixelProb[1152*(Row)+32*dataword+pixel ] ++;
                        }
                }
                else
                {
                        for(int pixel=0;pixel<32;pixel++)
                        {
-                               fPixelProb[1152*(fRow_count+1)+32*dataword+pixel ] += (Data & 0x1);
+                               fPixelProb[1152*(Row)+32*dataword+pixel ] += (Data & 0x1);
                                Data >>= 1;
                        }
                }
+               }
        }
        
-       fRowCount[fRow_count]++;
+       fRowCount[Row]++;
+//     cout<<Row<<"\t"<<fRowCount[Row]<<endl;
        
-       fRunNumber_tmp  = RunNumber;
-//     fRow_tmp                = Row;
-       fThreshold_tmp  = Threshold;
-       if( fRow_count==0 ) { fRunNumber_count++; }
-       
-       fRow_count++;
-       fRow_count = fRow_count%575;
+       fThreshold_tmp = Threshold;
        
 //     cout<<setw(10)<<right<<         Bank;
 //     cout<<setw(10)<<right<<         Threshold;
@@ -226,16 +223,6 @@ void unpacker::anaScurves()        {
 
 void unpacker::saveScurveData()        {
        
-       if( fDataTree==0 )
-       {
-               cout<<"\r Tree started:  "<<fOutFileName<<"                                    "<<endl;
-               fOutFile = new TFile(fOutFileName,"RECREATE");
-               fDataTree = new TTree("scurvesall", "scurvesall");
-               fDataTree->Branch("threshold"   , &fThreshold_tmp       , "threshold/s"                 , 32000);
-               fDataTree->Branch("pixelprob"   ,  fPixelProb           , "pixelprob[663552]/F" , 32000);
-               fDataTree->Branch("frames"              ,  fRowCount            , "frames[576]/s"               , 32000);
-       }
-       
        for(int row=0;row<576;row++)
        {
                for(int col=0;col<1152;col++)
@@ -248,6 +235,10 @@ void unpacker::saveScurveData()    {
 //                             cout<<setw(25)<<setprecision(5)<<right<< fRowCount[row];
 //                             cout<<endl;
                        }
+                       else
+                       {
+                               fPixelProb[1152*row+col] = 0;
+                       }
                }
        }
        
@@ -534,5 +525,44 @@ UInt_t unpacker::bigEndian8(char* RawData, Int_t Pos) {
        (Int_t)(UChar_t)RawData[0+Pos];
 }
 
+//####################################################################
+
+Int_t unpacker::print_progress(Float_t ProgressInPercent) {
+       
+       Int_t nCharacter = printf("\r [");
+       Int_t iBlock;
+       
+       for( iBlock=0; iBlock<ProgressInPercent/2; ++iBlock )
+       {
+               putchar( '=' );
+               nCharacter++;
+       }
+       
+       for( ; iBlock<100/2; ++iBlock )
+       {
+               putchar( ' ' );
+               nCharacter++;
+       }
+       
+//     Int_t sec       = TimeInSec%60;
+//     Int_t min       = TimeInSec/60;
+//     Int_t hours     = TimeInSec/3600;
+       
+       nCharacter += printf( "] %4.0f%%", ProgressInPercent);
+       fflush( stdout );
+       
+       if((Int_t)ProgressInPercent==100) 
+       {
+               printf("\r");
+               for(Int_t i=0; i<nCharacter; i++)
+               {
+                       putchar( ' ' );
+               }
+               printf("\r ... done! \n");
+       }
+       
+       return nCharacter;
+}
+
 //####################################################################
 #endif
\ No newline at end of file
index f667cf714745ddbd4fa2bfc132584575585c4e83..4cc242940d246602813fedb7ccdc20d58957d3ce 100644 (file)
@@ -1,4 +1,23 @@
-#include <header.h>
+//-----------------
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#define SAVE                           4
+#define ENDING                         "hld"
+#define CONTENTIN                      1048576                                 // --> 1 MByte
+#define BUFSIZE                                32000
+#define MAXSENSORS                     64
+#define MAXSTATES                      1140
+#define MAXCLUSTERS                    1140
+#endif
+//-----------------
+
+// #include <header.h>
+#include <dirent.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <vector>
+#include "help.h"
 
 class unpacker {
        
@@ -28,15 +47,14 @@ private:
        UInt_t          fPaddingSub;
        
        Float_t*        fPixelProb;
-       UInt_t*         fRowCount;
+       UShort_t*       fRowCount;
        UInt_t          fRunNumber_count;
        UInt_t          fRunNumber_tmp;
        UInt_t          fRow_count;
        UInt_t          fRow_tmp;
-       UInt_t          fThreshold_tmp;
+       UShort_t        fThreshold_tmp;
        
        bool            fWrongRowNumber;
-       bool            fWrongThreshold;
        bool            fWrongRunNumber;
        bool            fFirstOut;
        bool            fHeaderVer;
@@ -51,11 +69,12 @@ private:
        UInt_t  getNextSubEvent         ();
        UInt_t  getNextSubSubEvent      ();
        
-       UInt_t littleEndian32           (char* RawData, Int_t Pos);
-       UInt_t bigEndian32                      (char* RawData, Int_t Pos);
-       UInt_t bigEndian24                      (char* RawData, Int_t Pos);
-       UInt_t bigEndian16                      (char* RawData, Int_t Pos);
-       UInt_t bigEndian8                       (char* RawData, Int_t Pos);
+       UInt_t  littleEndian32          (char* RawData, Int_t Pos);
+       UInt_t  bigEndian32                     (char* RawData, Int_t Pos);
+       UInt_t  bigEndian24                     (char* RawData, Int_t Pos);
+       UInt_t  bigEndian16                     (char* RawData, Int_t Pos);
+       UInt_t  bigEndian8                      (char* RawData, Int_t Pos);
+       Int_t   print_progress          (Float_t ProgressInPercent);
        
 public:
 //     Methods