//-----------------
#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;
// 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();
}
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
// --------------------
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;
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;
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)
{
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;
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++)
// cout<<setw(25)<<setprecision(5)<<right<< fRowCount[row];
// cout<<endl;
}
+ else
+ {
+ fPixelProb[1152*row+col] = 0;
+ }
}
}
(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