1 #ifndef HADAQ_TRBPROCESSOR_H
2 #define HADAQ_TRBPROCESSOR_H
4 #include "base/StreamProc.h"
6 #include "hadaq/definess.h"
7 #include "hadaq/TdcProcessor.h"
8 #include "hadaq/SubProcessor.h"
161 void SetHadaqHUBId(
unsigned id1,
unsigned id2=0,
unsigned id3=0,
unsigned id4=0)
225 for (SubProcMap::const_iterator iter =
fMap.begin(); iter!=
fMap.end(); iter++) {
226 if (indx==0)
return iter->second;
235 SubProcMap::const_iterator iter =
fMap.find(tdcid);
238 if ((iter ==
fMap.end()) && !fullid) iter =
fMap.find(tdcid & 0xff);
241 return ((iter !=
fMap.end()) && ((iter->first >> 16) == 0) && iter->second->IsTDC()) ? (
TdcProcessor*) iter->second : 0;
248 for (SubProcMap::const_iterator iter =
fMap.begin(); iter!=
fMap.end(); iter++) {
249 if (iter->second->IsTDC()) num++;
257 for (SubProcMap::const_iterator iter =
fMap.begin(); iter!=
fMap.end(); iter++) {
258 if (!iter->second->IsTDC())
continue;
273 static void SetDefaults(
unsigned numch=65,
unsigned edges=0x1,
bool ignore_sync =
true);
291 int CreateTDC(
unsigned id1,
unsigned id2 = 0,
unsigned id3 = 0,
unsigned id4 = 0);
300 void SetWriteCalibrations(
const char* fileprefix,
bool every_time =
false,
bool use_linear =
false);
Memory management class.
Definition: Buffer.h:49
Abstract processor of data streams.
Definition: StreamProc.h:21
HLD processor.
Definition: HldProcessor.h:93
Abstract processor of HADAQ sub-sub-event.
Definition: SubProcessor.h:26
TDC processor.
Definition: TdcProcessor.h:32
TRB processor.
Definition: TrbProcessor.h:46
static bool gIgnoreSync
ignore sync in analysis, very rare used for sync with other data sources
Definition: TrbProcessor.h:109
void SetCompensateEpochReset(bool on=true)
When enabled, artificially create contiguous epoch value.
Definition: TrbProcessor.h:217
base::H1handle fErrPerBrd
! errors per board
Definition: TrbProcessor.h:74
void BuildFastTDCVector()
Build vector of TDCs processor for fast access.
Definition: TrbProcessor.cxx:1017
unsigned fCalibrTriggerMask
trigger mask used for calibration
Definition: TrbProcessor.h:86
bool IsPrintRawData() const
Return true if printing of raw data enabled.
Definition: TrbProcessor.h:188
virtual void CreateBranch(TTree *t)
Create branch in TTree to store hadaq::TrbMessage.
Definition: TrbProcessor.cxx:532
static unsigned gNumChannels
default number of channels
Definition: TrbProcessor.h:107
virtual void UserPostLoop()
Post loop function.
Definition: TrbProcessor.cxx:198
bool fPrintRawData
true when raw data should be printed
Definition: TrbProcessor.h:80
void AfterEventScan()
Function called after event scan - TDCs analyze data they got.
Definition: TrbProcessor.cxx:489
base::H1handle fEvSize
HADAQ event size.
Definition: TrbProcessor.h:65
void EventError(const char *msg)
Add event-related error message - adds event info.
Definition: TrbProcessor.cxx:576
void SetPrintRawData(bool on=true)
Enables printing of raw data.
Definition: TrbProcessor.h:185
TdcProcessor * GetTDCWithIndex(unsigned indx) const
Get TDC processor by index.
Definition: TrbProcessor.h:255
void SetSyncIds(unsigned mask, unsigned value)
Set sync mask and value which, should be obtained from trigger type to detect CBM sync message in CTS...
Definition: TrbProcessor.h:204
bool fUseTriggerAsSync
when true, trigger number used as sync message between TRBs
Definition: TrbProcessor.h:88
static unsigned gTDCMin
min TDC id when doing autoscan
Definition: TrbProcessor.h:111
unsigned fMinTdc
minimal id of TDC
Definition: TrbProcessor.h:99
unsigned fHadaqCTSId
identifier of CTS header in HADAQ event
Definition: TrbProcessor.h:58
hadaqs::RawSubevent fLastSubevHdr
! copy of last subevent header (without data)
Definition: TrbProcessor.h:103
bool fAutoCreate
when true, automatically crates TDC processors
Definition: TrbProcessor.h:92
HldProcessor * GetHLD() const
Returns instance of hadaq::HldProcessor to which it belongs.
Definition: TrbProcessor.h:149
void AddBufferToTDC(hadaqs::RawSubevent *sub, hadaq::SubProcessor *tdcproc, unsigned ix, unsigned datalen)
Provide buffer to sub-processor.
Definition: TrbProcessor.cxx:541
void CreateCTS_TDC()
Create TDC processor, which extracts TDC information from CTS header.
Definition: TrbProcessor.h:294
void SetCh0Enabled(bool on=true)
Enable/disable ch0 store in output event for all TDC processors.
Definition: TrbProcessor.cxx:369
TdcProcessor * FindTDC(unsigned tdcid) const
Find TDC with provided id.
Definition: TrbProcessor.cxx:129
unsigned fTakenTriggerCnt
registered trigger counts
Definition: TrbProcessor.h:63
unsigned fLostTriggerCnt
lost trigger counts
Definition: TrbProcessor.h:62
virtual bool doTriggerSelection() const
Returns true when processor used to select trigger signal TRB3 not yet able to perform trigger select...
Definition: TrbProcessor.h:119
TrbProcessor(unsigned brdid=0, HldProcessor *hld=nullptr, int hfill=-1)
Constructor, one could specify histogram fill level.
Definition: TrbProcessor.cxx:53
unsigned fMaxTdc
maximal id of TDC
Definition: TrbProcessor.h:100
hadaqs::RawSubevent & GetLastSubeventHdr()
Return reference on last subevent header.
Definition: TrbProcessor.h:324
virtual bool FirstBufferScan(const base::Buffer &buf)
First scan of buffer - main entry point for data.
Definition: TrbProcessor.cxx:423
base::H2handle fToTPerBrd
! ToT values for each TDC channel
Definition: TrbProcessor.h:77
void BeforeEventScan()
Function called before each event scan.
Definition: TrbProcessor.cxx:480
unsigned TransformSubEvent(hadaqs::RawSubevent *sub, void *tgtbuf=nullptr, unsigned tgtlen=0, bool only_hist=false, std::vector< unsigned > *newids=nullptr)
Transform (calibrate) raw data Creates output HLD structure, used in HADES DAQ.
Definition: TrbProcessor.cxx:1055
void AddHadaqHUBId(unsigned id)
Add HUB id.
Definition: TrbProcessor.h:158
void SetCalibrTriggerMask(unsigned trigmask=0xFFFF)
Set trigger ids mask which should be used for calibration Value 0x3FF enables calibration for all kin...
Definition: TrbProcessor.cxx:336
void SetHadaqCTSId(unsigned id)
Set id of CTS sub-sub event.
Definition: TrbProcessor.h:155
base::H1handle fTrigType
trigger type
Definition: TrbProcessor.h:70
base::H2handle fCalHitsPerBrd
! calibration hits per board, used only in HADES
Definition: TrbProcessor.h:76
bool IsUseTriggerAsSync() const
Returns true if trigger number should be used to sync events over all TRBs.
Definition: TrbProcessor.h:214
hadaq::TrbMessage & GetTrbMsg()
Return reference on last filled message.
Definition: TrbProcessor.h:327
unsigned EmulateTransform(hadaqs::RawSubevent *sub, int dummycnt, bool only_hist=false)
Emulate transform (calibrate) raw data - only for debugging.
Definition: TrbProcessor.cxx:1206
void SetHadaqHUBId(unsigned id1, unsigned id2=0, unsigned id3=0, unsigned id4=0)
Set up to 4 different HUB ids.
Definition: TrbProcessor.h:161
unsigned fLastTriggerId
last seen trigger id
Definition: TrbProcessor.h:61
static unsigned gHUBMin
min HUB id when doing autoscan
Definition: TrbProcessor.h:114
void ConfigureCalibration(const std::string &name, long period, unsigned trigmask=0xFFFF)
Configure calibration.
Definition: TrbProcessor.cxx:316
bool LoadCalibrations(const char *fileprefix)
Load calibrations for all existing TDCs as argument file prefix (without TDC id) should be specified.
Definition: TrbProcessor.cxx:300
base::H1handle fHitsPerBrd
! data hits per board
Definition: TrbProcessor.h:75
void AddSub(SubProcessor *tdc, unsigned id)
Way to register sub-processor, like for TDC.
Definition: TrbProcessor.cxx:350
static unsigned gTDCMax
max TDC id when doing autoscan
Definition: TrbProcessor.h:112
bool fCrossProcess
if true, cross-processing will be enabled
Definition: TrbProcessor.h:81
bool fCompensateEpochReset
when true, artificially create contiguous epoch value
Definition: TrbProcessor.h:90
SubProcessor * GetSubProc(unsigned indx) const
Returns sub-processor by its index.
Definition: TrbProcessor.h:223
void AfterEventFill()
if SetCrossProcess() enabled - fill histograms across TDCs
Definition: TrbProcessor.cxx:499
bool IsCrossProcess() const
Returns true if cross-processing enabled.
Definition: TrbProcessor.h:196
void CreatePerTDCHistos()
Create overview histograms where each TDC corresponds one bin.
Definition: TrbProcessor.cxx:139
void ClearFastTDCVector()
Clear helper vector of TDCs processor for fast access.
Definition: TrbProcessor.cxx:1045
static void SetHUBRange(unsigned min, unsigned max)
Define range for HUBs, used when auto mode is enabled.
Definition: TrbProcessor.h:285
void SetHadaqSUBId(unsigned)
deprecated, keep for backward compatibility, can be ignored
Definition: TrbProcessor.h:173
void AccountTriggerId(unsigned id)
Assign current trigger id.
Definition: TrbProcessor.cxx:393
SubProcMap fMap
map of sub-processors
Definition: TrbProcessor.h:56
bool CollectMissingTDCs(hadaqs::RawSubevent *sub, std::vector< unsigned > &ids)
Using data structure in raw event, collect ids of missing TDCs.
Definition: TrbProcessor.cxx:979
bool CheckPrintError()
Checks if error can be print out.
Definition: TrbProcessor.cxx:207
unsigned fSyncTrigValue
value from trigger type (after mask) which corresponds to sync message
Definition: TrbProcessor.h:85
base::H1handle fErrBits
error bit statistics
Definition: TrbProcessor.h:71
virtual ~TrbProcessor()
Destructor.
Definition: TrbProcessor.cxx:122
virtual void UserPreLoop()
Pre loop function.
Definition: TrbProcessor.cxx:187
int fPrintErrCnt
number of error messages, which could be printed
Definition: TrbProcessor.h:82
void SetHadaqTDCId(unsigned)
deprecated, keep for backward compatibility, can be ignored
Definition: TrbProcessor.h:171
void SetAutoCreate(bool on=true)
enable autocreation mode if necessary, works for single event
Definition: TrbProcessor.h:152
void ClearDAQHistos()
Clear all DAQ-related histograms.
Definition: TrbProcessor.cxx:1229
static void SetDefaults(unsigned numch=65, unsigned edges=0x1, bool ignore_sync=true)
Set defaults for the next creation of TDC processors.
Definition: TrbProcessor.cxx:35
virtual void ScanSubEvent(hadaqs::RawSubevent *sub, unsigned trb3runid, unsigned trb3seqid)
Scan FPGA-TDC data, distribute over sub-processors.
Definition: TrbProcessor.cxx:600
unsigned fSubevHDiv
integer division for subevent
Definition: TrbProcessor.h:67
unsigned NumSubProc() const
Returns number of sub-processors.
Definition: TrbProcessor.h:220
bool HasPerTDCHistos() const
Are there per-TDC histograms.
Definition: TrbProcessor.h:319
unsigned fCurrentRunId
! current runid
Definition: TrbProcessor.h:104
HldProcessor * fHldProc
pointer on HLD processor
Definition: TrbProcessor.h:54
virtual void SetStoreKind(unsigned kind=1)
Configure store kind.
Definition: TrbProcessor.cxx:358
void SetPrintErrors(int cnt=100)
Set number of errors which could be printed.
Definition: TrbProcessor.h:191
void SetAutoCalibrations(long cnt=100000)
Set auto calibration for all existing TDCs.
Definition: TrbProcessor.cxx:266
void SetUseTriggerAsSync(bool on=true)
Use TRB trigger number as SYNC message.
Definition: TrbProcessor.h:212
std::vector< unsigned > fHadaqHUBId
identifier of HUB header in HADQ event
Definition: TrbProcessor.h:59
void DisableCalibrationFor(unsigned firstch, unsigned lastch=0)
Disable calibration of specified channels for all existing TDCs.
Definition: TrbProcessor.cxx:277
unsigned fCurrentEventId
! current processed event id, used in log msg
Definition: TrbProcessor.h:105
static unsigned gEdgesMask
default edges mask
Definition: TrbProcessor.h:108
TrbMessage * pMsg
used for TTree store
Definition: TrbProcessor.h:95
static unsigned GetDefaultNumCh()
Retun default number of TDC channels.
Definition: TrbProcessor.cxx:45
void EventLog(const char *msg)
Add event-related log message - adds event info.
Definition: TrbProcessor.cxx:586
base::H1handle fSubevSize
HADAQ subevent size.
Definition: TrbProcessor.h:68
TrbMessage fMsg
used for TTree store
Definition: TrbProcessor.h:94
std::vector< hadaq::TdcProcessor * > fTdcsVect
array of TDCs
Definition: TrbProcessor.h:101
void SetCrossProcessAll()
Cal SetCrossProcess for all existing TRB processors.
Definition: TrbProcessor.cxx:511
int CreateTDC(unsigned id1, unsigned id2=0, unsigned id3=0, unsigned id4=0)
Create up to 4 TDC with pre-configured default parameters.
Definition: TrbProcessor.cxx:222
static unsigned gHUBMax
max HUB id when doing autoscan
Definition: TrbProcessor.h:115
unsigned fSyncTrigMask
mask which should be applied for trigger type
Definition: TrbProcessor.h:84
void SetWriteCalibrations(const char *fileprefix, bool every_time=false, bool use_linear=false)
Set write calibration for all existing TDCs.
Definition: TrbProcessor.cxx:288
void SetCrossProcess(bool on=true)
Enable Cross-processing - hits correlation between different TDCs.
Definition: TrbProcessor.cxx:522
TdcProcessor * GetTDC(unsigned tdcid, bool fullid=false) const
Returns TDC processor according to it ID.
Definition: TrbProcessor.h:233
unsigned NumberOfTDC() const
Returns number of TDC processors.
Definition: TrbProcessor.h:245
base::H1handle fMsgPerBrd
! messages per board
Definition: TrbProcessor.h:73
base::H1handle fLostRate
lost rate
Definition: TrbProcessor.h:69
virtual void SetTriggerWindow(double left, double right)
Set trigger window for all TDCs.
Definition: TrbProcessor.cxx:380
unsigned fSubevHLen
maximal length of subevent in bytes
Definition: TrbProcessor.h:66
static void SetTDCRange(unsigned min, unsigned max)
Define range for TDCs, used when auto mode is enabled.
Definition: TrbProcessor.h:278
message used for ROOT tree storage, similar to TdcMessage and AdcMessage
Definition: TrbProcessor.h:17
unsigned fTrigSyncId
sync id
Definition: TrbProcessor.h:19
void Reset()
reset
Definition: TrbProcessor.h:26
uint64_t fTrigTm
trigger time
Definition: TrbProcessor.h:21
bool fTrigSyncIdFound
is sync id found
Definition: TrbProcessor.h:18
unsigned fSyncPulsePeriod
sync pulse period
Definition: TrbProcessor.h:22
unsigned fTrigSyncIdStatus
sync id status
Definition: TrbProcessor.h:20
unsigned fSyncPulseLength
sync pulse length
Definition: TrbProcessor.h:23
Raw hades subevent.
Definition: definess.h:408