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 7851 additions and 3412 deletions
source diff could not be displayed: it is too large. Options to address this: view the blob.
/* Copyright (C) 2018-2020 PI-UHd, GSI
SPDX-License-Identifier: GPL-3.0-only
Authors: Norbert Herrmann [committer] */
/**
* CbmDeviceHitBuilderTof.h
*
......@@ -8,28 +12,28 @@
#ifndef CBMDEVICEHITBUILDERTOF_H_
#define CBMDEVICEHITBUILDERTOF_H_
#include "FairMQDevice.h"
#include "FairEventHeader.h"
#include "TGeoManager.h"
#include "TFile.h"
#include "TTree.h"
#include "CbmTofGeoHandler.h" // in tof/TofTools
#include "CbmTofAddress.h" // in cbmdata/tof
#include "CbmMqTMessage.h"
#include "CbmTofAddress.h" // in cbmdata/tof
#include "CbmTofGeoHandler.h" // in tof/TofTools
#include "Timeslice.hpp"
#include "MicrosliceDescriptor.hpp"
#include "Timeslice.hpp"
#include "FairEventHeader.h"
#include "FairMQDevice.h"
#include "TMessage.h"
#include "Rtypes.h"
#include "TFile.h"
#include "TGeoManager.h"
#include "TMessage.h"
#include "TTree.h"
#include <vector>
#include <map>
#include <vector>
class CbmMQTMessage;
class CbmHistManager;
// Relevant TOF classes
// Relevant TOF classes
class CbmTofDigi;
class CbmTofDigiExp;
class CbmTofHit;
class CbmMatch;
class CbmEvent;
......@@ -50,262 +54,240 @@ class TProfile;
class TString;
// C++ Classes and includes
#include <vector>
#include <map>
#include <list>
#include <map>
#include <vector>
class CbmDeviceHitBuilderTof: public FairMQDevice
{
public:
CbmDeviceHitBuilderTof();
virtual ~CbmDeviceHitBuilderTof();
protected:
virtual void InitTask();
//bool HandleData(FairMQMessagePtr&, int);
bool HandleData(FairMQParts&, int);
bool HandleMessage(FairMQMessagePtr&, int);
virtual void fit_ybox(const char *hname); // Fit
virtual void fit_ybox(TH1 *h, Double_t dy); // Fit
virtual void fit_ybox(TH1 *h, Double_t dy, Double_t* fpar); // Fit
virtual void CheckLHMemory(); // Check consistency of stored last hits
virtual void CleanLHMemory(); // Cleanup
virtual Bool_t AddNextChan(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iLastChan, Double_t dLastPosX, Double_t dLastPosY, Double_t dLastTime, Double_t dLastTot); // needed for time based data
virtual void LH_store(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iChm, CbmTofHit *pHit);
private:
// Variables used for histo filling
Bool_t IsChannelNameAllowed(std::string channelName);
Bool_t InitWorkspace();
Bool_t InitContainers();
Bool_t LoadGeometry();
Bool_t InitRootOutput();
Bool_t ReInitContainers();
void CreateHistograms();
void WriteHistograms();
Bool_t MonitorPulser();
Bool_t ApplyPulserCorrection();
Bool_t InitCalibParameter();
Bool_t BuildClusters();
Bool_t InspectRawDigis();
Bool_t CalibRawDigis();
Bool_t FillDigiStor();
Bool_t BuildHits();
Bool_t MergeClusters();
Bool_t FillHistos();
Bool_t SendHits();
Bool_t SendAll();
uint64_t fNumMessages;
std::vector<std::string> fAllowedChannels = {"tofcomponent","parameters","tofdigis","tofhits","syscmd"};
CbmTofDigiExp* fDigi;
TGeoManager * fGeoMan;
// ToF geometry variables
CbmTofGeoHandler * fGeoHandler;
CbmTofDetectorId * fTofId;
CbmTofDigiPar * fDigiPar;
CbmTofCell * fChannelInfo;
CbmTofDigiBdfPar * fDigiBdfPar;
// Input variables
TClonesArray * fTofDigisColl; // TOF Digis
CbmTofDigiExp * pDigiIn;
Int_t fiNDigiIn;
std::vector <CbmTofDigiExp> fvDigiIn;
std::vector<int> fEventHeader;
FairEventHeader* fEvtHeader;
// Output variables
TClonesArray * fTofCalDigisColl; // Calibrated TOF Digis
TClonesArray * fTofHitsColl; // TOF hits
TClonesArray * fTofDigiMatchColl; // TOF Digi Links
TClonesArray * fTofCalDigisCollOut; // Calibrated TOF Digis
TClonesArray * fTofHitsCollOut; // TOF hits
TClonesArray * fTofDigiMatchCollOut; // TOF Digi Links
Int_t fiNbHits; // Index of the CbmTofHit TClonesArray
// Constants or setting parameters
Int_t fiNevtBuild;
Int_t fiMsgCnt;
Double_t fdTOTMax;
Double_t fdTOTMin;
Double_t fdTTotMean;
Double_t fdMaxTimeDist; // Isn't this just a local variable? Why make it global and preset?!?
Double_t fdMaxSpaceDist; // Isn't this just a local variable? Why make it global and preset?!?
Double_t fdEvent;
Int_t fiMaxEvent;
Int_t fiRunId;
Bool_t fbSwapChannelSides;
Int_t fiOutputTreeEntry;
Int_t fiFileIndex;
// Intermediate storage variables
std::vector< std::vector< std::vector< std::vector< CbmTofDigi* > > > >
fStorDigi; //[nbType][nbSm*nbRpc][nbCh][nDigis]
std::vector< std::vector< std::vector< std::vector< CbmTofDigiExp* > > > >
fStorDigiExp; //[nbType][nbSm*nbRpc][nbCh][nDigis]
std::vector< std::vector< std::vector< std::vector< Int_t > > > >
fStorDigiInd; //[nbType][nbSm*nbRpc][nbCh][nDigis]
std::vector< Int_t > vDigiIndRef;
std::vector< std::vector< std::vector< Int_t > > > fviClusterMul; //[nbType][nbSm][nbRpc]
std::vector< std::vector< std::vector< Int_t > > > fviClusterSize; //[nbType][nbRpc][nClusters]
std::vector< std::vector< std::vector< Int_t > > > fviTrkMul; //[nbType][nbRpc][nClusters]
std::vector< std::vector< std::vector< Double_t > > > fvdX; //[nbType][nbRpc][nClusters]
std::vector< std::vector< std::vector< Double_t > > > fvdY; //[nbType][nbRpc][nClusters]
std::vector< std::vector< std::vector< Double_t > > > fvdDifX; //[nbType][nbRpc][nClusters]
std::vector< std::vector< std::vector< Double_t > > > fvdDifY; //[nbType][nbRpc][nClusters]
std::vector< std::vector< std::vector< Double_t > > > fvdDifCh; //[nbType][nbRpc][nClusters]
// Intermediate calibration variables
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPDelTof; //[nSMT][nRpc][nbClDelTofBinX][nbSel]
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTOff; //[nSMT][nRpc][nCh][nbSide]
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTotGain; //[nSMT][nRpc][nCh][nbSide]
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTotOff; //[nSMT][nRpc][nCh][nbSide]
std::vector< std::vector< std::vector< std::vector< std::vector< Double_t > > > > > fvCPWalk; //[nSMT][nRpc][nCh][nbSide][nbWalkBins]
std::vector< std::vector< std::vector< std::vector< std::list< CbmTofHit * > > > > > fvLastHits; //[nSMT[nSm][nRpc][nCh][NHits]
std::vector< Int_t > fvDeadStrips; //[nbDet]
std::vector< std::vector< Double_t > > fvPulserOffset; //[nbDet][nbSide]
const Int_t NPulserTimes=10;
std::vector< std::vector< std::list< Double_t > > > fvPulserTimes; //[nbDet][nbSide][NPulserTimes]
// histograms
TH1* fhEvDetMul;
TH1* fhPulMul;
TH2* fhPulserTimesRaw;
std::vector< TProfile* > fhPulserTimeRawEvo;
TH2* fhPulserTimesCor;
TH2* fhDigiTimesRaw;
TH2* fhDigiTimesCor;
std::vector< TH2* > fhRpcDigiTot; //[nbDet]
std::vector< TH2* > fhRpcDigiCor; //[nbDet]
std::vector< TH1* > fhRpcCluMul; //[nbDet]
std::vector< TH1* > fhRpcCluRate; //[nbDet]
std::vector< TH2* > fhRpcCluPosition; //[nbDet]
std::vector< TH2* > fhRpcCluDelPos; //[nbDet]
std::vector< TH2* > fhRpcCluDelMatPos; //[nbDet]
std::vector< TH2* > fhRpcCluTOff; //[nbDet]
std::vector< TH2* > fhRpcCluDelTOff; //[nbDet]
std::vector< TH2* > fhRpcCluDelMatTOff; //[nbDet]
std::vector< TH2* > fhRpcCluTrms; //[nbDet]
std::vector< TH2* > fhRpcCluTot; //[nbDet]
std::vector< TH2* > fhRpcCluSize; //[nbDet]
std::vector< TH2* > fhRpcCluAvWalk; //[nbDet]
std::vector< TH2* > fhRpcCluAvLnWalk; //[nbDet]
std::vector< std::vector< std::vector<TH2 *> > >fhRpcCluWalk; // [nbDet][nbCh][nSide]
std::vector< TH2* > fhSmCluPosition; //[nbSmTypes]
std::vector< TH2* > fhSmCluTOff;
std::vector< TProfile* > fhSmCluSvel;
std::vector< std::vector< TProfile* > > fhSmCluFpar;
std::vector< TH1* > fhRpcDTLastHits; //[nbDet]
std::vector< TH1* > fhRpcDTLastHits_Tot; //[nbDet]
std::vector< TH1* > fhRpcDTLastHits_CluSize; //[nbDet]
std::vector< std::vector< TH1* > > fhTRpcCluMul; //[nbDet][nbSel]
std::vector< std::vector< TH2* > > fhTRpcCluPosition; //[nbDet][nbSel]
std::vector< std::vector< TH2* > > fhTRpcCluTOff; //[nbDet] [nbSel]
std::vector< std::vector< TH2* > > fhTRpcCluTot; // [nbDet][nbSel]
std::vector< std::vector< TH2* > > fhTRpcCluSize; // [nbDet][nbSel]
std::vector< std::vector< TH2* > > fhTRpcCluAvWalk; // [nbDet][nbSel]
std::vector< std::vector< TH2* > > fhTRpcCluDelTof; // [nbDet][nbSel]
std::vector< std::vector< TH2* > > fhTRpcCludXdY; // [nbDet][nbSel]
std::vector< std::vector< std::vector< std::vector<TH2 *> > > >fhTRpcCluWalk; // [nbDet][nbSel][nbCh][nSide]
std::vector< std::vector< TH2* > > fhTSmCluPosition; //[nbSmTypes][nbSel]
std::vector< std::vector< TH2* > > fhTSmCluTOff; //[nbSmTypes][nbSel]
std::vector< std::vector< TH2* > > fhTSmCluTRun; //[nbSmTypes][nbSel]
std::vector< std::vector< TH2* > > fhTRpcCluTOffDTLastHits;
std::vector< std::vector< TH2* > > fhTRpcCluTotDTLastHits;
std::vector< std::vector< TH2* > > fhTRpcCluSizeDTLastHits;
std::vector< std::vector< TH2* > > fhTRpcCluMemMulDTLastHits;
std::vector< TH1* > fhSeldT; //[nbSel]
// Calibration control variables
Double_t dTRef;
Double_t fdTRefMax;
Int_t fCalMode;
Int_t fCalSel;
Int_t fCalSmAddr;
Double_t fdCaldXdYMax;
Int_t fiCluMulMax;
Int_t fTRefMode;
Int_t fTRefHits;
Int_t fDutId;
Int_t fDutSm;
Int_t fDutRpc;
Int_t fDutAddr;
Int_t fSelId;
Int_t fSelSm;
Int_t fSelRpc;
Int_t fSelAddr;
Int_t fiBeamRefType;
Int_t fiBeamRefSm;
Int_t fiBeamRefDet;
Int_t fiBeamRefAddr;
Int_t fiBeamRefMulMax;
Int_t fiBeamAddRefMul;
Int_t fSel2Id;
Int_t fSel2Sm;
Int_t fSel2Rpc;
Int_t fSel2Addr;
Int_t fiMode;
Int_t fiPulserMode;
uint64_t fiPulMulMin;
uint64_t fiPulDetRef;
uint64_t fiPulTotMin;
uint64_t fiPulTotMax;
std::map<UInt_t, UInt_t> fDetIdIndexMap;
std::vector< Int_t > fviDetId;
Double_t fPosYMaxScal;
Double_t fTRefDifMax;
Double_t fTotMax;
Double_t fTotMin;
Double_t fTotOff;
Double_t fTotMean;
Double_t fdDelTofMax;
Double_t fTotPreRange;
Double_t fMaxTimeDist;
Double_t fdChannelDeadtime;
Double_t fdMemoryTime;
Double_t fdYFitMin;
Bool_t fEnableMatchPosScaling;
Bool_t fEnableAvWalk;
Bool_t fbPs2Ns; // convert input raw digis from ps to ns
TString fCalParFileName; // name of the file name with Calibration Parameters
TString fOutHstFileName; // name of the histogram output file name with Calibration Parameters
TString fOutRootFileName; // name of the output file name with Digis & Hits
TFile* fCalParFile; // pointer to Calibration Parameter file
TFile* fOutRootFile; // pointer to root output file
TTree* fRootEvent; // pointer to root event tree
};
// special class to expose protected TMessage constructor
class CbmMQTMessage : public TMessage
{
public:
CbmMQTMessage(void* buf, Int_t len)
: TMessage(buf, len)
{
ResetBit(kIsOwner);
}
class CbmDeviceHitBuilderTof : public FairMQDevice {
public:
CbmDeviceHitBuilderTof();
virtual ~CbmDeviceHitBuilderTof();
protected:
virtual void InitTask();
//bool HandleData(FairMQMessagePtr&, int);
bool HandleData(FairMQParts&, int);
bool HandleMessage(FairMQMessagePtr&, int);
virtual void fit_ybox(const char* hname); // Fit
virtual void fit_ybox(TH1* h, Double_t dy); // Fit
virtual void fit_ybox(TH1* h, Double_t dy, Double_t* fpar); // Fit
virtual void CheckLHMemory(); // Check consistency of stored last hits
virtual void CleanLHMemory(); // Cleanup
virtual Bool_t AddNextChan(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iLastChan, Double_t dLastPosX,
Double_t dLastPosY, Double_t dLastTime,
Double_t dLastTot); // needed for time based data
virtual void LH_store(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iChm, CbmTofHit* pHit);
private:
// Variables used for histo filling
Bool_t IsChannelNameAllowed(std::string channelName);
Bool_t InitWorkspace();
Bool_t InitContainers();
Bool_t LoadGeometry();
Bool_t InitRootOutput();
Bool_t ReInitContainers();
void CreateHistograms();
void WriteHistograms();
Bool_t MonitorPulser();
Bool_t ApplyPulserCorrection();
Bool_t InitCalibParameter();
Bool_t BuildClusters();
Bool_t InspectRawDigis();
Bool_t CalibRawDigis();
Bool_t FillDigiStor();
Bool_t BuildHits();
Bool_t MergeClusters();
Bool_t FillHistos();
Bool_t SendHits();
Bool_t SendAll();
uint64_t fNumMessages;
std::vector<std::string> fAllowedChannels = {"tofcomponent", "parameters", "tofdigis", "tofhits", "syscmd"};
TGeoManager* fGeoMan;
// ToF geometry variables
CbmTofGeoHandler* fGeoHandler;
CbmTofDetectorId* fTofId;
CbmTofDigiPar* fDigiPar;
CbmTofCell* fChannelInfo;
CbmTofDigiBdfPar* fDigiBdfPar;
// Input variables
Int_t fiNDigiIn;
std::vector<CbmTofDigi> fvDigiIn;
std::vector<uint64_t> fEventHeader;
FairEventHeader* fEvtHeader;
// Output variables
// TClonesArray* fTofCalDigisColl; // Calibrated TOF Digis
std::vector<CbmTofDigi>* fTofCalDigiVec = nullptr; // Calibrated TOF Digis
TClonesArray* fTofHitsColl; // TOF hits
TClonesArray* fTofDigiMatchColl; // TOF Digi Links
TClonesArray* fTofHitsCollOut; // TOF hits
TClonesArray* fTofDigiMatchCollOut; // TOF Digi Links
Int_t fiNbHits; // Index of the CbmTofHit TClonesArray
// Constants or setting parameters
Int_t fiNevtBuild;
Int_t fiMsgCnt;
Double_t fdTOTMax;
Double_t fdTOTMin;
Double_t fdTTotMean;
Double_t fdMaxTimeDist; // Isn't this just a local variable? Why make it global and preset?!?
Double_t fdMaxSpaceDist; // Isn't this just a local variable? Why make it global and preset?!?
Double_t fdEvent;
Int_t fiMaxEvent;
Int_t fiRunId;
Int_t fiOutputTreeEntry;
Int_t fiFileIndex;
// Intermediate storage variables
std::vector<std::vector<std::vector<std::vector<CbmTofDigi*>>>> fStorDigi; //[nbType][nbSm*nbRpc][nbCh][nDigis]
std::vector<std::vector<std::vector<std::vector<Int_t>>>> fStorDigiInd; //[nbType][nbSm*nbRpc][nbCh][nDigis]
std::vector<Int_t> vDigiIndRef;
std::vector<std::vector<std::vector<Int_t>>> fviClusterMul; //[nbType][nbSm][nbRpc]
std::vector<std::vector<std::vector<Int_t>>> fviClusterSize; //[nbType][nbRpc][nClusters]
std::vector<std::vector<std::vector<Int_t>>> fviTrkMul; //[nbType][nbRpc][nClusters]
std::vector<std::vector<std::vector<Double_t>>> fvdX; //[nbType][nbRpc][nClusters]
std::vector<std::vector<std::vector<Double_t>>> fvdY; //[nbType][nbRpc][nClusters]
std::vector<std::vector<std::vector<Double_t>>> fvdDifX; //[nbType][nbRpc][nClusters]
std::vector<std::vector<std::vector<Double_t>>> fvdDifY; //[nbType][nbRpc][nClusters]
std::vector<std::vector<std::vector<Double_t>>> fvdDifCh; //[nbType][nbRpc][nClusters]
// Intermediate calibration variables
std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPDelTof; //[nSMT][nRpc][nbClDelTofBinX][nbSel]
std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTOff; //[nSMT][nRpc][nCh][nbSide]
std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTotGain; //[nSMT][nRpc][nCh][nbSide]
std::vector<std::vector<std::vector<std::vector<Double_t>>>> fvCPTotOff; //[nSMT][nRpc][nCh][nbSide]
std::vector<std::vector<std::vector<std::vector<std::vector<Double_t>>>>>
fvCPWalk; //[nSMT][nRpc][nCh][nbSide][nbWalkBins]
std::vector<std::vector<std::vector<std::vector<std::list<CbmTofHit*>>>>> fvLastHits; //[nSMT[nSm][nRpc][nCh][NHits]
std::vector<Int_t> fvDeadStrips; //[nbDet]
std::vector<std::vector<Double_t>> fvPulserOffset; //[nbDet][nbSide]
const Int_t NPulserTimes = 10;
std::vector<std::vector<std::list<Double_t>>> fvPulserTimes; //[nbDet][nbSide][NPulserTimes]
// histograms
TH1* fhEvDetMul;
TH1* fhEvDigiMul;
TH1* fhEvRateIn;
TH1* fhEvRateOut;
TH1* fhPulMul;
TH1* fhDigiTdif;
TH2* fhPulserTimesRaw;
std::vector<TProfile*> fhPulserTimeRawEvo;
TH2* fhPulserTimesCor;
TH2* fhDigiTimesRaw;
TH2* fhDigiTimesCor;
std::vector<TH2*> fhRpcDigiTot; //[nbDet]
std::vector<TH2*> fhRpcDigiCor; //[nbDet]
std::vector<TH1*> fhRpcCluMul; //[nbDet]
std::vector<TH1*> fhRpcCluRate; //[nbDet]
std::vector<TH2*> fhRpcCluPosition; //[nbDet]
std::vector<TH2*> fhRpcCluDelPos; //[nbDet]
std::vector<TH2*> fhRpcCluDelMatPos; //[nbDet]
std::vector<TH2*> fhRpcCluTOff; //[nbDet]
std::vector<TH2*> fhRpcCluDelTOff; //[nbDet]
std::vector<TH2*> fhRpcCluDelMatTOff; //[nbDet]
std::vector<TH2*> fhRpcCluTrms; //[nbDet]
std::vector<TH2*> fhRpcCluTot; //[nbDet]
std::vector<TH2*> fhRpcCluSize; //[nbDet]
std::vector<TH2*> fhRpcCluAvWalk; //[nbDet]
std::vector<TH2*> fhRpcCluAvLnWalk; //[nbDet]
std::vector<std::vector<std::vector<TH2*>>> fhRpcCluWalk; // [nbDet][nbCh][nSide]
std::vector<TH2*> fhSmCluPosition; //[nbSmTypes]
std::vector<TH2*> fhSmCluTOff;
std::vector<TProfile*> fhSmCluSvel;
std::vector<std::vector<TProfile*>> fhSmCluFpar;
std::vector<TH1*> fhRpcDTLastHits; //[nbDet]
std::vector<TH1*> fhRpcDTLastHits_Tot; //[nbDet]
std::vector<TH1*> fhRpcDTLastHits_CluSize; //[nbDet]
std::vector<std::vector<TH1*>> fhTRpcCluMul; //[nbDet][nbSel]
std::vector<std::vector<TH2*>> fhTRpcCluPosition; //[nbDet][nbSel]
std::vector<std::vector<TH2*>> fhTRpcCluTOff; //[nbDet] [nbSel]
std::vector<std::vector<TH2*>> fhTRpcCluTot; // [nbDet][nbSel]
std::vector<std::vector<TH2*>> fhTRpcCluSize; // [nbDet][nbSel]
std::vector<std::vector<TH2*>> fhTRpcCluAvWalk; // [nbDet][nbSel]
std::vector<std::vector<TH2*>> fhTRpcCluDelTof; // [nbDet][nbSel]
std::vector<std::vector<TH2*>> fhTRpcCludXdY; // [nbDet][nbSel]
std::vector<std::vector<std::vector<std::vector<TH2*>>>> fhTRpcCluWalk; // [nbDet][nbSel][nbCh][nSide]
std::vector<std::vector<TH2*>> fhTSmCluPosition; //[nbSmTypes][nbSel]
std::vector<std::vector<TH2*>> fhTSmCluTOff; //[nbSmTypes][nbSel]
std::vector<std::vector<TH2*>> fhTSmCluTRun; //[nbSmTypes][nbSel]
std::vector<std::vector<TH2*>> fhTRpcCluTOffDTLastHits;
std::vector<std::vector<TH2*>> fhTRpcCluTotDTLastHits;
std::vector<std::vector<TH2*>> fhTRpcCluSizeDTLastHits;
std::vector<std::vector<TH2*>> fhTRpcCluMemMulDTLastHits;
std::vector<TH1*> fhSeldT; //[nbSel]
// Calibration control variables
Double_t dTRef;
Int_t fCalMode;
Double_t fdCaldXdYMax;
Int_t fiCluMulMax;
Int_t fTRefMode;
Int_t fTRefHits;
Int_t fDutId;
Int_t fDutSm;
Int_t fDutRpc;
Int_t fDutAddr;
Int_t fSelId;
Int_t fSelSm;
Int_t fSelRpc;
Int_t fSelAddr;
Int_t fiBeamRefType;
Int_t fiBeamRefSm;
Int_t fiBeamRefDet;
Int_t fiBeamRefAddr;
Int_t fiBeamRefMulMax;
Int_t fiBeamAddRefMul;
Int_t fSel2Id;
Int_t fSel2Sm;
Int_t fSel2Rpc;
Int_t fSel2Addr;
Int_t fiMode;
Int_t fiPulserMode;
uint64_t fiPulMulMin;
uint64_t fiPulDetRef;
uint64_t fiPulTotMin;
uint64_t fiPulTotMax;
std::map<UInt_t, UInt_t> fDetIdIndexMap;
std::vector<Int_t> fviDetId;
Double_t fPosYMaxScal;
Double_t fTRefDifMax;
Double_t fTotMax;
Double_t fTotMin;
Double_t fTotMean;
Double_t fdDelTofMax;
Double_t fMaxTimeDist;
Double_t fdChannelDeadtime;
Double_t fdMemoryTime;
Bool_t fEnableMatchPosScaling;
Bool_t fbPs2Ns; // convert input raw digis from ps to ns
TString fCalParFileName; // name of the file name with Calibration Parameters
TString fOutHstFileName; // name of the histogram output file name with Calibration Parameters
TString fOutRootFileName; // name of the output file name with Digis & Hits
TFile* fCalParFile; // pointer to Calibration Parameter file
TFile* fOutRootFile; // pointer to root output file
};
#endif /* CBMDEVICEHITBUILDERTOF_H_ */
/**
* \file CbmTofHit.h
* \author E. Cordier
* Modified by D. Gonzalez-Diaz 06/09/06
* Modified by A.Lebedev 26/05/09
* Modified by nh 16/12/12
* Modified by A.Lebedev 15/05/13
**/
#ifndef CBMTOFHIT_H_
#define CBMTOFHIT_H_
#include "CbmPixelHit.h"
#include "TMath.h"
#include <boost/serialization/access.hpp>
#include <boost/serialization/base_object.hpp>
class CbmTofHit : public CbmPixelHit
{
public:
/**
* \brief Default constructor.
**/
CbmTofHit();
/**
* \brief Constructor with hit parameters (1b).
**/
CbmTofHit(Int_t address, TVector3 pos, TVector3 dpos, Int_t refIndex, Double_t time, Double_t dtime, Int_t flag, Int_t channel);
/**
* \brief Constructor with hit parameters (1a).
**/
CbmTofHit(Int_t address, TVector3 pos, TVector3 dpos, Int_t refIndex, Double_t tof, Int_t flag, Int_t channel);
/**
* \brief Constructor with hit parameters (1).
**/
CbmTofHit(Int_t address, TVector3 pos, TVector3 dpos, Int_t refIndex, Double_t tof, Int_t flag);
/**
* \brief Constructor with hit parameters (2) [not the flag]
**/
CbmTofHit(Int_t address, TVector3 pos, TVector3 dpos, Int_t refIndex, Double_t tof);
/**
* \brief Destructor.
**/
virtual ~CbmTofHit();
/**
* \brief Inherited from CbmBaseHit.
*/
virtual std::string ToString() const;
/**
* \brief Inherited from CbmBaseHit.
*/
Int_t GetPlaneId() const { return 0; }
/** Accessors **/
Int_t GetFlag() const { return fFlag; }
Int_t GetCh() const { return fChannel; }
Double_t GetR() const {return TMath::Sqrt(GetX()*GetX()+GetY()*GetY()+GetZ()*GetZ());}
Double_t GetRt() const {return TMath::Sqrt(GetX()*GetX()+GetY()*GetY());}
Double_t GetCosThe() const {return GetZ()/GetR();}
Double_t GetSinThe() const {return TMath::Sqrt(GetX()*GetX()+GetY()*GetY())/GetR();}
Double_t GetCosPhi() const {return GetX()/GetRt();}
Double_t GetSinPhi() const {return GetY()/GetRt();}
/** Modifiers **/
void SetFlag(Int_t flag) { fFlag = flag; };
// Make this method otherwise inherited from CbmHit through CbmPixelHit
// private to prevent its usage
Int_t GetRefId() const __attribute__ ((deprecated)) { return -1; }
// Field is instead used to store the number of strips used to generate the hit
Int_t GetClusterSize() { return CbmHit::GetRefId(); }
private:
Int_t fFlag; ///< Flag for general purposes [TDC, event tagging...]
Int_t fChannel; ///< Channel identifier
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int /*version*/)
{
ar& fFlag;
ar& fChannel;
}
ClassDef(CbmTofHit, 4)
};
#endif
#include "runFairMQDevice.h"
/* Copyright (C) 2018-2019 PI-UHd/GSI, Heidelberg/Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Norbert Herrmann [committer] */
#include "CbmDeviceHitBuilderTof.h"
#include "runFairMQDevice.h"
namespace bpo = boost::program_options;
void addCustomOptions(bpo::options_description& options)
{
options.add_options() ("OutRootFile", bpo::value<std::string>()->default_value(""),"Root output file name");
options.add_options() ("MaxEvent", bpo::value<int64_t>()->default_value(-1),"Nr of Event for ROOT file");
options.add_options() ("RunId", bpo::value<int64_t>()->default_value(11),"Run identifier for ROOT geometry file");
options.add_options() ("Mode", bpo::value<int64_t>()->default_value(0),"Choose device operation mode");
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() ("PulDetRef", bpo::value<uint64_t>()->default_value(0), "Pulser Reference Detector");
options.add_options() ("PulTotMin", bpo::value<uint64_t>()->default_value(0), "Min Tot value");
options.add_options() ("PulTotMax", bpo::value<uint64_t>()->default_value(0), "Max Tot value");
options.add_options() ("DutType", bpo::value<uint64_t>()->default_value(0),"Dut type identifier");
options.add_options() ("DutSm", bpo::value<uint64_t>()->default_value(0),"Dut module number");
options.add_options() ("DutRpc", bpo::value<uint64_t>()->default_value(1),"Dut counter number");
options.add_options() ("SelType", bpo::value<uint64_t>()->default_value(0),"Sel type identifier");
options.add_options() ("SelSm", bpo::value<uint64_t>()->default_value(1),"Sel module number");
options.add_options() ("SelRpc", bpo::value<uint64_t>()->default_value(1),"Sel counter number");
options.add_options() ("Sel2Type", bpo::value<uint64_t>()->default_value(0),"Sel2 type identifier");
options.add_options() ("Sel2Sm", bpo::value<uint64_t>()->default_value(2),"Sel2 module number");
options.add_options() ("Sel2Rpc", bpo::value<uint64_t>()->default_value(1),"Sel2 counter number");
options.add_options() ("BRefType", bpo::value<uint64_t>()->default_value(0),"Beam Reference type identifier");
options.add_options() ("BRefSm", bpo::value<uint64_t>()->default_value(3),"Beam Reference module number");
options.add_options() ("BRefDet", bpo::value<uint64_t>()->default_value(1),"Beam Reference counter number");
options.add_options() ("CalMode", bpo::value<uint64_t>()->default_value(0),"Calibration Mode");
options.add_options() ("CalSel", bpo::value<uint64_t>()->default_value(0),"Calibration Selector");
options.add_options() ("CaldXdYMax", bpo::value<double_t>()->default_value(30.),"Matching Window");
options.add_options() ("CalCluMulMax", bpo::value<uint64_t>()->default_value(3),"Max Counter Multiplicity");
options.add_options() ("CalRefSel", bpo::value<uint64_t>()->default_value(0),"Reference Selector");
options.add_options() ("CalTotMax", bpo::value<double_t>()->default_value(20.),"Time Over Threhold Maximum");
options.add_options() ("CalTotMean", bpo::value<double_t>()->default_value(5.),"Time Over Threhold Mean");
options.add_options() ("MaxTimeDist", bpo::value<double_t>()->default_value(1.),"Cluster range in ns");
options.add_options() ("DelTofMax", bpo::value<double_t>()->default_value(60.),"acceptance range for cluster distance");
options.add_options() ("Sel2MulMax", bpo::value<double_t>()->default_value(3.),"Limit of 2nd selector multiplicity");
options.add_options() ("ChannelDeadtime", bpo::value<double_t>()->default_value(50.),"channel deadtime in ns");
options.add_options() ("CalYFitMin", bpo::value<double_t>()->default_value(1.E4),"Min counts for box fit");
options.add_options() ("OutHstFile", bpo::value<std::string>()->default_value(""),"monitor histogram file name");
options.add_options() ("OutParFile", bpo::value<std::string>()->default_value(""),"parameter histogram file name");
options.add_options()("OutRootFile", bpo::value<std::string>()->default_value(""), "Root output file name");
options.add_options()("MaxEvent", bpo::value<int64_t>()->default_value(-1), "Nr of Event for ROOT file");
options.add_options()("RunId", bpo::value<int64_t>()->default_value(11), "Run identifier for ROOT geometry file");
options.add_options()("Mode", bpo::value<int64_t>()->default_value(0), "Choose device operation mode");
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()("PulDetRef", bpo::value<uint64_t>()->default_value(0), "Pulser Reference Detector");
options.add_options()("PulTotMin", bpo::value<uint64_t>()->default_value(0), "Min Tot value");
options.add_options()("PulTotMax", bpo::value<uint64_t>()->default_value(0), "Max Tot value");
options.add_options()("ReqTint", bpo::value<uint64_t>()->default_value(50), "Coincidence time interval");
options.add_options()("DutType", bpo::value<uint64_t>()->default_value(0), "Dut type identifier");
options.add_options()("DutSm", bpo::value<uint64_t>()->default_value(0), "Dut module number");
options.add_options()("DutRpc", bpo::value<uint64_t>()->default_value(1), "Dut counter number");
options.add_options()("SelType", bpo::value<uint64_t>()->default_value(0), "Sel type identifier");
options.add_options()("SelSm", bpo::value<uint64_t>()->default_value(1), "Sel module number");
options.add_options()("SelRpc", bpo::value<uint64_t>()->default_value(1), "Sel counter number");
options.add_options()("Sel2Type", bpo::value<uint64_t>()->default_value(0), "Sel2 type identifier");
options.add_options()("Sel2Sm", bpo::value<uint64_t>()->default_value(2), "Sel2 module number");
options.add_options()("Sel2Rpc", bpo::value<uint64_t>()->default_value(1), "Sel2 counter number");
options.add_options()("BRefType", bpo::value<uint64_t>()->default_value(0), "Beam Reference type identifier");
options.add_options()("BRefSm", bpo::value<uint64_t>()->default_value(3), "Beam Reference module number");
options.add_options()("BRefDet", bpo::value<uint64_t>()->default_value(1), "Beam Reference counter number");
options.add_options()("CalMode", bpo::value<uint64_t>()->default_value(0), "Calibration Mode");
options.add_options()("CalSel", bpo::value<uint64_t>()->default_value(0), "Calibration Selector");
options.add_options()("CaldXdYMax", bpo::value<double_t>()->default_value(30.), "Matching Window");
options.add_options()("CalCluMulMax", bpo::value<uint64_t>()->default_value(3), "Max Counter Multiplicity");
options.add_options()("CalRefSel", bpo::value<uint64_t>()->default_value(0), "Reference Selector");
options.add_options()("CalTotMax", bpo::value<double_t>()->default_value(20.), "Time Over Threhold Maximum");
options.add_options()("CalTotMean", bpo::value<double_t>()->default_value(5.), "Time Over Threhold Mean");
options.add_options()("MaxTimeDist", bpo::value<double_t>()->default_value(1.), "Cluster range in ns");
options.add_options()("DelTofMax", bpo::value<double_t>()->default_value(60.),
"acceptance range for cluster distance");
options.add_options()("Sel2MulMax", bpo::value<double_t>()->default_value(3.), "Limit of 2nd selector multiplicity");
options.add_options()("ChannelDeadtime", bpo::value<double_t>()->default_value(50.), "channel deadtime in ns");
options.add_options()("CalYFitMin", bpo::value<double_t>()->default_value(1.E4), "Min counts for box fit");
options.add_options()("OutHstFile", bpo::value<std::string>()->default_value(""), "monitor histogram file name");
options.add_options()("OutParFile", bpo::value<std::string>()->default_value(""), "parameter histogram file name");
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
{
return new CbmDeviceHitBuilderTof();
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceHitBuilderTof(); }
#!/bin/bash
#SBATCH -J MQevb
#SBATCH -D /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/topologies
#SBATCH --time=6-00:00:00
#SBATCH --mem=4000
#SBATCH --partition=long
X=$((${SLURM_ARRAY_TASK_ID} - 0))
XXX=$(printf "%03d" "$X")
#$FAIRROOTPATH/bin/shmmonitor --cleanup
node=`hostname`
nodeStatus=`ps uaxwww | grep parmq`
nodeOK=`echo $nodeStatus | grep ParServ`
if [[ $nodeOK != "" ]]; then
echo parmq already running on node $node: $nodeOK, exiting ...
exit 0
fi
echo node check on $node passed, stop eventually relict processes
./stop_MQ.sh
#exit 0 ## debug exit
if [ -z "$1" ]; then
_runname="359"
else
_runname=$1
fi
if [ -z "$2" ]; then
_reqmod=-193
else
_reqmod=$2
fi
if [ -z "$3" ]; then
_pulmode=1
else
_pulmode=$3
fi
if [ -z "$4" ]; then
_reqtint=100
else
_reqtint=$4
fi
_Opt=$5
#_ntimeslices=-1
_ntimeslices=10000
_iUnp=4
_batch=1
_pulmulmin=5
_pultotmin=50
_pultotmax=500
#_puldetref=12 # TSR=022
#_puldetref=16 # TSR=032
_puldetref=16 # TSR=031
#_tofftof=0.
_tofftof=-35.
if [[ $_reqmod -eq 1 ]]; then
_iUnp=1
fi
#_dirname=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/input/$_runname/
_outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/data/
#_datapath=~/KRONOS/CBM/cbmroot/trunk
#_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/
#_outdir=$_datapath/macro/beamtime/mcbm2018/data/
#_filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa"
#_filename="./tsaData2020/${_runname}_pn02_*.tsa;./tsaData2020/${_runname}_pn04_*.tsa;./tsaData2020/${_runname}_pn05_*.tsa;./tsaData2020/${_runname}_pn06_*.tsa;./tsaData2020/${_runname}_pn08_*.tsa;./tsaData2020/${_runname}_pn10_*.tsa;./tsaData2020/${_runname}_pn11_*.tsa;./tsaData2020/${_runname}_pn12_*.tsa;./tsaData2020/${_runname}_pn13_*.tsa;./tsaData2020/${_runname}_pn15_*.tsa"
if [ $_runname -lt 1400 ]; then
_dirname=""
_filename="./tsaData2021/${_runname}_node8_*.tsa;./tsaData2021/${_runname}_node9_*.tsa"
_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21b_mcbm.digibdf.par
else
if [ $_runname -lt 1384 ]; then
_dirname=`ls -d /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/input06/r${_runname}*` # double stack AFCK
else
_dirname=`ls -d /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/inp07/r${_runname}*` # triple stack AFCK
fi
_filename="r${_runname}*.tsa"
_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21c_mcbm.digibdf.par
echo dir: $_dirname
echo file: $_filename
fi
_digifile=$_runname.$_reqtint.$_reqmod.${_pulmode}${_Opt}.root
# ASCII files
#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/MQ/hitbuilder/MapTofGbtx.par
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar.par
if [ $_runname -ge 707 ] && [ $_runname -lt 754 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_2Stack.par
else
if [ $_runname -ge 754 ] && [ $_runname -lt 900 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_3Stack.par
_puldetref=12 # TSR=022
else
if [ $_runname -ge 1079 ] && [ $_runname -lt 1086 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar2Stack.par
else
if [ $_runname -lt 1172 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524_DirectBeam.par
else
if [ $_runname -lt 1600 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524.par
else
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524.par
fi
fi
fi
fi
fi
#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/etofPar.par
#_digibdffile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/v18j_cosmicHD.digibdf.par
#_digiparfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v18j_cosmicHD.digi.par
#_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21a_mcbm.digibdf.par
#_digiparfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v19b_mcbm.digi.par
# ROOT files
#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root
#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_01.par.root
_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_02.par.root
# MQ ports
_pPar=5603
_pSam=5613
_pCmd=5623
_pDig=5633
#rm -v nohup.out
#rm -v *log
rm all_*
PARAMETERSERVER="parmq-server"
echo pkill $PARAMETERSERVER
pkill -9 $PARAMETERSERVER
sleep 1
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018"
#PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-name $_mapfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --second-input-name $_geofile"
PARAMETERSERVER+=" --second-input-type ROOT"
PARAMETERSERVER+=" --severity INFO"
if [[ $_batch = 1 ]]; then
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --log-to-file ParServ_${_runname}.out"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER &
else
xterm -geometry 80x23+0+340 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER &
#xterm -geometry 80x23+500+0 -hold -e /cvmfs/fairroot.gsi.de/fairroot/v18.0.6_fairsoft-may18/bin/$PARAMETERSERVER &
fi
echo Started ParameterServer
SAMPLER="TsaMultiSamplerTof"
SAMPLER+=" --id sampler1"
SAMPLER+=" --max-timeslices $_ntimeslices"
#SAMPLER+=" --max-timeslices 1000000"
#SAMPLER+=" --flib-port 10"
SAMPLER+=" --dirname $_dirname"
SAMPLER+=" --filename $_filename"
#SAMPLER+=" --flib-host myHost"
SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pSam"
SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pCmd"
#SAMPLER+=" --transport shmem"
#SAMPLER+=" --transport zeromq"
#SAMPLER+=" --transport nanomsg"
#SAMPLER+=" --severity WARN"
SAMPLER+=" --severity INFO"
#SAMPLER+=" --severity DEBUG"
SAMPLER+=" --SelectComponents 1"
if [[ $_batch = 1 ]]; then
SAMPLER+=" --log-to-file Sampl_${_runname}.out"
SAMPLER+=" --control static"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER &
else
xterm -geometry 80x23+0+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER &
fi
echo Started Sampler
while (( _iUnp > 0 )); do
UNPACKER="UnpackTofMcbm2018"
UNPACKER+=" --id unpack$_iUnp"
UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pSam"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pDig"
UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#UNPACKER+=" --transport shmem"
#UNPACKER+=" --severity DEBUG"
UNPACKER+=" --severity INFO"
UNPACKER+=" --SelectComponents 1"
if [[ $_reqmod -gt 10 ]]; then
echo define ReqBeam
#UNPACKER+=" --ReqBeam 20486" # diamond -> 0x00005006 v14a
UNPACKER+=" --ReqBeam 10246" # diamond -> 0x00002806 v21a
fi
if [[ $_reqmod -lt 1 ]]; then
UNPACKER+=" --ReqMode 0"
case $_reqmod in
0)
;;
-1)
UNPACKER+=" --ReqDet0 10246" # diamond -> 0x00002806 v21a
UNPACKER+=" --ReqDet1 32822" # RPC 031 -> 0x00008036 v21a
UNPACKER+=" --ReqDet2 32838" # RPC 041 -> 0x00008046 v21a
;;
-2)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 131126" # RPC 032
UNPACKER+=" --ReqDet2 131142" # RPC 042
;; # for ceramics
-3)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 196662" # RPC 033
UNPACKER+=" --ReqDet2 196678" # RPC 043
;; # for BUC
-4) # v21a address mode
UNPACKER+=" --ReqDet0 10246" # diamond
UNPACKER+=" --ReqDet1 65542" # RPC 002
UNPACKER+=" --ReqDet2 65574" # RPC 022
;;
-190)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 36870" # RPC 900
UNPACKER+=" --ReqDet3 102406" # RPC 901
;; # for double stack calibration
-191)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 24582" # RPC 600
UNPACKER+=" --ReqDet3 90118" # RPC 601
;; # for USTC counter analysis
-192)
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 36870" # RPC 900
UNPACKER+=" --ReqDet2 102406" # RPC 901
;; # for double stack calibration
-193) BeamBeam
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
-194)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
*)
echo ReqMode $_reqmod not yet defined, exiting
exit 1
;;
esac;
else
UNPACKER+=" --ReqMode $_reqmod"
fi
UNPACKER+=" --ReqTint $_reqtint"
UNPACKER+=" --PulserMode $_pulmode"
UNPACKER+=" --PulMulMin $_pulmulmin"
UNPACKER+=" --PulTotMin $_pultotmin"
UNPACKER+=" --PulTotMax $_pultotmax"
UNPACKER+=" --ToffTof $_tofftof"
UNPACKER+=" --RefModType 5"
UNPACKER+=" --RefModId 0"
UNPACKER+=" --RefCtrType 0"
UNPACKER+=" --RefCtrId 0"
if [[ $_batch = 1 ]]; then
UNPACKER+=" --control static"
UNPACKER+=" --log-to-file Unp${_iUnp}_${_runname}.out"
#echo nohup $UNPACKER
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER &
#echo execute interactively in a separate console: /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER
#read -p "Continue? (Y/N): "confirm && [[ $confirm == [yY] ]]
else
xterm -geometry 110x23+520+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER &
fi
(( _iUnp -= 1 ))
done
echo Started Unpacker
HITBUILDER="HitBuilderTof"
HITBUILDER+=" --id hitbuilder1"
HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pDig"
HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557"
#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558"
#HITBUILDER+=" --transport shmem"
#HITBUILDER+=" --severity DEBUG"
HITBUILDER+=" --severity INFO"
#HITBUILDER+=" --severity WARN"
HITBUILDER+=" --OutRootFile $_outdir$_digifile"
#HITBUILDER+=" --MaxEvent 10000000"
#HITBUILDER+=" --RunId 1552883952"
#HITBUILDER+=" --RunId 1614415472" # tof_mcbm_beam_2021_01.par.root
HITBUILDER+=" --RunId 1621902311" # tof_mcbm_beam_2021_02.par.root
HITBUILDER+=" --PulserMode $_pulmode"
HITBUILDER+=" --PulMulMin $_pulmulmin"
HITBUILDER+=" --PulTotMin $_pultotmin"
HITBUILDER+=" --PulTotMax $_pultotmax"
HITBUILDER+=" --PulDetRef $_puldetref"
HITBUILDER+=" --ReqTint $_reqtint"
#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006
HITBUILDER+=" --BRefType 0"
HITBUILDER+=" --BRefSm 4"
HITBUILDER+=" --BRefDet 1"
HITBUILDER+=" --DutType 0"
HITBUILDER+=" --DutSm 3"
HITBUILDER+=" --DutRpc 1"
HITBUILDER+=" --SelType 0"
HITBUILDER+=" --SelSm 4"
HITBUILDER+=" --SelRpc 1"
HITBUILDER+=" --Sel2Type 5"
HITBUILDER+=" --Sel2Sm 0"
HITBUILDER+=" --Sel2Rpc 0"
if [[ $_reqmod -eq 1 ]]; then
HITBUILDER+=" --Mode 1"
fi
if [[ $_batch = 1 ]]; then
HITBUILDER+=" --control static"
HITBUILDER+=" --log-to-file HitBuild_${_runname}.out"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER &
else
xterm -geometry 120x23+1400+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER &
fi
echo Started HitBuilder
# show daughter processes
ps
# wait for completion
RUNTIMEMAX=28000
DeltaTime=120
RunTime=0
while [ $RunTime -lt $RUNTIMEMAX ]; do
PROC=`ps uaxww | grep Hit`
ProcRunning=`echo $PROC | grep Builder`
if [[ $ProcRunning != "" ]]; then
(( Runtime += DeltaTime ))
sleep $DeltaTime
else
echo No HitBuilder in $PROC
break;
fi
done
#sleep 14400 # 4h
#sleep 28000 # 8h
echo kill all MQ processes
./stop_MQ.sh
echo done
#!/bin/bash
#SBATCH -J MQevb
#SBATCH -D /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/topologies
#SBATCH --time=6-00:00:00
#SBATCH --mem=4000
#SBATCH --partition=long
X=$((${SLURM_ARRAY_TASK_ID} - 0))
XXX=$(printf "%03d" "$X")
#$FAIRROOTPATH/bin/shmmonitor --cleanup
node=`hostname`
nodeStatus=`ps uaxwww | grep parmq`
nodeOK=`echo $nodeStatus | grep ParServ`
if [[ $nodeOK != "" ]]; then
echo parmq already running on node $node: $nodeOK, exiting ...
exit 0
fi
echo node check on $node passed, stop eventually relict processes
./stop_MQ.sh
#exit 0 ## debug exit
if [ -z "$1" ]; then
_runname="359"
else
_runname=$1
fi
if [ -z "$2" ]; then
_reqmod=-193
else
_reqmod=$2
fi
if [ -z "$3" ]; then
_pulmode=1
else
_pulmode=$3
fi
if [ -z "$4" ]; then
_reqtint=100
else
_reqtint=$4
fi
_Opt=$5
_ntimeslices=-1
#_ntimeslices=10000
_iUnp=1
_batch=1
_pulmulmin=5
_pultotmin=50
_pultotmax=500
#_puldetref=12 # TSR=022
#_puldetref=16 # TSR=032
_puldetref=16 # TSR=031
#_tofftof=0.
_tofftof=-35.
if [[ $_reqmod -eq 1 ]]; then
_iUnp=1
fi
#_dirname=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/input/$_runname/
_outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/data/
#_datapath=~/KRONOS/CBM/cbmroot/trunk
#_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/
#_outdir=$_datapath/macro/beamtime/mcbm2018/data/
#_filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa"
#_filename="./tsaData2020/${_runname}_pn02_*.tsa;./tsaData2020/${_runname}_pn04_*.tsa;./tsaData2020/${_runname}_pn05_*.tsa;./tsaData2020/${_runname}_pn06_*.tsa;./tsaData2020/${_runname}_pn08_*.tsa;./tsaData2020/${_runname}_pn10_*.tsa;./tsaData2020/${_runname}_pn11_*.tsa;./tsaData2020/${_runname}_pn12_*.tsa;./tsaData2020/${_runname}_pn13_*.tsa;./tsaData2020/${_runname}_pn15_*.tsa"
if [ $_runname -lt 1400 ]; then
_dirname=""
_filename="./tsaData2021/${_runname}_node8_*.tsa;./tsaData2021/${_runname}_node9_*.tsa"
_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21b_mcbm.digibdf.par
else
if [ $_runname -lt 1384 ]; then
_dirname=`ls -d /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/input06/r${_runname}*` # double stack AFCK
else
_dirname=`ls -d /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/inp07/r${_runname}*` # triple stack AFCK
fi
_filename="r${_runname}*.tsa"
_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21c_mcbm.digibdf.par
echo dir: $_dirname
echo file: $_filename
fi
_digifile=$_runname.$_reqtint.$_reqmod.${_pulmode}${_Opt}.root
# ASCII files
#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/MQ/hitbuilder/MapTofGbtx.par
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar.par
if [ $_runname -ge 707 ] && [ $_runname -lt 754 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_2Stack.par
else
if [ $_runname -ge 754 ] && [ $_runname -lt 900 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_3Stack.par
_puldetref=12 # TSR=022
else
if [ $_runname -ge 1079 ] && [ $_runname -lt 1086 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar2Stack.par
else
if [ $_runname -lt 1172 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524_DirectBeam.par
else
if [ $_runname -lt 1600 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524.par
else
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524.par
fi
fi
fi
fi
fi
#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/etofPar.par
#_digibdffile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/v18j_cosmicHD.digibdf.par
#_digiparfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v18j_cosmicHD.digi.par
#_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21a_mcbm.digibdf.par
#_digiparfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v19b_mcbm.digi.par
# ROOT files
#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root
#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_01.par.root
_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_02.par.root
# MQ ports
_pPar=5603
_pSam=5613
_pCmd=5623
_pDig=5633
#rm -v nohup.out
#rm -v *log
rm all_*
PARAMETERSERVER="parmq-server"
echo pkill $PARAMETERSERVER
pkill -9 $PARAMETERSERVER
sleep 1
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018"
#PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-name $_mapfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --second-input-name $_geofile"
PARAMETERSERVER+=" --second-input-type ROOT"
PARAMETERSERVER+=" --severity INFO"
if [[ $_batch = 1 ]]; then
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --log-to-file ParServ_${_runname}.out"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER &
else
xterm -geometry 80x23+0+340 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER &
#xterm -geometry 80x23+500+0 -hold -e /cvmfs/fairroot.gsi.de/fairroot/v18.0.6_fairsoft-may18/bin/$PARAMETERSERVER &
fi
echo Started ParameterServer
SAMPLER="TsaMultiSamplerTof"
SAMPLER+=" --id sampler1"
SAMPLER+=" --max-timeslices $_ntimeslices"
#SAMPLER+=" --max-timeslices 1000000"
#SAMPLER+=" --flib-port 10"
#SAMPLER+=" --dirname $_dirname"
SAMPLER+=" --filename $_filename"
#SAMPLER+=" --flib-host myHost"
SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pSam"
SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pCmd"
#SAMPLER+=" --transport shmem"
#SAMPLER+=" --transport zeromq"
#SAMPLER+=" --transport nanomsg"
#SAMPLER+=" --severity WARN"
SAMPLER+=" --severity INFO"
#SAMPLER+=" --severity DEBUG"
SAMPLER+=" --SelectComponents 1"
if [[ $_batch = 1 ]]; then
SAMPLER+=" --log-to-file Sampl_${_runname}.out"
SAMPLER+=" --control static"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER &
else
xterm -geometry 80x23+0+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER &
fi
echo Started Sampler
while (( _iUnp > 0 )); do
UNPACKER="UnpackTofMcbm2018"
UNPACKER+=" --id unpack$_iUnp"
UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pSam"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pDig"
UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#UNPACKER+=" --transport shmem"
#UNPACKER+=" --severity DEBUG"
UNPACKER+=" --severity INFO"
UNPACKER+=" --SelectComponents 1"
if [[ $_reqmod -gt 10 ]]; then
echo define ReqBeam
#UNPACKER+=" --ReqBeam 20486" # diamond -> 0x00005006 v14a
UNPACKER+=" --ReqBeam 10246" # diamond -> 0x00002806 v21a
fi
if [[ $_reqmod -lt 1 ]]; then
UNPACKER+=" --ReqMode 0"
case $_reqmod in
0)
;;
-1)
UNPACKER+=" --ReqDet0 10246" # diamond -> 0x00002806 v21a
UNPACKER+=" --ReqDet1 32822" # RPC 031 -> 0x00008036 v21a
UNPACKER+=" --ReqDet2 32838" # RPC 041 -> 0x00008046 v21a
;;
-2)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 131126" # RPC 032
UNPACKER+=" --ReqDet2 131142" # RPC 042
;; # for ceramics
-3)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 196662" # RPC 033
UNPACKER+=" --ReqDet2 196678" # RPC 043
;; # for BUC
-4) # v21a address mode
UNPACKER+=" --ReqDet0 10246" # diamond
UNPACKER+=" --ReqDet1 65542" # RPC 002
UNPACKER+=" --ReqDet2 65574" # RPC 022
;;
-190)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 36870" # RPC 900
UNPACKER+=" --ReqDet3 102406" # RPC 901
;; # for double stack calibration
-191)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 24582" # RPC 600
UNPACKER+=" --ReqDet3 90118" # RPC 601
;; # for USTC counter analysis
-192)
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 36870" # RPC 900
UNPACKER+=" --ReqDet2 102406" # RPC 901
;; # for double stack calibration
-193) BeamBeam
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
-194)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
*)
echo ReqMode $_reqmod not yet defined, exiting
exit 1
;;
esac;
else
UNPACKER+=" --ReqMode $_reqmod"
fi
UNPACKER+=" --ReqTint $_reqtint"
UNPACKER+=" --PulserMode $_pulmode"
UNPACKER+=" --PulMulMin $_pulmulmin"
UNPACKER+=" --PulTotMin $_pultotmin"
UNPACKER+=" --PulTotMax $_pultotmax"
UNPACKER+=" --ToffTof $_tofftof"
UNPACKER+=" --RefModType 5"
UNPACKER+=" --RefModId 0"
UNPACKER+=" --RefCtrType 0"
UNPACKER+=" --RefCtrId 0"
if [[ $_batch = 1 ]]; then
UNPACKER+=" --control static"
UNPACKER+=" --log-to-file Unp${_iUnp}_${_runname}.out"
#echo nohup $UNPACKER
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER &
#echo execute interactively in a separate console: /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER
#read -p "Continue? (Y/N): "confirm && [[ $confirm == [yY] ]]
else
xterm -geometry 110x23+520+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER &
fi
(( _iUnp -= 1 ))
done
echo Started Unpacker
HITBUILDER="HitBuilderTof"
HITBUILDER+=" --id hitbuilder1"
HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pDig"
HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557"
#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558"
#HITBUILDER+=" --transport shmem"
#HITBUILDER+=" --severity DEBUG"
HITBUILDER+=" --severity INFO"
#HITBUILDER+=" --severity WARN"
HITBUILDER+=" --OutRootFile $_outdir$_digifile"
#HITBUILDER+=" --MaxEvent 10000000"
#HITBUILDER+=" --RunId 1552883952"
#HITBUILDER+=" --RunId 1614415472" # tof_mcbm_beam_2021_01.par.root
HITBUILDER+=" --RunId 1621902311" # tof_mcbm_beam_2021_02.par.root
HITBUILDER+=" --PulserMode $_pulmode"
HITBUILDER+=" --PulMulMin $_pulmulmin"
HITBUILDER+=" --PulTotMin $_pultotmin"
HITBUILDER+=" --PulTotMax $_pultotmax"
HITBUILDER+=" --PulDetRef $_puldetref"
HITBUILDER+=" --ReqTint $_reqtint"
#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006
HITBUILDER+=" --BRefType 0"
HITBUILDER+=" --BRefSm 4"
HITBUILDER+=" --BRefDet 1"
HITBUILDER+=" --DutType 0"
HITBUILDER+=" --DutSm 3"
HITBUILDER+=" --DutRpc 1"
HITBUILDER+=" --SelType 0"
HITBUILDER+=" --SelSm 4"
HITBUILDER+=" --SelRpc 1"
HITBUILDER+=" --Sel2Type 5"
HITBUILDER+=" --Sel2Sm 0"
HITBUILDER+=" --Sel2Rpc 0"
if [[ $_reqmod -eq 1 ]]; then
HITBUILDER+=" --Mode 1"
fi
if [[ $_batch = 1 ]]; then
HITBUILDER+=" --control static"
HITBUILDER+=" --log-to-file HitBuild_${_runname}.out"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER &
else
xterm -geometry 120x23+1400+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER &
fi
echo Started HitBuilder
# show daughter processes
ps
# wait for completion
RUNTIMEMAX=28000
DeltaTime=120
RunTime=0
while [ $RunTime -lt $RUNTIMEMAX ]; do
PROC=`ps uaxww | grep Hit`
ProcRunning=`echo $PROC | grep Builder`
if [[ $ProcRunning != "" ]]; then
(( Runtime += DeltaTime ))
sleep $DeltaTime
else
echo No HitBuilder in $PROC
break;
fi
done
#sleep 14400 # 4h
#sleep 28000 # 8h
echo kill all MQ processes
./stop_MQ.sh
echo done
#!/bin/bash
Running=`ps uaxww | grep HitB`
if [[ $Running == *"hitbuilder1"* ]]; then
if [[ $Running == *"hitbuilder1"* ]]; then
echo Hitbuilder is still running, wait or cleanup!
exit 1
exit 1
fi
$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
_runname="r0088_20180905_1602"
else
else
_runname=$1
fi
_reqmod=3
_reqtint=100
_reqmod=3
_reqtint=100
_batch=1
_iUnp=6
......@@ -25,18 +26,18 @@ _dirname=@VMCWORKDIR@/macro/beamtime/star2019/input/$_runname/
_filename=$_runname_*.tsa
_digifile=$_runname.$_reqtint.$_reqmod.root
# ASCII files
# ASCII files
_mapfile=@CMAKE_CURRENT_SOURCE_DIR@/MapTofGbtx.par
#_digibdffile=@CMAKE_CURRENT_SOURCE_DIR@/v18j_cosmicHD.digibdf.par
#_digiparfile=@CMAKE_CURRENT_SOURCE_DIR@/tof_v18j_cosmicHD.digi.par
_digibdffile=@VMCWORKDIR@/parameters/tof/v18_star_cosmics.digibdf.par
_digiparfile=@VMCWORKDIR@/parameters/tof/tof_v18_star_cosmics.digi.par
# ROOT files
# ROOT files
#_geofile=@CMAKE_CURRENT_SOURCE_DIR@/tof_v18j_cosmicHD.par.root
_geofile=@CMAKE_CURRENT_SOURCE_DIR@/tof_v18_star_cosmics.par.root
rm -v nohup.out
rm -v nohup.out
rm -v *log
rm all_*
......@@ -53,7 +54,7 @@ PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --second-input-name $_geofile"
PARAMETERSERVER+=" --second-input-type ROOT"
PARAMETERSERVER+=" --verbosity INFO"
if [[ $_batch = 1 ]]; then
if [[ $_batch = 1 ]]; then
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --log-to-file ParServ.out"
nohup @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &
......@@ -78,14 +79,14 @@ SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,transport=zeromq,ad
#SAMPLER+=" --verbosity WARN"
SAMPLER+=" --verbosity INFO"
#SAMPLER+=" --verbosity DEBUG"
if [[ $_batch = 1 ]]; then
if [[ $_batch = 1 ]]; then
SAMPLER+=" --log-to-file Sampl.out"
SAMPLER+=" --control static"
nohup @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
else
nohup @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
else
xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
fi
while (( _iUnp > 0 )); do
UNPACKER="UnpackTofMcbm2018"
......@@ -117,16 +118,16 @@ UNPACKER+=" --ReqDet14 131110"
UNPACKER+=" --ReqDet15 131126"
UNPACKER+=" --ReqDet16 131142"
UNPACKER+=" --ReqDet17 131158"
if [[ $_batch = 1 ]]; then
if [[ $_batch = 1 ]]; then
UNPACKER+=" --control static"
UNPACKER+=" --log-to-file Unp.out"
nohup @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER &
else
xterm -geometry 110x23+520+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER &
else
xterm -geometry 110x23+520+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER &
fi
(( _iUnp -= 1 ))
done
done
HITBUILDER="HitBuilderTof"
HITBUILDER+=" --id hitbuilder1"
......@@ -144,7 +145,7 @@ HITBUILDER+=" --OutRootFile $_digifile"
HITBUILDER+=" --RunId 1538835959"
#HITBUILDER+=" --RunId 1536669562"
#HITBUILDER+=" --RunId 1537898701"
if [[ $_batch = 1 ]]; then
if [[ $_batch = 1 ]]; then
HITBUILDER+=" --control static"
HITBUILDER+=" --log-to-file HitBuild.out"
nohup @CMAKE_BINARY_DIR@/bin/MQ/hitbuilder/$HITBUILDER &
......
#!/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
_runname="r0088_20180905_1602"
else
else
_runname=$1
fi
_reqmod=3
_reqtint=50
_ntimeslices=-1
_iUnp=4
_batch=1
_pulmode=1
_pulmode=1
_pulmulmin=9
_pultotmin=50
#_tshiftref=0.
_tshiftref=-35.
#_tshiftref=0.
_tshiftref=-35.
#_dirname=@VMCWORKDIR@/macro/beamtime/mcbm2018/input/$_runname/
_outdir=@VMCWORKDIR@/macro/beamtime/mcbm2018/data/
#_datapath=~/KRONOS/CBM/cbmroot/trunk
#_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/
#_outdir=$_datapath/macro/beamtime/mcbm2018/data/
_filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa"
_digifile=$_runname.$_reqtint.$_reqmod.$_pulmode.root
# ASCII files
# ASCII files
#_mapfile=@CMAKE_CURRENT_SOURCE_DIR@/MapTofGbtx.par
_mapfile=@VMCWORKDIR@/macro/beamtime/mcbm2018/mTofPar.par
#_mapfile=@VMCWORKDIR@/macro/beamtime/mcbm2018/etofPar.par
......@@ -36,10 +38,10 @@ _mapfile=@VMCWORKDIR@/macro/beamtime/mcbm2018/mTofPar.par
_digibdffile=@VMCWORKDIR@/parameters/tof/v18l_mCbm.digibdf.par
_digiparfile=@VMCWORKDIR@/parameters/tof/tof_v18l_mCbm.digi.par
# ROOT files
# ROOT files
_geofile=@VMCWORKDIR@/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root
rm -v nohup.out
rm -v nohup.out
rm -v *log
rm all_*
......@@ -57,7 +59,7 @@ PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --second-input-name $_geofile"
PARAMETERSERVER+=" --second-input-type ROOT"
PARAMETERSERVER+=" --severity INFO"
if [[ $_batch = 1 ]]; then
if [[ $_batch = 1 ]]; then
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --log-to-file ParServ.out"
nohup @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &
......@@ -82,14 +84,14 @@ SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,transport=zeromq,ad
#SAMPLER+=" --severity WARN"
SAMPLER+=" --severity INFO"
#SAMPLER+=" --severity DEBUG"
if [[ $_batch = 1 ]]; then
if [[ $_batch = 1 ]]; then
SAMPLER+=" --log-to-file Sampl.out"
SAMPLER+=" --control static"
nohup @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
else
nohup @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
else
xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
fi
while (( _iUnp > 0 )); do
UNPACKER="UnpackTofMcbm2018"
......@@ -107,16 +109,16 @@ UNPACKER+=" --PulserMode $_pulmode"
UNPACKER+=" --PulMulMin $_pulmulmin"
UNPACKER+=" --PulTotMin $_pultotmin"
UNPACKER+=" --TShiftRef $_tshiftref"
if [[ $_batch = 1 ]]; then
if [[ $_batch = 1 ]]; then
UNPACKER+=" --control static"
UNPACKER+=" --log-to-file Unp.out"
nohup @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER &
else
xterm -geometry 110x23+520+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER &
else
xterm -geometry 110x23+520+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER &
fi
(( _iUnp -= 1 ))
done
done
HITBUILDER="HitBuilderTof"
HITBUILDER+=" --id hitbuilder1"
......@@ -148,7 +150,7 @@ HITBUILDER+=" --Sel2Type 0"
HITBUILDER+=" --Sel2Sm 2"
HITBUILDER+=" --Sel2Rpc 2"
if [[ $_batch = 1 ]]; then
if [[ $_batch = 1 ]]; then
HITBUILDER+=" --control static"
HITBUILDER+=" --log-to-file HitBuild.out"
nohup @CMAKE_BINARY_DIR@/bin/MQ/hitbuilder/$HITBUILDER &
......
#!/bin/bash
# Copyright (C) 2020 PI-UHd,GSI
# SPDX-License-Identifier: GPL-3.0-only
# First commited by Norbert Herrmann
$FAIRROOTPATH/bin/shmmonitor --cleanup
if [ -z "$1" ]; then
_runname="359"
else
_runname=$1
fi
if [ -z "$2" ]; then
_reqmod=-193
else
_reqmod=$2
fi
if [ -z "$3" ]; then
_pulmode=1
else
_pulmode=$3
fi
if [ -z "$4" ]; then
_reqtint=100
else
_reqtint=$4
fi
_Opt=$5
_ntimeslices=-1
#_ntimeslices=10000
_iUnp=4
_batch=1
_pulmulmin=5
_pultotmin=50
_pultotmax=500
_puldetref=12 # TSR=022
#_puldetref=16 # TSR=032
#_puldetref=17 # TSR=032
#_tofftof=0.
_tofftof=30.
if [[ $_reqmod -eq 1 ]]; then
_iUnp=1
fi
#_dirname=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/input/$_runname/
_outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/data/
#_datapath=~/KRONOS/CBM/cbmroot/trunk
#_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/
#_outdir=$_datapath/macro/beamtime/mcbm2018/data/
#_filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa"
_filename="./tsaData/${_runname}_pn02_*.tsa;./tsaData/${_runname}_pn04_*.tsa;./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa;./tsaData/${_runname}_pn08_*.tsa;./tsaData/${_runname}_pn10_*.tsa"
#_filename="./tsaData2020/${_runname}_pn02_*.tsa;./tsaData2020/${_runname}_pn04_*.tsa;./tsaData2020/${_runname}_pn05_*.tsa;./tsaData2020/${_runname}_pn06_*.tsa;./tsaData2020/${_runname}_pn08_*.tsa;./tsaData2020/${_runname}_pn10_*.tsa;./tsaData2020/${_runname}_pn11_*.tsa;./tsaData2020/${_runname}_pn12_*.tsa;./tsaData2020/${_runname}_pn13_*.tsa;./tsaData2020/${_runname}_pn15_*.tsa"
_digifile=$_runname.$_reqtint.$_reqmod.${_pulmode}${_Opt}.root
# ASCII files
#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/MQ/hitbuilder/MapTofGbtx.par
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/mTofPar.par
if [ $_runname -ge 707 ] && [ $_runname -lt 754 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_2Stack.par
else
if [ $_runname -ge 754 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_3Stack.par
_puldetref=12 # TSR=022
fi
fi
#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/etofPar.par
#_digibdffile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/v18j_cosmicHD.digibdf.par
#_digiparfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v18j_cosmicHD.digi.par
_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/v19b_mcbm.digibdf.par
_digiparfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v19b_mcbm.digi.par
# ROOT files
#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root
_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/tof_mcbm_beam_2019_03.par.root
# MQ ports
_pPar=5603
_pSam=5613
_pCmd=5623
_pDig=5633
rm -v nohup.out
rm -v *log
rm all_*
PARAMETERSERVER="parmq-server"
echo pkill $PARAMETERSERVER
pkill -9 $PARAMETERSERVER
pkill -9 $PARAMETERSERVER
sleep 1
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018"
PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --second-input-name $_geofile"
PARAMETERSERVER+=" --second-input-type ROOT"
PARAMETERSERVER+=" --severity INFO"
if [[ $_batch = 1 ]]; then
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --log-to-file ParServ.out"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER &
else
xterm -geometry 80x23+0+340 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER &
#xterm -geometry 80x23+500+0 -hold -e /cvmfs/fairroot.gsi.de/fairroot/v18.0.6_fairsoft-may18/bin/$PARAMETERSERVER &
fi
SAMPLER="TsaMultiSamplerTof"
SAMPLER+=" --id sampler1"
SAMPLER+=" --max-timeslices $_ntimeslices"
#SAMPLER+=" --max-timeslices 1000000"
#SAMPLER+=" --flib-port 10"
#SAMPLER+=" --dirname $_dirname"
SAMPLER+=" --filename $_filename"
#SAMPLER+=" --flib-host myHost"
SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pSam"
SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pCmd"
#SAMPLER+=" --transport shmem"
#SAMPLER+=" --transport zeromq"
#SAMPLER+=" --transport nanomsg"
#SAMPLER+=" --severity WARN"
SAMPLER+=" --severity INFO"
#SAMPLER+=" --severity DEBUG"
SAMPLER+=" --SelectComponents 1"
if [[ $_batch = 1 ]]; then
SAMPLER+=" --log-to-file Sampl.out"
SAMPLER+=" --control static"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER &
else
xterm -geometry 80x23+0+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER &
fi
while (( _iUnp > 0 )); do
UNPACKER="UnpackTofMcbm2018"
UNPACKER+=" --id unpack$_iUnp"
UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pSam"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pDig"
UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#UNPACKER+=" --transport shmem"
#UNPACKER+=" --severity DEBUG"
UNPACKER+=" --severity INFO"
UNPACKER+=" --SelectComponents 1"
#UNPACKER+=" --ReqBeam 20486" # diamond -> 0x00005006 v14a
UNPACKER+=" --ReqBeam 10246" # diamond -> 0x00002806 v21a
if [[ $_reqmod -lt 1 ]]; then
UNPACKER+=" --ReqMode 0"
case $_reqmod in
0)
;;
-1)
UNPACKER+=" --ReqDet0 20486" # diamond -> 0x00005006
UNPACKER+=" --ReqDet1 65590" # RPC 031 -> 0x00010036
UNPACKER+=" --ReqDet2 65606" # RPC 041
;;
-2)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 131126" # RPC 032
UNPACKER+=" --ReqDet2 131142" # RPC 042
;; # for ceramics
-3)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 196662" # RPC 033
UNPACKER+=" --ReqDet2 196678" # RPC 043
;; # for BUC
-4) # v21a address mode
UNPACKER+=" --ReqDet0 10246" # diamond
UNPACKER+=" --ReqDet1 65542" # RPC 022
UNPACKER+=" --ReqDet2 65574" # RPC 022
;;
-190)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 36870" # RPC 900
UNPACKER+=" --ReqDet3 102406" # RPC 901
;; # for double stack calibration
-191)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 24582" # RPC 600
UNPACKER+=" --ReqDet3 90118" # RPC 601
;; # for USTC counter analysis
-192)
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 36870" # RPC 900
UNPACKER+=" --ReqDet2 102406" # RPC 901
;; # for double stack calibration
-193) BeamBeam
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
-194)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
*)
echo ReqMode $_reqmod not yet defined, exiting
exit 1
;;
esac;
else
UNPACKER+=" --ReqMode $_reqmod"
fi
UNPACKER+=" --ReqTint $_reqtint"
UNPACKER+=" --PulserMode $_pulmode"
UNPACKER+=" --PulMulMin $_pulmulmin"
UNPACKER+=" --PulTotMin $_pultotmin"
UNPACKER+=" --PulTotMax $_pultotmax"
UNPACKER+=" --ToffTof $_tofftof"
UNPACKER+=" --RefModType 5"
UNPACKER+=" --RefModId 0"
UNPACKER+=" --RefCtrType 0"
UNPACKER+=" --RefCtrId 0"
if [[ $_batch = 1 ]]; then
UNPACKER+=" --control static"
UNPACKER+=" --log-to-file Unp$_iUnp.out"
#echo nohup $UNPACKER
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER &
else
xterm -geometry 110x23+520+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER &
fi
(( _iUnp -= 1 ))
done
HITBUILDER="HitBuilderTof"
HITBUILDER+=" --id hitbuilder1"
HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pDig"
HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557"
#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558"
#HITBUILDER+=" --transport shmem"
#HITBUILDER+=" --severity DEBUG"
HITBUILDER+=" --severity INFO"
#HITBUILDER+=" --severity WARN"
HITBUILDER+=" --OutRootFile $_outdir$_digifile"
#HITBUILDER+=" --MaxEvent 10000000"
#HITBUILDER+=" --RunId 1552883952"
HITBUILDER+=" --RunId 1601311083"
HITBUILDER+=" --PulserMode $_pulmode"
HITBUILDER+=" --PulMulMin $_pulmulmin"
HITBUILDER+=" --PulTotMin $_pultotmin"
HITBUILDER+=" --PulTotMax $_pultotmax"
HITBUILDER+=" --PulDetRef $_puldetref"
HITBUILDER+=" --ReqTint $_reqtint"
#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006
HITBUILDER+=" --BRefType 5"
HITBUILDER+=" --BRefSm 0"
HITBUILDER+=" --BRefDet 0"
HITBUILDER+=" --DutType 0"
HITBUILDER+=" --DutSm 3"
HITBUILDER+=" --DutRpc 1"
HITBUILDER+=" --SelType 0"
HITBUILDER+=" --SelSm 4"
HITBUILDER+=" --SelRpc 1"
HITBUILDER+=" --Sel2Type 5"
HITBUILDER+=" --Sel2Sm 0"
HITBUILDER+=" --Sel2Rpc 0"
if [[ $_reqmod -eq 1 ]]; then
HITBUILDER+=" --Mode 1"
fi
if [[ $_batch = 1 ]]; then
HITBUILDER+=" --control static"
HITBUILDER+=" --log-to-file HitBuild.out"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER &
else
xterm -geometry 120x23+1400+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER &
fi
#!/bin/bash
# Copyright (C) 2020 PI-UHd,GSI
# SPDX-License-Identifier: GPL-3.0-only
# First commited by Norbert Herrmann
$FAIRROOTPATH/bin/shmmonitor --cleanup
if [ -z "$1" ]; then
_runname="359"
else
_runname=$1
fi
if [ -z "$2" ]; then
_reqmod=-193
else
_reqmod=$2
fi
if [ -z "$3" ]; then
_pulmode=1
else
_pulmode=$3
fi
if [ -z "$4" ]; then
_reqtint=100
else
_reqtint=$4
fi
_Opt=$5
_ntimeslices=-1
#_ntimeslices=10000
_iUnp=1
_batch=1
_pulmulmin=5
_pultotmin=50
_pultotmax=500
#_puldetref=12 # TSR=022
_puldetref=16 # TSR=032
#_tofftof=0.
_tofftof=-30.
if [[ $_reqmod -eq 1 ]]; then
_iUnp=1
fi
#_dirname=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/input/$_runname/
_outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/data/
#_datapath=~/KRONOS/CBM/cbmroot/trunk
#_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/
#_outdir=$_datapath/macro/beamtime/mcbm2018/data/
#_filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa"
_filename="./tsaData2020/${_runname}_pn02_*.tsa;./tsaData2020/${_runname}_pn04_*.tsa;./tsaData2020/${_runname}_pn05_*.tsa;./tsaData2020/${_runname}_pn06_*.tsa;./tsaData2020/${_runname}_pn08_*.tsa;./tsaData2020/${_runname}_pn10_*.tsa;./tsaData2020/${_runname}_pn11_*.tsa;./tsaData2020/${_runname}_pn12_*.tsa;./tsaData2020/${_runname}_pn13_*.tsa;./tsaData2020/${_runname}_pn15_*.tsa"
_digifile=$_runname.$_reqtint.$_reqmod.${_pulmode}${_Opt}.root
# ASCII files
#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/MQ/hitbuilder/MapTofGbtx.par
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar.par
if [ $_runname -ge 707 ] && [ $_runname -lt 754 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_2Stack.par
else
if [ $_runname -ge 754 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_3Stack.par
_puldetref=12 # TSR=022
fi
fi
#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/etofPar.par
#_digibdffile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/v18j_cosmicHD.digibdf.par
#_digiparfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v18j_cosmicHD.digi.par
_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/v19b_mcbm.digibdf.par
#_digiparfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v19b_mcbm.digi.par
# ROOT files
#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root
_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/tof_mcbm_beam_2019_03.par.root
# MQ ports
_pPar=5603
_pSam=5613
_pCmd=5623
_pDig=5633
rm -v nohup.out
rm -v *log
rm all_*
PARAMETERSERVER="parmq-server"
echo pkill $PARAMETERSERVER
pkill -9 $PARAMETERSERVER
pkill -9 $PARAMETERSERVER
sleep 1
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018"
#PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-name $_mapfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --second-input-name $_geofile"
PARAMETERSERVER+=" --second-input-type ROOT"
PARAMETERSERVER+=" --severity INFO"
if [[ $_batch = 1 ]]; then
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --log-to-file ParServ.out"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER &
else
xterm -geometry 80x23+0+340 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER &
#xterm -geometry 80x23+500+0 -hold -e /cvmfs/fairroot.gsi.de/fairroot/v18.0.6_fairsoft-may18/bin/$PARAMETERSERVER &
fi
SAMPLER="TsaMultiSamplerTof"
SAMPLER+=" --id sampler1"
SAMPLER+=" --max-timeslices $_ntimeslices"
#SAMPLER+=" --max-timeslices 1000000"
#SAMPLER+=" --flib-port 10"
#SAMPLER+=" --dirname $_dirname"
SAMPLER+=" --filename $_filename"
#SAMPLER+=" --flib-host myHost"
SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pSam"
SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pCmd"
#SAMPLER+=" --transport shmem"
#SAMPLER+=" --transport zeromq"
#SAMPLER+=" --transport nanomsg"
#SAMPLER+=" --severity WARN"
SAMPLER+=" --severity INFO"
#SAMPLER+=" --severity DEBUG"
SAMPLER+=" --SelectComponents 1"
if [[ $_batch = 1 ]]; then
SAMPLER+=" --log-to-file Sampl.out"
SAMPLER+=" --control static"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER &
else
xterm -geometry 80x23+0+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER &
fi
while (( _iUnp > 0 )); do
UNPACKER="UnpackTofMcbm2018"
UNPACKER+=" --id unpack$_iUnp"
UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pSam"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pDig"
UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#UNPACKER+=" --transport shmem"
#UNPACKER+=" --severity DEBUG"
UNPACKER+=" --severity INFO"
UNPACKER+=" --SelectComponents 1"
#UNPACKER+=" --ReqBeam 20486" # diamond -> 0x00005006 v14a
UNPACKER+=" --ReqBeam 10246" # diamond -> 0x00002806 v21a
if [[ $_reqmod -lt 1 ]]; then
UNPACKER+=" --ReqMode 0"
case $_reqmod in
0)
;;
-1)
UNPACKER+=" --ReqDet0 10246" # diamond -> 0x00002806 v21a
UNPACKER+=" --ReqDet1 32822" # RPC 031 -> 0x00008036 v21a
UNPACKER+=" --ReqDet2 32838" # RPC 041 -> 0x00008046 v21a
;;
-2)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 131126" # RPC 032
UNPACKER+=" --ReqDet2 131142" # RPC 042
;; # for ceramics
-3)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 196662" # RPC 033
UNPACKER+=" --ReqDet2 196678" # RPC 043
;; # for BUC
-4) # v21a address mode
UNPACKER+=" --ReqDet0 10246" # diamond
UNPACKER+=" --ReqDet1 65542" # RPC 002
UNPACKER+=" --ReqDet2 65574" # RPC 022
;;
-190)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 36870" # RPC 900
UNPACKER+=" --ReqDet3 102406" # RPC 901
;; # for double stack calibration
-191)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 24582" # RPC 600
UNPACKER+=" --ReqDet3 90118" # RPC 601
;; # for USTC counter analysis
-192)
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 36870" # RPC 900
UNPACKER+=" --ReqDet2 102406" # RPC 901
;; # for double stack calibration
-193) BeamBeam
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
-194)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
*)
echo ReqMode $_reqmod not yet defined, exiting
exit 1
;;
esac;
else
UNPACKER+=" --ReqMode $_reqmod"
fi
UNPACKER+=" --ReqTint $_reqtint"
UNPACKER+=" --PulserMode $_pulmode"
UNPACKER+=" --PulMulMin $_pulmulmin"
UNPACKER+=" --PulTotMin $_pultotmin"
UNPACKER+=" --PulTotMax $_pultotmax"
UNPACKER+=" --ToffTof $_tofftof"
UNPACKER+=" --RefModType 5"
UNPACKER+=" --RefModId 0"
UNPACKER+=" --RefCtrType 0"
UNPACKER+=" --RefCtrId 0"
if [[ $_batch = 1 ]]; then
UNPACKER+=" --control static"
UNPACKER+=" --log-to-file Unp$_iUnp.out"
#echo nohup $UNPACKER
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER &
else
xterm -geometry 110x23+520+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER &
fi
(( _iUnp -= 1 ))
done
HITBUILDER="HitBuilderTof"
HITBUILDER+=" --id hitbuilder1"
HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pDig"
HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557"
#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558"
#HITBUILDER+=" --transport shmem"
#HITBUILDER+=" --severity DEBUG"
HITBUILDER+=" --severity INFO"
#HITBUILDER+=" --severity WARN"
HITBUILDER+=" --OutRootFile $_outdir$_digifile"
#HITBUILDER+=" --MaxEvent 10000000"
#HITBUILDER+=" --RunId 1552883952"
HITBUILDER+=" --RunId 1601311083"
HITBUILDER+=" --PulserMode $_pulmode"
HITBUILDER+=" --PulMulMin $_pulmulmin"
HITBUILDER+=" --PulTotMin $_pultotmin"
HITBUILDER+=" --PulTotMax $_pultotmax"
HITBUILDER+=" --PulDetRef $_puldetref"
HITBUILDER+=" --ReqTint $_reqtint"
#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006
HITBUILDER+=" --BRefType 5"
HITBUILDER+=" --BRefSm 0"
HITBUILDER+=" --BRefDet 0"
HITBUILDER+=" --DutType 0"
HITBUILDER+=" --DutSm 3"
HITBUILDER+=" --DutRpc 1"
HITBUILDER+=" --SelType 0"
HITBUILDER+=" --SelSm 4"
HITBUILDER+=" --SelRpc 1"
HITBUILDER+=" --Sel2Type 5"
HITBUILDER+=" --Sel2Sm 0"
HITBUILDER+=" --Sel2Rpc 0"
if [[ $_reqmod -eq 1 ]]; then
HITBUILDER+=" --Mode 1"
fi
if [[ $_batch = 1 ]]; then
HITBUILDER+=" --control static"
HITBUILDER+=" --log-to-file HitBuild.out"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER &
else
xterm -geometry 120x23+1400+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER &
fi
#!/bin/bash
# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
# SPDX-License-Identifier: GPL-3.0-only
# First commited by Florian Uhlig
$FAIRROOTPATH/bin/shmmonitor --cleanup
if [ -z "$1" ]; then
_runname="359"
else
_runname=$1
fi
if [ -z "$2" ]; then
_reqmod=-193
else
_reqmod=$2
fi
if [ -z "$3" ]; then
_pulmode=1
else
_pulmode=$3
fi
if [ -z "$4" ]; then
_reqtint=100
else
_reqtint=$4
fi
_Opt=$5
#_ntimeslices=-1
_ntimeslices=100000
_iUnp=4
_batch=1
_pulmulmin=5
_pultotmin=50
_pultotmax=500
_puldetref=12 # TSR=022
#_puldetref=16 # TSR=032
#_tofftof=0.
_tofftof=-35.
if [[ $_reqmod -eq 1 ]]; then
_iUnp=1
fi
#_dirname=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/input/$_runname/
_outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/data/
#_datapath=~/KRONOS/CBM/cbmroot/trunk
#_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/
#_outdir=$_datapath/macro/beamtime/mcbm2018/data/
#_filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa"
#_filename="./tsaData2020/${_runname}_pn02_*.tsa;./tsaData2020/${_runname}_pn04_*.tsa;./tsaData2020/${_runname}_pn05_*.tsa;./tsaData2020/${_runname}_pn06_*.tsa;./tsaData2020/${_runname}_pn08_*.tsa;./tsaData2020/${_runname}_pn10_*.tsa;./tsaData2020/${_runname}_pn11_*.tsa;./tsaData2020/${_runname}_pn12_*.tsa;./tsaData2020/${_runname}_pn13_*.tsa;./tsaData2020/${_runname}_pn15_*.tsa"
#_filename="./tsaData2021/${_runname}_node8_*.tsa;./tsaData2021/${_runname}_node9_*.tsa"
_filename="./input07/${_runname}_node8_1_*.tsa;./input07/${_runname}_node9_1_*.tsa;./input07/${_runname}_node8_2_*.tsa;./input07/${_runname}_node9_2_*.tsa;./input07/${_runname}_node8_3_*.tsa;./input07/${_runname}_node9_3_*.tsa;./input07/${_runname}_node8_4_*.tsa;./input07/${_runname}_node9_4_*.tsa;./input07/${_runname}_node8_5_*.tsa;./input07/${_runname}_node9_5_*.tsa"
#_filename="./input07/${_runname}*"
_digifile=$_runname.$_reqtint.$_reqmod.${_pulmode}${_Opt}.root
# ASCII files
#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/MQ/hitbuilder/MapTofGbtx.par
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar.par
if [ $_runname -ge 707 ] && [ $_runname -lt 754 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_2Stack.par
else
if [ $_runname -ge 754 ] && [ $_runname -lt 900 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_3Stack.par
_puldetref=12 # TSR=022
else
if [ $_runname -ge 1079 ] && [ $_runname -lt 1086 ]; then
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar2Stack.par
else
_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofParCri.par
fi
fi
fi
#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/etofPar.par
#_digibdffile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/v18j_cosmicHD.digibdf.par
#_digiparfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v18j_cosmicHD.digi.par
_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21c_mcbm.digibdf.par
#_digiparfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v19b_mcbm.digi.par
# ROOT files
#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root
#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_01.par.root
#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_02.par.root
_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_07.par.root
# MQ ports
_pPar=5603
_pSam=5613
_pCmd=5623
_pDig=5633
#rm -v nohup.out
#rm -v *log
rm all_*
PARAMETERSERVER="parmq-server"
echo pkill $PARAMETERSERVER
pkill -9 $PARAMETERSERVER
sleep 1
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018"
#PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-name $_mapfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --second-input-name $_geofile"
PARAMETERSERVER+=" --second-input-type ROOT"
PARAMETERSERVER+=" --severity INFO"
if [[ $_batch = 1 ]]; then
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --log-to-file ParServ_${_runname}.out"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER &
else
xterm -geometry 80x23+0+340 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER &
#xterm -geometry 80x23+500+0 -hold -e /cvmfs/fairroot.gsi.de/fairroot/v18.0.6_fairsoft-may18/bin/$PARAMETERSERVER &
fi
echo Started ParameterServer
SAMPLER="TsaMultiSamplerTof"
SAMPLER+=" --id sampler1"
SAMPLER+=" --max-timeslices $_ntimeslices"
#SAMPLER+=" --max-timeslices 1000000"
#SAMPLER+=" --flib-port 10"
#SAMPLER+=" --dirname $_dirname"
SAMPLER+=" --filename $_filename"
#SAMPLER+=" --flib-host myHost"
SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pSam"
SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pCmd"
#SAMPLER+=" --transport shmem"
#SAMPLER+=" --transport zeromq"
#SAMPLER+=" --transport nanomsg"
#SAMPLER+=" --severity WARN"
SAMPLER+=" --severity INFO"
#SAMPLER+=" --severity DEBUG"
SAMPLER+=" --SelectComponents 0"
if [[ $_batch = 1 ]]; then
SAMPLER+=" --log-to-file Sampl_${_runname}.out"
SAMPLER+=" --control static"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER &
else
xterm -geometry 80x23+0+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER &
fi
while (( _iUnp > 0 )); do
UNPACKER="UnpackTofCri"
UNPACKER+=" --id unpack$_iUnp"
UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pSam"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pDig"
UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#UNPACKER+=" --transport shmem"
#UNPACKER+=" --severity DEBUG"
UNPACKER+=" --severity INFO"
UNPACKER+=" --SelectComponents 0"
#UNPACKER+=" --ReqBeam 20486" # diamond -> 0x00005006 v14a
#UNPACKER+=" --ReqBeam 10246" # diamond -> 0x00002806 v21a
if [[ $_reqmod -lt 1 ]]; then
UNPACKER+=" --ReqMode 0"
case $_reqmod in
0)
;;
-1)
UNPACKER+=" --ReqDet0 10246" # diamond -> 0x00002806 v21a
UNPACKER+=" --ReqDet1 32822" # RPC 031 -> 0x00008036 v21a
UNPACKER+=" --ReqDet2 32838" # RPC 041 -> 0x00008046 v21a
;;
-2)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 131126" # RPC 032
UNPACKER+=" --ReqDet2 131142" # RPC 042
;; # for ceramics
-3)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 196662" # RPC 033
UNPACKER+=" --ReqDet2 196678" # RPC 043
;; # for BUC
-4) # v21a address mode
UNPACKER+=" --ReqDet0 10246" # diamond
UNPACKER+=" --ReqDet1 65542" # RPC 002
UNPACKER+=" --ReqDet2 65574" # RPC 022
;;
-190)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 36870" # RPC 900
UNPACKER+=" --ReqDet3 102406" # RPC 901
;; # for double stack calibration
-191)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 24582" # RPC 600
UNPACKER+=" --ReqDet3 90118" # RPC 601
;; # for USTC counter analysis
-192)
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 36870" # RPC 900
UNPACKER+=" --ReqDet2 102406" # RPC 901
;; # for double stack calibration
-193) BeamBeam
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
-194)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
*)
echo ReqMode $_reqmod not yet defined, exiting
exit 1
;;
esac;
else
UNPACKER+=" --ReqMode $_reqmod"
fi
UNPACKER+=" --ReqTint $_reqtint"
UNPACKER+=" --PulserMode $_pulmode"
UNPACKER+=" --PulMulMin $_pulmulmin"
UNPACKER+=" --PulTotMin $_pultotmin"
UNPACKER+=" --PulTotMax $_pultotmax"
UNPACKER+=" --ToffTof $_tofftof"
UNPACKER+=" --RefModType 5"
UNPACKER+=" --RefModId 0"
UNPACKER+=" --RefCtrType 0"
UNPACKER+=" --RefCtrId 0"
if [[ $_batch = 1 ]]; then
UNPACKER+=" --control static"
UNPACKER+=" --log-to-file Unp${_iUnp}_${_runname}.out"
#echo nohup $UNPACKER
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER &
else
xterm -geometry 110x23+520+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER &
fi
(( _iUnp -= 1 ))
done
HITBUILDER="HitBuilderTof"
HITBUILDER+=" --id hitbuilder1"
HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pDig"
HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557"
#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558"
#HITBUILDER+=" --transport shmem"
#HITBUILDER+=" --severity DEBUG"
HITBUILDER+=" --severity INFO"
#HITBUILDER+=" --severity WARN"
HITBUILDER+=" --OutRootFile $_outdir$_digifile"
#HITBUILDER+=" --MaxEvent 10000000"
#HITBUILDER+=" --RunId 1552883952"
#HITBUILDER+=" --RunId 1614415472" # tof_mcbm_beam_2021_01.par.root
#HITBUILDER+=" --RunId 1621902311" # tof_mcbm_beam_2021_02.par.root
HITBUILDER+=" --RunId 1629444189" # tof_mcbm_beam_2021_07.par.root
HITBUILDER+=" --PulserMode $_pulmode"
HITBUILDER+=" --PulMulMin $_pulmulmin"
HITBUILDER+=" --PulTotMin $_pultotmin"
HITBUILDER+=" --PulTotMax $_pultotmax"
HITBUILDER+=" --PulDetRef $_puldetref"
HITBUILDER+=" --ReqTint $_reqtint"
#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006
HITBUILDER+=" --BRefType 0"
HITBUILDER+=" --BRefSm 0"
HITBUILDER+=" --BRefDet 3"
HITBUILDER+=" --DutType 0"
HITBUILDER+=" --DutSm 1"
HITBUILDER+=" --DutRpc 3"
HITBUILDER+=" --SelType 0"
HITBUILDER+=" --SelSm 2"
HITBUILDER+=" --SelRpc 3"
HITBUILDER+=" --Sel2Type 0"
HITBUILDER+=" --Sel2Sm 0"
HITBUILDER+=" --Sel2Rpc 3"
if [[ $_reqmod -eq 1 ]]; then
HITBUILDER+=" --Mode 1"
fi
if [[ $_batch = 1 ]]; then
HITBUILDER+=" --control static"
HITBUILDER+=" --log-to-file HitBuild_${_runname}.out"
nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER &
else
xterm -geometry 120x23+1400+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER &
fi
#!/bin/bash
# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
# SPDX-License-Identifier: GPL-3.0-only
# First commited by Florian Uhlig
$FAIRROOTPATH/bin/shmmonitor --cleanup
if [ -z "$1" ]; then
_runname="359"
else
_runname=$1
fi
if [ -z "$2" ]; then
_reqmod=-193
else
_reqmod=$2
fi
if [ -z "$3" ]; then
_pulmode=1
else
_pulmode=$3
fi
if [ -z "$4" ]; then
_reqtint=100
else
_reqtint=$4
fi
_Opt=$5
_ntimeslices=-1
#_ntimeslices=1
_iUnp=4
_batch=1
_pulmulmin=5
_pultotmin=50
_pultotmax=500
_puldetref=12 # TSR=022
#_puldetref=16 # TSR=032
#_tofftof=0.
_tofftof=-35.
if [[ $_reqmod -eq 1 ]]; then
_iUnp=1
fi
#_dirname=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/input/$_runname/
_outdir=${VMCWORKDIR}/macro/beamtime/mcbm2021/data/
#_datapath=~/KRONOS/CBM/cbmroot/trunk
#_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/
#_outdir=$_datapath/macro/beamtime/mcbm2018/data/
#_filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa"
#_filename="./tsaData2020/${_runname}_pn02_*.tsa;./tsaData2020/${_runname}_pn04_*.tsa;./tsaData2020/${_runname}_pn05_*.tsa;./tsaData2020/${_runname}_pn06_*.tsa;./tsaData2020/${_runname}_pn08_*.tsa;./tsaData2020/${_runname}_pn10_*.tsa;./tsaData2020/${_runname}_pn11_*.tsa;./tsaData2020/${_runname}_pn12_*.tsa;./tsaData2020/${_runname}_pn13_*.tsa;./tsaData2020/${_runname}_pn15_*.tsa"
_filename="${_runname}_node8_*.tsa;${_runname}_node9_*.tsa"
_dirname="${VMCWORKDIR}/build/bin/MQ/topologies/tsaData2022"
#_filename="./input07/${_runname}_node8_1_*.tsa;./input07/${_runname}_node9_1_*.tsa;./input07/${_runname}_node8_2_*.tsa;./input07/${_runname}_node9_2_*.tsa;./input07/${_runname}_node8_3_*.tsa;./input07/${_runname}_node9_3_*.tsa;./input07/${_runname}_node8_4_*.tsa;./input07/${_runname}_node9_4_*.tsa;./input07/${_runname}_node8_5_*.tsa;./input07/${_runname}_node9_5_*.tsa"
#_filename="./input07/${_runname}*"
_digifile=$_runname.$_reqtint.$_reqmod.${_pulmode}${_Opt}.root
# ASCII files
#_mapfile=${VMCWORKDIR}/MQ/hitbuilder/MapTofGbtx.par
_mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2021/mTofPar.par
if [ $_runname -ge 707 ] && [ $_runname -lt 754 ]; then
_mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2020/mTofPar_2Stack.par
else
if [ $_runname -ge 754 ] && [ $_runname -lt 900 ]; then
_mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2020/mTofPar_3Stack.par
_puldetref=12 # TSR=022
else
if [ $_runname -ge 1079 ] && [ $_runname -lt 1086 ]; then
_mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2021/mTofPar2Stack.par
else
_mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2021/mTofCriPar.par
fi
fi
fi
#_mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2018/etofPar.par
#_digibdffile=${VMCWORKDIR}/parameters/tof/v18j_cosmicHD.digibdf.par
#_digiparfile=${VMCWORKDIR}/parameters/tof/tof_v18j_cosmicHD.digi.par
_digibdffile=${VMCWORKDIR}/parameters/tof/tof_v21f_mcbm.digibdf.par
#_digiparfile=${VMCWORKDIR}/parameters/tof/tof_v19b_mcbm.digi.par
# ROOT files
#_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root
#_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_01.par.root
#_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_02.par.root
_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_09.par.root
# MQ ports
_pPar=5603
_pSam=5613
_pCmd=5623
_pDig=5633
#rm -v nohup.out
#rm -v *log
rm all_*
PARAMETERSERVER="parmq-server"
echo pkill $PARAMETERSERVER
pkill -9 $PARAMETERSERVER
sleep 1
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018"
#PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-name $_mapfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --second-input-name $_geofile"
PARAMETERSERVER+=" --second-input-type ROOT"
PARAMETERSERVER+=" --severity info"
PARAMETERSERVER+=" --file-severity info"
if [[ $_batch = 1 ]]; then
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --log-to-file ParServ_${_runname}.out"
nohup ${VMCWORKDIR}/build/bin/MQ/parmq/$PARAMETERSERVER &
else
xterm -geometry 80x23+0+340 -hold -e ${VMCWORKDIR}/build/bin/MQ/parmq/$PARAMETERSERVER &
#xterm -geometry 80x23+500+0 -hold -e /cvmfs/fairroot.gsi.de/fairroot/v18.0.6_fairsoft-may18/bin/$PARAMETERSERVER &
fi
echo Started ParameterServer
SAMPLER="TsaMultiSamplerTof"
SAMPLER+=" --id sampler1"
SAMPLER+=" --max-timeslices $_ntimeslices"
#SAMPLER+=" --max-timeslices 1000000"
#SAMPLER+=" --flib-port 10"
SAMPLER+=" --dirname $_dirname"
SAMPLER+=" --filename $_filename"
#SAMPLER+=" --flib-host myHost"
SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,sndBufSize=10,rateLogging=0,transport=zeromq,address=tcp://*:$_pSam"
SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pCmd"
#SAMPLER+=" --transport shmem"
#SAMPLER+=" --transport zeromq"
#SAMPLER+=" --transport nanomsg"
#SAMPLER+=" --severity WARN"
SAMPLER+=" --severity info"
SAMPLER+=" --file-severity info"
#SAMPLER+=" --file-severity debug"
SAMPLER+=" --SelectComponents 0"
if [[ $_batch = 1 ]]; then
SAMPLER+=" --log-to-file Sampl_${_runname}.out"
SAMPLER+=" --control static"
echo Sampler cmd:
echo ${VMCWORKDIR}/build/bin/MQ/source/$SAMPLER
nohup ${VMCWORKDIR}/build/bin/MQ/source/$SAMPLER &
else
xterm -geometry 80x23+0+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/source/$SAMPLER &
fi
while (( _iUnp > 0 )); do
UNPACKER="UnpackTofCri"
UNPACKER+=" --id unpack$_iUnp"
UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rcvBufSize=2,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pSam"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,sndBufSize=2,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pDig"
UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#UNPACKER+=" --transport shmem"
#UNPACKER+=" --severity debug"
UNPACKER+=" --severity info"
UNPACKER+=" --file-severity info"
UNPACKER+=" --SelectComponents 0"
#UNPACKER+=" --ReqBeam 20486" # diamond -> 0x00005006 v14a
UNPACKER+=" --ReqBeam 10246" # diamond -> 0x00002806 v21a
if [[ $_reqmod -lt 1 ]]; then
UNPACKER+=" --ReqMode 0"
case $_reqmod in
0)
;;
-1)
UNPACKER+=" --ReqDet0 10246" # diamond -> 0x00002806 v21a
UNPACKER+=" --ReqDet1 32822" # RPC 031 -> 0x00008036 v21a
UNPACKER+=" --ReqDet2 32838" # RPC 041 -> 0x00008046 v21a
;;
-2)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 131126" # RPC 032
UNPACKER+=" --ReqDet2 131142" # RPC 042
;; # for ceramics
-3)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 196662" # RPC 033
UNPACKER+=" --ReqDet2 196678" # RPC 043
;; # for BUC
-4) # v21a address mode
UNPACKER+=" --ReqDet0 10246" # diamond
UNPACKER+=" --ReqDet1 65542" # RPC 002
UNPACKER+=" --ReqDet2 65574" # RPC 022
;;
-190)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 36870" # RPC 900
UNPACKER+=" --ReqDet3 102406" # RPC 901
;; # for double stack calibration
-191)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 65606" # RPC 041
UNPACKER+=" --ReqDet2 24582" # RPC 600
UNPACKER+=" --ReqDet3 90118" # RPC 601
;; # for USTC counter analysis
-192)
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 36870" # RPC 900
UNPACKER+=" --ReqDet2 102406" # RPC 901
;; # for double stack calibration
-193) BeamBeam
UNPACKER+=" --ReqDet0 65606" # RPC 041
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
-194)
UNPACKER+=" --ReqDet0 20486" # diamond
UNPACKER+=" --ReqDet1 24582" # RPC 600
UNPACKER+=" --ReqDet2 90118" # RPC 601
;; # for USTC counter analysis
-810)
UNPACKER+=" --ReqDet0 16406" # RPC 810 -> 0x00004016 v21a
#UNPACKER+=" --ReqDet1 10246" # diamond 500 -> 0x00002806 v21a
#UNPACKER+=" --ReqDet2 98358" # RPC 033 -> 0x00018036 v21a
#UNPACKER+=" --ReqDet3 12294" # RPC 600 -> 0x00003006 v21a
#UNPACKER+=" --ReqDet4 98374" # RPC 043 -> 0x00018046 v21a
;;
*)
echo ReqMode $_reqmod not yet defined, exiting
exit 1
;;
esac;
else
UNPACKER+=" --ReqMode $_reqmod"
fi
UNPACKER+=" --ReqTint $_reqtint"
UNPACKER+=" --PulserMode $_pulmode"
UNPACKER+=" --PulMulMin $_pulmulmin"
UNPACKER+=" --PulTotMin $_pultotmin"
UNPACKER+=" --PulTotMax $_pultotmax"
UNPACKER+=" --ToffTof $_tofftof"
UNPACKER+=" --RefModType 5"
UNPACKER+=" --RefModId 0"
UNPACKER+=" --RefCtrType 0"
UNPACKER+=" --RefCtrId 0"
if [[ $_batch = 1 ]]; then
UNPACKER+=" --control static"
UNPACKER+=" --log-to-file Unp${_iUnp}_${_runname}.out"
#echo nohup $UNPACKER
nohup ${VMCWORKDIR}/build/bin/MQ/unpacker/$UNPACKER &
#VALGRIND_UNP="valgrind -v --error-limit=no --tool=memcheck --leak-check=full --show-reachable=yes --log-file=valgrind_unp_log.txt"
VALGRIND_UNP="valgrind -v --error-limit=no --tool=massif --massif-out-file=massif_unp_log.out"
#nohup $VALGRIND_UNP ${VMCWORKDIR}/build/bin/MQ/unpacker/$UNPACKER &
else
xterm -geometry 110x23+520+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/unpacker/$UNPACKER &
fi
(( _iUnp -= 1 ))
done
HITBUILDER="HitBuilderTof"
HITBUILDER+=" --id hitbuilder1"
HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rcvBufSize=4,rateLogging=0,transport=zeromq,address=tcp://*:$_pDig"
HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar"
HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd"
#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557"
#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558"
#HITBUILDER+=" --transport shmem"
#HITBUILDER+=" --severity debug"
HITBUILDER+=" --severity info"
HITBUILDER+=" --file-severity info"
#HITBUILDER+=" --severity WARN"
HITBUILDER+=" --OutRootFile $_outdir$_digifile"
#HITBUILDER+=" --MaxEvent 10000000"
#HITBUILDER+=" --RunId 1552883952"
#HITBUILDER+=" --RunId 1614415472" # tof_mcbm_beam_2021_01.par.root
#HITBUILDER+=" --RunId 1621902311" # tof_mcbm_beam_2021_02.par.root
#HITBUILDER+=" --RunId 1629444189" # tof_mcbm_beam_2021_07.par.root
HITBUILDER+=" --RunId 1648616420" # tof_mcbm_beam_2021_09.par.root
HITBUILDER+=" --PulserMode $_pulmode"
HITBUILDER+=" --PulMulMin $_pulmulmin"
HITBUILDER+=" --PulTotMin $_pultotmin"
HITBUILDER+=" --PulTotMax $_pultotmax"
HITBUILDER+=" --PulDetRef $_puldetref"
HITBUILDER+=" --ReqTint $_reqtint"
#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006
HITBUILDER+=" --BRefType 0"
HITBUILDER+=" --BRefSm 0"
HITBUILDER+=" --BRefDet 3"
HITBUILDER+=" --DutType 0"
HITBUILDER+=" --DutSm 1"
HITBUILDER+=" --DutRpc 3"
HITBUILDER+=" --SelType 0"
HITBUILDER+=" --SelSm 2"
HITBUILDER+=" --SelRpc 3"
HITBUILDER+=" --Sel2Type 0"
HITBUILDER+=" --Sel2Sm 0"
HITBUILDER+=" --Sel2Rpc 3"
if [[ $_reqmod -eq 1 ]]; then
HITBUILDER+=" --Mode 1"
fi
if [[ $_batch = 1 ]]; then
HITBUILDER+=" --control static"
HITBUILDER+=" --log-to-file HitBuild_${_runname}.out"
nohup ${VMCWORKDIR}/build/bin/MQ/hitbuilder/$HITBUILDER &
else
xterm -geometry 120x23+1400+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/hitbuilder/$HITBUILDER &
fi
#!/bin/bash
# Copyright (C) 2019 PI-UHd,GSI
# SPDX-License-Identifier: GPL-3.0-only
# First commited by Norbert Herrmann
# script to write cosmic data to file
$FAIRROOTPATH/bin/shmmonitor --cleanup
......
#!/bin/bash
# Copyright (C) 2020 PI-UHd,GSI
# SPDX-License-Identifier: GPL-3.0-only
# First commited by Norbert Herrmann
$FAIRROOTPATH/bin/shmmonitor --cleanup
if [ -z "$1" ]; then
_runname="HD_cosmic_`date +%F`_`date +%T`"
else
_runname=$1
fi
_reqmod=3
_reqtint=50
_ntimeslices=-1
_iUnp=4
_batch=0
_pulmode=0
_pulmulmin=3
_pultotmin=50
_pultotmax=500
_puldetref=16 # TSR=032
#_puldetref=17 # TSR=032
#_tofftof=0.
_tofftof=-30.
_version=0
if [[ $_reqmod -eq 1 ]]; then
_iUnp=1
fi
_dirname=/home/cbm/software/cbmroot/git/cbmroot/macro/beamtime/hd2020/input/$_runname/
#_outdir=/home/cbm/software/cbmroot/git/cbmroot/macro/beamtime/hd2020/data/
_outdir=/d/cbm/HD2020/
#_datapath=~/KRONOS/CBM/cbmroot/git/cbmroot
_filename=$_runname*.tsa
#_filename=/home/cbm/software/cbmroot/git/cbmroot/macro/beamtime/hd2020/input/$_runname/*.tsa
#_outdir=$_datapath/macro/beamtime/mcbm2018/data/
#_filename="./tsaData/_pn05_*.tsa;./tsaData/_pn06_*.tsa;./tsaData/_pn07_*.tsa"
_digifile=$_runname.$_reqtint.$_reqmod.$_pulmode.$_version.root
# ASCII files
_mapfile=/home/cbm/software/cbmroot/git/cbmroot/macro/beamtime/hd2020/mTofParBuc.par
_digibdffile=/home/cbm/software/cbmroot/git/cbmroot/parameters/tof/tof_v20b_cosmicHD.digibdf.par
_digiparfile=/home/cbm/software/cbmroot/git/cbmroot/parameters/tof/tof_v20b_cosmicHD.digi.par
# ROOT files
_geofile=/home/cbm/software/cbmroot/git/cbmroot/macro/beamtime/hd2020/tof_cosmicHD_2020_01.par.root
rm -v nohup.out
rm -v *log
rm all_*
PARAMETERSERVER="parmq-server"
echo pkill $PARAMETERSERVER
pkill -9 $PARAMETERSERVER
sleep 1
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5005"
#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018"
PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile"
#PARAMETERSERVER+=" --first-input-name $_mapfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --second-input-name $_geofile"
PARAMETERSERVER+=" --second-input-type ROOT"
PARAMETERSERVER+=" --severity INFO"
if [[ $_batch = 1 ]]; then
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --log-to-file ParServ.out"
nohup /home/cbm/software/cbmroot/git/cbmroot/build/bin/MQ/parmq/$PARAMETERSERVER &
else
xterm -geometry 80x23+0+340 -hold -e /home/cbm/software/cbmroot/git/cbmroot/build/bin/MQ/parmq/$PARAMETERSERVER &
#xterm -geometry 80x23+500+0 -hold -e /home/cbm/starsoft/fairroot_v18.0.6-fairsoft_may18p1_root6/bin/$PARAMETERSERVER &
fi
SAMPLER="TsaMultiSamplerTof"
SAMPLER+=" --id sampler1"
SAMPLER+=" --max-timeslices $_ntimeslices"
#SAMPLER+=" --max-timeslices 1000000"
SAMPLER+=" --flib-port 5556"
SAMPLER+=" --flib-host cbmin008"
#SAMPLER+=" --dirname $_dirname"
#SAMPLER+=" --filename $_filename"
SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:5655"
SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:5666"
#SAMPLER+=" --transport shmem"
#SAMPLER+=" --transport zeromq"
#SAMPLER+=" --transport nanomsg"
#SAMPLER+=" --severity WARN"
SAMPLER+=" --severity INFO"
#SAMPLER+=" --severity DEBUG"
SAMPLER+=" --SelectComponents 0"
if [[ $_batch = 1 ]]; then
SAMPLER+=" --log-to-file Sampl.out"
SAMPLER+=" --control static"
nohup /home/cbm/software/cbmroot/git/cbmroot/build/bin/MQ/source/$SAMPLER &
else
xterm -geometry 80x23+0+0 -hold -e /home/cbm/software/cbmroot/git/cbmroot/build/bin/MQ/source/$SAMPLER &
fi
while (( _iUnp > 0 )); do
UNPACKER="UnpackTofMcbm2018"
UNPACKER+=" --id unpack$_iUnp"
UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5655"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5005"
UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5656"
UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5666"
#UNPACKER+=" --transport shmem"
#UNPACKER+=" --severity DEBUG"
UNPACKER+=" --severity INFO"
UNPACKER+=" --SelectComponents 0"
UNPACKER+=" --ReqMode $_reqmod"
UNPACKER+=" --ReqTint $_reqtint"
UNPACKER+=" --PulserMode $_pulmode"
UNPACKER+=" --PulMulMin $_pulmulmin"
UNPACKER+=" --PulTotMin $_pultotmin"
UNPACKER+=" --PulTotMax $_pultotmax"
UNPACKER+=" --ToffTof $_tofftof"
UNPACKER+=" --RefModType -1"
UNPACKER+=" --RefModId 0"
UNPACKER+=" --RefCtrType 0"
UNPACKER+=" --RefCtrId 0"
if [[ $_batch = 1 ]]; then
UNPACKER+=" --control static"
UNPACKER+=" --log-to-file Unp$_iUnp.out"
nohup /home/cbm/software/cbmroot/git/cbmroot/build/bin/MQ/unpacker/$UNPACKER &
else
xterm -geometry 110x23+520+0 -hold -e /home/cbm/software/cbmroot/git/cbmroot/build/bin/MQ/unpacker/$UNPACKER &
fi
(( _iUnp -= 1 ))
done
HITBUILDER="HitBuilderTof"
HITBUILDER+=" --id hitbuilder1"
HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:5656"
HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5005"
HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5666"
#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557"
#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558"
#HITBUILDER+=" --transport shmem"
#HITBUILDER+=" --severity DEBUG"
HITBUILDER+=" --severity INFO"
#HITBUILDER+=" --severity WARN"
HITBUILDER+=" --OutRootFile $_outdir$_digifile"
#HITBUILDER+=" --MaxEvent 10000000"
#HITBUILDER+=" --RunId 1581312162" # v20a
HITBUILDER+=" --RunId 1597162455" # v20b
HITBUILDER+=" --PulserMode $_pulmode"
HITBUILDER+=" --PulMulMin $_pulmulmin"
HITBUILDER+=" --PulTotMin $_pultotmin"
HITBUILDER+=" --PulTotMax $_pultotmax"
HITBUILDER+=" --PulDetRef $_puldetref"
HITBUILDER+=" --ReqTint $_reqtint"
#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006
HITBUILDER+=" --BRefType 9"
HITBUILDER+=" --BRefSm 1"
HITBUILDER+=" --BRefDet 0"
HITBUILDER+=" --DutType 9"
HITBUILDER+=" --DutSm 1"
HITBUILDER+=" --DutRpc 0"
HITBUILDER+=" --SelType 9"
HITBUILDER+=" --SelSm 0"
HITBUILDER+=" --SelRpc 1"
HITBUILDER+=" --Sel2Type 9"
HITBUILDER+=" --Sel2Sm 1"
HITBUILDER+=" --Sel2Rpc 1"
if [[ $_batch = 1 ]]; then
HITBUILDER+=" --control static"
HITBUILDER+=" --log-to-file HitBuild.out"
nohup /home/cbm/software/cbmroot/git/cbmroot/build/bin/MQ/hitbuilder/$HITBUILDER &
else
xterm -geometry 120x23+1400+0 -hold -e /home/cbm/software/cbmroot/git/cbmroot/build/bin/MQ/hitbuilder/$HITBUILDER &
fi
#!/bin/bash
# Copyright (C) 2020 PI-UHd,GSI
# SPDX-License-Identifier: GPL-3.0-only
# First commited by Norbert Herrmann
$FAIRROOTPATH/bin/shmmonitor --cleanup
if [ -z "$1" ]; then
_runname="MCBM_cosmic_`date +%F`_`date +%T`"
else
_runname=$1
fi
if [ -z "$2" ]; then
_version=0
else
_version=$2
fi
if [ -z "$3" ]; then
_node="node8"
else
_node=$3
fi
_reqmod=0
_reqtint=50
_ntimeslices=-1
#_ntimeslices=100
_iUnp=1
_batch=1
_pulmode=0
_pulmulmin=18
_pultotmin=80
_pultotmax=500
_puldetref=12 # TSR=022
#_puldetref=16 # TSR=032
#_puldetref=17 # TSR=032
_tofftof=0.
#_tofftof=-30.
if [[ $_reqmod -eq 1 ]]; then
_iUnp=1
fi
_dirname=${VMCWORKDIR}/macro/beamtime/mcbm2021/input/$_runname/
#_outdir=${VMCWORKDIR}/macro/beamtime/hd2020/data/
_outdir=${VMCWORKDIR}/macro/beamtime/mcbm2021/data/
#_datapath=~/KRONOS/CBM/cbmroot/git/cbmroot
_filename=$_runname*.tsa
#_filename=${VMCWORKDIR}/macro/beamtime/hd2020/input/$_runname/*.tsa
#_outdir=$_datapath/macro/beamtime/mcbm2018/data/
#_filename="./tsaData/_pn05_*.tsa;./tsaData/_pn06_*.tsa;./tsaData/_pn07_*.tsa"
_digifile=$_runname.$_reqtint.$_reqmod.$_pulmode.$_version.$_node.root
# ASCII files
_mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2021/mTofCriPar.par
_digibdffile=${VMCWORKDIR}/parameters/tof/tof_v21f_mcbm.digibdf.par
#_digiparfile=${VMCWORKDIR}/parameters/tof/tof_v21c_mcbm.digi.par
# ROOT files
#_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_07.par.root
#_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_07_surveyed.par.root
_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_08.par.root
rm -v nohup.out
rm -v *log
rm all_*
PARAMETERSERVER="parmq-server"
echo pkill $PARAMETERSERVER
pkill -9 $PARAMETERSERVER
sleep 1
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5005"
#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018"
#PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-name $_mapfile;$_digibdffile"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --second-input-name $_geofile"
PARAMETERSERVER+=" --second-input-type ROOT"
#PARAMETERSERVER+=" --severity INFO"
PARAMETERSERVER+=" --severity DEBUG"
#PARAMETERSERVER+=" --file-severity INFO"
if [[ $_batch = 1 ]]; then
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --log-to-file ParServ.out"
nohup ${VMCWORKDIR}/build/bin/MQ/parmq/$PARAMETERSERVER &
else
xterm -geometry 80x23+0+340 -hold -e ${VMCWORKDIR}/build/bin/MQ/parmq/$PARAMETERSERVER &
#xterm -geometry 80x23+500+0 -hold -e /home/cbm/starsoft/fairroot_v18.0.6-fairsoft_may18p1_root6/bin/$PARAMETERSERVER &
fi
SAMPLER="TsaMultiSamplerTof"
SAMPLER+=" --id sampler1"
SAMPLER+=" --max-timeslices $_ntimeslices"
#SAMPLER+=" --max-timeslices 1000000"
#SAMPLER+=" --flib-port 5556"
#SAMPLER+=" --flib-host $_node"
SAMPLER+=" --dirname $_dirname"
SAMPLER+=" --filename $_filename"
SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:5655"
SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:5666"
#SAMPLER+=" --transport shmem"
#SAMPLER+=" --transport zeromq"
#SAMPLER+=" --transport nanomsg"
#SAMPLER+=" --severity WARN"
SAMPLER+=" --severity INFO"
SAMPLER+=" --file-severity INFO"
#SAMPLER+=" --severity DEBUG"
SAMPLER+=" --SelectComponents 0"
if [[ $_batch = 1 ]]; then
SAMPLER+=" --log-to-file Sampl.out"
SAMPLER+=" --control static"
nohup ${VMCWORKDIR}/build/bin/MQ/source/$SAMPLER &
else
xterm -geometry 80x23+0+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/source/$SAMPLER &
fi
while (( _iUnp > 0 )); do
UNPACKER="UnpackTofCri"
UNPACKER+=" --id unpack$_iUnp"
UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5655"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5005"
UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5656"
UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5666"
#UNPACKER+=" --transport shmem"
#UNPACKER+=" --severity DEBUG"
#UNPACKER+=" --severity INFO"
UNPACKER+=" --file-severity info"
UNPACKER+=" --SelectComponents 0"
UNPACKER+=" --ReqMode $_reqmod"
UNPACKER+=" --ReqTint $_reqtint"
UNPACKER+=" --PulserMode $_pulmode"
UNPACKER+=" --PulMulMin $_pulmulmin"
UNPACKER+=" --PulTotMin $_pultotmin"
UNPACKER+=" --PulTotMax $_pultotmax"
UNPACKER+=" --ToffTof $_tofftof"
UNPACKER+=" --RefModType -1"
UNPACKER+=" --RefModId 0"
UNPACKER+=" --RefCtrType 0"
UNPACKER+=" --RefCtrId 0"
if [[ $_batch = 1 ]]; then
UNPACKER+=" --control static"
UNPACKER+=" --log-to-file Unp$_iUnp.out"
nohup ${VMCWORKDIR}/build/bin/MQ/unpacker/$UNPACKER &
else
xterm -geometry 110x23+520+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/unpacker/$UNPACKER &
fi
(( _iUnp -= 1 ))
done
HITBUILDER="HitBuilderTof"
HITBUILDER+=" --id hitbuilder1"
HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:5656"
HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5005"
HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5666"
#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557"
#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558"
#HITBUILDER+=" --transport shmem"
#HITBUILDER+=" --severity DEBUG"
HITBUILDER+=" --severity INFO"
HITBUILDER+=" --file-severity INFO"
#HITBUILDER+=" --severity WARN"
HITBUILDER+=" --OutRootFile $_outdir$_digifile"
#HITBUILDER+=" --MaxEvent 10000000"
#HITBUILDER+=" --RunId 1581312162" # v20a
#HITBUILDER+=" --RunId 1597162455" # v20b
#HITBUILDER+=" --RunId 1621902311" # tof_mcbm_beam_2021_02.par.root
#HITBUILDER+=" --RunId 1629444189" # tof_mcbm_beam_2021_07.par.root
#HITBUILDER+=" --RunId 1639163969" # tof_mcbm_beam_2021_07_surveyed.par.root
HITBUILDER+=" --RunId 1647348218" # tof_mcbm_beam_2021_08.par.root
HITBUILDER+=" --PulserMode $_pulmode"
HITBUILDER+=" --PulMulMin $_pulmulmin"
HITBUILDER+=" --PulTotMin $_pultotmin"
HITBUILDER+=" --PulTotMax $_pultotmax"
HITBUILDER+=" --PulDetRef $_puldetref"
HITBUILDER+=" --ReqTint $_reqtint"
#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006
HITBUILDER+=" --BRefType -1" # -1 = no beam counter
HITBUILDER+=" --BRefSm 0"
HITBUILDER+=" --BRefDet -1" # -1 = use ModMask
HITBUILDER+=" --DutType 0"
HITBUILDER+=" --DutSm 1"
HITBUILDER+=" --DutRpc 2"
HITBUILDER+=" --SelType 0"
HITBUILDER+=" --SelSm 2"
HITBUILDER+=" --SelRpc 2"
HITBUILDER+=" --Sel2Type 2"
HITBUILDER+=" --Sel2Sm 0"
HITBUILDER+=" --Sel2Rpc 2"
if [[ $_batch = 1 ]]; then
HITBUILDER+=" --control static"
HITBUILDER+=" --log-to-file HitBuild.out"
nohup ${VMCWORKDIR}/build/bin/MQ/hitbuilder/$HITBUILDER &
else
xterm -geometry 120x23+1400+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/hitbuilder/$HITBUILDER &
fi
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQMcbmPulserMonitor2020.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQMcbmPulserMonitor2020.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQMcbmEvtBuilderWin2020.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQMcbmEvtBuilderWin2020.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQBuildRawEvents.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQBuildRawEvents.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startBuildRawEvents2021.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startBuildRawEvents2021.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startBuildRawEventsCosmics2021.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startBuildRawEventsCosmics2021.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startBuildRawEvents2022.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startBuildRawEvents2022.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startBmonMoni2022.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startBmonMoni2022.sh)
set(INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
)
# Set the install path within the build directory
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/MQ/mcbm")
# Set the install path within the installation directory
set(BIN_DESTINATION bin/MQ/mcbm)
If(UNIX AND NOT APPLE)
List(APPEND BOOST_LIBS pthread)
EndIf()
set(PUBLIC_DEPS
CbmData
CbmFlibMcbm2018
CbmMQBase
FairRoot::ParBase
ROOT::Core
Boost::program_options
L1
)
set(PRIVATE_DEPS
CbmFlibFlesTools
CbmBmonReco
CbmMuchReco
CbmPsdReco
CbmRecoSts
CbmRichReco
CbmSimSteer
CbmTofReco
CbmTrdReco
CbmEventBuilder
FairRoot::Base
ROOT::Gpad
ROOT::Hist
ROOT::RIO
)
set(INTERFACE_DEPS
FairMQ::FairMQ
external::fles_ipc
)
set(EXE_NAME McbmUnpack)
set(SRCS CbmDeviceMcbmUnpack.cxx runMcbmUnpack.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME McbmMonitorPulser)
set(SRCS CbmDeviceMcbmMonitorPulser.cxx runMcbmMonitorPulser.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME BuildRawEvents)
set(SRCS CbmDeviceBuildRawEvents.cxx runBuildRawEvents.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME McbmEventBuilderWin)
set(SRCS CbmDeviceMcbmEventBuilderWin.cxx runMcbmEvtBuilderWin.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES "${PRIVATE_DEPS};FairRoot::Online")
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME McbmEventSink)
set(SRCS CbmDeviceMcbmEventSink.cxx runMcbmEventSink.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES "${PRIVATE_DEPS};FairRoot::Online")
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME MqUnpack)
set(SRCS CbmDeviceUnpack.cxx runUnpack.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME BuildDigiEvents)
set(SRCS CbmDeviceBuildDigiEvents.cxx runBuildDigiEvents.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME DigiEventSink)
set(SRCS CbmDeviceDigiEventSink.cxx runDigiEventSink.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES "${PRIVATE_DEPS};FairRoot::Online")
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME BmonMonitor)
set(SRCS CbmDeviceBmonMonitor.cxx runBmonMonitor.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
# 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}/startMQMcbmPulserMonitor2020.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQMcbmPulserMonitor2020.sh)
configure_file(${MY_SOURCE_DIR}/startMQMcbmEvtBuilderWin2020.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQMcbmEvtBuilderWin2020.sh)
configure_file(${MY_SOURCE_DIR}/startMQBuildRawEvents.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQBuildRawEvents.sh)
configure_file(${MY_SOURCE_DIR}/startBuildRawEvents2021.sh.in ${TMPDIR}/bin/MQ/topologies/install/startBuildRawEvents2021.sh)
configure_file(${MY_SOURCE_DIR}/startBuildRawEventsCosmics2021.sh.in ${TMPDIR}/bin/MQ/topologies/install/startBuildRawEventsCosmics2021.sh)
configure_file(${MY_SOURCE_DIR}/startBmonMoni2022.sh.in ${TMPDIR}/bin/MQ/topologies/install/startBmonMoni2022.sh)
install(PROGRAMS ${TMPDIR}/bin/MQ/topologies/install/startMQMcbmPulserMonitor2020.sh
${TMPDIR}/bin/MQ/topologies/install/startMQMcbmEvtBuilderWin2020.sh
${TMPDIR}/bin/MQ/topologies/install/startMQBuildRawEvents.sh
${TMPDIR}/bin/MQ/topologies/install/startBuildRawEvents2021.sh
${TMPDIR}/bin/MQ/topologies/install/startBuildRawEventsCosmics2021.sh
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/MQ/topologies
)
/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
/**
* CbmDeviceBmonMonitor.cxx
*
* @since 2022-05-23
* @author P.-A. Loizeau
*/
#include "CbmDeviceBmonMonitor.h"
#include "CbmBmonUnpackConfig.h"
#include "CbmFlesCanvasTools.h"
#include "CbmMQDefs.h"
#include "CbmMuchUnpackConfig.h"
#include "CbmPsdUnpackConfig.h"
#include "CbmRichUnpackConfig.h"
#include "CbmSetup.h"
#include "CbmStsUnpackConfig.h"
#include "CbmTofUnpackConfig.h"
#include "CbmTofUnpackMonitor.h"
#include "CbmTrdUnpackConfig.h"
#include "CbmTrdUnpackFaspConfig.h"
#include "StorableTimeslice.hpp"
#include "TimesliceMetaData.h"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairParGenericSet.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH1.h"
#include "TList.h"
#include "TNamed.h"
#include "BoostSerializer.h"
#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/utility.hpp>
#include <array>
#include <iomanip>
#include <stdexcept>
#include <string>
#include <utility>
#include "RootSerializer.h"
struct InitTaskError : std::runtime_error {
using std::runtime_error::runtime_error;
};
using namespace std;
//Bool_t bMcbm2018MonitorTaskBmonResetHistos = kFALSE;
CbmDeviceBmonMonitor::CbmDeviceBmonMonitor() {}
void CbmDeviceBmonMonitor::InitTask()
try {
/// Read options from executable
LOG(info) << "Init options for CbmDeviceBmonMonitor.";
fsSetupName = fConfig->GetValue<std::string>("Setup");
fuRunId = fConfig->GetValue<uint32_t>("RunId");
fbUnpBmon = fConfig->GetValue<bool>("UnpBmon");
fbIgnoreOverlapMs = fConfig->GetValue<bool>("IgnOverMs");
fbOutputFullTimeSorting = fConfig->GetValue<bool>("FullTimeSort");
fvsSetTimeOffs = fConfig->GetValue<std::vector<std::string>>("SetTimeOffs");
fsChannelNameDataInput = fConfig->GetValue<std::string>("TsNameIn");
fsChannelNameDataOutput = fConfig->GetValue<std::string>("TsNameOut");
fuPublishFreqTs = fConfig->GetValue<uint32_t>("PubFreqTs");
fdMinPublishTime = fConfig->GetValue<double_t>("PubTimeMin");
fdMaxPublishTime = fConfig->GetValue<double_t>("PubTimeMax");
fsChannelNameHistosInput = fConfig->GetValue<std::string>("ChNameIn");
}
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_t CbmDeviceBmonMonitor::InitContainers()
{
LOG(info) << "Init parameter containers for CbmDeviceBmonMonitor.";
// ----- FIXME: Environment settings? or binary option?
TString srcDir = std::getenv("VMCWORKDIR"); // top source directory, standard C++ library
// TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory
// ----- CbmSetup -----------------------------------------------------
// TODO: support for multiple setups on Par Server? with request containing setup name?
CbmSetup* cbmsetup = CbmSetup::Instance();
FairMQMessagePtr req(NewSimpleMessage("setup"));
FairMQMessagePtr rep(NewMessage());
if (Send(req, "parameters") > 0) {
if (Receive(rep, "parameters") >= 0) {
if (0 != rep->GetSize()) {
CbmSetupStorable* exchangableSetup;
CbmMqTMessage tmsg(rep->GetData(), rep->GetSize());
exchangableSetup = dynamic_cast<CbmSetupStorable*>(tmsg.ReadObject(tmsg.GetClass()));
if (nullptr != exchangableSetup) {
/// Prevent clang format single line if
cbmsetup->LoadStoredSetup(exchangableSetup);
}
else {
LOG(error) << "Received corrupt reply. Setup not available";
throw InitTaskError("Setup not received from par-server.");
}
} // if( 0 != rep->GetSize() )
else {
LOG(error) << "Received empty reply. Setup not available";
throw InitTaskError("Setup not received from par-server.");
} // else of if( 0 != rep->GetSize() )
} // if( Receive( rep, "parameters" ) >= 0)
} // if( Send(req, "parameters") > 0 )
// ------------------------------------------------------------------------
/// Initialize the UnpackerConfigs objects and their "user options"
// ---- BMON ----
std::shared_ptr<CbmBmonUnpackConfig> bmonconfig = nullptr;
if (fbUnpBmon) {
bmonconfig = std::make_shared<CbmBmonUnpackConfig>("", fuRunId);
if (bmonconfig) {
// bmonconfig->SetDebugState();
bmonconfig->SetDoWriteOutput();
// bmonconfig->SetDoWriteOptOutA("CbmBmonErrors");
std::string parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2022/", srcDir.Data());
bmonconfig->SetParFilesBasePath(parfilesbasepathBmon);
bmonconfig->SetParFileName("mBmonCriPar.par");
bmonconfig->SetSystemTimeOffset(-1220); // [ns] value to be updated
/// Enable Monitor plots
auto monitor = std::make_shared<CbmTofUnpackMonitor>();
monitor->SetBmonMode(true);
monitor->SetInternalHttpMode(false);
if (2337 <= fuRunId) {
monitor->SetSpillThreshold(250);
monitor->SetSpillThresholdNonPulser(100);
}
bmonconfig->SetMonitor(monitor);
}
}
// -------------
/// Enable full time sorting instead of time sorting per FLIM link
if (bmonconfig) SetUnpackConfig(bmonconfig);
/// Load time offsets
for (std::vector<std::string>::iterator itStrOffs = fvsSetTimeOffs.begin(); itStrOffs != fvsSetTimeOffs.end();
++itStrOffs) {
size_t charPosDel = (*itStrOffs).find(',');
if (std::string::npos == charPosDel) {
LOG(info) << "CbmDeviceBmonMonitor::InitContainers => "
<< "Trying to set trigger window with invalid option pattern, ignored! "
<< " (Should be ECbmModuleId,dWinBeg,dWinEnd but instead found " << (*itStrOffs) << " )";
} // if( std::string::npos == charPosDel )
/// Detector Enum Tag
std::string sSelDet = (*itStrOffs).substr(0, charPosDel);
/// Min number
charPosDel++;
int32_t iOffset = std::stoi((*itStrOffs).substr(charPosDel));
if ("kBmon" == sSelDet && fBmonConfig) { //
fBmonConfig->SetSystemTimeOffset(iOffset);
} // else if( "kBmon" == sSelDet )
else {
LOG(info) << "CbmDeviceBmonMonitor::InitContainers => Trying to set time "
"offset for unsupported detector, ignored! "
<< (sSelDet);
continue;
} // else of detector enum detection
} // for( std::vector< std::string >::iterator itStrAdd = fvsAddDet.begin(); itStrAdd != fvsAddDet.end(); ++itStrAdd )
Bool_t initOK = kTRUE;
// --- Bmon
if (fBmonConfig) {
fBmonConfig->InitOutput();
// RegisterOutputs(ioman, fBmonConfig); /// Framework bound work = kept in this Task
fBmonConfig->SetAlgo();
fBmonConfig->LoadParFileName(); /// Needed to change the Parameter file name before it is used!!!
initOK &= InitParameters(fBmonConfig->GetParContainerRequest()); /// Framework bound work = kept in this Device
fBmonConfig->InitAlgo();
// initPerformanceMaps(fkFlesBmon, "Bmon");
}
/// Event header object
fCbmTsEventHeader = new CbmTsEventHeader();
return initOK;
}
Bool_t
CbmDeviceBmonMonitor::InitParameters(std::vector<std::pair<std::string, std::shared_ptr<FairParGenericSet>>>* reqparvec)
{
LOG(info) << "CbmDeviceBmonMonitor::InitParameters";
if (!reqparvec) {
LOG(info) << "CbmDeviceBmonMonitor::InitParameters - empty requirements vector no parameters initialized.";
return kTRUE;
}
// Now get the actual ascii files and init the containers with the asciiIo
for (auto& pair : *reqparvec) {
/*
auto filepath = pair.first;
auto parset = pair.second;
FairParAsciiFileIo asciiInput;
if (!filepath.empty()) {
if (asciiInput.open(filepath.data())) { parset->init(&asciiInput); }
}
* */
std::string paramName {pair.second->GetName()};
// 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
// Here must come the proper Runid
std::string message = paramName + ",111";
LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message;
FairMQMessagePtr req(NewSimpleMessage(message));
FairMQMessagePtr rep(NewMessage());
FairParGenericSet* newObj = nullptr;
if (Send(req, "parameters") > 0) {
if (Receive(rep, "parameters") >= 0) {
if (0 != rep->GetSize()) {
CbmMqTMessage tmsg(rep->GetData(), rep->GetSize());
newObj = static_cast<FairParGenericSet*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(info) << "Received unpack parameter from the server: " << newObj->GetName();
newObj->print();
} // if( 0 != rep->GetSize() )
else {
LOG(error) << "Received empty reply. Parameter not available";
return kFALSE;
} // else of if( 0 != rep->GetSize() )
} // if( Receive( rep, "parameters" ) >= 0)
} // if( Send(req, "parameters") > 0 )
pair.second.reset(newObj); /// Potentially unsafe reasignment of raw pointer to the shared pointer?
//delete newObj;
}
return kTRUE;
}
bool CbmDeviceBmonMonitor::InitHistograms()
{
/// Histos creation and obtain pointer on them
/// Trigger histo creation on all associated algos
// ALGO: bool initOK = fMonitorAlgo->CreateHistograms();
bool initOK = true;
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
// ALGO: std::vector<std::pair<TNamed*, std::string>> vHistos = fMonitorAlgo->GetHistoVector();
std::vector<std::pair<TNamed*, std::string>> vHistos = fBmonConfig->GetMonitor()->GetHistoVector();
/// Obtain vector of pointers on each canvas from the algo (+ optionally desired folder)
// ALGO: std::vector<std::pair<TCanvas*, std::string>> vCanvases = fMonitorAlgo->GetCanvasVector();
std::vector<std::pair<TCanvas*, std::string>> vCanvases = fBmonConfig->GetMonitor()->GetCanvasVector();
/// Add pointers to each histo in the histo array
/// Create histo config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Histo name, Folder >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
// LOG(info) << "Registering " << vHistos[ uHisto ].first->GetName()
// << " in " << vHistos[ uHisto ].second.data()
// ;
fArrayHisto.Add(vHistos[uHisto].first);
std::pair<std::string, std::string> psHistoConfig(vHistos[uHisto].first->GetName(), vHistos[uHisto].second);
fvpsHistosFolder.push_back(psHistoConfig);
LOG(info) << "Config of hist " << psHistoConfig.first.data() << " in folder " << psHistoConfig.second.data();
} // for( UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto )
/// Create canvas config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Canvas name, config >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv) {
// LOG(info) << "Registering " << vCanvases[ uCanv ].first->GetName()
// << " in " << vCanvases[ uCanv ].second.data();
std::string sCanvName = (vCanvases[uCanv].first)->GetName();
std::string sCanvConf = GenerateCanvasConfigString(vCanvases[uCanv].first);
std::pair<std::string, std::string> psCanvConfig(sCanvName, sCanvConf);
fvpsCanvasConfig.push_back(psCanvConfig);
LOG(info) << "Config string of Canvas " << psCanvConfig.first.data() << " is " << psCanvConfig.second.data();
} // for( UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv )
return initOK;
}
// Method called by run loop and requesting new data from the TS source whenever
bool CbmDeviceBmonMonitor::ConditionalRun()
{
/// First do Algo related Initialization steps if needed
if (0 == fulNumMessages) {
try {
InitContainers();
}
catch (InitTaskError& e) {
LOG(error) << e.what();
ChangeState(fair::mq::Transition::ErrorFound);
}
} // if( 0 == fulNumMessages)
if (0 == fulNumMessages) InitHistograms();
/// If first TS of this device, ask for the start time (lead to skip of 1 TS for 1st request)
if (!fbStartTimeSet) {
/// Request the start time
std::string message = "SendFirstTimesliceIndex";
LOG(debug) << "Requesting start time by sending message: SendFirstTimesliceIndex" << message;
FairMQMessagePtr req(NewSimpleMessage(message));
FairMQMessagePtr rep(NewMessage());
if (Send(req, fsChannelNameDataInput) <= 0) {
LOG(error) << "Failed to send the request! message was " << message;
return false;
} // if (Send(req, fsChannelNameDataInput) <= 0)
else if (Receive(rep, fsChannelNameDataInput) < 0) {
LOG(error) << "Failed to receive a reply to the request! message was " << message;
return false;
} // else if (Receive(rep, fsChannelNameDataInput) < 0)
else if (rep->GetSize() == 0) {
LOG(error) << "Received empty reply. Something went wrong with the timeslice generation! message was " << message;
return false;
} // else if (rep->GetSize() == 0)
std::string sReply;
std::string msgStrRep(static_cast<char*>(rep->GetData()), rep->GetSize());
std::istringstream issRep(msgStrRep);
boost::archive::binary_iarchive inputArchiveRep(issRep);
inputArchiveRep >> sReply;
fBmonConfig->GetMonitor()->SetHistosStartTime((1e-9) * static_cast<double>(std::stoul(sReply)));
fbStartTimeSet = true;
}
/// First request a new TS (full one)
std::string message = "full";
LOG(debug) << "Requesting new TS by sending message: full" << message;
FairMQMessagePtr req(NewSimpleMessage(message));
FairMQMessagePtr rep(NewMessage());
if (Send(req, fsChannelNameDataInput) <= 0) {
LOG(error) << "Failed to send the request! message was " << message;
return false;
} // if (Send(req, fsChannelNameDataInput) <= 0)
else if (Receive(rep, fsChannelNameDataInput) < 0) {
LOG(error) << "Failed to receive a reply to the request! message was " << message;
return false;
} // else if (Receive(rep, fsChannelNameDataInput) < 0)
else if (rep->GetSize() == 0) {
LOG(error) << "Received empty reply. Something went wrong with the timeslice generation! message was " << message;
return false;
} // else if (rep->GetSize() == 0)
fulNumMessages++;
LOG(debug) << "Received message number " << fulNumMessages << " with size " << rep->GetSize();
if (0 == fulNumMessages % 10000) LOG(info) << "Received " << fulNumMessages << " messages";
std::string msgStr(static_cast<char*>(rep->GetData()), rep->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
/// Create an empty TS and fill it with the incoming message
fles::StorableTimeslice ts {0};
inputArchive >> ts;
/// On first TS, extract the TS parameters from header (by definition stable over time)
if (-1.0 == fdTsCoreSizeInNs) {
fuNbCoreMsPerTs = ts.num_core_microslices();
fuNbOverMsPerTs = ts.num_microslices(0) - ts.num_core_microslices();
fdMsSizeInNs = (ts.descriptor(0, fuNbCoreMsPerTs).idx - ts.descriptor(0, 0).idx) / fuNbCoreMsPerTs;
fdTsCoreSizeInNs = fdMsSizeInNs * (fuNbCoreMsPerTs);
fdTsOverSizeInNs = fdMsSizeInNs * (fuNbOverMsPerTs);
fdTsFullSizeInNs = fdTsCoreSizeInNs + fdTsOverSizeInNs;
LOG(info) << "Timeslice parameters: each TS has " << fuNbCoreMsPerTs << " Core MS and " << fuNbOverMsPerTs
<< " Overlap MS, for a MS duration of " << fdMsSizeInNs << " ns, a core duration of " << fdTsCoreSizeInNs
<< " ns and a full duration of " << fdTsFullSizeInNs << " ns";
fTsMetaData = new TimesliceMetaData(ts.descriptor(0, 0).idx, fdTsCoreSizeInNs, fdTsOverSizeInNs, ts.index());
} // if( -1.0 == fdTsCoreSizeInNs )
else {
/// Update only the fields changing from TS to TS
fTsMetaData->SetStartTime(ts.descriptor(0, 0).idx);
fTsMetaData->SetIndex(ts.index());
}
/// Process the Timeslice
DoUnpack(ts, 0);
// Reset the event header for a new timeslice
fCbmTsEventHeader->Reset();
// Reset the unpackers for a new timeslice, e.g. clear the output vectors
// ---- Bmon ----
if (fBmonConfig) fBmonConfig->Reset();
/// Send histograms each 100 time slices. Should be each ~1s
/// Use also runtime checker to trigger sending after M s if
/// processing too slow or delay sending if processing too fast
std::chrono::system_clock::time_point currentTime = std::chrono::system_clock::now();
std::chrono::duration<double_t> elapsedSeconds = currentTime - fLastPublishTime;
if ((fdMaxPublishTime < elapsedSeconds.count())
|| (0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count())) {
if (!fbConfigSent) {
// Send the configuration only once per run!
fbConfigSent = SendHistoConfAndData();
} // if( !fbConfigSent )
else
SendHistograms();
fLastPublishTime = std::chrono::system_clock::now();
} // if( ( fdMaxPublishTime < elapsedSeconds.count() ) || ( 0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count() ) )
return true;
}
bool CbmDeviceBmonMonitor::SendUnpData()
{
FairMQParts parts;
/// Prepare serialized versions of the TS Event header
FairMQMessagePtr messTsHeader(NewMessage());
// Serialize<RootSerializer>(*messTsHeader, fCbmTsEventHeader);
RootSerializer().Serialize(*messTsHeader, fCbmTsEventHeader);
parts.AddPart(std::move(messTsHeader));
// ---- Bmon ----
std::stringstream ossBmon;
boost::archive::binary_oarchive oaBmon(ossBmon);
if (fBmonConfig) { //
oaBmon << *(fBmonConfig->GetOutputVec());
}
else {
oaBmon << (std::vector<CbmTofDigi>());
}
std::string* strMsgBmon = new std::string(ossBmon.str());
parts.AddPart(NewMessage(
const_cast<char*>(strMsgBmon->c_str()), // data
strMsgBmon->length(), // size
[](void*, void* object) { delete static_cast<std::string*>(object); },
strMsgBmon)); // object that manages the data
/// Prepare serialized versions of the TS Meta
/// FIXME: only for TS duration and overlap, should be sent to parameter service instead as stable values in run
/// Index and start time are already included in the TsHeader object!
FairMQMessagePtr messTsMeta(NewMessage());
// Serialize<RootSerializer>(*messTsMeta, fTsMetaData);
RootSerializer().Serialize(*messTsMeta, fTsMetaData);
parts.AddPart(std::move(messTsMeta));
if (Send(parts, fsChannelNameDataOutput) < 0) {
LOG(error) << "Problem sending data to " << fsChannelNameDataOutput;
return false;
}
return true;
}
bool CbmDeviceBmonMonitor::SendHistoConfAndData()
{
/// Prepare multiparts message and header
std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size());
FairMQMessagePtr messageHeader(NewMessage());
// Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader);
BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader);
FairMQParts partsOut;
partsOut.AddPart(std::move(messageHeader));
for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) {
/// Serialize the vector of histo config into a single MQ message
FairMQMessagePtr messageHist(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]);
partsOut.AddPart(std::move(messageHist));
} // for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto)
/// Catch case where no histos are registered!
/// => Add empty message
if (0 == fvpsHistosFolder.size()) {
FairMQMessagePtr messageHist(NewMessage());
partsOut.AddPart(std::move(messageHist));
}
for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) {
/// Serialize the vector of canvas config into a single MQ message
FairMQMessagePtr messageCan(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]);
partsOut.AddPart(std::move(messageCan));
} // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv)
/// Catch case where no Canvases are registered!
/// => Add empty message
if (0 == fvpsCanvasConfig.size()) {
FairMQMessagePtr messageHist(NewMessage());
partsOut.AddPart(std::move(messageHist));
}
/// Serialize the array of histos into a single MQ message
FairMQMessagePtr msgHistos(NewMessage());
// Serialize<RootSerializer>(*msgHistos, &fArrayHisto);
RootSerializer().Serialize(*msgHistos, &fArrayHisto);
partsOut.AddPart(std::move(msgHistos));
/// Send the multi-parts message to the common histogram messages queue
if (Send(partsOut, fsChannelNameHistosInput) < 0) {
LOG(error) << "CbmTsConsumerReqDevExample::SendHistoConfAndData => Problem sending data";
return false;
} // if( Send( partsOut, fsChannelNameHistosInput ) < 0 )
/// Reset the histograms after sending them (but do not reset the time)
// ALGO: fMonitorAlgo->ResetHistograms(kFALSE);
fBmonConfig->GetMonitor()->ResetHistograms();
fBmonConfig->GetMonitor()->ResetBmonHistograms(kFALSE);
return true;
}
bool CbmDeviceBmonMonitor::SendHistograms()
{
/// Serialize the array of histos into a single MQ message
FairMQMessagePtr message(NewMessage());
// Serialize<RootSerializer>(*message, &fArrayHisto);
RootSerializer().Serialize(*message, &fArrayHisto);
/// Send message to the common histogram messages queue
if (Send(message, fsChannelNameHistosInput) < 0) {
LOG(error) << "Problem sending data";
return false;
} // if( Send( message, fsChannelNameHistosInput ) < 0 )
/// Reset the histograms after sending them (but do not reset the time)
// ALGO: fMonitorAlgo->ResetHistograms(kFALSE);
return true;
}
CbmDeviceBmonMonitor::~CbmDeviceBmonMonitor()
{
if (fBmonConfig) fBmonConfig->GetUnpacker()->Finish();
}
Bool_t CbmDeviceBmonMonitor::DoUnpack(const fles::Timeslice& ts, size_t /*component*/)
{
fulTsCounter++;
// Prepare timeslice
// const fles::Timeslice& timeslice = *ts;
fCbmTsEventHeader->SetTsIndex(ts.index());
fCbmTsEventHeader->SetTsStartTime(ts.start_time());
uint64_t nComponents = ts.num_components();
// if (fDoDebugPrints) LOG(info) << "Unpack: TS index " << ts.index() << " components " << nComponents;
LOG(debug) << "Unpack: TS index " << ts.index() << " components " << nComponents;
for (uint64_t component = 0; component < nComponents; component++) {
auto systemId = static_cast<std::uint16_t>(ts.descriptor(component, 0).sys_id);
switch (systemId) {
case fkFlesBmon: {
if (fBmonConfig) {
fCbmTsEventHeader->AddNDigisBmon(
unpack(systemId, &ts, component, fBmonConfig, fBmonConfig->GetOptOutAVec(), fBmonConfig->GetOptOutBVec()));
}
break;
}
default: {
if (fDoDebugPrints) LOG(error) << "Unpack: Unknown system ID " << systemId << " for component " << component;
break;
}
}
}
if (0 == fulTsCounter % 10000) LOG(info) << "Processed " << fulTsCounter << " time slices";
return kTRUE;
}
/**
* @brief Get the Trd Spadic
* @return std::shared_ptr<CbmTrdSpadic>
*/
std::shared_ptr<CbmTrdSpadic> CbmDeviceBmonMonitor::GetTrdSpadic(bool useAvgBaseline)
{
auto spadic = std::make_shared<CbmTrdSpadic>();
spadic->SetUseBaselineAverage(useAvgBaseline);
spadic->SetMaxAdcToEnergyCal(1.0);
return spadic;
}
void CbmDeviceBmonMonitor::Finish() {}
/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
/**
* CbmDeviceBmonMonitor.h
*
* @since 2022-05-23
* @author P.-A. Loizeau
*/
#ifndef CBMDEVICEBMONMONI_H_
#define CBMDEVICEBMONMONI_H_
#include "CbmMqTMessage.h"
#include "CbmTsEventHeader.h"
#include "Timeslice.hpp"
#include "FairMQDevice.h"
#include "FairParGenericSet.h"
#include "Rtypes.h"
#include "TObjArray.h"
#include <chrono>
#include <map>
#include <vector>
class TList;
class CbmBmonUnpackConfig;
class TimesliceMetaData;
class CbmTrdSpadic;
class CbmDeviceBmonMonitor : public FairMQDevice {
public:
CbmDeviceBmonMonitor();
virtual ~CbmDeviceBmonMonitor();
protected:
virtual void InitTask();
bool ConditionalRun();
bool HandleCommand(FairMQMessagePtr&, int);
/** @brief Set the Bmon Unpack Config @param config */
void SetUnpackConfig(std::shared_ptr<CbmBmonUnpackConfig> config) { fBmonConfig = config; }
private:
/// Constants
static constexpr std::uint16_t fkFlesBmon = static_cast<std::uint16_t>(fles::Subsystem::BMON);
/// Control flags
Bool_t fbIgnoreOverlapMs = false; //! Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice
Bool_t fbComponentsAddedToList = kFALSE;
bool fbStartTimeSet = false;
/** @brief Flag if extended debug output is to be printed or not*/
bool fDoDebugPrints = false; //!
/** @brief Flag if performance profiling should be activated or not.*/
bool fDoPerfProf = false; //!
/** @brief Flag to Enable/disable a full time sorting. If off, time sorting happens per link/FLIM source */
bool fbOutputFullTimeSorting = false;
/// User settings parameters
std::string fsSetupName = "mcbm_beam_2021_07_surveyed";
uint32_t fuRunId = 1588;
/// ---> for selective unpacking
bool fbUnpBmon = true;
/// message queues
std::string fsChannelNameDataInput = "ts-request";
std::string fsChannelNameDataOutput = "unpts_0";
std::string fsChannelNameCommands = "commands";
std::string fsChannelNameHistosInput = "histogram-in";
/// Histograms management
uint32_t fuPublishFreqTs = 100;
double_t fdMinPublishTime = 0.5;
double_t fdMaxPublishTime = 5.0;
/// Parameters management
// TList* fParCList = nullptr;
Bool_t InitParameters(std::vector<std::pair<std::string, std::shared_ptr<FairParGenericSet>>>* reqparvec);
/// Statistics & first TS rejection
uint64_t fulNumMessages = 0;
uint64_t fulTsCounter = 0;
std::chrono::system_clock::time_point fLastPublishTime = std::chrono::system_clock::now();
/** @brief Map to store a name for the unpackers and the processed amount of digis, key = fkFlesId*/
std::map<std::uint16_t, std::pair<std::string, size_t>> fNameMap = {}; //!
/** @brief Map to store the cpu and wall time, key = fkFlesId*/
std::map<std::uint16_t, std::pair<double, double>> fTimeMap = {}; //!
/** @brief Map to store the in and out data amount, key = fkFlesId*/
std::map<std::uint16_t, std::pair<double, double>> fDataSizeMap = {}; //!
/// Configuration of the unpackers. Provides the configured algorithm
std::shared_ptr<CbmBmonUnpackConfig> fBmonConfig = nullptr;
/// Pointer to the Timeslice header conatining start time and index
CbmTsEventHeader* fCbmTsEventHeader = nullptr;
/// Time offsets
std::vector<std::string> fvsSetTimeOffs = {};
/// TS MetaData storage: stable so should be moved somehow to parameters handling (not transmitted with each TS
size_t fuNbCoreMsPerTs = 0; //!
size_t fuNbOverMsPerTs = 0; //!
Double_t fdMsSizeInNs = 0; //! Size of a single MS, [nanoseconds]
Double_t fdTsCoreSizeInNs = -1.0; //! Total size of the core MS in a TS, [nanoseconds]
Double_t fdTsOverSizeInNs = -1.0; //! Total size of the overlap MS in a TS, [nanoseconds]
Double_t fdTsFullSizeInNs = -1.0; //! Total size of all MS in a TS, [nanoseconds]
TimesliceMetaData* fTsMetaData;
/// Array of histograms to send to the histogram server
TObjArray fArrayHisto = {};
/// Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server
std::vector<std::pair<std::string, std::string>> fvpsHistosFolder = {};
/// Vector of string pairs with ( CanvasName, CanvasConfig ) to send to the histogram server
/// Format of Can config is "NbPadX(U);NbPadY(U);ConfigPad1(s);....;ConfigPadXY(s)"
/// Format of Pad config is "GrixX(b),GridY(b),LogX(b),LogY(b),LogZ(b),HistoName(s),DrawOptions(s)"
std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig = {};
/// Flag indicating whether the histograms and canvases configurations were already published
bool fbConfigSent = false;
Bool_t InitContainers();
bool InitHistograms();
Bool_t DoUnpack(const fles::Timeslice& ts, size_t component);
void Finish();
bool SendUnpData();
bool SendHistoConfAndData();
bool SendHistograms();
std::shared_ptr<CbmTrdSpadic> GetTrdSpadic(bool useAvgBaseline);
/** @brief Sort a vector timewise vector type has to provide GetTime() */
template<typename TVecobj>
typename std::enable_if<std::is_same<TVecobj, std::nullptr_t>::value == true, void>::type
timesort(std::vector<TVecobj>* /*vec = nullptr*/)
{
LOG(debug)
<< "CbmDeviceBmonMonitor::timesort() got an object that has no member function GetTime(). Hence, we can and "
"will not timesort it!";
}
template<typename TVecobj>
typename std::enable_if<!std::is_member_function_pointer<decltype(&TVecobj::GetTime)>::value, void>::type
timesort(std::vector<TVecobj>* /*vec = nullptr*/)
{
LOG(debug) << "CbmDeviceBmonMonitor::timesort() " << TVecobj::Class_Name()
<< "is an object that has no member function GetTime(). Hence, we can and "
"will not timesort it!";
}
template<typename TVecobj>
typename std::enable_if<std::is_member_function_pointer<decltype(&TVecobj::GetTime)>::value, void>::type
timesort(std::vector<TVecobj>* vec = nullptr)
{
if (vec == nullptr) return;
std::sort(vec->begin(), vec->end(),
[](const TVecobj& a, const TVecobj& b) -> bool { return a.GetTime() < b.GetTime(); });
}
/**
* @brief Template for the unpacking call of a given algorithm.
*
* @tparam TAlgo Algorithm to be called
* @tparam TOutput Output element types
* @tparam TOptoutputs Optional output element types
* @param ts Timeslice
* @param icomp Component number
* @param algo Algorithm to be used for this component
* @param outtargetvec Target vector for the output elements
* @param optoutputvecs Target vectors for optional outputs
* @return std::pair<ndigis, std::pair<cputime, walltime>>
*/
template<class TConfig, class TOptOutA = std::nullptr_t, class TOptOutB = std::nullptr_t>
size_t unpack(const std::uint16_t subsysid, const fles::Timeslice* ts, std::uint16_t icomp, TConfig config,
std::vector<TOptOutA>* optouttargetvecA = nullptr, std::vector<TOptOutB>* optouttargetvecB = nullptr)
{
auto wallstarttime = std::chrono::high_resolution_clock::now();
std::clock_t cpustarttime = std::clock();
auto algo = config->GetUnpacker();
std::vector<TOptOutA> optoutAvec = {};
std::vector<TOptOutB> optoutBvec = {};
if (optouttargetvecA) { algo->SetOptOutAVec(&optoutAvec); }
if (optouttargetvecB) { algo->SetOptOutBVec(&optoutBvec); }
// Set the start time of the current TS for this algorithm
algo->SetTsStartTime(ts->start_time());
// Run the actual unpacking
auto digivec = algo->Unpack(ts, icomp);
// Check if we want to write the output to somewhere (in pure online monitoring mode for example this can/would/should be skipped)
if (config->GetOutputVec()) {
// Lets do some time-sorting if we are not doing it later
if (!fbOutputFullTimeSorting) timesort(&digivec);
// Transfer the data from the timeslice vector to the target branch vector
// Digis/default output retrieved as offered by the algorithm
for (auto digi : digivec)
config->GetOutputVec()->emplace_back(digi);
}
if (optouttargetvecA) {
// Lets do some timesorting
if (!fbOutputFullTimeSorting) timesort(&optoutAvec);
// Transfer the data from the timeslice vector to the target branch vector
for (auto optoutA : optoutAvec)
optouttargetvecA->emplace_back(optoutA);
}
if (optouttargetvecB) {
// Second opt output is not time sorted to allow non GetTime data container.
// Lets do some timesorting
timesort(&optoutAvec);
// Transfer the data from the timeslice vector to the target branch vector
for (auto optoutB : optoutBvec)
optouttargetvecB->emplace_back(optoutB);
}
std::clock_t cpuendtime = std::clock();
auto wallendtime = std::chrono::high_resolution_clock::now();
// Cpu time in [mus]
auto cputime = 1e6 * (cpuendtime - cpustarttime) / CLOCKS_PER_SEC;
algo->AddCpuTime(cputime);
// Real time in [mus]
auto walltime = std::chrono::duration<double, std::micro>(wallendtime - wallstarttime).count();
algo->AddWallTime(walltime);
// Check some numbers from this timeslice
size_t nDigis = digivec.size();
LOG(debug) << "Component " << icomp << " connected to config " << config->GetName() << " n-Digis " << nDigis
<< " processed in walltime(cputime) = " << walltime << "(" << cputime << cputime << ") micro s"
<< "this timeslice.";
if (fDoPerfProf) {
auto timeit = fTimeMap.find(subsysid);
timeit->second.first += cputime;
timeit->second.second += walltime;
auto datait = fDataSizeMap.find(subsysid);
datait->second.first += ts->size_component(icomp) / 1.0e6;
datait->second.second += nDigis * algo->GetOutputObjSize() / 1.0e6;
fNameMap.find(subsysid)->second.second += nDigis;
}
return nDigis;
}
};
#endif /* CBMDEVICEMCBMUNPACK_H_ */
/* Copyright (C) 2021 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau[committer] */
/**
* CbmDeviceBuildDigiEvents.cxx
*
* @since 2021-11-18
* @author P.-A. Loizeau
*/
#include "CbmDeviceBuildDigiEvents.h"
/// CBM headers
#include "CbmDigiEvent.h"
#include "CbmEvent.h"
#include "CbmFlesCanvasTools.h"
#include "CbmMQDefs.h"
#include "CbmMatch.h"
#include "CbmMvdDigi.h"
#include "CbmTsEventHeader.h"
#include "TimesliceMetaData.h"
/// FAIRROOT headers
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairParGenericSet.h"
#include "FairRunOnline.h"
#include "BoostSerializer.h"
#include "RootSerializer.h"
/// FAIRSOFT headers (geant, boost, ...)
#include "TCanvas.h"
#include "TFile.h"
#include "TH1.h"
#include "TList.h"
#include "TNamed.h"
#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/utility.hpp>
/// C/C++ headers
#include <array>
#include <iomanip>
#include <stdexcept>
#include <string>
struct InitTaskError : std::runtime_error {
using std::runtime_error::runtime_error;
};
using namespace std;
CbmDeviceBuildDigiEvents::CbmDeviceBuildDigiEvents() { fpAlgo = new CbmAlgoBuildRawEvents(); }
void CbmDeviceBuildDigiEvents::InitTask()
try {
/// Read options from executable
LOG(info) << "Init options for CbmDeviceBuildDigiEvents.";
fbFillHistos = fConfig->GetValue<bool>("FillHistos");
fbIgnoreTsOverlap = fConfig->GetValue<bool>("IgnOverMs");
fsEvtOverMode = fConfig->GetValue<std::string>("EvtOverMode");
fsRefDet = fConfig->GetValue<std::string>("RefDet");
fvsAddDet = fConfig->GetValue<std::vector<std::string>>("AddDet");
fvsDelDet = fConfig->GetValue<std::vector<std::string>>("DelDet");
fvsSetTrigWin = fConfig->GetValue<std::vector<std::string>>("SetTrigWin");
fvsSetTrigMinNb = fConfig->GetValue<std::vector<std::string>>("SetTrigMinNb");
fvsSetTrigMaxNb = fConfig->GetValue<std::vector<std::string>>("SetTrigMaxNb");
fvsSetTrigMinLayersNb = fConfig->GetValue<std::vector<std::string>>("SetTrigMinLayersNb");
fvsSetHistMaxDigiNb = fConfig->GetValue<std::vector<std::string>>("SetHistMaxDigiNb");
fbDoNotSend = fConfig->GetValue<bool>("DoNotSend");
fbDigiEventOutput = fConfig->GetValue<bool>("DigiEventOutput");
fsChannelNameDataInput = fConfig->GetValue<std::string>("TsNameIn");
fsChannelNameDataOutput = fConfig->GetValue<std::string>("EvtNameOut");
fsChannelNameHistosInput = fConfig->GetValue<std::string>("ChNameIn");
fsAllowedChannels[0] = fsChannelNameDataInput;
fuPublishFreqTs = fConfig->GetValue<uint32_t>("PubFreqTs");
fdMinPublishTime = fConfig->GetValue<double_t>("PubTimeMin");
fdMaxPublishTime = fConfig->GetValue<double_t>("PubTimeMax");
// 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 (std::string::npos != entry.first.find(fsChannelNameDataInput)) {
if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match.");
OnData(entry.first, &CbmDeviceBuildDigiEvents::HandleData);
}
}
/// FIXME: Disable clang formatting for now as it corrupts all alignment
/* clang-format off */
/// Initialize the Algorithm parameters
fpAlgo->SetFillHistos(fbFillHistos);
fpAlgo->SetIgnoreTsOverlap(fbIgnoreTsOverlap);
/// Extract Event Overlap Mode
EOverlapModeRaw mode = ("NoOverlap" == fsEvtOverMode ? EOverlapModeRaw::NoOverlap
: ("MergeOverlap" == fsEvtOverMode ? EOverlapModeRaw::MergeOverlap
: ("AllowOverlap" == fsEvtOverMode ? EOverlapModeRaw::AllowOverlap
: EOverlapModeRaw::NoOverlap)));
fpAlgo->SetEventOverlapMode(mode);
/// Extract refdet
RawEventBuilderDetector refDet = GetDetectorBuilderCfg(fsRefDet);
if (kRawEventBuilderDetUndef != refDet) {
fpAlgo->SetReferenceDetector(refDet);
}
else {
LOG(info) << "CbmDeviceBuildDigiEvents::InitTask => Trying to change "
"reference to unsupported detector, ignored! "
<< fsRefDet;
}
/// Extract detector to add if any
for (std::vector<std::string>::iterator itStrAdd = fvsAddDet.begin();
itStrAdd != fvsAddDet.end();
++itStrAdd) {
RawEventBuilderDetector addDet = GetDetectorBuilderCfg(*itStrAdd);
if (kRawEventBuilderDetUndef != addDet) {
fpAlgo->AddDetector(addDet);
}
else {
LOG(info) << "CbmDeviceBuildDigiEvents::InitTask => Trying to add "
"unsupported detector, ignored! "
<< (*itStrAdd);
continue;
}
}
/// Extract detector to remove if any
for (std::vector<std::string>::iterator itStrRem = fvsDelDet.begin();
itStrRem != fvsDelDet.end();
++itStrRem) {
RawEventBuilderDetector remDet = GetDetectorBuilderCfg(*itStrRem);
if (kRawEventBuilderDetUndef != remDet) {
fpAlgo->RemoveDetector(remDet);
}
else {
LOG(info) << "CbmDeviceBuildDigiEvents::InitTask => Trying to remove "
"unsupported detector, ignored! "
<< (*itStrRem);
continue;
}
}
/// Extract Trigger window to add if any
for (std::vector<std::string>::iterator itStrTrigWin = fvsSetTrigWin.begin();
itStrTrigWin != fvsSetTrigWin.end();
++itStrTrigWin) {
size_t charPosDel = (*itStrTrigWin).find(',');
if (std::string::npos == charPosDel) {
LOG(info)
<< "CbmDeviceBuildDigiEvents::InitTask => "
<< "Trying to set trigger window with invalid option pattern, ignored! "
<< " (Should be ECbmModuleId,dWinBeg,dWinEnd but instead found "
<< (*itStrTrigWin) << " )";
continue;
}
/// Detector Enum Tag
std::string sSelDet = (*itStrTrigWin).substr(0, charPosDel);
ECbmModuleId selDet = GetDetectorId(sSelDet);
if (ECbmModuleId::kNotExist == selDet) {
LOG(info)
<< "CbmDeviceBuildDigiEvents::InitTask => "
<< "Trying to set trigger window for unsupported detector, ignored! "
<< sSelDet;
continue;
}
/// Window beginning
charPosDel++;
std::string sNext = (*itStrTrigWin).substr(charPosDel);
charPosDel = sNext.find(',');
if (std::string::npos == charPosDel) {
LOG(info)
<< "CbmDeviceBuildDigiEvents::InitTask => "
<< "Trying to set trigger window with invalid option pattern, ignored! "
<< " (Should be ECbmModuleId,dWinBeg,dWinEnd but instead found "
<< (*itStrTrigWin) << " )";
continue;
}
Double_t dWinBeg = std::stod(sNext.substr(0, charPosDel));
/// Window end
charPosDel++;
Double_t dWinEnd = std::stod(sNext.substr(charPosDel));
fpAlgo->SetTriggerWindow(selDet, dWinBeg, dWinEnd);
}
/// Extract MinNb for trigger if any
for (std::vector<std::string>::iterator itStrMinNb = fvsSetTrigMinNb.begin();
itStrMinNb != fvsSetTrigMinNb.end();
++itStrMinNb) {
size_t charPosDel = (*itStrMinNb).find(',');
if (std::string::npos == charPosDel) {
LOG(info)
<< "CbmDeviceBuildDigiEvents::InitTask => "
<< "Trying to set trigger min Nb with invalid option pattern, ignored! "
<< " (Should be ECbmModuleId,uMinNb but instead found " << (*itStrMinNb)
<< " )";
continue;
}
/// Detector Enum Tag
std::string sSelDet = (*itStrMinNb).substr(0, charPosDel);
ECbmModuleId selDet = GetDetectorId(sSelDet);
if (ECbmModuleId::kNotExist == selDet) {
LOG(info)
<< "CbmDeviceBuildDigiEvents::InitTask => "
<< "Trying to set trigger min Nb for unsupported detector, ignored! "
<< sSelDet;
continue;
}
/// Min number
charPosDel++;
UInt_t uMinNb = std::stoul((*itStrMinNb).substr(charPosDel));
fpAlgo->SetTriggerMinNumber(selDet, uMinNb);
}
/// Extract MaxNb for trigger if any
for (std::vector<std::string>::iterator itStrMaxNb = fvsSetTrigMaxNb.begin();
itStrMaxNb != fvsSetTrigMaxNb.end();
++itStrMaxNb) {
size_t charPosDel = (*itStrMaxNb).find(',');
if (std::string::npos == charPosDel) {
LOG(info)
<< "CbmDeviceBuildDigiEvents::InitTask => "
<< "Trying to set trigger Max Nb with invalid option pattern, ignored! "
<< " (Should be ECbmModuleId,uMaxNb but instead found " << (*itStrMaxNb)
<< " )";
continue;
}
/// Detector Enum Tag
std::string sSelDet = (*itStrMaxNb).substr(0, charPosDel);
ECbmModuleId selDet = GetDetectorId(sSelDet);
if (ECbmModuleId::kNotExist == selDet) {
LOG(info)
<< "CbmDeviceBuildDigiEvents::InitTask => "
<< "Trying to set trigger Max Nb for unsupported detector, ignored! "
<< sSelDet;
continue;
}
/// Max number
charPosDel++;
Int_t iMaxNb = std::stol((*itStrMaxNb).substr(charPosDel));
fpAlgo->SetTriggerMaxNumber(selDet, iMaxNb);
}
/// Extract MinLayersNb for trigger if any
for (std::vector<std::string>::iterator itStrMinLayersNb = fvsSetTrigMinLayersNb.begin();
itStrMinLayersNb != fvsSetTrigMinLayersNb.end();
++itStrMinLayersNb) {
size_t charPosDel = (*itStrMinLayersNb).find(',');
if (std::string::npos == charPosDel) {
LOG(info)
<< "CbmDeviceBuildDigiEvents::InitTask => "
<< "Trying to set trigger min layers Nb with invalid option pattern, ignored! "
<< " (Should be ECbmModuleId,uMinLayersNb but instead found " << (*itStrMinLayersNb)
<< " )";
continue;
}
/// Detector Enum Tag
std::string sSelDet = (*itStrMinLayersNb).substr(0, charPosDel);
ECbmModuleId selDet = GetDetectorId(sSelDet);
if (ECbmModuleId::kNotExist == selDet) {
LOG(info)
<< "CbmDeviceBuildDigiEvents::InitTask => "
<< "Trying to set trigger min layers Nb for unsupported detector, ignored! "
<< sSelDet;
continue;
}
/// Min number
charPosDel++;
UInt_t uMinLayersNb = std::stoul((*itStrMinLayersNb).substr(charPosDel));
fpAlgo->SetTriggerMinLayersNumber(selDet, uMinLayersNb);
}
/// Extract Histograms Max Digi limits if any
for (std::vector<std::string>::iterator itStrHistMaxDigi = fvsSetHistMaxDigiNb.begin();
itStrHistMaxDigi != fvsSetHistMaxDigiNb.end();
++itStrHistMaxDigi) {
size_t charPosDel = (*itStrHistMaxDigi).find(',');
if (std::string::npos == charPosDel) {
LOG(info)
<< "CbmDeviceBuildDigiEvents::InitTask => "
<< "Trying to set Histos max Digi nb with invalid option pattern, ignored! "
<< " (Should be ECbmModuleId,dMaxDigiNb but instead found " << (*itStrHistMaxDigi)
<< " )";
continue;
}
/// Detector Enum Tag
std::string sSelDet = (*itStrHistMaxDigi).substr(0, charPosDel);
ECbmModuleId selDet = GetDetectorId(sSelDet);
if (ECbmModuleId::kNotExist == selDet) {
LOG(info)
<< "CbmDeviceBuildDigiEvents::InitTask => "
<< "Trying to set Histos max Digi nb for unsupported detector, ignored! "
<< sSelDet;
continue;
}
/// Min number
charPosDel++;
Double_t dHistMaxDigiNb = std::stod((*itStrHistMaxDigi).substr(charPosDel));
LOG(debug) << "set Histos max Digi nb to " << dHistMaxDigiNb;
fpAlgo->SetHistogramMaxDigiNb(selDet, dHistMaxDigiNb);
}
/// FIXME: Re-enable clang formatting after formatted lines
/* clang-format on */
/// Create input vectors
fvDigiBmon = new std::vector<CbmBmonDigi>(1000000);
fvDigiSts = new std::vector<CbmStsDigi>(1000000);
fvDigiMuch = new std::vector<CbmMuchDigi>(1000000);
fvDigiTrd = new std::vector<CbmTrdDigi>(1000000);
fvDigiTof = new std::vector<CbmTofDigi>(1000000);
fvDigiRich = new std::vector<CbmRichDigi>(1000000);
fvDigiPsd = new std::vector<CbmPsdDigi>(1000000);
fCbmTsEventHeader = new CbmTsEventHeader();
/// Digis storage
fpAlgo->SetDigis(fvDigiBmon);
fpAlgo->SetDigis(fvDigiSts);
fpAlgo->SetDigis(fvDigiMuch);
fpAlgo->SetDigis(fvDigiTrd);
fpAlgo->SetDigis(fvDigiTof);
fpAlgo->SetDigis(fvDigiRich);
fpAlgo->SetDigis(fvDigiPsd);
// Mvd currently not implemented in event builder
//std::vector<CbmMvdDigi>* pMvdDigi = new std::vector<CbmMvdDigi>();
fTimeSliceMetaDataArray = new TClonesArray("TimesliceMetaData", 1);
if (NULL == fTimeSliceMetaDataArray) { throw InitTaskError("Failed creating the TS meta data TClonesarray "); }
fpAlgo->SetTimeSliceMetaDataArray(fTimeSliceMetaDataArray);
/// Now that everything is set, initialize the Algorithm
if (kFALSE == fpAlgo->InitAlgo()) { throw InitTaskError("Failed to initialize the algorithm class."); }
/// Histograms management
if (kTRUE == fbFillHistos) {
/// Comment to prevent clang format single lining
if (kFALSE == InitHistograms()) { throw InitTaskError("Failed to initialize the histograms."); }
}
}
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 CbmDeviceBuildDigiEvents::IsChannelNameAllowed(std::string channelName)
{
for (auto const& entry : fsAllowedChannels) {
std::size_t pos1 = channelName.find(entry);
if (pos1 != std::string::npos) {
const vector<std::string>::const_iterator pos =
std::find(fsAllowedChannels.begin(), fsAllowedChannels.end(), entry);
const vector<std::string>::size_type idx = pos - fsAllowedChannels.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;
}
RawEventBuilderDetector CbmDeviceBuildDigiEvents::GetDetectorBuilderCfg(std::string detName)
{
/// FIXME: Disable clang formatting for now as it corrupts all alignment
/* clang-format off */
RawEventBuilderDetector cfgDet = ("kBmon" == detName ? kRawEventBuilderDetBmon
: ("kSts" == detName ? kRawEventBuilderDetSts
: ("kMuch" == detName ? kRawEventBuilderDetMuch
: ("kTrd" == detName ? kRawEventBuilderDetTrd
: ("kTrd2D" == detName ? kRawEventBuilderDetTrd2D
: ("kTof" == detName ? kRawEventBuilderDetTof
: ("kRich" == detName ? kRawEventBuilderDetRich
: ("kPsd" == detName ? kRawEventBuilderDetPsd
: kRawEventBuilderDetUndef))))))));
return cfgDet;
/// FIXME: Re-enable clang formatting after formatted lines
/* clang-format on */
}
ECbmModuleId CbmDeviceBuildDigiEvents::GetDetectorId(std::string detName)
{
/// FIXME: Disable clang formatting for now as it corrupts all alignment
/* clang-format off */
ECbmModuleId detId = ("kBmon" == detName ? ECbmModuleId::kBmon
: ("kSts" == detName ? ECbmModuleId::kSts
: ("kMuch" == detName ? ECbmModuleId::kMuch
: ("kTrd" == detName ? ECbmModuleId::kTrd
: ("kTrd2D" == detName ? ECbmModuleId::kTrd2d
: ("kTof" == detName ? ECbmModuleId::kTof
: ("kRich" == detName ? ECbmModuleId::kRich
: ("kPsd" == detName ? ECbmModuleId::kPsd
: ECbmModuleId::kNotExist))))))));
return detId;
/// FIXME: Re-enable clang formatting after formatted lines
/* clang-format on */
}
bool CbmDeviceBuildDigiEvents::InitHistograms()
{
bool initOK = true;
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
std::vector<std::pair<TNamed*, std::string>> vHistos = fpAlgo->GetHistoVector();
/// Obtain vector of pointers on each canvas from the algo (+ optionally desired folder)
std::vector<std::pair<TCanvas*, std::string>> vCanvases = fpAlgo->GetCanvasVector();
/// Add pointers to each histo in the histo array
/// Create histo config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Histo name, Folder >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
// LOG(info) << "Registering " << vHistos[ uHisto ].first->GetName()
// << " in " << vHistos[ uHisto ].second.data()
// ;
fArrayHisto.Add(vHistos[uHisto].first);
std::pair<std::string, std::string> psHistoConfig(vHistos[uHisto].first->GetName(), vHistos[uHisto].second);
fvpsHistosFolder.push_back(psHistoConfig);
LOG(info) << "Config of hist " << psHistoConfig.first.data() << " in folder " << psHistoConfig.second.data();
} // for( UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto )
/// Create canvas config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Canvas name, config >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv) {
// LOG(info) << "Registering " << vCanvases[ uCanv ].first->GetName()
// << " in " << vCanvases[ uCanv ].second.data();
std::string sCanvName = (vCanvases[uCanv].first)->GetName();
std::string sCanvConf = GenerateCanvasConfigString(vCanvases[uCanv].first);
std::pair<std::string, std::string> psCanvConfig(sCanvName, sCanvConf);
fvpsCanvasConfig.push_back(psCanvConfig);
LOG(info) << "Config string of Canvas " << psCanvConfig.first.data() << " is " << psCanvConfig.second.data();
} // for( UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv )
return initOK;
}
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
bool CbmDeviceBuildDigiEvents::HandleData(FairMQParts& parts, int /*index*/)
{
fulNumMessages++;
LOG(debug) << "Received message number " << fulNumMessages << " with " << parts.Size() << " parts"
<< ", size0: " << parts.At(0)->GetSize();
if (0 == fulNumMessages % 10000) LOG(info) << "Received " << fulNumMessages << " messages";
/// Extract unpacked data from input message
uint32_t uPartIdx = 0;
/// TS header
// Deserialize<RootSerializer>(*parts.At(uPartIdx), fCbmTsEventHeader);
RootSerializer().Deserialize(*parts.At(uPartIdx), fCbmTsEventHeader);
++uPartIdx;
/// Bmon
if (0 < (parts.At(uPartIdx))->GetSize()) {
std::string msgStrBmon(static_cast<char*>(parts.At(uPartIdx)->GetData()), (parts.At(uPartIdx))->GetSize());
std::istringstream issBmon(msgStrBmon);
boost::archive::binary_iarchive inputArchiveBmon(issBmon);
inputArchiveBmon >> *fvDigiBmon;
}
++uPartIdx;
/// STS
if (0 < (parts.At(uPartIdx))->GetSize()) {
std::string msgStrSts(static_cast<char*>(parts.At(uPartIdx)->GetData()), (parts.At(uPartIdx))->GetSize());
std::istringstream issSts(msgStrSts);
boost::archive::binary_iarchive inputArchiveSts(issSts);
inputArchiveSts >> *fvDigiSts;
}
++uPartIdx;
/// MUCH
if (0 < (parts.At(uPartIdx))->GetSize()) {
std::string msgStrMuch(static_cast<char*>(parts.At(uPartIdx)->GetData()), (parts.At(uPartIdx))->GetSize());
std::istringstream issMuch(msgStrMuch);
boost::archive::binary_iarchive inputArchiveMuch(issMuch);
inputArchiveMuch >> *fvDigiMuch;
}
++uPartIdx;
/// TRD
if (0 < (parts.At(uPartIdx))->GetSize()) {
std::string msgStrTrd(static_cast<char*>(parts.At(uPartIdx)->GetData()), (parts.At(uPartIdx))->GetSize());
std::istringstream issTrd(msgStrTrd);
boost::archive::binary_iarchive inputArchiveTrd(issTrd);
inputArchiveTrd >> *fvDigiTrd;
}
++uPartIdx;
/// BmonF
if (0 < (parts.At(uPartIdx))->GetSize()) {
std::string msgStrTof(static_cast<char*>(parts.At(uPartIdx)->GetData()), (parts.At(uPartIdx))->GetSize());
std::istringstream issTof(msgStrTof);
boost::archive::binary_iarchive inputArchiveTof(issTof);
inputArchiveTof >> *fvDigiTof;
}
++uPartIdx;
/// RICH
if (0 < (parts.At(uPartIdx))->GetSize()) {
std::string msgStrRich(static_cast<char*>(parts.At(uPartIdx)->GetData()), (parts.At(uPartIdx))->GetSize());
std::istringstream issRich(msgStrRich);
boost::archive::binary_iarchive inputArchiveRich(issRich);
inputArchiveRich >> *fvDigiRich;
}
++uPartIdx;
/// PSD
if (0 < (parts.At(uPartIdx))->GetSize()) {
std::string msgStrPsd(static_cast<char*>(parts.At(uPartIdx)->GetData()), (parts.At(uPartIdx))->GetSize());
std::istringstream issPsd(msgStrPsd);
boost::archive::binary_iarchive inputArchivePsd(issPsd);
inputArchivePsd >> *fvDigiPsd;
}
++uPartIdx;
/// TS metadata
// Deserialize<RootSerializer>(*parts.At(uPartIdx), fTsMetaData);
RootSerializer().Deserialize(*parts.At(uPartIdx), fTsMetaData);
new ((*fTimeSliceMetaDataArray)[fTimeSliceMetaDataArray->GetEntriesFast()])
TimesliceMetaData(std::move(*fTsMetaData));
++uPartIdx;
LOG(debug) << "Bmon Vector size: " << fvDigiBmon->size();
LOG(debug) << "STS Vector size: " << fvDigiSts->size();
LOG(debug) << "MUCH Vector size: " << fvDigiMuch->size();
LOG(debug) << "TRD Vector size: " << fvDigiTrd->size();
LOG(debug) << "TOF Vector size: " << fvDigiTof->size();
LOG(debug) << "RICH Vector size: " << fvDigiRich->size();
LOG(debug) << "PSD Vector size: " << fvDigiPsd->size();
if (1 == fulNumMessages) {
/// First message received
fpAlgo->SetTsParameters(0, fTsMetaData->GetDuration(), fTsMetaData->GetOverlapDuration());
}
/// Call Algo ProcessTs method
fpAlgo->ProcessTs();
/// Send events vector to ouput
if (!fbDoNotSend) {
if (fbDigiEventOutput) {
if (!(SendDigiEvents(parts))) return false;
}
else {
if (!(SendEvents(parts))) return false;
}
}
/// Clear metadata
fTimeSliceMetaDataArray->Clear();
/// Clear vectors
fvDigiBmon->clear();
fvDigiSts->clear();
fvDigiMuch->clear();
fvDigiTrd->clear();
fvDigiTof->clear();
fvDigiRich->clear();
fvDigiPsd->clear();
/// Clear event vector after usage
fpAlgo->ClearEventVector();
/// Histograms management
if (kTRUE == fbFillHistos) {
/// Send histograms each 100 time slices. Should be each ~1s
/// Use also runtime checker to trigger sending after M s if
/// processing too slow or delay sending if processing too fast
std::chrono::system_clock::time_point currentTime = std::chrono::system_clock::now();
std::chrono::duration<double_t> elapsedSeconds = currentTime - fLastPublishTime;
if ((fdMaxPublishTime < elapsedSeconds.count())
|| (0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count())) {
if (!fbConfigSent) {
// Send the configuration only once per run!
fbConfigSent = SendHistoConfAndData();
} // if( !fbConfigSent )
else
SendHistograms();
fLastPublishTime = std::chrono::system_clock::now();
} // if( ( fdMaxPublishTime < elapsedSeconds.count() ) || ( 0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count() ) )
}
return true;
}
bool CbmDeviceBuildDigiEvents::SendEvents(FairMQParts& partsIn)
{
/// Get vector reference from algo
std::vector<CbmEvent*> vEvents = fpAlgo->GetEventVector();
/// Move CbmEvent from temporary vector to std::vector of full objects
LOG(debug) << "Vector size: " << vEvents.size();
std::vector<CbmEvent> vOutEvents;
for (CbmEvent* event : vEvents) {
LOG(debug) << "Vector ptr: " << event->ToString();
vOutEvents.push_back(std::move(*event));
LOG(debug) << "Vector obj: " << vOutEvents[(vOutEvents.size()) - 1].ToString();
}
/// Serialize the array of events into a single MQ message
/// FIXME: Find out if possible to use only the boost serializer
FairMQMessagePtr message(NewMessage());
// Serialize<RootSerializer>(*message, &(vOutEvents));
RootSerializer().Serialize(*message, &(vOutEvents));
/*
std::stringstream ossEvt;
boost::archive::binary_oarchive oaEvt(ossEvt);
oaEvt << vOutEvents;
std::string* strMsgEvt = new std::string(ossEvt.str());
*/
/// Add it at the end of the input composed message
/// FIXME: Find out if possible to use only the boost serializer
FairMQParts partsOut(std::move(partsIn));
partsOut.AddPart(std::move(message));
/*
partsOut.AddPart(NewMessage(
const_cast<char*>(strMsgEvt->c_str()), // data
strMsgEvt->length(), // size
[](void*, void* object) { delete static_cast<std::string*>(object); },
strMsgEvt)); // object that manages the data
*/
if (Send(partsOut, fsChannelNameDataOutput) < 0) {
LOG(error) << "Problem sending data to " << fsChannelNameDataOutput;
return false;
}
vOutEvents.clear();
return true;
}
bool CbmDeviceBuildDigiEvents::SendDigiEvents(FairMQParts& partsIn)
{
/// Get vector reference from algo
std::vector<CbmEvent*> vEvents = fpAlgo->GetEventVector();
/// Move CbmEvent from temporary vector to std::vector of full objects
LOG(debug) << "In Vector size: " << vEvents.size();
std::vector<CbmDigiEvent> vOutEvents;
vOutEvents.reserve(vEvents.size());
for (CbmEvent* event : vEvents) {
CbmDigiEvent selEvent;
selEvent.fTime = event->GetStartTime();
selEvent.fNumber = event->GetNumber();
/// FIXME: for pure digi based event, we select "continuous slices of digis"
/// => Copy block of [First Digi index, last digi index] with assign(it_start, it_stop)
/// FIXME: Keep TRD1D + TRD2D support, may lead to holes in the digi sequence!
/// => Would need to keep the loop
/// Get the proper order for block selection as TRD1D and TRD2D may insert indices in separate loops
/// => Needed to ensure that the start and stop of the block copy do not trigger a vector size exception
event->SortIndices();
/// for each detector, find the data in the Digi vectors and copy them
/// TODO: Template + loop on list of data types?
/// ==> Bmon
uint32_t uNbDigis =
(0 < event->GetNofData(ECbmDataType::kBmonDigi) ? event->GetNofData(ECbmDataType::kBmonDigi) : 0);
if (uNbDigis) {
auto startIt = fvDigiBmon->begin() + event->GetIndex(ECbmDataType::kBmonDigi, 0);
auto stopIt = fvDigiBmon->begin() + event->GetIndex(ECbmDataType::kBmonDigi, uNbDigis - 1);
++stopIt;
selEvent.fData.fBmon.fDigis.assign(startIt, stopIt);
}
/// ==> STS
uNbDigis = (0 < event->GetNofData(ECbmDataType::kStsDigi) ? event->GetNofData(ECbmDataType::kStsDigi) : 0);
if (uNbDigis) {
auto startIt = fvDigiSts->begin() + event->GetIndex(ECbmDataType::kStsDigi, 0);
auto stopIt = fvDigiSts->begin() + event->GetIndex(ECbmDataType::kStsDigi, uNbDigis - 1);
++stopIt;
selEvent.fData.fSts.fDigis.assign(startIt, stopIt);
}
/// ==> MUCH
uNbDigis = (0 < event->GetNofData(ECbmDataType::kMuchDigi) ? event->GetNofData(ECbmDataType::kMuchDigi) : 0);
if (uNbDigis) {
auto startIt = fvDigiMuch->begin() + event->GetIndex(ECbmDataType::kMuchDigi, 0);
auto stopIt = fvDigiMuch->begin() + event->GetIndex(ECbmDataType::kMuchDigi, uNbDigis - 1);
++stopIt;
selEvent.fData.fMuch.fDigis.assign(startIt, stopIt);
}
/// ==> TRD + TRD2D
uNbDigis = (0 < event->GetNofData(ECbmDataType::kTrdDigi) ? event->GetNofData(ECbmDataType::kTrdDigi) : 0);
if (uNbDigis) {
auto startIt = fvDigiTrd->begin() + event->GetIndex(ECbmDataType::kTrdDigi, 0);
auto stopIt = fvDigiTrd->begin() + event->GetIndex(ECbmDataType::kTrdDigi, uNbDigis - 1);
++stopIt;
selEvent.fData.fTrd.fDigis.assign(startIt, stopIt);
}
/// ==> TOF
uNbDigis = (0 < event->GetNofData(ECbmDataType::kTofDigi) ? event->GetNofData(ECbmDataType::kTofDigi) : 0);
if (uNbDigis) {
auto startIt = fvDigiTof->begin() + event->GetIndex(ECbmDataType::kTofDigi, 0);
auto stopIt = fvDigiTof->begin() + event->GetIndex(ECbmDataType::kTofDigi, uNbDigis - 1);
++stopIt;
selEvent.fData.fTof.fDigis.assign(startIt, stopIt);
}
/// ==> RICH
uNbDigis = (0 < event->GetNofData(ECbmDataType::kRichDigi) ? event->GetNofData(ECbmDataType::kRichDigi) : 0);
if (uNbDigis) {
auto startIt = fvDigiRich->begin() + event->GetIndex(ECbmDataType::kRichDigi, 0);
auto stopIt = fvDigiRich->begin() + event->GetIndex(ECbmDataType::kRichDigi, uNbDigis - 1);
++stopIt;
selEvent.fData.fRich.fDigis.assign(startIt, stopIt);
}
/// ==> PSD
uNbDigis = (0 < event->GetNofData(ECbmDataType::kPsdDigi) ? event->GetNofData(ECbmDataType::kPsdDigi) : 0);
if (uNbDigis) {
auto startIt = fvDigiPsd->begin() + event->GetIndex(ECbmDataType::kPsdDigi, 0);
auto stopIt = fvDigiPsd->begin() + event->GetIndex(ECbmDataType::kPsdDigi, uNbDigis - 1);
++stopIt;
selEvent.fData.fPsd.fDigis.assign(startIt, stopIt);
}
vOutEvents.push_back(std::move(selEvent));
}
LOG(debug) << "Out Vector size: " << vEvents.size();
/// Serialize the array of events into a single MQ message
std::stringstream ossEvt;
boost::archive::binary_oarchive oaEvt(ossEvt);
oaEvt << vOutEvents;
std::string* strMsgEvt = new std::string(ossEvt.str());
FairMQMessagePtr message(NewMessage(
const_cast<char*>(strMsgEvt->c_str()), // data
strMsgEvt->length(), // size
[](void*, void* object) { delete static_cast<std::string*>(object); },
strMsgEvt)); // object that manages the data
LOG(debug) << "Serializing done";
/// Make a new composed messaged with TsHeader + vector of Digi Event + TsMetaData
/// FIXME: Find out if possible to use only the boost serializer
FairMQParts partsOut;
partsOut.AddPart(std::move(partsIn.At(0))); // TsHeader
partsOut.AddPart(std::move(partsIn.At(partsIn.Size() - 1))); // TsMetaData
partsOut.AddPart(std::move(message)); // DigiEvent vector
LOG(debug) << "Message preparation done";
if (Send(partsOut, fsChannelNameDataOutput) < 0) {
LOG(error) << "Problem sending data to " << fsChannelNameDataOutput;
return false;
}
vOutEvents.clear();
return true;
}
bool CbmDeviceBuildDigiEvents::SendHistoConfAndData()
{
/// Prepare multiparts message and header
std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size());
FairMQMessagePtr messageHeader(NewMessage());
// Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader);
BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader);
FairMQParts partsOut;
partsOut.AddPart(std::move(messageHeader));
for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) {
/// Serialize the vector of histo config into a single MQ message
FairMQMessagePtr messageHist(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]);
partsOut.AddPart(std::move(messageHist));
} // for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto)
/// Catch case where no histos are registered!
/// => Add empty message
if (0 == fvpsHistosFolder.size()) {
FairMQMessagePtr messageHist(NewMessage());
partsOut.AddPart(std::move(messageHist));
}
for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) {
/// Serialize the vector of canvas config into a single MQ message
FairMQMessagePtr messageCan(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]);
partsOut.AddPart(std::move(messageCan));
} // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv)
/// Catch case where no Canvases are registered!
/// => Add empty message
if (0 == fvpsCanvasConfig.size()) {
FairMQMessagePtr messageHist(NewMessage());
partsOut.AddPart(std::move(messageHist));
}
/// Serialize the array of histos into a single MQ message
FairMQMessagePtr msgHistos(NewMessage());
// Serialize<RootSerializer>(*msgHistos, &fArrayHisto);
RootSerializer().Serialize(*msgHistos, &fArrayHisto);
partsOut.AddPart(std::move(msgHistos));
/// Send the multi-parts message to the common histogram messages queue
if (Send(partsOut, fsChannelNameHistosInput) < 0) {
LOG(error) << "CbmTsConsumerReqDevExample::SendHistoConfAndData => Problem sending data";
return false;
} // if( Send( partsOut, fsChannelNameHistosInput ) < 0 )
/// Reset the histograms after sending them (but do not reset the time)
fpAlgo->ResetHistograms(kFALSE);
return true;
}
bool CbmDeviceBuildDigiEvents::SendHistograms()
{
/// Serialize the array of histos into a single MQ message
FairMQMessagePtr message(NewMessage());
// Serialize<RootSerializer>(*message, &fArrayHisto);
RootSerializer().Serialize(*message, &fArrayHisto);
/// Send message to the common histogram messages queue
if (Send(message, fsChannelNameHistosInput) < 0) {
LOG(error) << "Problem sending data";
return false;
} // if( Send( message, fsChannelNameHistosInput ) < 0 )
/// Reset the histograms after sending them (but do not reset the time)
fpAlgo->ResetHistograms(kFALSE);
return true;
}
CbmDeviceBuildDigiEvents::~CbmDeviceBuildDigiEvents()
{
/// Clear metadata
if (fCbmTsEventHeader) delete fCbmTsEventHeader;
/// Clear vectors
if (fvDigiBmon) fvDigiBmon->clear();
if (fvDigiSts) fvDigiSts->clear();
if (fvDigiMuch) fvDigiMuch->clear();
if (fvDigiTrd) fvDigiTrd->clear();
if (fvDigiTof) fvDigiTof->clear();
if (fvDigiRich) fvDigiRich->clear();
if (fvDigiPsd) fvDigiPsd->clear();
/// Clear metadata
if (fTimeSliceMetaDataArray) {
fTimeSliceMetaDataArray->Clear();
delete fTsMetaData;
delete fTimeSliceMetaDataArray;
}
if (fpAlgo) delete fpAlgo;
}
void CbmDeviceBuildDigiEvents::Finish() {}
/* Copyright (C) 2021 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau[committer] */
/**
* CbmDeviceBuildRawEvents.h
*
* @since 2021-11-18
* @author P.-A. Loizeau
*/
#ifndef CBMDEVICEBUILDDIGIEVENTS_H_
#define CBMDEVICEBUILDDIGIEVENTS_H_
/// CBM headers
#include "CbmAlgoBuildRawEvents.h"
#include "CbmBmonDigi.h"
#include "CbmMuchDigi.h"
#include "CbmPsdDigi.h"
#include "CbmRichDigi.h"
#include "CbmStsDigi.h"
#include "CbmTofDigi.h"
#include "CbmTrdDigi.h"
/// FAIRROOT headers
#include "FairMQDevice.h"
/// FAIRSOFT headers (geant, boost, ...)
#include "Rtypes.h"
#include "TObjArray.h"
/// C/C++ headers
#include <chrono>
#include <map>
#include <vector>
class TList;
class TClonesArray;
class FairRunOnline;
class CbmTsEventHeader;
class CbmDeviceBuildDigiEvents : public FairMQDevice {
public:
CbmDeviceBuildDigiEvents();
virtual ~CbmDeviceBuildDigiEvents();
protected:
virtual void InitTask();
bool HandleData(FairMQParts&, int);
bool HandleCommand(FairMQMessagePtr&, int);
private:
/// Constants
/// Control flags
Bool_t fbIgnoreTsOverlap = kFALSE; //! Ignore data in Overlap part of the TS
Bool_t fbFillHistos = kTRUE; //! Switch ON/OFF filling of histograms
/// User settings parameters
/// Algo enum settings
std::string fsEvtOverMode = "NoOverlap";
std::string fsRefDet = "kBmon";
std::vector<std::string> fvsAddDet = {};
std::vector<std::string> fvsDelDet = {};
std::vector<std::string> fvsSetTrigWin = {};
std::vector<std::string> fvsSetTrigMinNb = {};
std::vector<std::string> fvsSetTrigMaxNb = {};
std::vector<std::string> fvsSetTrigMinLayersNb = {};
std::vector<std::string> fvsSetHistMaxDigiNb = {};
/// I/O control
bool fbDoNotSend = false;
bool fbDigiEventOutput = false;
/// message queues
std::string fsChannelNameDataInput = "unpts_0";
std::string fsChannelNameDataOutput = "events";
std::string fsChannelNameCommands = "commands";
std::string fsChannelNameHistosInput = "histogram-in";
/// Histograms management
uint32_t fuPublishFreqTs = 100;
double_t fdMinPublishTime = 0.5;
double_t fdMaxPublishTime = 5.0;
/// List of MQ channels names
std::vector<std::string> fsAllowedChannels = {fsChannelNameDataInput};
/// Statistics & first TS rejection
uint64_t fulNumMessages = 0;
uint64_t fulTsCounter = 0;
std::chrono::system_clock::time_point fLastPublishTime = std::chrono::system_clock::now();
/// Processing algos
CbmAlgoBuildRawEvents* fpAlgo = nullptr;
/// TS MetaData stable values storage
size_t fuNbCoreMsPerTs = 0; //!
size_t fuNbOverMsPerTs = 0; //!
Double_t fdMsSizeInNs = 1280000; //! Size of a single MS, [nanoseconds]
Double_t fdTsCoreSizeInNs = -1.0; //! Total size of the core MS in a TS, [nanoseconds]
Double_t fdTsOverSizeInNs = -1.0; //! Total size of the overlap MS in a TS, [nanoseconds]
Double_t fdTsFullSizeInNs = -1.0; //! Total size of all MS in a TS, [nanoseconds]
/// Data reception
/// TS information in header
CbmTsEventHeader* fCbmTsEventHeader = nullptr;
/// Digis storage
std::vector<CbmBmonDigi>* fvDigiBmon = nullptr;
std::vector<CbmStsDigi>* fvDigiSts = nullptr;
std::vector<CbmMuchDigi>* fvDigiMuch = nullptr;
std::vector<CbmTrdDigi>* fvDigiTrd = nullptr;
std::vector<CbmTofDigi>* fvDigiTof = nullptr;
std::vector<CbmRichDigi>* fvDigiRich = nullptr;
std::vector<CbmPsdDigi>* fvDigiPsd = nullptr;
/// TS MetaData storage
TClonesArray* fTimeSliceMetaDataArray = nullptr; //!
TimesliceMetaData* fTsMetaData = nullptr;
/// Array of histograms to send to the histogram server
TObjArray fArrayHisto = {};
/// Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server
std::vector<std::pair<std::string, std::string>> fvpsHistosFolder = {};
/// Vector of string pairs with ( CanvasName, CanvasConfig ) to send to the histogram server
/// Format of Can config is "NbPadX(U);NbPadY(U);ConfigPad1(s);....;ConfigPadXY(s)"
/// Format of Pad config is "GrixX(b),GridY(b),LogX(b),LogY(b),LogZ(b),HistoName(s),DrawOptions(s)"
std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig = {};
/// Flag indicating whether the histograms and canvases configurations were already published
bool fbConfigSent = false;
/// Check wether an MQ channel name is among those expected for this device
bool IsChannelNameAllowed(std::string channelName);
/// Get detector event builder config from string containing name
RawEventBuilderDetector GetDetectorBuilderCfg(std::string detName);
/// Get detector type from string containing name
ECbmModuleId GetDetectorId(std::string detName);
bool InitHistograms();
void Finish();
bool SendEvents(FairMQParts& partsIn);
bool SendDigiEvents(FairMQParts& partsIn);
bool SendHistoConfAndData();
bool SendHistograms();
};
#endif /* CBMDEVICEBUILDDIGIEVENTS_H_ */