25 #include <QTreeWidget>
26 #include <QTreeWidgetItem>
36 :
Logger(
"VP1TriggerProcessor"),
37 m_triggersystem(nullptr),
42 m_L1_QData{}, m_L2_QData{}, m_EF_QData{} {
43 log_verbose(
"constructor");
51 log_verbose(
"destructor");
52 delete m_triggersystem;
60 log_info(
"Initializing VP1Trig::VP1TriggerSystem");
70 QString
method=
"loadData(): ";
71 log_info(
"Loading trigger data via VP1TriggerSystem");
75 m_daqStatus = m_triggersystem->loadTriggerHandles(
storeGate, m_trigLvl);
79 log_fatal(
method+
"system initialized but retrieving data failed!");
82 log_error(
method+
"trigger system not initialized!");
90 QString
method=
"processData(): ";
91 log_info(
"Processing trigger data: start");
94 bool l1status=
false,l2status=
false,efstatus=
false;
97 QTreeWidgetItem * L1_triggers, * L2_triggers, * EF_triggers;
98 L1_triggers =
new QTreeWidgetItem(0);
99 L2_triggers =
new QTreeWidgetItem(0);
100 EF_triggers =
new QTreeWidgetItem(0);
101 L1_triggers->setText(0, QString(
"Triggers"));
102 L2_triggers->setText(0, QString(
"Triggers"));
103 EF_triggers->setText(0, QString(
"Triggers"));
112 if(m_trigLvl.compare(
"ALL", Qt::CaseInsensitive)==0 || m_trigLvl.compare(
"L1", Qt::CaseInsensitive)==0) {
113 std::vector<VP1Trig::VP1TriggerHandleL1> handleL1 = m_triggersystem->getHandleL1();
116 if(handleL1.size()>0) {
117 log_info(pfx1()+
"processing L1 data: start");
119 if(m_dataFormat==
'q') {
120 log_verbose(
"processing sector for QTree format");
122 m_L1_QData =
new QTreeWidgetItem(0);
123 m_L1_QData->setText(0, QString(
"L1 Data"));
126 for(l1it=handleL1.begin(); l1it!=handleL1.end(); ++l1it) {
127 if(l1it->processQTrigItem()) {
128 QString trigID = l1it->m_trigID;
129 if(trigID.contains(
"L2_"))
130 L2_triggers->addChild(l1it->m_qtrigitem);
131 else if(trigID.contains(
"EF_"))
132 EF_triggers->addChild(l1it->m_qtrigitem);
134 L1_triggers->addChild(l1it->m_qtrigitem);
137 m_L1_QData->addChild(L1_triggers);
140 m_trigLvlDataSet << m_L1_QData;
143 if(
int(m_L1_QData->childCount())>0)
146 log_warning(
"L1 QTree has no children");
149 else if(m_dataFormat==
'v') {
150 log_verbose(
"processing sector for vector format");
152 int p_success=0, p_failed=0;
155 for(l1it=handleL1.begin(); l1it!=handleL1.end(); ++l1it) {
156 if(l1it->processVTrigItem())
166 log_warning(
"L1 data item(s) failed processing: "+
VP1String::str(p_failed));
169 log_error(
method+
"data container format invalid!");
170 log_info(pfx1()+
"processing L1 data: complete");
173 log_warning(
method+
"L1 data requested but not available");
179 if(m_trigLvl.compare(
"ALL", Qt::CaseInsensitive)==0 || m_trigLvl.compare(
"L2", Qt::CaseInsensitive)==0) {
180 std::vector<VP1Trig::VP1TriggerHandleL2> handleL2 = m_triggersystem->getHandleL2();
183 if(handleL2.size()>0) {
184 log_info(pfx1()+
"processing L2 data: start");
185 if(m_dataFormat==
'q') {
186 log_verbose(
"processing sector for QTree format");
188 if(l2it->processQTrigItem())
189 m_L2_QData = l2it->m_qtrigData;
191 m_L2_QData =
new QTreeWidgetItem(0);
192 m_L2_QData->setText(0, QString(
"L2 Data"));
194 if(
int(L2_triggers->childCount())>0)
195 m_L2_QData->insertChild(0,L2_triggers);
198 m_trigLvlDataSet << m_L2_QData;
201 if(
int(m_L2_QData->childCount())>0)
204 log_warning(
"L2 QTree has no children");
206 else if(m_dataFormat==
'v') {
207 log_verbose(
"processing sector for vector format");
209 l2it->processVTrigItem();
215 log_error(
method+
"data container format invalid!");
216 log_info(pfx1()+
"processing L2 data: complete");
219 log_warning(
method+
"L2 data requested but not available");
225 if(m_trigLvl.compare(
"ALL", Qt::CaseInsensitive)==0 || m_trigLvl.compare(
"EF", Qt::CaseInsensitive)==0) {
226 std::vector<VP1Trig::VP1TriggerHandleEF> handleEF = m_triggersystem->getHandleEF();
232 if(handleEF.size()>0) {
233 log_info(pfx1()+
"processing EF data: start");
234 if(m_dataFormat==
'q') {
235 log_verbose(
"processing sector for QTree format");
237 m_EF_QData =
new QTreeWidgetItem(0);
238 m_EF_QData->setText(0, QString(
"EF Data"));
241 if(
int(EF_triggers->childCount())>0)
242 m_EF_QData->addChild(EF_triggers);
243 for(efit=handleEF.begin(); efit!=handleEF.end(); ++efit) {
244 if(efit->processQTrigItem())
245 m_EF_QData->addChild(efit->m_qtrigData);
249 m_trigLvlDataSet << m_EF_QData;
252 if(
int(m_EF_QData->childCount())>0)
255 log_warning(
"EF QTree has no children");
257 else if(m_dataFormat==
'v') {
258 log_verbose(
"processing sector for vector format");
260 int p_success=0, p_failed=0;
263 for(efit=handleEF.begin(); efit!=handleEF.end(); ++efit) {
264 if(efit->processVTrigItem())
274 log_warning(
"EF data item(s) failed processing: "+
VP1String::str(p_failed));
277 log_error(
method+
"data container format invalid!");
278 log_info(pfx1()+
"processing EF data: complete");
281 log_warning(
method+
"EF data requested but not available");
287 if(l1status || l2status || efstatus)
293 log_info(
"Processing trigger data: complete");
301 log_info(
"clearSystem()");
303 m_triggersystem->clearTriggerHandles();
305 m_trigLvlDataSet.clear();
307 m_L1_QData->takeChildren();
308 m_L2_QData->takeChildren();
309 m_EF_QData->takeChildren();
322 log_verbose(
"User request: return status of initalization");
331 log_verbose(
"User request: return daq status");
340 log_verbose(
"User request: return data container export type");
349 log_verbose(
"User request: return trigger level flag to process");
358 log_verbose(
"User request: return number of muons in event");
367 log_verbose(
"User request: return collected trigger data in QTree container format");
368 QList<QTreeWidgetItem *> customDataSet;
371 if(triglvl.compare(
"ALL", Qt::CaseInsensitive)==0 || triglvl.compare(
"L1", Qt::CaseInsensitive)==0 || triglvl.compare(
"L2", Qt::CaseInsensitive)==0 || triglvl.compare(
"EF", Qt::CaseInsensitive)==0) {
372 if(m_trigLvl.compare(triglvl, Qt::CaseInsensitive)==0)
373 return m_trigLvlDataSet;
374 else if(m_trigLvl.compare(
"ALL", Qt::CaseInsensitive)==0) {
375 if(triglvl.compare(
"ALL", Qt::CaseInsensitive)==0)
376 return m_trigLvlDataSet;
377 else if(triglvl.compare(
"L1", Qt::CaseInsensitive)==0) {
378 customDataSet << m_L1_QData;
379 return customDataSet;
381 else if(triglvl.compare(
"L2", Qt::CaseInsensitive)==0) {
382 customDataSet << m_L2_QData;
383 return customDataSet;
385 else if(triglvl.compare(
"EF", Qt::CaseInsensitive)==0) {
386 customDataSet << m_EF_QData;
387 return customDataSet;
393 log_fatal(
"User data request: DAQ not available!");
394 return customDataSet;
397 log_error(
"User requested ["+triglvl+
"] trigger data which is not available! Only ["+m_trigLvl+
"] available.");
398 return m_trigLvlDataSet;
411 if(triglvl.compare(
"L1", Qt::CaseInsensitive)==0 || triglvl.compare(
"L2", Qt::CaseInsensitive)==0 || triglvl.compare(
"EF", Qt::CaseInsensitive)==0 || triglvl.compare(
"ALL", Qt::CaseInsensitive)==0) {
412 log_verbose(
"User request: set trigger level flag to "+triglvl);
416 log_error(
"setTrigLvl(): ["+triglvl+
"] as trigger level flag not available!");
424 if(ctnid==
'v' || ctnid==
'q' || ctnid==
'a') {
425 log_verbose(
"User request: set data container format to "+qstr(ctnid));
426 m_dataFormat = ctnid;
429 log_error(
"setDataFormat(): ["+qstr(ctnid)+
"] as data container format not available!");