stream  0.10.0
stream analysis framework
HldProcessor.h
1 #ifndef HADAQ_HLDPROCESSOR_H
2 #define HADAQ_HLDPROCESSOR_H
3 
4 #include "base/EventProc.h"
5 
6 #include "hadaq/definess.h"
7 
8 #include "hadaq/TrbProcessor.h"
9 
10 namespace hadaq {
11 
12 
14  typedef std::map<unsigned,TrbProcessor*> TrbProcMap;
15 
22  struct HldMessage {
23  uint8_t trig_type;
24  uint32_t seq_nr;
25  uint32_t run_nr;
26 
28  HldMessage() : trig_type(0), seq_nr(0), run_nr(0) {}
29 
31  HldMessage(const HldMessage& src) : trig_type(src.trig_type), seq_nr(src.seq_nr), run_nr(src.run_nr) {}
32  };
33 
40  class HldSubEvent : public base::SubEvent {
41  public:
43 
45  HldSubEvent() : base::SubEvent(), fMsg() {}
47  HldSubEvent(const HldMessage& msg) : base::SubEvent(), fMsg(msg) {}
49  virtual ~HldSubEvent() {}
50 
52  virtual unsigned Multiplicity() const { return 1; }
53  };
54 
62  class HldFilter : public base::EventProc {
63  protected:
64  unsigned fOnlyTrig;
65  public:
66 
68  HldFilter(unsigned trig = 0x1) : base::EventProc(), fOnlyTrig(trig) {}
69 
71  virtual ~HldFilter() {}
72 
74  virtual bool Process(base::Event* ev)
75  {
76  hadaq::HldSubEvent* sub =
77  dynamic_cast<hadaq::HldSubEvent*> (ev->GetSubEvent("HLD"));
78 
79  if (sub==0) return false;
80 
81  return sub->fMsg.trig_type == fOnlyTrig;
82  }
83  };
84 
93  class HldProcessor : public base::StreamProc {
94 
95  friend class TrbProcessor;
96 
97  protected:
98 
99  TrbProcMap fMap;
100 
101  unsigned fEventTypeSelect;
102 
104 
105  bool fAutoCreate;
106  std::string fAfterFunc;
107 
108  std::string fCalibrName;
111 
112  base::H1handle fEvType;
113  base::H1handle fEvSize;
114  base::H1handle fSubevSize;
115  base::H1handle fHitsPerTDC;
116  base::H1handle fErrPerTDC;
117  base::H2handle fHitsPerTDCChannel;
118  base::H2handle fErrPerTDCChannel;
119  base::H2handle fCorrPerTDCChannel;
120  base::H2handle fQaFinePerTDCChannel;
121  base::H2handle fQaToTPerTDCChannel;
122  base::H2handle fQaEdgesPerTDCChannel;
123  base::H2handle fQaErrorsPerTDCChannel;
124  base::H1handle fQaSummary;
125 
128 
130 
132 
135  virtual bool doTriggerSelection() const { return false; }
136 
138  void AddTrb(TrbProcessor* trb, unsigned id);
139 
140  virtual void CreateBranch(TTree*);
141 
142  virtual void Store(base::Event* ev);
143  virtual void ResetStore();
144 
145  void CreatePerTDCHisto();
146 
147  void DoHadesHistSummary();
148 
149  void SetCrossProcess(bool on);
150 
151  public:
152 
153  HldProcessor(bool auto_create = false, const char* after_func = "");
154  virtual ~HldProcessor();
155 
157  uint32_t GetEventId() const { return fMsg.seq_nr; }
159  uint32_t GetRunId() const { return fMsg.run_nr; }
160 
161  unsigned NumberOfTDC() const;
162  TdcProcessor* GetTDC(unsigned indx) const;
163  TdcProcessor* FindTDC(unsigned tdcid) const;
164 
165  unsigned NumberOfTRB() const;
166  TrbProcessor* GetTRB(unsigned indx) const;
167  TrbProcessor* FindTRB(unsigned trbid) const;
168 
169  void ConfigureCalibration(const std::string& fileprefix, long period, unsigned trig = 0xFFFF);
170 
172  void SetEventTypeSelect(unsigned evid) { fEventTypeSelect = evid; }
173 
174  virtual void SetTriggerWindow(double left, double right);
175 
176  virtual void SetStoreKind(unsigned kind = 1);
177 
179  virtual bool FirstBufferScan(const base::Buffer& buf);
180 
181  void SetPrintRawData(bool on = true);
183  bool IsPrintRawData() const { return fPrintRawData; }
184 
186  void SetAutoCreate(bool on = true) { fAutoCreate = on; }
187 
188  unsigned TransformEvent(void* src, unsigned len, void* tgt = 0, unsigned tgtlen = 0);
189 
190  virtual void UserPreLoop();
191 
194  };
195 
196 }
197 
198 #endif
Memory management class.
Definition: Buffer.h:49
Abstract processor of build events.
Definition: EventProc.h:12
EventProc(const char *name="", unsigned brdid=DummyBrdId)
Make constructor protected - no way to create base class instance.
Definition: EventProc.cxx:3
Event - collection of several subevents.
Definition: Event.h:17
base::SubEvent * GetSubEvent(const std::string &name) const
Return subevent by name.
Definition: Event.h:69
Abstract processor of data streams.
Definition: StreamProc.h:21
SubEvent - base class for all event structures Need for: virtual destructor - to be able delete any i...
Definition: base/SubEvent.h:14
SubEvent()
default constructor
Definition: base/SubEvent.h:17
HLD filter.
Definition: HldProcessor.h:62
virtual ~HldFilter()
destructor
Definition: HldProcessor.h:71
virtual bool Process(base::Event *ev)
process event
Definition: HldProcessor.h:74
HldFilter(unsigned trig=0x1)
constructor
Definition: HldProcessor.h:68
unsigned fOnlyTrig
configured trigger to filter
Definition: HldProcessor.h:64
HLD processor.
Definition: HldProcessor.h:93
void SetEventTypeSelect(unsigned evid)
Set event type, only used in the analysis.
Definition: HldProcessor.h:172
virtual void UserPreLoop()
Executing preliminary function before entering event loop.
Definition: HldProcessor.cxx:446
TdcProcessor * GetTDC(unsigned indx) const
Get TDC by index.
Definition: HldProcessor.cxx:122
void CreatePerTDCHisto()
Create summary histos where each bin corresponds to single TDC.
Definition: HldProcessor.cxx:457
virtual void CreateBranch(TTree *)
Create branch in TTree to store provided data - hadaq::HldMessage.
Definition: HldProcessor.cxx:204
base::H2handle fCorrPerTDCChannel
HADAQ corrections per TDC channel.
Definition: HldProcessor.h:119
TrbProcessor * GetTRB(unsigned indx) const
Get TRB by index.
Definition: HldProcessor.cxx:89
std::string fCalibrName
name of calibration for (auto)created components
Definition: HldProcessor.h:108
virtual bool FirstBufferScan(const base::Buffer &buf)
Scan all messages, find reference signals.
Definition: HldProcessor.cxx:216
base::H2handle fHitsPerTDCChannel
HADAQ hits per TDC channel.
Definition: HldProcessor.h:117
hadaqs::RawEvent fLastEvHdr
! copy of last event header (without data)
Definition: HldProcessor.h:129
base::H1handle fSubevSize
HADAQ sub-event size.
Definition: HldProcessor.h:114
std::string fAfterFunc
function called after new elements are created
Definition: HldProcessor.h:106
bool fAutoCreate
when true, TRB/TDC processors will be created automatically
Definition: HldProcessor.h:105
HldMessage fMsg
used for TTree store
Definition: HldProcessor.h:126
void ConfigureCalibration(const std::string &fileprefix, long period, unsigned trig=0xFFFF)
Configure calibration modes.
Definition: HldProcessor.cxx:159
virtual bool doTriggerSelection() const
Returns true when processor used to select trigger signal TRB3 not yet able to perform trigger select...
Definition: HldProcessor.h:135
base::H2handle fQaFinePerTDCChannel
HADAQ QA fine time per TDC channel.
Definition: HldProcessor.h:120
void SetCrossProcess(bool on)
Enable cross-processing of data Let produce time correlation between different TRBs.
Definition: HldProcessor.cxx:547
unsigned NumberOfTDC() const
Return number of TDCs in all TRBs.
Definition: HldProcessor.cxx:111
TdcProcessor * FindTDC(unsigned tdcid) const
Find TDC by id.
Definition: HldProcessor.cxx:136
uint32_t GetEventId() const
Returns current event id.
Definition: HldProcessor.h:157
virtual void Store(base::Event *ev)
Call store event.
Definition: HldProcessor.cxx:357
base::H1handle fErrPerTDC
HADAQ errors per TDC.
Definition: HldProcessor.h:116
hadaqs::RawEvent & GetLastEventHdr()
Return reference on last event header structure.
Definition: HldProcessor.h:193
base::H1handle fQaSummary
HADAQ QA summary histogram.
Definition: HldProcessor.h:124
unsigned fEventTypeSelect
selection for event type (lower 4 bits in event id)
Definition: HldProcessor.h:101
long fCalibrPeriod
how often calibration should be performed
Definition: HldProcessor.h:109
base::H1handle fHitsPerTDC
HADAQ hits per TDC.
Definition: HldProcessor.h:115
virtual void SetStoreKind(unsigned kind=1)
Set store kind for all sub processors.
Definition: HldProcessor.cxx:182
HldProcessor(bool auto_create=false, const char *after_func="")
constructor
Definition: HldProcessor.cxx:23
virtual ~HldProcessor()
destructor
Definition: HldProcessor.cxx:66
base::H2handle fQaEdgesPerTDCChannel
HADAQ QA edges per TDC channel.
Definition: HldProcessor.h:122
base::H2handle fQaToTPerTDCChannel
HADAQ QA ToT per TDC channel.
Definition: HldProcessor.h:121
void DoHadesHistSummary()
Fill QA summary histograms.
Definition: HldProcessor.cxx:323
HldMessage * pMsg
used for TTree store
Definition: HldProcessor.h:127
void SetPrintRawData(bool on=true)
Configure printing raw data in all sub-processors.
Definition: HldProcessor.cxx:193
TrbProcMap fMap
map of trb processors
Definition: HldProcessor.h:99
long fLastHadesTm
! last hades time
Definition: HldProcessor.h:131
unsigned NumberOfTRB() const
Return number of TRBs.
Definition: HldProcessor.cxx:81
void SetAutoCreate(bool on=true)
Enable auto-create mode.
Definition: HldProcessor.h:186
unsigned TransformEvent(void *src, unsigned len, void *tgt=0, unsigned tgtlen=0)
Function to transform HLD event, used for TDC calibrations.
Definition: HldProcessor.cxx:384
virtual void ResetStore()
Reset store.
Definition: HldProcessor.cxx:376
base::H1handle fEvSize
HADAQ event size.
Definition: HldProcessor.h:113
bool IsPrintRawData() const
Returns true if print raw data configured.
Definition: HldProcessor.h:183
base::H2handle fErrPerTDCChannel
HADAQ errors per TDC channel.
Definition: HldProcessor.h:118
bool fPrintRawData
true when raw data should be printed
Definition: HldProcessor.h:103
base::H2handle fQaErrorsPerTDCChannel
HADAQ QA errors per TDC channel.
Definition: HldProcessor.h:123
void AddTrb(TrbProcessor *trb, unsigned id)
Way to register trb processor.
Definition: HldProcessor.cxx:73
TrbProcessor * FindTRB(unsigned trbid) const
Find TRB by id.
Definition: HldProcessor.cxx:101
base::H1handle fEvType
HADAQ event type.
Definition: HldProcessor.h:112
virtual void SetTriggerWindow(double left, double right)
Set trigger window not only for itself, but for all subprocessors.
Definition: HldProcessor.cxx:171
uint32_t GetRunId() const
Returns current run id.
Definition: HldProcessor.h:159
unsigned fCalibrTriggerMask
mask with enabled event ID, default all
Definition: HldProcessor.h:110
HLD subevent.
Definition: HldProcessor.h:40
HldSubEvent(const HldMessage &msg)
copy constructor
Definition: HldProcessor.h:47
virtual ~HldSubEvent()
destructor
Definition: HldProcessor.h:49
virtual unsigned Multiplicity() const
Method returns event multiplicity - that ever it means.
Definition: HldProcessor.h:52
HldSubEvent()
constructor
Definition: HldProcessor.h:45
HldMessage fMsg
message
Definition: HldProcessor.h:42
TDC processor.
Definition: TdcProcessor.h:32
TRB processor.
Definition: TrbProcessor.h:46
HLD message.
Definition: HldProcessor.h:22
uint32_t run_nr
run number
Definition: HldProcessor.h:25
HldMessage(const HldMessage &src)
copy constructor
Definition: HldProcessor.h:31
uint8_t trig_type
trigger type
Definition: HldProcessor.h:23
uint32_t seq_nr
event sequence number
Definition: HldProcessor.h:24
HldMessage()
constructor
Definition: HldProcessor.h:28
HADES raw event.
Definition: definess.h:315