Commit 87406c69 authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Merge branch 'preprod' into 'preprod'

Merge TreeBuilder branch in preprod and correct EventBuilder bug

See merge request IPNL_GAMMA/narval_emulator!62
parents d125cd9a 92b09a91
...@@ -39,6 +39,8 @@ Frame: Agata data:ranc2 4 0 Agata data:ranc2 65000 0 ...@@ -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:psa 4 0 Agata data:psa 0 0
Frame: Agata data:tracked 4 0 Agata data:tracked 1 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 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: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:ranc0 4 0 Agata event:data:ranc0 4 0
Frame: Agata event:data:ranc1 4 0 Agata event:data:ranc1 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) ...@@ -765,7 +765,7 @@ UInt_t EventBuilder::GetParameters(const std::string& confFile, Bool_t doList)
} }
} }
if(conf.Seen("TstampCorrect")) { if(conf.Seen("TstampCorrect")) {
int which = conf.Find("TimestampCorrect"); int which = conf.Find("TstampCorrect");
int times = conf.Times(which); int times = conf.Times(which);
for(int nn = 0; nn < times; nn++) { for(int nn = 0; nn < times; nn++) {
conf.Restore(which, nn); conf.Restore(which, nn);
......
This diff is collapsed.
...@@ -21,15 +21,139 @@ ...@@ -21,15 +21,139 @@
#ifndef _TB_AGATA #ifndef _TB_AGATA
#define _TB_AGATA #define _TB_AGATA
#include "AGAPRO_TB_Detector.h" #include "CrystalFrame.h"
class TGeoCombiTrans; #include "AGAPRO_TB_Detector.h"
namespace AGAPRO { 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 ******/// /// ****** 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 struct core_property
{ {
...@@ -58,8 +182,8 @@ protected: ...@@ -58,8 +182,8 @@ protected:
Float_t hitGX[MaxHits]; // Position x of hit with , in global 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 hitGY[MaxHits]; // Position y of hit with , in global frame
Float_t hitGZ[MaxHits]; // Position z 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 hitId[MaxHits]; // Crystal ID in which a hit occurs
Int_t hitSg[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 nbCores; // for more than 1 frame (built event)
Int_t nbHitsperCry[MaxCore]; // nb of hits epr crystal Int_t nbHitsperCry[MaxCore]; // nb of hits epr crystal
...@@ -68,6 +192,11 @@ protected: ...@@ -68,6 +192,11 @@ protected:
Float_t coreE1[MaxCore]; // Core energy, low gain Float_t coreE1[MaxCore]; // Core energy, low gain
Float_t coreT0[MaxCore]; // Core time, high 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 nbAdd; // Addback multiplicity
Int_t AddId[MaxCore]; // Addback crystal Id of the hit with highest energy Int_t AddId[MaxCore]; // Addback crystal Id of the hit with highest energy
Float_t AddE[MaxCore]; // Addback energy Float_t AddE[MaxCore]; // Addback energy
...@@ -79,11 +208,9 @@ protected: ...@@ -79,11 +208,9 @@ protected:
ULong64_t AddTS[MaxCore]; // timestamp of he hit with highest energy ULong64_t AddTS[MaxCore]; // timestamp of he hit with highest energy
ULong64_t TSHit; ULong64_t TSHit;
TObjArray* fMatrixList = nullptr;
public: public:
TB_AGATA_Builder(TString name="", TString ADFKey=""); TB_AGATA_Builder_PSA(TString name="", TString ADFKey="");
virtual ~TB_AGATA_Builder(); virtual ~TB_AGATA_Builder_PSA();
void Init(); void Init();
void InitValues(); void InitValues();
...@@ -91,10 +218,6 @@ public: ...@@ -91,10 +218,6 @@ public:
void Process(Int_t idet); void Process(Int_t idet);
protected: 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) { static bool coreCompare(const core_property& firstElem, const core_property& secondElem) {
return firstElem.E > secondElem.E; return firstElem.E > secondElem.E;
} }
......
...@@ -39,7 +39,7 @@ TB_DIAMANT::~TB_DIAMANT() ...@@ -39,7 +39,7 @@ TB_DIAMANT::~TB_DIAMANT()
void TB_DIAMANT::Init() void TB_DIAMANT::Init()
{ {
fFrame = fTrigger->AddUtility("data:ranc1",ConfAgent::theGlobalAgent()); fSFrame = fTrigger->AddUtility("data:ranc1",ConfAgent::theGlobalAgent());
fDIAMANTFrame = new MFMDiamantFrame(); fDIAMANTFrame = new MFMDiamantFrame();
LoadLUT(); LoadLUT();
...@@ -83,7 +83,7 @@ void TB_DIAMANT::Process(Int_t idet) ...@@ -83,7 +83,7 @@ void TB_DIAMANT::Process(Int_t idet)
{ {
Log.ClearMessage(); Log.ClearMessage();
Log.GetProcessName() = gActualClass; Log.GetProcessName() = gActualClass;
Log.SetProcessMethod("Process()"); Log.SetProcessMethod(Form("Process(%d)",idet));
fCompFrame = (ADF::AgataCompositeFrame*) fTrigger->GetInputSharedFP(idet+1)->GetFrame(); fCompFrame = (ADF::AgataCompositeFrame*) fTrigger->GetInputSharedFP(idet+1)->GetFrame();
fCompFrame->Scan(); fCompFrame->Scan();
...@@ -101,9 +101,9 @@ void TB_DIAMANT::Process(Int_t idet) ...@@ -101,9 +101,9 @@ void TB_DIAMANT::Process(Int_t idet)
for(Int_t i = 0u; i <nbDIAMANT; i++) for(Int_t i = 0u; i <nbDIAMANT; i++)
{ {
fCompFrame->LinkSubFrame(i,fFrame->GetFrame()); fCompFrame->LinkSubFrame(i,fSFrame->GetFrame());
fFrame->GetFrame()->Read(); fSFrame->GetFrame()->Read();
fDIAMANTFrame->SetAttributs(((ADF::RawFrame *)fFrame->GetFrame())->RawBuffer().Address()); fDIAMANTFrame->SetAttributs(((ADF::RawFrame *)fSFrame->GetFrame())->RawBuffer().Address());
DIAMANTBoardId[i] = fDIAMANTFrame->GetBoardId(); DIAMANTBoardId[i] = fDIAMANTFrame->GetBoardId();
DIAMANTChannelId[i] = fDIAMANTFrame->GetTGCristalId() ; DIAMANTChannelId[i] = fDIAMANTFrame->GetTGCristalId() ;
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "AGAPRO_TB_Detector.h" #include "AGAPRO_TB_Detector.h"
#endif #endif
#include "TGeoMatrix.h"
using namespace AGAPRO; using namespace AGAPRO;
TB_Detector::TB_Detector(TString name, TString ADFKey) : TB_Detector::TB_Detector(TString name, TString ADFKey) :
...@@ -37,6 +39,125 @@ TB_Detector::~TB_Detector() ...@@ -37,6 +39,125 @@ TB_Detector::~TB_Detector()
{ {
if(fCompFrame) if(fCompFrame)
delete fCompFrame; delete fCompFrame;
if(fFrame) if(fSFrame)
delete fFrame; 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;
cin.get();
return false;
}
trans[0] = x; trans[1] = y, trans[2] = z;
if (nd > 180) {
Log << error << Form("Id %d too large, max: %d\n", nd, 180) << dolog;
return false;
}
in.getline(line,255);
if(sscanf(line, "%d %lf %lf %lf", &k, &x, &y, &z) != 4) {
Log << error << Form("b Problem reading 1st rotation factors for id %d\n", nd) << dolog;
return false;
}
rot[0] = x; rot[1] = y; rot[2] = z;
in.getline(line,255);
if(sscanf(line, "%d %lf %lf %lf", &k, &x, &y, &z) != 4) {
Log << error << Form("c Problem reading 2nd rotation factors for id %d\n", nd) << dolog;
return false;
}
rot[3] = x; rot[4] = y; rot[5] = z;
in.getline(line,255);
if(sscanf(line, "%d %lf %lf %lf", &k, &x, &y, &z) != 4) {
Log << error << Form("d Problem reading 3rd rotation factors for id %d\n", nd) << dolog;
return false;
}
rot[6] = x; rot[7] = y; rot[8] = z;
// add matrix for the given id
if (fMatrixList->At(nd)) {
Log << error << Form("Matrix transformation already exist for id %d\n", nd) << dolog;
return false;
} else
fMatrixList->AddAt( FillTransMatrix(trans, rot), nd );
}
in.close( );
Log << dolog;
} }
...@@ -37,10 +37,16 @@ ...@@ -37,10 +37,16 @@
using namespace std; using namespace std;
using namespace ADF; using namespace ADF;
class TGeoCombiTrans;
namespace AGAPRO { namespace AGAPRO {
class TB_Detector class TB_Detector
{ {
protected:
enum kType { crystal, ccrystal, psa, ppsa, undef };
kType fType;
public: public:
std::string gMotherClass = "TB_Detector"; std::string gMotherClass = "TB_Detector";
std::string gActualClass; std::string gActualClass;
...@@ -57,13 +63,15 @@ protected: ...@@ -57,13 +63,15 @@ protected:
Bool_t fIsTriggered = false; Bool_t fIsTriggered = false;
AgataFrameTrigger *fTrigger = nullptr; AgataFrameTrigger *fTrigger = nullptr;
AgataCompositeFrame *fCompFrame = nullptr; AgataCompositeFrame *fCompFrame = nullptr;
SharedFP *fFrame = nullptr; SharedFP *fSFrame = nullptr;
Frame *fFrame = nullptr;
TTree *fTree = nullptr; TTree *fTree = nullptr;
bool fNoMergerMode = false; bool fMergerMode = true;
TObjArray* fMatrixList = nullptr;
public: public:
TB_Detector(TString name="", TString ADFKey=""); TB_Detector(TString name="", TString ADFKey="");
...@@ -95,8 +103,13 @@ public: ...@@ -95,8 +103,13 @@ public:
void SetTriggered(Bool_t ok){fIsTriggered = ok;} void SetTriggered(Bool_t ok){fIsTriggered = ok;}
Bool_t IsTriggered(){return fIsTriggered;} Bool_t IsTriggered(){return fIsTriggered;}
void SetNoMergerMode(Bool_t mode){fNoMergerMode = mode;} void SetMergerMode(Bool_t mode){fMergerMode = mode;}
Bool_t GetNoMergerMode(){return fNoMergerMode;} Bool_t GetMergerMode(){return fMergerMode;}
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();
}; };
} }
......
...@@ -39,7 +39,7 @@ TB_NEDA::~TB_NEDA() ...@@ -39,7 +39,7 @@ TB_NEDA::~TB_NEDA()
void TB_NEDA::Init() void TB_NEDA::Init()
{ {
fFrame = fTrigger->AddUtility("data:ranc0",ConfAgent::theGlobalAgent()); fSFrame = fTrigger->AddUtility("data:ranc0",ConfAgent::theGlobalAgent());
fNEDAFrame = new MFMNedaCompFrame(); fNEDAFrame = new MFMNedaCompFrame();
LoadLUT(); LoadLUT();
...@@ -87,7 +87,7 @@ void TB_NEDA::Process(Int_t idet) ...@@ -87,7 +87,7 @@ void TB_NEDA::Process(Int_t idet)
{ {
Log.ClearMessage(); Log.ClearMessage();
Log.GetProcessName() = gActualClass; Log.GetProcessName() = gActualClass;
Log.SetProcessMethod("Process()"); Log.SetProcessMethod(Form("Process(%d)",idet));
fCompFrame = (ADF::AgataCompositeFrame*) fTrigger->GetInputSharedFP(idet+1)->GetFrame(); fCompFrame = (ADF::AgataCompositeFrame*) fTrigger->GetInputSharedFP(idet+1)->GetFrame();
fCompFrame->Scan(); fCompFrame->Scan();
...@@ -105,9 +105,9 @@ void TB_NEDA::Process(Int_t idet) ...@@ -105,9 +105,9 @@ void TB_NEDA::Process(Int_t idet)
for(Int_t i = 0u; i <nbNEDA; i++) for(Int_t i = 0u; i <nbNEDA; i++)
{ {
fCompFrame->LinkSubFrame(i,fFrame->GetFrame()); fCompFrame->LinkSubFrame(i,fSFrame->GetFrame());
fFrame->GetFrame()->Read(); fSFrame->GetFrame()->Read();
fNEDAFrame->SetAttributs(((ADF::RawFrame *)fFrame->GetFrame())->RawBuffer().Address()); fNEDAFrame->SetAttributs(((ADF::RawFrame *)fSFrame->GetFrame())->RawBuffer().Address());
NEDABoardId[i] = fNEDAFrame->GetBoardId(); NEDABoardId[i] = fNEDAFrame->GetBoardId();
NEDAChannelId[i] = fNEDAFrame->GetChannelId() ; NEDAChannelId[i] = fNEDAFrame->GetChannelId() ;
......
...@@ -48,7 +48,7 @@ TB_VAMOS::~TB_VAMOS() ...@@ -48,7 +48,7 @@ TB_VAMOS::~TB_VAMOS()
void TB_VAMOS::Init() void TB_VAMOS::Init()
{ {
fFrame = fTrigger->AddUtility("data:ranc0",ConfAgent::theGlobalAgent()); fSFrame = fTrigger->AddUtility("data:ranc0",ConfAgent::theGlobalAgent());
fMFMMergeFrame = new MFMMergeFrame(); fMFMMergeFrame = new MFMMergeFrame();
fMFMCommonFrame = new MFMCommonFrame(); fMFMCommonFrame = new MFMCommonFrame();
fMFMEBYFrame = new MFMEbyedatFrame(); fMFMEBYFrame = new MFMEbyedatFrame();
...@@ -132,15 +132,15 @@ void TB_VAMOS::Process(Int_t idet) ...@@ -132,15 +132,15 @@ void TB_VAMOS::Process(Int_t idet)
{ {
Log.ClearMessage(); Log.ClearMessage();
Log.GetProcessName() = gActualClass; Log.GetProcessName() = gActualClass;
Log.SetProcessMethod("Process()"); Log.SetProcessMethod(Form("Process(%d)",idet));
if(fAnalysis == nullptr) if(fAnalysis == nullptr)
return; return;
fFrame = fTrigger->GetInputSharedFP(idet+1); fSFrame = fTrigger->GetInputSharedFP(idet+1);
fFrame->GetFrame()->Read(); fSFrame->GetFrame()->Read();
fMFMCommonFrame->SetAttributs(((ADF::RawFrame *)fFrame->GetFrame())->RawBuffer().Address()); fMFMCommonFrame->SetAttributs(((ADF::RawFrame *)fSFrame->GetFrame())->RawBuffer().Address());
fAnalysis->UnPack(fMFMCommonFrame); fAnalysis->UnPack(fMFMCommonFrame);
fAnalysis->Treat(); fAnalysis->Treat();
......
...@@ -47,11 +47,7 @@ using namespace AGAPRO; ...@@ -47,11 +47,7 @@ using namespace AGAPRO;
string TreeBuilder::gMotherClass = "TreeBuilder"; string TreeBuilder::gMotherClass = "TreeBuilder";