Commit b1e9b1ed authored by Stezowski Olivier's avatar Stezowski Olivier
Browse files

add watchers for NEDA/DIAMANT

git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@2236 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent ba66a61b
/***************************************************************************
* Copyright (C) 2010 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "EventDIAMANTWatchers.h"
#include "DFAgent.h"
#include "TH3.h"
#include "TH2.h"
#include "TH1.h"
using namespace ADF;
Bool_t EventDIAMANTWatchers::SetTrigger( ADF::DFTrigger *trigger )
{
if ( !Watcher::GetFromTrigger(trigger, "event:data:ranc1", fFrame) ) {
std::cout << "Cannot get event:data:ranc0, check your ADF.conf file " << std::endl;
return false;
}
// first extract from the current configuration the definition
// of the data:ranc0 frame on the data flow
FactoryItem i_asked, k_defined, f_defined;
i_asked.SetItem("Agata","data:ranc1",Version());
k_defined = ConfAgent::theGlobalAgent()->GetDFAgent()->WhichKnownKey (i_asked,i_asked);
f_defined = ConfAgent::theGlobalAgent()->GetDFAgent()->WhichKnownFrame (i_asked,i_asked);
Frame *f = MainFrameFactory::theMainFactory().New(k_defined,f_defined);
if ( f ) { // it exists
if ( fSubFrame )
{ delete fSubFrame; fSubFrame = 0x0; }
fSubFrame = f;
}
else fFrame = 0x0;
return fFrame != 0x0;
}
///******************************************************************************************///
UInt_t EventDIAMANTWatchers::GetNbSubFrame()
{
if ( fFrame && fFrame->IsValid() ) {
fFrame->GetFrame()->Scan();
return fFrame->GetFrame()->GetNbSubFrame();
}
return 0u;
}
MFMDiamantFrame *EventDIAMANTWatchers::GetMFM(UInt_t which)
{
// does not exist
if ( !(which < GetNbSubFrame()) ) {
if ( gDebug > 3 )
printf("EventDIAMANTWatchers::GetMFM %d %d \n",which,GetNbSubFrame());
return 0x0;
}
// cannot load subframe #i in fPSAFrame
if ( !fFrame->GetFrame()->LinkSubFrame(which,fSubFrame) ) {
if ( gDebug > 3 )
printf("EventDIAMANTWatchers::GetMFM cannot LinkSubFrame \n");
return 0x0;
}
// cannot read the data
if( fSubFrame->Read() == 0 ) {
if ( gDebug > 3 )
printf("EventDIAMANTWatchers::GetMFM cannot Read \n");
return 0x0;
}
// return the data interface for that frame
// ((ADF::RawFrame *)fSubFrame)->RawBuffer().Address();
fMFMFrame->SetAttributs(((ADF::RawFrame *)fSubFrame)->RawBuffer().Address());
return fMFMFrame;
}
EventDIAMANTSpectra::EventDIAMANTSpectra(const char *name, const char *title, TDirectory *sp_dir, TDirectory *tag_dir):
EventDIAMANTWatchers(name,title,sp_dir,tag_dir),
fFold(0x0)
{
fFold = MakeTH1<TH1F>("Fold","Crystal Fold distributions",20,0,20);
fBoardxChannel = MakeTH2<TH2F>("BC","Crystal Fold distributions",256,0,256,16,0,16);
}
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;
}
UInt_t nb_frames = GetNbSubFrame();
fFold->Fill(nb_frames);
for(UInt_t i = 0u; i <nb_frames; i++) {
MFMDiamantFrame *mfmframe = GetMFM(i);
if ( mfmframe == 0x0 ){
std::cout << "BUG" << std::endl;
continue;
}
fBoardxChannel->Fill(mfmframe->GetBoardId(),mfmframe->GetTGCristalId());
}
}
EventDIAMANTTree::EventDIAMANTTree(const char *name, const char *title, TTree *tree) :
EventDIAMANTWatchers(name,title),
TTreeBuilder(name,title,tree)
{
if ( GetTree() ) { // just add the branch for that watcher
SetBranches();
}
// create spetra
}
EventDIAMANTTree::~EventDIAMANTTree()
{
}
void EventDIAMANTTree::SetBranches()
{
GetTree()->Branch("number_of_diamant",&number_of_diamant,"number_of_diamant/I");
GetTree()->Branch( "BoardId_c", BoardId_c, "BoardId_c[number_of_diamant]/s" );
GetTree()->Branch( "ChannelId_c", ChannelId_c, "ChannelId_c[number_of_diamant]/s" );
}
void EventDIAMANTTree::Exec(Option_t * /*option*/)
{
if ( fFrame == 0x0 || !fFrame->IsValid() ) {
SetLastExecStatus(1u);
return;
}
UInt_t number_of_frame = GetNbSubFrame(); number_of_diamant = number_of_frame;
for(UInt_t i = 0u; i <number_of_frame; i++) {
MFMDiamantFrame *mfmframe = GetMFM(i);
if ( mfmframe == 0x0 ){
std::cout << "BUG" << std::endl;
continue;
}
BoardId_c[i] = mfmframe->GetBoardId(); ChannelId_c[i] = mfmframe->GetTGCristalId() ;
}
FillTree();
}
ClassImp(EventDIAMANTWatchers)
ClassImp(EventDIAMANTSpectra)
ClassImp(EventDIAMANTTree)
/***************************************************************************
* Copyright (C) 2018 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _EventDIAMANTWatchers
#define _EventDIAMANTWatchers
// Watcher definition
#include "Watchers.h"
#include "TTreeWatchers.h"
// ADF definitions
#include "AgataRawFrame.h"
// ROOT definitions
#include "Rtypes.h"
// MFM
#include "MFMDiamantFrame.h"
class TH1F;
class TH2F;
class TH3F;
using namespace ADF;
using namespace Gw;
//! Base Watcher working for any event:data:ranc0
/*!
*/
class EventDIAMANTWatchers : public WatcherWithTag
{
protected:
//! current data:ranc0 frame to help decoding one by one
Frame *fSubFrame;
MFMDiamantFrame *fMFMFrame;
protected:
//! main frame i.e. event:data:ranc0
SharedFP *fFrame;
protected:
//! number of sub Frames extracted from the current event
UInt_t GetNbSubFrame();
MFMDiamantFrame *GetMFM(UInt_t i);
public:
EventDIAMANTWatchers(const char *name, const char *title, TDirectory *sp_dir = 0x0, TDirectory *tag_dir = 0x0) :
WatcherWithTag(name,title,sp_dir,tag_dir),
fSubFrame(0x0),
fMFMFrame(new MFMDiamantFrame()),
fFrame(0x0)
{;}
virtual ~EventDIAMANTWatchers()
{
if (fMFMFrame)
delete fMFMFrame;
fMFMFrame = 0x0;
if (fSubFrame)
delete fSubFrame;
fSubFrame = 0x0;
}
//! Set the trigger attached to this watcher
/*!
look in the list of input Frame one called Agata data:tracked
*/
virtual Bool_t SetTrigger( ADF::DFTrigger */*trigger*/ = 0x0 );
ClassDef(EventDIAMANTWatchers,0) // Trigger on tracked Frame
};
class EventDIAMANTSpectra : public EventDIAMANTWatchers
{
private:
TH1 *fFold; //! Crystal fold
TH1 *fBoardxChannel; //! Board versus channel
public:
EventDIAMANTSpectra(const char *name, const char *title, TDirectory *sp_dir = 0x0, TDirectory *tag_dir = 0x0);
virtual ~EventDIAMANTSpectra()
{;}
//! watch the current frame
virtual void Exec(Option_t *option="");
};
class EventDIAMANTTree : public EventDIAMANTWatchers, public TTreeBuilder
{
static const Int_t MaxDIAMANT = 100;
private:
Int_t number_of_diamant; // Number of hits in the array
UShort_t BoardId_c[MaxDIAMANT], ChannelId_c[MaxDIAMANT];
protected:
virtual void SetBranches();
public:
EventDIAMANTTree(const char *name, const char *title, TTree *tree = 0x0);
virtual ~EventDIAMANTTree();
//! watch the current frame
virtual void Exec(Option_t *option="");
//! Filling the spectra
void FillSpectraByUser()
{;}
//virtual void Print(Option_t *option="") const; //*MENU*
ClassDef(EventDIAMANTTree,0) // built a root tree for the neda comp part
};
#endif
/***************************************************************************
* Copyright (C) 2010 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "EventNEDAWatchers.h"
#include "DFAgent.h"
#include "TH3.h"
#include "TH2.h"
#include "TH1.h"
using namespace ADF;
Bool_t EventNEDAWatchers::SetTrigger( ADF::DFTrigger *trigger )
{
if ( !Watcher::GetFromTrigger(trigger, "event:data:ranc0", fFrame) ) {
std::cout << "Cannot get event:data:ranc0, check your ADF.conf file " << std::endl;
return false;
}
// first extract from the current configuration the definition
// of the data:ranc0 frame on the data flow
FactoryItem i_asked, k_defined, f_defined;
i_asked.SetItem("Agata","data:ranc0",Version());
k_defined = ConfAgent::theGlobalAgent()->GetDFAgent()->WhichKnownKey (i_asked,i_asked);
f_defined = ConfAgent::theGlobalAgent()->GetDFAgent()->WhichKnownFrame (i_asked,i_asked);
Frame *f = MainFrameFactory::theMainFactory().New(k_defined,f_defined);
if ( f ) { // it exists
if ( fSubFrame )
{ delete fSubFrame; fSubFrame = 0x0; }
fSubFrame = f;
}
else fFrame = 0x0;
return fFrame != 0x0;
}
///******************************************************************************************///
UInt_t EventNEDAWatchers::GetNbSubFrame()
{
if ( fFrame && fFrame->IsValid() ) {
fFrame->GetFrame()->Scan();
return fFrame->GetFrame()->GetNbSubFrame();
}
return 0u;
}
MFMNedaFrame *EventNEDAWatchers::GetMFM(UInt_t which)
{
// does not exist
if ( !(which < GetNbSubFrame()) ) {
if ( gDebug > 3 )
printf("EventPSAWatcher::GetDataPSA %d %d \n",which,GetNbSubFrame());
return 0x0;
}
// cannot load subframe #i in fPSAFrame
if ( !fFrame->GetFrame()->LinkSubFrame(which,fSubFrame) ) {
if ( gDebug > 3 )
printf("EventPSAWatcher::GetDataPSA cannot LinkSubFrame \n");
return 0x0;
}
// cannot read the data
if( fSubFrame->Read() == 0 ) {
if ( gDebug > 3 )
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());
return fMFMFrame;
}
EventNEDASpectra::EventNEDASpectra(const char *name, const char *title, TDirectory *sp_dir, TDirectory *tag_dir):
EventNEDAWatchers(name,title,sp_dir,tag_dir),
fFold(0x0)
{
fFold = MakeTH1<TH1F>("Fold","Crystal Fold distributions",20,0,20);
fBoardxChannel = MakeTH2<TH2F>("BC","Crystal Fold distributions",256,0,256,16,0,16);
}
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;
}
UInt_t nb_frames = GetNbSubFrame();
fFold->Fill(nb_frames);
for(UInt_t i = 0u; i <nb_frames; i++) {
MFMNedaFrame *mfmframe = GetMFM(i);
if ( mfmframe == 0x0 ){
std::cout << "BUG" << std::endl;
continue;
}
fBoardxChannel->Fill(mfmframe->GetBoardId(),mfmframe->GetChannelId());
}
}
EventNEDATree::EventNEDATree(const char *name, const char *title, TTree *tree) :
EventNEDAWatchers(name,title),
TTreeBuilder(name,title,tree)
{
if ( GetTree() ) { // just add the branch for that watcher
SetBranches();
}
// create spetra
}
EventNEDATree::~EventNEDATree()
{
}
void EventNEDATree::SetBranches()
{
GetTree()->Branch("NEDA.number_of_neda",&number_of_neda,"number_of_neda/I");
GetTree()->Branch( "NEDA.BoardId_c", BoardId_c, "BoardId_c[number_of_neda]/s" );
GetTree()->Branch( "NEDA.ChannelId_c", ChannelId_c, "ChannelId_c[number_of_neda]/s" );
}
void EventNEDATree::Exec(Option_t * /*option*/)
{
if ( fFrame == 0x0 || !fFrame->IsValid() ) {
SetLastExecStatus(1u);
return;
}
// fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
// fEfvtNbr = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetEventNumber();
//
// const PSAInterface *data = GetCstDataPointer<PSAInterface>(fFrame);
//
// number_of_hits = data->GetNbHits();
// coreE0 = data->GetE(0u);
// coreE1 = data->GetE(1u);
// coreT0 = data->GetT(0u);
// coreT1 = data->GetT(1u);
//
// for( UShort_t i=0u; i < number_of_hits; i++ )
// {
// hitSg[i] = data->GetHit(i)->GetID(0);
// hitE[i] = data->GetHit(i)->GetE();
// hitX[i] = data->GetHit(i)->GetX();
// hitY[i] = data->GetHit(i)->GetY();
// hitZ[i] = data->GetHit(i)->GetZ();
// }
UInt_t number_of_frame = GetNbSubFrame(); number_of_neda = number_of_frame;
for(UInt_t i = 0u; i <number_of_frame; i++) {
MFMNedaFrame *mfmframe = GetMFM(i);
if ( mfmframe == 0x0 ){
std::cout << "BUG" << std::endl;
continue;
}
BoardId_c[i] = mfmframe->GetBoardId(); ChannelId_c[i] = mfmframe->GetChannelId() ;
}
FillTree();
}
ClassImp(EventNEDAWatchers)
ClassImp(EventNEDASpectra)
ClassImp(EventNEDATree)
/***************************************************************************
* Copyright (C) 2010 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _EventNEDAWatchers
#define _EventNEDAWatchers
// Watcher definition
#include "Watchers.h"
#include "TTreeWatchers.h"
// ADF definitions
#include "AgataRawFrame.h"
// ROOT definitions
#include "Rtypes.h"
// MFM
#include "MFMNedaFrame.h"
class TH1F;
class TH2F;
class TH3F;
using namespace ADF;
using namespace Gw;
//! Base Watcher working for any event:data:ranc0
/*!
*/
class EventNEDAWatchers : public WatcherWithTag
{
protected:
//! current data:ranc0 frame to help decoding one by one
Frame *fSubFrame;
MFMNedaFrame *fMFMFrame;
protected:
//! main frame i.e. event:data:ranc0
SharedFP *fFrame;
protected:
//! number of sub Frames extracted from the current event
UInt_t GetNbSubFrame();
MFMNedaFrame *GetMFM(UInt_t i);
public:
EventNEDAWatchers(const char *name, const char *title, TDirectory *sp_dir = 0x0, TDirectory *tag_dir = 0x0) :
WatcherWithTag(name,title,sp_dir,tag_dir),
fSubFrame(0x0),
fMFMFrame(new MFMNedaFrame()),
fFrame(0x0)
{;}
virtual ~EventNEDAWatchers()
{
if (fMFMFrame)
delete fMFMFrame;
fMFMFrame = 0x0;
if (fSubFrame)
delete fSubFrame;
fSubFrame = 0x0;
}
//! Set the trigger attached to this watcher
/*!
look in the list of input Frame one called Agata data:tracked