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

add calibrated crystal frame

git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@936 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent 24c593ac
......@@ -86,7 +86,7 @@ Frame *AgataFrameFactory::NewImp(const Char_t *which_frame, Version version)
// CRYSTAL --------------------------------------------------------------------------- //
if ( frametype == "data:crystal" ) {
if ( version == Version(65000,0) )
frame = new CrystalFrame_65000_0(GetPrimaryKey());
frame = new CrystalFrame_0(GetPrimaryKey());
}
if ( frametype == "proxy:data:crystal" ) {
// first allocate the embedded frame USING the factory to properly set the Signature !!
......@@ -94,8 +94,25 @@ Frame *AgataFrameFactory::NewImp(const Char_t *which_frame, Version version)
ACrystalFrame *fimp = 0x0;
fimp = dynamic_cast< ACrystalFrame* > (New("data:crystal",version));
// default ?
if ( fimp == 0x0 )
fimp = dynamic_cast< ACrystalFrame* > (New("data:crystal",Version(65000,0))); // default
fimp = dynamic_cast< ACrystalFrame* > (New("data:crystal",Version(65000,0)));
frame =
new ProxyDataFrame< ACrystalFrame, CrystalInterface >( fimp );
}
if ( frametype == "data:ccrystal" ) {
if ( version == Version(65000,0) )
frame = new CrystalFrame_1(GetPrimaryKey());
}
if ( frametype == "proxy:data:ccrystal" ) {
// first allocate the embedded frame USING the factory to properly set the Signature !!
// try with the version asked
ACrystalFrame *fimp = 0x0;
fimp = dynamic_cast< ACrystalFrame* > (New("data:ccrystal",version));
// default ?
if ( fimp == 0x0 )
fimp = dynamic_cast< ACrystalFrame* > (New("data:ccrystal",Version(65000,0)));
frame =
new ProxyDataFrame< ACrystalFrame, CrystalInterface >( fimp );
}
......
......@@ -34,19 +34,19 @@ BasicAFC::BasicAFC() :
fEndOfFrames(aMByte,ConfAgent::kWrite),
fPath("./"),
fBaseForName("AFC_"),
fCurrentFile(NULL),
fCurrentFile(0x0),
fCurrentFileNumber(0u),
fMaxSize(kMaxUInt_t)
{
Log.GetProcessName() = "BasicAFC"; Log.SetPID(GetPID());
fFrameIO.SetName("BasicAFC");
GetFrameIO().SetName("BasicAFC");
// to be sure unknown frames are written in the ouput
GetConfAgent()->SetModel(ConfAgent::kSafe);
// to protect readings in the source of frames
fEndOfFrames.SetModeIO(ConfAgent::kWrite);
fFrameIO.Attach(NULL,&fEndOfFrames);
GetFrameIO().Attach(0x0,&fEndOfFrames);
}
BasicAFC::~BasicAFC()
......@@ -81,22 +81,22 @@ Bool_t BasicAFC::NewFile()
filename << tmp << fBaseForName << fCurrentFileNumber++ << ".adf";
fCurrentFile = ::fopen(filename.str().data(),"wb");
if ( fCurrentFile != NULL ) {
if ( fCurrentFile != 0x0 ) {
Log << info << "A new output file has just been open "
<< filename.str();
fEndOfFrames.SetFile
(fCurrentFile,fMaxSize);
fFrameIO.SetStatus
GetFrameIO().SetStatus
(BaseFrameIO::kIdle);
fFrameIO.RecordGlobalConfiguration();
GetFrameIO().RecordGlobalConfiguration();
ok = true;
}
else {
Log << warning << "Cannot open file "
<< filename.str();
fFrameIO.SetStatus(BaseFrameIO::kFinished);
GetFrameIO().SetStatus(BaseFrameIO::kFinished);
}
return ok;
......@@ -105,19 +105,19 @@ Bool_t BasicAFC::NewFile()
UInt_t BasicAFC::ProcessBlock (ADF::FrameBlock &in)
{
// attach the FrameBlocks
fFrameIO.Attach(&in,NULL);
GetFrameIO().Attach(&in,0x0);
// fill the output block with the frames from the input block
while ( fFrameIO.Notify() ) {
while ( GetFrameIO().Notify() ) {
}
// interruption: means end of file or out is full
if ( fFrameIO.GetCurrentBlockIN()->IsEoB() ) { // the file has been read
if ( GetFrameIO().GetCurrentBlockIN()->IsEoB() ) { // the file has been read
}
if ( fFrameIO.GetCurrentBlockOUT()->IsEoB() ) { // the output block is full
if ( GetFrameIO().GetCurrentBlockOUT()->IsEoB() ) { // the output block is full
NewFile();
}
//
fFrameIO.Detach(&in,NULL);
GetFrameIO().Detach(&in,0x0);
return 0u;
}
......@@ -163,7 +163,7 @@ void BasicAFC::process_reset (UInt_t *error_code)
if ( fCurrentFile )
::fclose(fCurrentFile);
fFrameIO.Print( Log() );
GetFrameIO().Print( Log() );
Log << dolog;
}
......
......@@ -34,11 +34,11 @@ BasicAFP::BasicAFP():
fSourceOfFrames(aMByte,ConfAgent::kRead),
fPath("./"),
fBaseForName("AFP_"),
fCurrentFile(NULL),
fCurrentFile(0x0),
fCurrentFileNumber(0u),
fMaxSize(kMaxUInt_t)
{
Log.GetProcessName() = "BasicAFP"; fFrameIO.SetName("BasicAFP");
Log.GetProcessName() = "BasicAFP"; GetFrameIO().SetName("BasicAFP");
// to be sure unknown frames are written in the ouput
GetConfAgent()->SetModel(ConfAgent::kSafe);
......@@ -46,7 +46,7 @@ BasicAFP::BasicAFP():
fSourceOfFrames.SetModeIO(ConfAgent::kRead);
// the input datablock is owned by BasicAFP
fFrameIO.Attach(&fSourceOfFrames,NULL);
GetFrameIO().Attach(&fSourceOfFrames,0x0);
}
BasicAFP::~BasicAFP()
......@@ -71,12 +71,12 @@ Bool_t BasicAFP::NewFile()
filename << tmp << fBaseForName << fCurrentFileNumber++ << ".adf";
fCurrentFile = ::fopen(filename.str().data(),"rb");
if ( fCurrentFile != NULL ) {
if ( fCurrentFile != 0x0 ) {
Log << "A new input file has just been open "
<< filename.str();
fSourceOfFrames.SetFile
(fCurrentFile,fMaxSize);
fFrameIO.SetStatus
GetFrameIO().SetStatus
(BaseFrameIO::kIdle);
ok = true;
......@@ -84,7 +84,7 @@ Bool_t BasicAFP::NewFile()
else {
Log << "Cannot open file "
<< filename.str();
fFrameIO.SetStatus(BaseFrameIO::kFinished);
GetFrameIO().SetStatus(BaseFrameIO::kFinished);
}
return ok;
......@@ -102,31 +102,28 @@ void BasicAFP::process_config (const Char_t *directory_path, UInt_t *error_code)
UInt_t BasicAFP::ProcessBlock(ADF::FrameBlock &out)
{
// Log.ClearMessage(); Log.GetProcessMethod() = "process_block";
if ( fFrameIO.GetStatus() == BaseFrameIO::kFinished )
if ( GetFrameIO().GetStatus() == BaseFrameIO::kFinished )
return 1u;
// attach the FrameBlock
fFrameIO.Attach(NULL,&out);
GetFrameIO().Attach(0x0,&out);
// fill the output with successive frames read from the file until out is filled
while ( fFrameIO.Notify() ) {
while ( GetFrameIO().Notify() ) {
}
// interruption: means end of file or out is full
if ( fFrameIO.GetCurrentBlockIN()->IsEoB() ) { // the file has been read, try to open the next one
if ( GetFrameIO().GetCurrentBlockIN()->IsEoB() ) { // the file has been read, try to open the next one
NewFile();
}
/* if ( fFrameIO.GetCurrentBlockOUT()->IsEoB() ) { // the output block is full
}*/
//
fFrameIO.Detach(NULL,&out);
GetFrameIO().Detach(0x0,&out);
Log << dolog;
return 0u;
}
void BasicAFP::process_initialise (UInt_t *error_code)
{
*error_code = 0u;
......@@ -168,7 +165,7 @@ void BasicAFP::process_reset (UInt_t *error_code)
if ( fCurrentFile )
::fclose(fCurrentFile);
fFrameIO.Print( Log() );
GetFrameIO().Print( Log() );
Log << dolog;
}
/*
......
......@@ -26,3 +26,12 @@
using namespace ADF;
UInt_t CrystalInterface::kDefaultLength = 200u;
GeSegment::~GeSegment()
{
if (fSignal)
delete fSignal;
fSignal = 0x0;
}
......@@ -83,7 +83,7 @@ public:
class GeCore : public GeSegment
{
private:
Double32_t fT; // Time for this segment
Double32_t fT; // Time for the core
public:
GeCore(UInt_t length, const char *type):
......@@ -99,8 +99,9 @@ public:
{ fT = 0.0; GeSegment::Reset(l); }
};
//!
//! Data produced fro a Crystal
/*!
The data for a crystal are composed of 2 Core signals (GeCore) and 36 Segments Signals (GeSegment).
*/
class CrystalInterface : public DataInterface
{
......
......@@ -3,6 +3,137 @@
namespace ADF
{
class CrystalFrame_ : public ACrystalFrame
{
friend class AgataFrameFactory;
protected:
PtrStack<GeCore> fCore;
PtrStack<GeSegment> fSegment;
protected:
UInt_t fMaxFrameSize;
protected:
CrystalFrame_(const Key *akey, const char *sig_type);
virtual UInt_t ReadImp() ;
virtual UInt_t WriteImp() ;
virtual void DataReset();
public:
virtual ~CrystalFrame_()
{;}
virtual GeSegment *GetSegment(UShort_t which)
{ return fSegment.At(which); }
virtual GeCore *GetCore(UShort_t which)
{ return fCore.At(which); }
};
CrystalFrame_::CrystalFrame_(const Key *akey, const Char_t *sig_type) :
ACrystalFrame(akey), fCore(kNbCores), fSegment(kNbSegments), fMaxFrameSize(ADF::aMByte)
{
for (UShort_t i = 0u; i < kNbCores; i++ )
{ fCore.Add( new GeCore(kDefaultLength,sig_type) ); }
for (UShort_t i = 0u; i < kNbSegments; i++ )
{ fSegment.Add( new GeSegment(kDefaultLength,sig_type) ); }
Global()->AddItem( new NamedItem<UShort_t>("CrystalID",0u) );
Global()->AddItem( new NamedItem<UShort_t>("CrystalStatus",0u) );
}
void CrystalFrame_::DataReset()
{
// set check level to 0 to fully reset the signals .. in principle
// not needed since the user should fill them completely
if ( GetCheckLevel() > 0 ) {
DataInterface::ResetGlobal();
for (UShort_t i = 0u; i < kNbCores; i++ )
{ fCore.At(i)->Reset(); }
for (UShort_t i = 0u; i < kNbSegments; i++ )
{ fSegment.At(i)->Reset(); }
}
}
UInt_t CrystalFrame_::ReadImp()
{
// local variables used to decode the in buffer objects
Int_t length;
Float_t energy;
Float_t t;
UShort_t status, id;
// read the global part first
Global()->GetItems((*fBuffer));
for (UShort_t i = 0u; i < kNbSegments; i++ ) {
GeSegment *seg = fSegment.At(i); (*fBuffer) >> length >> status >> id >> energy;
seg->SetStatus(status);
seg->SetID(id);
seg->SetE(energy);
// the trace
seg->GetSignal()->Resize(length); seg->GetSignal()->Import(fBuffer);
}
for (UShort_t i = 0u; i < kNbCores; i++ ) {
GeCore *core = fCore.At(i); (*fBuffer) >> length >> status >> id >> energy >> t;
core->SetStatus(status);
core->SetID(id);
core->SetE(energy);
core->SetT(t);
// the trace
core->GetSignal()->Resize(length); core->GetSignal()->Import(fBuffer);
}
return fBuffer->Offset();
}
UInt_t CrystalFrame_::WriteImp()
{
// local variables used to encode the in memory objects
Int_t length;
Float_t energy;
Float_t t;
if ( !fBuffer->Reserve(fMaxFrameSize) )
return 0u;
// start writting data in the buffer
Global()->SetItems((*fBuffer));
for (UShort_t i = 0u; i < kNbSegments; i++ ) {
GeSegment *seg = fSegment.At(i);
length = seg->GetSignal()->GetLength();
energy = seg->GetE();
// WARNING Is length needed
(*fBuffer) << length << seg->GetStatus() << seg->GetID() << energy;
// the trace, without the length writting in the buffer
seg->GetSignal()->Export(fBuffer);
}
for (UShort_t i = 0u; i < kNbCores; i++ ) {
GeCore *core = fCore.At(i);
length = core->GetSignal()->GetLength();
energy = core->GetE();
t = core->GetT();
// WARNING Is length needed
(*fBuffer) << length << core->GetStatus() << core->GetID() << energy << t;
// the trace, without the length writting in the buffer
core->GetSignal()->Export(fBuffer);
}
return fBuffer->Offset();
}
} // namespace ADF
......
......@@ -3,138 +3,33 @@
namespace ADF
{
UInt_t CrystalInterface::kDefaultLength = 200u;
GeSegment::~GeSegment()
{
if (fSignal)
delete fSignal;
fSignal = NULL;
}
//! A particular CrystalFrame
//! CrystalFrame with signals as UShort_t
/*!
*/
class CrystalFrame_65000_0 : public ACrystalFrame
class CrystalFrame_0 : public CrystalFrame_
{
friend class AgataFrameFactory;
private:
PtrStack<GeCore> fCore;
PtrStack<GeSegment> fSegment;
protected:
CrystalFrame_65000_0(const Key *akey);
virtual UInt_t ReadImp() ;
virtual UInt_t WriteImp() ;
virtual void DataReset();
CrystalFrame_0(const Key *akey) : CrystalFrame_(akey,"US") {;}
public:
virtual ~CrystalFrame_65000_0()
virtual ~CrystalFrame_0()
{;}
virtual GeSegment *GetSegment(UShort_t which)
{ return fSegment.At(which); }
virtual GeCore *GetCore(UShort_t which)
{ return fCore.At(which); }
};
void CrystalFrame_65000_0::DataReset()
{
DataInterface::ResetGlobal();
for (UShort_t i = 0u; i < kNbCores; i++ )
{ fCore.At(i)->Reset(); }
for (UShort_t i = 0u; i < kNbSegments; i++ )
{ fSegment.At(i)->Reset(); }
}
CrystalFrame_65000_0::CrystalFrame_65000_0(const Key *akey) :
ACrystalFrame(akey), fCore(kNbCores), fSegment(kNbSegments)
{
for (UShort_t i = 0u; i < kNbCores; i++ )
{ fCore.Add( new GeCore(kDefaultLength,"US") ); }
for (UShort_t i = 0u; i < kNbSegments; i++ )
{ fSegment.Add( new GeSegment(kDefaultLength,"US") ); }
Global()->AddItem( new NamedItem<UShort_t>("CrystalID",0u) );
Global()->AddItem( new NamedItem<UShort_t>("CrystalStatus",0u) );
}
UInt_t CrystalFrame_65000_0::ReadImp()
{
// local variables used to decode the in buffer objects
Int_t length;
Float_t energy;
Float_t t;
UShort_t status, id;
// read the global part first
Global()->GetItems((*fBuffer));
for (UShort_t i = 0u; i < kNbSegments; i++ ) {
GeSegment *seg = fSegment.At(i); (*fBuffer) >> length >> status >> id >> energy;
seg->SetStatus(status);
seg->SetID(id);
seg->SetE(energy);
// the trace
seg->GetSignal()->Resize(length); seg->GetSignal()->Import(fBuffer);
}
for (UShort_t i = 0u; i < kNbCores; i++ ) {
GeCore *core = fCore.At(i); (*fBuffer) >> length >> status >> id >> energy >> t;
core->SetStatus(status);
core->SetID(id);
core->SetE(energy);
core->SetT(t);
// the trace
core->GetSignal()->Resize(length); core->GetSignal()->Import(fBuffer);
}
return fBuffer->Offset();
}
UInt_t CrystalFrame_65000_0::WriteImp()
//! CrystalFrame with signals as Float_t
/*!
*/
class CrystalFrame_1 : public CrystalFrame_
{
// local variables used to encode the in memory objects
Int_t length;
Float_t energy;
Float_t t;
UInt_t needed = ADF::aMByte;
if ( !fBuffer->Reserve(needed) )
return 0u;
// start writting data in the buffer
Global()->SetItems((*fBuffer));
for (UShort_t i = 0u; i < kNbSegments; i++ ) {
GeSegment *seg = fSegment.At(i);
length = seg->GetSignal()->GetLength();
energy = seg->GetE();
// WARNING Is length needed
(*fBuffer) << length << seg->GetStatus() << seg->GetID() << energy;
// the trace, without the length writting in the buffer
seg->GetSignal()->Export(fBuffer);
}
for (UShort_t i = 0u; i < kNbCores; i++ ) {
GeCore *core = fCore.At(i);
length = core->GetSignal()->GetLength();
energy = core->GetE();
t = core->GetT();
friend class AgataFrameFactory;
// WARNING Is length needed
(*fBuffer) << length << core->GetStatus() << core->GetID() << energy << t;
// the trace, without the length writting in the buffer
core->GetSignal()->Export(fBuffer);
}
return fBuffer->Offset();
}
protected:
CrystalFrame_1(const Key *akey) : CrystalFrame_(akey,"F") {;}
public:
virtual ~CrystalFrame_1()
{;}
};
} // namespace ADF
......
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