Commit 050faf13 authored by LEGEARD Luc's avatar LEGEARD Luc
Browse files

Remove a bug in MFMtest with usage of MFMReaGenericFrame

parent 2d8cd7c4
#include <stdlib.h>
#ifndef __CUtilities__ #ifndef __CUtilities__
#define __CUtilities__ #define __CUtilities__
// //
...@@ -65,6 +66,15 @@ class UtilVector_c ...@@ -65,6 +66,15 @@ class UtilVector_c
char *GetPointer()const{ char *GetPointer()const{
return fPt; return fPt;
} }
//_______________________________________________________________________________
char GetValue(int i){
return (((char* )fPt)[i]);
}
//_______________________________________________________________________________
void SetValue(int i, char c){
((char* )fPt)[i] = c;
}
//_______________________________________________________________________________ //_______________________________________________________________________________
int GetSize() const{ int GetSize() const{
return fSize; return fSize;
......
...@@ -24,11 +24,13 @@ MFMReaGenericFrame::MFMReaGenericFrame(){ ...@@ -24,11 +24,13 @@ MFMReaGenericFrame::MFMReaGenericFrame(){
fEnergy = NULL; fEnergy = NULL;
fTime = NULL; fTime = NULL;
fNumberOfBoards =0; fNumberOfBoards =0;
fInitTabValuesDone = false;
} }
//_______________________________________________________________________________ //_______________________________________________________________________________
MFMReaGenericFrame::~MFMReaGenericFrame(){ MFMReaGenericFrame::~MFMReaGenericFrame(){
int card; int card=0;
if (fInitTabValuesDone==false)return;
for (card=0;card<fNumberOfBoards;card++){ for (card=0;card<fNumberOfBoards;card++){
if (fStatus1[card]!=NULL) delete[] fStatus1[card]; if (fStatus1[card]!=NULL) delete[] fStatus1[card];
if (fStatus2[card]!=NULL) delete[] fStatus2[card]; if (fStatus2[card]!=NULL) delete[] fStatus2[card];
...@@ -41,7 +43,6 @@ MFMReaGenericFrame::~MFMReaGenericFrame(){ ...@@ -41,7 +43,6 @@ MFMReaGenericFrame::~MFMReaGenericFrame(){
if (fTypeTNS!=NULL) delete[] fTypeTNS; if (fTypeTNS!=NULL) delete[] fTypeTNS;
if (fEnergy !=NULL) delete[] fEnergy; if (fEnergy !=NULL) delete[] fEnergy;
if (fTime !=NULL) delete[] fTime; if (fTime !=NULL) delete[] fTime;
} }
//_______________________________________________________________________________ //_______________________________________________________________________________
...@@ -194,11 +195,13 @@ string MFMReaGenericFrame::GetStat(string info)const { ...@@ -194,11 +195,13 @@ string MFMReaGenericFrame::GetStat(string info)const {
//_______________________________________________________________________________ //_______________________________________________________________________________
void MFMReaGenericFrame::InitTabValues(uint16_t *listofboards,int numberofboards){ void MFMReaGenericFrame::InitTabValues(uint16_t *listofboards,int numberofboards){
// method to init tab for analyse and use to fill TTree // method to init tab for analyse and use to fill TTree
int board =0, channel=0; int board =0, channel=0;
fNumberOfBoards = numberofboards; fNumberOfBoards = numberofboards;
fInitTabValuesDone = true;
for(board =0; board< NUMEXO_MAX_NUMB_BOARDS ;board ++) { for(board =0; board< NUMEXO_MAX_NUMB_BOARDS ;board ++) {
fConvertNoBoardIndex[board] =0; fConvertNoBoardIndex[board] = 0;
fConvertIndexNoBoard[board] =0; fConvertIndexNoBoard[board] = 0;
} }
if (fEnergy == NULL) fEnergy = new uint16_t*[fNumberOfBoards]; if (fEnergy == NULL) fEnergy = new uint16_t*[fNumberOfBoards];
if (fTime == NULL) fTime = new uint16_t*[fNumberOfBoards]; if (fTime == NULL) fTime = new uint16_t*[fNumberOfBoards];
...@@ -213,13 +216,14 @@ void MFMReaGenericFrame::InitTabValues(uint16_t *listofboards,int numberofboard ...@@ -213,13 +216,14 @@ void MFMReaGenericFrame::InitTabValues(uint16_t *listofboards,int numberofboard
fTime[board] = new uint16_t[NUMEXO_NB_CHANNELS]; fTime[board] = new uint16_t[NUMEXO_NB_CHANNELS];
fTypeTNS[board] = new uint16_t[NUMEXO_NB_CHANNELS]; fTypeTNS[board] = new uint16_t[NUMEXO_NB_CHANNELS];
fStatus1[board] = new uint16_t[NUMEXO_NB_CHANNELS]; fStatus1[board] = new uint16_t[NUMEXO_NB_CHANNELS];
fStatus2[board] = new uint16_t[NUMEXO_NB_CHANNELS]; fStatus2[board] = new uint16_t[NUMEXO_NB_CHANNELS];
} }
ResetTabValues(); ResetTabValues();
} }
//_______________________________________________________________________________ //_______________________________________________________________________________
void MFMReaGenericFrame::ResetTabValues(){ void MFMReaGenericFrame::ResetTabValues(){
if (fInitTabValuesDone==false)return;
int board =0, channel=0; int board =0, channel=0;
fTabValueEventNumber=0; fTabValueEventNumber=0;
...@@ -227,13 +231,14 @@ int board =0, channel=0; ...@@ -227,13 +231,14 @@ int board =0, channel=0;
fChannel =0; fChannel =0;
fBoardNumber=0; fBoardNumber=0;
fBoardIndex=0; fBoardIndex=0;
for (board=0 ; board< fNumberOfBoards; board++){ for (board=0 ; board< fNumberOfBoards; board++){
for (channel=0 ; channel< NUMEXO_NB_CHANNELS; channel++){ for (channel=0 ; channel< NUMEXO_NB_CHANNELS; channel++){
fEnergy[board][channel] = 0; fEnergy[board][channel] = 0;
fTime[board][channel] = 0; fTime[board][channel] = 0;
fTypeTNS[board][channel] = 0; fTypeTNS[board][channel] = 0;
fStatus1[board][channel] = 0; fStatus1[board][channel] = 0;
fStatus2[board][channel] = 0; fStatus2[board][channel] = 0;
} }
} }
} }
...@@ -244,13 +249,19 @@ void MFMReaGenericFrame::SetTabValues(){ ...@@ -244,13 +249,19 @@ void MFMReaGenericFrame::SetTabValues(){
fBoardNumber = GetBoardId(); fBoardNumber = GetBoardId();
fTabValueEventNumber = GetEventNumber(); fTabValueEventNumber = GetEventNumber();
fTabValueTimeStamp = GetTimeStamp(); fTabValueTimeStamp = GetTimeStamp();
fBoardIndex = fConvertNoBoardIndex[fBoardNumber]; fBoardIndex = fConvertNoBoardIndex[fBoardNumber];
fEnergy[fBoardIndex][fChannel] = GetEnergy(); if (fInitTabValuesDone==false)return;
fTime[fBoardIndex][fChannel] = GetTime(); if ((fNumberOfBoards>fBoardIndex)and ( fNumberOfBoards >fChannel)){
fTypeTNS[fBoardIndex][fChannel] = GetTypeTns(); fEnergy[fBoardIndex][fChannel] = GetEnergy();
fStatus1[fBoardIndex][fChannel] = GetStatus(0); fTime[fBoardIndex][fChannel] = GetTime();
fStatus2[fBoardIndex][fChannel] = GetStatus(1); fTypeTNS[fBoardIndex][fChannel] = GetTypeTns();
fStatus1[fBoardIndex][fChannel] = GetStatus(0);
fStatus2[fBoardIndex][fChannel] = GetStatus(1);
} else {
cout << "Warning , index of card or No Channel to big \n";
cout <<dec <<" BoardIndex = "<<fBoardIndex << " <-> NumberOfBoards = "<<fNumberOfBoards<<"\n";
cout <<" ChannelIndex = "<<fChannel << " <-> NUMEXO_NB_CHANNELS = "<<NUMEXO_NB_CHANNELS<<"\n";
}
} }
//_______________________________________________________________________________ //_______________________________________________________________________________
...@@ -275,7 +286,6 @@ string MFMReaGenericFrame::GetDumpData(char mode, bool nozero) const { ...@@ -275,7 +286,6 @@ string MFMReaGenericFrame::GetDumpData(char mode, bool nozero) const {
if (GetEventNumber() == 0xFFFFFFFF) { if (GetEventNumber() == 0xFFFFFFFF) {
ss << "No Event , so no event dump. Get a new event frame"; ss << "No Event , so no event dump. Get a new event frame";
} else { } else {
ss << " E = "<<GetEnergy()<<" T = "<< GetTime() ; ss << " E = "<<GetEnergy()<<" T = "<< GetTime() ;
} }
display = ss.str(); display = ss.str();
......
...@@ -48,11 +48,11 @@ class MFMReaGenericFrame : public MFMNumExoFrame ...@@ -48,11 +48,11 @@ class MFMReaGenericFrame : public MFMNumExoFrame
uint16_t **fStatus1, **fStatus2, **fTypeTNS,**fEnergy,**fTime; uint16_t **fStatus1, **fStatus2, **fTypeTNS,**fEnergy,**fTime;
uint32_t fTabValueEventNumber; uint32_t fTabValueEventNumber;
uint64_t fTabValueTimeStamp; uint64_t fTabValueTimeStamp;
bool fInitTabValuesDone ; // init of Tab/Values for root Tree convertion
int fNumberOfBoards; //sum of board int fNumberOfBoards; //sum of board
int fBoardNumber; //current number of board int fBoardNumber; //current number of board
int fBoardIndex; //current index of board int fBoardIndex; //current index of board
int fChannel; //current number of channel int fChannel; //current number of channel
// attributes to do convertion between index and number of board // attributes to do convertion between index and number of board
int fConvertNoBoardIndex[NUMEXO_MAX_NUMB_BOARDS]; int fConvertNoBoardIndex[NUMEXO_MAX_NUMB_BOARDS];
int fConvertIndexNoBoard[NUMEXO_MAX_NUMB_BOARDS]; int fConvertIndexNoBoard[NUMEXO_MAX_NUMB_BOARDS];
......
...@@ -67,7 +67,6 @@ int fNbFramesStart;// no of frame to start the dump if dump is asked ...@@ -67,7 +67,6 @@ int fNbFramesStart;// no of frame to start the dump if dump is asked
int fNbFramesDump; // no of frame to the dump if dump is asked int fNbFramesDump; // no of frame to the dump if dump is asked
uint32_t fEventNumber; uint32_t fEventNumber;
int fNbItems ; int fNbItems ;
int fVerbose ; int fVerbose ;
int fFormat ; int fFormat ;
int fNbOfEvent ; int fNbOfEvent ;
...@@ -137,7 +136,7 @@ int main(int argc, char **argv) { ...@@ -137,7 +136,7 @@ int main(int argc, char **argv) {
fNbFramesDump = 0; fNbFramesDump = 0;
fVerbose = 5; fVerbose = 5;
fNbItems =-1; // if -1 , we leave frame to get its defined value fNbItems =-1; // if -1 , we leave frame to get its defined value
fExpSize =-1; fExpSize =-1;
fExpType=-1; fExpType=-1;
fExpEndian=-1; fExpEndian=-1;
...@@ -180,9 +179,9 @@ int main(int argc, char **argv) { ...@@ -180,9 +179,9 @@ int main(int argc, char **argv) {
fS3eGUNframe = new MFMS3eGUNFrame(); fS3eGUNframe = new MFMS3eGUNFrame();
fS3Synchroframe = new MFMS3SynchroFrame(); fS3Synchroframe = new MFMS3SynchroFrame();
fReaGenericframe = new MFMReaGenericFrame(); fReaGenericframe = new MFMReaGenericFrame();
uint16_t tabcard[1]; uint16_t tabcard[1]; // this is given in example
tabcard[0]=112; tabcard[0]=112; // this is given in example
fReaGenericframe -> InitTabValues(tabcard,1); //fReaGenericframe -> InitTabValues(tabcard,1); // this is given in example
fReaTraceframe = new MFMReaTraceFrame(); fReaTraceframe = new MFMReaTraceFrame();
fSiriusframe = new MFMSiriusFrame(); fSiriusframe = new MFMSiriusFrame();
fDeflectorframe = new MFMS3DeflectorFrame(); fDeflectorframe = new MFMS3DeflectorFrame();
...@@ -296,8 +295,9 @@ int main(int argc, char **argv) { ...@@ -296,8 +295,9 @@ int main(int argc, char **argv) {
if (fLun <= 0) { if (fLun <= 0) {
Error.TreatError(2, 0, "Error open file :", filename); Error.TreatError(2, 0, "Error open file :", filename);
} }
cout << endl;
cout << "-------------------------------------------------------------" << endl; cout << "-------------------------------------------------------------" << endl;
cout << " MFMtest " << endl; cout << " MFMtest " << " version : " << MFM_VERSION << endl;
cout << "| READ MFMFrame from file : " << filename << "" << endl; cout << "| READ MFMFrame from file : " << filename << "" << endl;
cout << "-------------------------------------------------------------" << endl; cout << "-------------------------------------------------------------" << endl;
cout << endl; cout << endl;
...@@ -366,6 +366,7 @@ int main(int argc, char **argv) { ...@@ -366,6 +366,7 @@ int main(int argc, char **argv) {
cout << endl; cout << endl;
cout << "-------------------------------------------------------------" cout << "-------------------------------------------------------------"
<< endl; << endl;
cout << "| MFMtest " << " version : " << MFM_VERSION << endl;
cout << "| TEST MFMFrame in extract mode from file " << filename << "" << endl; cout << "| TEST MFMFrame in extract mode from file " << filename << "" << endl;
cout << "-------------------------------------------------------------"<< endl; cout << "-------------------------------------------------------------"<< endl;
...@@ -482,6 +483,7 @@ int main(int argc, char **argv) { ...@@ -482,6 +483,7 @@ int main(int argc, char **argv) {
if (fPatternMode==true) { if (fPatternMode==true) {
cout << endl; cout << endl;
cout << "-------------------------------------------------------------"<< endl; cout << "-------------------------------------------------------------"<< endl;
cout << "| MFMtest " << " version : " << MFM_VERSION << endl;
cout << "| TEST MFMFrame in Pattern mode from file " << filename << "" << endl; cout << "| TEST MFMFrame in Pattern mode from file " << filename << "" << endl;
cout << "-------------------------------------------------------------"<< endl; cout << "-------------------------------------------------------------"<< endl;
...@@ -639,13 +641,12 @@ void deletefunction(){ ...@@ -639,13 +641,12 @@ void deletefunction(){
delete (fS3eGUNframe); delete (fS3eGUNframe);
if (fS3Synchroframe) if (fS3Synchroframe)
delete (fS3Synchroframe); delete (fS3Synchroframe);
if (fReaGenericframe) delete (fReaGenericframe); if (fReaGenericframe) delete (fReaGenericframe);
if (fReaTraceframe ) delete (fReaTraceframe); if (fReaTraceframe ) delete (fReaTraceframe);
if (fSiriusframe) delete (fSiriusframe) ; if (fSiriusframe) delete (fSiriusframe) ;
if (fDeflectorframe) delete (fDeflectorframe) ; if (fDeflectorframe) delete (fDeflectorframe) ;
} }
//_______________________________________________________________________________________________________________________ //_______________________________________________________________________________________________________________________
void PrintQuestion() { void PrintQuestion() {
cout << "Which Frame you want to generate?\n"; cout << "Which Frame you want to generate?\n";
...@@ -700,9 +701,10 @@ void Announce(char* progname){ ...@@ -700,9 +701,10 @@ void Announce(char* progname){
} }
//_______________________________________________________________________________________________________________________ //_______________________________________________________________________________________________________________________
void Help() { void Help() {
cout cout<< endl;
<< "MFMtest.exe : utility to generate and use MFM frame in different formats \n"; cout << " MFMtest " << " Version : " << MFM_VERSION << endl;
cout << " The generated frames are stored in a file \n"; cout << " Utility to generate and use MFM frame in different formats \n";
cout << " The generated frames are stored in a file \n";
cout << " Usage : \n"; cout << " Usage : \n";
cout << " MFMtest.exe [-h] or [--help] , print this help \n"; cout << " MFMtest.exe [-h] or [--help] , print this help \n";
......
#define MFM_VERSION "21.02.01" #define MFM_VERSION "21.03.XX"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment