Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • le.koch/cbmroot
  • patrick.pfistner_AT_kit.edu/cbmroot
  • lena.rossel_AT_stud.uni-frankfurt.de/cbmroot
  • i.deppner/cbmroot
  • fweig/cbmroot
  • karpushkin_AT_inr.ru/cbmroot
  • v.akishina/cbmroot
  • rishat.sultanov_AT_cern.ch/cbmroot
  • l_fabe01_AT_uni-muenster.de/cbmroot
  • pwg-c2f/cbmroot
  • j.decuveland/cbmroot
  • a.toia/cbmroot
  • i.vassiliev/cbmroot
  • n.herrmann/cbmroot
  • o.lubynets/cbmroot
  • se.gorbunov/cbmroot
  • cornelius.riesen_AT_physik.uni-giessen.de/cbmroot
  • zhangqn17_AT_mails.tsinghua.edu.cn/cbmroot
  • bartosz.sobol/cbmroot
  • ajit.kumar/cbmroot
  • computing/cbmroot
  • a.agarwal_AT_vecc.gov.in/cbmroot
  • osingh/cbmroot
  • wielanek_AT_if.pw.edu.pl/cbmroot
  • malgorzata.karabowicz.stud_AT_pw.edu.pl/cbmroot
  • m.shiroya/cbmroot
  • s.roy/cbmroot
  • p.-a.loizeau/cbmroot
  • a.weber/cbmroot
  • ma.beyer/cbmroot
  • d.klein/cbmroot
  • d.smith/cbmroot
  • mvdsoft/cbmroot
  • d.spicker/cbmroot
  • y.h.leung/cbmroot
  • m.deveaux/cbmroot
  • mkunold/cbmroot
  • h.darwish/cbmroot
  • f_fido01_AT_uni-muenster.de/cbmroot
  • g.kozlov/cbmroot
  • d.emschermann/cbmroot
  • evgeny.lavrik/cbmroot
  • v.friese/cbmroot
  • f.uhlig/cbmroot
  • ebechtel_AT_ikf.uni-frankfurt.de/cbmroot
  • a.senger/cbmroot
  • praisig/cbmroot
  • s.lebedev/cbmroot
  • redelbach_AT_compeng.uni-frankfurt.de/cbmroot
  • p.subramani/cbmroot
  • a_meye37_AT_uni-muenster.de/cbmroot
  • om/cbmroot
  • o.golosov/cbmroot
  • l.chlad/cbmroot
  • a.bercuci/cbmroot
  • d.ramirez/cbmroot
  • v.singhal/cbmroot
  • h.schiller/cbmroot
  • apuntke/cbmroot
  • f.zorn/cbmroot
  • rubio_AT_physi.uni-heidelberg.de/cbmroot
  • p.chudoba/cbmroot
  • apuntke/mcbmroot
  • r.karabowicz/cbmroot
