Commit 66e4971d authored by Stezowski Olivier's avatar Stezowski Olivier
Browse files

first try to integrate Argonne Forward Tracking

parent cf28cd7b
......@@ -88,13 +88,25 @@ endif()
#
OPTION(DO_MGT_INTERFACE "Add the Narval interface for MGT" ON)
if ( DO_MGT_INTERFACE )
if ( DO_MGT )
if ( WITH_MGT )
MESSAGE("[AGAPRO] MGT, External built-in ")
else()
MESSAGE("[AGAPRO] MGT, Internal built-in ")
OPTION(DO_MGT "Built internal MGT" ON)
endif()
endif()
#
# ADD AFT
#
OPTION(DO_AFT_INTERFACE "Add the Narval interface for AFT" OFF)
if ( DO_AFT_INTERFACE )
if ( WITH_AFT )
MESSAGE("[AGAPRO] AFT, External built-in ")
else()
MESSAGE("[AGAPRO] AFT, Internal built-in ")
OPTION(DO_AFT "Built internal AFT" ON)
endif()
endif()
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Find mondule using cmake find system
......
......@@ -517,7 +517,7 @@ void *Histogramer::CreateNewSMz(const char *name, Int_t Size, Int_t PortNumber)
if(result==-1)
{
Log.SetLevel(LogMessage::kError);
cout << "Error in the SMZ creation: "<<SMZ.str() << dolog;
Log << "Error in the SMZ creation: "<<SMZ.str() << dolog;
}
// create a new Transport Layer
......@@ -541,7 +541,7 @@ void *Histogramer::CreateNewSMz(const char *name, Int_t Size, Int_t PortNumber)
if(result==-1)
{
Log.SetLevel(LogMessage::kError);
cout << "Error in the TL creation: "<<SMZ.str() << dolog;
Log << "Error in the TL creation: "<<SMZ.str() << dolog;
}
// Connect a new Transport Layer to the SMZ
......@@ -556,7 +556,7 @@ void *Histogramer::CreateNewSMz(const char *name, Int_t Size, Int_t PortNumber)
if(result==-1)
{
Log.SetLevel(LogMessage::kError);
cout << "Error in the TL connexion: "<<SMZ.str() << dolog;
Log << "Error in the TL connexion: "<<SMZ.str() << dolog;
}
}
else
......
/********************************************************************************
* Copyright (c) IPNL, IN2P3, CNRS *
* Contibutor(s) : *
* Olivier Stezowski stezow(AT)ipnl.in2p3.fr [2018] *
* *
* The AGAPRO package contains actors processing the AGATA Data flows *
* *
* This software is governed by the CeCILL-B license under French law and *
* abiding by the rules of distribution of free software. You can use, *
* modify and/ or redistribute the software under the terms of the *
* CeCILL-B license as circulated by CEA, CNRS and INRIA at the following *
* URL \"http://www.cecill.info\". *
* *
* As a counterpart to the access to the source code and rights to copy, *
* modify and redistribute granted by the license, users are provided *
* only with a limited warranty and the software's author, the holder of *
* the economic rights, and the successive licensors have only limited *
* liability. *
* *
* In this respect, the user's attention is drawn to the risks associated *
* with loading, using, modifying and/or developing or reproducing the *
* software by the user in light of its specific status of free software, *
* that may mean that it is complicated to manipulate, and that also *
* therefore means that it is reserved for developers and experienced *
* professionals having in-depth computer knowledge. Users are therefore *
* encouraged to load and test the software's suitability as regards *
* their requirements in conditions enabling the security of their *
* systems and/or data to be ensured and, more generally, to use and *
* operate it in the same conditions as regards security. *
* *
* The fact that you are presently reading this means that you have had *
* knowledge of the CeCILL-B license and that you accept its terms. *
********************************************************************************/
/** @file AGAPRO_AFT.cpp compiled in libAGAPRO_ */
#include "AGAPRO_AFT.h"
#include "AgataKeyFactory.h"
#include "PSAFrame.h"
#include "GEBheaders.h"
typedef GRETINA::crys_intpts CRYS_INTPTS3;
AGAPRO::AFT::AFT() :
GTOnADFHits()
{
track.gd = (GEBDATA *) calloc (MAXTRACK, sizeof (GEBDATA));
track.payload = (PAYLOAD *) calloc (MAXTRACK, sizeof (PAYLOAD));
memset ((void *) &ctkStat, 0, sizeof (STAT));
}
AGAPRO::AFT::~AFT()
{
}
void AGAPRO::AFT::process_config (const Char_t *directory_path, UInt_t *error_code)
{
*error_code = 0;
// first init mother class
AGAPRO::GTOnADFHits::process_config(directory_path, error_code);
if( *error_code )
return;
// then daugher
}
void AGAPRO::AFT::process_initialise (UInt_t *error_code)
{
// local init
std::string tmp, option; *error_code = 0u; Log.ClearMessage(); Log.SetProcessMethod("process_initialise");
// trigger are set by the mother class
AGAPRO::GTOnADFHits::process_initialise (error_code);
// init from trackMain
setupTrack (&timesThen, &ctkStat, &shellhit);
std::string conffile = GetConfPath();
conffile += "GANIL_AGATA_crmat.dat";
readChatFile (conffile.data());
setupTrack_crmat (&timesThen, &ctkStat, &shellhit);
}
UInt_t AGAPRO::AFT::SetInput()
{
ADF::SharedFP *psa_frames = nullptr; CRYS_INTPTS3 *ptpayload = nullptr; GEBDATA *ptgd = nullptr;
track.n = 0;
//
if ( triggerOnEvents->IsFired() ) {
psa_frames = triggerOnEvents->GetInputSharedFP(1);
}
else {
psa_frames = triggerOnPSAEvents->GetInputSharedFP();
}
// Scan the event:data:psa frame to extract all the PSAInterface and move them into track structures
UInt_t nb_psa_frames = psa_frames->GetFrame()->Scan(); ADF::SharedFP *psa;
if ( nb_psa_frames > MAXTRACK ) {
Log << ADF::error << "Input frame contains too many hits for AFT" << ADF::dolog;
return 1u;
}
// move adf hits into TRACK_STRUCT
track.n = static_cast<int>(nb_psa_frames); ptgd = track.gd; ptpayload = (CRYS_INTPTS3 *)track.payload;
for (UInt_t i = 0u; i < nb_psa_frames; i++) {
psa_frames->GetFrame()->LinkSubFrame(i,frameOnePSA->GetFrame());
frameOnePSA->GetFrame()->Read();
ADF::PSAInterface *psadata =
ADF::GetDataPointer<ADF::PSAInterface>(frameOnePSA);
// first set GEBHeader for that
ptgd->type = GEB_TYPE_DECOMP;
ptgd->length = sizeof (CRYS_INTPTS3);
ptgd->timestamp = ((ADF::AgataKey *)psa_frames->GetFrame()->GetKey())->GetTimeStamp(); // TO BE CHECKED
bzero ((void *) ptpayload, sizeof (CRYS_INTPTS3));
/* Pass on as much as we have of the the header. */
/* What we can't/don't pass will be zero */
ptpayload->type = (int) 0xabcd5678;
unsigned int moduleno, crystalno;
moduleno = psadata->GetUID() / 3;
crystalno = psadata->GetUID() - moduleno * 3;
ptpayload->crystal_id = crystalno;
ptpayload->crystal_id |= (moduleno << 2);
ptpayload->num = psadata->GetNbHits();
ptpayload->tot_e = psadata->GetE();
ptpayload->timestamp = ((ADF::AgataKey *)psa_frames->GetFrame()->GetKey())->GetTimeStamp();; // TO BE CHECKED
ptpayload->trig_time = 0;
ptpayload->t0 = 0;
ptpayload->cfd = 0;
ptpayload->chisq = 0;
ptpayload->norm_chisq = 0;
ptpayload->baseline = 0;
ptpayload->pad = 0;
for (int j = 0; j < ptpayload->num; j++)
{
const ADF::PSAHit *psahit = dynamic_cast<ADF::PSAHit*>(psadata->GetHit(j));
if ( psahit->GetID(1) != psadata->GetUID() ) {
std::cout << "PB Crystal ID in psa:data is different that for hit " << j << std::endl;
}
ptpayload->intpts[j].x = psahit->GetX();
ptpayload->intpts[j].y = psahit->GetY();
ptpayload->intpts[j].z = psahit->GetZ();
ptpayload->intpts[j].e = psahit->GetE();
ptpayload->intpts[j].seg = psahit->GetID(0);
ptpayload->intpts[j].seg_ener = psahit->GetE();
};
// fill next one
ptgd++;
ptpayload++;
}
return 0u;
}
UInt_t AGAPRO::AFT::SetOutput()
{
/*
ADF::SharedFP *track_frame = nullptr;
//
if ( triggerOnEvents->IsFired() ) {
track_frame = triggerOnEvents->GetOutputSharedFP();
}
else {
track_frame = triggerOnPSAEvents->GetOutputSharedFP();
}
// Scan the event:data:psa frame to extract all the PSAInterface and move them into track structures
UInt_t nb_psa_frames = psa_frames->GetFrame()->Scan(); ADF::SharedFP *psa;
if ( nb_psa_frames > MAXTRACK ) {
Log << ADF::error << "Input frame contains too many hits for AFT" << ADF::dolog;
return 1u;
}
for (iCluster = 0; iCluster < *nClusters; iCluster++){
}
{
bzero ((char *) &tgr, sizeof (TRACKED_GAMMA_RAY));
tgr.esum = Clstr[iCluster].esum * 1000;
tgr.ndet = Clstr[iCluster].ndet;
tgr.fom = Clstr[iCluster].fom;
tgr.tracked = Clstr[iCluster].tracked;
#if(0)
fprintf (stderr,"sizeof (TRACKED_GAMMA_RAY)=%i bytes\n", sizeof (TRACKED_GAMMA_RAY));
fprintf (stderr,"sizeof(int)=%i\n", sizeof (int));
fprintf (stderr,"sizeof(float)=%i\n", sizeof (float));
fprintf (stderr,"sizeof(long long int)=%i\n", sizeof (long long int));
fprintf (stderr,"sizeof(char)=%i\n", sizeof (char));
fprintf (stderr,"tgr.esum=%f ;", tgr.esum);
fprintf (stderr,"tgr.ndet=%i;", tgr.ndet);
fprintf (stderr,"tgr.fom=%f ;", tgr.fom);
fprintf (stderr,"tgr.tracked=%i ;", tgr.tracked);
fprintf (stderr,"\n");
#endif
// find and extract first and second interaction points
// write in mm and keV from cm and keV
for (j = 0; j < Clstr[iCluster].ndet; j++)
{
if (Clstr[iCluster].intpts[j].order == 0)
{
tgr.x0 = Clstr[iCluster].intpts[j].xx * 10;
tgr.y0 = Clstr[iCluster].intpts[j].yy * 10;
tgr.z0 = Clstr[iCluster].intpts[j].zz * 10;
tgr.e0 = Clstr[iCluster].intpts[j].edet * 1000;
tgr.timestamp = Clstr[iCluster].intpts[j].timestamp;
#if (TRACK2==1)
tgr.fhcrID=Clstr[iCluster].intpts[j].detno;
#endif
}
if (Clstr[iCluster].intpts[j].order == 1)
{
tgr.x1 = Clstr[iCluster].intpts[j].xx * 10;
tgr.y1 = Clstr[iCluster].intpts[j].yy * 10;
tgr.z1 = Clstr[iCluster].intpts[j].zz * 10;
tgr.e1 = Clstr[iCluster].intpts[j].edet * 1000;
}
};
// store in payload
memcpy (payLoad + trackGeb.length, (char *) &tgr, sizeof (TRACKED_GAMMA_RAY));
trackGeb.length += sizeof (TRACKED_GAMMA_RAY);
// keep record of how many gamma arays
// we actually write out
ctkStat->gammasWritten++;
}
*/
return 0u;
}
UInt_t AGAPRO::AFT::Process()
{
for (int j = 0; j < MAXCLUSTERHITS; j++)
memset ((void *) &Clstr[j], 0, sizeof (CLUSTER_INTPTS));
// trackStatus = trackEvent (target_pos, &track, &ctkStat, &shellhit, Clstr, &nClusters);
return 0u;
}
UInt_t AGAPRO::AFT::ProcessBlock (ADF::FrameBlock &in, ADF::FrameBlock &out)
{
Log.ClearMessage(); Log.SetProcessMethod("process_block");
// attach the input/output buffer to the FrameIO system
GetFrameIO().Attach(&in,&out);
// start the processing
UInt_t error_code = 0u;
while ( GetFrameIO().Notify() ) { // process the input
if ( ! (SetInput() == 0u && Process() == 0u && SetOutput() == 0u) )
{ error_code = 1u; break; }
else {
if ( !GetFrameIO().Record() )
{ error_code = 2u; break; }
}
}
if ( error_code == 1u ) {
Log << ADF::error
<< "During processing : SetInput -> Process -> SetOuput() " << ADF::nline;
}
if ( error_code == 2u ) {
Log << ADF::error
<< "During Record() " << ADF::nline;
}
GetFrameIO().Detach(&in,&out);
// send messages to the central log
Log << ADF::dolog;
return error_code;
}
/********************************************************************************
* Copyright (c) IPNL, IN2P3, CNRS *
* Contibutor(s) : *
* Olivier Stezowski stezow(AT)ipnl.in2p3.fr [2018] *
* *
* The AGAPRO package contains actors processing the AGATA Data flows *
* *
* This software is governed by the CeCILL-B license under French law and *
* abiding by the rules of distribution of free software. You can use, *
* modify and/ or redistribute the software under the terms of the *
* CeCILL-B license as circulated by CEA, CNRS and INRIA at the following *
* URL \"http://www.cecill.info\". *
* *
* As a counterpart to the access to the source code and rights to copy, *
* modify and redistribute granted by the license, users are provided *
* only with a limited warranty and the software's author, the holder of *
* the economic rights, and the successive licensors have only limited *
* liability. *
* *
* In this respect, the user's attention is drawn to the risks associated *
* with loading, using, modifying and/or developing or reproducing the *
* software by the user in light of its specific status of free software, *
* that may mean that it is complicated to manipulate, and that also *
* therefore means that it is reserved for developers and experienced *
* professionals having in-depth computer knowledge. Users are therefore *
* encouraged to load and test the software's suitability as regards *
* their requirements in conditions enabling the security of their *
* systems and/or data to be ensured and, more generally, to use and *
* operate it in the same conditions as regards security. *
* *
* The fact that you are presently reading this means that you have had *
* knowledge of the CeCILL-B license and that you accept its terms. *
********************************************************************************/
/** @file AGAPRO_AFT virtual base class for all the Gamma-ray trackers */
#ifndef AGAPRO_AFT_h
#define AGAPRO_AFT_h
#include "AGAPRO_GammaTracker.h"
#include "ctk.h"
#include <sys/times.h>
namespace AGAPRO {
//! ATF : Argonne Forward Tracker
/*!
This is the interface to run Torben's code in the AGAPRO environnement
*/
class AFT : public GTOnADFHits
{
private:
TRACKINGPAR Pars;
private:
struct tms timesThen;
//! Torben's code internal structures
TRACK_STRUCT track;
STAT ctkStat;
SHELLHIT shellhit;
int nClusters;
CLUSTER_INTPTS Clstr[MAXCLUSTERHITS];
float target_pos[3];
protected:
//! read the data from the trigger and put them in local variable
virtual UInt_t SetInput();
//! process this with the current conditions
virtual UInt_t Process();
//! compute output of the process
virtual UInt_t SetOutput();
public:
AFT();
virtual ~AFT();
//! NARVAL/DCOD interface
static void process_config (const Char_t *, UInt_t *);
virtual void process_initialise (UInt_t *error_code);
virtual UInt_t ProcessBlock (ADF::FrameBlock &, ADF::FrameBlock &);
};
} // AGAPRO namespace
#endif //AGAPRO_AFT_h
/********************************************************************************
* Copyright (c) IPNL, IN2P3, CNRS *
* Contibutor(s) : *
* Olivier Stezowski stezow(AT)ipnl.in2p3.fr [2018] *
* *
* The AGAPRO package contains actors processing the AGATA Data flows *
* *
* This software is governed by the CeCILL-B license under French law and *
* abiding by the rules of distribution of free software. You can use, *
* modify and/ or redistribute the software under the terms of the *
* CeCILL-B license as circulated by CEA, CNRS and INRIA at the following *
* URL \"http://www.cecill.info\". *
* *
* As a counterpart to the access to the source code and rights to copy, *
* modify and redistribute granted by the license, users are provided *
* only with a limited warranty and the software's author, the holder of *
* the economic rights, and the successive licensors have only limited *
* liability. *
* *
* In this respect, the user's attention is drawn to the risks associated *
* with loading, using, modifying and/or developing or reproducing the *
* software by the user in light of its specific status of free software, *
* that may mean that it is complicated to manipulate, and that also *
* therefore means that it is reserved for developers and experienced *
* professionals having in-depth computer knowledge. Users are therefore *
* encouraged to load and test the software's suitability as regards *
* their requirements in conditions enabling the security of their *
* systems and/or data to be ensured and, more generally, to use and *
* operate it in the same conditions as regards security. *
* *
* The fact that you are presently reading this means that you have had *
* knowledge of the CeCILL-B license and that you accept its terms. *
********************************************************************************/
/** @file AGAPRO_GammaTracker.cpp compiled in libAGAPRO_ */
#include "AGAPRO_GammaTracker.h"
void AGAPRO::GammaTracker::process_config(const Char_t *directory_path, UInt_t *error_code)
{
*error_code = 0;
// first init narval stuff
NarvalFilter::process_config(directory_path, error_code);
if( *error_code )
return;
// then do Gammatracker statics
}
AGAPRO::GTOnADFHits::GTOnADFHits() :
GammaTracker(),
frameAllPSA(nullptr),
frameOnePSA(nullptr),
triggerOnEvents(nullptr),
triggerOnPSAEvents(nullptr)
{
Log.GetProcessName() = "GTOnADFHits";
}
AGAPRO::GTOnADFHits::~GTOnADFHits()
{
}
void AGAPRO::GTOnADFHits::process_initialise (UInt_t *error_code)
{
// local init
std::string tmp, option; *error_code = 0u; Log.ClearMessage(); Log.SetProcessMethod("process_initialise");
// those trigger allw this filter to get event:data:psa required for tracking from file out of the event builder or the merger
triggerOnEvents =
ADF::AgataFrameTrigger::Build("TriggerFromEvents", "event:data event:data:psa","data:tracked");
triggerOnPSAEvents =
ADF::AgataFrameTrigger::Build("TriggerFromEvents", "event:data:psa","data:tracked");
if ( triggerOnEvents == nullptr && triggerOnPSAEvents == nullptr ) {
*error_code = 1u;
Log << ADF::error << " Cannot Init the triggers " << ADF::dolog;
}
else {
if (triggerOnEvents) {
frameOnePSA = triggerOnEvents->AddUtility("data:psa",GetFrameIO().GetConfAgent());
GetFrameIO().Register(triggerOnEvents);
}
if (triggerOnPSAEvents) {
if (frameOnePSA==nullptr) {
frameOnePSA = triggerOnEvents->AddUtility("data:psa",GetFrameIO().GetConfAgent());
}
GetFrameIO().Register(triggerOnPSAEvents);
}
GetFrameIO().SetStatus(ADF::BaseFrameIO::kIdle);
}
Log << ADF::dolog;
}
void AGAPRO::GTOnADFHits::process_config(const Char_t *directory_path, UInt_t *error_code)
{
*error_code = 0;
// first init mother class
GammaTracker::process_config(directory_path, error_code);
if( *error_code )
return;
// then daugher
}
/********************************************************************************
* Copyright (c) IPNL, IN2P3, CNRS *
* Contibutor(s) : *
* Olivier Stezowski stezow(AT)ipnl.in2p3.fr [2018] *
* *
* The AGAPRO package contains actors processing the AGATA Data flows *
* *
* This software is governed by the CeCILL-B license under French law and *
* abiding by the rules of distribution of free software. You can use, *
* modify and/ or redistribute the software under the terms of the *
* CeCILL-B license as circulated by CEA, CNRS and INRIA at the following *
* URL \"http://www.cecill.info\". *
* *
* As a counterpart to the access to the source code and rights to copy, *
* modify and redistribute granted by the license, users are provided *
* only with a limited warranty and the software's author, the holder of *
* the economic rights, and the successive licensors have only limited *
* liability. *
* *
* In this respect, the user's attention is drawn to the risks associated *
* with loading, using, modifying and/or developing or reproducing the *
* software by the user in light of its specific status of free software, *
* that may mean that it is complicated to manipulate, and that also *
* therefore means that it is reserved for developers and experienced *
* professionals having in-depth computer knowledge. Users are therefore *
* encouraged to load and test the software's suitability as regards *
* their requirements in conditions enabling the security of their *
* systems and/or data to be ensured and, more generally, to use and *
* operate it in the same conditions as regards security. *
* *
* The fact that you are presently reading this means that you have had *
* knowledge of the CeCILL-B license and that you accept its terms. *
********************************************************************************/
/** @file AGAPRO_GammaTracker virtual base class for all the Gamma-ray trackers */
#ifndef AGAPRO_GammaTracker_h
#define AGAPRO_GammaTracker_h
#include "NarvalInterface.h"
#include "Trigger.h"
#include "Frame.h"
namespace AGAPRO {
//! Virtual Base class for all gamma-ray trackers
/*!
*/
class GammaTracker : public ADF::NarvalFilter