Commit c9bb0551 authored by J.Dudouet [IPNL/CSNSM]'s avatar J.Dudouet [IPNL/CSNSM]
Browse files

DIAMANTWatchers: improvement of the Print method

EventDIAMANTWatchers : Add TS by hit and improvement of the Print method
EventNEDAWatchers : Add TS by hit and improvement of the Print method
NEDAWatchers : improvement of the Print method
StartOfflineWatchers : Add the possibility to set a number of loop



git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@2257 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent 13a9d31a
......@@ -140,6 +140,10 @@ void DIAMANTWatchers::Print(const char * /* option */ ) const
std::cout<<"Number of treated events : "<<fNEvts<<std::endl;
cout<<"Stat per board (and \% per channel):"<<endl;
cout<<setw(28)<<"";
for(int i=0 ; i<MaxChannel ; i++)
cout<<left<<setw(8)<<i;
cout<<endl;
for (auto& kv : fStatPerBoard)
{
......@@ -149,9 +153,26 @@ void DIAMANTWatchers::Print(const char * /* option */ ) const
if(avector[MaxChannel]>0)
{
cout<<"Board id "<<Form("%3.1d",board)<<" : "<<Form("%9.3g",(Float_t)avector[MaxChannel])<<" (";
for(int ich=0 ; ich<MaxChannel-1 ; ich++)
cout<<Form("%5.1f ; ",(double)avector[ich]/avector[MaxChannel]*100.);
cout<<Form("%5.1f )",(double)avector[MaxChannel-1]/avector[MaxChannel]*100.)<<endl;
for(int ich=0 ; ich<MaxChannel ; ich++)
{
float_t ratio = (double)avector[ich]/avector[MaxChannel]*100.;
BashColor::BColor Color = BashColor::kBlack;
if(ratio<5) Color = BashColor::kWhite;
else if(ratio<10) Color = BashColor::kCyan;
else if(ratio<15) Color = BashColor::kBlue;
else if(ratio<20) Color = BashColor::kPurple;
else Color = BashColor::kRed;
fBashColor->SetColor(Color);
if(ich<MaxChannel-1)
cout<<Form("%5.1f ; ",(double)avector[ich]/avector[MaxChannel]*100.);
else
cout<<Form("%5.1f )",(double)avector[ich]/avector[MaxChannel]*100.)<<endl;
fBashColor->ResetColor();
}
}
}
......
......@@ -92,10 +92,137 @@ MFMDiamantFrame *EventDIAMANTWatchers::GetMFM(UInt_t which)
// ((ADF::RawFrame *)fSubFrame)->RawBuffer().Address();
fMFMFrame->SetAttributs(((ADF::RawFrame *)fSubFrame)->RawBuffer().Address());
if(fMFMFrame->GetTimeStamp() != ((AgataKey *)fSubFrame->GetKey())->GetTimeStamp())
{
fBashColor->SetWarningOut();
cout<<"ADF and MFM timestamps not equal !"<<endl;
cout<<"ADF : "<<((AgataKey *)fSubFrame->GetKey())->GetTimeStamp()<<endl;
cout<<"MFM : "<<fMFMFrame->GetTimeStamp()<<endl;
cout<<"Board id : "<<fMFMFrame->GetBoardId()<<" ; Channel id : "<<fMFMFrame->GetTGCristalId()<<endl;
fBashColor->ResetColor();
}
return fMFMFrame;
}
void EventDIAMANTWatchers::Exec(Option_t * /*option*/)
{
// be sure the frame has been set properly
if ( fFrame == 0x0 || !fFrame->IsValid() ) {
// cout << "non valid frame" << endl;
return;
}
memset(BoardId ,0,sizeof(UShort_t)*MaxDIAMANT);
memset(ChannelId,0,sizeof(UShort_t)*MaxDIAMANT);
memset(Status1,0,sizeof(Int_t)*MaxDIAMANT);
memset(Status2,0,sizeof(Int_t)*MaxDIAMANT);
memset(Energy ,0,sizeof(Int_t)*MaxDIAMANT);
memset(Top ,0,sizeof(Int_t)*MaxDIAMANT);
memset(PID ,0,sizeof(Float_t)*MaxDIAMANT);
memset(TSHit ,0,sizeof(ULong64_t)*MaxDIAMANT);
fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
UInt_t number_of_frame = GetNbSubFrame(); nbDIAMANT = number_of_frame;
if(nbDIAMANT>MaxDIAMANT)
{
fBashColor->SetWarningOut();
cout<<GetName()<<endl;
cout<<number_of_frame<<" sub frames in event:data:ranc1 ==> maximum is "<<MaxDIAMANT<<endl;
cout<<"Event ignored"<<endl;
fBashColor->ResetColor();
nbDIAMANT=0;
}
for(Int_t i = 0u; i <nbDIAMANT; i++) {
MFMDiamantFrame *mfmframe = GetMFM(i);
if ( mfmframe == 0x0 ){
std::cout << "BUG" << std::endl;
continue;
}
BoardId[i] = mfmframe->GetBoardId();
ChannelId[i] = mfmframe->GetTGCristalId() ;
Status1[i] = mfmframe->GetStatus(0);
Status2[i] = mfmframe->GetStatus(1);
Energy[i] = mfmframe->GetEnergy()/512.;
Top[i] = mfmframe->GetTop()/64.;
TSHit[i] = mfmframe->GetTimeStamp();
if (Top[i] > 0 && Energy[i] > 0)
PID[i] = 1.-Top[i]*1./Energy[i];
if(fStatPerBoard[BoardId[i]].size() == 0)
{
vector< Int_t > avector(MaxChannel+1);
fStatPerBoard[BoardId[i]] = avector;
}
fStatPerBoard[BoardId[i]][MaxChannel]++;
fStatPerBoard[BoardId[i]][ChannelId[i]]++;
}
fNEvts++;
}
void EventDIAMANTWatchers::Print(const char * /* option */ ) const
{
std::cout<<std::endl;
int size = 3 + 3 + ((TString)GetName()).Length() + 5 + ((TString)GetTitle()).Length() + 3 + 3;
for(int i=0; i<size ; i++) std::cout<<"*";
std::cout<<std::endl;
std::cout<<"*** "<<GetName()<<" --- "<<GetTitle()<<" ***"<<std::endl;
for(int i=0; i<size ; i++) std::cout<<"*";
std::cout<<std::endl;
std::cout<<"Number of treated events : "<<fNEvts<<std::endl;
cout<<"Stat per board (and \% per channel):"<<endl;
cout<<setw(28)<<"";
for(int i=0 ; i<MaxChannel ; i++)
cout<<left<<setw(8)<<i;
cout<<endl;
for (auto& kv : fStatPerBoard)
{
Int_t board = kv.first;
vector< Int_t > avector = kv.second;
if(avector[MaxChannel]>0)
{
cout<<"Board id "<<Form("%3.1d",board)<<" : "<<Form("%9.3g",(Float_t)avector[MaxChannel])<<" (";
for(int ich=0 ; ich<MaxChannel ; ich++)
{
float_t ratio = (double)avector[ich]/avector[MaxChannel]*100.;
BashColor::BColor Color = BashColor::kBlack;
if(ratio<5) Color = BashColor::kWhite;
else if(ratio<10) Color = BashColor::kCyan;
else if(ratio<15) Color = BashColor::kBlue;
else if(ratio<20) Color = BashColor::kPurple;
else Color = BashColor::kRed;
fBashColor->SetColor(Color);
if(ich<MaxChannel-1)
cout<<Form("%5.1f ; ",(double)avector[ich]/avector[MaxChannel]*100.);
else
cout<<Form("%5.1f )",(double)avector[ich]/avector[MaxChannel]*100.)<<endl;
fBashColor->ResetColor();
}
}
}
fBashColor->ResetColor();
}
EventDIAMANTSpectra::EventDIAMANTSpectra(const char *name, const char *title, TDirectory *sp_dir, TDirectory *tag_dir):
EventDIAMANTWatchers(name,title,sp_dir,tag_dir),
......@@ -107,11 +234,7 @@ EventDIAMANTSpectra::EventDIAMANTSpectra(const char *name, const char *title, TD
void EventDIAMANTSpectra::Exec(Option_t * /*option*/)
{
// be sure the frame has been set properly
if ( fFrame == 0x0 || !fFrame->IsValid() ) {
// cout << "non valid frame" << endl;
return;
}
EventDIAMANTWatchers::Exec();
UInt_t nb_frames = GetNbSubFrame();
fFold->Fill(nb_frames);
......@@ -155,57 +278,13 @@ void EventDIAMANTTree::SetBranches()
GetTree()->Branch("DIAMANT_Top" ,Top, "DIAMANT_Top[nbDIAMANT]/F" );
GetTree()->Branch("DIAMANT_PID" ,PID, "DIAMANT_PID[nbDIAMANT]/F" );
GetTree()->Branch("TSDIAMANT_Hit" ,TSHit, "TSDIAMANT_Hit[nbDIAMANT]/l" );
GetTree()->Branch("TSDIAMANT", &fTimestamp, "TSDIAMANT/l" );
}
void EventDIAMANTTree::Exec(Option_t * /*option*/)
{
if ( fFrame == 0x0 || !fFrame->IsValid() ) {
SetLastExecStatus(1u);
return;
}
memset(BoardId ,0,sizeof(UShort_t)*MaxDIAMANT);
memset(ChannelId,0,sizeof(UShort_t)*MaxDIAMANT);
memset(Status1,0,sizeof(Int_t)*MaxDIAMANT);
memset(Status2,0,sizeof(Int_t)*MaxDIAMANT);
memset(Energy ,0,sizeof(Int_t)*MaxDIAMANT);
memset(Top ,0,sizeof(Int_t)*MaxDIAMANT);
memset(PID ,0,sizeof(Float_t)*MaxDIAMANT);
fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
UInt_t number_of_frame = GetNbSubFrame(); nbDIAMANT = number_of_frame;
if(nbDIAMANT>MaxDIAMANT)
{
fBashColor->SetWarningOut();
cout<<GetName()<<endl;
cout<<number_of_frame<<" sub frames in event:data:ranc1 ==> maximum is "<<MaxDIAMANT<<endl;
cout<<"Event ignored"<<endl;
fBashColor->ResetColor();
nbDIAMANT=0;
}
for(Int_t i = 0u; i <nbDIAMANT; i++) {
MFMDiamantFrame *mfmframe = GetMFM(i);
if ( mfmframe == 0x0 ){
std::cout << "BUG" << std::endl;
continue;
}
BoardId[i] = mfmframe->GetBoardId();
ChannelId[i] = mfmframe->GetTGCristalId() ;
Status1[i] = mfmframe->GetStatus(0);
Status2[i] = mfmframe->GetStatus(1);
Energy[i] = mfmframe->GetEnergy()/512.;
Top[i] = mfmframe->GetTop()/64.;
if (Top[i] > 0 && Energy[i] > 0)
PID[i] = 1.-Top[i]*1./Energy[i];
}
EventDIAMANTWatchers::Exec();
FillTree();
}
......
......@@ -45,10 +45,13 @@ using namespace Gw;
//! Base Watcher working for any event:data:ranc0
/*!
*/
class EventDIAMANTWatchers : public WatcherWithTag
{
static const Int_t MaxDIAMANT = 96; //6 boards * 16 channels
static const Int_t MaxChannel = 16;
protected:
BashColor *fBashColor;
protected:
......@@ -65,13 +68,26 @@ protected:
UInt_t GetNbSubFrame();
MFMDiamantFrame *GetMFM(UInt_t i);
protected:
Int_t nbDIAMANT;
UShort_t BoardId[MaxDIAMANT], ChannelId[MaxDIAMANT];
UInt_t Status1[MaxDIAMANT], Status2[MaxDIAMANT];
Float_t Energy[MaxDIAMANT], Top[MaxDIAMANT], PID[MaxDIAMANT];
ULong64_t TSHit[MaxDIAMANT];
ULong64_t fTimestamp;
protected:
UInt_t fNEvts = 0;
map< Int_t, vector<Int_t> > fStatPerBoard;
public:
EventDIAMANTWatchers(const char *name, const char *title, TDirectory *sp_dir = 0x0, TDirectory *tag_dir = 0x0) :
WatcherWithTag(name,title,sp_dir,tag_dir),
fBashColor(new BashColor()),
fSubFrame(0x0),
fMFMFrame(new MFMDiamantFrame()),
fFrame(0x0)
fFrame(0x0),
fNEvts(0)
{;}
virtual ~EventDIAMANTWatchers()
{
......@@ -83,6 +99,11 @@ public:
fSubFrame = 0x0;
}
//! watch the current frame
virtual void Exec(Option_t *option="");
virtual void Print(const char *option="") const; //*MENU*
//! Set the trigger attached to this watcher
/*!
look in the list of input Frame one called Agata data:tracked
......@@ -110,15 +131,6 @@ public:
class EventDIAMANTTree : public EventDIAMANTWatchers, public TTreeBuilder
{
static const Int_t MaxDIAMANT = 96; //6 boards * 16 channels
private:
Int_t nbDIAMANT; // Number of hits in the array
UShort_t BoardId[MaxDIAMANT], ChannelId[MaxDIAMANT];
UInt_t Status1[MaxDIAMANT], Status2[MaxDIAMANT];
Float_t Energy[MaxDIAMANT], Top[MaxDIAMANT], PID[MaxDIAMANT];
ULong64_t fTimestamp;
protected:
virtual void SetBranches();
......
......@@ -87,13 +87,138 @@ MFMNedaCompFrame *EventNEDAWatchers::GetMFM(UInt_t which)
printf("EventPSAWatcher::GetDataPSA cannot Read \n");
return 0x0;
}
// return the data interface for that frame
// ((ADF::RawFrame *)fSubFrame)->RawBuffer().Address();
fMFMFrame->SetAttributs(((ADF::RawFrame *)fSubFrame)->RawBuffer().Address());
if(fMFMFrame->GetTimeStamp() != ((AgataKey *)fSubFrame->GetKey())->GetTimeStamp())
{
fBashColor->SetWarningOut();
cout<<"ADF and MFM timestamps not equal !"<<endl;
cout<<"ADF : "<<((AgataKey *)fSubFrame->GetKey())->GetTimeStamp()<<endl;
cout<<"MFM : "<<fMFMFrame->GetTimeStamp()<<endl;
cout<<"Board id : "<<fMFMFrame->GetBoardId()<<" ; Channel id : "<<fMFMFrame->GetChannelId()<<endl;
fBashColor->ResetColor();
}
return fMFMFrame;
}
void EventNEDAWatchers::Exec(Option_t * /*option*/)
{
// be sure the frame has been set properly
if ( fFrame == 0x0 || !fFrame->IsValid() ) {
// cout << "non valid frame" << endl;
return;
}
memset(BoardId,0,sizeof(UShort_t)*MaxNEDA);
memset(ChannelId,0,sizeof(UShort_t)*MaxNEDA);
memset(NEDATdc,0,sizeof(UShort_t)*MaxNEDA);
memset(NEDAFast,0,sizeof(UShort_t)*MaxNEDA);
memset(NEDASlow,0,sizeof(UShort_t)*MaxNEDA);
memset(NEDAZco,0,sizeof(UShort_t)*MaxNEDA);
memset(TSHit ,0,sizeof(ULong64_t)*MaxNEDA);
fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
UInt_t number_of_frame = GetNbSubFrame(); nbNEDA = number_of_frame;
if(nbNEDA>MaxNEDA)
{
fBashColor->SetWarningOut();
cout<<GetName()<<endl;
cout<<number_of_frame<<" sub frames in event:data:ranc0 ==> maximum is "<<MaxNEDA<<endl;
cout<<"Event ignored"<<endl;
fBashColor->ResetColor();
nbNEDA = 0;
}
for(Int_t i = 0u; i <nbNEDA; i++)
{
MFMNedaCompFrame *mfmframe = GetMFM(i);
if ( mfmframe == 0x0 ){
std::cout << "BUG" << std::endl;
continue;
}
BoardId[i] = mfmframe->GetBoardId();
ChannelId[i] = mfmframe->GetChannelId() ;
if(fStatPerBoard[BoardId[i]].size() == 0)
{
vector< Int_t > avector(MaxChannel+1);
fStatPerBoard[BoardId[i]] = avector;
}
fStatPerBoard[BoardId[i]][MaxChannel]++;
fStatPerBoard[BoardId[i]][ChannelId[i]]++;
NEDATdc[i] = mfmframe->GetTdcCorValue();
NEDAFast[i] = mfmframe->GetFastIntegral();
NEDASlow[i] = mfmframe->GetSlowIntegral();
NEDAZco[i] = mfmframe->GetNbZero();
TSHit[i] = mfmframe->GetTimeStamp();
}
fNEvts++;
}
void EventNEDAWatchers::Print(const char * /* option */ ) const
{
std::cout<<std::endl;
int size = 3 + 3 + ((TString)GetName()).Length() + 5 + ((TString)GetTitle()).Length() + 3 + 3;
for(int i=0; i<size ; i++) std::cout<<"*";
std::cout<<std::endl;
std::cout<<"*** "<<GetName()<<" --- "<<GetTitle()<<" ***"<<std::endl;
for(int i=0; i<size ; i++) std::cout<<"*";
std::cout<<std::endl;
std::cout<<"Number of treated events : "<<fNEvts<<std::endl;
cout<<"Stat per board (and \% per channel):"<<endl;
cout<<setw(28)<<"";
for(int i=0 ; i<MaxChannel ; i++)
cout<<left<<setw(8)<<i;
cout<<endl;
for (auto& kv : fStatPerBoard)
{
Int_t board = kv.first;
vector< Int_t > avector = kv.second;
if(avector[MaxChannel]>0)
{
cout<<"Board id "<<Form("%3.1d",board)<<" : "<<Form("%9.3g",(Float_t)avector[MaxChannel])<<" (";
for(int ich=0 ; ich<MaxChannel ; ich++)
{
float_t ratio = (double)avector[ich]/avector[MaxChannel]*100.;
BashColor::BColor Color = BashColor::kBlack;
if(ratio<5) Color = BashColor::kWhite;
else if(ratio<10) Color = BashColor::kCyan;
else if(ratio<15) Color = BashColor::kBlue;
else if(ratio<20) Color = BashColor::kPurple;
else Color = BashColor::kRed;
fBashColor->SetColor(Color);
if(ich<MaxChannel-1)
cout<<Form("%5.1f ; ",(double)avector[ich]/avector[MaxChannel]*100.);
else
cout<<Form("%5.1f )",(double)avector[ich]/avector[MaxChannel]*100.)<<endl;
fBashColor->ResetColor();
}
}
}
fBashColor->ResetColor();
}
EventNEDASpectra::EventNEDASpectra(const char *name, const char *title, TDirectory *sp_dir, TDirectory *tag_dir):
......@@ -106,11 +231,7 @@ EventNEDASpectra::EventNEDASpectra(const char *name, const char *title, TDirecto
void EventNEDASpectra::Exec(Option_t * /*option*/)
{
// be sure the frame has been set properly
if ( fFrame == 0x0 || !fFrame->IsValid() ) {
// cout << "non valid frame" << endl;
return;
}
EventNEDAWatchers::Exec();
UInt_t nb_frames = GetNbSubFrame();
fFold->Fill(nb_frames);
......@@ -153,55 +274,13 @@ void EventNEDATree::SetBranches()
GetTree()->Branch("NEDASlow", NEDASlow, "NEDASlow[nbNEDA]/s" );
GetTree()->Branch("NEDAZco", NEDAZco, "NEDAZco[nbNEDA]/s" );
GetTree()->Branch("TSNEDA_Hit", TSHit, "TSNEDA_Hit[nbNEDA]/l" );
GetTree()->Branch("TSNEDA", &fTimestamp, "TSNeda/l" );
}
void EventNEDATree::Exec(Option_t * /*option*/)
{
if ( fFrame == 0x0 || !fFrame->IsValid() ) {
SetLastExecStatus(1u);
return;
}
memset(BoardId,0,sizeof(UShort_t)*MaxNEDA);
memset(ChannelId,0,sizeof(UShort_t)*MaxNEDA);
memset(NEDATdc,0,sizeof(UShort_t)*MaxNEDA);
memset(NEDAFast,0,sizeof(UShort_t)*MaxNEDA);
memset(NEDASlow,0,sizeof(UShort_t)*MaxNEDA);
memset(NEDAZco,0,sizeof(UShort_t)*MaxNEDA);
fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
UInt_t number_of_frame = GetNbSubFrame(); nbNEDA = number_of_frame;
if(nbNEDA>MaxNEDA)
{
fBashColor->SetWarningOut();
cout<<GetName()<<endl;
cout<<number_of_frame<<" sub frames in event:data:ranc0 ==> maximum is "<<MaxNEDA<<endl;
cout<<"Event ignored"<<endl;
fBashColor->ResetColor();
nbNEDA = 0;
}
for(Int_t i = 0u; i <nbNEDA; i++)
{
MFMNedaCompFrame *mfmframe = GetMFM(i);
if ( mfmframe == 0x0 ){
std::cout << "BUG" << std::endl;
continue;
}
BoardId[i] = mfmframe->GetBoardId();
ChannelId[i] = mfmframe->GetChannelId() ;
NEDATdc[i] = mfmframe->GetTdcCorValue();
NEDAFast[i] = mfmframe->GetFastIntegral();
NEDASlow[i] = mfmframe->GetSlowIntegral();
NEDAZco[i] = mfmframe->GetNbZero();
}
EventNEDAWatchers::Exec();
FillTree();
}
......
......@@ -45,10 +45,13 @@ using namespace Gw;
//! Base Watcher working for any event:data:ranc0
/*!
*/
class EventNEDAWatchers : public WatcherWithTag
{
static const Int_t MaxNEDA = 128; //8 boards * 16 channels
static const Int_t MaxChannel = 16;
protected:
BashColor *fBashColor;
protected:
......@@ -65,13 +68,25 @@ protected:
UInt_t GetNbSubFrame();
MFMNedaCompFrame *GetMFM(UInt_t i);
protected:
Int_t nbNEDA;
UShort_t BoardId[MaxNEDA], ChannelId[MaxNEDA];
UShort_t NEDATdc[MaxNEDA], NEDAFast[MaxNEDA], NEDASlow[MaxNEDA] ,NEDAZco[MaxNEDA];
ULong64_t TSHit[MaxNEDA];
ULong64_t fTimestamp;
protected:
UInt_t fNEvts = 0;
map< Int_t, vector<Int_t> > fStatPerBoard;
public:
EventNEDAWatchers(const char *name, const char *title, TDirectory *sp_dir = 0x0, TDirectory *tag_dir = 0x0) :
WatcherWithTag(name,title,sp_dir,tag_dir),
fBashColor(new BashColor()),
fSubFrame(0x0),
fMFMFrame(new MFMNedaCompFrame()),
fFrame(0x0)
fFrame(0x0),
fNEvts(0)
{;}
virtual ~EventNEDAWatchers()
{
......@@ -82,7 +97,13 @@ public:
delete fSubFrame;
fSubFrame = 0x0;
}