64 results
Show changes
Showing
with 3262 additions and 2461 deletions
......@@ -43,7 +43,7 @@ If(UNIX AND NOT APPLE)
EndIf()
set(FAIR_LIBS
FairMQ
${FAIRMQ_LIBS}
)
If(FAIRLOGGER_FOUND)
......@@ -53,13 +53,18 @@ If(FAIRLOGGER_FOUND)
)
EndIf()
# Dependencies common to all executables
set(DEPENDENCIES_ALL
${DEPENDENCIES}
${FAIR_LIBS}
${BOOST_LIBS}
)
set(EXE_NAME StsLocalReco)
set(SRCS CbmDeviceStsLocalReco.cxx runStsLocalReco.cxx)
set(DEPENDENCIES
${DEPENDENCIES}
${FAIR_LIBS}
${BOOST_LIBS}
${DEPENDENCIES_ALL}
CbmField
CbmSts
Core
......
/* Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig [committer] */
/**
* CbmDeviceStsLocalReco.cxx
*
......@@ -8,25 +12,16 @@
#include "CbmDeviceStsLocalReco.h"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairMQProgOptions.h" // device->fConfig
CbmDeviceStsLocalReco::CbmDeviceStsLocalReco()
: FairMQDevice(), fMaxTimeslices{0}, fNumMessages{0}
{
}
CbmDeviceStsLocalReco::CbmDeviceStsLocalReco() : FairMQDevice(), fMaxTimeslices {0}, fNumMessages {0} {}
void CbmDeviceStsLocalReco::InitTask()
{
// fMaxTimeslices = fConfig->GetValue<uint64_t>("max-timeslices");
// fMaxTimeslices = fConfig->GetValue<uint64_t>("max-timeslices");
}
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
bool CbmDeviceStsLocalReco::HandleData(FairMQMessagePtr& msg, int /*index*/)
{
return true;
}
CbmDeviceStsLocalReco::~CbmDeviceStsLocalReco()
{
}
bool CbmDeviceStsLocalReco::HandleData(FairMQMessagePtr& msg, int /*index*/) { return true; }
CbmDeviceStsLocalReco::~CbmDeviceStsLocalReco() {}
/* Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig [committer] */
/**
* CbmDeviceStsLocalReco.h
*
......@@ -8,37 +12,24 @@
#ifndef CBMDEVICESTSLOCALRECO_H_
#define CBMDEVICESTSLOCALRECO_H_
#include "CbmMqTMessage.h"
#include "FairMQDevice.h"
#include "TMessage.h"
#include <vector>
class CbmDeviceStsLocalReco: public FairMQDevice
{
public:
CbmDeviceStsLocalReco();
virtual ~CbmDeviceStsLocalReco();
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
class CbmDeviceStsLocalReco : public FairMQDevice {
public:
CbmDeviceStsLocalReco();
virtual ~CbmDeviceStsLocalReco();
private:
uint64_t fMaxTimeslices;
uint64_t fNumMessages;
};
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
// special class to expose protected TMessage constructor
class CbmMQTMessage : public TMessage
{
public:
CbmMQTMessage(void* buf, Int_t len)
: TMessage(buf, len)
{
ResetBit(kIsOwner);
}
private:
uint64_t fMaxTimeslices;
uint64_t fNumMessages;
};
#endif /* CBMDEVICESTSLOCALRECO_H_ */
/* Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig [committer] */
/**
* CbmDeviceStsLocalReco.cxx
*
......@@ -6,26 +10,23 @@
*/
#include "CbmDeviceStsLocalReco.h"
#include "CbmMQDefs.h"
#include "CbmStsDigitizeParameters.h"
#include "CbmFieldPar.h"
#include "CbmBsField.h"
#include "CbmFieldConst.h"
#include "CbmFieldMap.h"
#include "CbmFieldMapDistorted.h"
#include "CbmFieldMapSym1.h"
#include "CbmFieldMapSym2.h"
#include "CbmFieldMapSym3.h"
#include "CbmFieldMapDistorted.h"
#include "CbmFieldMapSym1.h"
#include "CbmBsField.h"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "CbmFieldPar.h"
#include "CbmMQDefs.h"
#include "CbmStsDigitizeParameters.h"
#include "FairField.h"
#include "FairGeoParSet.h"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairRunAna.h"
#include "FairField.h"
//#include "FairParGenericSet.h"
//#include "RootSerializer.h"
......@@ -34,34 +35,34 @@
#include "TSystem.h"
/*
#include "TNamed.h"
#include "TList.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH1.h"
#include "TList.h"
#include "TNamed.h"
*/
#include <string>
#include <iomanip>
#include <array>
#include <boost/archive/binary_iarchive.hpp>
#include <array>
#include <iomanip>
#include <stdexcept>
struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; };
#include <string>
struct InitTaskError : std::runtime_error {
using std::runtime_error::runtime_error;
};
//using namespace std;
using std::string;
CbmDeviceStsLocalReco::CbmDeviceStsLocalReco()
: fMaxTimeslices{0}
, fNumMessages{0}
, fRunId{"0"}
, fvmcworkdir{""}
, fDigiPar{nullptr}
, fGeoPar{nullptr}
, fFieldPar{nullptr}
// , fParCList{nullptr}
: fMaxTimeslices {0}
, fNumMessages {0}
, fRunId {"0"}
, fvmcworkdir {""}
, fDigiPar {nullptr}
, fGeoPar {nullptr}
, fFieldPar {nullptr} // , fParCList{nullptr}
{
}
......@@ -75,29 +76,29 @@ CbmDeviceStsLocalReco::~CbmDeviceStsLocalReco()
void CbmDeviceStsLocalReco::InitTask()
try
{
fMaxTimeslices = fConfig->GetValue<uint64_t>("max-timeslices");
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
// for the device
// The idea is to check at initilization if the devices are
// properly connected. For the time beeing this is done with a
// nameing convention. It is not avoided that someone sends other
// data on this channel.
try {
fMaxTimeslices = fConfig->GetValue<uint64_t>("max-timeslices");
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
// for the device
// The idea is to check at initilization if the devices are
// properly connected. For the time beeing this is done with a
// nameing convention. It is not avoided that someone sends other
// data on this channel.
//logger::SetLogLevel("INFO");
int noChannel = fChannels.size();
LOG(INFO) << "Number of defined channels: " << noChannel;
for(auto const &entry : fChannels) {
LOG(INFO) << "Channel name: " << entry.first;
if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match.");
OnData(entry.first, &CbmDeviceStsLocalReco::HandleData);
}
InitContainers();
} catch (InitTaskError& e) {
LOG(ERROR) << e.what();
int noChannel = fChannels.size();
LOG(info) << "Number of defined channels: " << noChannel;
for (auto const& entry : fChannels) {
LOG(info) << "Channel name: " << entry.first;
if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match.");
OnData(entry.first, &CbmDeviceStsLocalReco::HandleData);
}
InitContainers();
}
catch (InitTaskError& e) {
LOG(error) << e.what();
// Wrapper defined in CbmMQDefs.h to support different FairMQ versions
cbm::mq::ChangeState(this, cbm::mq::Transition::ErrorFound);
}
......@@ -105,41 +106,41 @@ try
bool CbmDeviceStsLocalReco::IsChannelNameAllowed(std::string channelName)
{
for(auto const &entry : fAllowedChannels) {
for (auto const& entry : fAllowedChannels) {
std::size_t pos1 = channelName.find(entry);
if (pos1!=std::string::npos) {
if (pos1 != std::string::npos) {
const std::vector<std::string>::const_iterator pos =
std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry);
const std::vector<std::string>::size_type idx = pos-fAllowedChannels.begin();
LOG(INFO) << "Found " << entry << " in " << channelName;
LOG(INFO) << "Channel name " << channelName
<< " found in list of allowed channel names at position " << idx;
std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry);
const std::vector<std::string>::size_type idx = pos - fAllowedChannels.begin();
LOG(info) << "Found " << entry << " in " << channelName;
LOG(info) << "Channel name " << channelName << " found in list of allowed channel names at position " << idx;
return true;
}
}
LOG(INFO) << "Channel name " << channelName
<< " not found in list of allowed channel names.";
LOG(ERROR) << "Stop device.";
LOG(info) << "Channel name " << channelName << " not found in list of allowed channel names.";
LOG(error) << "Stop device.";
return false;
}
Bool_t CbmDeviceStsLocalReco::InitContainers()
{
Bool_t initOK{kTRUE};
Bool_t initOK {kTRUE};
fRunId = fConfig->GetValue<string>("run-id");
fvmcworkdir = fConfig->GetValue<string>("vmcworkdir");
fRunId = fConfig->GetValue<string>("run-id");
fvmcworkdir = fConfig->GetValue<string>("vmcworkdir");
fMaxTimeslices = fConfig->GetValue<uint64_t>("max-timeslices");
LOG(INFO) << "Init parameter containers for CbmDeviceStsLocalReco.";
LOG(info) << "Init parameter containers for CbmDeviceStsLocalReco.";
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
// Should only be used for small data because of the cost of an additional copy
std::string message{"CbmStsDigitizeParameters,"};
std::string message {"CbmStsDigitizeParameters,"};
message += fRunId;
LOG(INFO) << "Requesting parameter container CbmStsDigitizeParameters, sending message: " << message;
LOG(info) << "Requesting parameter container CbmStsDigitizeParameters, "
"sending message: "
<< message;
FairMQMessagePtr req(NewSimpleMessage(message));
FairMQMessagePtr rep(NewMessage());
......@@ -147,21 +148,22 @@ Bool_t CbmDeviceStsLocalReco::InitContainers()
if (Send(req, "parameters") > 0) {
if (Receive(rep, "parameters") >= 0) {
if (rep->GetSize() != 0) {
CbmMQTMessage tmsg(rep->GetData(), rep->GetSize());
CbmMqTMessage tmsg(rep->GetData(), rep->GetSize());
fDigiPar = dynamic_cast<CbmStsDigitizeParameters*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(INFO) << "Received unpack parameter from parmq server: " << fDigiPar;
LOG(info) << "Received unpack parameter from parmq server: " << fDigiPar;
// TODO: check if fDigiPar is properly initialized from the file
fDigiPar->Print();
LOG(info) << fDigiPar->ToString();
} else {
}
else {
throw InitTaskError("Received empty reply. Parameter not available");
}
}
}
std::string message1{"FairGeoParSet,"};
std::string message1 {"FairGeoParSet,"};
message1 += fRunId;
LOG(INFO) << "Requesting parameter container FairGeoParSet, sending message: " << message1;
LOG(info) << "Requesting parameter container FairGeoParSet, sending message: " << message1;
FairMQMessagePtr req1(NewSimpleMessage(message1));
FairMQMessagePtr rep1(NewMessage());
......@@ -169,24 +171,24 @@ Bool_t CbmDeviceStsLocalReco::InitContainers()
if (Send(req1, "parameters") > 0) {
if (Receive(rep1, "parameters") >= 0) {
if (rep1->GetSize() != 0) {
CbmMQTMessage tmsg(rep1->GetData(), rep1->GetSize());
CbmMqTMessage tmsg(rep1->GetData(), rep1->GetSize());
fGeoPar = static_cast<FairGeoParSet*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(INFO) << "Received unpack parameter from parmq server: " << fGeoPar;
LOG(info) << "Received unpack parameter from parmq server: " << fGeoPar;
fGeoPar->Print();
if (!gGeoManager) {
throw InitTaskError("No gGeoManager found in FairGeoParSet");
} else {
if (!gGeoManager) { throw InitTaskError("No gGeoManager found in FairGeoParSet"); }
else {
gGeoManager->Print();
}
} else {
}
else {
throw InitTaskError("Received empty reply. Parameter not available");
}
}
}
std::string message2{"CbmFieldPar,"};
std::string message2 {"CbmFieldPar,"};
message2 += fRunId;
LOG(INFO) << "Requesting parameter container CbmFieldPar, sending message: " << message2;
LOG(info) << "Requesting parameter container CbmFieldPar, sending message: " << message2;
FairMQMessagePtr req2(NewSimpleMessage(message2));
FairMQMessagePtr rep2(NewMessage());
......@@ -194,21 +196,21 @@ Bool_t CbmDeviceStsLocalReco::InitContainers()
if (Send(req2, "parameters") > 0) {
if (Receive(rep2, "parameters") >= 0) {
if (rep2->GetSize() != 0) {
CbmMQTMessage tmsg(rep2->GetData(), rep2->GetSize());
CbmMqTMessage tmsg(rep2->GetData(), rep2->GetSize());
fFieldPar = static_cast<CbmFieldPar*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(info) << "Received unpack parameter from parmq server: " << fGeoPar;
if ( -1 == fFieldPar->GetType() ) {
throw InitTaskError("No field parameters available!");
}else{
if (-1 == fFieldPar->GetType()) { throw InitTaskError("No field parameters available!"); }
else {
fFieldPar->Print();
LOG(info) << "Before creating the field";
FairField* field = createField();
FairField* field = createField();
LOG(info) << "After creating the field";
FairRunAna* run = new FairRunAna();
run->SetField(field);
}
} else {
LOG(ERROR) << "Received empty reply. Parameter not available";
}
else {
LOG(error) << "Received empty reply. Parameter not available";
}
}
}
......@@ -219,19 +221,25 @@ Bool_t CbmDeviceStsLocalReco::InitContainers()
FairField* CbmDeviceStsLocalReco::createField()
{
FairField* fMagneticField{nullptr};
{
FairField* fMagneticField {nullptr};
// Instantiate correct field type
Int_t fType = fFieldPar->GetType();
gSystem->Setenv("VMCWORKDIR", fvmcworkdir.c_str());
if ( fType == 0 ) fMagneticField = new CbmFieldConst(fFieldPar);
else if ( fType == 1 ) fMagneticField = new CbmFieldMap(fFieldPar);
else if ( fType == 2 ) fMagneticField = new CbmFieldMapSym2(fFieldPar);
else if ( fType == 3 ) fMagneticField = new CbmFieldMapSym3(fFieldPar);
else if ( fType == 4 ) fMagneticField = new CbmFieldMapDistorted(fFieldPar);
else if ( fType == 5 ) fMagneticField = new CbmFieldMapSym1(fFieldPar);
else if ( fType == 6 ) fMagneticField = new CbmBsField(fFieldPar);
gSystem->Setenv("VMCWORKDIR", fvmcworkdir.c_str());
if (fType == 0) fMagneticField = new CbmFieldConst(fFieldPar);
else if (fType == 1)
fMagneticField = new CbmFieldMap(fFieldPar);
else if (fType == 2)
fMagneticField = new CbmFieldMapSym2(fFieldPar);
else if (fType == 3)
fMagneticField = new CbmFieldMapSym3(fFieldPar);
else if (fType == 4)
fMagneticField = new CbmFieldMapDistorted(fFieldPar);
else if (fType == 5)
fMagneticField = new CbmFieldMapSym1(fFieldPar);
else if (fType == 6)
fMagneticField = new CbmBsField(fFieldPar);
else {
std::stringstream ss;
ss << "Unknown field type " << fType;
......@@ -240,7 +248,7 @@ FairField* CbmDeviceStsLocalReco::createField()
LOG(info) << "New field at " << fMagneticField << ", type " << fType;
// Initialise field
if ( fMagneticField ) {
if (fMagneticField) {
fMagneticField->Init();
fMagneticField->Print("");
}
......@@ -253,12 +261,11 @@ FairField* CbmDeviceStsLocalReco::createField()
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
bool CbmDeviceStsLocalReco::HandleData(FairMQMessagePtr& msg, int /*index*/)
{
// Don't do anything with the data
// Maybe add an message counter which counts the incomming messages and add
// an output
// Don't do anything with the data
// Maybe add an message counter which counts the incomming messages and add
// an output
fNumMessages++;
LOG(DEBUG) << "Received message number "<< fNumMessages
<< " with size " << msg->GetSize();
LOG(debug) << "Received message number " << fNumMessages << " with size " << msg->GetSize();
std::string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
std::istringstream iss(msgStr);
......@@ -266,7 +273,7 @@ bool CbmDeviceStsLocalReco::HandleData(FairMQMessagePtr& msg, int /*index*/)
DoWork();
if(fNumMessages%10000 == 0) LOG(INFO)<<"Processed "<<fNumMessages<<" time slices";
if (fNumMessages % 10000 == 0) LOG(info) << "Processed " << fNumMessages << " time slices";
SendData();
......@@ -274,16 +281,8 @@ bool CbmDeviceStsLocalReco::HandleData(FairMQMessagePtr& msg, int /*index*/)
}
bool CbmDeviceStsLocalReco::SendData()
{
return true;
}
bool CbmDeviceStsLocalReco::SendData() { return true; }
Bool_t CbmDeviceStsLocalReco::DoWork()
{
return true;
}
Bool_t CbmDeviceStsLocalReco::DoWork() { return true; }
void CbmDeviceStsLocalReco::Finish()
{
}
void CbmDeviceStsLocalReco::Finish() {}
/* Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig [committer] */
/**
* CbmDeviceStsLocalReco.h
*
......@@ -8,18 +12,19 @@
#ifndef CBMDEVICEMSTSLOCALRECO_H_
#define CBMDEVICEMSTSLOCALRECO_H_
#include "CbmMqTMessage.h"
#include "FairMQDevice.h"
//#include "CbmStsDigitizeParameters.h"
//#include "FairGeoParSet.h"
#include "TMessage.h"
//#include "Rtypes.h"
//#include "TObjArray.h"
#include <vector>
#include <string>
#include <vector>
//class TList;
class CbmStsDigitizeParameters;
......@@ -28,60 +33,46 @@ class CbmFieldPar;
class FairGeoParSet;
class FairField;
class CbmDeviceStsLocalReco: public FairMQDevice
{
public:
CbmDeviceStsLocalReco();
virtual ~CbmDeviceStsLocalReco();
class CbmDeviceStsLocalReco : public FairMQDevice {
public:
CbmDeviceStsLocalReco();
virtual ~CbmDeviceStsLocalReco();
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
private:
uint64_t fMaxTimeslices;
uint64_t fNumMessages;
std::string fRunId;
std::string fvmcworkdir;
CbmStsDigitizeParameters* fDigiPar;
private:
uint64_t fMaxTimeslices;
uint64_t fNumMessages;
std::string fRunId;
std::string fvmcworkdir;
FairGeoParSet* fGeoPar;
CbmStsDigitizeParameters* fDigiPar;
CbmFieldPar* fFieldPar;
std::vector<std::string> fAllowedChannels
= {"stsdigi","parameters"};
std::vector<std::vector<std::string>> fChannelsToSend = { {},{} };
FairGeoParSet* fGeoPar;
bool IsChannelNameAllowed(std::string channelName);
bool InitContainers();
CbmFieldPar* fFieldPar;
bool DoWork();
std::vector<std::string> fAllowedChannels = {"stsdigi", "parameters"};
std::vector<std::vector<std::string>> fChannelsToSend = {{}, {}};
bool SendData();
bool IsChannelNameAllowed(std::string channelName);
void Finish();
bool InitContainers();
bool DoWork();
FairField* createField();
// TList* fParCList;
bool SendData();
// TObjArray fArrayHisto;
};
void Finish();
FairField* createField();
// TList* fParCList;
// special class to expose protected TMessage constructor
class CbmMQTMessage : public TMessage
{
public:
CbmMQTMessage(void* buf, Int_t len)
: TMessage(buf, len)
{
ResetBit(kIsOwner);
}
// TObjArray fArrayHisto;
};
#endif /* CBMDEVICESTSLOCALRECO_H_ */
#include "runFairMQDevice.h"
/* Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig [committer] */
#include "CbmDeviceStsLocalReco.h"
#include <iostream>
#include "runFairMQDevice.h"
namespace bpo = boost::program_options;
void addCustomOptions(bpo::options_description& options)
{
options.add_options()
("max-timeslices", bpo::value<uint64_t>()->default_value(0), "Maximum number of timeslices to process for Run/ConditionalRun/OnData (0 - infinite)")
("vmcworkdir", bpo::value<std::string>()->default_value("."), "Directory where to find needed input data")
("run-id", bpo::value<std::string>()->default_value("0"), "Rund ID which is needed to retrieve the proper parameters from Parameter Manager");
options.add_options()("max-timeslices", bpo::value<uint64_t>()->default_value(0),
"Maximum number of timeslices to process for "
"Run/ConditionalRun/OnData (0 - infinite)")(
"vmcworkdir", bpo::value<std::string>()->default_value("."), "Directory where to find needed input data")(
"run-id", bpo::value<std::string>()->default_value("0"),
"Rund ID which is needed to retrieve the proper parameters from Parameter "
"Manager");
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
{
return new CbmDeviceStsLocalReco();
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceStsLocalReco(); }
#!/bin/bash
$FAIRROOTPATH/bin/shmmonitor --cleanup
if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
@SIMPATH@/bin/fairmq-shmmonitor --cleanup
fi
if [ -z "$1" ]; then
if [ -z "$1" ]; then
_run_id="1568041655"
else
else
_run_id=$1
fi
......
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQSamplerUnpackerParserver.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQSamplerUnpackerParserver.sh)
set(INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
${CBMROOT_SOURCE_DIR}/MQ/base
${CBMROOT_SOURCE_DIR}/fles/cern2016/param
${CBMROOT_SOURCE_DIR}/fles/cern2016/unpacker
${CBMROOT_SOURCE_DIR}/fles/mcbm2018/parameter
${CBMROOT_SOURCE_DIR}/fles/mcbm2018/dataformat
${CBMROOT_SOURCE_DIR}/fles/mcbm2018/unpacker
${CBMROOT_SOURCE_DIR}/fles/mcbm2018/commonMQ
${CBMROOT_SOURCE_DIR}/beamtime/base
${CBMDATA_DIR}
${CBMDATA_DIR}/tof
${CBMBASE_DIR}
)
Set(SYSTEM_INCLUDE_DIRECTORIES
${SYSTEM_INCLUDE_DIRECTORIES}
${ZeroMQ_INCLUDE_DIR}
${Boost_INCLUDE_DIR}
${FAIRROOT_INCLUDE_DIR}
${FAIRMQ_INCLUDE_DIR}
${FAIRMQ_INCLUDE_DIR}/options
${IPC_INCLUDE_DIRECTORY}
${CBMROOT_SOURCE_DIR}/external/cppzmq
)
include_directories(${INCLUDE_DIRECTORIES})
include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
set(LINK_DIRECTORIES
${ROOT_LIBRARY_DIR}
${FAIRROOT_LIBRARY_DIR}
${Boost_LIBRARY_DIRS}
)
link_directories(${LINK_DIRECTORIES})
${CMAKE_CURRENT_SOURCE_DIR}
)
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/MQ/unpacker")
# set the install dir
set(BIN_DESTINATION bin/MQ/unpacker)
Set(BOOST_LIBS
${Boost_SYSTEM_LIBRARY}
${Boost_SERIALIZATION_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_LOG_LIBRARY}
)
If(UNIX AND NOT APPLE)
List(APPEND BOOST_LIBS pthread)
EndIf()
set(FAIR_LIBS
Base
ParBase
FairMQ
)
If(FAIRLOGGER_FOUND)
set(FAIR_LIBS
${FAIR_LIBS}
FairLogger
)
EndIf()
set(PUBLIC_DEPS
CbmData
CbmMQBase
CbmTofBase
CbmTofReco
)
set(EXE_NAME UnpackTofMcbm2018)
set(SRCS CbmDeviceUnpackTofMcbm2018.cxx runUnpackTofMcbm2018.cxx)
set(DEPENDENCIES
${DEPENDENCIES}
${FAIR_LIBS}
${BOOST_LIBS}
fles_ipc
CbmFlibCern2016
CbmFlibMcbm2018
set(PRIVATE_DEPS
CbmBase
CbmData
Core
RIO
Net
Hist
)
GENERATE_EXECUTABLE()
CbmFlibMcbm2018
FairLogger::FairLogger
FairRoot::ParBase
ROOT::Hist
external::fles_ipc
ROOT::Net
)
set(INTERFACE_DEPS
FairMQ::FairMQ
)
set(EXE_NAME UnpackTofMcbm2018)
set(SRCS CbmTbDaqBuffer.cxx CbmDeviceUnpackTofMcbm2018.cxx runUnpackTofMcbm2018.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME UnpackTofCri)
set(SRCS CbmTbDaqBuffer.cxx CbmDeviceUnpackTofCri.cxx runUnpackTofCri.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
# Install script and input file(s)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/MapTofHdCosmics_v18d.par
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cbmroot/input
)
if(EXISTS ${VMCWORKDIR}/input/tofget4_hd2018.tsa)
install(FILES ${VMCWORKDIR}/input/tofget4_hd2018.tsa
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cbmroot/input
)
endif()
# Set the correct variables for the installation
set(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/cbmroot)
set(MY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CURRENT_SOURCE_DIR ${VMCWORKDIR}/input)
set(TMPDIR "${CMAKE_BINARY_DIR}")
set(CMAKE_BINARY_DIR ${CMAKE_INSTALL_PREFIX})
# Configure file for installation directory
configure_file(${MY_SOURCE_DIR}/startMQSamplerUnpackerParserver.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerUnpackerParserver.sh)
install(PROGRAMS ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerUnpackerParserver.sh
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/MQ/topologies
)
/* Copyright (C) 2018-2020 PI-UHd, GSI
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig, Norbert Herrmann [committer] */
/**
* CbmDeviceUnpackTofMcbm2018.cxx
*
* @since 2018-04-24
* @author F. Uhlig
*/
#include "CbmDeviceUnpackTofCri.h"
#include "CbmDefs.h"
#include "CbmMQDefs.h"
#include "CbmMcbm2018TofPar.h"
#include "CbmTofUnpackAlgo.h"
#include "CbmTofUnpackConfig.h"
//#include "CbmHistManager.h"
#include "CbmTbDaqBuffer.h"
#include "CbmTimeSlice.h"
#include "CbmTofAddress.h"
#include "CbmTofDetectorId_v21a.h" // in cbmdata/tof
#include "CbmTofDigi.h"
//#include "CbmRawEvent.h"
#include "StorableTimeslice.hpp"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairParGenericSet.h"
#include "FairRuntimeDb.h"
#include "TH1.h"
#include "TH2.h"
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
// include this header to serialize vectors
#include <boost/serialization/vector.hpp>
#include <array>
#include <iomanip>
#include <stdexcept>
#include <string>
struct InitTaskError : std::runtime_error {
using std::runtime_error::runtime_error;
};
using namespace std;
static Int_t iReportMess = 0;
//const Int_t DetMask = 0x001FFFFF;
std::shared_ptr<CbmTofUnpackConfig> fTofConfig = nullptr; //!
CbmDeviceUnpackTofCri::CbmDeviceUnpackTofCri()
: fNumMessages(0)
, fiSelectComponents(0)
, fNumTint(0)
, fEventHeader()
, fiReqMode(0)
, fiReqTint(0)
, fiReqBeam(-1)
, fiReqDigiAddr()
, fiPulserMode(0)
, fiPulMulMin(0)
, fiPulTotMin(0)
, fiPulTotMax(1000)
, fuTotalMsNb(0)
, fuOverlapMsNb(0)
, fuCoreMs(0)
, fdMsSizeInNs(0)
, fdTsCoreSizeInNs(0)
, fuMinNbGdpb(0)
, fuNrOfGdpbs(0)
, fuNrOfFeePerGdpb(0)
, fuNrOfGet4PerFee(0)
, fuNrOfChannelsPerGet4(0)
, fuNrOfChannelsPerFee(0)
, fuNrOfGet4(0)
, fuNrOfGet4PerGdpb(0)
, fuNrOfChannelsPerGdpb(0)
, fuGdpbId(0)
, fuGdpbNr(0)
, fuGet4Id(0)
, fuGet4Nr(0)
, fMsgCounter(11, 0) // length of enum MessageTypes initialized with 0
, fGdpbIdIndexMap()
, fvulCurrentEpoch()
, fvbFirstEpochSeen()
, fNofEpochs(0)
, fulCurrentEpochTime(0.)
//, fdMsIndex(0.)
, fdToffTof(0.)
, fiAddrRef(-1)
//, fuDiamondDpbIdx(3)
//, fbEpochSuppModeOn( kTRUE )
//, fbGet4M24b( kFALSE )
//, fbGet4v20( kTRUE )
//, fbMergedEpochsOn( kTRUE )
, fUnpackPar(nullptr)
, fdLastDigiTime(0.)
, fdFirstDigiTimeDif(0.)
//, fdEvTime0(0.)
, fhRawTDigEvBmon(nullptr)
, fhRawTDigRef0(nullptr)
, fhRawTDigRef(nullptr)
, fhRawTRefDig0(nullptr)
, fhRawTRefDig1(nullptr)
, fhRawDigiLastDigi(nullptr)
, fhRawTotCh()
, fhChCount()
, fvbChanThere()
, fhChanCoinc()
, fhDetChanCoinc(nullptr)
, fvuPadiToGet4()
, fvuGet4ToPadi()
, fvuElinkToGet4()
, fvuGet4ToElink()
, fviRpcType()
, fviModuleId()
, fviNrOfRpc()
, fviRpcSide()
, fviRpcChUId()
, fBuffer(CbmTbDaqBuffer::Instance())
, fUnpackerAlgo(nullptr)
{
//fUnpackerAlgo = new CbmTofUnpackAlgo();
}
CbmDeviceUnpackTofCri::~CbmDeviceUnpackTofCri() {}
void CbmDeviceUnpackTofCri::InitTask()
try {
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
// for the device
// The idea is to check at initilization if the devices are
// properly connected. For the time beeing this is done with a
// nameing convention. It is not avoided that someone sends other
// data on this channel.
//logger::SetLogLevel("INFO");
int noChannel = fChannels.size();
LOG(info) << "Number of defined channels: " << noChannel;
for (auto const& entry : fChannels) {
LOG(info) << "Channel name: " << entry.first;
if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match.");
if (entry.first == "syscmd") {
OnData(entry.first, &CbmDeviceUnpackTofCri::HandleMessage);
continue;
}
//if(entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofCri::HandleData);
if (entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofCri::HandleParts);
else {
fChannelsToSend[0].push_back(entry.first);
LOG(info) << "Init to send data to channel " << fChannelsToSend[0][0];
}
}
// ---- TOF ----
Int_t runid = 111;
fTofConfig = std::make_shared<CbmTofUnpackConfig>("", runid);
// fTofConfig->SetDoWriteOutput();
// fTofConfig->SetDoWriteOptOutA("CbmTofErrors");
if (fTofConfig) {
LOG(info) << "Configure Tof Unpacker ";
fTofConfig->SetDebugState();
fTofConfig->SetAlgo();
fUnpackerAlgo = fTofConfig->GetUnpacker();
InitContainers();
//fTofConfig->InitUnpacker();
}
else
LOG(fatal) << "Tof Unpacker not configured ";
const Int_t iHeaderSize = 5;
fEventHeader.resize(iHeaderSize); // define size of eventheader int[]
for (int i = 0; i < iHeaderSize; i++)
fEventHeader[i] = 0;
LOG(info) << "Read config";
fiSelectComponents = fConfig->GetValue<uint64_t>("SelectComponents");
fiReqMode = fConfig->GetValue<uint64_t>("ReqMode");
fiReqTint = fConfig->GetValue<uint64_t>("ReqTint");
fiReqBeam = fConfig->GetValue<uint64_t>("ReqBeam");
fiPulserMode = fConfig->GetValue<int64_t>("PulserMode");
fiPulMulMin = fConfig->GetValue<uint64_t>("PulMulMin");
fiPulTotMin = fConfig->GetValue<uint64_t>("PulTotMin");
fiPulTotMax = fConfig->GetValue<uint64_t>("PulTotMax");
fdToffTof = fConfig->GetValue<double_t>("ToffTof");
Int_t iRefModType = fConfig->GetValue<int64_t>("RefModType");
Int_t iRefModId = fConfig->GetValue<int64_t>("RefModId");
Int_t iRefCtrType = fConfig->GetValue<int64_t>("RefCtrType");
Int_t iRefCtrId = fConfig->GetValue<int64_t>("RefCtrId");
if (iRefModType > -1)
fiAddrRef = CbmTofAddress::GetUniqueAddress(iRefModId, iRefCtrId, 0, 0, iRefModType, iRefCtrType);
LOG(info) << " Using reference counter address 0x" << std::hex << fiAddrRef << " and offset shift " << std::dec
<< fdToffTof;
// Int_t iMaxAsicInactive = fConfig->GetValue<uint64_t>("MaxAsicInactive");
// fUnpackerAlgo->SetMaxAsicInactive( iMaxAsicInactive );
Int_t iReqDet = 1;
Int_t iNReq = 0;
const Int_t iMaxReq = 50;
while (iNReq < iMaxReq) { // FIXME, setup parameter hardwired!
iReqDet = fConfig->GetValue<uint64_t>(Form("ReqDet%d", iNReq));
if (iReqDet == 0) break;
AddReqDigiAddr(iReqDet);
iNReq++;
}
LOG(info) << "Setup request";
if (fiReqMode > 0)
if (iNReq == 0) { // take all defined detectors
for (UInt_t iGbtx = 0; iGbtx < fviNrOfRpc.size(); iGbtx++) {
switch (fviRpcType[iGbtx]) {
case 0: // mTof modules
case 1: // eTof modules
case 2: // M6 modules
if (iGbtx % 2 == 0)
for (Int_t iRpc = 0; iRpc < fviNrOfRpc[iGbtx]; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
case 4:
case 9: // HD 2-RPC boxes
for (Int_t iRpc = 0; iRpc < 2; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
case 6: // Buc box
for (Int_t iRpc = 0; iRpc < 2; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
case 7: // CERN box
for (Int_t iRpc = 0; iRpc < 1; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, 7);
AddReqDigiAddr(iAddr);
}
break;
case 8: // ceramics
for (Int_t iRpc = 0; iRpc < 8; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
case 5: // add Diamond, single cell RPC
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], 0, 0, 0, 5);
AddReqDigiAddr(iAddr);
break;
}
}
}
LOG(info) << "ReqMode " << fiReqMode << " in " << fiReqTint << " ns "
<< " with " << fiReqDigiAddr.size() << " detectors out of " << fviNrOfRpc.size() << " GBTx, PulserMode "
<< fiPulserMode << " with Mul " << fiPulMulMin << ", TotMin " << fiPulTotMin;
LOG(info) << Form("ReqBeam 0x%08x", (uint) fiReqBeam);
}
catch (InitTaskError& e) {
LOG(error) << e.what();
// Wrapper defined in CbmMQDefs.h to support different FairMQ versions
cbm::mq::ChangeState(this, cbm::mq::Transition::ErrorFound);
}
bool CbmDeviceUnpackTofCri::IsChannelNameAllowed(std::string channelName)
{
for (auto const& entry : fAllowedChannels) {
LOG(info) << "Inspect " << entry;
std::size_t pos1 = channelName.find(entry);
if (pos1 != std::string::npos) {
const vector<std::string>::const_iterator pos =
std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry);
const vector<std::string>::size_type idx = pos - fAllowedChannels.begin();
LOG(info) << "Found " << entry << " in " << channelName;
LOG(info) << "Channel name " << channelName << " found in list of allowed channel names at position " << idx;
return true;
}
}
LOG(info) << "Channel name " << channelName << " not found in list of allowed channel names.";
LOG(error) << "Stop device.";
return false;
}
Bool_t CbmDeviceUnpackTofCri::InitContainers()
{
LOG(info) << "Init parameter containers for CbmDeviceUnpackTofCri";
// FairRuntimeDb* fRtdb = FairRuntimeDb::instance();
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
// Should only be used for small data because of the cost of an additional copy
std::string message {"CbmMcbm2018TofPar,111"};
LOG(info) << "Requesting parameter container CbmMcbm2018TofPar, sending message: " << message;
FairMQMessagePtr req(NewSimpleMessage("CbmMcbm2018TofPar,111"));
FairMQMessagePtr rep(NewMessage());
if (Send(req, "parameters") > 0) {
if (Receive(rep, "parameters") >= 0) {
if (rep->GetSize() != 0) {
CbmMQTMessage tmsg(rep->GetData(), rep->GetSize());
fUnpackPar = dynamic_cast<CbmMcbm2018TofPar*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(info) << "Received unpack parameter from parmq server: " << fUnpackPar;
LOG(info) << "NrOfGdpbs: " << fUnpackPar->GetNrOfGdpbs();
}
else {
LOG(error) << "Received empty reply. Parameter not available";
}
}
}
//FairParGenericSet* parset=
SetParContainers();
Bool_t initOK = kTRUE;
//Int_t fRunId=111;
//string fGeoSetupTag="v21c";
//initOK &= fUnpackerAlgo->InitContainers();
//auto reqparvec = fUnpackerAlgo->GetParContainerRequest(fGeoSetupTag, fRunId);
//initOk &= initParContainers(reqparvec);
initOK &= ReInitContainers(); // needed for TInt parameters
// CreateHistograms();
// initOK &= fUnpackerAlgo->CreateHistograms();
fvulCurrentEpoch.resize(fuNrOfGdpbs * fuNrOfGet4PerGdpb);
fvbFirstEpochSeen.resize(fuNrOfGdpbs * fuNrOfGet4PerGdpb);
fvbChanThere.resize(fviRpcChUId.size(), kFALSE);
for (UInt_t i = 0; i < fuNrOfGdpbs; ++i) {
for (UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j) {
fvulCurrentEpoch[GetArrayIndex(i, j)] = 0;
fvbFirstEpochSeen[GetArrayIndex(i, j)] = kFALSE;
} // for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j )
} // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
fNumTint = 0;
return initOK;
}
void CbmDeviceUnpackTofCri::SetParContainers()
{
//FairRuntimeDb* fRtdb = FairRuntimeDb::instance();
LOG(info) << "NrOfGdpbs: " << fUnpackPar->GetNrOfGdpbs();
// PAL, 2022/07/05: use algo native pointer interface + sanity checks to set the parameter
auto reqparvec = fTofConfig->GetParContainerRequest();
if (1 == reqparvec->size() && (reqparvec->at(0).second->IsA() == CbmMcbm2018TofPar::Class())) {
reqparvec->at(0).second.reset(fUnpackPar);
}
else {
LOG(fatal) << "CbmDeviceUnpackTofCri::SetParContainers => wronf number of parameters needed for the algo or wrong "
<< "Parameter type";
}
/*
TList* fParCList; // = fUnpackerAlgo->GetParList();
LOG(info) << "Setting parameter containers for " << fParCList->GetEntries() << " entries ";
for (Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC) {
FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC));
fParCList->Remove(tempObj);
std::string sParamName {tempObj->GetName()};
FairParGenericSet* newObj = dynamic_cast<FairParGenericSet*>(fRtdb->getContainer(sParamName.data()));
LOG(info) << " - Get " << sParamName.data() << " at " << newObj;
if (nullptr == newObj) {
LOG(error) << "Failed to obtain parameter container " << sParamName << ", for parameter index " << iparC;
return;
} // if( nullptr == newObj )
if (iparC == 0) {
newObj = (FairParGenericSet*) fUnpackPar;
LOG(info) << " - Mod " << sParamName.data() << " to " << newObj;
}
fParCList->AddAt(newObj, iparC);
// delete tempObj;
} // for( Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC )
*/
}
void CbmDeviceUnpackTofCri::AddMsComponentToList(size_t /*component*/, UShort_t /*usDetectorId*/)
{
//fUnpackerAlgo->AddMsComponentToList(component, usDetectorId);
}
Bool_t CbmDeviceUnpackTofCri::ReInitContainers()
{
LOG(info) << "ReInit parameter containers for CbmDeviceUnpackCriTofPar.";
UInt_t uNrOfGbtx = fUnpackPar->GetNrOfGbtx();
fviRpcType.resize(uNrOfGbtx);
fviModuleId.resize(uNrOfGbtx);
fviNrOfRpc.resize(uNrOfGbtx);
fviRpcSide.resize(uNrOfGbtx);
for (UInt_t iGbtx = 0; iGbtx < uNrOfGbtx; ++iGbtx) {
fviNrOfRpc[iGbtx] = fUnpackPar->GetNrOfRpc(iGbtx);
fviRpcType[iGbtx] = fUnpackPar->GetRpcType(iGbtx);
fviRpcSide[iGbtx] = fUnpackPar->GetRpcSide(iGbtx);
fviModuleId[iGbtx] = fUnpackPar->GetModuleId(iGbtx);
}
return kTRUE;
}
void CbmDeviceUnpackTofCri::CreateHistograms()
{
LOG(info) << "create Histos for " << fuNrOfGdpbs << " gDPBs ";
fhRawTDigEvBmon =
new TH1F(Form("Raw_TDig-EvBmon"), Form("Raw digi time difference to 1st digi ; time [ns]; cts"), 500, 0, 100.);
// fHM->Add( Form("Raw_TDig-EvBmon"), fhRawTDigEvBmon);
fhRawTDigRef0 =
new TH1F(Form("Raw_TDig-Ref0"), Form("Raw digi time difference to Ref ; time [ns]; cts"), 6000, -10000, 50000);
// fHM->Add( Form("Raw_TDig-Ref0"), fhRawTDigRef0);
fhRawTDigRef =
new TH1F(Form("Raw_TDig-Ref"), Form("Raw digi time difference to Ref ; time [ns]; cts"), 6000, -1000, 5000);
// fHM->Add( Form("Raw_TDig-Ref"), fhRawTDigRef);
fhRawTRefDig0 = new TH1F(Form("Raw_TRef-Dig0"), Form("Raw Ref time difference to last digi ; time [ns]; cts"), 9999,
-50000, 50000);
// fHM->Add( Form("Raw_TRef-Dig0"), fhRawTRefDig0);
fhRawTRefDig1 =
new TH1F(Form("Raw_TRef-Dig1"), Form("Raw Ref time difference to last digi ; time [ns]; cts"), 9999, -5000, 5000);
// fHM->Add( Form("Raw_TRef-Dig1"), fhRawTRefDig1);
fhRawDigiLastDigi = new TH1F(Form("Raw_Digi-LastDigi"),
Form("Raw Digi time difference to last digi ; time [ns]; cts"), 9999, -5000, 5000);
// 9999, -5000000, 5000000);
// fHM->Add( Form("Raw_Digi-LastDigi"), fhRawDigiLastDigi);
fhRawTotCh.resize(fuNrOfGdpbs);
fhChCount.resize(fuNrOfGdpbs);
fhChanCoinc.resize(fuNrOfGdpbs * fuNrOfFeePerGdpb / 2);
for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb++) {
fhRawTotCh[uGdpb] = new TH2F(Form("Raw_Tot_gDPB_%02u", uGdpb), Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb, 256, 0., 256.);
// fHM->Add( Form("Raw_Tot_gDPB_%02u", uGdpb), fhRawTotCh[ uGdpb ]);
fhChCount[uGdpb] =
new TH1I(Form("ChCount_gDPB_%02u", uGdpb), Form("Channel counts gDPB %02u; channel; Hits", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb);
// fHM->Add( Form("ChCount_gDPB_%02u", uGdpb), fhChCount[ uGdpb ]);
/*
for( UInt_t uLeftFeb = uGdpb*fuNrOfFebsPerGdpb / 2;
uLeftFeb < (uGdpb + 1 )*fuNrOfFebsPerGdpb / 2;
++uLeftFeb )
{
fhChanCoinc[ uLeftFeb ] = new TH2F( Form("fhChanCoinc_%02u", uLeftFeb),
Form("Channels Coincidence %02; Left; Right", uLeftFeb),
fuNrOfChannelsPerFee, 0., fuNrOfChannelsPerFee,
fuNrOfChannelsPerFee, 0., fuNrOfChannelsPerFee );
} // for( UInt_t uLeftFeb = 0; uLeftFeb < fuNrOfFebsPerGdpb / 2; uLeftFeb ++ )
*/
fhChanCoinc[uGdpb] =
new TH2F(Form("fhChanCoinc_%02u", uGdpb), Form("Channels Coincidence %02u; Left; Right", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb, fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb);
} // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++)
fhDetChanCoinc = new TH2F("fhDetChanCoinc", "Det Channels Coincidence; Left; Right", 32, 0., 32, 32, 0., 32);
}
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
bool CbmDeviceUnpackTofCri::HandleData(FairMQMessagePtr& msg, int /*index*/)
{
// Don't do anything with the data
// Maybe add an message counter which counts the incomming messages and add
// an output
fNumMessages++;
LOG(debug) << "Received message number " << fNumMessages << " with size " << msg->GetSize();
std::string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
fles::StorableTimeslice component {0};
inputArchive >> component;
// CheckTimeslice(component);
DoUnpack(component, 0);
BuildTint(component.start_time(), 0);
if (fNumMessages % 1000 == 0) LOG(info) << "Processed " << fNumMessages << " time slices";
return true;
}
bool CbmDeviceUnpackTofCri::HandleParts(FairMQParts& parts, int /*index*/)
{
// Don't do anything with the data
// Maybe add an message counter which counts the incomming messages and add
// an output
fNumMessages++;
LOG(debug) << "Received message number " << fNumMessages << " with " << parts.Size() << " parts";
fles::StorableTimeslice ts {0};
uint64_t ulTsStartTime = 0;
switch (fiSelectComponents) {
case 0: {
std::string msgStr(static_cast<char*>(parts.At(0)->GetData()), (parts.At(0))->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
inputArchive >> ts;
//CheckTimeslice(ts);
for (size_t c {0}; c < ts.num_components(); c++) {
auto systemID = static_cast<int>(ts.descriptor(c, 0).sys_id);
if (1 == fNumMessages) {
LOG(info) << "Found systemID: " << std::hex << systemID << std::dec;
//fUnpackerAlgo->AddMsComponentToList(c, systemID); // TOF data
}
if (systemID == 0x60 || systemID == 0x90) { // FIXME hardwired numbers
//LOG(info) << "Call unpacker for component " << c;
DoUnpack(ts, c);
}
}
ulTsStartTime = ts.start_time();
} break;
case 1: {
fles::StorableTimeslice component {0};
uint ncomp = parts.Size();
for (uint i = 0; i < ncomp; i++) {
std::string msgStr(static_cast<char*>(parts.At(i)->GetData()), (parts.At(i))->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
//fles::StorableTimeslice component{i};
inputArchive >> component;
// CheckTimeslice(component);
//fUnpackerAlgo->AddMsComponentToList(0, 0x60); // TOF data
LOG(debug) << "HandleParts message " << fNumMessages << ", component " << i << ",size "
<< (parts.At(i))->GetSize();
DoUnpack(component, 0);
}
ulTsStartTime = component.start_time();
} break;
default:;
}
BuildTint(ulTsStartTime, 0);
if (fNumMessages % 100 == 0) LOG(info) << "Processed " << fNumMessages << " time slices";
//LOG(info) << "HandleParts done with message number " << fNumMessages;
return true;
}
bool CbmDeviceUnpackTofCri::HandleMessage(FairMQMessagePtr& msg, int /*index*/)
{
const char* cmd = (char*) (msg->GetData());
const char cmda[4] = {*cmd};
LOG(info) << "Handle message " << cmd << ", " << cmd[0];
cbm::mq::LogState(this);
// only one implemented so far "Stop"
if (strcmp(cmda, "STOP")) {
LOG(info) << "STOP";
fUnpackerAlgo->Finish();
cbm::mq::ChangeState(this, cbm::mq::Transition::Ready);
cbm::mq::LogState(this);
cbm::mq::ChangeState(this, cbm::mq::Transition::DeviceReady);
cbm::mq::LogState(this);
cbm::mq::ChangeState(this, cbm::mq::Transition::Idle);
cbm::mq::LogState(this);
cbm::mq::ChangeState(this, cbm::mq::Transition::End);
cbm::mq::LogState(this);
}
return true;
}
Bool_t CbmDeviceUnpackTofCri::DoUnpack(const fles::Timeslice& ts, size_t component)
{
LOG(debug) << "Timeslice " << ts.index() << " contains " << ts.num_microslices(component)
<< " microslices of component " << component << ", NCoreMs: " << ts.num_core_microslices();
fUnpackerAlgo->SetTsStartTime(ts.start_time());
std::vector<CbmTofDigi> vDigi = fUnpackerAlgo->Unpack(&ts, component);
LOG(debug) << "TS " << ts.index() << ", startTime " << ts.start_time() << ": insert " << vDigi.size()
<< " digis of component " << component << " into DAQ buffer with size " << fBuffer->GetSize();
CbmTofDigi* fDigi = NULL;
CbmTofDigi* fDigiLast = NULL;
for (auto digi : vDigi) {
// Memorize last digi
if (NULL != fDigi) fDigiLast = fDigi;
// copy Digi for insertion into DAQ buffer
fDigi = new CbmTofDigi(digi);
//if( (fDigi->GetAddress() & 0x000F00F ) != fiAddrRef ) fDigi->SetTime(fDigi->GetTime()+fdToffTof); // shift all Tof Times for v14a geometries
if ((fDigi->GetAddress() & 0x000780F) != fiAddrRef)
fDigi->SetTime(fDigi->GetTime() + fdToffTof); // shift all Tof Times for V21a
LOG(debug) << "BufferInsert TSRCS "
<< Form("%d%d%d%02d%d", (int) fDigi->GetType(), (int) fDigi->GetSm(), (int) fDigi->GetRpc(),
(int) fDigi->GetChannel(), (int) fDigi->GetSide())
<< Form(", 0x%08x, t %012.2f", fDigi->GetAddress(), fDigi->GetTime())
<< Form(", first %012.2f, last %012.2f, size %u", fBuffer->GetTimeFirst(), fBuffer->GetTimeLast(),
fBuffer->GetSize());
if (NULL != fDigiLast) {
if ((fDigi->GetTime() * 1000) == (fDigiLast->GetTime() * 1000)) {
if (iReportMess++ < 1000)
LOG(warn) << "Successive digis with same time: "
<< Form("%12.3f, TSRCS %d%d%d%02d%d - %d%d%d%02d%d", fDigi->GetTime(), (Int_t) fDigi->GetType(),
(Int_t) fDigi->GetSm(), (Int_t) fDigi->GetRpc(), (Int_t) fDigi->GetChannel(),
(Int_t) fDigi->GetSide(), (Int_t) fDigiLast->GetType(), (Int_t) fDigiLast->GetSm(),
(Int_t) fDigiLast->GetRpc(), (Int_t) fDigiLast->GetChannel(), (Int_t) fDigiLast->GetSide());
}
else
fBuffer->InsertData<CbmTofDigi>(fDigi);
}
else
fBuffer->InsertData<CbmTofDigi>(fDigi);
LOG(debug) << "I "
<< " TSRC " << fDigi->GetType() << fDigi->GetSm() << fDigi->GetRpc() << fDigi->GetChannel() << " S "
<< fDigi->GetSide() << " : " << Form("T %15.3f, Tot %5.1f", fDigi->GetTime(), fDigi->GetTot());
}
vDigi.clear();
//fUnpackerAlgo->ClearVector();
return kTRUE;
}
void CbmDeviceUnpackTofCri::BuildTint(uint64_t ulTsStartTime, int iMode)
{
// iMode - sending condition
// 0 (default)- build time interval only if last buffer entry is older the start + TSLength
// 1 (finish), empty buffer without checking
// Steering variables
double TSLENGTH = 1.E6;
double fdMaxDeltaT = (double) fiReqTint; // in ns
LOG(debug) << "BuildTint: Buffer size " << fBuffer->GetSize() << ", DeltaT "
<< (fBuffer->GetTimeLast() - fBuffer->GetTimeFirst()) / 1.E9 << " s";
CbmTbDaqBuffer::Data data;
CbmTofDigi* digi;
while (fBuffer->GetSize() > 0) {
Double_t fTimeBufferLast = fBuffer->GetTimeLast();
switch (iMode) {
case 0:
if (fTimeBufferLast - fBuffer->GetTimeFirst() < TSLENGTH) {
LOG(debug) << "BuildTint: refill DAQ buffer ";
return;
}
break;
case 1:; break;
}
data = fBuffer->GetNextData(fTimeBufferLast);
digi = boost::any_cast<CbmTofDigi*>(data.first);
assert(digi);
Double_t dTEnd = digi->GetTime() + fdMaxDeltaT;
Double_t dTEndMax = digi->GetTime() + 2 * fdMaxDeltaT;
LOG(debug) << Form("Next event at %f until %f, max %f ", digi->GetTime(), dTEnd, dTEndMax);
if (dTEnd > fTimeBufferLast) {
LOG(warn) << Form("Remaining buffer < %f with %d entries is not "
"sufficient for digi ending at %f -> skipped ",
fTimeBufferLast, fBuffer->GetSize(), dTEnd);
return;
}
LOG(debug) << "BuildTint0 with digi " << Form("0x%08x at %012.2f", digi->GetAddress(), digi->GetTime());
Bool_t bDet[fiReqDigiAddr.size()][2];
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++)
for (Int_t j = 0; j < 2; j++)
bDet[i][j] = kFALSE; //initialize
Bool_t bPul[fiReqDigiAddr.size()][2];
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++)
for (Int_t j = 0; j < 2; j++)
bPul[i][j] = kFALSE; //initialize
Bool_t bBeam = kFALSE;
std::vector<CbmTofDigi*> vdigi;
UInt_t nDigi = 0;
//const Int_t AddrMask=0x003FFFFF;
const Int_t AddrMask = 0x001FFFFF;
Bool_t bOut = kFALSE;
Int_t iBucMul = 0;
while (data.second != ECbmModuleId::kNotExist) { // build digi array
digi = boost::any_cast<CbmTofDigi*>(data.first);
LOG(debug) << "GetNextData " << digi << ", " << data.second << ", " << Form("%f %f", digi->GetTime(), dTEnd)
<< ", Mul " << nDigi;
assert(digi);
if (nDigi == vdigi.size()) vdigi.resize(nDigi + 100);
vdigi[nDigi++] = digi;
Int_t iAddr = digi->GetAddress() & AddrMask;
if (iAddr == 0x00003006 || iAddr == 0x0000b006) {
iBucMul++;
LOG(debug) << Form("Event %10lu: BucMul %2d, addr 0x%08x, side %d, strip %2d, rpc %d", fEventHeader[0], iBucMul,
(uint) digi->GetAddress(), (Int_t) digi->GetSide(), (Int_t) digi->GetChannel(),
(int) digi->GetRpc());
}
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++)
if ((digi->GetAddress() & AddrMask) == fiReqDigiAddr[i]) {
Int_t j = ((CbmTofDigi*) digi)->GetSide();
bDet[i][j] = kTRUE;
if (fiReqDigiAddr[i] == (Int_t) fiReqBeam) {
bBeam = kTRUE;
LOG(debug) << "Found ReqBeam at index " << nDigi - 1 << ", req " << i;
}
if ((UInt_t) fiReqDigiAddr[i] == fiAddrRef) bDet[i][1] = kTRUE; // diamond with pad readout
if ((fiReqDigiAddr[i] & 0x0000F00F) == 0x00004006) { // pad counters v21a
bDet[i][1] = kTRUE;
LOG(debug) << Form("Pad counter 0x%08x found in ev %10lu", fiReqDigiAddr[i], fEventHeader[0]);
}
Int_t str = ((CbmTofDigi*) digi)->GetChannel();
switch (j) { // treat both strip ends separately
case 0: {
switch (fiPulserMode) {
case 0:
case 1:
if (str == 31)
if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) bPul[i][0] = kTRUE;
if (str == 0) bPul[i][1] = kFALSE;
if ((UInt_t) fiReqDigiAddr[i] == fiAddrRef) { //special mapping for MAr2019 diamond (Bmon)
if (str == 0) bPul[i][0] = kTRUE;
if (str == 40) bPul[i][1] = kTRUE;
}
break;
case 2:
if (str == 0) {
if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) {
bPul[i][0] = kTRUE;
if ((fiReqDigiAddr[i] & 0x000FF00F) == 0x00078006) {
bPul[i][1] = kTRUE; // ceramic with pad readout
bDet[i][1] = kFALSE; // remove Hit flag
}
if (str == 31) bPul[i][1] = kFALSE;
}
}
default:;
}
} break;
case 1:
switch (fiPulserMode) {
case 0:
case 1:
if (str == 31) bPul[i][0] = kFALSE;
if (str == 0)
if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) bPul[i][1] = kTRUE;
break;
case 2:
if (str == 0) bPul[i][0] = kFALSE;
if (str == 31)
if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) bPul[i][1] = kTRUE;
break;
default:;
}
break;
default:;
}
}
//if(bOut) LOG(info)<<Form("Found 0x%08x, Req 0x%08x ", digi->GetAddress(), fiReqDigiAddr);
if (dTEnd - digi->GetTime() < fdMaxDeltaT * 0.5) {
if (digi->GetTime() + fdMaxDeltaT * 0.5 < dTEndMax) dTEnd = digi->GetTime() + fdMaxDeltaT * 0.5;
else
dTEnd = dTEndMax;
};
data = fBuffer->GetNextData(dTEnd);
} // end while
LOG(debug) << Form(" %d digis associated to dTEnd = %15.9f", nDigi, dTEnd);
//for(UInt_t iDigi=0; iDigi<nDigi; iDigi++) LOG(debug)<<Form(" 0x%08x",vdigi[iDigi]->GetAddress());
//for (UInt_t iDigi = 0; iDigi < nDigi; iDigi++) LOG(debug) << vdigi[iDigi]->ToString();
for (UInt_t iDigi = 0; iDigi < nDigi; iDigi++)
LOG(debug) << "B " << iDigi << " TSRC " << vdigi[iDigi]->GetType() << vdigi[iDigi]->GetSm()
<< vdigi[iDigi]->GetRpc() << vdigi[iDigi]->GetChannel() << " S " << vdigi[iDigi]->GetSide() << " : "
<< Form("T %15.3f, Tot %5.1f", vdigi[iDigi]->GetTime(), vdigi[iDigi]->GetTot());
UInt_t iDetMul = 0;
if (fiReqDigiAddr.size() == 0) bOut = kTRUE; // output everything
else {
if (fiReqMode == 0) { // check for presence of requested detectors
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++)
if (bDet[i][0] == kFALSE || bDet[i][1] == kFALSE) break;
else if (i == fiReqDigiAddr.size() - 1) {
bOut = kTRUE;
iDetMul = i;
}
}
else { // check for presence of any known detector
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++)
if (bDet[i][0] == kTRUE && bDet[i][1] == kTRUE) { iDetMul++; }
if (iDetMul >= fiReqMode) { bOut = kTRUE; }
}
}
if (bOut && fiReqDigiAddr.size() > 1) {
LOG(debug) << "Found Req coinc in event with " << nDigi << " digis in " << iDetMul
<< " detectors, dTEnd = " << dTEnd;
}
// determine Pulser status
UInt_t iPulMul = 0; // Count Potential Pulser Signals
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++) {
if (bPul[i][0] == kTRUE && bPul[i][1] == kTRUE) iPulMul++;
}
if (fiPulserMode > 0 && iPulMul > fiPulMulMin) {
LOG(debug) << "@Event " << fEventHeader[0] << ": iPulMul = " << iPulMul;
bOut = kTRUE;
}
LOG(debug) << "Process Ev " << fEventHeader[0] << " with iDetMul = " << iDetMul << ", iPulMul = " << iPulMul;
fEventHeader[0]++;
if ((Int_t) fiReqBeam > -1) {
if (bBeam) { LOG(debug) << "Beam counter is present "; }
else {
LOG(debug) << "Beam counter is not present";
bOut = kFALSE; // request beam counter for event
}
}
if (bOut) {
fEventHeader[1] = iDetMul;
fEventHeader[2] = fiReqMode;
fEventHeader[3] = iPulMul;
fEventHeader[4] = ulTsStartTime; // PAL, 2022/07/05: no need to go to algo to get this value
/*
LOG(info) << "Sevt # " << fEventHeader[0]
<<", DetMul "<< fEventHeader[1]
<<", ReqMod "<< fEventHeader[2]
<<", PulMul "<< fEventHeader[3]
<<", TsStart "<< fEventHeader[4];
*/
vdigi.resize(nDigi);
const Int_t NDigiMax = 10000; //FIXME constant number in code
if (nDigi > NDigiMax) {
LOG(warn) << "Oversized event " << fEventHeader[0] << ", size " << nDigi << " truncated! ";
for (UInt_t iDigi = NDigiMax; iDigi < nDigi; iDigi++) {
LOG(debug) << "Discard digi " << iDigi << ": " << vdigi[iDigi]->ToString();
delete vdigi[iDigi];
}
nDigi = 1; //NDigiMax;
vdigi.resize(nDigi);
}
LOG(debug) << "Send " << nDigi << " digis to HitBuilder";
SendDigis(vdigi, 0);
for (UInt_t iDigi = 0; iDigi < nDigi; iDigi++)
delete vdigi[iDigi];
}
else {
LOG(debug) << " BuildTint cleanup of " << nDigi << " digis";
for (UInt_t iDigi = 0; iDigi < nDigi; iDigi++) {
delete vdigi[iDigi];
// vdigi[iDigi]->Delete();
}
LOG(debug) << " Digis deleted ";
//vdigi.clear();
//delete &vdigi; // crashes, since local variable, will be done at return (?)
}
}
}
bool CbmDeviceUnpackTofCri::SendDigis(std::vector<CbmTofDigi*> vdigi, int idx)
{
LOG(debug) << "Send Digis for event " << fNumTint << " with size " << vdigi.size() << Form(" at %p ", &vdigi);
LOG(debug) << "EventHeader: " << fEventHeader[0] << " " << fEventHeader[1] << " " << fEventHeader[2] << " "
<< fEventHeader[3];
// Int_t NDigi=vdigi.size();
std::stringstream ossE;
boost::archive::binary_oarchive oaE(ossE);
oaE << fEventHeader;
std::string* strMsgE = new std::string(ossE.str());
std::stringstream oss;
boost::archive::binary_oarchive oa(oss);
oa << vdigi;
std::string* strMsg = new std::string(oss.str());
FairMQParts parts;
parts.AddPart(NewMessage(
const_cast<char*>(strMsgE->c_str()), // data
strMsgE->length(), // size
[](void*, void* object) { delete static_cast<std::string*>(object); },
strMsgE)); // object that manages the data
parts.AddPart(NewMessage(
const_cast<char*>(strMsg->c_str()), // data
strMsg->length(), // size
[](void*, void* object) { delete static_cast<std::string*>(object); },
strMsg)); // object that manages the data
/*
std::vector<CbmTofDigi>vTofDigi;
vTofDigi.resize(vdigi.size());
for (Int_t i=0; i<vdigi.size(); i++) {
CbmTofDigi *pdigi = (CbmTofDigi *) vdigi[i];
CbmTofDigi digi = *pdigi;
vTofDigi[i] = digi;
LOG(debug) << vTofDigi[i].ToString()<<" bits "<<Form("0x%08x",vTofDigi[i].TestBits(0xFFFF));
}
FairMQMessagePtr msg(NewMessage(static_cast<std::vector<CbmTofDigi>*> (&vTofDigi), // data
NDigi*sizeof(CbmTofDigi), // size
[](void* , void* object){ delete static_cast<CbmTofDigi*>(object); }
)); // object that manages the data
// transfer of TofDigi array, ... works
CbmTofDigi aTofDigi[NDigi];
// const Int_t iNDigiOut=100;
// NDigi=TMath::Min(NDigi,iNDigiOut);
// std::array<CbmTofDigi,iNDigiOut> aTofDigi;
for (Int_t i=0; i<NDigi; i++) {
aTofDigi[i] = *vdigi[i];
LOG(debug) << aTofDigi[i].ToString()<<" bits "<<Form("0x%08x",aTofDigi[i].TestBits(0xFFFF));
}
FairMQMessagePtr msg(NewMessage(static_cast<CbmTofDigi*> (&aTofDigi[0]), // data
NDigi*sizeof(CbmTofDigi), // size
[](void* , void* object){ delete static_cast<CbmTofDigi*>(object); }
)); // object that manages the data
LOG(info) << "Send aTofDigi sizes "<<NDigi<<", "<<sizeof(CbmTofDigi)<<", msg size "<<msg->GetSize();
// serialize the timeslice and create the message
std::stringstream oss;
boost::archive::binary_oarchive oa(oss);
oa << vdigi;
std::string* strMsg = new std::string(oss.str());
LOG(debug) << "send strMsg with length " << strMsg->length()<<" "<<strMsg;
FairMQMessagePtr msg(NewMessage(const_cast<char*>(strMsg->c_str()), // data
strMsg->length(), // size
[](void* , void* object){ delete static_cast<std::string*>(object); },
strMsg)); // object that manages the data
*/
/*
FairMQMessagePtr msg(NewMessage(static_cast<CbmTofDigi*> (vTofDigi.data()), // data
vTofDigi.size()*sizeof(CbmTofDigi), // size
[](void* , void* object){ delete static_cast<CbmTofDigi*>(object); }
)); // object that manages the data
*/
/* --------------------------------------- compiles but crashes .... ---------------------------------------------------
const Int_t WSize=8;
FairMQMessagePtr msg(NewMessage(static_cast<std::vector<CbmTofDigi>*> (&vTofDigi), // data
vTofDigi.size()*sizeof(CbmTofDigi)*WSize, // size, FIXME, numerical value in code!
[](void* , void* object){ delete static_cast<std::vector<CbmTofDigi>*>(object); }
)); // object that manages the data
LOG(info) << "Send TofDigi sizes "<<vTofDigi.size()<<", "<<sizeof(CbmTofDigi)<<", msg size "<<msg->GetSize();
int *pData = static_cast <int *>(vTofDigi.data());
int *pData = static_cast <int *>(msg->GetData());
const Int_t NBytes=4;
for (int iData=0; iData<msg->GetSize()/NBytes; iData++) {
LOG(info) << Form(" ind %d, poi %p, data: 0x%08x",iData,pData,*pData++);
}
*/
/*
auto msg = NewMessageFor("my_channel", 0,
static_cast<void*>(vTofDigi.data()),
vTofDigi.size() * sizeof(CbmTofDigi),
FairMQNoCleanup, nullptr);
*/
// TODO: Implement sending same data to more than one channel
// Need to create new message (copy message??)
/*
if (fChannelsToSend[idx]>1) {
LOG(info) << "Need to copy FairMessage ?";
}
*/
// in case of error or transfer interruption,
// return false to go to IDLE state
// successfull transfer will return number of bytes
// transfered (can be 0 if sending an empty message).
LOG(debug) << "Send data to channel " << idx << " " << fChannelsToSend[idx][0];
// if (Send(msg, fChannelsToSend[idx][0]) < 0) {
if (Send(parts, fChannelsToSend[idx][0]) < 0) {
LOG(error) << "Problem sending data " << fChannelsToSend[idx][0];
return false;
}
LOG(debug) << "Sent event # " << fNumTint << " from " << vdigi.size() << " Digis at " << vdigi.data() << ", "
<< &vdigi;
fNumTint++;
//if(fNumTint==100) FairMQStateMachine::ChangeState(PAUSE); //sleep(10000); // Stop for debugging ...
/*
LOG(info) << "Send message " << fNumTint << " with a size of "
<< msg->GetSize();
*/
return true;
}
void CbmDeviceUnpackTofCri::AddReqDigiAddr(Int_t iAddr)
{
UInt_t iNReq = fiReqDigiAddr.size();
for (UInt_t i = 0; i < iNReq; i++)
if (fiReqDigiAddr[i] == iAddr) return; // det already present, avoid double counting
fiReqDigiAddr.resize(iNReq + 1); // hopefully the old entries are preserved ...
fiReqDigiAddr[iNReq] = iAddr;
LOG(info) << Form("Request Digi Address 0x%08x at index %d", iAddr, iNReq);
}
void CbmDeviceUnpackTofCri::SetIgnoreOverlapMs(Bool_t bFlagIn) { fUnpackerAlgo->SetDoIgnoreOverlappMs(bFlagIn); }
//void CbmDeviceUnpackTofCri::SetTimeOffsetNs(Double_t dOffsetIn) { fUnpackerAlgo->SetTimeOffsetNs(dOffsetIn); }
//void CbmDeviceUnpackTofCri::SetDiamondDpbIdx(UInt_t uIdx) { fUnpackerAlgo->SetDiamondDpbIdx(uIdx); }
/* Copyright (C) 2018-2020 PI-UHd, GSI
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig, Norbert Herrmann [committer] */
/**
* CbmDeviceUnpackTofCri.h
*
* @since 2018-04-25
* @author F. Uhlig
*/
// TODO: (VF, 190914) Many unused private members were commented out.
// The class has to be revised.
#ifndef CBMDEVICEUNPACKTOFCri_H_
#define CBMDEVICEUNPACKTOFCri_H_
#include "CbmMcbm2018TofPar.h"
#include "MicrosliceDescriptor.hpp"
#include "Timeslice.hpp"
#include "FairMQDevice.h"
#include "Rtypes.h"
#include "TMessage.h"
#include <map>
#include <vector>
#include "gDpbMessv100.h"
class CbmTofUnpackAlgo;
class CbmMcbm2018TofPar;
class CbmTbDaqBuffer;
class CbmHistManager;
class CbmTofDigi;
class TH1;
class TH2;
class CbmDeviceUnpackTofCri : public FairMQDevice {
public:
CbmDeviceUnpackTofCri();
virtual ~CbmDeviceUnpackTofCri();
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
bool HandleParts(FairMQParts&, int);
bool HandleMessage(FairMQMessagePtr&, int);
virtual void BuildTint(uint64_t ulTsStartTime, int iMode = 0);
virtual bool SendDigis(std::vector<CbmTofDigi*>, int);
private:
uint64_t fNumMessages;
uint64_t fiSelectComponents;
uint64_t fNumTint;
std::vector<uint64_t> fEventHeader;
uint64_t fiReqMode;
uint64_t fiReqTint;
uint64_t fiReqBeam;
std::vector<Int_t> fiReqDigiAddr;
Int_t fiPulserMode;
uint64_t fiPulMulMin;
uint64_t fiPulTotMin;
uint64_t fiPulTotMax;
std::vector<std::string> fAllowedChannels = {"tofcomponent", "parameters", "tofdigis", "syscmd"};
std::vector<std::vector<std::string>> fChannelsToSend = {{}, {}, {}};
size_t fuTotalMsNb; /** Total nb of MS per link in timeslice **/
size_t fuOverlapMsNb; /** Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/
size_t fuCoreMs; /** Number of non overlap MS at beginning of TS **/
Double_t fdMsSizeInNs;
Double_t fdTsCoreSizeInNs;
UInt_t fuMinNbGdpb;
UInt_t fuNrOfGdpbs; // Total number of GDPBs in the system
UInt_t fuNrOfFeePerGdpb; // Number of FEEs per GDPB
UInt_t fuNrOfGet4PerFee; // Number of GET4s per FEE
UInt_t fuNrOfChannelsPerGet4; // Number of channels in each GET4
UInt_t fuNrOfChannelsPerFee; // Number of channels in each FEET
UInt_t fuNrOfGet4; // Total number of Get4 chips in the system
UInt_t fuNrOfGet4PerGdpb; // Number of GET4s per GDPB
UInt_t fuNrOfChannelsPerGdpb; // Number of channels per GDPB
const UInt_t kuNbFeePerGbtx = 5;
const UInt_t kuNbGbtxPerGdpb = 6;
UInt_t fuGdpbId; // Id (hex number) of the GDPB for current message
UInt_t fuGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB for current message
UInt_t fuGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message
UInt_t fuGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system for current message
std::vector<int> fMsgCounter;
std::map<UInt_t, UInt_t> fGdpbIdIndexMap;
// CbmHistManager* fHM; ///< Histogram manager
/** Current epoch marker for each GDPB and GET4
* (first epoch in the stream initializes the map item)
* pointer points to an array of size fNrOfGdpbs * fNrOfGet4PerGdpb
* The correct array index is calculated using the function
* GetArrayIndex(gdpbId, get4Id)
**/
std::vector<ULong64_t> fvulCurrentEpoch; //!
std::vector<Bool_t> fvbFirstEpochSeen; //!
Int_t fNofEpochs; /** Current epoch marker for each ROC **/
ULong64_t fulCurrentEpochTime; /** Time stamp of current epoch **/
//Double_t fdMsIndex;
Double_t fdToffTof;
UInt_t fiAddrRef;
//UInt_t fuDiamondDpbIdx;
//Bool_t fbEpochSuppModeOn;
//Bool_t fbGet4M24b;
//Bool_t fbGet4v20;
//Bool_t fbMergedEpochsOn;
CbmMcbm2018TofPar* fUnpackPar; //!
// Variables used for histo filling
Double_t fdLastDigiTime;
Double_t fdFirstDigiTimeDif;
//Double_t fdEvTime0;
TH1* fhRawTDigEvBmon;
TH1* fhRawTDigRef0;
TH1* fhRawTDigRef;
TH1* fhRawTRefDig0;
TH1* fhRawTRefDig1;
TH1* fhRawDigiLastDigi;
std::vector<TH2*> fhRawTotCh;
std::vector<TH1*> fhChCount;
std::vector<Bool_t> fvbChanThere;
std::vector<TH2*> fhChanCoinc;
//Bool_t fbDetChanThere[64]; // FIXME
TH2* fhDetChanCoinc;
inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id) { return gdpbId * fuNrOfGet4PerGdpb + get4Id; }
///* PADI channel to GET4 channel mapping and reverse *///
std::vector<UInt_t> fvuPadiToGet4;
std::vector<UInt_t> fvuGet4ToPadi;
///* GET4 to eLink mapping and reverse *///
static const UInt_t kuNbGet4PerGbtx = 5 * 8; /// 5 FEE with 8 GET4 each
std::vector<UInt_t> fvuElinkToGet4;
std::vector<UInt_t> fvuGet4ToElink;
inline UInt_t ConvertElinkToGet4(UInt_t uElinkIdx)
{
return fvuElinkToGet4[uElinkIdx % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uElinkIdx / kuNbGet4PerGbtx);
}
inline UInt_t ConvertGet4ToElink(UInt_t uGet4Idx)
{
return fvuGet4ToElink[uGet4Idx % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uGet4Idx / kuNbGet4PerGbtx);
}
std::vector<Int_t> fviRpcType;
std::vector<Int_t> fviModuleId;
std::vector<Int_t> fviNrOfRpc;
std::vector<Int_t> fviRpcSide;
std::vector<Int_t> fviRpcChUId;
CbmTbDaqBuffer* fBuffer;
bool CheckTimeslice(const fles::Timeslice& ts);
void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc);
bool IsChannelNameAllowed(std::string channelName);
void SetParContainers();
Bool_t InitContainers();
Bool_t ReInitContainers();
void CreateHistograms();
void AddReqDigiAddr(int);
Bool_t DoUnpack(const fles::Timeslice& ts, size_t component);
/// Temp until we change from CbmMcbmUnpack to something else
void AddMsComponentToList(size_t component, UShort_t usDetectorId);
void SetNbMsInTs(size_t /*uCoreMsNb*/, size_t /*uOverlapMsNb*/) {};
/// Algo settings setters
void SetIgnoreOverlapMs(Bool_t bFlagIn = kTRUE);
void SetTimeOffsetNs(Double_t dOffsetIn = 0.0);
void SetDiamondDpbIdx(UInt_t uIdx = 2);
/// Processing algo
std::shared_ptr<CbmTofUnpackAlgo> fUnpackerAlgo;
/// Control flags
// Bool_t fbMonitorMode; //! Switch ON the filling of a minimal set of histograms
// Bool_t fbDebugMonitorMode; //! Switch ON the filling of a additional set of histograms
// Bool_t fbSeparateArrayBmon; //! If ON, Bmon digis are saved in separate TClonesArray
// Bool_t fbWriteOutput; //! If ON the output TClonesArray of digi is written to disk
CbmDeviceUnpackTofCri(const CbmDeviceUnpackTofCri&) = delete;
CbmDeviceUnpackTofCri operator=(const CbmDeviceUnpackTofCri&) = delete;
};
// special class to expose protected TMessage constructor
class CbmMQTMessage : public TMessage {
public:
CbmMQTMessage(void* buf, Int_t len) : TMessage(buf, len) { ResetBit(kIsOwner); }
};
#endif /* CBMDEVICEUNPACKTOFCri_H_ */
/* Copyright (C) 2018-2020 PI-UHd, GSI
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig, Norbert Herrmann [committer] */
/**
* CbmDeviceUnpackTofMcbm2018.cxx
*
......@@ -6,24 +10,23 @@
*/
#include "CbmDeviceUnpackTofMcbm2018.h"
#include "CbmMQDefs.h"
#include "CbmDigi.h"
#include "CbmMcbm2018UnpackerAlgoTof.h"
#include "CbmDefs.h"
#include "CbmMQDefs.h"
#include "CbmMcbm2018TofPar.h"
#include "CbmMcbm2018UnpackerAlgoTof.h"
//#include "CbmHistManager.h"
#include "CbmTbDaqBuffer.h"
#include "CbmTofDigi.h"
#include "CbmTofAddress.h"
#include "CbmTofDetectorId_v14a.h" // in cbmdata/tof
#include "CbmTofDetectorId_v21a.h" // in cbmdata/tof
#include "CbmTofDigi.h"
#include "StorableTimeslice.hpp"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairRuntimeDb.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairParGenericSet.h"
#include "FairRuntimeDb.h"
#include "TH1.h"
#include "TH2.h"
......@@ -34,17 +37,18 @@
// include this header to serialize vectors
#include <boost/serialization/vector.hpp>
#include <string>
#include <iomanip>
#include <array>
#include <iomanip>
#include <stdexcept>
struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; };
#include <string>
struct InitTaskError : std::runtime_error {
using std::runtime_error::runtime_error;
};
using namespace std;
//static Int_t iMess=0;
const Int_t DetMask = 0x003FFFFF;
//const Int_t DetMask = 0x001FFFFF;
CbmDeviceUnpackTofMcbm2018::CbmDeviceUnpackTofMcbm2018()
: fNumMessages(0)
......@@ -53,21 +57,18 @@ CbmDeviceUnpackTofMcbm2018::CbmDeviceUnpackTofMcbm2018()
, fEventHeader()
, fiReqMode(0)
, fiReqTint(0)
, fiReqBeam(-1)
, fiReqDigiAddr()
, fiPulserMode(0)
, fiPulMulMin(0)
, fiPulTotMin(0)
, fiPulTotMax(1000)
// , fAllowedChannels()
// , fChannelsToSend()
//, fuMsAcceptsPercent(100)
, fuTotalMsNb(0)
, fuOverlapMsNb(0)
, fuCoreMs(0)
, fdMsSizeInNs(0)
, fdMsSizeInNs(0)
, fdTsCoreSizeInNs(0)
, fuMinNbGdpb( 0 )
//, fuCurrNbGdpb( 0 )
, fuMinNbGdpb(0)
, fuNrOfGdpbs(0)
, fuNrOfFeePerGdpb(0)
, fuNrOfGet4PerFee(0)
......@@ -80,41 +81,30 @@ CbmDeviceUnpackTofMcbm2018::CbmDeviceUnpackTofMcbm2018()
, fuGdpbNr(0)
, fuGet4Id(0)
, fuGet4Nr(0)
//, fiEquipmentId(0)
, fMsgCounter(11,0) // length of enum MessageTypes initialized with 0
, fMsgCounter(11, 0) // length of enum MessageTypes initialized with 0
, fGdpbIdIndexMap()
, fvulGdpbTsMsb()
, fvulGdpbTsLsb()
, fvulStarTsMsb()
, fvulStarTsMid()
, fvulGdpbTsFullLast()
, fvulStarTsFullLast()
, fvuStarTokenLast()
, fvuStarDaqCmdLast()
, fvuStarTrigCmdLast()
, fvulCurrentEpoch()
, fvbFirstEpochSeen()
, fNofEpochs(0)
, fulCurrentEpochTime(0.)
//, fdMsIndex(0.)
, fdTShiftRef(0.)
, fdToffTof(0.)
, fiAddrRef(0)
//, fuDiamondDpbIdx(3)
//, fbEpochSuppModeOn( kTRUE )
//, fbGet4M24b( kFALSE )
//, fbGet4v20( kTRUE )
//, fbMergedEpochsOn( kTRUE )
, fDigi(nullptr)
, fUnpackPar(nullptr)
//, fdRefTime(0.)
, fdLastDigiTime(0.)
, fdFirstDigiTimeDif(0.)
//, fdEvTime0(0.)
, fhRawTDigEvT0( nullptr )
, fhRawTDigRef0( nullptr )
, fhRawTDigRef( nullptr )
, fhRawTRefDig0( nullptr )
, fhRawTRefDig1( nullptr )
, fhRawDigiLastDigi( nullptr )
, fhRawTDigEvBmon(nullptr)
, fhRawTDigRef0(nullptr)
, fhRawTDigRef(nullptr)
, fhRawTRefDig0(nullptr)
, fhRawTRefDig1(nullptr)
, fhRawDigiLastDigi(nullptr)
, fhRawTotCh()
, fhChCount()
, fvbChanThere()
......@@ -129,145 +119,131 @@ CbmDeviceUnpackTofMcbm2018::CbmDeviceUnpackTofMcbm2018()
, fviNrOfRpc()
, fviRpcSide()
, fviRpcChUId()
, fvmEpSupprBuffer()
, fBuffer(CbmTbDaqBuffer::Instance())
, fulGdpbTsMsb(0.)
, fulGdpbTsLsb(0.)
, fulStarTsMsb(0.)
, fulStarTsMid(0.)
, fulGdpbTsFullLast(0.)
, fulStarTsFullLast(0.)
, fuStarTokenLast(0)
, fuStarDaqCmdLast(0)
, fuStarTrigCmdLast(0)
, fUnpackerAlgo( nullptr )
, fUnpackerAlgo(nullptr)
{
fUnpackerAlgo = new CbmMcbm2018UnpackerAlgoTof();
fUnpackerAlgo = new CbmMcbm2018UnpackerAlgoTof();
}
CbmDeviceUnpackTofMcbm2018::~CbmDeviceUnpackTofMcbm2018()
{
delete fUnpackerAlgo;
}
CbmDeviceUnpackTofMcbm2018::~CbmDeviceUnpackTofMcbm2018() { delete fUnpackerAlgo; }
void CbmDeviceUnpackTofMcbm2018::InitTask()
try
{
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
// for the device
// The idea is to check at initilization if the devices are
// properly connected. For the time beeing this is done with a
// nameing convention. It is not avoided that someone sends other
// data on this channel.
//logger::SetLogLevel("INFO");
int noChannel = fChannels.size();
LOG(info) << "Number of defined channels: " << noChannel;
for(auto const &entry : fChannels) {
LOG(info) << "Channel name: " << entry.first;
if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match.");
if(entry.first == "syscmd") {
OnData(entry.first, &CbmDeviceUnpackTofMcbm2018::HandleMessage);
continue;
}
//if(entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofMcbm2018::HandleData);
if(entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofMcbm2018::HandleParts);
else {
fChannelsToSend[0].push_back(entry.first);
LOG(info) << "Init to send data to channel " << fChannelsToSend[0][0];
}
try {
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
// for the device
// The idea is to check at initilization if the devices are
// properly connected. For the time beeing this is done with a
// nameing convention. It is not avoided that someone sends other
// data on this channel.
//logger::SetLogLevel("INFO");
int noChannel = fChannels.size();
LOG(info) << "Number of defined channels: " << noChannel;
for (auto const& entry : fChannels) {
LOG(info) << "Channel name: " << entry.first;
if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match.");
if (entry.first == "syscmd") {
OnData(entry.first, &CbmDeviceUnpackTofMcbm2018::HandleMessage);
continue;
}
InitContainers();
const Int_t iHeaderSize=4;
fEventHeader.resize(iHeaderSize); // define size of eventheader int[]
for(int i=0; i<iHeaderSize; i++) fEventHeader[i]=0;
fiSelectComponents = fConfig->GetValue<uint64_t>("SelectComponents");
fiReqMode = fConfig->GetValue<uint64_t>("ReqMode");
fiReqTint = fConfig->GetValue<uint64_t>("ReqTint");
fiPulserMode= fConfig->GetValue<int64_t>("PulserMode");
fiPulMulMin = fConfig->GetValue<uint64_t>("PulMulMin");
fiPulTotMin = fConfig->GetValue<uint64_t>("PulTotMin");
fiPulTotMax = fConfig->GetValue<uint64_t>("PulTotMax");
fdTShiftRef = fConfig->GetValue<double_t>("TShiftRef");
// Int_t iMaxAsicInactive = fConfig->GetValue<uint64_t>("MaxAsicInactive");
// fUnpackerAlgo->SetMaxAsicInactive( iMaxAsicInactive );
Int_t iReqDet=1;
Int_t iNReq=0;
const Int_t iMaxReq=36;
while(iNReq<iMaxReq) { // FIXME, setup parameter hardwired!
iReqDet = fConfig->GetValue<uint64_t>(Form("ReqDet%d",iNReq));
if (iReqDet == 0) break;
AddReqDigiAddr(iReqDet);
iNReq++;
//if(entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofMcbm2018::HandleData);
if (entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofMcbm2018::HandleParts);
else {
fChannelsToSend[0].push_back(entry.first);
LOG(info) << "Init to send data to channel " << fChannelsToSend[0][0];
}
}
InitContainers();
const Int_t iHeaderSize = 4;
fEventHeader.resize(iHeaderSize); // define size of eventheader int[]
for (int i = 0; i < iHeaderSize; i++)
fEventHeader[i] = 0;
LOG(info) << "Read config";
fiSelectComponents = fConfig->GetValue<uint64_t>("SelectComponents");
fiReqMode = fConfig->GetValue<uint64_t>("ReqMode");
fiReqTint = fConfig->GetValue<uint64_t>("ReqTint");
fiReqBeam = fConfig->GetValue<uint64_t>("ReqBeam");
fiPulserMode = fConfig->GetValue<int64_t>("PulserMode");
fiPulMulMin = fConfig->GetValue<uint64_t>("PulMulMin");
fiPulTotMin = fConfig->GetValue<uint64_t>("PulTotMin");
fiPulTotMax = fConfig->GetValue<uint64_t>("PulTotMax");
fdToffTof = fConfig->GetValue<double_t>("ToffTof");
Int_t iRefModType = fConfig->GetValue<int64_t>("RefModType");
Int_t iRefModId = fConfig->GetValue<int64_t>("RefModId");
Int_t iRefCtrType = fConfig->GetValue<int64_t>("RefCtrType");
Int_t iRefCtrId = fConfig->GetValue<int64_t>("RefCtrId");
if (iRefModType > -1)
fiAddrRef = CbmTofAddress::GetUniqueAddress(iRefModId, iRefCtrId, 0, 0, iRefModType, iRefCtrType);
LOG(info) << " Using Reference counter address 0x" << std::hex << fiAddrRef;
// Int_t iMaxAsicInactive = fConfig->GetValue<uint64_t>("MaxAsicInactive");
// fUnpackerAlgo->SetMaxAsicInactive( iMaxAsicInactive );
Int_t iReqDet = 1;
Int_t iNReq = 0;
const Int_t iMaxReq = 50;
while (iNReq < iMaxReq) { // FIXME, setup parameter hardwired!
iReqDet = fConfig->GetValue<uint64_t>(Form("ReqDet%d", iNReq));
if (iReqDet == 0) break;
AddReqDigiAddr(iReqDet);
iNReq++;
}
LOG(info) << "Setup request";
if (fiReqMode > 0)
if (iNReq == 0) { // take all defined detectors
for (UInt_t iGbtx = 0; iGbtx < fviNrOfRpc.size(); iGbtx++) {
switch (fviRpcType[iGbtx]) {
case 0: // mTof modules
case 1: // eTof modules
if (iGbtx % 2 == 0)
for (Int_t iRpc = 0; iRpc < fviNrOfRpc[iGbtx]; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
case 4:
case 9: // HD 2-RPC boxes
for (Int_t iRpc = 0; iRpc < 2; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
case 6: // Buc box
for (Int_t iRpc = 0; iRpc < 2; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
if(fiReqMode > 0)
if(iNReq == 0) { // take all defined detectors
for(UInt_t iGbtx= 0; iGbtx < fviNrOfRpc.size(); iGbtx++) {
switch(fviRpcType[iGbtx]){
case 0: // mTof modules
case 1: // eTof modules
if(iGbtx%2 == 0)
for(Int_t iRpc= 0; iRpc < fviNrOfRpc[iGbtx]; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
iRpc,0,0,
fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
case 9: // HD 2-RPC boxes
for(Int_t iRpc= 0; iRpc < 2; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
iRpc,0,0,
fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
case 6: // Buc box
for(Int_t iRpc= 0; iRpc < 2; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
iRpc,0,0,
fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
case 7: // CERN box
for(Int_t iRpc= 0; iRpc < 1; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
iRpc,0,0,
7);
AddReqDigiAddr(iAddr);
}
break;
case 8: // ceramics
for(Int_t iRpc= 0; iRpc < 8; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
iRpc,0,0,
fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
case 5: // add Diamond, single cell RPC
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
0,0,0,5);
AddReqDigiAddr(iAddr);
break;
}
}
case 7: // CERN box
for (Int_t iRpc = 0; iRpc < 1; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, 7);
AddReqDigiAddr(iAddr);
}
break;
case 8: // ceramics
for (Int_t iRpc = 0; iRpc < 8; iRpc++) {
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]);
AddReqDigiAddr(iAddr);
}
break;
case 5: // add Diamond, single cell RPC
Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], 0, 0, 0, 5);
AddReqDigiAddr(iAddr);
break;
}
}
}
LOG(info)<<"ReqMode "<<fiReqMode
<<" in " << fiReqTint << " ns "
<<" with "<<fiReqDigiAddr.size()
<<" detectors out of " << fviNrOfRpc.size() <<" GBTx, PulserMode "
<< fiPulserMode << " with Mul " << fiPulMulMin<<", TotMin "<<fiPulTotMin;
} catch (InitTaskError& e) {
LOG(info) << "ReqMode " << fiReqMode << " in " << fiReqTint << " ns "
<< " with " << fiReqDigiAddr.size() << " detectors out of " << fviNrOfRpc.size() << " GBTx, PulserMode "
<< fiPulserMode << " with Mul " << fiPulMulMin << ", TotMin " << fiPulTotMin;
LOG(info) << Form("ReqBeam 0x%08x", (uint) fiReqBeam);
}
catch (InitTaskError& e) {
LOG(error) << e.what();
// Wrapper defined in CbmMQDefs.h to support different FairMQ versions
cbm::mq::ChangeState(this, cbm::mq::Transition::ErrorFound);
......@@ -275,21 +251,19 @@ try
bool CbmDeviceUnpackTofMcbm2018::IsChannelNameAllowed(std::string channelName)
{
for(auto const &entry : fAllowedChannels) {
for (auto const& entry : fAllowedChannels) {
LOG(info) << "Inspect " << entry;
std::size_t pos1 = channelName.find(entry);
if (pos1!=std::string::npos) {
if (pos1 != std::string::npos) {
const vector<std::string>::const_iterator pos =
std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry);
const vector<std::string>::size_type idx = pos-fAllowedChannels.begin();
std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry);
const vector<std::string>::size_type idx = pos - fAllowedChannels.begin();
LOG(info) << "Found " << entry << " in " << channelName;
LOG(info) << "Channel name " << channelName
<< " found in list of allowed channel names at position " << idx;
LOG(info) << "Channel name " << channelName << " found in list of allowed channel names at position " << idx;
return true;
}
}
LOG(info) << "Channel name " << channelName
<< " not found in list of allowed channel names.";
LOG(info) << "Channel name " << channelName << " not found in list of allowed channel names.";
LOG(error) << "Stop device.";
return false;
}
......@@ -297,55 +271,49 @@ bool CbmDeviceUnpackTofMcbm2018::IsChannelNameAllowed(std::string channelName)
Bool_t CbmDeviceUnpackTofMcbm2018::InitContainers()
{
LOG(info) << "Init parameter containers for CbmDeviceUnpackTofMcbm2018.";
// FairRuntimeDb* fRtdb = FairRuntimeDb::instance();
// FairRuntimeDb* fRtdb = FairRuntimeDb::instance();
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
// Should only be used for small data because of the cost of an additional copy
std::string message{"CbmMcbm2018TofPar,111"};
std::string message {"CbmMcbm2018TofPar,111"};
LOG(info) << "Requesting parameter container CbmMcbm2018TofPar, sending message: " << message;
FairMQMessagePtr req(NewSimpleMessage("CbmMcbm2018TofPar,111"));
FairMQMessagePtr rep(NewMessage());
if (Send(req, "parameters") > 0)
{
if (Receive(rep, "parameters") >= 0)
{
if (rep->GetSize() != 0)
{
CbmMQTMessage tmsg(rep->GetData(), rep->GetSize());
fUnpackPar = dynamic_cast<CbmMcbm2018TofPar*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(info) << "Received unpack parameter from parmq server: " << fUnpackPar;
fUnpackPar->Print();
}
else
{
LOG(error) << "Received empty reply. Parameter not available";
}
}
if (Send(req, "parameters") > 0) {
if (Receive(rep, "parameters") >= 0) {
if (rep->GetSize() != 0) {
CbmMqTMessage tmsg(rep->GetData(), rep->GetSize());
fUnpackPar = dynamic_cast<CbmMcbm2018TofPar*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(info) << "Received unpack parameter from parmq server: " << fUnpackPar;
fUnpackPar->Print();
}
else {
LOG(error) << "Received empty reply. Parameter not available";
}
}
}
SetParContainers();
SetParContainers();
Bool_t initOK = kTRUE;
initOK &= fUnpackerAlgo->InitContainers();
initOK &= ReInitContainers(); // needed for TInt parameters
// CreateHistograms();
initOK &= fUnpackerAlgo->CreateHistograms();
Bool_t initOK = kTRUE;
initOK &= fUnpackerAlgo->InitContainers();
initOK &= ReInitContainers(); // needed for TInt parameters
fvulCurrentEpoch.resize( fuNrOfGdpbs * fuNrOfGet4PerGdpb );
fvbFirstEpochSeen.resize( fuNrOfGdpbs * fuNrOfGet4PerGdpb );
fvbChanThere.resize( fviRpcChUId.size(), kFALSE );
for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
{
for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j )
{
fvulCurrentEpoch[GetArrayIndex(i, j)] = 0;
fvbFirstEpochSeen[GetArrayIndex(i, j)] = kFALSE;
} // for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j )
} // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
// CreateHistograms();
initOK &= fUnpackerAlgo->CreateHistograms();
fvulCurrentEpoch.resize(fuNrOfGdpbs * fuNrOfGet4PerGdpb);
fvbFirstEpochSeen.resize(fuNrOfGdpbs * fuNrOfGet4PerGdpb);
fvbChanThere.resize(fviRpcChUId.size(), kFALSE);
for (UInt_t i = 0; i < fuNrOfGdpbs; ++i) {
for (UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j) {
fvulCurrentEpoch[GetArrayIndex(i, j)] = 0;
fvbFirstEpochSeen[GetArrayIndex(i, j)] = kFALSE;
} // for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j )
} // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
fNumTint = 0;
return initOK;
......@@ -353,40 +321,37 @@ Bool_t CbmDeviceUnpackTofMcbm2018::InitContainers()
void CbmDeviceUnpackTofMcbm2018::SetParContainers()
{
FairRuntimeDb* fRtdb = FairRuntimeDb::instance();
TList* fParCList = fUnpackerAlgo->GetParList();
LOG(info) << "Setting parameter containers for " << fParCList->GetEntries() << " entries ";
for( Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC )
{
FairParGenericSet* tempObj = (FairParGenericSet*)(fParCList->At(iparC));
fParCList->Remove(tempObj);
std::string sParamName{ tempObj->GetName() };
FairParGenericSet* newObj = dynamic_cast<FairParGenericSet*>( fRtdb->getContainer( sParamName.data() ) );
LOG(info) << " - Get " << sParamName.data() << " at " << newObj;
if( nullptr == newObj )
{
FairRuntimeDb* fRtdb = FairRuntimeDb::instance();
LOG(error) << "Failed to obtain parameter container " << sParamName
<< ", for parameter index " << iparC;
return;
} // if( nullptr == newObj )
if( iparC == 0 ) {
newObj=(FairParGenericSet *) fUnpackPar;
LOG(info) << " - Mod " << sParamName.data() << " to " << newObj;
}
fParCList->AddAt(newObj, iparC);
// delete tempObj;
} // for( Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC )
TList* fParCList = fUnpackerAlgo->GetParList();
LOG(info) << "Setting parameter containers for " << fParCList->GetEntries() << " entries ";
for (Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC) {
FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC));
fParCList->Remove(tempObj);
std::string sParamName {tempObj->GetName()};
FairParGenericSet* newObj = dynamic_cast<FairParGenericSet*>(fRtdb->getContainer(sParamName.data()));
LOG(info) << " - Get " << sParamName.data() << " at " << newObj;
if (nullptr == newObj) {
LOG(error) << "Failed to obtain parameter container " << sParamName << ", for parameter index " << iparC;
return;
} // if( nullptr == newObj )
if (iparC == 0) {
newObj = (FairParGenericSet*) fUnpackPar;
LOG(info) << " - Mod " << sParamName.data() << " to " << newObj;
}
fParCList->AddAt(newObj, iparC);
// delete tempObj;
} // for( Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC )
}
void CbmDeviceUnpackTofMcbm2018::AddMsComponentToList( size_t component, UShort_t usDetectorId )
void CbmDeviceUnpackTofMcbm2018::AddMsComponentToList(size_t component, UShort_t usDetectorId)
{
fUnpackerAlgo->AddMsComponentToList( component, usDetectorId );
fUnpackerAlgo->AddMsComponentToList(component, usDetectorId);
}
Bool_t CbmDeviceUnpackTofMcbm2018::ReInitContainers()
......@@ -415,58 +380,10 @@ Bool_t CbmDeviceUnpackTofMcbm2018::ReInitContainers()
fuNrOfGet4PerGdpb = fuNrOfFeePerGdpb * fuNrOfGet4PerFee;
LOG(info) << "Nr. of GET4s per GDPB: " << fuNrOfGet4PerGdpb;
fuNrOfChannelsPerGdpb = fuNrOfGet4PerGdpb * fuNrOfChannelsPerGet4;
LOG(info) << "Nr. of channels per GDPB: " << fuNrOfChannelsPerGdpb;
fGdpbIdIndexMap.clear();
for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
{
fGdpbIdIndexMap[fUnpackPar->GetGdpbId(i)] = i;
LOG(info) << "GDPB Id of TOF " << i << " : " << std::hex << fUnpackPar->GetGdpbId(i)
;
} // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
fuTotalMsNb = fUnpackPar->GetNbMsTot();
fuOverlapMsNb = fUnpackPar->GetNbMsOverlap();
fuCoreMs = fuTotalMsNb - fuOverlapMsNb;
fdMsSizeInNs = fUnpackPar->GetSizeMsInNs();
fdTsCoreSizeInNs = fdMsSizeInNs * fuCoreMs;
LOG(info) << "Timeslice parameters: "
<< fuTotalMsNb << " MS per link, of which "
<< fuOverlapMsNb << " overlap MS, each MS is "
<< fdMsSizeInNs << " ns"
;
/// STAR Trigger decoding and monitoring
fvulGdpbTsMsb.resize( fuNrOfGdpbs );
fvulGdpbTsLsb.resize( fuNrOfGdpbs );
fvulStarTsMsb.resize( fuNrOfGdpbs );
fvulStarTsMid.resize( fuNrOfGdpbs );
fvulGdpbTsFullLast.resize( fuNrOfGdpbs );
fvulStarTsFullLast.resize( fuNrOfGdpbs );
fvuStarTokenLast.resize( fuNrOfGdpbs );
fvuStarDaqCmdLast.resize( fuNrOfGdpbs );
fvuStarTrigCmdLast.resize( fuNrOfGdpbs );
for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb)
{
fvulGdpbTsMsb[ uGdpb ] = 0;
fvulGdpbTsLsb[ uGdpb ] = 0;
fvulStarTsMsb[ uGdpb ] = 0;
fvulStarTsMid[ uGdpb ] = 0;
fvulGdpbTsFullLast[ uGdpb ] = 0;
fvulStarTsFullLast[ uGdpb ] = 0;
fvuStarTokenLast[ uGdpb ] = 0;
fvuStarDaqCmdLast[ uGdpb ] = 0;
fvuStarTrigCmdLast[ uGdpb ] = 0;
} // for (Int_t iGdpb = 0; iGdpb < fuNrOfGdpbs; ++iGdpb)
fvmEpSupprBuffer.resize( fuNrOfGet4 );
/// TODO: move these constants somewhere shared, e.g the parameter file
fvuPadiToGet4.resize( fuNrOfChannelsPerFee );
fvuGet4ToPadi.resize( fuNrOfChannelsPerFee );
/* source: Monitor
/// TODO: move these constants somewhere shared, e.g the parameter file
fvuPadiToGet4.resize(fuNrOfChannelsPerFee);
fvuGet4ToPadi.resize(fuNrOfChannelsPerFee);
/* source: Monitor
UInt_t uGet4topadi[32] = {
4, 3, 2, 1, // provided by Jochen
24, 23, 22, 21,
......@@ -478,341 +395,362 @@ Bool_t CbmDeviceUnpackTofMcbm2018::ReInitContainers()
20, 19, 18, 17 };
*/
UInt_t uGet4topadi[32] = {
4, 3, 2, 1, // provided by Jochen
8, 7, 6, 5,
12, 11, 10, 9,
16, 15, 14, 13,
20, 19, 18, 17,
24, 23, 22, 21,
28, 27, 26, 25,
32, 31, 30, 29
};
UInt_t uGet4topadi[32] = {4, 3, 2, 1, // provided by Jochen
8, 7, 6, 5, 12, 11, 10, 9, 16, 15, 14, 13, 20, 19,
18, 17, 24, 23, 22, 21, 28, 27, 26, 25, 32, 31, 30, 29};
UInt_t uPaditoget4[32] = {4, 3, 2, 1, // provided by Jochen
12, 11, 10, 9, 20, 19, 18, 17, 28, 27, 26, 25, 32, 31,
30, 29, 8, 7, 6, 5, 16, 15, 14, 13, 24, 23, 22, 21};
for (UInt_t uChan = 0; uChan < fuNrOfChannelsPerFee; ++uChan) {
fvuPadiToGet4[uChan] = uPaditoget4[uChan] - 1;
fvuGet4ToPadi[uChan] = uGet4topadi[uChan] - 1;
} // for( UInt_t uChan = 0; uChan < fuNrOfChannelsPerFee; ++uChan )
/// TODO: move these constants somewhere shared, e.g the parameter file
fvuElinkToGet4.resize(kuNbGet4PerGbtx);
fvuGet4ToElink.resize(kuNbGet4PerGbtx);
UInt_t kuElinkToGet4[kuNbGet4PerGbtx] = {27, 2, 7, 3, 31, 26, 30, 1, 33, 37, 32, 13, 9, 14,
10, 15, 17, 21, 16, 35, 34, 38, 25, 24, 0, 6, 20, 23,
18, 22, 28, 4, 29, 5, 19, 36, 39, 8, 12, 11};
UInt_t kuGet4ToElink[kuNbGet4PerGbtx] = {24, 7, 1, 3, 31, 33, 25, 2, 37, 12, 14, 39, 38, 11,
13, 15, 18, 16, 28, 34, 26, 17, 29, 27, 23, 22, 5, 0,
30, 32, 6, 4, 10, 8, 20, 19, 35, 9, 21, 36};
for (UInt_t uLinkAsic = 0; uLinkAsic < kuNbGet4PerGbtx; ++uLinkAsic) {
fvuElinkToGet4[uLinkAsic] = kuElinkToGet4[uLinkAsic];
fvuGet4ToElink[uLinkAsic] = kuGet4ToElink[uLinkAsic];
} // for( UInt_t uChan = 0; uChan < fuNrOfChannelsPerFee; ++uChan )
UInt_t uNrOfGbtx = fUnpackPar->GetNrOfGbtx();
fviRpcType.resize(uNrOfGbtx);
fviModuleId.resize(uNrOfGbtx);
fviNrOfRpc.resize(uNrOfGbtx);
fviRpcSide.resize(uNrOfGbtx);
for (UInt_t iGbtx = 0; iGbtx < uNrOfGbtx; ++iGbtx) {
fviNrOfRpc[iGbtx] = fUnpackPar->GetNrOfRpc(iGbtx);
fviRpcType[iGbtx] = fUnpackPar->GetRpcType(iGbtx);
fviRpcSide[iGbtx] = fUnpackPar->GetRpcSide(iGbtx);
fviModuleId[iGbtx] = fUnpackPar->GetModuleId(iGbtx);
}
UInt_t uPaditoget4[32] = {
4, 3, 2, 1, // provided by Jochen
12, 11, 10, 9,
20, 19, 18, 17,
28, 27, 26, 25,
32, 31, 30, 29,
8, 7, 6, 5,
16, 15, 14, 13,
24, 23, 22, 21 };
for( UInt_t uChan = 0; uChan < fuNrOfChannelsPerFee; ++uChan )
{
fvuPadiToGet4[ uChan ] = uPaditoget4[ uChan ] - 1;
fvuGet4ToPadi[ uChan ] = uGet4topadi[ uChan ] - 1;
} // for( UInt_t uChan = 0; uChan < fuNrOfChannelsPerFee; ++uChan )
/// TODO: move these constants somewhere shared, e.g the parameter file
fvuElinkToGet4.resize( kuNbGet4PerGbtx );
fvuGet4ToElink.resize( kuNbGet4PerGbtx );
UInt_t kuElinkToGet4[ kuNbGet4PerGbtx ] = { 27, 2, 7, 3, 31, 26, 30, 1,
33, 37, 32, 13, 9, 14, 10, 15,
17, 21, 16, 35, 34, 38, 25, 24,
0, 6, 20, 23, 18, 22, 28, 4,
29, 5, 19, 36, 39, 8, 12, 11
};
UInt_t kuGet4ToElink[ kuNbGet4PerGbtx ] = { 24, 7, 1, 3, 31, 33, 25, 2,
37, 12, 14, 39, 38, 11, 13, 15,
18, 16, 28, 34, 26, 17, 29, 27,
23, 22, 5, 0, 30, 32, 6, 4,
10, 8, 20, 19, 35, 9, 21, 36
};
for( UInt_t uLinkAsic = 0; uLinkAsic < kuNbGet4PerGbtx; ++uLinkAsic )
{
fvuElinkToGet4[ uLinkAsic ] = kuElinkToGet4[ uLinkAsic ];
fvuGet4ToElink[ uLinkAsic ] = kuGet4ToElink[ uLinkAsic ];
} // for( UInt_t uChan = 0; uChan < fuNrOfChannelsPerFee; ++uChan )
UInt_t uNrOfGbtx = fUnpackPar->GetNrOfGbtx();
fviRpcType.resize(uNrOfGbtx);
fviModuleId.resize(uNrOfGbtx);
fviNrOfRpc.resize(uNrOfGbtx);
fviRpcSide.resize(uNrOfGbtx);
for (UInt_t iGbtx = 0; iGbtx < uNrOfGbtx; ++iGbtx)
{
fviNrOfRpc[ iGbtx ] = fUnpackPar->GetNrOfRpc( iGbtx );
fviRpcType[ iGbtx ] = fUnpackPar->GetRpcType( iGbtx );
fviRpcSide[ iGbtx ] = fUnpackPar->GetRpcSide( iGbtx );
fviModuleId[ iGbtx ] = fUnpackPar->GetModuleId( iGbtx );
}
UInt_t uNrOfChannels = fuNrOfGet4 * fuNrOfChannelsPerGet4;
LOG(info) << "Nr. of possible Tof channels: " << uNrOfChannels;
// CbmTofDetectorId* fTofId = new CbmTofDetectorId_v14a();
fviRpcChUId.resize(uNrOfChannels);
UInt_t iCh= 0;
for(UInt_t iGbtx= 0; iGbtx < uNrOfGbtx; iGbtx++) {
switch(fviRpcType[iGbtx]) {
case 0: // CBM modules
if(fviRpcSide[iGbtx]<2){ // mTof modules
const Int_t RpcMap[5]={4,2,0,3,1};
for(Int_t iRpc= 0; iRpc < fviNrOfRpc[iGbtx]; iRpc++) {
Int_t iStrMax=32;
Int_t iChNext=1;
for(Int_t iStr= 0; iStr < iStrMax; iStr++) {
Int_t iStrMap = iStr;
Int_t iRpcMap = RpcMap[iRpc];
if( fviRpcSide[iGbtx] == 0) iStrMap=31-iStr;
if(fviModuleId[iGbtx] > -1)
fviRpcChUId[iCh]=CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
iRpcMap,iStrMap,
fviRpcSide[iGbtx],
fviRpcType[iGbtx]);
else
fviRpcChUId[iCh]=0;
// LOG(debug)<<Form("Map Ch %d to Address 0x%08x",iCh,fviRpcChUId[iCh]);
iCh += iChNext;
}
}
}
break;
case 1: // STAR eTOF modules
if(fviRpcSide[iGbtx]<2){ // mTof modules
const Int_t RpcMap[3]={0,1,2};
for(Int_t iRpc= 0; iRpc < fviNrOfRpc[iGbtx]; iRpc++) {
Int_t iStrMax=32;
Int_t iChNext=1;
for(Int_t iStr= 0; iStr < iStrMax; iStr++) {
Int_t iStrMap = iStr;
Int_t iRpcMap = RpcMap[iRpc];
if( fviRpcSide[iGbtx] == 0) iStrMap=31-iStr;
if(fviModuleId[iGbtx] > -1)
fviRpcChUId[iCh]=CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
iRpcMap,iStrMap,
fviRpcSide[iGbtx],
fviRpcType[iGbtx]);
else
fviRpcChUId[iCh]=0;
// LOG(DEBUG)<<Form("Map Ch %d to Address 0x%08x",iCh,fviRpcChUId[iCh]);
iCh += iChNext;
}
}
}
iCh += 64;
break;
case 5: // Diamond
{
LOG(info) << " Map diamond at GBTX - iCh = " << iCh;
for( UInt_t uFee = 0; uFee < fUnpackPar->GetNrOfFeePerGbtx(); ++uFee )
{
for( UInt_t uCh = 0; uCh < fUnpackPar->GetNrOfChannelsPerFee(); ++uCh )
{
if( uFee < 4 && ( 0 == uCh%4 || uCh<4 )) {
// if( 0 == uCh ) {
fviRpcChUId[ iCh ] = CbmTofAddress::GetUniqueAddress(
fviModuleId[iGbtx],
0, uFee*fUnpackPar->GetNrOfChannelsPerFee()/4 + uCh/4 + 40 * fviRpcSide[iGbtx],
// 0, uFee + 10 * fviRpcSide[iGbtx],
0, fviRpcType[iGbtx] );
LOG(info) << Form( "Map T0 Ch %d to Address 0x%08x", iCh, fviRpcChUId[iCh] );
}
else fviRpcChUId[ iCh ] = 0;
iCh++;
} // for( UInt_t uCh = 0; uCh < fUnpackPar->GetNrOfChannelsPerFee(); ++uCh )
} // for( UInt_t uFee = 0; uFee < fUnpackPar->GetNrOfFeePerGbtx(); ++uFee )
}
break;
case 78: // cern-20-gap + ceramic module
{
LOG(info) << " Map CERN 20 gap at GBTX - iCh = " << iCh;
const Int_t StrMap[32]={0,1,2,3,4,31,5,6,7,30,8,9,10,29,11,12,13,14,28,15,16,17,18,27,26,25,24,23,22,21,20,19};
Int_t iModuleId = 0;
Int_t iModuleType=7;
Int_t iRpcMap = 0;
for(Int_t iFeet= 0; iFeet <2; iFeet++){
for(Int_t iStr= 0; iStr < 32; iStr++) {
Int_t iStrMap = 31-12-StrMap[iStr];
Int_t iSideMap = iFeet;
if (iStrMap < 20 )
fviRpcChUId[iCh]=CbmTofAddress::GetUniqueAddress(iModuleId,
iRpcMap,iStrMap,
iSideMap,
iModuleType);
else
fviRpcChUId[iCh]=0;
iCh++;
}
}
}
// fall through is intended
case 8: // ceramics
{
Int_t iModuleId=0;
Int_t iModuleType=8;
for(Int_t iRpc= 0; iRpc < 8; iRpc++) {
fviRpcChUId[iCh]=CbmTofAddress::GetUniqueAddress(iModuleId,
7-iRpc,0,0,
iModuleType);
iCh++;
}
iCh += (24 + 2*32);
}
LOG(info) << " Map end ceramics box at GBTX - iCh = " << iCh;
break;
case 9: // Star2 boxes
{
LOG(info) << " Map Star2 box at GBTX - iCh = " << iCh;
const Int_t iRpc[5] ={1,-1,1,0,0};
const Int_t iSide[5]={1,-1,0,1,0};
for(Int_t iFeet= 0; iFeet <5; iFeet++){
for(Int_t iStr= 0; iStr < 32; iStr++) {
Int_t iStrMap = iStr;
Int_t iRpcMap = iRpc[iFeet];
Int_t iSideMap = iSide[iFeet];
if(iSideMap == 0) iStrMap=31-iStr;
if( iSideMap > -1)
fviRpcChUId[iCh]=CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
iRpcMap,iStrMap,
iSideMap,
fviRpcType[iGbtx]);
else
fviRpcChUId[iCh]=0;
iCh++;
}
}
}
break;
case 6: // Buc box
{
LOG(info) << " Map Buc box at GBTX - iCh = " << iCh;
const Int_t iRpc[5] ={0,-1,0,1,1};
const Int_t iSide[5]={1,-1,0,1,0};
for(Int_t iFeet= 0; iFeet <5; iFeet++){
for(Int_t iStr= 0; iStr < 32; iStr++) {
Int_t iStrMap = iStr;
Int_t iRpcMap = iRpc[iFeet];
Int_t iSideMap = iSide[iFeet];
//if(iSideMap == 0)iStrMap=31-iStr;
switch (fviRpcSide[iGbtx]) {
case 0:
;
break;
case 1: // HD cosmic 2019, Buc2018, v18n
iStrMap=31-iStr;
iRpcMap=1-iRpcMap;
break;
case 2: // v18m_cosmicHD
// iStrMap=31-iStr;
iSideMap=1-iSideMap;
break;
case 3:
iStrMap=31-iStr;
iRpcMap=1-iRpcMap;
iSideMap=1-iSideMap;
break;
case 4: // HD cosmic 2019, Buc2018, v18o
iRpcMap=1-iRpcMap;
break;
default:
;
}
if( iSideMap > -1)
fviRpcChUId[iCh]=CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
iRpcMap,iStrMap,
iSideMap,
fviRpcType[iGbtx]);
else
fviRpcChUId[iCh]=0;
iCh++;
}
}
}
break;
case -1:
LOG(info) << " Found unused GBTX link at iCh = " << iCh;
iCh+=160;
break;
default:
LOG(error) << "Invalid Type specifier for Gbtx " << iGbtx << ": "<< fviRpcType[iGbtx];
}
}
for( UInt_t i = 0; i < uNrOfChannels; i=i+8)
{
if (i % 64 == 0)
LOG(info) << " Index "<< i;
LOG(info) << Form("0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x",
fviRpcChUId[i], fviRpcChUId[i+1], fviRpcChUId[i+2], fviRpcChUId[i+3], fviRpcChUId[i+4],fviRpcChUId[i+5],fviRpcChUId[i+6], fviRpcChUId[i+7] );
} // for( UInt_t i = 0; i < uNrOfChannels; ++i)
UInt_t uNrOfChannels = fuNrOfGet4 * fuNrOfChannelsPerGet4;
LOG(info) << "Nr. of possible Tof channels: " << uNrOfChannels;
// CbmTofDetectorId* fTofId = new CbmTofDetectorId_v14a();
fviRpcChUId.resize(uNrOfChannels);
UInt_t iCh = 0;
for (UInt_t iGbtx = 0; iGbtx < uNrOfGbtx; iGbtx++) {
Int_t iModuleIdMap = fviModuleId[iGbtx];
switch (fviRpcType[iGbtx]) {
case 0: // CBM modules
if (fviRpcSide[iGbtx] < 2) { // mTof modules
const Int_t RpcMap[5] = {4, 2, 0, 3, 1};
for (Int_t iRpc = 0; iRpc < fviNrOfRpc[iGbtx]; iRpc++) {
Int_t iStrMax = 32;
Int_t iChNext = 1;
for (Int_t iStr = 0; iStr < iStrMax; iStr++) {
Int_t iStrMap = iStr;
Int_t iRpcMap = RpcMap[iRpc];
if (fviRpcSide[iGbtx] == 0) iStrMap = 31 - iStr;
if (fviModuleId[iGbtx] > -1)
fviRpcChUId[iCh] = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpcMap, iStrMap,
fviRpcSide[iGbtx], fviRpcType[iGbtx]);
else
fviRpcChUId[iCh] = 0;
// LOG(debug)<<Form("Map Ch %d to Address 0x%08x",iCh,fviRpcChUId[iCh]);
iCh += iChNext;
}
}
}
break;
case 1: // STAR eTOF modules
if (fviRpcSide[iGbtx] < 2) { // mTof modules
const Int_t RpcMap[3] = {0, 1, 2};
for (Int_t iRpc = 0; iRpc < fviNrOfRpc[iGbtx]; iRpc++) {
Int_t iStrMax = 32;
Int_t iChNext = 1;
for (Int_t iStr = 0; iStr < iStrMax; iStr++) {
Int_t iStrMap = iStr;
Int_t iRpcMap = RpcMap[iRpc];
if (fviRpcSide[iGbtx] == 0) iStrMap = 31 - iStr;
if (fviModuleId[iGbtx] > -1)
fviRpcChUId[iCh] = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpcMap, iStrMap,
fviRpcSide[iGbtx], fviRpcType[iGbtx]);
else
fviRpcChUId[iCh] = 0;
// LOG(debug)<<Form("Map Ch %d to Address 0x%08x",iCh,fviRpcChUId[iCh]);
iCh += iChNext;
}
}
}
iCh += 64;
break;
case 5: // Diamond
{
LOG(info) << " Map diamond at GBTX - iCh = " << iCh;
for (UInt_t uFee = 0; uFee < fUnpackPar->GetNrOfFeePerGbtx(); ++uFee) {
for (UInt_t uCh = 0; uCh < fUnpackPar->GetNrOfChannelsPerFee(); ++uCh) {
if (uFee < 4 && (0 == uCh % 4 || uCh < 4)) {
// if( 0 == uCh ) {
fviRpcChUId[iCh] = CbmTofAddress::GetUniqueAddress(
fviModuleId[iGbtx], 0,
uFee * fUnpackPar->GetNrOfChannelsPerFee() / 4 + uCh / 4 + 40 * fviRpcSide[iGbtx],
// 0, uFee + 10 * fviRpcSide[iGbtx],
0, fviRpcType[iGbtx]);
LOG(info) << Form("Map Bmon Ch %d to Address 0x%08x", iCh, fviRpcChUId[iCh]);
}
else
fviRpcChUId[iCh] = 0;
iCh++;
} // for( UInt_t uCh = 0; uCh < fUnpackPar->GetNrOfChannelsPerFee(); ++uCh )
} // for( UInt_t uFee = 0; uFee < fUnpackPar->GetNrOfFeePerGbtx(); ++uFee )
} break;
case 78: // cern-20-gap + ceramic module
{
LOG(info) << " Map CERN 20 gap at GBTX - iCh = " << iCh;
// clang-format off
const Int_t StrMap[32] = {0, 1, 2, 3, 4, 31, 5, 6, 7, 30, 8,
9, 10, 29, 11, 12, 13, 14, 28, 15, 16, 17,
18, 27, 26, 25, 24, 23, 22, 21, 20, 19};
// clang-format on
Int_t iModuleId = 0;
Int_t iModuleType = 7;
Int_t iRpcMap = 0;
for (Int_t iFeet = 0; iFeet < 2; iFeet++) {
for (Int_t iStr = 0; iStr < 32; iStr++) {
Int_t iStrMap = 31 - 12 - StrMap[iStr];
Int_t iSideMap = iFeet;
if (iStrMap < 20)
fviRpcChUId[iCh] = CbmTofAddress::GetUniqueAddress(iModuleId, iRpcMap, iStrMap, iSideMap, iModuleType);
else
fviRpcChUId[iCh] = 0;
iCh++;
}
}
}
[[fallthrough]]; // fall through is intended
case 8: // ceramics
{
Int_t iModuleId = 0;
Int_t iModuleType = 8;
for (Int_t iRpc = 0; iRpc < 8; iRpc++) {
fviRpcChUId[iCh] = CbmTofAddress::GetUniqueAddress(iModuleId, 7 - iRpc, 0, 0, iModuleType);
iCh++;
}
iCh += (24 + 2 * 32);
}
LOG(info) << " Map end ceramics box at GBTX - iCh = " << iCh;
break;
case 4:
case 9: // Star2 boxes
{
LOG(info) << " Map Star2 box at GBTX - iCh = " << iCh;
const Int_t iRpc[5] = {1, -1, 1, 0, 0};
const Int_t iSide[5] = {1, -1, 0, 1, 0};
for (Int_t iFeet = 0; iFeet < 5; iFeet++) {
for (Int_t iStr = 0; iStr < 32; iStr++) {
Int_t iStrMap = iStr;
Int_t iRpcMap = iRpc[iFeet];
Int_t iSideMap = iSide[iFeet];
if (iSideMap == 0) iStrMap = 31 - iStr;
switch (fviRpcSide[iGbtx]) {
case 0:; break;
case 1:; break;
case 2:
switch (iFeet) {
case 1:
iRpcMap = iRpc[4];
iSideMap = iSide[4];
break;
case 4:
iRpcMap = iRpc[1];
iSideMap = iSide[1];
break;
default:;
}
break;
}
if (iSideMap > -1)
fviRpcChUId[iCh] =
CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpcMap, iStrMap, iSideMap, fviRpcType[iGbtx]);
else
fviRpcChUId[iCh] = 0;
iCh++;
}
}
} break;
case 6: // Buc box
{
LOG(info) << " DevMap Buc box at GBTX - iCh = " << iCh;
const Int_t iRpc[5] = {0, -1, 0, 1, 1};
const Int_t iSide[5] = {1, -1, 0, 1, 0};
for (Int_t iFeet = 0; iFeet < 5; iFeet++) {
for (Int_t iStr = 0; iStr < 32; iStr++) {
Int_t iStrMap = iStr;
Int_t iRpcMap = iRpc[iFeet];
Int_t iSideMap = iSide[iFeet];
//if(iSideMap == 0)iStrMap=31-iStr;
switch (fviRpcSide[iGbtx]) {
case 0:; break;
case 1: // HD cosmic 2019, Buc2018, v18n
iStrMap = 31 - iStr;
iRpcMap = 1 - iRpcMap;
break;
case 2: // v18m_cosmicHD
// iStrMap=31-iStr;
iSideMap = 1 - iSideMap;
break;
case 3:
iStrMap = 31 - iStr;
iRpcMap = 1 - iRpcMap;
iSideMap = 1 - iSideMap;
break;
case 4: // HD cosmic 2019, Buc2018, v18o
iRpcMap = 1 - iRpcMap;
break;
case 5: // HD cosmic 2020, Buc2018, v20a
iStrMap = 31 - iStr;
break;
case 6: //BUC special
{
switch (fviModuleId[iGbtx]) {
case 0: iRpcMap = 0; break;
case 1: iRpcMap = 1; break;
}
if (iFeet > 2) iModuleIdMap = 1;
} break;
case 7: {
// clang-format off
const Int_t iChMap[160]={
127, 126, 125, 124, 12, 13, 14, 15, 7, 6, 5, 4, 28, 29, 30, 31, 123, 122, 121, 120, 8, 9, 10, 11, 107, 106, 105, 104, 108, 109, 110, 111,
39, 38, 37, 36, 52, 53, 54, 55, 63, 62, 61, 60, 128, 129, 130, 131, 43, 42, 41, 40, 148, 149, 150, 151, 59, 58, 57, 56, 132, 133, 134, 135,
139, 138, 137, 136, 140, 141, 142, 143, 99, 98, 97, 96, 64, 65, 66, 67, 103, 102, 101, 100, 84, 85, 86, 87, 155, 154, 153, 152, 68, 69, 70, 71,
159, 158, 157, 156, 144, 145, 146, 147, 47, 46, 45, 44, 76, 77, 78, 79, 51, 50, 49, 48, 20, 21, 22, 23, 35, 34, 33, 32, 116, 117, 118, 119,
75, 74, 73, 72, 92, 93, 94, 95, 19, 18, 17, 16, 80, 81, 82, 83, 115, 114, 113, 112, 24, 25, 26, 27, 91, 90, 89, 88, 0, 1, 2, 3
};
// clang-format on
Int_t iInd = iFeet * 32 + iStr;
Int_t i = 0;
for (; i < 160; i++)
if (iInd == iChMap[i]) break;
iStrMap = i % 32;
Int_t iFeetInd = (i - iStrMap) / 32;
switch (iFeet) {
case 0:
iRpcMap = 0;
iSideMap = 1;
break;
case 1:
iRpcMap = 1;
iSideMap = 1;
break;
case 2:
iRpcMap = 1;
iSideMap = 0;
break;
case 3:
iRpcMap = 0;
iSideMap = 0;
break;
case 4: iSideMap = -1; break;
}
iModuleIdMap = fviModuleId[iGbtx];
LOG(info) << "Buc of GBTX " << iGbtx
<< Form(", Feet %1d, Str %2d, i %3d, FeetInd %1d, Rpc %1d, Side %1d, Str %2d ", iFeet, iStr,
i, iFeetInd, iRpcMap, iSideMap, iStrMap);
} break;
default:;
}
if (iSideMap > -1)
fviRpcChUId[iCh] =
CbmTofAddress::GetUniqueAddress(iModuleIdMap, iRpcMap, iStrMap, iSideMap, fviRpcType[iGbtx]);
else
fviRpcChUId[iCh] = 0;
iCh++;
}
}
} break;
case -1:
LOG(info) << " Found unused GBTX link at iCh = " << iCh;
iCh += 160;
break;
default: LOG(error) << "Invalid Type specifier for Gbtx " << iGbtx << ": " << fviRpcType[iGbtx];
}
}
for (UInt_t i = 0; i < uNrOfChannels; i = i + 8) {
if (i % 64 == 0) LOG(info) << " Index " << i;
LOG(info) << Form("0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x", fviRpcChUId[i], fviRpcChUId[i + 1],
fviRpcChUId[i + 2], fviRpcChUId[i + 3], fviRpcChUId[i + 4], fviRpcChUId[i + 5],
fviRpcChUId[i + 6], fviRpcChUId[i + 7]);
} // for( UInt_t i = 0; i < uNrOfChannels; ++i)
return kTRUE;
}
void CbmDeviceUnpackTofMcbm2018::CreateHistograms()
{
LOG(info) << "create Histos for " << fuNrOfGdpbs <<" gDPBs ";
LOG(info) << "create Histos for " << fuNrOfGdpbs << " gDPBs ";
fhRawTDigEvT0 = new TH1F( Form("Raw_TDig-EvT0"),
Form("Raw digi time difference to 1st digi ; time [ns]; cts"),
500, 0, 100.);
// fHM->Add( Form("Raw_TDig-EvT0"), fhRawTDigEvT0);
fhRawTDigEvBmon =
new TH1F(Form("Raw_TDig-EvBmon"), Form("Raw digi time difference to 1st digi ; time [ns]; cts"), 500, 0, 100.);
// fHM->Add( Form("Raw_TDig-EvBmon"), fhRawTDigEvBmon);
fhRawTDigRef0 = new TH1F( Form("Raw_TDig-Ref0"),
Form("Raw digi time difference to Ref ; time [ns]; cts"),
6000, -10000, 50000);
fhRawTDigRef0 =
new TH1F(Form("Raw_TDig-Ref0"), Form("Raw digi time difference to Ref ; time [ns]; cts"), 6000, -10000, 50000);
// fHM->Add( Form("Raw_TDig-Ref0"), fhRawTDigRef0);
fhRawTDigRef = new TH1F( Form("Raw_TDig-Ref"),
Form("Raw digi time difference to Ref ; time [ns]; cts"),
6000, -1000, 5000);
fhRawTDigRef =
new TH1F(Form("Raw_TDig-Ref"), Form("Raw digi time difference to Ref ; time [ns]; cts"), 6000, -1000, 5000);
// fHM->Add( Form("Raw_TDig-Ref"), fhRawTDigRef);
fhRawTRefDig0 = new TH1F( Form("Raw_TRef-Dig0"),
Form("Raw Ref time difference to last digi ; time [ns]; cts"),
9999, -50000, 50000);
fhRawTRefDig0 = new TH1F(Form("Raw_TRef-Dig0"), Form("Raw Ref time difference to last digi ; time [ns]; cts"), 9999,
-50000, 50000);
// fHM->Add( Form("Raw_TRef-Dig0"), fhRawTRefDig0);
fhRawTRefDig1 = new TH1F( Form("Raw_TRef-Dig1"),
Form("Raw Ref time difference to last digi ; time [ns]; cts"),
9999, -5000, 5000);
fhRawTRefDig1 =
new TH1F(Form("Raw_TRef-Dig1"), Form("Raw Ref time difference to last digi ; time [ns]; cts"), 9999, -5000, 5000);
// fHM->Add( Form("Raw_TRef-Dig1"), fhRawTRefDig1);
fhRawDigiLastDigi = new TH1F( Form("Raw_Digi-LastDigi"),
Form("Raw Digi time difference to last digi ; time [ns]; cts"),
9999, -5000, 5000);
fhRawDigiLastDigi = new TH1F(Form("Raw_Digi-LastDigi"),
Form("Raw Digi time difference to last digi ; time [ns]; cts"), 9999, -5000, 5000);
// 9999, -5000000, 5000000);
// fHM->Add( Form("Raw_Digi-LastDigi"), fhRawDigiLastDigi);
fhRawTotCh.resize( fuNrOfGdpbs );
fhChCount.resize( fuNrOfGdpbs );
fhChanCoinc.resize( fuNrOfGdpbs * fuNrOfFeePerGdpb / 2 );
for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++)
{
fhRawTotCh[ uGdpb ] = new TH2F( Form("Raw_Tot_gDPB_%02u", uGdpb),
Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb,
256, 0., 256. );
// fHM->Add( Form("Raw_Tot_gDPB_%02u", uGdpb), fhRawTotCh[ uGdpb ]);
fhChCount[ uGdpb ] = new TH1I( Form("ChCount_gDPB_%02u", uGdpb),
Form("Channel counts gDPB %02u; channel; Hits", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb );
// fHM->Add( Form("ChCount_gDPB_%02u", uGdpb), fhChCount[ uGdpb ]);
/*
fhRawTotCh.resize(fuNrOfGdpbs);
fhChCount.resize(fuNrOfGdpbs);
fhChanCoinc.resize(fuNrOfGdpbs * fuNrOfFeePerGdpb / 2);
for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb++) {
fhRawTotCh[uGdpb] = new TH2F(Form("Raw_Tot_gDPB_%02u", uGdpb), Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb, 256, 0., 256.);
// fHM->Add( Form("Raw_Tot_gDPB_%02u", uGdpb), fhRawTotCh[ uGdpb ]);
fhChCount[uGdpb] =
new TH1I(Form("ChCount_gDPB_%02u", uGdpb), Form("Channel counts gDPB %02u; channel; Hits", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb);
// fHM->Add( Form("ChCount_gDPB_%02u", uGdpb), fhChCount[ uGdpb ]);
/*
for( UInt_t uLeftFeb = uGdpb*fuNrOfFebsPerGdpb / 2;
uLeftFeb < (uGdpb + 1 )*fuNrOfFebsPerGdpb / 2;
++uLeftFeb )
......@@ -823,114 +761,106 @@ void CbmDeviceUnpackTofMcbm2018::CreateHistograms()
fuNrOfChannelsPerFee, 0., fuNrOfChannelsPerFee );
} // for( UInt_t uLeftFeb = 0; uLeftFeb < fuNrOfFebsPerGdpb / 2; uLeftFeb ++ )
*/
fhChanCoinc[ uGdpb ] = new TH2F( Form("fhChanCoinc_%02u", uGdpb),
Form("Channels Coincidence %02u; Left; Right", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb,
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb );
} // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++)
fhDetChanCoinc = new TH2F( "fhDetChanCoinc",
"Det Channels Coincidence; Left; Right",
32, 0., 32,
32, 0., 32 );
fhChanCoinc[uGdpb] =
new TH2F(Form("fhChanCoinc_%02u", uGdpb), Form("Channels Coincidence %02u; Left; Right", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb, fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb);
} // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++)
fhDetChanCoinc = new TH2F("fhDetChanCoinc", "Det Channels Coincidence; Left; Right", 32, 0., 32, 32, 0., 32);
}
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
bool CbmDeviceUnpackTofMcbm2018::HandleData(FairMQMessagePtr& msg, int /*index*/)
{
// Don't do anything with the data
// Maybe add an message counter which counts the incomming messages and add
// an output
// Don't do anything with the data
// Maybe add an message counter which counts the incomming messages and add
// an output
fNumMessages++;
LOG(debug) << "Received message number "<< fNumMessages
<< " with size " << msg->GetSize();
LOG(debug) << "Received message number " << fNumMessages << " with size " << msg->GetSize();
std::string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
fles::StorableTimeslice component{0};
fles::StorableTimeslice component {0};
inputArchive >> component;
CheckTimeslice(component);
// CheckTimeslice(component);
DoUnpack(component, 0);
BuildTint(0);
if(fNumMessages%10000 == 0) LOG(info)<<"Processed "<<fNumMessages<<" time slices";
if (fNumMessages % 10000 == 0) LOG(info) << "Processed " << fNumMessages << " time slices";
return true;
}
bool CbmDeviceUnpackTofMcbm2018::HandleParts(FairMQParts& parts, int /*index*/)
{
// Don't do anything with the data
// Maybe add an message counter which counts the incomming messages and add
// an output
// Don't do anything with the data
// Maybe add an message counter which counts the incomming messages and add
// an output
fNumMessages++;
LOG(debug) << "Received message number "<< fNumMessages
<< " with " << parts.Size() << " parts" ;
fles::StorableTimeslice ts{0};
switch(fiSelectComponents) {
case 0: {
std::string msgStr(static_cast<char*>(parts.At(0)->GetData()),(parts.At(0))->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
inputArchive >> ts;
CheckTimeslice(ts);
if( 1 == fNumMessages ) {
LOG(info) << "Initialize TS components list to " << ts.num_components();
for (size_t c {0}; c < ts.num_components(); c++) {
auto systemID = static_cast<int>(ts.descriptor(c, 0).sys_id);
LOG(info) << "Found systemID: " << std::hex << systemID << std::dec;
fUnpackerAlgo->AddMsComponentToList( c, systemID ); // TOF data
}
}
DoUnpack(ts, 0);
}
break;
case 1: {
fles::StorableTimeslice component{0};
LOG(debug) << "Received message number " << fNumMessages << " with " << parts.Size() << " parts";
fles::StorableTimeslice ts {0};
uint ncomp=parts.Size();
for (uint i=0; i<ncomp; i++) {
std::string msgStr(static_cast<char*>(parts.At(i)->GetData()),(parts.At(i))->GetSize());
switch (fiSelectComponents) {
case 0: {
std::string msgStr(static_cast<char*>(parts.At(0)->GetData()), (parts.At(0))->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
//fles::StorableTimeslice component{i};
inputArchive >> component;
CheckTimeslice(component);
fUnpackerAlgo->AddMsComponentToList( 0, 0x60 ); // TOF data
LOG(debug) << "HandleParts message " << fNumMessages << " with indx " << component.index();
DoUnpack(component, 0);
}
}
break;
default:
;
inputArchive >> ts;
//CheckTimeslice(ts);
if (1 == fNumMessages) {
LOG(info) << "Initialize TS components list to " << ts.num_components();
for (size_t c {0}; c < ts.num_components(); c++) {
auto systemID = static_cast<int>(ts.descriptor(c, 0).sys_id);
LOG(info) << "Found systemID: " << std::hex << systemID << std::dec;
fUnpackerAlgo->AddMsComponentToList(c, systemID); // TOF data
}
}
DoUnpack(ts, 0);
} break;
case 1: {
fles::StorableTimeslice component {0};
uint ncomp = parts.Size();
for (uint i = 0; i < ncomp; i++) {
std::string msgStr(static_cast<char*>(parts.At(i)->GetData()), (parts.At(i))->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
//fles::StorableTimeslice component{i};
inputArchive >> component;
// CheckTimeslice(component);
fUnpackerAlgo->AddMsComponentToList(0, 0x60); // TOF data
LOG(debug) << "HandleParts message " << fNumMessages << " with indx " << component.index();
DoUnpack(component, 0);
}
} break;
default:;
}
BuildTint(0);
if(fNumMessages%10000 == 0) LOG(info)<<"Processed "<<fNumMessages<<" time slices";
if (fNumMessages % 10000 == 0) LOG(info) << "Processed " << fNumMessages << " time slices";
return true;
}
bool CbmDeviceUnpackTofMcbm2018::HandleMessage(FairMQMessagePtr& msg, int /*index*/)
{
const char *cmd = (char *)(msg->GetData());
const char cmda[4]={*cmd};
LOG(info) << "Handle message " << cmd <<", " << cmd[0];
const char* cmd = (char*) (msg->GetData());
const char cmda[4] = {*cmd};
LOG(info) << "Handle message " << cmd << ", " << cmd[0];
cbm::mq::LogState(this);
// only one implemented so far "Stop"
if( strcmp(cmda,"STOP") ) {
if (strcmp(cmda, "STOP")) {
LOG(info) << "STOP";
fUnpackerAlgo->Finish();
cbm::mq::ChangeState(this, cbm::mq::Transition::Ready);
cbm::mq::LogState(this);
cbm::mq::ChangeState(this, cbm::mq::Transition::DeviceReady);
......@@ -945,20 +875,18 @@ bool CbmDeviceUnpackTofMcbm2018::HandleMessage(FairMQMessagePtr& msg, int /*inde
Bool_t CbmDeviceUnpackTofMcbm2018::DoUnpack(const fles::Timeslice& ts, size_t component)
{
LOG(debug) << "Timeslice " << ts.index() << " contains " << ts.num_microslices(component)
<< " microslices of component " << component;
if( kFALSE == fUnpackerAlgo->ProcessTs( ts ) )
{
LOG(error) << "Failed processing TS " << ts.index()
<< " in unpacker algorithm class";
return kTRUE;
} // if( kFALSE == fUnpackerAlgo->ProcessTs( ts ) )
/// Copy the digis in the DaqBuffer
std::vector< CbmTofDigi > vDigi = fUnpackerAlgo->GetVector();
/*
LOG(debug) << "Timeslice " << ts.index() << " contains " << ts.num_microslices(component)
<< " microslices of component " << component;
if (kFALSE == fUnpackerAlgo->ProcessTs(ts)) {
LOG(error) << "Failed processing TS " << ts.index() << " in unpacker algorithm class";
return kTRUE;
} // if( kFALSE == fUnpackerAlgo->ProcessTs( ts ) )
/// Copy the digis in the DaqBuffer
std::vector<CbmTofDigi> vDigi = fUnpackerAlgo->GetVector();
/*
// time sort vDigis
sort(vDigi.begin(), vDigi.end(),
[](const CbmTofDigi & a, const CbmTofDigi & b) -> bool
......@@ -967,596 +895,257 @@ Bool_t CbmDeviceUnpackTofMcbm2018::DoUnpack(const fles::Timeslice& ts, size_t co
});
*/
LOG(debug) << "Insert " << vDigi.size() << " digis into DAQ buffer with size " << fBuffer->GetSize();
for( auto digi: vDigi) {
// copy Digi for insertion into DAQ buffer
fDigi = new CbmTofDigi(digi);
LOG(debug) << "BufferInsert digi " << Form("0x%08x at %012.2f",fDigi->GetAddress(),fDigi->GetTime())
<< Form(", first %012.2f, last %012.2f, size %u",fBuffer->GetTimeFirst(),fBuffer->GetTimeLast(),fBuffer->GetSize());
fBuffer->InsertData<CbmTofDigi>(fDigi);
}
vDigi.clear();
fUnpackerAlgo->ClearVector();
return kTRUE;
}
static Int_t iErrorMess=0;
static Int_t iWarnMess=0;
void CbmDeviceUnpackTofMcbm2018::FillHitInfo( gdpbv100::Message mess )
{
UInt_t uChannel = mess.getGdpbHitChanId(); // Get4 channel nr
UInt_t uTot = mess.getGdpbHit32Tot();
// UInt_t uFts = mess.getGdpbHitFineTs();
ULong_t ulCurEpochGdpbGet4 = fvulCurrentEpoch[ fuGet4Nr ];
// In Ep. Suppr. Mode, receive following epoch instead of previous
if( 0 < ulCurEpochGdpbGet4 )
ulCurEpochGdpbGet4 --;
else ulCurEpochGdpbGet4 = gdpbv100::kuEpochCounterSz; // Catch epoch cycle!
UInt_t uChannelNr = fuGet4Id * fuNrOfChannelsPerGet4 + uChannel;
UInt_t uChannelNrInFee = (fuGet4Id % fuNrOfGet4PerFee) * fuNrOfChannelsPerGet4 + uChannel;
UInt_t uFeeNr = (fuGet4Id / fuNrOfGet4PerFee);
UInt_t uFeeNrInSys = fuGdpbNr * fuNrOfFeePerGdpb + uFeeNr;
UInt_t uGbtxNr = (uFeeNr / kuNbFeePerGbtx);
// UInt_t uFeeInGbtx = (uFeeNr % kuNbFeePerGbtx);
UInt_t uGbtxNrInSys = fuGdpbNr * kuNbGbtxPerGdpb + uGbtxNr;
UInt_t uRemappedChannelNr = fuGdpbNr * fuNrOfChannelsPerGdpb
+ uFeeNr * fuNrOfChannelsPerFee + fvuGet4ToPadi[ uChannelNrInFee ];
/// Diamond FEE have straight connection from Get4 to eLink and from PADI to GET4
if( fviRpcType[uGbtxNrInSys]==5 ) {
uRemappedChannelNr = fuGdpbNr * fuNrOfChannelsPerGdpb + uChannelNr;
}
/*
UInt_t uRemappedChannelNr = fuGdpbNr * fuNrOfChannelsPerGdpb +
+ ( fviRpcType[uGbtxNrInSys]==5 ? uChannelNr // Diamond
: uFeeNr * fuNrOfChannelsPerFee +fvuGet4ToPadi[ uChannelNrInFee ] );
*/
// + ( fviRpcType[uGbtxNrInSys]==5 ? uChannelNrInFee : fvuGet4ToPadi[ uChannelNrInFee ] );
// UInt_t uRemappedChannelNr = uFeeNr * fuNrOfChannelsPerFee + uChannelNrInFee;
/*
if( fuGdpbNr==2)
LOG(info)<<" Fill Hit GdpbNr" << fuGdpbNr
<<", ChNr "<<uChannelNr<<", CIF "<< uChannelNrInFee
<<", FNr "<<uFeeNr<<", FIS "<<uFeeNrInSys
<<", GbtxNr "<<uGbtxNr
<<", Remap "<<uRemappedChannelNr;
*/
// ULong_t ulHitTime = mess.getMsgFullTime(ulCurEpochGdpbGet4);
Double_t dHitTime = mess.getMsgFullTimeD(ulCurEpochGdpbGet4);
// uFts = mess.getGdpbHitFullTs() % 112;
if( kTRUE == fvbFirstEpochSeen[ fuGet4Nr ] )
{
Double_t dHitTot = uTot; // in bins
//if( fUnpackPar->GetNumberOfChannels() < uRemappedChannelNr )
if( fviRpcChUId.size() < uRemappedChannelNr )
{
if(iErrorMess++ < 10000)
{
LOG(error) << "Invalid mapping index " << uRemappedChannelNr
<< " vs " << fviRpcChUId.size()
<< ", from GdpbNr " << fuGdpbNr
<< ", Get4 " << fuGet4Id
<< ", Ch " << uChannel
<< ", ChNr " << uChannelNr
<< ", ChNrIF " << uChannelNrInFee
<< ", FiS " << uFeeNrInSys
;
return;
} else
LOG(error) << "Max number of error messages reached "
;
} // if( fUnpackPar->GetNumberOfChannels() < uChanUId )
fvbChanThere[ uRemappedChannelNr ] = kTRUE;
// UInt_t uChanUId = fUnpackPar->GetChannelToDetUIdMap( uRemappedChannelNr );
UInt_t uChanUId = fviRpcChUId[ uRemappedChannelNr ];
if( 0 == uChanUId ) {
if(iWarnMess++ < 1000)
{
LOG(warn) << "Invalid ChanUId for " << uRemappedChannelNr
<< ", ChOff " << fuGdpbNr * fuNrOfChannelsPerGdpb + uFeeNr * fuNrOfChannelsPerFee
<< ", ChIF " << ( fviRpcType[uGbtxNrInSys]==5 ? uChannelNrInFee : fvuGet4ToPadi[ uChannelNrInFee ] )
<< ", GdpbNr " << fuGdpbNr
<< ", GbtxNr " << uGbtxNrInSys
<< ", Get4 " << fuGet4Id
<< ", Ch " << uChannel
<< ", ChNr " << uChannelNr
<< ", ChNrIF " << uChannelNrInFee
<< ", FiS " << uFeeNrInSys
;
} else {
if(iWarnMess==1000)
LOG(warn) << "No more messages. Fix your mapping problem!";
//FairMQStateMachine::ChangeState(PAUSE);
}
return; // Hit not mapped to digi
}
if( (uChanUId & DetMask) == 0x00005006 ) dHitTime += fdTShiftRef;
fdLastDigiTime = dHitTime;
LOG(debug) << Form("Insert 0x%08x digi with time ", uChanUId ) << dHitTime << Form(", Tot %4.0f",dHitTot)
<< " into buffer with " << fBuffer->GetSize() << " data from "
<< Form("%11.1f to %11.1f ", fBuffer->GetTimeFirst(), fBuffer->GetTimeLast())
<< " at epoch " << ulCurEpochGdpbGet4
;
fDigi = new CbmTofDigi(uChanUId, dHitTime, dHitTot);
fBuffer->InsertData<CbmTofDigi>(fDigi);
// Histograms filling
// fhRawTotCh[ fuGdpbNr ]->Fill( uRemappedChannelNr, dHitTot);
// fhChCount[ fuGdpbNr ] ->Fill( uRemappedChannelNr );
// for debugging
if(0){
if(fuGdpbNr == 2) {
LOG(info) << Form("Insert 0x%08x digi at %d with time ", uChanUId, uRemappedChannelNr)
<< dHitTime << Form(", Tot %4.0f",dHitTot);
}
}
} // if( kTRUE == fvbFirstEpochSeen[ fuGet4Nr ] )
}
void CbmDeviceUnpackTofMcbm2018::FillEpochInfo( gdpbv100::Message mess )
{
ULong64_t ulEpochNr = mess.getGdpbEpEpochNb();
//LOG(debug) << "Get4Nr "<<fuGet4Nr<< " in epoch "<<ulEpochNr;
fvulCurrentEpoch[ fuGet4Nr ] = ulEpochNr;
if( kFALSE == fvbFirstEpochSeen[ fuGet4Nr ] )
fvbFirstEpochSeen[ fuGet4Nr ] = kTRUE;
fulCurrentEpochTime = mess.getMsgFullTime(ulEpochNr);
fNofEpochs++;
/// In Ep. Suppr. Mode, receive following epoch instead of previous
/// Re-align the epoch number of the message in case it will be used later:
/// We received the epoch after the data instead of the one before!
if( 0 < ulEpochNr )
mess.setGdpbEpEpochNb( ulEpochNr - 1 );
else mess.setGdpbEpEpochNb( gdpbv100::kuEpochCounterSz );
Int_t iBufferSize = fvmEpSupprBuffer[ fuGet4Nr ].size();
if( 0 < iBufferSize )
{
LOG(debug) << "Now processing "<<iBufferSize<<" stored messages for get4 "
<< fuGet4Nr << " with epoch number "
<< (fvulCurrentEpoch[ fuGet4Nr ] - 1);
const Int_t MaxBufferSize = 1000; // FIXME: hardwired setup parameter
if(iBufferSize < MaxBufferSize) {
/// Data are sorted between epochs, not inside => Epoch level ordering
/// Sorting at lower bin precision level
std::stable_sort( fvmEpSupprBuffer[fuGet4Nr].begin(), fvmEpSupprBuffer[fuGet4Nr].begin() );
for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ )
{
FillHitInfo( fvmEpSupprBuffer[ fuGet4Nr ][ iMsgIdx ] );
} // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ )
}
fvmEpSupprBuffer[fuGet4Nr].clear();
} // if( 0 < fvmEpSupprBuffer[fGet4Nr] )
}
void CbmDeviceUnpackTofMcbm2018::PrintSlcInfo(gdpbv100::Message /*mess*/)
{
/// Nothing to do, maybe later use it to trakc parameter changes like treshold?
/*
if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) )
LOG(info) << "GET4 Slow Control message, epoch " << static_cast<Int_t>(fCurrentEpoch[rocId][get4Id])
<< ", time " << std::setprecision(9) << std::fixed
<< Double_t(fulCurrentEpochTime) * 1.e-9 << " s "
<< " for board ID " << std::hex << std::setw(4) << rocId << std::dec
<< " +++++++ > Chip = " << std::setw(2) << mess.getGdpbGenChipId()
<< ", Chan = " << std::setw(1) << mess.getGdpbSlcChan()
<< ", Edge = " << std::setw(1) << mess.getGdpbSlcEdge()
<< ", Type = " << std::setw(1) << mess.getGdpbSlcType()
<< ", Data = " << std::hex << std::setw(6) << mess.getGdpbSlcData() << std::dec
<< ", Type = " << mess.getGdpbSlcCrc();
*/
}
void CbmDeviceUnpackTofMcbm2018::PrintGenInfo(gdpbv100::Message mess)
{
Int_t mType = mess.getMessageType();
Int_t channel = mess.getGdpbHitChanId();
uint64_t uData = mess.getData();
LOG(debug) << "Get4 MSG type " << mType << " from gdpbId " << fuGdpbId
<< ", getId " << fuGet4Id << ", (hit channel) " << channel
<< " data " << std::hex << uData
;
}
void CbmDeviceUnpackTofMcbm2018::PrintSysInfo(gdpbv100::Message mess)
{
if (fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find(fuGdpbId))
LOG(debug) << "GET4 System message, epoch "
<< static_cast<Int_t>(fvulCurrentEpoch[fuGet4Nr]) << ", time " << std::setprecision(9)
<< std::fixed << Double_t(fulCurrentEpochTime) * 1.e-9 << " s "
<< " for board ID " << std::hex << std::setw(4) << fuGdpbId
<< std::dec ;
switch( mess.getGdpbSysSubType() )
{
case gdpbv100::SYS_GET4_ERROR:
{
uint32_t uData = mess.getGdpbSysErrData();
if( gdpbv100::GET4_V2X_ERR_TOT_OVERWRT == uData
|| gdpbv100::GET4_V2X_ERR_TOT_RANGE == uData
|| gdpbv100::GET4_V2X_ERR_EVT_DISCARD == uData
|| gdpbv100::GET4_V2X_ERR_ADD_RIS_EDG == uData
|| gdpbv100::GET4_V2X_ERR_UNPAIR_FALL == uData
|| gdpbv100::GET4_V2X_ERR_SEQUENCE_ER == uData
)
LOG(debug) << " +++++++ > gDPB: " << std::hex << std::setw(4) << fuGdpbId
<< std::dec << ", Chip = " << std::setw(2)
<< mess.getGdpbGenChipId() << ", Chan = " << std::setw(1)
<< mess.getGdpbSysErrChanId() << ", Edge = "
<< std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = "
<< std::setw(1) << mess.getGdpbSysErrUnused()
<< ", Data = " << std::hex << std::setw(2) << uData
<< std::dec << " -- GET4 V1 Error Event"
;
else LOG(debug) << " +++++++ >gDPB: " << std::hex << std::setw(4) << fuGdpbId
<< std::dec << ", Chip = " << std::setw(2)
<< mess.getGdpbGenChipId() << ", Chan = " << std::setw(1)
<< mess.getGdpbSysErrChanId() << ", Edge = "
<< std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = "
<< std::setw(1) << mess.getGdpbSysErrUnused()
<< ", Data = " << std::hex << std::setw(2) << uData
<< std::dec << " -- GET4 V1 Error Event "
;
break;
} // case gdpbv100::SYSMSG_GET4_EVENT
case gdpbv100::SYS_GDPB_UNKWN:
{
LOG(debug) << "Unknown GET4 message, data: " << std::hex << std::setw(8)
<< mess.getGdpbSysUnkwData() << std::dec
<<" Full message: " << std::hex << std::setw(16)
<< mess.getData() << std::dec
;
break;
} // case gdpbv100::SYS_GDPB_UNKWN:
case gdpbv100::SYS_PATTERN:
{
LOG(debug) << "ASIC pattern for missmatch, disable or resync";
break;
} // case gdpbv100::SYS_PATTERN:
} // switch( getGdpbSysSubType() )
}
LOG(debug) << "Insert " << vDigi.size() << " digis into DAQ buffer with size " << fBuffer->GetSize();
void CbmDeviceUnpackTofMcbm2018::FillStarTrigInfo(gdpbv100::Message mess)
{
Int_t iMsgIndex = mess.getStarTrigMsgIndex();
//mess.printDataCout();
for (auto digi : vDigi) {
// copy Digi for insertion into DAQ buffer
CbmTofDigi* fDigi = new CbmTofDigi(digi);
switch( iMsgIndex )
{
case 0:
fulGdpbTsMsb = mess.getGdpbTsMsbStarA();
break;
case 1:
fulGdpbTsLsb = mess.getGdpbTsLsbStarB();
fulStarTsMsb = mess.getStarTsMsbStarB();
break;
case 2:
fulStarTsMid = mess.getStarTsMidStarC();
break;
case 3:
{
ULong64_t ulNewGdpbTsFull = ( fulGdpbTsMsb << 24 )
+ ( fulGdpbTsLsb );
ULong64_t ulNewStarTsFull = ( fulStarTsMsb << 48 )
+ ( fulStarTsMid << 8 )
+ mess.getStarTsLsbStarD();
UInt_t uNewToken = mess.getStarTokenStarD();
UInt_t uNewDaqCmd = mess.getStarDaqCmdStarD();
UInt_t uNewTrigCmd = mess.getStarTrigCmdStarD();
if( ( uNewToken == fuStarTokenLast ) && ( ulNewGdpbTsFull == fulGdpbTsFullLast ) &&
( ulNewStarTsFull == fulStarTsFullLast ) && ( uNewDaqCmd == fuStarDaqCmdLast ) &&
( uNewTrigCmd == fuStarTrigCmdLast ) )
//if( (fDigi->GetAddress() & 0x000F00F ) != fiAddrRef ) fDigi->SetTime(fDigi->GetTime()+fdToffTof); // shift all Tof Times for v14a geometries
if ((fDigi->GetAddress() & 0x000780F) != fiAddrRef)
fDigi->SetTime(fDigi->GetTime() + fdToffTof); // shift all Tof Times for V21a
{
LOG(debug) << "Possible error: identical STAR tokens found twice in a row => ignore 2nd! "
<< Form("token = %5u ", fuStarTokenLast )
<< Form("gDPB ts = %12llu ", fulGdpbTsFullLast )
<< Form("STAR ts = %12llu ", fulStarTsFullLast )
<< Form("DAQ cmd = %2u ", fuStarDaqCmdLast )
<< Form("TRG cmd = %2u ", fuStarTrigCmdLast )
;
return;
} // if exactly same message repeated
/*
if( (uNewToken != fuStarTokenLast + 1) &&
0 < fulGdpbTsFullLast && 0 < fulStarTsFullLast &&
( 4095 != fuStarTokenLast || 1 != uNewToken) )
LOG(warn) << "Possible error: STAR token did not increase by exactly 1! "
<< Form("old = %5u vs new = %5u ", fuStarTokenLast, uNewToken)
<< Form("old = %12llu vs new = %12llu ", fulGdpbTsFullLast, ulNewGdpbTsFull)
<< Form("old = %12llu vs new = %12llu ", fulStarTsFullLast, ulNewStarTsFull)
<< Form("old = %2u vs new = %2u ", fuStarDaqCmdLast, uNewDaqCmd)
<< Form("old = %2u vs new = %2u ", fuStarTrigCmdLast, uNewTrigCmd);
*/
fulGdpbTsFullLast = ulNewGdpbTsFull;
fulStarTsFullLast = ulNewStarTsFull;
fuStarTokenLast = uNewToken;
fuStarDaqCmdLast = uNewDaqCmd;
fuStarTrigCmdLast = uNewTrigCmd;
Double_t dTot = 1.;
Double_t dTime = fulGdpbTsFullLast * 6.25;
if( 0. == fdFirstDigiTimeDif && 0. != fdLastDigiTime )
{
fdFirstDigiTimeDif = dTime - fdLastDigiTime;
LOG(info) << "Reference fake digi time shift initialized to " << fdFirstDigiTimeDif
<< ", default: " << fdTShiftRef;
} // if( 0. == fdFirstDigiTimeDif && 0. != fdLastDigiTime )
// dTime -= fdFirstDigiTimeDif;
// dTime += fdTShiftRef;
LOG(debug) << "Insert fake digi with time " << dTime << ", Tot " << dTot;
fhRawTRefDig0->Fill( dTime - fdLastDigiTime);
fhRawTRefDig1->Fill( dTime - fdLastDigiTime);
fDigi = new CbmTofDigi(0x00005006, dTime, dTot); // fake start counter signal
fBuffer->InsertData<CbmTofDigi>(fDigi);
break;
} // case 3
default:
LOG(error) << "Unknown Star Trigger messageindex: " << iMsgIndex;
} // switch( iMsgIndex )
}
LOG(debug) << "BufferInsert digi " << Form("0x%08x at %012.2f", fDigi->GetAddress(), fDigi->GetTime())
<< Form(", first %012.2f, last %012.2f, size %u", fBuffer->GetTimeFirst(), fBuffer->GetTimeLast(),
fBuffer->GetSize());
void CbmDeviceUnpackTofMcbm2018::PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc)
{
LOG(info) << "Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id)
<< std::dec;
LOG(info) << "Header version: Ox" << std::hex << static_cast<int>(mdsc.hdr_ver)
<< std::dec;
LOG(info) << "Equipement ID: " << mdsc.eq_id;
LOG(info) << "Flags: " << mdsc.flags;
LOG(info) << "Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id)
<< std::dec;
LOG(info) << "Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver)
<< std::dec;
LOG(info) << "Microslice Idx: " << mdsc.idx;
LOG(info) << "Checksum: " << mdsc.crc;
LOG(info) << "Size: " << mdsc.size;
LOG(info) << "Offset: " << mdsc.offset;
}
bool CbmDeviceUnpackTofMcbm2018::CheckTimeslice(const fles::Timeslice& ts)
{
if ( 0 == ts.num_components() ) {
LOG(error) << "No Component in TS " << ts.index();
return 1;
}
auto tsIndex = ts.index();
LOG(debug) << "Found " << ts.num_components()
<< " different components in timeslice "
<< tsIndex;
/*
for (size_t c = 0; c < ts.num_components(); ++c) {
LOG(debug) << "Found " << ts.num_microslices(c)
<< " microslices in component " << c;
LOG(debug) << "Component " << c << " has a size of "
<< ts.size_component(c) << " bytes";
LOG(debug) << "Sys ID: Ox" << std::hex << static_cast<int>(ts.descriptor(0,0).sys_id)
<< std::dec;
for (size_t m = 0; m < ts.num_microslices(c); ++m) {
PrintMicroSliceDescriptor(ts.descriptor(c,m));
}
fBuffer->InsertData<CbmTofDigi>(fDigi);
}
*/
return true;
vDigi.clear();
fUnpackerAlgo->ClearVector();
return kTRUE;
}
void CbmDeviceUnpackTofMcbm2018::BuildTint( int iMode=0 )
void CbmDeviceUnpackTofMcbm2018::BuildTint(int iMode = 0)
{
// iMode - sending condition
// 0 (default)- build time interval only if last buffer entry is older the start + TSLength
// 1 (finish), empty buffer without checking
// Steering variables
double TSLENGTH = 1.E6;
double fdMaxDeltaT = (double) fiReqTint; // in ns
double fdMaxDeltaT = (double) fiReqTint; // in ns
LOG(debug) << " Buffer size " << fBuffer->GetSize()
<< ", DeltaT " << (fBuffer->GetTimeLast()-fBuffer->GetTimeFirst())/1.E9 << " s";
LOG(debug) << "BuildTint: Buffer size " << fBuffer->GetSize() << ", DeltaT "
<< (fBuffer->GetTimeLast() - fBuffer->GetTimeFirst()) / 1.E9 << " s";
CbmTbDaqBuffer::Data data;
CbmTofDigi* digi;
while (fBuffer->GetSize()>0) {
while (fBuffer->GetSize() > 0) {
Double_t fTimeBufferLast = fBuffer->GetTimeLast();
switch(iMode){
case 0:
if( fTimeBufferLast - fBuffer->GetTimeFirst() < TSLENGTH ) return;
break;
case 1:
;
break;
switch (iMode) {
case 0:
if (fTimeBufferLast - fBuffer->GetTimeFirst() < TSLENGTH) return;
break;
case 1:; break;
}
CbmTofDigi* digi = (CbmTofDigi*)fBuffer->GetNextData(fTimeBufferLast);
Double_t dTEnd = digi->GetTime() + fdMaxDeltaT;
Double_t dTEndMax = digi->GetTime() + 2*fdMaxDeltaT;
if(dTEnd > fTimeBufferLast) {
LOG(warn)<<Form("Remaining buffer < %f with %d entries is not sufficient for digi ending at %f -> skipped ",
fTimeBufferLast, fBuffer->GetSize(), dTEnd );
data = fBuffer->GetNextData(fTimeBufferLast);
digi = boost::any_cast<CbmTofDigi*>(data.first);
assert(digi);
Double_t dTEnd = digi->GetTime() + fdMaxDeltaT;
Double_t dTEndMax = digi->GetTime() + 2 * fdMaxDeltaT;
LOG(debug) << Form("Next event at %f until %f, max %f ", digi->GetTime(), dTEnd, dTEndMax);
if (dTEnd > fTimeBufferLast) {
LOG(warn) << Form("Remaining buffer < %f with %d entries is not "
"sufficient for digi ending at %f -> skipped ",
fTimeBufferLast, fBuffer->GetSize(), dTEnd);
return;
}
LOG(debug) << "BuildTint0 with digi " << Form("0x%08x at %012.2f", digi->GetAddress(), digi->GetTime());
Bool_t bDet[fiReqDigiAddr.size()][2];
for(UInt_t i=0; i<fiReqDigiAddr.size(); i++) for(Int_t j=0; j<2; j++) bDet[i][j]=kFALSE; //initialize
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++)
for (Int_t j = 0; j < 2; j++)
bDet[i][j] = kFALSE; //initialize
Bool_t bPul[fiReqDigiAddr.size()][2];
for(UInt_t i=0; i<fiReqDigiAddr.size(); i++) for(Int_t j=0; j<2; j++) bPul[i][j]=kFALSE; //initialize
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++)
for (Int_t j = 0; j < 2; j++)
bPul[i][j] = kFALSE; //initialize
Bool_t bBeam = kFALSE;
std::vector<CbmTofDigi*> vdigi;
UInt_t nDigi=0;
const Int_t AddrMask=0x003FFFFF;
Bool_t bOut=kFALSE;
while(digi) { // build digi array
if (nDigi == vdigi.size()) vdigi.resize(nDigi+100);
vdigi[nDigi++]=digi;
for(UInt_t i=0; i<fiReqDigiAddr.size(); i++)
if( (digi->GetAddress() & AddrMask) == fiReqDigiAddr[i]) {
Int_t j = ((CbmTofDigi *)digi)->GetSide();
bDet[i][j]=kTRUE;
if ( fiReqDigiAddr[i] == 0x00005006 ) bDet[i][1]=kTRUE; // diamond with pad readout
if ( (fiReqDigiAddr[i] & 0x0000F00F ) == 0x00008006) bDet[i][1]=kTRUE; // ceramic with pad readout
Int_t str = ((CbmTofDigi *)digi)->GetChannel();
switch(j){ // treat both strip ends separately
case 0:
switch(fiPulserMode) {
case 0:
case 1:
if (str==31) if(digi->GetTot()>fiPulTotMin && digi->GetTot()<fiPulTotMax) bPul[i][0]=kTRUE;
if (str==0) bPul[i][1]=kFALSE;
if ( fiReqDigiAddr[i] == 0x00005006 ) { //special mapping for MAr2019 diamond (T0)
if (str==0) bPul[i][0]=kTRUE;
if (str==40) bPul[i][1]=kTRUE;
}
break;
case 2:
if (str==0) if(digi->GetTot()>fiPulTotMin && digi->GetTot()<fiPulTotMax) {
bPul[i][0]=kTRUE;
if ( (fiReqDigiAddr[i] & 0x000FF00F ) == 0x00078006) {
bPul[i][1]=kTRUE; // ceramic with pad readout
bDet[i][1]=kFALSE; // remove Hit flag
}
if (str==31) bPul[i][1]=kFALSE;
}
default:
;
}
break;
case 1:
switch(fiPulserMode) {
case 0:
case 1:
if (str==31) bPul[i][0]=kFALSE;
if (str==0) if(digi->GetTot()>fiPulTotMin && digi->GetTot()<fiPulTotMax) bPul[i][1]=kTRUE;
break;
case 2:
if (str==0) bPul[i][0]=kFALSE;
if (str==31) if(digi->GetTot()>fiPulTotMin && digi->GetTot()<fiPulTotMax) bPul[i][1]=kTRUE;
break;
default:
;
}
break;
default:
;
}
}
UInt_t nDigi = 0;
//const Int_t AddrMask=0x003FFFFF;
const Int_t AddrMask = 0x001FFFFF;
Bool_t bOut = kFALSE;
Int_t iBucMul = 0;
while (data.second != ECbmModuleId::kNotExist) { // build digi array
digi = boost::any_cast<CbmTofDigi*>(data.first);
LOG(debug) << "GetNextData " << digi << ", " << data.second << ", " << Form("%f %f", digi->GetTime(), dTEnd)
<< ", Mul " << nDigi;
assert(digi);
if (nDigi == vdigi.size()) vdigi.resize(nDigi + 100);
vdigi[nDigi++] = digi;
Int_t iAddr = digi->GetAddress() & AddrMask;
if (iAddr == 0x00003006 || iAddr == 0x0000b006) {
iBucMul++;
LOG(debug) << Form("Event %10d: BucMul %2d, addr 0x%08x, side %d, strip %2d, rpc %d", fEventHeader[0], iBucMul,
digi->GetAddress(), (Int_t) digi->GetSide(), (Int_t) digi->GetChannel(),
(Int_t) digi->GetRpc());
}
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++)
if ((digi->GetAddress() & AddrMask) == fiReqDigiAddr[i]) {
Int_t j = ((CbmTofDigi*) digi)->GetSide();
bDet[i][j] = kTRUE;
if (fiReqDigiAddr[i] == (Int_t) fiReqBeam) {
bBeam = kTRUE;
LOG(debug) << "Found ReqBeam at index " << nDigi - 1 << ", req " << i;
}
if ((UInt_t) fiReqDigiAddr[i] == fiAddrRef) bDet[i][1] = kTRUE; // diamond with pad readout
// if ( (fiReqDigiAddr[i] & 0x0000F00F ) == 0x00008006) bDet[i][1]=kTRUE; // ceramic with pad readout
Int_t str = ((CbmTofDigi*) digi)->GetChannel();
switch (j) { // treat both strip ends separately
case 0:
switch (fiPulserMode) {
case 0:
case 1:
if (str == 31)
if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) bPul[i][0] = kTRUE;
if (str == 0) bPul[i][1] = kFALSE;
if ((UInt_t) fiReqDigiAddr[i] == fiAddrRef) { //special mapping for MAr2019 diamond (Bmon)
if (str == 0) bPul[i][0] = kTRUE;
if (str == 40) bPul[i][1] = kTRUE;
}
break;
case 2:
if (str == 0)
if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) {
bPul[i][0] = kTRUE;
if ((fiReqDigiAddr[i] & 0x000FF00F) == 0x00078006) {
bPul[i][1] = kTRUE; // ceramic with pad readout
bDet[i][1] = kFALSE; // remove Hit flag
}
if (str == 31) bPul[i][1] = kFALSE;
}
default:;
}
break;
case 1:
switch (fiPulserMode) {
case 0:
case 1:
if (str == 31) bPul[i][0] = kFALSE;
if (str == 0)
if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) bPul[i][1] = kTRUE;
break;
case 2:
if (str == 0) bPul[i][0] = kFALSE;
if (str == 31)
if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) bPul[i][1] = kTRUE;
break;
default:;
}
break;
default:;
}
}
//if(bOut) LOG(info)<<Form("Found 0x%08x, Req 0x%08x ", digi->GetAddress(), fiReqDigiAddr);
if(dTEnd - digi->GetTime() < fdMaxDeltaT*0.5) {
if( digi->GetTime() + fdMaxDeltaT*0.5 < dTEndMax) dTEnd=digi->GetTime() + fdMaxDeltaT*0.5 ;
else dTEnd=dTEndMax;
if (dTEnd - digi->GetTime() < fdMaxDeltaT * 0.5) {
if (digi->GetTime() + fdMaxDeltaT * 0.5 < dTEndMax) dTEnd = digi->GetTime() + fdMaxDeltaT * 0.5;
else
dTEnd = dTEndMax;
};
digi = (CbmTofDigi*)fBuffer->GetNextData(dTEnd);
} // end while
data = fBuffer->GetNextData(dTEnd);
} // end while
LOG(debug) << nDigi << " digis associated to dTEnd = " <<dTEnd<<":";
LOG(debug) << nDigi << " digis associated to dTEnd = " << dTEnd << ":";
//for(UInt_t iDigi=0; iDigi<nDigi; iDigi++) LOG(debug)<<Form(" 0x%08x",vdigi[iDigi]->GetAddress());
for(UInt_t iDigi=0; iDigi<nDigi; iDigi++) LOG(debug)<<vdigi[iDigi]->ToString();
for (UInt_t iDigi = 0; iDigi < nDigi; iDigi++)
LOG(debug) << vdigi[iDigi]->ToString();
UInt_t iDetMul=0;
if(fiReqDigiAddr.size()==0) bOut=kTRUE; // output everything
UInt_t iDetMul = 0;
if (fiReqDigiAddr.size() == 0) bOut = kTRUE; // output everything
else {
if( fiReqMode == 0 ) { // check for presence of requested detectors
for(UInt_t i=0; i<fiReqDigiAddr.size(); i++)
if(bDet[i][0]==kFALSE || bDet[i][1]==kFALSE ) break;
else if( i == fiReqDigiAddr.size()-1 ) {
bOut=kTRUE;
iDetMul=i;
}
} else { // check for presence of any known detector
for(UInt_t i=0; i<fiReqDigiAddr.size(); i++)
if(bDet[i][0]==kTRUE && bDet[i][1]==kTRUE ) {
iDetMul++;
}
if(iDetMul >= fiReqMode) {bOut=kTRUE;}
if (fiReqMode == 0) { // check for presence of requested detectors
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++)
if (bDet[i][0] == kFALSE || bDet[i][1] == kFALSE) break;
else if (i == fiReqDigiAddr.size() - 1) {
bOut = kTRUE;
iDetMul = i;
}
}
else { // check for presence of any known detector
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++)
if (bDet[i][0] == kTRUE && bDet[i][1] == kTRUE) { iDetMul++; }
if (iDetMul >= fiReqMode) { bOut = kTRUE; }
}
}
if( bOut && fiReqDigiAddr.size() > 1) {
LOG(debug) << "Found Req coinc in event with " <<nDigi << " digis in "<<iDetMul
<<" detectors, dTEnd = " <<dTEnd;
if (bOut && fiReqDigiAddr.size() > 1) {
LOG(debug) << "Found Req coinc in event with " << nDigi << " digis in " << iDetMul
<< " detectors, dTEnd = " << dTEnd;
}
// determine Pulser status
UInt_t iPulMul=0; // Count Potential Pulser Signals
for(UInt_t i=0; i<fiReqDigiAddr.size(); i++) {
if( bPul[i][0]==kTRUE && bPul[i][1]==kTRUE ) iPulMul++;
UInt_t iPulMul = 0; // Count Potential Pulser Signals
for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++) {
if (bPul[i][0] == kTRUE && bPul[i][1] == kTRUE) iPulMul++;
}
if(fiPulserMode>0 && iPulMul > fiPulMulMin) {
LOG(debug)<<"@Event "<< fEventHeader[0] <<": iPulMul = " << iPulMul;
bOut=kTRUE;
if (fiPulserMode > 0 && iPulMul > fiPulMulMin) {
LOG(debug) << "@Event " << fEventHeader[0] << ": iPulMul = " << iPulMul;
bOut = kTRUE;
}
LOG(debug)<<"Process Ev " << fEventHeader[0] <<" with iDetMul = "<<iDetMul << ", iPulMul = " << iPulMul;
LOG(debug) << "Process Ev " << fEventHeader[0] << " with iDetMul = " << iDetMul << ", iPulMul = " << iPulMul;
fEventHeader[0]++;
if(bOut) {
fEventHeader[1]=iDetMul;
fEventHeader[2]=fiReqMode;
fEventHeader[3]=iPulMul;
if ((Int_t) fiReqBeam > -1) {
if (bBeam) { LOG(debug) << "Beam counter is present "; }
else {
LOG(debug) << "Beam counter is not present";
bOut = kFALSE; // request beam counter for event
}
}
if (bOut) {
fEventHeader[1] = iDetMul;
fEventHeader[2] = fiReqMode;
fEventHeader[3] = iPulMul;
vdigi.resize(nDigi);
const Int_t NDigiMax=10000;
if(nDigi > NDigiMax) {
LOG(warn) << "Oversized event, truncated! ";
for(UInt_t iDigi=NDigiMax; iDigi<nDigi; iDigi++) vdigi[iDigi]->Delete();
nDigi=1; //NDigiMax;
vdigi.resize(nDigi);
const Int_t NDigiMax = 10000;
if (nDigi > NDigiMax) {
LOG(warn) << "Oversized event, truncated! ";
for (UInt_t iDigi = NDigiMax; iDigi < nDigi; iDigi++)
delete vdigi[iDigi];
nDigi = 1; //NDigiMax;
vdigi.resize(nDigi);
}
SendDigis(vdigi,0);
SendDigis(vdigi, 0);
for(UInt_t iDigi=0; iDigi<nDigi; iDigi++) vdigi[iDigi]->Delete();
for (UInt_t iDigi = 0; iDigi < nDigi; iDigi++)
delete vdigi[iDigi];
}
else {
for(UInt_t iDigi=0; iDigi<nDigi; iDigi++){
digi=vdigi[iDigi];
digi->Delete();
LOG(debug) << " BuildTint cleanup of " << nDigi << " digis";
for (UInt_t iDigi = 0; iDigi < nDigi; iDigi++) {
// vdigi[iDigi]->Delete();
}
//LOG(debug) << " Digis deleted ";
LOG(debug) << " Digis deleted ";
//vdigi.clear();
//delete &vdigi; // crashes, since local variable, will be done at return (?)
}
}
}
bool CbmDeviceUnpackTofMcbm2018::SendDigis( std::vector<CbmTofDigi*> vdigi, int idx )
bool CbmDeviceUnpackTofMcbm2018::SendDigis(std::vector<CbmTofDigi*> vdigi, int idx)
{
LOG(debug) << "Send Digis for event "<<fNumTint<<" with size "<< vdigi.size()<< Form(" at %p ",&vdigi);
LOG(debug) << "EventHeader: "<< fEventHeader[0] << " " << fEventHeader[1] << " " << fEventHeader[2] << " " << fEventHeader[3];
LOG(debug) << "Send Digis for event " << fNumTint << " with size " << vdigi.size() << Form(" at %p ", &vdigi);
LOG(debug) << "EventHeader: " << fEventHeader[0] << " " << fEventHeader[1] << " " << fEventHeader[2] << " "
<< fEventHeader[3];
// Int_t NDigi=vdigi.size();
// Int_t NDigi=vdigi.size();
std::stringstream ossE;
boost::archive::binary_oarchive oaE(ossE);
......@@ -1569,15 +1158,17 @@ bool CbmDeviceUnpackTofMcbm2018::SendDigis( std::vector<CbmTofDigi*> vdigi, int
std::string* strMsg = new std::string(oss.str());
FairMQParts parts;
parts.AddPart(NewMessage(const_cast<char*>(strMsgE->c_str()), // data
strMsgE->length(), // size
[](void* , void* object){ delete static_cast<std::string*>(object); },
strMsgE)); // object that manages the data
parts.AddPart(NewMessage(
const_cast<char*>(strMsgE->c_str()), // data
strMsgE->length(), // size
[](void*, void* object) { delete static_cast<std::string*>(object); },
strMsgE)); // object that manages the data
parts.AddPart(NewMessage(const_cast<char*>(strMsg->c_str()), // data
strMsg->length(), // size
[](void* , void* object){ delete static_cast<std::string*>(object); },
strMsg)); // object that manages the data
parts.AddPart(NewMessage(
const_cast<char*>(strMsg->c_str()), // data
strMsg->length(), // size
[](void*, void* object) { delete static_cast<std::string*>(object); },
strMsg)); // object that manages the data
/*
......@@ -1666,7 +1257,7 @@ bool CbmDeviceUnpackTofMcbm2018::SendDigis( std::vector<CbmTofDigi*> vdigi, int
// successfull transfer will return number of bytes
// transfered (can be 0 if sending an empty message).
LOG(debug) << "Send data to channel "<< idx << " " << fChannelsToSend[idx][0];
LOG(debug) << "Send data to channel " << idx << " " << fChannelsToSend[idx][0];
// if (Send(msg, fChannelsToSend[idx][0]) < 0) {
......@@ -1690,23 +1281,15 @@ bool CbmDeviceUnpackTofMcbm2018::SendDigis( std::vector<CbmTofDigi*> vdigi, int
void CbmDeviceUnpackTofMcbm2018::AddReqDigiAddr(Int_t iAddr)
{
UInt_t iNReq=fiReqDigiAddr.size();
for(UInt_t i=0; i<iNReq; i++) if ( fiReqDigiAddr[i] == iAddr ) return; // det already present, avoid double counting
fiReqDigiAddr.resize(iNReq+1); // hopefully the old entries are preserved ...
fiReqDigiAddr[iNReq]=iAddr;
LOG(info) <<Form("Request Digi Address 0x%08x ",iAddr);
UInt_t iNReq = fiReqDigiAddr.size();
for (UInt_t i = 0; i < iNReq; i++)
if (fiReqDigiAddr[i] == iAddr) return; // det already present, avoid double counting
fiReqDigiAddr.resize(iNReq + 1); // hopefully the old entries are preserved ...
fiReqDigiAddr[iNReq] = iAddr;
LOG(info) << Form("Request Digi Address 0x%08x at index %d", iAddr, iNReq);
}
void CbmDeviceUnpackTofMcbm2018::SetIgnoreOverlapMs( Bool_t bFlagIn )
{
fUnpackerAlgo->SetIgnoreOverlapMs( bFlagIn );
}
void CbmDeviceUnpackTofMcbm2018::SetIgnoreOverlapMs(Bool_t bFlagIn) { fUnpackerAlgo->SetIgnoreOverlapMs(bFlagIn); }
void CbmDeviceUnpackTofMcbm2018::SetTimeOffsetNs( Double_t dOffsetIn )
{
fUnpackerAlgo->SetTimeOffsetNs( dOffsetIn );
}
void CbmDeviceUnpackTofMcbm2018::SetDiamondDpbIdx( UInt_t uIdx )
{
fUnpackerAlgo->SetDiamondDpbIdx( uIdx );
}
void CbmDeviceUnpackTofMcbm2018::SetTimeOffsetNs(Double_t dOffsetIn) { fUnpackerAlgo->SetTimeOffsetNs(dOffsetIn); }
void CbmDeviceUnpackTofMcbm2018::SetDiamondDpbIdx(UInt_t uIdx) { fUnpackerAlgo->SetDiamondDpbIdx(uIdx); }
/* Copyright (C) 2018-2020 PI-UHd, GSI
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig, Norbert Herrmann [committer] */
/**
* CbmDeviceUnpackTofMcbm2018.h
*
......@@ -11,21 +15,20 @@
#ifndef CBMDEVICEUNPACKTOFMCBM2018_H_
#define CBMDEVICEUNPACKTOFMCBM2018_H_
#include "FairMQDevice.h"
#include "gDpbMessv100.h"
#include "CbmMcbm2018TofPar.h"
#include "CbmMqTMessage.h"
#include "Timeslice.hpp"
#include "MicrosliceDescriptor.hpp"
#include "Timeslice.hpp"
#include "TMessage.h"
#include "Rtypes.h"
#include "FairMQDevice.h"
#include "CbmDigi.h"
#include "CbmMcbm2018TofPar.h"
#include "Rtypes.h"
#include <vector>
#include <map>
#include <vector>
#include "gDpbMessv100.h"
class CbmMcbm2018UnpackerAlgoTof;
class CbmMcbm2018TofPar;
......@@ -35,211 +38,163 @@ class CbmTofDigi;
class TH1;
class TH2;
class CbmDeviceUnpackTofMcbm2018: public FairMQDevice
{
public:
CbmDeviceUnpackTofMcbm2018();
virtual ~CbmDeviceUnpackTofMcbm2018();
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
bool HandleParts(FairMQParts&, int);
bool HandleMessage(FairMQMessagePtr&, int);
virtual void BuildTint(int);
virtual bool SendDigis(std::vector<CbmTofDigi*>, int);
private:
uint64_t fNumMessages;
uint64_t fiSelectComponents;
uint64_t fNumTint;
std::vector<int> fEventHeader;
uint64_t fiReqMode;
uint64_t fiReqTint;
std::vector< Int_t > fiReqDigiAddr;
Int_t fiPulserMode;
uint64_t fiPulMulMin;
uint64_t fiPulTotMin;
uint64_t fiPulTotMax;
std::vector<std::string> fAllowedChannels
= {"tofcomponent","parameters","tofdigis","syscmd"};
std::vector<std::vector<std::string>> fChannelsToSend = { {},{},{} };
//size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/
size_t fuTotalMsNb; /** Total nb of MS per link in timeslice **/
size_t fuOverlapMsNb; /** Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/
size_t fuCoreMs; /** Number of non overlap MS at beginning of TS **/
Double_t fdMsSizeInNs;
Double_t fdTsCoreSizeInNs;
UInt_t fuMinNbGdpb;
//UInt_t fuCurrNbGdpb;
UInt_t fuNrOfGdpbs; // Total number of GDPBs in the system
UInt_t fuNrOfFeePerGdpb; // Number of FEEs per GDPB
UInt_t fuNrOfGet4PerFee; // Number of GET4s per FEE
UInt_t fuNrOfChannelsPerGet4; // Number of channels in each GET4
UInt_t fuNrOfChannelsPerFee; // Number of channels in each FEET
UInt_t fuNrOfGet4; // Total number of Get4 chips in the system
UInt_t fuNrOfGet4PerGdpb; // Number of GET4s per GDPB
UInt_t fuNrOfChannelsPerGdpb; // Number of channels per GDPB
const UInt_t kuNbFeePerGbtx = 5;
const UInt_t kuNbGbtxPerGdpb = 6;
UInt_t fuGdpbId; // Id (hex number) of the GDPB for current message
UInt_t fuGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB for current message
UInt_t fuGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message
UInt_t fuGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system for current message
//Int_t fiEquipmentId;
std::vector<int> fMsgCounter;
std::map<UInt_t, UInt_t> fGdpbIdIndexMap;
///* STAR TRIGGER detection *///
std::vector< ULong64_t > fvulGdpbTsMsb;
std::vector< ULong64_t > fvulGdpbTsLsb;
std::vector< ULong64_t > fvulStarTsMsb;
std::vector< ULong64_t > fvulStarTsMid;
std::vector< ULong64_t > fvulGdpbTsFullLast;
std::vector< ULong64_t > fvulStarTsFullLast;
std::vector< UInt_t > fvuStarTokenLast;
std::vector< UInt_t > fvuStarDaqCmdLast;
std::vector< UInt_t > fvuStarTrigCmdLast;
// CbmHistManager* fHM; ///< Histogram manager
/** Current epoch marker for each GDPB and GET4
class CbmDeviceUnpackTofMcbm2018 : public FairMQDevice {
public:
CbmDeviceUnpackTofMcbm2018();
virtual ~CbmDeviceUnpackTofMcbm2018();
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
bool HandleParts(FairMQParts&, int);
bool HandleMessage(FairMQMessagePtr&, int);
virtual void BuildTint(int);
virtual bool SendDigis(std::vector<CbmTofDigi*>, int);
private:
uint64_t fNumMessages;
uint64_t fiSelectComponents;
uint64_t fNumTint;
std::vector<int> fEventHeader;
uint64_t fiReqMode;
uint64_t fiReqTint;
uint64_t fiReqBeam;
std::vector<Int_t> fiReqDigiAddr;
Int_t fiPulserMode;
uint64_t fiPulMulMin;
uint64_t fiPulTotMin;
uint64_t fiPulTotMax;
std::vector<std::string> fAllowedChannels = {"tofcomponent", "parameters", "tofdigis", "syscmd"};
std::vector<std::vector<std::string>> fChannelsToSend = {{}, {}, {}};
size_t fuTotalMsNb; /** Total nb of MS per link in timeslice **/
size_t fuOverlapMsNb; /** Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/
size_t fuCoreMs; /** Number of non overlap MS at beginning of TS **/
Double_t fdMsSizeInNs;
Double_t fdTsCoreSizeInNs;
UInt_t fuMinNbGdpb;
UInt_t fuNrOfGdpbs; // Total number of GDPBs in the system
UInt_t fuNrOfFeePerGdpb; // Number of FEEs per GDPB
UInt_t fuNrOfGet4PerFee; // Number of GET4s per FEE
UInt_t fuNrOfChannelsPerGet4; // Number of channels in each GET4
UInt_t fuNrOfChannelsPerFee; // Number of channels in each FEET
UInt_t fuNrOfGet4; // Total number of Get4 chips in the system
UInt_t fuNrOfGet4PerGdpb; // Number of GET4s per GDPB
UInt_t fuNrOfChannelsPerGdpb; // Number of channels per GDPB
const UInt_t kuNbFeePerGbtx = 5;
const UInt_t kuNbGbtxPerGdpb = 6;
UInt_t fuGdpbId; // Id (hex number) of the GDPB for current message
UInt_t fuGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB for current message
UInt_t fuGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message
UInt_t fuGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system for current message
std::vector<int> fMsgCounter;
std::map<UInt_t, UInt_t> fGdpbIdIndexMap;
// CbmHistManager* fHM; ///< Histogram manager
/** Current epoch marker for each GDPB and GET4
* (first epoch in the stream initializes the map item)
* pointer points to an array of size fNrOfGdpbs * fNrOfGet4PerGdpb
* The correct array index is calculated using the function
* GetArrayIndex(gdpbId, get4Id)
**/
std::vector< ULong64_t > fvulCurrentEpoch; //!
std::vector< Bool_t > fvbFirstEpochSeen; //!
Int_t fNofEpochs; /** Current epoch marker for each ROC **/
ULong64_t fulCurrentEpochTime; /** Time stamp of current epoch **/
//Double_t fdMsIndex;
Double_t fdTShiftRef;
//UInt_t fuDiamondDpbIdx;
//Bool_t fbEpochSuppModeOn;
//Bool_t fbGet4M24b;
//Bool_t fbGet4v20;
//Bool_t fbMergedEpochsOn;
CbmTofDigi* fDigi;
CbmMcbm2018TofPar* fUnpackPar; //!
// Variables used for histo filling
//Double_t fdRefTime;
Double_t fdLastDigiTime;
Double_t fdFirstDigiTimeDif;
//Double_t fdEvTime0;
TH1* fhRawTDigEvT0;
TH1* fhRawTDigRef0;
TH1* fhRawTDigRef;
TH1* fhRawTRefDig0;
TH1* fhRawTRefDig1;
TH1* fhRawDigiLastDigi;
std::vector< TH2* > fhRawTotCh;
std::vector< TH1* > fhChCount;
std::vector< Bool_t > fvbChanThere;
std::vector< TH2* > fhChanCoinc;
//Bool_t fbDetChanThere[64]; // FIXME
TH2* fhDetChanCoinc;
inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id)
{
return gdpbId * fuNrOfGet4PerGdpb + get4Id;
}
///* PADI channel to GET4 channel mapping and reverse *///
std::vector< UInt_t > fvuPadiToGet4;
std::vector< UInt_t > fvuGet4ToPadi;
///* GET4 to eLink mapping and reverse *///
static const UInt_t kuNbGet4PerGbtx = 5 * 8; /// 5 FEE with 8 GET4 each
std::vector< UInt_t > fvuElinkToGet4;
std::vector< UInt_t > fvuGet4ToElink;
inline UInt_t ConvertElinkToGet4( UInt_t uElinkIdx )
{
return fvuElinkToGet4[ uElinkIdx % kuNbGet4PerGbtx ] + kuNbGet4PerGbtx * (uElinkIdx / kuNbGet4PerGbtx);
}
inline UInt_t ConvertGet4ToElink( UInt_t uGet4Idx )
{
return fvuGet4ToElink[ uGet4Idx % kuNbGet4PerGbtx ] + kuNbGet4PerGbtx * (uGet4Idx / kuNbGet4PerGbtx);
}
std::vector< Int_t > fviRpcType;
std::vector< Int_t > fviModuleId;
std::vector< Int_t > fviNrOfRpc;
std::vector< Int_t > fviRpcSide;
std::vector< Int_t > fviRpcChUId;
std::vector< std::vector < gdpbv100::Message > > fvmEpSupprBuffer;
CbmTbDaqBuffer* fBuffer;
ULong64_t fulGdpbTsMsb;
ULong64_t fulGdpbTsLsb;
ULong64_t fulStarTsMsb;
ULong64_t fulStarTsMid;
ULong64_t fulGdpbTsFullLast;
ULong64_t fulStarTsFullLast;
UInt_t fuStarTokenLast;
UInt_t fuStarDaqCmdLast;
UInt_t fuStarTrigCmdLast;
bool CheckTimeslice(const fles::Timeslice& ts);
void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc);
bool IsChannelNameAllowed(std::string channelName);
void SetParContainers();
Bool_t InitContainers();
Bool_t ReInitContainers();
void CreateHistograms();
void AddReqDigiAddr(int);
void FillHitInfo(gdpbv100::Message);
void FillStarTrigInfo(gdpbv100::Message);
void FillEpochInfo(gdpbv100::Message);
void PrintSlcInfo(gdpbv100::Message);
void PrintSysInfo(gdpbv100::Message);
void PrintGenInfo(gdpbv100::Message);
Bool_t DoUnpack(const fles::Timeslice& ts, size_t component);
/// Temp until we change from CbmMcbmUnpack to something else
void AddMsComponentToList( size_t component, UShort_t usDetectorId );
void SetNbMsInTs( size_t /*uCoreMsNb*/, size_t /*uOverlapMsNb*/ ){};
/// Algo settings setters
inline void SetMonitorMode( Bool_t bFlagIn = kTRUE ) { fbMonitorMode = bFlagIn; }
void SetIgnoreOverlapMs( Bool_t bFlagIn = kTRUE );
void SetTimeOffsetNs( Double_t dOffsetIn = 0.0 );
void SetDiamondDpbIdx( UInt_t uIdx = 2 );
/// Processing algo
CbmMcbm2018UnpackerAlgoTof * fUnpackerAlgo;
/// Control flags
Bool_t fbMonitorMode; //! Switch ON the filling of a minimal set of histograms
// Bool_t fbDebugMonitorMode; //! Switch ON the filling of a additional set of histograms
//Bool_t fbSeparateArrayT0; //! If ON, T0 digis are saved in separate TClonesArray
//Bool_t fbWriteOutput; //! If ON the output TClonesArray of digi is written to disk
};
// special class to expose protected TMessage constructor
class CbmMQTMessage : public TMessage
{
public:
CbmMQTMessage(void* buf, Int_t len)
: TMessage(buf, len)
{
ResetBit(kIsOwner);
}
std::vector<ULong64_t> fvulCurrentEpoch; //!
std::vector<Bool_t> fvbFirstEpochSeen; //!
Int_t fNofEpochs; /** Current epoch marker for each ROC **/
ULong64_t fulCurrentEpochTime; /** Time stamp of current epoch **/
//Double_t fdMsIndex;
Double_t fdToffTof;
UInt_t fiAddrRef;
//UInt_t fuDiamondDpbIdx;
//Bool_t fbEpochSuppModeOn;
//Bool_t fbGet4M24b;
//Bool_t fbGet4v20;
//Bool_t fbMergedEpochsOn;
CbmMcbm2018TofPar* fUnpackPar; //!
// Variables used for histo filling
Double_t fdLastDigiTime;
Double_t fdFirstDigiTimeDif;
//Double_t fdEvTime0;
TH1* fhRawTDigEvBmon;
TH1* fhRawTDigRef0;
TH1* fhRawTDigRef;
TH1* fhRawTRefDig0;
TH1* fhRawTRefDig1;
TH1* fhRawDigiLastDigi;
std::vector<TH2*> fhRawTotCh;
std::vector<TH1*> fhChCount;
std::vector<Bool_t> fvbChanThere;
std::vector<TH2*> fhChanCoinc;
//Bool_t fbDetChanThere[64]; // FIXME
TH2* fhDetChanCoinc;
inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id) { return gdpbId * fuNrOfGet4PerGdpb + get4Id; }
///* PADI channel to GET4 channel mapping and reverse *///
std::vector<UInt_t> fvuPadiToGet4;
std::vector<UInt_t> fvuGet4ToPadi;
///* GET4 to eLink mapping and reverse *///
static const UInt_t kuNbGet4PerGbtx = 5 * 8; /// 5 FEE with 8 GET4 each
std::vector<UInt_t> fvuElinkToGet4;
std::vector<UInt_t> fvuGet4ToElink;
inline UInt_t ConvertElinkToGet4(UInt_t uElinkIdx)
{
return fvuElinkToGet4[uElinkIdx % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uElinkIdx / kuNbGet4PerGbtx);
}
inline UInt_t ConvertGet4ToElink(UInt_t uGet4Idx)
{
return fvuGet4ToElink[uGet4Idx % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uGet4Idx / kuNbGet4PerGbtx);
}
std::vector<Int_t> fviRpcType;
std::vector<Int_t> fviModuleId;
std::vector<Int_t> fviNrOfRpc;
std::vector<Int_t> fviRpcSide;
std::vector<Int_t> fviRpcChUId;
CbmTbDaqBuffer* fBuffer;
bool CheckTimeslice(const fles::Timeslice& ts);
void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc);
bool IsChannelNameAllowed(std::string channelName);
void SetParContainers();
Bool_t InitContainers();
Bool_t ReInitContainers();
void CreateHistograms();
void AddReqDigiAddr(int);
Bool_t DoUnpack(const fles::Timeslice& ts, size_t component);
/// Temp until we change from CbmMcbmUnpack to something else
void AddMsComponentToList(size_t component, UShort_t usDetectorId);
void SetNbMsInTs(size_t /*uCoreMsNb*/, size_t /*uOverlapMsNb*/) {};
/// Algo settings setters
void SetIgnoreOverlapMs(Bool_t bFlagIn = kTRUE);
void SetTimeOffsetNs(Double_t dOffsetIn = 0.0);
void SetDiamondDpbIdx(UInt_t uIdx = 2);
/// Processing algo
CbmMcbm2018UnpackerAlgoTof* fUnpackerAlgo;
/// Control flags
// Bool_t fbMonitorMode; //! Switch ON the filling of a minimal set of histograms
// Bool_t fbDebugMonitorMode; //! Switch ON the filling of a additional set of histograms
// Bool_t fbSeparateArrayBmon; //! If ON, Bmon digis are saved in separate TClonesArray
// Bool_t fbWriteOutput; //! If ON the output TClonesArray of digi is written to disk
CbmDeviceUnpackTofMcbm2018(const CbmDeviceUnpackTofMcbm2018&) = delete;
CbmDeviceUnpackTofMcbm2018 operator=(const CbmDeviceUnpackTofMcbm2018&) = delete;
};
#endif /* CBMDEVICEUNPACKTOFMCBM2018_H_ */
/* Copyright (C) 2018-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig [committer] */
/**
* CbmDeviceUnpackTofStar2018.cxx
*
......@@ -15,30 +19,31 @@
#include "StorableTimeslice.hpp"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairMQProgOptions.h" // device->fConfig
#include "TH1.h"
#include "TH2.h"
#include <boost/archive/binary_iarchive.hpp>
#include <string>
#include <iomanip>
#include <stdexcept>
struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; };
#include <string>
struct InitTaskError : std::runtime_error {
using std::runtime_error::runtime_error;
};
using namespace std;
static Int_t iMess=0;
const Int_t DetMask = 0x0001FFFF;
static Int_t iMess = 0;
const Int_t DetMask = 0x0001FFFF;
CbmDeviceUnpackTofStar2018::CbmDeviceUnpackTofStar2018()
: fNumMessages(0)
, fuMsAcceptsPercent(100)
, fuOverlapMsNb(0)
, fuMinNbGdpb( 0 )
, fuCurrNbGdpb( 0 )
, fuMinNbGdpb(0)
, fuCurrNbGdpb(0)
, fuNrOfGdpbs(0)
, fuNrOfFebsPerGdpb(0)
, fuNrOfGet4PerFeb(0)
......@@ -47,13 +52,13 @@ CbmDeviceUnpackTofStar2018::CbmDeviceUnpackTofStar2018()
, fuNrOfGet4(0)
, fuNrOfGet4PerGdpb(0)
, fuNrOfChannelsPerGdpb(0)
, fMsgCounter(11,0) // length of enum MessageTypes initialized with 0
, fMsgCounter(11, 0) // length of enum MessageTypes initialized with 0
, fGdpbIdIndexMap()
, fuGdpbId(0)
, fuGdpbNr(0)
, fuGet4Id(0)
, fuGet4Nr(0)
// , fHM(new CbmHistManager())
// , fHM(new CbmHistManager())
, fvulCurrentEpoch()
, fvbFirstEpochSeen()
, fNofEpochs(0)
......@@ -61,22 +66,22 @@ CbmDeviceUnpackTofStar2018::CbmDeviceUnpackTofStar2018()
, fEquipmentId(0)
, fdMsIndex(0.)
, fdTShiftRef(0.)
, fbEpochSuppModeOn( kFALSE )
, fbGet4M24b( kFALSE )
, fbGet4v20( kFALSE )
, fbMergedEpochsOn( kFALSE )
, fbEpochSuppModeOn(kFALSE)
, fbGet4M24b(kFALSE)
, fbGet4v20(kFALSE)
, fbMergedEpochsOn(kFALSE)
, fDigi(nullptr)
, fUnpackPar(nullptr)
, fdRefTime(0.)
, fdLastDigiTime(0.)
, fdFirstDigiTimeDif(0.)
, fdEvTime0(0.)
, fhRawTDigEvT0( nullptr )
, fhRawTDigRef0( nullptr )
, fhRawTDigRef( nullptr )
, fhRawTRefDig0( nullptr )
, fhRawTRefDig1( nullptr )
, fhRawDigiLastDigi( nullptr )
, fhRawTDigEvBmon(nullptr)
, fhRawTDigRef0(nullptr)
, fhRawTDigRef(nullptr)
, fhRawTRefDig0(nullptr)
, fhRawTRefDig1(nullptr)
, fhRawDigiLastDigi(nullptr)
, fhRawTotCh()
, fhChCount()
, fvbChanThere()
......@@ -84,59 +89,57 @@ CbmDeviceUnpackTofStar2018::CbmDeviceUnpackTofStar2018()
, fhDetChanCoinc(nullptr)
, fvmEpSupprBuffer()
, fBuffer(CbmTbDaqBuffer::Instance())
, fulGdpbTsMsb(0.)
, fulGdpbTsLsb(0.)
, fulStarTsMsb(0.)
, fulStarTsMid(0.)
, fulGdpbTsMsb(0.)
, fulGdpbTsLsb(0.)
, fulStarTsMsb(0.)
, fulStarTsMid(0.)
, fulGdpbTsFullLast(0.)
, fulStarTsFullLast(0.)
, fuStarTokenLast(0)
, fuStarDaqCmdLast(0)
, fuStarDaqCmdLast(0)
, fuStarTrigCmdLast(0)
{
}
void CbmDeviceUnpackTofStar2018::InitTask()
try
{
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
// for the device
// The idea is to check at initilization if the devices are
// properly connected. For the time beeing this is done with a
// nameing convention. It is not avoided that someone sends other
// data on this channel.
int noChannel = fChannels.size();
LOG(info) << "Number of defined input channels: " << noChannel;
for(auto const &entry : fChannels) {
LOG(info) << "Channel name: " << entry.first;
if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match.");
OnData(entry.first, &CbmDeviceUnpackTofStar2018::HandleData);
}
InitContainers();
} catch (InitTaskError& e) {
LOG(error) << e.what();
ChangeState(ERROR_FOUND);
try {
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
// for the device
// The idea is to check at initilization if the devices are
// properly connected. For the time beeing this is done with a
// nameing convention. It is not avoided that someone sends other
// data on this channel.
int noChannel = fChannels.size();
LOG(info) << "Number of defined input channels: " << noChannel;
for (auto const& entry : fChannels) {
LOG(info) << "Channel name: " << entry.first;
if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match.");
OnData(entry.first, &CbmDeviceUnpackTofStar2018::HandleData);
}
InitContainers();
}
catch (InitTaskError& e) {
LOG(error) << e.what();
ChangeState(ERROR_FOUND);
}
bool CbmDeviceUnpackTofStar2018::IsChannelNameAllowed(std::string channelName)
{
for(auto const &entry : fAllowedChannels) {
for (auto const& entry : fAllowedChannels) {
std::size_t pos1 = channelName.find(entry);
if (pos1!=std::string::npos) {
if (pos1 != std::string::npos) {
const vector<std::string>::const_iterator pos =
std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry);
const vector<std::string>::size_type idx = pos-fAllowedChannels.begin();
std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry);
const vector<std::string>::size_type idx = pos - fAllowedChannels.begin();
LOG(info) << "Found " << entry << " in " << channelName;
LOG(info) << "Channel name " << channelName
<< " found in list of allowed channel names at position " << idx;
LOG(info) << "Channel name " << channelName << " found in list of allowed channel names at position " << idx;
return true;
}
}
LOG(info) << "Channel name " << channelName
<< " not found in list of allowed channel names.";
LOG(info) << "Channel name " << channelName << " not found in list of allowed channel names.";
LOG(error) << "Stop device.";
return false;
}
......@@ -144,159 +147,138 @@ bool CbmDeviceUnpackTofStar2018::IsChannelNameAllowed(std::string channelName)
Bool_t CbmDeviceUnpackTofStar2018::InitContainers()
{
LOG(info) << "Init parameter containers for CbmDeviceUnpackTofStar2018.";
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
// Should only be used for small data because of the cost of an additional copy
std::string message{"CbmTofUnpackPar,111"};
std::string message {"CbmTofUnpackPar,111"};
LOG(info) << "Requesting parameter container CbmTofUnpackPar, sending message: " << message;
FairMQMessagePtr req(NewSimpleMessage("CbmTofUnpackPar,111"));
FairMQMessagePtr rep(NewMessage());
if (Send(req, "parameters") > 0)
{
if (Receive(rep, "parameters") >= 0)
{
if (rep->GetSize() != 0)
{
CbmMQTMessage tmsg(rep->GetData(), rep->GetSize());
fUnpackPar = static_cast<CbmTofUnpackPar*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(info) << "Received parameter from the server:";
fUnpackPar->print();
}
else
{
LOG(error) << "Received empty reply. Parameter not available";
}
}
if (Send(req, "parameters") > 0) {
if (Receive(rep, "parameters") >= 0) {
if (rep->GetSize() != 0) {
CbmMqTMessage tmsg(rep->GetData(), rep->GetSize());
fUnpackPar = static_cast<CbmTofUnpackPar*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(info) << "Received parameter from the server:";
fUnpackPar->print();
}
else {
LOG(error) << "Received empty reply. Parameter not available";
}
}
}
Bool_t initOK = ReInitContainers();
CreateHistograms();
fvulCurrentEpoch.resize( fuNrOfGdpbs * fuNrOfGet4PerGdpb );
fvbFirstEpochSeen.resize( fuNrOfGdpbs * fuNrOfGet4PerGdpb );
fvbChanThere.resize( fUnpackPar->GetNumberOfChannels(), kFALSE );
for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
{
for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j )
{
fvulCurrentEpoch[GetArrayIndex(i, j)] = 0;
fvbFirstEpochSeen[GetArrayIndex(i, j)] = kFALSE;
} // for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j )
} // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
fvulCurrentEpoch.resize(fuNrOfGdpbs * fuNrOfGet4PerGdpb);
fvbFirstEpochSeen.resize(fuNrOfGdpbs * fuNrOfGet4PerGdpb);
fvbChanThere.resize(fUnpackPar->GetNumberOfChannels(), kFALSE);
for (UInt_t i = 0; i < fuNrOfGdpbs; ++i) {
for (UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j) {
fvulCurrentEpoch[GetArrayIndex(i, j)] = 0;
fvbFirstEpochSeen[GetArrayIndex(i, j)] = kFALSE;
} // for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j )
} // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
return initOK;
}
Bool_t CbmDeviceUnpackTofStar2018::ReInitContainers()
{
LOG(info) << "ReInit parameter containers for CbmDeviceUnpackTofStar2018.";
fuNrOfGdpbs = fUnpackPar->GetNrOfRocs();
LOG(info) << "Nr. of Tof GDPBs: " << fuNrOfGdpbs;
fuMinNbGdpb = fuNrOfGdpbs;
fuNrOfFebsPerGdpb = fUnpackPar->GetNrOfFebsPerGdpb();
LOG(info) << "Nr. of FEBS per Tof GDPB: " << fuNrOfFebsPerGdpb;
fuNrOfGet4PerFeb = fUnpackPar->GetNrOfGet4PerFeb();
LOG(info) << "Nr. of GET4 per Tof FEB: " << fuNrOfGet4PerFeb;
fuNrOfChannelsPerGet4 = fUnpackPar->GetNrOfChannelsPerGet4();
LOG(info) << "Nr. of channels per GET4: " << fuNrOfChannelsPerGet4;
fuNrOfChannelsPerFeet = fuNrOfGet4PerFeb * fuNrOfChannelsPerGet4;
LOG(info) << "Nr. of channels per FEET: " << fuNrOfChannelsPerFeet;
fuNrOfGet4 = fuNrOfGdpbs * fuNrOfFebsPerGdpb * fuNrOfGet4PerFeb;
LOG(info) << "Nr. of GET4s: " << fuNrOfGet4;
fuNrOfGet4PerGdpb = fuNrOfFebsPerGdpb * fuNrOfGet4PerFeb;
LOG(info) << "Nr. of GET4s per GDPB: " << fuNrOfGet4PerGdpb;
fuNrOfChannelsPerGdpb = fuNrOfGet4PerGdpb * fuNrOfChannelsPerGet4;
LOG(info) << "Nr. of channels per GDPB: " << fuNrOfChannelsPerGdpb;
fGdpbIdIndexMap.clear();
for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
{
fGdpbIdIndexMap[fUnpackPar->GetRocId(i)] = i;
LOG(info) << "GDPB Id of TOF " << i << " : " << std::hex << fUnpackPar->GetRocId(i)
<< std::dec;
} // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
for (UInt_t i = 0; i < fuNrOfGdpbs; ++i) {
fGdpbIdIndexMap[fUnpackPar->GetRocId(i)] = i;
LOG(info) << "GDPB Id of TOF " << i << " : " << std::hex << fUnpackPar->GetRocId(i) << std::dec;
} // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
UInt_t uNrOfChannels = fUnpackPar->GetNumberOfChannels();
LOG(info) << "Nr. of mapped Tof channels: " << uNrOfChannels;
for( UInt_t i = 0; i < uNrOfChannels; ++i)
{
if (i % 8 == 0)
LOG(info);
LOG(info) << Form(" 0x%08x", fUnpackPar->GetChannelToDetUIdMap(i) );
} // for( UInt_t i = 0; i < uNrOfChannels; ++i)
for (UInt_t i = 0; i < uNrOfChannels; ++i) {
if (i % 8 == 0) LOG(info);
LOG(info) << Form(" 0x%08x", fUnpackPar->GetChannelToDetUIdMap(i));
} // for( UInt_t i = 0; i < uNrOfChannels; ++i)
LOG(info);
LOG(info) << "Plot Channel Rate => "
<< (fUnpackPar->IsChannelRateEnabled() ? "ON" : "OFF");
if( fbEpochSuppModeOn )
fvmEpSupprBuffer.resize( fuNrOfGet4 );
LOG(info) << "Plot Channel Rate => " << (fUnpackPar->IsChannelRateEnabled() ? "ON" : "OFF");
if (fbEpochSuppModeOn) fvmEpSupprBuffer.resize(fuNrOfGet4);
return kTRUE;
}
void CbmDeviceUnpackTofStar2018::CreateHistograms()
{
LOG(info) << "create Histos for " << fuNrOfGdpbs <<" gDPBs ";
fhRawTDigEvT0 = new TH1F( Form("Raw_TDig-EvT0"),
Form("Raw digi time difference to 1st digi ; time [ns]; cts"),
500, 0, 100.);
// fHM->Add( Form("Raw_TDig-EvT0"), fhRawTDigEvT0);
fhRawTDigRef0 = new TH1F( Form("Raw_TDig-Ref0"),
Form("Raw digi time difference to Ref ; time [ns]; cts"),
6000, -10000, 50000);
LOG(info) << "create Histos for " << fuNrOfGdpbs << " gDPBs ";
fhRawTDigEvBmon =
new TH1F(Form("Raw_TDig-EvBmon"), Form("Raw digi time difference to 1st digi ; time [ns]; cts"), 500, 0, 100.);
// fHM->Add( Form("Raw_TDig-EvBmon"), fhRawTDigEvBmon);
fhRawTDigRef0 =
new TH1F(Form("Raw_TDig-Ref0"), Form("Raw digi time difference to Ref ; time [ns]; cts"), 6000, -10000, 50000);
// fHM->Add( Form("Raw_TDig-Ref0"), fhRawTDigRef0);
fhRawTDigRef = new TH1F( Form("Raw_TDig-Ref"),
Form("Raw digi time difference to Ref ; time [ns]; cts"),
6000, -1000, 5000);
fhRawTDigRef =
new TH1F(Form("Raw_TDig-Ref"), Form("Raw digi time difference to Ref ; time [ns]; cts"), 6000, -1000, 5000);
// fHM->Add( Form("Raw_TDig-Ref"), fhRawTDigRef);
fhRawTRefDig0 = new TH1F( Form("Raw_TRef-Dig0"),
Form("Raw Ref time difference to last digi ; time [ns]; cts"),
9999, -50000, 50000);
fhRawTRefDig0 = new TH1F(Form("Raw_TRef-Dig0"), Form("Raw Ref time difference to last digi ; time [ns]; cts"), 9999,
-50000, 50000);
// fHM->Add( Form("Raw_TRef-Dig0"), fhRawTRefDig0);
fhRawTRefDig1 = new TH1F( Form("Raw_TRef-Dig1"),
Form("Raw Ref time difference to last digi ; time [ns]; cts"),
9999, -5000, 5000);
fhRawTRefDig1 =
new TH1F(Form("Raw_TRef-Dig1"), Form("Raw Ref time difference to last digi ; time [ns]; cts"), 9999, -5000, 5000);
// fHM->Add( Form("Raw_TRef-Dig1"), fhRawTRefDig1);
fhRawDigiLastDigi = new TH1F( Form("Raw_Digi-LastDigi"),
Form("Raw Digi time difference to last digi ; time [ns]; cts"),
9999, -5000, 5000);
fhRawDigiLastDigi = new TH1F(Form("Raw_Digi-LastDigi"),
Form("Raw Digi time difference to last digi ; time [ns]; cts"), 9999, -5000, 5000);
// 9999, -5000000, 5000000);
// fHM->Add( Form("Raw_Digi-LastDigi"), fhRawDigiLastDigi);
fhRawTotCh.resize( fuNrOfGdpbs );
fhChCount.resize( fuNrOfGdpbs );
fhChanCoinc.resize( fuNrOfGdpbs * fuNrOfFebsPerGdpb / 2 );
for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++)
{
fhRawTotCh[ uGdpb ] = new TH2F( Form("Raw_Tot_gDPB_%02u", uGdpb),
Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb,
256, 0., 256. );
// fHM->Add( Form("Raw_Tot_gDPB_%02u", uGdpb), fhRawTotCh[ uGdpb ]);
fhChCount[ uGdpb ] = new TH1I( Form("ChCount_gDPB_%02u", uGdpb),
Form("Channel counts gDPB %02u; channel; Hits", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb );
// fHM->Add( Form("ChCount_gDPB_%02u", uGdpb), fhChCount[ uGdpb ]);
/*
fhRawTotCh.resize(fuNrOfGdpbs);
fhChCount.resize(fuNrOfGdpbs);
fhChanCoinc.resize(fuNrOfGdpbs * fuNrOfFebsPerGdpb / 2);
for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb++) {
fhRawTotCh[uGdpb] = new TH2F(Form("Raw_Tot_gDPB_%02u", uGdpb), Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb, 256, 0., 256.);
// fHM->Add( Form("Raw_Tot_gDPB_%02u", uGdpb), fhRawTotCh[ uGdpb ]);
fhChCount[uGdpb] =
new TH1I(Form("ChCount_gDPB_%02u", uGdpb), Form("Channel counts gDPB %02u; channel; Hits", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb);
// fHM->Add( Form("ChCount_gDPB_%02u", uGdpb), fhChCount[ uGdpb ]);
/*
for( UInt_t uLeftFeb = uGdpb*fuNrOfFebsPerGdpb / 2;
uLeftFeb < (uGdpb + 1 )*fuNrOfFebsPerGdpb / 2;
++uLeftFeb )
......@@ -307,33 +289,28 @@ void CbmDeviceUnpackTofStar2018::CreateHistograms()
fuNrOfChannelsPerFeet, 0., fuNrOfChannelsPerFeet );
} // for( UInt_t uLeftFeb = 0; uLeftFeb < fuNrOfFebsPerGdpb / 2; uLeftFeb ++ )
*/
fhChanCoinc[ uGdpb ] = new TH2F( Form("fhChanCoinc_%02u", uGdpb),
Form("Channels Coincidence %02u; Left; Right", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb,
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb );
} // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++)
fhDetChanCoinc = new TH2F( "fhDetChanCoinc",
"Det Channels Coincidence; Left; Right",
32, 0., 32,
32, 0., 32 );
fhChanCoinc[uGdpb] =
new TH2F(Form("fhChanCoinc_%02u", uGdpb), Form("Channels Coincidence %02u; Left; Right", uGdpb),
fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb, fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb);
} // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++)
fhDetChanCoinc = new TH2F("fhDetChanCoinc", "Det Channels Coincidence; Left; Right", 32, 0., 32, 32, 0., 32);
}
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
bool CbmDeviceUnpackTofStar2018::HandleData(FairMQMessagePtr& msg, int /*index*/)
{
// Don't do anything with the data
// Maybe add an message counter which counts the incomming messages and add
// an output
// Don't do anything with the data
// Maybe add an message counter which counts the incomming messages and add
// an output
fNumMessages++;
LOG(info) << "Received message number "<< fNumMessages
<< " with size " << msg->GetSize();
LOG(info) << "Received message number " << fNumMessages << " with size " << msg->GetSize();
std::string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
fles::StorableTimeslice component{0};
fles::StorableTimeslice component {0};
inputArchive >> component;
CheckTimeslice(component);
......@@ -344,224 +321,191 @@ bool CbmDeviceUnpackTofStar2018::HandleData(FairMQMessagePtr& msg, int /*index*/
Bool_t CbmDeviceUnpackTofStar2018::DoUnpack(const fles::Timeslice& ts, size_t component)
{
LOG(debug) << "Timeslice contains " << ts.num_microslices(component)
<< " microslices of component " << component;
// Loop over microslices
Int_t iMessageType = -111;
size_t numCompMsInTs = ts.num_microslices(component);
for (size_t m = 0; m < numCompMsInTs; ++m)
{
// Jump some microslices if needed
// if( fuMsAcceptsPercent < m)
// continue;
// Ignore overlap ms if number defined by user
if( numCompMsInTs - fuOverlapMsNb <= m )
continue;
constexpr uint32_t kuBytesPerMessage = 8;
auto msDescriptor = ts.descriptor(component, m);
fEquipmentId = msDescriptor.eq_id;
fdMsIndex = static_cast<double>(msDescriptor.idx);
const uint8_t* msContent = reinterpret_cast< const uint8_t* >( ts.content(component, m) );
uint32_t size = msDescriptor.size;
if( 0 < size )
LOG(debug) << "Microslice "<< m <<": " << fdMsIndex
<< " has size: " << size;
// If not integer number of message in input buffer, print warning/error
if( 0 != (size % kuBytesPerMessage) )
LOG(error) << "The input microslice buffer does NOT "
<< "contain only complete nDPB messages!";
// If not integer number of message in input buffer, print warning/error
if( 0 != (size % kuBytesPerMessage) )
LOG(error) << "The input microslice buffer does NOT "
<< "contain only complete nDPB messages!";
// Compute the number of complete messages in the input microslice buffer
uint32_t uNbMessages = (size - (size % kuBytesPerMessage) )
/ kuBytesPerMessage;
// Prepare variables for the loop on contents
const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent );
for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++)
{
// Fill message
uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] );
ngdpb::Message mess( ulData );
LOG(debug) << "Timeslice contains " << ts.num_microslices(component) << " microslices of component " << component;
/*
if( gLogger->IsLogNeeded(fair::mq::logger::DEBUG) )
{
mess.printDataCout();
} // if( gLogger->IsLogNeeded(fair::mq::logger::DEBUG) )
*/
// Loop over microslices
Int_t iMessageType = -111;
size_t numCompMsInTs = ts.num_microslices(component);
for (size_t m = 0; m < numCompMsInTs; ++m) {
// Jump some microslices if needed
// if( fuMsAcceptsPercent < m)
// continue;
// Increment counter for different message types
iMessageType = mess.getMessageType();
fMsgCounter[ iMessageType ]++;
// Ignore overlap ms if number defined by user
if (numCompMsInTs - fuOverlapMsNb <= m) continue;
fuGdpbId = mess.getRocNumber();
fuGdpbNr = fGdpbIdIndexMap[ fuGdpbId ];
constexpr uint32_t kuBytesPerMessage = 8;
fuGet4Id = mess.getGdpbGenChipId();
fuGet4Nr = (fuGdpbNr * fuNrOfGet4PerGdpb) + fuGet4Id;
auto msDescriptor = ts.descriptor(component, m);
fEquipmentId = msDescriptor.eq_id;
fdMsIndex = static_cast<double>(msDescriptor.idx);
const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m));
if( fuNrOfGet4PerGdpb <= fuGet4Id &&
ngdpb::MSG_STAR_TRI != iMessageType &&
( get4v1x::kuChipIdMergedEpoch != fuGet4Id ||
kFALSE == fbMergedEpochsOn ) )
{
LOG(warn) << "Message with Get4 ID too high: " << fuGet4Id
<< " VS " << fuNrOfGet4PerGdpb << " set in parameters, message ignored";
continue;
}
uint32_t size = msDescriptor.size;
if (0 < size) LOG(debug) << "Microslice " << m << ": " << fdMsIndex << " has size: " << size;
switch( mess.getMessageType() )
{
case ngdpb::MSG_HIT:
case ngdpb::MSG_EPOCH:
case ngdpb::MSG_GET4:
{
if( fbGet4M24b )
FillHitInfo(mess);
else PrintGenInfo(mess);
break;
} // case old non tof messages
case ngdpb::MSG_EPOCH2:
{
if( get4v1x::kuChipIdMergedEpoch == fuGet4Id &&
kTRUE == fbMergedEpochsOn )
{
for( uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGet4Index ++ )
{
fuGet4Id = uGet4Index;
fuGet4Nr = (fuGdpbNr * fuNrOfGet4PerGdpb) + fuGet4Id;
ngdpb::Message tmpMess( mess );
tmpMess.setGdpbGenChipId( uGet4Index );
// fHistGet4MessType->Fill(uGet4Index, ngdpb::GET4_32B_EPOCH);
FillEpochInfo( tmpMess );
} // for( uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGetIndex ++ )
} // if this epoch message is a merged one valiud for all chips
else
{
// fHistGet4MessType->Fill( fuGet4Nr, ngdpb::GET4_32B_EPOCH );
FillEpochInfo(mess);
} // if single chip epoch message
break;
} // case ngdpb::MSG_EPOCH2:
case ngdpb::MSG_GET4_32B:
{
if( fbEpochSuppModeOn )
{
fvmEpSupprBuffer[ fuGet4Nr ].push_back( mess );
LOG(debug) << "Add 32B message from Gdpb " << fuGdpbNr << " to EpSupprBuffer of Get4 "
<< fuGet4Nr << " size " << fvmEpSupprBuffer[ fuGet4Nr ].size();
}
else FillHitInfo(mess);
break;
} // case ngdpb::MSG_GET4_32B:
case ngdpb::MSG_GET4_SLC:
{
PrintSlcInfo(mess);
break;
} // case ngdpb::MSG_GET4_SLC:
case ngdpb::MSG_GET4_SYS:
{
if(100 > iMess++)
PrintSysInfo(mess);
break;
} // case ngdpb::MSG_GET4_SYS:
case ngdpb::MSG_STAR_TRI:
{
FillStarTrigInfo(mess);
break;
} // case ngdpb::MSG_STAR_TRI:
default:
{
if(100 > iMess++)
LOG(error) << "Message ("<<iMess<<") type " << std::hex << std::setw(2)
<< static_cast< uint16_t >( mess.getMessageType() )
<< " not included in Get4 unpacker.";
if(100 == iMess)
LOG(error) << "Stop reporting MSG errors... ";
} // default:
} // switch( mess.getMessageType() )
// If not integer number of message in input buffer, print warning/error
if (0 != (size % kuBytesPerMessage))
LOG(error) << "The input microslice buffer does NOT "
<< "contain only complete nDPB messages!";
// If not integer number of message in input buffer, print warning/error
if (0 != (size % kuBytesPerMessage))
LOG(error) << "The input microslice buffer does NOT "
<< "contain only complete nDPB messages!";
} // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++)
// Compute the number of complete messages in the input microslice buffer
uint32_t uNbMessages = (size - (size % kuBytesPerMessage)) / kuBytesPerMessage;
// Prepare variables for the loop on contents
const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>(msContent);
for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
// Fill message
uint64_t ulData = static_cast<uint64_t>(pInBuff[uIdx]);
ngdpb::Message mess(ulData);
/*
if(fair::Logger::Logging(fair::Severity::debug)
{
mess.printDataCout();
}
*/
} // for (size_t m = 0; m < numCompMsInTs; ++m)
// Increment counter for different message types
iMessageType = mess.getMessageType();
fMsgCounter[iMessageType]++;
fuGdpbId = mess.getRocNumber();
fuGdpbNr = fGdpbIdIndexMap[fuGdpbId];
fuGet4Id = mess.getGdpbGenChipId();
fuGet4Nr = (fuGdpbNr * fuNrOfGet4PerGdpb) + fuGet4Id;
if (fuNrOfGet4PerGdpb <= fuGet4Id && ngdpb::MSG_STAR_TRI != iMessageType
&& (get4v1x::kuChipIdMergedEpoch != fuGet4Id || kFALSE == fbMergedEpochsOn)) {
LOG(warn) << "Message with Get4 ID too high: " << fuGet4Id << " VS " << fuNrOfGet4PerGdpb
<< " set in parameters, message ignored";
continue;
}
switch (mess.getMessageType()) {
case ngdpb::MSG_HIT:
case ngdpb::MSG_EPOCH:
case ngdpb::MSG_GET4: {
if (fbGet4M24b) FillHitInfo(mess);
else
PrintGenInfo(mess);
break;
} // case old non tof messages
case ngdpb::MSG_EPOCH2: {
if (get4v1x::kuChipIdMergedEpoch == fuGet4Id && kTRUE == fbMergedEpochsOn) {
for (uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGet4Index++) {
fuGet4Id = uGet4Index;
fuGet4Nr = (fuGdpbNr * fuNrOfGet4PerGdpb) + fuGet4Id;
ngdpb::Message tmpMess(mess);
tmpMess.setGdpbGenChipId(uGet4Index);
// fHistGet4MessType->Fill(uGet4Index, ngdpb::GET4_32B_EPOCH);
FillEpochInfo(tmpMess);
} // for( uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGetIndex ++ )
} // if this epoch message is a merged one valiud for all chips
else {
// fHistGet4MessType->Fill( fuGet4Nr, ngdpb::GET4_32B_EPOCH );
FillEpochInfo(mess);
} // if single chip epoch message
break;
} // case ngdpb::MSG_EPOCH2:
case ngdpb::MSG_GET4_32B: {
if (fbEpochSuppModeOn) {
fvmEpSupprBuffer[fuGet4Nr].push_back(mess);
LOG(debug) << "Add 32B message from Gdpb " << fuGdpbNr << " to EpSupprBuffer of Get4 " << fuGet4Nr
<< " size " << fvmEpSupprBuffer[fuGet4Nr].size();
}
else
FillHitInfo(mess);
break;
} // case ngdpb::MSG_GET4_32B:
case ngdpb::MSG_GET4_SLC: {
PrintSlcInfo(mess);
break;
} // case ngdpb::MSG_GET4_SLC:
case ngdpb::MSG_GET4_SYS: {
if (100 > iMess++) PrintSysInfo(mess);
break;
} // case ngdpb::MSG_GET4_SYS:
case ngdpb::MSG_STAR_TRI: {
FillStarTrigInfo(mess);
break;
} // case ngdpb::MSG_STAR_TRI:
default: {
if (100 > iMess++)
LOG(error) << "Message (" << iMess << ") type " << std::hex << std::setw(2)
<< static_cast<uint16_t>(mess.getMessageType()) << " not included in Get4 unpacker.";
if (100 == iMess) LOG(error) << "Stop reporting MSG errors... ";
} // default:
} // switch( mess.getMessageType() )
} // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++)
} // for (size_t m = 0; m < numCompMsInTs; ++m)
return kTRUE;
}
void CbmDeviceUnpackTofStar2018::FillHitInfo( ngdpb::Message mess )
void CbmDeviceUnpackTofStar2018::FillHitInfo(ngdpb::Message mess)
{
// --- Get absolute time, GET4 ID and channel number
UInt_t uGet4Id = mess.getGdpbGenChipId();
UInt_t uChannel = mess.getGdpbHitChanId();
UInt_t uTot = mess.getGdpbHit32Tot();
// UInt_t uFts = mess.getGdpbHitFineTs();
ULong_t ulCurEpochGdpbGet4 = fvulCurrentEpoch[ fuGet4Nr ];
if( kTRUE == fvbFirstEpochSeen[ fuGet4Nr ] )
{
// In Ep. Suppr. Mode, receive following epoch instead of previous
if( 0 < ulCurEpochGdpbGet4 )
ulCurEpochGdpbGet4 --;
else ulCurEpochGdpbGet4 = get4v1x::kuEpochCounterSz; // Catch epoch cycle!
// ULong_t ulhitTime;
Double_t dHitTime;
if( fbGet4v20 )
{
// ulhitTime = mess.getMsgG4v2FullTime( ulCurEpochGdpbGet4 );
dHitTime = mess.getMsgG4v2FullTimeD( ulCurEpochGdpbGet4 );
// --- Get absolute time, GET4 ID and channel number
UInt_t uGet4Id = mess.getGdpbGenChipId();
UInt_t uChannel = mess.getGdpbHitChanId();
UInt_t uTot = mess.getGdpbHit32Tot();
// UInt_t uFts = mess.getGdpbHitFineTs();
ULong_t ulCurEpochGdpbGet4 = fvulCurrentEpoch[fuGet4Nr];
if (kTRUE == fvbFirstEpochSeen[fuGet4Nr]) {
// In Ep. Suppr. Mode, receive following epoch instead of previous
if (0 < ulCurEpochGdpbGet4) ulCurEpochGdpbGet4--;
else
ulCurEpochGdpbGet4 = get4v1x::kuEpochCounterSz; // Catch epoch cycle!
// ULong_t ulhitTime;
Double_t dHitTime;
if (fbGet4v20) {
// ulhitTime = mess.getMsgG4v2FullTime( ulCurEpochGdpbGet4 );
dHitTime = mess.getMsgG4v2FullTimeD(ulCurEpochGdpbGet4);
// In 32b mode the coarse counter is already computed back to 112 FTS bins
// => need to hide its contribution from the Finetime
// => FTS = Fullt TS modulo 112
// if( !fbGet4M24b )
// uFts = mess.getGdpbHitFullTs() % 112;
} // if( fbGet4v20 )
else
{
// ulhitTime = mess.getMsgFullTime(ulCurEpochGdpbGet4);
dHitTime = mess.getMsgFullTimeD(ulCurEpochGdpbGet4);
} // else of if( fbGet4v20 )
// if( !fbGet4M24b )
// uFts = mess.getGdpbHitFullTs() % 112;
} // if( fbGet4v20 )
else {
// ulhitTime = mess.getMsgFullTime(ulCurEpochGdpbGet4);
dHitTime = mess.getMsgFullTimeD(ulCurEpochGdpbGet4);
} // else of if( fbGet4v20 )
Double_t dHitTot = uTot; // in bins
Double_t dHitTot = uTot; // in bins
// UInt_t uFebIdx = (uGet4Id / fuNrOfGet4PerFeb);
// UInt_t uFullFebIdx = (fuGdpbNr * fuNrOfFebsPerGdpb) + uFebIdx;
// UInt_t uFebIdx = (uGet4Id / fuNrOfGet4PerFeb);
// UInt_t uFullFebIdx = (fuGdpbNr * fuNrOfFebsPerGdpb) + uFebIdx;
UInt_t uChanInGdpb = uGet4Id * fuNrOfChannelsPerGet4 + uChannel;
Int_t uChanInSyst = fuGdpbNr * fuNrOfChannelsPerGdpb + uChanInGdpb;
if( fUnpackPar->GetNumberOfChannels() < uChanInSyst )
{
LOG(error) << "Invalid mapping index " << uChanInSyst
<< " VS " << fUnpackPar->GetNumberOfChannels()
<<", from " << fuGdpbNr
<<", " << uGet4Id
<<", " << uChannel;
return;
} // if( fUnpackPar->GetNumberOfChannels() < uChanUId )
UInt_t uChanInGdpb = uGet4Id * fuNrOfChannelsPerGet4 + uChannel;
Int_t uChanInSyst = fuGdpbNr * fuNrOfChannelsPerGdpb + uChanInGdpb;
if (fUnpackPar->GetNumberOfChannels() < uChanInSyst) {
LOG(error) << "Invalid mapping index " << uChanInSyst << " VS " << fUnpackPar->GetNumberOfChannels() << ", from "
<< fuGdpbNr << ", " << uGet4Id << ", " << uChannel;
return;
} // if( fUnpackPar->GetNumberOfChannels() < uChanUId )
fvbChanThere[ uChanInSyst ] = kTRUE;
fvbChanThere[uChanInSyst] = kTRUE;
UInt_t uChanUId = fUnpackPar->GetChannelToDetUIdMap( uChanInSyst );
if( 0 == uChanUId )
return; // Hit not mapped to digi
UInt_t uChanUId = fUnpackPar->GetChannelToDetUIdMap(uChanInSyst);
if (0 == uChanUId) return; // Hit not mapped to digi
/*
/*
if( (uChanUId & DetMask) == 0x00001006 )
{
UInt_t uDetChan = (uChanUId & 0xFF000000) >> 24;
......@@ -571,60 +515,56 @@ void CbmDeviceUnpackTofStar2018::FillHitInfo( ngdpb::Message mess )
fbDetChanThere[ uDetChan ] = kTRUE;
} // if( (uChanUId & DetMask) == 0x00001006 )
*/
// fhRawDigiLastDigi->Fill( dHitTime - fdLastDigiTime );
// fhRawDigiLastDigi->Fill( dHitTime - fdLastDigiTime );
if( (uChanUId & DetMask) != 0x00005006 ) dHitTime += fdTShiftRef;
fdLastDigiTime = dHitTime;
if ((uChanUId & DetMask) != 0x00005006) dHitTime += fdTShiftRef;
fdLastDigiTime = dHitTime;
LOG(debug) << Form("Insert 0x%08x digi with time ", uChanUId ) << dHitTime << Form(", Tot %4.0f",dHitTot)
<< " into buffer with " << fBuffer->GetSize() << " data from "
<< Form("%11.1f to %11.1f ", fBuffer->GetTimeFirst(), fBuffer->GetTimeLast())
<< " at epoch " << ulCurEpochGdpbGet4;
LOG(debug) << Form("Insert 0x%08x digi with time ", uChanUId) << dHitTime << Form(", Tot %4.0f", dHitTot)
<< " into buffer with " << fBuffer->GetSize() << " data from "
<< Form("%11.1f to %11.1f ", fBuffer->GetTimeFirst(), fBuffer->GetTimeLast()) << " at epoch "
<< ulCurEpochGdpbGet4;
fDigi = new CbmTofDigiExp(uChanUId, dHitTime, dHitTot);
fDigi = new CbmTofDigiExp(uChanUId, dHitTime, dHitTot);
fBuffer->InsertData<CbmTofDigiExp>(fDigi);
fBuffer->InsertData<CbmTofDigiExp>(fDigi);
// Histograms filling
fhRawTotCh[ fuGdpbNr ]->Fill( uChanInGdpb, dHitTot);
fhChCount[ fuGdpbNr ] ->Fill( uChanInGdpb );
// Histograms filling
fhRawTotCh[fuGdpbNr]->Fill(uChanInGdpb, dHitTot);
fhChCount[fuGdpbNr]->Fill(uChanInGdpb);
} // if( kTRUE == fvbFirstEpochSeen[ fuGet4Nr ] )
} // if( kTRUE == fvbFirstEpochSeen[ fuGet4Nr ] )
}
void CbmDeviceUnpackTofStar2018::FillEpochInfo( ngdpb::Message mess )
void CbmDeviceUnpackTofStar2018::FillEpochInfo(ngdpb::Message mess)
{
ULong64_t ulEpochNr = mess.getGdpbEpEpochNb();
ULong64_t ulEpochNr = mess.getGdpbEpEpochNb();
// LOG(debug) << "Get4Nr "<<fuGet4Nr<< " in epoch "<<ulEpochNr;
// LOG(debug) << "Get4Nr "<<fuGet4Nr<< " in epoch "<<ulEpochNr;
fvulCurrentEpoch[ fuGet4Nr ] = ulEpochNr;
fvulCurrentEpoch[fuGet4Nr] = ulEpochNr;
if( kFALSE == fvbFirstEpochSeen[ fuGet4Nr ] )
fvbFirstEpochSeen[ fuGet4Nr ] = kTRUE;
if (kFALSE == fvbFirstEpochSeen[fuGet4Nr]) fvbFirstEpochSeen[fuGet4Nr] = kTRUE;
fulCurrentEpochTime = mess.getMsgFullTime(ulEpochNr);
fNofEpochs++;
fulCurrentEpochTime = mess.getMsgFullTime(ulEpochNr);
fNofEpochs++;
/// In Ep. Suppr. Mode, receive following epoch instead of previous
/// Re-align the epoch number of the message in case it will be used later:
/// We received the epoch after the data instead of the one before!
if( 0 < ulEpochNr )
mess.setEpoch2Number( ulEpochNr - 1 );
else mess.setEpoch2Number( get4v1x::kuEpochCounterSz );
/// In Ep. Suppr. Mode, receive following epoch instead of previous
/// Re-align the epoch number of the message in case it will be used later:
/// We received the epoch after the data instead of the one before!
if (0 < ulEpochNr) mess.setEpoch2Number(ulEpochNr - 1);
else
mess.setEpoch2Number(get4v1x::kuEpochCounterSz);
Int_t iBufferSize = fvmEpSupprBuffer[ fuGet4Nr ].size();
if( 0 < iBufferSize )
{
LOG(debug) << "Now processing "<<iBufferSize<<" stored messages for get4 "
<< fuGet4Nr << " with epoch number "
<< (fvulCurrentEpoch[ fuGet4Nr ] - 1);
Int_t iBufferSize = fvmEpSupprBuffer[fuGet4Nr].size();
if (0 < iBufferSize) {
LOG(debug) << "Now processing " << iBufferSize << " stored messages for get4 " << fuGet4Nr << " with epoch number "
<< (fvulCurrentEpoch[fuGet4Nr] - 1);
for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ )
{
FillHitInfo( fvmEpSupprBuffer[ fuGet4Nr ][ iMsgIdx ] );
} // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ )
/*
for (Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++) {
FillHitInfo(fvmEpSupprBuffer[fuGet4Nr][iMsgIdx]);
} // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ )
/*
for( UInt_t uLeftFeb = fuGdpbNr * fuNrOfFebsPerGdpb / 2;
uLeftFeb < (fuGdpbNr + 1) * fuNrOfFebsPerGdpb / 2;
++uLeftFeb )
......@@ -648,14 +588,14 @@ void CbmDeviceUnpackTofStar2018::FillEpochInfo( ngdpb::Message mess )
}
} // for( UInt_t uLeftFeb = 0; uLeftFeb < fuNrOfFebsPerGdpb / 2; ++uLeftFeb )
*/
fvmEpSupprBuffer[fuGet4Nr].clear();
} // if( 0 < fvmEpSupprBuffer[fGet4Nr] )
fvmEpSupprBuffer[fuGet4Nr].clear();
} // if( 0 < fvmEpSupprBuffer[fGet4Nr] )
}
void CbmDeviceUnpackTofStar2018::PrintSlcInfo(ngdpb::Message /*mess*/)
{
/// Nothing to do, maybe later use it to trakc parameter changes like treshold?
/*
/// Nothing to do, maybe later use it to trakc parameter changes like treshold?
/*
if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) )
LOG(info) << "GET4 Slow Control message, epoch " << static_cast<Int_t>(fCurrentEpoch[rocId][get4Id])
<< ", time " << std::setprecision(9) << std::fixed
......@@ -672,46 +612,36 @@ void CbmDeviceUnpackTofStar2018::PrintSlcInfo(ngdpb::Message /*mess*/)
void CbmDeviceUnpackTofStar2018::PrintGenInfo(ngdpb::Message mess)
{
Int_t mType = mess.getMessageType();
Int_t rocId = mess.getRocNumber();
Int_t get4Id = mess.getGdpbGenChipId();
Int_t channel = mess.getGdpbHitChanId();
uint64_t uData = mess.getData();
if(100 > iMess++)
LOG(info) << "Get4 MSG type "<<mType<<" from rocId "<<rocId<<", getId "<<get4Id
<< ", (hit channel) "<<channel<<Form(" hex data %0lx ",uData);
Int_t mType = mess.getMessageType();
Int_t rocId = mess.getRocNumber();
Int_t get4Id = mess.getGdpbGenChipId();
Int_t channel = mess.getGdpbHitChanId();
uint64_t uData = mess.getData();
if (100 > iMess++)
LOG(info) << "Get4 MSG type " << mType << " from rocId " << rocId << ", getId " << get4Id << ", (hit channel) "
<< channel << Form(" hex data %0lx ", uData);
}
void CbmDeviceUnpackTofStar2018::PrintSysInfo(ngdpb::Message mess)
{
LOG(info) << "GET4 System message, epoch " << (fvulCurrentEpoch[ fuGet4Nr])
<< ", time " << std::setprecision(9) << std::fixed
<< Double_t(fulCurrentEpochTime) * 1.e-9 << " s "
<< " for board ID " << std::hex << std::setw(4) << fuGdpbId << std::dec;
switch( mess.getGdpbSysSubType() )
{
case ngdpb::SYSMSG_GET4_EVENT:
{
LOG(info) << " +++++++ > Chip = " << std::setw(2) << mess.getGdpbGenChipId()
<< ", Chan = " << std::setw(1) << mess.getGdpbSysErrChanId()
<< ", Edge = " << std::setw(1) << mess.getGdpbSysErrEdge()
<< ", Empt = " << std::setw(1) << mess.getGdpbSysErrUnused()
<< ", Data = " << std::hex << std::setw(2) << mess.getGdpbSysErrData() << std::dec
<< " -- GET4 V1 Error Event";
break;
} //
case ngdpb::SYSMSG_CLOSYSYNC_ERROR:
LOG(info) << "Closy synchronization error";
break;
case ngdpb::SYSMSG_TS156_SYNC:
LOG(info) << "156.25MHz timestamp reset";
break;
case ngdpb::SYSMSG_GDPB_UNKWN:
LOG(info) << "Unknown GET4 message, data: " << std::hex << std::setw(8)
<< mess.getGdpbSysUnkwData() << std::dec;
break;
} // switch( getGdpbSysSubType() )
LOG(info) << "GET4 System message, epoch " << (fvulCurrentEpoch[fuGet4Nr]) << ", time " << std::setprecision(9)
<< std::fixed << Double_t(fulCurrentEpochTime) * 1.e-9 << " s "
<< " for board ID " << std::hex << std::setw(4) << fuGdpbId << std::dec;
switch (mess.getGdpbSysSubType()) {
case ngdpb::SYSMSG_GET4_EVENT: {
LOG(info) << " +++++++ > Chip = " << std::setw(2) << mess.getGdpbGenChipId() << ", Chan = " << std::setw(1)
<< mess.getGdpbSysErrChanId() << ", Edge = " << std::setw(1) << mess.getGdpbSysErrEdge()
<< ", Empt = " << std::setw(1) << mess.getGdpbSysErrUnused() << ", Data = " << std::hex << std::setw(2)
<< mess.getGdpbSysErrData() << std::dec << " -- GET4 V1 Error Event";
break;
} //
case ngdpb::SYSMSG_CLOSYSYNC_ERROR: LOG(info) << "Closy synchronization error"; break;
case ngdpb::SYSMSG_TS156_SYNC: LOG(info) << "156.25MHz timestamp reset"; break;
case ngdpb::SYSMSG_GDPB_UNKWN:
LOG(info) << "Unknown GET4 message, data: " << std::hex << std::setw(8) << mess.getGdpbSysUnkwData() << std::dec;
break;
} // switch( getGdpbSysSubType() )
}
void CbmDeviceUnpackTofStar2018::FillStarTrigInfo(ngdpb::Message mess)
......@@ -720,41 +650,30 @@ void CbmDeviceUnpackTofStar2018::FillStarTrigInfo(ngdpb::Message mess)
//mess.printDataCout();
switch( iMsgIndex )
{
case 0:
fulGdpbTsMsb = mess.getGdpbTsMsbStarA();
break;
case 1:
fulGdpbTsLsb = mess.getGdpbTsLsbStarB();
fulStarTsMsb = mess.getStarTsMsbStarB();
break;
case 2:
fulStarTsMid = mess.getStarTsMidStarC();
break;
case 3:
{
ULong64_t ulNewGdpbTsFull = ( fulGdpbTsMsb << 24 )
+ ( fulGdpbTsLsb );
ULong64_t ulNewStarTsFull = ( fulStarTsMsb << 48 )
+ ( fulStarTsMid << 8 )
+ mess.getStarTsLsbStarD();
UInt_t uNewToken = mess.getStarTokenStarD();
UInt_t uNewDaqCmd = mess.getStarDaqCmdStarD();
UInt_t uNewTrigCmd = mess.getStarTrigCmdStarD();
if( ( uNewToken == fuStarTokenLast ) && ( ulNewGdpbTsFull == fulGdpbTsFullLast ) &&
( ulNewStarTsFull == fulStarTsFullLast ) && ( uNewDaqCmd == fuStarDaqCmdLast ) &&
( uNewTrigCmd == fuStarTrigCmdLast ) )
{
LOG(debug) << "Possible error: identical STAR tokens found twice in a row => ignore 2nd! "
<< Form("token = %5u ", fuStarTokenLast )
<< Form("gDPB ts = %12llu ", fulGdpbTsFullLast )
<< Form("STAR ts = %12llu ", fulStarTsFullLast )
<< Form("DAQ cmd = %2u ", fuStarDaqCmdLast )
<< Form("TRG cmd = %2u ", fuStarTrigCmdLast );
return;
} // if exactly same message repeated
/*
switch (iMsgIndex) {
case 0: fulGdpbTsMsb = mess.getGdpbTsMsbStarA(); break;
case 1:
fulGdpbTsLsb = mess.getGdpbTsLsbStarB();
fulStarTsMsb = mess.getStarTsMsbStarB();
break;
case 2: fulStarTsMid = mess.getStarTsMidStarC(); break;
case 3: {
ULong64_t ulNewGdpbTsFull = (fulGdpbTsMsb << 24) + (fulGdpbTsLsb);
ULong64_t ulNewStarTsFull = (fulStarTsMsb << 48) + (fulStarTsMid << 8) + mess.getStarTsLsbStarD();
UInt_t uNewToken = mess.getStarTokenStarD();
UInt_t uNewDaqCmd = mess.getStarDaqCmdStarD();
UInt_t uNewTrigCmd = mess.getStarTrigCmdStarD();
if ((uNewToken == fuStarTokenLast) && (ulNewGdpbTsFull == fulGdpbTsFullLast)
&& (ulNewStarTsFull == fulStarTsFullLast) && (uNewDaqCmd == fuStarDaqCmdLast)
&& (uNewTrigCmd == fuStarTrigCmdLast)) {
LOG(debug) << "Possible error: identical STAR tokens found twice in a "
"row => ignore 2nd! "
<< Form("token = %5u ", fuStarTokenLast) << Form("gDPB ts = %12llu ", fulGdpbTsFullLast)
<< Form("STAR ts = %12llu ", fulStarTsFullLast) << Form("DAQ cmd = %2u ", fuStarDaqCmdLast)
<< Form("TRG cmd = %2u ", fuStarTrigCmdLast);
return;
} // if exactly same message repeated
/*
if( (uNewToken != fuStarTokenLast + 1) &&
0 < fulGdpbTsFullLast && 0 < fulStarTsFullLast &&
( 4095 != fuStarTokenLast || 1 != uNewToken) )
......@@ -765,56 +684,46 @@ void CbmDeviceUnpackTofStar2018::FillStarTrigInfo(ngdpb::Message mess)
<< Form("old = %2u vs new = %2u ", fuStarDaqCmdLast, uNewDaqCmd)
<< Form("old = %2u vs new = %2u ", fuStarTrigCmdLast, uNewTrigCmd);
*/
fulGdpbTsFullLast = ulNewGdpbTsFull;
fulStarTsFullLast = ulNewStarTsFull;
fuStarTokenLast = uNewToken;
fuStarDaqCmdLast = uNewDaqCmd;
fuStarTrigCmdLast = uNewTrigCmd;
Double_t dTot = 1.;
Double_t dTime = fulGdpbTsFullLast * 6.25;
if( 0. == fdFirstDigiTimeDif && 0. != fdLastDigiTime )
{
fdFirstDigiTimeDif = dTime - fdLastDigiTime;
LOG(info) << "Reference fake digi time shift initialized to " << fdFirstDigiTimeDif
<< ", default: " << fdTShiftRef;
} // if( 0. == fdFirstDigiTimeDif && 0. != fdLastDigiTime )
// dTime -= fdFirstDigiTimeDif;
// dTime += fdTShiftRef;
LOG(debug) << "Insert fake digi with time " << dTime << ", Tot " << dTot;
fhRawTRefDig0->Fill( dTime - fdLastDigiTime);
fhRawTRefDig1->Fill( dTime - fdLastDigiTime);
fDigi = new CbmTofDigiExp(0x00005006, dTime, dTot); // fake start counter signal
fBuffer->InsertData<CbmTofDigiExp>(fDigi);
break;
} // case 3
default:
LOG(error) << "Unknown Star Trigger messageindex: " << iMsgIndex;
} // switch( iMsgIndex )
}
CbmDeviceUnpackTofStar2018::~CbmDeviceUnpackTofStar2018()
{
fulGdpbTsFullLast = ulNewGdpbTsFull;
fulStarTsFullLast = ulNewStarTsFull;
fuStarTokenLast = uNewToken;
fuStarDaqCmdLast = uNewDaqCmd;
fuStarTrigCmdLast = uNewTrigCmd;
Double_t dTot = 1.;
Double_t dTime = fulGdpbTsFullLast * 6.25;
if (0. == fdFirstDigiTimeDif && 0. != fdLastDigiTime) {
fdFirstDigiTimeDif = dTime - fdLastDigiTime;
LOG(info) << "Reference fake digi time shift initialized to " << fdFirstDigiTimeDif
<< ", default: " << fdTShiftRef;
} // if( 0. == fdFirstDigiTimeDif && 0. != fdLastDigiTime )
// dTime -= fdFirstDigiTimeDif;
// dTime += fdTShiftRef;
LOG(debug) << "Insert fake digi with time " << dTime << ", Tot " << dTot;
fhRawTRefDig0->Fill(dTime - fdLastDigiTime);
fhRawTRefDig1->Fill(dTime - fdLastDigiTime);
fDigi = new CbmTofDigiExp(0x00005006, dTime, dTot); // fake start counter signal
fBuffer->InsertData<CbmTofDigiExp>(fDigi);
break;
} // case 3
default: LOG(error) << "Unknown Star Trigger messageindex: " << iMsgIndex;
} // switch( iMsgIndex )
}
CbmDeviceUnpackTofStar2018::~CbmDeviceUnpackTofStar2018() {}
void CbmDeviceUnpackTofStar2018::PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc)
{
LOG(info) << "Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id)
<< std::dec;
LOG(info) << "Header version: Ox" << std::hex << static_cast<int>(mdsc.hdr_ver)
<< std::dec;
LOG(info) << "Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id) << std::dec;
LOG(info) << "Header version: Ox" << std::hex << static_cast<int>(mdsc.hdr_ver) << std::dec;
LOG(info) << "Equipement ID: " << mdsc.eq_id;
LOG(info) << "Flags: " << mdsc.flags;
LOG(info) << "Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id)
<< std::dec;
LOG(info) << "Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver)
<< std::dec;
LOG(info) << "Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id) << std::dec;
LOG(info) << "Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver) << std::dec;
LOG(info) << "Microslice Idx: " << mdsc.idx;
LOG(info) << "Checksum: " << mdsc.crc;
LOG(info) << "Size: " << mdsc.size;
......@@ -823,22 +732,18 @@ void CbmDeviceUnpackTofStar2018::PrintMicroSliceDescriptor(const fles::Microslic
bool CbmDeviceUnpackTofStar2018::CheckTimeslice(const fles::Timeslice& ts)
{
if ( 0 == ts.num_components() ) {
if (0 == ts.num_components()) {
LOG(error) << "No Component in TS " << ts.index();
return 1;
}
LOG(info) << "Found " << ts.num_components()
<< " different components in timeslice";
LOG(info) << "Found " << ts.num_components() << " different components in timeslice";
for (size_t c = 0; c < ts.num_components(); ++c) {
LOG(info) << "Found " << ts.num_microslices(c)
<< " microslices in component " << c;
LOG(info) << "Component " << c << " has a size of "
<< ts.size_component(c) << " bytes";
LOG(info) << "Sys ID: Ox" << std::hex << static_cast<int>(ts.descriptor(0,0).sys_id)
<< std::dec;
/*
LOG(info) << "Found " << ts.num_microslices(c) << " microslices in component " << c;
LOG(info) << "Component " << c << " has a size of " << ts.size_component(c) << " bytes";
LOG(info) << "Sys ID: Ox" << std::hex << static_cast<int>(ts.descriptor(0, 0).sys_id) << std::dec;
/*
for (size_t m = 0; m < ts.num_microslices(c); ++m) {
PrintMicroSliceDescriptor(ts.descriptor(c,m));
}
......
/* Copyright (C) 2018 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig [committer] */
/**
* CbmDeviceUnpackTofStar2018.h
*
......@@ -8,18 +12,20 @@
#ifndef CBMDEVICEUNPACKTOFSTAR2018_H_
#define CBMDEVICEUNPACKTOFSTAR2018_H_
#include "FairMQDevice.h"
#include "CbmMqTMessage.h"
#include "rocMess_wGet4v1.h"
#include "Timeslice.hpp"
#include "MicrosliceDescriptor.hpp"
#include "Timeslice.hpp"
#include "FairMQDevice.h"
#include "TMessage.h"
#include "Rtypes.h"
#include "TMessage.h"
#include <vector>
#include <map>
#include <vector>
#include "rocMess_wGet4v1.h"
class CbmTofUnpackPar;
class CbmTbDaqBuffer;
......@@ -28,142 +34,124 @@ class CbmTofDigiExp;
class TH1;
class TH2;
class CbmDeviceUnpackTofStar2018: public FairMQDevice
{
public:
CbmDeviceUnpackTofStar2018();
virtual ~CbmDeviceUnpackTofStar2018();
class CbmDeviceUnpackTofStar2018 : public FairMQDevice {
public:
CbmDeviceUnpackTofStar2018();
virtual ~CbmDeviceUnpackTofStar2018();
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
private:
uint64_t fNumMessages;
private:
uint64_t fNumMessages;
std::vector<std::string> fAllowedChannels
= {"tofcomponent","parameters"};
std::vector<std::string> fAllowedChannels = {"tofcomponent", "parameters"};
size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/
size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/
UInt_t fuMinNbGdpb;
UInt_t fuCurrNbGdpb;
size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/
size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/
UInt_t fuMinNbGdpb;
UInt_t fuCurrNbGdpb;
UInt_t fuNrOfGdpbs; // Total number of GDPBs in the system
UInt_t fuNrOfFebsPerGdpb; // Number of FEBs per GDPB
UInt_t fuNrOfGet4PerFeb; // Number of GET4s per FEB
UInt_t fuNrOfChannelsPerGet4; // Number of channels in each GET4
UInt_t fuNrOfGdpbs; // Total number of GDPBs in the system
UInt_t fuNrOfFebsPerGdpb; // Number of FEBs per GDPB
UInt_t fuNrOfGet4PerFeb; // Number of GET4s per FEB
UInt_t fuNrOfChannelsPerGet4; // Number of channels in each GET4
UInt_t fuNrOfChannelsPerFeet; // Number of channels in each FEET
UInt_t fuNrOfGet4; // Total number of Get4 chips in the system
UInt_t fuNrOfGet4PerGdpb; // Number of GET4s per GDPB
UInt_t fuNrOfChannelsPerGdpb; // Number of channels per GDPB
UInt_t fuNrOfChannelsPerFeet; // Number of channels in each FEET
UInt_t fuNrOfGet4; // Total number of Get4 chips in the system
UInt_t fuNrOfGet4PerGdpb; // Number of GET4s per GDPB
UInt_t fuNrOfChannelsPerGdpb; // Number of channels per GDPB
std::vector<int> fMsgCounter;
std::map<UInt_t, UInt_t> fGdpbIdIndexMap;
std::vector<int> fMsgCounter;
std::map<UInt_t, UInt_t> fGdpbIdIndexMap;
UInt_t fuGdpbId; // Id (hex number) of the GDPB for current message
UInt_t fuGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB for current message
UInt_t fuGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message
UInt_t fuGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system for current message
UInt_t fuGdpbId; // Id (hex number) of the GDPB for current message
UInt_t fuGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB for current message
UInt_t fuGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message
UInt_t fuGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system for current message
// CbmHistManager* fHM; ///< Histogram manager
// CbmHistManager* fHM; ///< Histogram manager
/** Current epoch marker for each GDPB and GET4
/** Current epoch marker for each GDPB and GET4
* (first epoch in the stream initializes the map item)
* pointer points to an array of size fNrOfGdpbs * fNrOfGet4PerGdpb
* The correct array index is calculated using the function
* GetArrayIndex(gdpbId, get4Id)
**/
std::vector< ULong64_t > fvulCurrentEpoch; //!
std::vector< Bool_t > fvbFirstEpochSeen; //!
Int_t fNofEpochs; /** Current epoch marker for each ROC **/
ULong64_t fulCurrentEpochTime; /** Time stamp of current epoch **/
Int_t fEquipmentId;
Double_t fdMsIndex;
Double_t fdTShiftRef;
Bool_t fbEpochSuppModeOn;
Bool_t fbGet4M24b;
Bool_t fbGet4v20;
Bool_t fbMergedEpochsOn;
CbmTofDigiExp* fDigi;
CbmTofUnpackPar* fUnpackPar; //!
// Variables used for histo filling
Double_t fdRefTime;
Double_t fdLastDigiTime;
Double_t fdFirstDigiTimeDif;
Double_t fdEvTime0;
TH1* fhRawTDigEvT0;
TH1* fhRawTDigRef0;
TH1* fhRawTDigRef;
TH1* fhRawTRefDig0;
TH1* fhRawTRefDig1;
TH1* fhRawDigiLastDigi;
std::vector< TH2* > fhRawTotCh;
std::vector< TH1* > fhChCount;
std::vector< Bool_t > fvbChanThere;
std::vector< TH2* > fhChanCoinc;
Bool_t fbDetChanThere[64];
TH2* fhDetChanCoinc;
std::vector< std::vector < ngdpb::Message > > fvmEpSupprBuffer;
CbmTbDaqBuffer* fBuffer;
ULong64_t fulGdpbTsMsb;
ULong64_t fulGdpbTsLsb;
ULong64_t fulStarTsMsb;
ULong64_t fulStarTsMid;
ULong64_t fulGdpbTsFullLast;
ULong64_t fulStarTsFullLast;
UInt_t fuStarTokenLast;
UInt_t fuStarDaqCmdLast;
UInt_t fuStarTrigCmdLast;
bool CheckTimeslice(const fles::Timeslice& ts);
void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc);
bool IsChannelNameAllowed(std::string channelName);
Bool_t InitContainers();
Bool_t ReInitContainers();
void CreateHistograms();
void FillHitInfo(ngdpb::Message);
void FillStarTrigInfo(ngdpb::Message);
void FillEpochInfo(ngdpb::Message);
void PrintSlcInfo(ngdpb::Message);
void PrintSysInfo(ngdpb::Message);
void PrintGenInfo(ngdpb::Message);
Bool_t DoUnpack(const fles::Timeslice& ts, size_t component);
inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id)
{
return gdpbId * fuNrOfGet4PerGdpb + get4Id;
}
};
// special class to expose protected TMessage constructor
class CbmMQTMessage : public TMessage
{
public:
CbmMQTMessage(void* buf, Int_t len)
: TMessage(buf, len)
{
ResetBit(kIsOwner);
}
std::vector<ULong64_t> fvulCurrentEpoch; //!
std::vector<Bool_t> fvbFirstEpochSeen; //!
Int_t fNofEpochs; /** Current epoch marker for each ROC **/
ULong64_t fulCurrentEpochTime; /** Time stamp of current epoch **/
Int_t fEquipmentId;
Double_t fdMsIndex;
Double_t fdTShiftRef;
Bool_t fbEpochSuppModeOn;
Bool_t fbGet4M24b;
Bool_t fbGet4v20;
Bool_t fbMergedEpochsOn;
CbmTofDigiExp* fDigi;
CbmTofUnpackPar* fUnpackPar; //!
// Variables used for histo filling
Double_t fdRefTime;
Double_t fdLastDigiTime;
Double_t fdFirstDigiTimeDif;
Double_t fdEvTime0;
TH1* fhRawTDigEvBmon;
TH1* fhRawTDigRef0;
TH1* fhRawTDigRef;
TH1* fhRawTRefDig0;
TH1* fhRawTRefDig1;
TH1* fhRawDigiLastDigi;
std::vector<TH2*> fhRawTotCh;
std::vector<TH1*> fhChCount;
std::vector<Bool_t> fvbChanThere;
std::vector<TH2*> fhChanCoinc;
Bool_t fbDetChanThere[64];
TH2* fhDetChanCoinc;
std::vector<std::vector<ngdpb::Message>> fvmEpSupprBuffer;
CbmTbDaqBuffer* fBuffer;
ULong64_t fulGdpbTsMsb;
ULong64_t fulGdpbTsLsb;
ULong64_t fulStarTsMsb;
ULong64_t fulStarTsMid;
ULong64_t fulGdpbTsFullLast;
ULong64_t fulStarTsFullLast;
UInt_t fuStarTokenLast;
UInt_t fuStarDaqCmdLast;
UInt_t fuStarTrigCmdLast;
bool CheckTimeslice(const fles::Timeslice& ts);
void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc);
bool IsChannelNameAllowed(std::string channelName);
Bool_t InitContainers();
Bool_t ReInitContainers();
void CreateHistograms();
void FillHitInfo(ngdpb::Message);
void FillStarTrigInfo(ngdpb::Message);
void FillEpochInfo(ngdpb::Message);
void PrintSlcInfo(ngdpb::Message);
void PrintSysInfo(ngdpb::Message);
void PrintGenInfo(ngdpb::Message);
Bool_t DoUnpack(const fles::Timeslice& ts, size_t component);
inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id) { return gdpbId * fuNrOfGet4PerGdpb + get4Id; }
};
#endif /* CBMDEVICEUNPACKTOFSTAR2018_H_ */
/* Copyright (C) 2013-2020 PI-UHd, GSI
SPDX-License-Identifier: GPL-3.0-only
Authors: Volker Friese, Norbert Herrmann [committer] */
/** @file CbmTbDaqBuffer.cxx
** @author Volker Friese <v.friese@gsi.de>
** @date 13 December 2013
**/
#include "CbmTbDaqBuffer.h"
#include <Logger.h> // for Logger, LOG
#include <boost/any.hpp>
#include <iomanip> // for setprecision, __iom_t5
#include <sstream> // for basic_stringstream<>::string_type
#include <stddef.h> // for NULL
// ----- Initialisation of static variables ------------------------------
CbmTbDaqBuffer* CbmTbDaqBuffer::fgInstance = nullptr;
// ---------------------------------------------------------------------------
// ----- Constructor -----------------------------------------------------
CbmTbDaqBuffer::CbmTbDaqBuffer() : fData() {}
// ---------------------------------------------------------------------------
// ----- Destructor ------------------------------------------------------
CbmTbDaqBuffer::~CbmTbDaqBuffer() {}
// ---------------------------------------------------------------------------
Double_t CbmTbDaqBuffer::GetTimeFirst() const
{
if (!GetSize()) return -1.;
// Return the key from the first element in the map
// The key of the map is the time of digi
return fData.begin()->first;
}
Double_t CbmTbDaqBuffer::GetTimeLast() const
{
if (!GetSize()) return -1.;
// Return the key from the last element in the map
// The key of the map is the time of digi
return (--fData.end())->first;
}
// ----- Access to next data ---------------------------------------------
CbmTbDaqBuffer::Data CbmTbDaqBuffer::GetNextData(Double_t time)
{
// --- Check for empty buffer
if (!fData.size()) return std::make_pair(boost::any(), ECbmModuleId::kNotExist);
// --- Get data from buffer
std::multimap<Double_t, std::pair<boost::any, ECbmModuleId>>::iterator it = fData.begin();
Double_t digi_time = it->first;
if (digi_time < time) {
boost::any digi = it->second.first;
ECbmModuleId sysID = it->second.second;
fData.erase(it);
return std::make_pair(digi, sysID);
}
return std::make_pair(boost::any(), ECbmModuleId::kNotExist);
}
// ---------------------------------------------------------------------------
// ----- Instance --------------------------------------------------------
CbmTbDaqBuffer* CbmTbDaqBuffer::Instance()
{
if (!fgInstance) fgInstance = new CbmTbDaqBuffer();
return fgInstance;
}
// ---------------------------------------------------------------------------
// ----- Print status ----------------------------------------------------
void CbmTbDaqBuffer::PrintStatus() const
{
Int_t size = GetSize();
std::stringstream ss;
ss << "CbmTbDaqBuffer: Status ";
if (!size) {
LOG(info) << ss.str() << "empty";
return;
}
LOG(info) << ss.str() << GetSize() << " digis from " << std::fixed << std::setprecision(9) << GetTimeFirst() * 1.e-9
<< " s to " << GetTimeLast() * 1.e-9 << " s";
}
// ---------------------------------------------------------------------------
/* Copyright (C) 2012-2020 PI-UHd, GSI
SPDX-License-Identifier: GPL-3.0-only
Authors: Volker Friese, Norbert Herrmann [committer] */
/** @file CbmDaqBuffer.h
** @author Volker Friese <v.friese@gsi.de>
** @date 17 July 2012
......@@ -6,11 +10,14 @@
#ifndef CBMTBDAQBUFFER_H
#define CBMTBDAQBUFFER_H 1
#include "CbmDefs.h"
#include <RtypesCore.h> // for Double_t, Int_t
#include <map> // for multimap, __map_const_iterator, multimap<>::...
#include <utility> // for pair
#include <boost/any.hpp>
#include "CbmDefs.h"
#include <map> // for multimap, __map_const_iterator, multimap<>::...
#include <utility> // for pair
/** @class CbmTbDaqBuffer
** @author Volker Friese <v.friese@gsi.de>
......@@ -29,15 +36,13 @@
** to be instantiated by the sending task (digitiser) and
** deleted by the receiving class (CbmDaq).
**/
class CbmTbDaqBuffer
{
public:
class CbmTbDaqBuffer {
public:
typedef std::pair<boost::any, ECbmModuleId> Data;
/** Destructor **/
~CbmTbDaqBuffer();
/** Pointer to next raw data object
** up to given time
** @param time maximal time [ns]
......@@ -48,61 +53,59 @@ class CbmTbDaqBuffer
**/
// boost::any GetNextData(Double_t time);
Data GetNextData(Double_t time);
/** Current buffer size
** @return number of objects in buffer
*/
Int_t GetSize() const { return fData.size(); }
/** Get first digi time **/
Double_t GetTimeFirst() const;
/** Get last digi time **/
Double_t GetTimeLast() const;
/** Access to singleton instance
** @return pointer to instance
**/
static CbmTbDaqBuffer* Instance();
/** Print buffer status **/
void PrintStatus() const;
/** Insert digi of any type into the buffer */
template <class Digi>
void InsertData(Digi* digi)
{
Double_t digi_time = digi->GetTime();
ECbmModuleId systemID = Digi::GetSystem();
InsertData(digi, digi_time, systemID);
}
private:
template<class Digi>
void InsertData(Digi* digi)
{
Double_t digi_time = digi->GetTime();
ECbmModuleId systemID = Digi::GetSystem();
InsertData(digi, digi_time, systemID);
}
private:
/** Buffer management **/
std::multimap<Double_t, Data> fData;
/** Pointer to singleton instance **/
static CbmTbDaqBuffer* fgInstance;
/** Default constructor
** Declared private to prevent instantiation.
**/
CbmTbDaqBuffer();
/** Copy constructor. Defined private to prevent usage. **/
CbmTbDaqBuffer(const CbmTbDaqBuffer&);
/** Assignment operator. Defined private to prevent usage. **/
CbmTbDaqBuffer& operator=(const CbmTbDaqBuffer&);
/** Insert data into the buffer
** @param digi pointer to data object to be inserted
**/
......@@ -111,7 +114,6 @@ class CbmTbDaqBuffer
{
fData.insert(std::make_pair(time, std::make_pair(std::move(digi), systemID)));
}
};
......
/* Copyright (C) 2018-2020 PI-UHd, GSI
SPDX-License-Identifier: GPL-3.0-only
Authors: Norbert Herrmann [committer] */
#include "CbmDeviceUnpackTofCri.h"
#include <iomanip>
#include <string>
#include "runFairMQDevice.h"
namespace bpo = boost::program_options;
using namespace std;
void addCustomOptions(bpo::options_description& options)
{
options.add_options()("ReqMode", bpo::value<uint64_t>()->default_value(0), "Time intervall selector");
options.add_options()("SelectComponents", bpo::value<uint64_t>()->default_value(1),
"Select components for transport");
options.add_options()("ReqTint", bpo::value<uint64_t>()->default_value(100), "Time intervall length in ns");
options.add_options()("ReqBeam", bpo::value<uint64_t>()->default_value(-1), "Mandatory beam counter in event");
options.add_options()("PulserMode", bpo::value<int64_t>()->default_value(0), "Choose pulser configuration");
options.add_options()("PulMulMin", bpo::value<uint64_t>()->default_value(0), "Min number of pulsed detectors");
options.add_options()("PulTotMin", bpo::value<uint64_t>()->default_value(0), "Min pulser TimeOverThreshold");
options.add_options()("PulTotMax", bpo::value<uint64_t>()->default_value(1000), "Max pulser TimeOverThreshold");
options.add_options()("ToffTof", bpo::value<double_t>()->default_value(0.),
"Time offset of Tof digis with respect to Bmon");
options.add_options()("RefModType", bpo::value<int64_t>()->default_value(5), "Module type of reference counter");
options.add_options()("RefModId", bpo::value<int64_t>()->default_value(0), "Module Id of reference counter");
options.add_options()("RefCtrType", bpo::value<int64_t>()->default_value(4), "Counter type of reference counter");
options.add_options()("RefCtrId", bpo::value<int64_t>()->default_value(0), "Counter Id of reference counter");
options.add_options()("MaxAsicInactive", bpo::value<uint64_t>()->default_value(0), "Max number of disabled ASICs");
int iNDet = 36;
for (int i = 0; i < iNDet; i++)
options.add_options()(Form("ReqDet%d", i), bpo::value<uint64_t>()->default_value(0), Form("ReqDet%d", i));
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceUnpackTofCri(); }
#include "runFairMQDevice.h"
/* Copyright (C) 2018-2020 PI-UHd, GSI
SPDX-License-Identifier: GPL-3.0-only
Authors: Norbert Herrmann [committer] */
#include "CbmDeviceUnpackTofMcbm2018.h"
#include <string>
#include <iomanip>
#include <string>
#include "runFairMQDevice.h"
namespace bpo = boost::program_options;
using namespace std;
void addCustomOptions(bpo::options_description& options)
{
options.add_options() ("ReqMode", bpo::value<uint64_t>()->default_value(0), "Time intervall selector");
options.add_options() ("SelectComponents", bpo::value<uint64_t>()->default_value(1), "Select components for transport");
options.add_options() ("ReqTint", bpo::value<uint64_t>()->default_value(100), "Time intervall length in ns");
options.add_options() ("PulserMode", bpo::value<int64_t>()->default_value(0),"Choose pulser configuration");
options.add_options() ("PulMulMin", bpo::value<uint64_t>()->default_value(0), "Min number of pulsed detectors");
options.add_options() ("PulTotMin", bpo::value<uint64_t>()->default_value(0), "Min pulser TimeOverThreshold");
options.add_options() ("TShiftRef", bpo::value<double_t>()->default_value(0.), "Time shift of reference counter to match digis");
options.add_options() ("MaxAsicInactive", bpo::value<uint64_t>()->default_value(0), "Max number of disabled ASICs");
options.add_options()("ReqMode", bpo::value<uint64_t>()->default_value(0), "Time intervall selector");
options.add_options()("SelectComponents", bpo::value<uint64_t>()->default_value(1),
"Select components for transport");
options.add_options()("ReqTint", bpo::value<uint64_t>()->default_value(100), "Time intervall length in ns");
options.add_options()("ReqBeam", bpo::value<uint64_t>()->default_value(-1), "Mandatory beam counter in event");
options.add_options()("PulserMode", bpo::value<int64_t>()->default_value(0), "Choose pulser configuration");
options.add_options()("PulMulMin", bpo::value<uint64_t>()->default_value(0), "Min number of pulsed detectors");
options.add_options()("PulTotMin", bpo::value<uint64_t>()->default_value(0), "Min pulser TimeOverThreshold");
options.add_options()("PulTotMax", bpo::value<uint64_t>()->default_value(1000), "Max pulser TimeOverThreshold");
options.add_options()("ToffTof", bpo::value<double_t>()->default_value(0.),
"Time offset of Tof digis with respect to Bmon");
options.add_options()("RefModType", bpo::value<int64_t>()->default_value(5), "Module type of reference counter");
options.add_options()("RefModId", bpo::value<int64_t>()->default_value(0), "Module Id of reference counter");
options.add_options()("RefCtrType", bpo::value<int64_t>()->default_value(4), "Counter type of reference counter");
options.add_options()("RefCtrId", bpo::value<int64_t>()->default_value(0), "Counter Id of reference counter");
options.add_options()("MaxAsicInactive", bpo::value<uint64_t>()->default_value(0), "Max number of disabled ASICs");
int iNDet=36;
for (int i=0; i<iNDet; i++)
options.add_options() (Form("ReqDet%d",i), bpo::value<uint64_t>()->default_value(0),Form("ReqDet%d",i));
int iNDet = 36;
for (int i = 0; i < iNDet; i++)
options.add_options()(Form("ReqDet%d", i), bpo::value<uint64_t>()->default_value(0), Form("ReqDet%d", i));
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
{
return new CbmDeviceUnpackTofMcbm2018();
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceUnpackTofMcbm2018(); }
#include "runFairMQDevice.h"
/* Copyright (C) 2018 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Florian Uhlig [committer] */
#include "CbmDeviceUnpackTofStar2018.h"
#include "runFairMQDevice.h"
namespace bpo = boost::program_options;
void addCustomOptions(bpo::options_description& /*options*/)
{
}
void addCustomOptions(bpo::options_description& /*options*/) {}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
{
return new CbmDeviceUnpackTofStar2018();
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceUnpackTofStar2018(); }
#!/bin/bash
$FAIRROOTPATH/bin/shmmonitor --cleanup
if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
@SIMPATH@/bin/fairmq-shmmonitor --cleanup
fi
if [ -z "$1" ]; then
if [ -z "$1" ]; then
_filename=@VMCWORKDIR@/input/tofget4_hd2018.tsa
else
else
_filename=$1
fi
......