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__
#define __CUtilities__
//
......@@ -65,6 +66,15 @@ class UtilVector_c
char *GetPointer()const{
return fPt;
}
//_______________________________________________________________________________
char GetValue(int i){
return (((char* )fPt)[i]);
}
//_______________________________________________________________________________
void SetValue(int i, char c){
((char* )fPt)[i] = c;
}
//_______________________________________________________________________________
int GetSize() const{
return fSize;
......
......@@ -24,11 +24,13 @@ MFMReaGenericFrame::MFMReaGenericFrame(){
fEnergy = NULL;
fTime = NULL;
fNumberOfBoards =0;
fInitTabValuesDone = false;
}
//_______________________________________________________________________________
MFMReaGenericFrame::~MFMReaGenericFrame(){
int card;
int card=0;
if (fInitTabValuesDone==false)return;
for (card=0;card<fNumberOfBoards;card++){
if (fStatus1[card]!=NULL) delete[] fStatus1[card];
if (fStatus2[card]!=NULL) delete[] fStatus2[card];
......@@ -41,7 +43,6 @@ MFMReaGenericFrame::~MFMReaGenericFrame(){
if (fTypeTNS!=NULL) delete[] fTypeTNS;
if (fEnergy !=NULL) delete[] fEnergy;
if (fTime !=NULL) delete[] fTime;
}
//_______________________________________________________________________________
......@@ -194,11 +195,13 @@ string MFMReaGenericFrame::GetStat(string info)const {
//_______________________________________________________________________________
void MFMReaGenericFrame::InitTabValues(uint16_t *listofboards,int numberofboards){
// method to init tab for analyse and use to fill TTree
int board =0, channel=0;
fNumberOfBoards = numberofboards;
fInitTabValuesDone = true;
for(board =0; board< NUMEXO_MAX_NUMB_BOARDS ;board ++) {
fConvertNoBoardIndex[board] =0;
fConvertIndexNoBoard[board] =0;
fConvertNoBoardIndex[board] = 0;
fConvertIndexNoBoard[board] = 0;
}
if (fEnergy == NULL) fEnergy = new uint16_t*[fNumberOfBoards];
if (fTime == NULL) fTime = new uint16_t*[fNumberOfBoards];
......@@ -214,19 +217,21 @@ void MFMReaGenericFrame::InitTabValues(uint16_t *listofboards,int numberofboard
fTypeTNS[board] = new uint16_t[NUMEXO_NB_CHANNELS];
fStatus1[board] = new uint16_t[NUMEXO_NB_CHANNELS];
fStatus2[board] = new uint16_t[NUMEXO_NB_CHANNELS];
}
ResetTabValues();
}
//_______________________________________________________________________________
void MFMReaGenericFrame::ResetTabValues(){
if (fInitTabValuesDone==false)return;
int board =0, channel=0;
fTabValueEventNumber=0;
fTabValueTimeStamp=0;
fChannel =0;
fBoardNumber=0;
fBoardIndex=0;
for (board=0 ; board< fNumberOfBoards; board++){
for (channel=0 ; channel< NUMEXO_NB_CHANNELS; channel++){
fEnergy[board][channel] = 0;
......@@ -245,12 +250,18 @@ void MFMReaGenericFrame::SetTabValues(){
fTabValueEventNumber = GetEventNumber();
fTabValueTimeStamp = GetTimeStamp();
fBoardIndex = fConvertNoBoardIndex[fBoardNumber];
if (fInitTabValuesDone==false)return;
if ((fNumberOfBoards>fBoardIndex)and ( fNumberOfBoards >fChannel)){
fEnergy[fBoardIndex][fChannel] = GetEnergy();
fTime[fBoardIndex][fChannel] = GetTime();
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 {
if (GetEventNumber() == 0xFFFFFFFF) {
ss << "No Event , so no event dump. Get a new event frame";
} else {
ss << " E = "<<GetEnergy()<<" T = "<< GetTime() ;
}
display = ss.str();
......
......@@ -48,11 +48,11 @@ class MFMReaGenericFrame : public MFMNumExoFrame
uint16_t **fStatus1, **fStatus2, **fTypeTNS,**fEnergy,**fTime;
uint32_t fTabValueEventNumber;
uint64_t fTabValueTimeStamp;
bool fInitTabValuesDone ; // init of Tab/Values for root Tree convertion
int fNumberOfBoards; //sum of board
int fBoardNumber; //current number of board
int fBoardIndex; //current index of board
int fChannel; //current number of channel
// attributes to do convertion between index and number of board
int fConvertNoBoardIndex[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
int fNbFramesDump; // no of frame to the dump if dump is asked
uint32_t fEventNumber;
int fNbItems ;
int fVerbose ;
int fFormat ;
int fNbOfEvent ;
......@@ -180,9 +179,9 @@ int main(int argc, char **argv) {
fS3eGUNframe = new MFMS3eGUNFrame();
fS3Synchroframe = new MFMS3SynchroFrame();
fReaGenericframe = new MFMReaGenericFrame();
uint16_t tabcard[1];
tabcard[0]=112;
fReaGenericframe -> InitTabValues(tabcard,1);
uint16_t tabcard[1]; // this is given in example
tabcard[0]=112; // this is given in example
//fReaGenericframe -> InitTabValues(tabcard,1); // this is given in example
fReaTraceframe = new MFMReaTraceFrame();
fSiriusframe = new MFMSiriusFrame();
fDeflectorframe = new MFMS3DeflectorFrame();
......@@ -296,8 +295,9 @@ int main(int argc, char **argv) {
if (fLun <= 0) {
Error.TreatError(2, 0, "Error open file :", filename);
}
cout << endl;
cout << "-------------------------------------------------------------" << endl;
cout << " MFMtest " << endl;
cout << " MFMtest " << " version : " << MFM_VERSION << endl;
cout << "| READ MFMFrame from file : " << filename << "" << endl;
cout << "-------------------------------------------------------------" << endl;
cout << endl;
......@@ -366,6 +366,7 @@ int main(int argc, char **argv) {
cout << endl;
cout << "-------------------------------------------------------------"
<< endl;
cout << "| MFMtest " << " version : " << MFM_VERSION << endl;
cout << "| TEST MFMFrame in extract mode from file " << filename << "" << endl;
cout << "-------------------------------------------------------------"<< endl;
......@@ -482,6 +483,7 @@ int main(int argc, char **argv) {
if (fPatternMode==true) {
cout << endl;
cout << "-------------------------------------------------------------"<< endl;
cout << "| MFMtest " << " version : " << MFM_VERSION << endl;
cout << "| TEST MFMFrame in Pattern mode from file " << filename << "" << endl;
cout << "-------------------------------------------------------------"<< endl;
......@@ -645,7 +647,6 @@ void deletefunction(){
if (fDeflectorframe) delete (fDeflectorframe) ;
}
//_______________________________________________________________________________________________________________________
void PrintQuestion() {
cout << "Which Frame you want to generate?\n";
......@@ -700,8 +701,9 @@ void Announce(char* progname){
}
//_______________________________________________________________________________________________________________________
void Help() {
cout
<< "MFMtest.exe : utility to generate and use MFM frame in different formats \n";
cout<< endl;
cout << " MFMtest " << " Version : " << MFM_VERSION << endl;
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";
......
#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