Commit 7176d1ce authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Merge branch 'preprod' into 'master'

Preprod

See merge request IPNL_GAMMA/narval_emulator!66
parents 0c65a058 6d379294
......@@ -12,6 +12,7 @@ compile:
- rm -rf AgataSoftware
- mkdir AgataSoftware
- cd AgataSoftware
- export gRaySoftware_Version=1
- git clone https://gitlab.in2p3.fr/IPNL_GAMMA/scripts.git
- python scripts/gRaySoftware.py --adf=origin/preprod all
- python scripts/gRaySoftware.py --mfm= all
......
......@@ -39,6 +39,8 @@ Frame: Agata data:ranc2 4 0 Agata data:ranc2 65000 0
Frame: Agata data:psa 4 0 Agata data:psa 0 0
Frame: Agata data:tracked 4 0 Agata data:tracked 1 0
Frame: Agata event:data 4 0 Agata event:data 4 0
Frame: Agata event:data:crystal 4 0 Agata event:data:crystal 4 0
Frame: Agata event:data:ccrystal 4 0 Agata event:data:ccrystal 4 0
Frame: Agata event:data:psa 4 0 Agata event:data:psa 4 0
Frame: Agata event:data:ranc0 4 0 Agata event:data:ranc0 4 0
Frame: Agata event:data:ranc1 4 0 Agata event:data:ranc1 4 0
......
......@@ -765,7 +765,7 @@ UInt_t EventBuilder::GetParameters(const std::string& confFile, Bool_t doList)
}
}
if(conf.Seen("TstampCorrect")) {
int which = conf.Find("TimestampCorrect");
int which = conf.Find("TstampCorrect");
int times = conf.Times(which);
for(int nn = 0; nn < times; nn++) {
conf.Restore(which, nn);
......
......@@ -47,7 +47,7 @@
#endif
#if defined(OS_TYPE)
#if !(OS_TYPE == OS_LINUX) && !(OS_TYPE == OS_WINDOWS) && !(OS_TYPE == OS_CYGWIN)
#if !(OS_TYPE == OS_LINUX) && !(OS_TYPE == OS_WINDOWS) && !(OS_TYPE == OS_CYGWIN) && !(OS_TYPE == OS_APPLE)
#error OS_TYPE should be either OS_LINUX or OS_WINDOWS or OS_CYGWIN or OS_APPLE
#endif
#else
......@@ -62,7 +62,7 @@
#define NRV_OFFLINE 2
// NRV_TYPE should be defined in the project or makefile (e.g. for narval: make library NRV_TYPE=-DNRV_ONLINE)
//#define NRV_TYPE NRV_ONLINE
#define NRV_TYPE NRV_OFFLINE
#ifndef NRV_TYPE
#error Please define NRV_TYPE to be either NRV_ONLINE or NRV_OFFLINE
......
......@@ -29,8 +29,8 @@
#include <cmath>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <cerrno>
#include <cstdlib>
#include <sys/mman.h>
#include <sys/stat.h>
......@@ -46,7 +46,6 @@ using namespace AGAPRO;
string Histogramer::gMotherClass = "Histogramer";
Histogramer::Histogramer(string trigname) :
NarvalConsumer(),
fTrigger(trigname.data())
{
......@@ -55,7 +54,7 @@ Histogramer::Histogramer(string trigname) :
Histogramer::~Histogramer()
{
// in principle not needed ... just in case reset it has not been called by narval
UInt_t error = 0u; process_reset(&error) ;
UInt_t error = 0; process_reset(&error) ;
}
void Histogramer::process_config(const Char_t *directory_path, UInt_t *error_code)
......@@ -72,7 +71,7 @@ void Histogramer::process_config(const Char_t *directory_path, UInt_t *error_cod
UInt_t Histogramer::ProcessBlock(ADF::FrameBlock &inBlock)
{
// attach the input/output buffer to the FrameIO system
fFrameIO.Attach(&inBlock, 0x0);
fFrameIO.Attach(&inBlock, nullptr);
// start the processing
UInt_t error_code = 0;
......@@ -85,23 +84,20 @@ UInt_t Histogramer::ProcessBlock(ADF::FrameBlock &inBlock)
// fill local variables with data from the input
error_code = SetInput();
if( error_code == 1)
{
if( error_code == 1) {
LOCK_COUT;
Log.SetProcessMethod("ProcessBlock");
Log << error << " During : SetInput()" << dolog;
break;
}
else
{
Process();
}
Process();
nevs++;
fReadEvts++;
}
fFrameIO.Detach(&inBlock, 0x0);
fFrameIO.Detach(&inBlock, nullptr);
cServer.Exec(timestamp, nevs);
......
......@@ -68,12 +68,12 @@ protected:
Int_t fReadEvts = 0;
UInt_t evnumber;
ULong64_t timestamp;
UInt_t evnumber = 0;
ULong64_t timestamp = 0;
Int_t fBasePortNumber;
Int_t fBasePortNumber = 0;
Bool_t fFirstBlock;
Bool_t fFirstBlock = 0;
Float_t fRefreshTime = 2.0;
......@@ -82,8 +82,8 @@ public:
static std::string gMotherClass; //! Static string containing the name of the base class
std::string gActualClass; //! Static string to choose daughter class at run time
UShort_t crystal_id; //! crystal id
std::string crystal_name; //! crystal name
UShort_t crystal_id = 0; //! crystal id
std::string crystal_name = ""; //! crystal name
vector < vector< void * > > fListOfHists; //! Level 1 : list of actors ; level 2 : list of observable per actor
......@@ -92,7 +92,7 @@ public:
virtual ~Histogramer();
static void process_config(const Char_t *, UInt_t *);
virtual void process_initialise ( UInt_t *error_code ){return;}
virtual void process_initialise ( UInt_t *){return;}
virtual void process_reset ( UInt_t *error_code );
virtual UInt_t ProcessBlock(ADF::FrameBlock &);
......@@ -109,7 +109,7 @@ public:
static std::string GetCoreNameFromID(const Int_t id);
protected:
virtual UInt_t GetParameters(const std::string& confFile, Bool_t doList=false){return 0;}
virtual UInt_t GetParameters(const std::string& , Bool_t ){return 0;}
virtual void InitSMZ(Int_t){return;}
void *CreateNewSMz(const char *name, Int_t Size, Int_t PortNumber);
......
......@@ -164,6 +164,8 @@ UInt_t PSAHist::Process()
fLastTS = timestamp;
}
return 0;
}
void PSAHist::process_initialise (UInt_t *error_code)
......@@ -230,7 +232,7 @@ void PSAHist::process_initialise (UInt_t *error_code)
Int_t PSAHist::SetInput()
{
Frame *frame_in = fFrameCrystal->GetFrame();
UInt_t bytes_in = frame_in->Read();
/*UInt_t bytes_in = */frame_in->Read();
timestamp = ((AgataKey *)frame_in->GetKey())->GetTimeStamp();
evnumber = ((AgataKey *)frame_in->GetKey())->GetEventNumber();
......
......@@ -76,10 +76,10 @@ public:
PSAHist();
virtual ~PSAHist();
virtual UInt_t Process();
virtual Int_t SetInput(); //! to init your local variables with the ones from the buffers
virtual UInt_t Process() override;
virtual Int_t SetInput() override; //! to init your local variables with the ones from the buffers
virtual void process_initialise ( UInt_t *error_code ); //! Constructor implementation
virtual void process_initialise ( UInt_t *error_code ) override; //! Constructor implementation
public:
virtual UInt_t GetParameters(const std::string& confFile, Bool_t doList=false) override;
......
......@@ -4,7 +4,7 @@
using namespace AGAPRO;
extern "C" {
Histogramer *process_register (UInt_t *error_code)
Histogramer *process_register (UInt_t *)
{
return new PSAHist();
}
......
......@@ -230,6 +230,8 @@ UInt_t PreproHist::Process()
fLastTS = timestamp;
}
return 0;
}
void PreproHist::process_initialise (UInt_t *error_code)
......@@ -545,7 +547,7 @@ float PreproHist::FindTriggerTime (float *pT, float trigFract, int trigChans, f
// gaussian smoothing once
float oldval = pT[0];
for(int nn = 0; nn < fTraceLengthPSA-1; nn++) {
for(uint nn = 0; nn < fTraceLengthPSA-1; nn++) {
float newval = 0.25f*(oldval + 2.f*pT[nn] + pT[nn+1]);
oldval = pT[nn];
pT[nn] = newval;
......
......@@ -101,10 +101,10 @@ public:
PreproHist();
virtual ~PreproHist();
virtual UInt_t Process();
virtual Int_t SetInput(); //! to init your local variables with the ones from the buffers
virtual UInt_t Process() override;
virtual Int_t SetInput() override; //! to init your local variables with the ones from the buffers
virtual void process_initialise ( UInt_t *error_code ); //! Constructor implementation
virtual void process_initialise ( UInt_t *error_code ) override; //! Constructor implementation
public:
virtual UInt_t GetParameters(const std::string& confFile, Bool_t doList=false) override;
......
......@@ -4,7 +4,7 @@
using namespace AGAPRO;
extern "C" {
Histogramer *process_register (UInt_t *error_code)
Histogramer *process_register (UInt_t *)
{
return new PreproHist();
}
......
......@@ -117,7 +117,7 @@ UInt_t ProdHist::Process()
vector< void* > SignalsList = fListOfHists[(Int_t)HistLib::Signals];
if(fFirstBlock && fPlotSignals && SignalsList.size() == (kNSG+kNCC)*fNumberOfSignals)
if(fFirstBlock && fPlotSignals && SignalsList.size() == (uint)((kNSG+kNCC)*fNumberOfSignals))
{
for(int nn = 0; nn < kNSG; nn++)
{
......@@ -178,6 +178,8 @@ UInt_t ProdHist::Process()
fLastTS = timestamp;
}
return 0;
}
void ProdHist::process_initialise (UInt_t *error_code)
......
......@@ -80,10 +80,10 @@ public:
ProdHist();
virtual ~ProdHist();
virtual UInt_t Process();
virtual Int_t SetInput(); //! to init your local variables with the ones from the buffers
virtual UInt_t Process() override;
virtual Int_t SetInput() override; //! to init your local variables with the ones from the buffers
virtual void process_initialise ( UInt_t *error_code ); //! Constructor implementation
virtual void process_initialise ( UInt_t *error_code ) override; //! Constructor implementation
public:
virtual UInt_t GetParameters(const std::string& confFile, Bool_t doList=false) override;
......
......@@ -4,7 +4,7 @@
using namespace AGAPRO;
extern "C" {
Histogramer *process_register (UInt_t *error_code)
Histogramer *process_register (UInt_t *)
{
return new ProdHist();
}
......
This diff is collapsed.
......@@ -21,15 +21,139 @@
#ifndef _TB_AGATA
#define _TB_AGATA
#include "AGAPRO_TB_Detector.h"
#include "CrystalFrame.h"
class TGeoCombiTrans;
#include "AGAPRO_TB_Detector.h"
namespace AGAPRO {
/// ****** CRYSTAL ******///
class TB_AGATA_CRYSTAL : public TB_Detector
{
protected:
static const int kNCC = ADF::CrystalInterface::kNbCores;
static const int kNSG = ADF::CrystalInterface::kNbSegments;
static const int kMaxTraceLenght = 100;
static const int kCrystalTraceLenght = 100;
static const int kCCrystalTraceLenght = 60;
private:
Float_t SegTraces[kNSG*kMaxTraceLenght];
UShort_t SegTracesu[kNSG*kMaxTraceLenght];
Float_t CoreTraces[kNCC*kMaxTraceLenght];
UShort_t CoreTracesu[kNCC*kMaxTraceLenght];
Float_t SegE[kNSG];
Float_t CoreE[kNCC];
ULong64_t crystalId;
ULong64_t crystalTS;
UInt_t fTraceLenght;
bool WarnedDone = false;
public:
TB_AGATA_CRYSTAL(TString name="", TString ADFKey="");
virtual ~TB_AGATA_CRYSTAL();
void Init();
void InitValues();
void InitTree();
void Process(Int_t idet);
};
/// ****** PSA ******///
class TB_AGATA_PSA : public TB_Detector
{
protected:
static const Int_t MaxHits = 36; // Max number of hits in one event
Int_t nbHits; // Number of hits in the crystal
Float_t hitE[MaxHits]; // Energie of the hit
Float_t hitX[MaxHits]; // X position of the hit in the Crystal Frame
Float_t hitY[MaxHits]; // Y position of the hit in the Crystal Frame
Float_t hitZ[MaxHits]; // Z position of the hit in the Crystal Frame
Float_t hitGX[MaxHits]; // Position x of hit with , in global frame
Float_t hitGY[MaxHits]; // Position y of hit with , in global frame
Float_t hitGZ[MaxHits]; // Position z of hit with , in global frame
Int_t hitSg[MaxHits]; // Crystal ID in which a hit occurs
Int_t coreId; // crystal ID
Float_t coreE0; // Core energy, high gain
Float_t coreE1; // Core energy, low gain
Float_t coreT0; // Core time, high gain
Float_t coreT1; // Core time, low gain
ULong64_t coreTS;
public:
TB_AGATA_PSA(TString name="", TString ADFKey="");
virtual ~TB_AGATA_PSA();
void Init();
void InitValues();
void InitTree();
void Process(Int_t idet);
};
/// ****** Builder ******///
class TB_AGATA_Builder : public TB_Detector
class TB_AGATA_Builder_CRYSTAL : public TB_Detector
{
protected:
static const int kNCC = ADF::CrystalInterface::kNbCores;
static const int kNSG = ADF::CrystalInterface::kNbSegments;
static const int kMaxTraceLenght = 100;
static const int kCrystalTraceLenght = 100;
static const int kCCrystalTraceLenght = 60;
protected:
static const Int_t MaxCore = 180; // Max number of cores in one event
Int_t nbCrystals; // for more than 1 frame (built event)
Int_t crystalId[MaxCore]; // for each crystal fired its ID
ULong64_t crystalTS[MaxCore]; // timestamp of cores
Int_t SegTracesSize;
Float_t SegTraces[kNSG*kMaxTraceLenght*MaxCore];
UShort_t SegTracesu[kNSG*kMaxTraceLenght*MaxCore];
Int_t CoreTracesSize;
Float_t CoreTraces[kNCC*kMaxTraceLenght*MaxCore];
UShort_t CoreTracesu[kNCC*kMaxTraceLenght*MaxCore];
Int_t SegESize;
Float_t SegE[kNSG*MaxCore];
Int_t CoreESize;
Float_t CoreE[kNCC*MaxCore];
ULong64_t EvtCrystalTS;
UInt_t fTraceLenght;
bool WarnedDone = false;
public:
TB_AGATA_Builder_CRYSTAL(TString name="", TString ADFKey="");
virtual ~TB_AGATA_Builder_CRYSTAL();
void Init();
void InitValues();
void InitTree();
void Process(Int_t idet);
};
class TB_AGATA_Builder_PSA : public TB_Detector
{
struct core_property
{
......@@ -58,8 +182,8 @@ protected:
Float_t hitGX[MaxHits]; // Position x of hit with , in global frame
Float_t hitGY[MaxHits]; // Position y of hit with , in global frame
Float_t hitGZ[MaxHits]; // Position z of hit with , in global frame
Int_t hitId[MaxHits]; // Segment ID in which a hit occurs
Int_t hitSg[MaxHits]; // Crystal ID in which a hit occurs
Int_t hitId[MaxHits]; // Crystal ID in which a hit occurs
Int_t hitSg[MaxHits]; // Segment ID in which a hit occurs
Int_t nbCores; // for more than 1 frame (built event)
Int_t nbHitsperCry[MaxCore]; // nb of hits epr crystal
......@@ -68,6 +192,11 @@ protected:
Float_t coreE1[MaxCore]; // Core energy, low gain
Float_t coreT0[MaxCore]; // Core time, high gain
array<Float_t, MaxCore> MaxESeg; // Maximum segment energy in the core
array<Float_t, MaxCore> MaxCoreX; // X position of the max segment energy
array<Float_t, MaxCore> MaxCoreY; // Y position of the max segment energy
array<Float_t, MaxCore> MaxCoreZ; // Z position of the max segment energy
Int_t nbAdd; // Addback multiplicity
Int_t AddId[MaxCore]; // Addback crystal Id of the hit with highest energy
Float_t AddE[MaxCore]; // Addback energy
......@@ -79,11 +208,9 @@ protected:
ULong64_t AddTS[MaxCore]; // timestamp of he hit with highest energy
ULong64_t TSHit;
TObjArray* fMatrixList = nullptr;
public:
TB_AGATA_Builder(TString name="", TString ADFKey="");
virtual ~TB_AGATA_Builder();
TB_AGATA_Builder_PSA(TString name="", TString ADFKey="");
virtual ~TB_AGATA_Builder_PSA();
void Init();
void InitValues();
......@@ -91,10 +218,6 @@ public:
void Process(Int_t idet);
protected:
virtual TGeoCombiTrans* FillTransMatrix(Double_t* trans, Double_t* rot);
virtual void Local2Global(Int_t detID, Double_t xl, Double_t yl, Double_t zl, Double_t& xg, Double_t& yg, Double_t& zg);
virtual bool ReadTransformation();
static bool coreCompare(const core_property& firstElem, const core_property& secondElem) {
return firstElem.E > secondElem.E;
}
......
......@@ -39,7 +39,7 @@ TB_DIAMANT::~TB_DIAMANT()
void TB_DIAMANT::Init()
{
fFrame = fTrigger->AddUtility("data:ranc1",ConfAgent::theGlobalAgent());
fSFrame = fTrigger->AddUtility("data:ranc1",ConfAgent::theGlobalAgent());
fDIAMANTFrame = new MFMDiamantFrame();
LoadLUT();
......@@ -83,7 +83,7 @@ void TB_DIAMANT::Process(Int_t idet)
{
Log.ClearMessage();
Log.GetProcessName() = gActualClass;
Log.SetProcessMethod("Process()");
Log.SetProcessMethod(Form("Process(%d)",idet));
fCompFrame = (ADF::AgataCompositeFrame*) fTrigger->GetInputSharedFP(idet+1)->GetFrame();
fCompFrame->Scan();
......@@ -101,9 +101,9 @@ void TB_DIAMANT::Process(Int_t idet)
for(Int_t i = 0u; i <nbDIAMANT; i++)
{
fCompFrame->LinkSubFrame(i,fFrame->GetFrame());
fFrame->GetFrame()->Read();
fDIAMANTFrame->SetAttributs(((ADF::RawFrame *)fFrame->GetFrame())->RawBuffer().Address());
fCompFrame->LinkSubFrame(i,fSFrame->GetFrame());
fSFrame->GetFrame()->Read();
fDIAMANTFrame->SetAttributs(((ADF::RawFrame *)fSFrame->GetFrame())->RawBuffer().Address());
DIAMANTBoardId[i] = fDIAMANTFrame->GetBoardId();
DIAMANTChannelId[i] = fDIAMANTFrame->GetTGCristalId() ;
......
......@@ -22,6 +22,8 @@
#include "AGAPRO_TB_Detector.h"
#endif
#include "TGeoMatrix.h"
using namespace AGAPRO;
TB_Detector::TB_Detector(TString name, TString ADFKey) :
......@@ -37,6 +39,127 @@ TB_Detector::~TB_Detector()
{
if(fCompFrame)
delete fCompFrame;
if(fFrame)
delete fFrame;
if(fSFrame)
delete fSFrame;
if(fMatrixList)
delete fMatrixList;
}
TGeoCombiTrans* TB_Detector::FillTransMatrix(Double_t* trans, Double_t* rot)
{
TGeoRotation rotation; rotation.SetMatrix(rot);
TGeoTranslation translation;
translation.SetTranslation(trans[0], trans[1], trans[2]);
return new TGeoCombiTrans(translation, rotation);
}
void TB_Detector::Local2Global(Int_t detID,
Double_t xl, Double_t yl, Double_t zl,
Double_t& xg, Double_t& yg, Double_t& zg)
{
Log.ClearMessage();
Log.GetProcessName() = gActualClass;
Log.SetProcessMethod("Local2Global()");
Double_t local[3] = {xl, yl, zl};
Double_t global[3] = {0., 0., 0.};
if (detID < 0 || detID > 180) {
Log << error << "Wrong detector id number" << dolog;
return;
}
if(fMatrixList) {
TGeoCombiTrans* mat = static_cast<TGeoCombiTrans*> ( fMatrixList->At(detID) );
mat->LocalToMaster(local, global);
}
xg = global[0];
yg = global[1];
zg = global[2];
}
bool TB_Detector::ReadTransformation()
{
Log.ClearMessage();
Log.GetProcessName() = gActualClass;
Log.SetProcessMethod("ReadTransformation()");
Log << info << " Ge positions extracted from CrystalPositionLookUpTable " << nline;
TString FileName = fConfPath + "/CrystalPositionLookUpTable";
ifstream in(FileName, ios::in);
if (!in) {
Log << error << Form("file %s not found\n", FileName.Data()) << dolog;
return false;
}
fMatrixList = new TObjArray(180);
fMatrixList->SetOwner();
Int_t nd, k;
Double_t x,y,z;
Double_t trans[3];
Double_t rot[9];
Char_t line[255];
while ( !in.eof() ) {
in.getline(line,255);
if((((TString)line)==""))
continue;
if(sscanf(line, "%d %d %lf %lf %lf", &nd, &k, &x, &y, &z) != 5) {
Log << error << "a Problem reading translation factors" << dolog;