]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
adding helper macro to print information on the HLTGlobalDecision from the raw data
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 12 Aug 2009 08:11:13 +0000 (08:11 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 12 Aug 2009 08:11:13 +0000 (08:11 +0000)
HLT/programs/print-RAW-HLTdecision.C [new file with mode: 0644]

diff --git a/HLT/programs/print-RAW-HLTdecision.C b/HLT/programs/print-RAW-HLTdecision.C
new file mode 100644 (file)
index 0000000..9d101c1
--- /dev/null
@@ -0,0 +1,92 @@
+// $Id$
+/**
+ * @file print-RAW-HLTdecision.C
+ * @brief Print HLT decisions per event of RAW data
+ * The uses the RawReader interface for data access and can be used
+ * with different types of data as long as a RawReader is implemented.
+ *
+ * <pre>
+ * Usage: aliroot -b -q print-RAW-HLTdecision.C'(input, minEvent, maxEvent)'
+ * 
+ * For help: aliroot -b -q print-RAW-HLTdecision.C
+ * </pre>
+ *
+ * @author Matthias.Richter@ift.uib.no
+ * @ingroup alihlt_programs
+ */
+void print_RAW_HLTdecision(const char* rawFileName,
+                          int minEvent=0, int maxEvent=-1)
+{
+  AliHLTLogging log;
+  log.SetGlobalLoggingLevel(0x7c);
+
+  AliRawReader* rawReader=NULL;
+  if (rawFileName && rawFileName[0]!=0) rawReader=AliRawReader::Create(rawFileName);
+  if (!rawFileName || rawFileName[0]==0 || !rawReader) {
+    if (rawFileName && rawFileName[0]!=0)
+      cerr << "can not open raw reader " << rawFileName << endl;
+    else
+      cerr << "print-RAW-HLTdecision.C Print HLT decisions per event of RAW data" << endl;
+    cerr << "===============================================================" << endl;
+    cerr << "usage: aliroot -b -q -l print-RAW-HLTdecision.C'(rawFileName" << endl;
+    cerr << "                                                 minEvent, maxEvent)'" << endl << endl;
+    cerr << "  Parameter:" << endl;
+    cerr << "       rawFileName      e.g \"raw.root\", \"./\"" << endl;
+    cerr << "       minEvent         first event (optional)" << endl;
+    cerr << "       maxEvent         last event (optional)" << endl;
+    cerr << "===============================================================" << endl;
+    return;
+  }
+
+  rawReader->RewindEvents();
+  int event=0;
+  if (!rawReader->NextEvent()) {
+    cout << "no events found in " << rawFileName << endl;
+    return;
+  }
+
+  AliHLTOUT* pHLTOUT=AliHLTOUT::New(rawReader);
+  if (!pHLTOUT) {
+    cerr << "can not create HLTOUT instance" << endl;
+    return;
+  }
+
+  do {
+    if (minEvent>=0 && event<minEvent) continue;
+    cout << "=====================  event " << event << "  ==========================" << endl;
+    if (pHLTOUT->Init()<0) {
+      cerr << "failed to initialize HLTOUT for event " << event << endl;
+      break;
+    }
+    bool found=false;
+    do {
+      TObject* decision=NULL;
+      // in the original implementation, the GlobalTriggerDecision has been
+      // sent with data type kAliHLTDataTypeTObject, thats why we check for
+      // both
+      if (pHLTOUT->SelectFirstDataBlock(kAliHLTDataTypeGlobalTrigger)>=0 ||
+         pHLTOUT->SelectFirstDataBlock(kAliHLTDataTypeTObject)>=0) {
+       decision=pHLTOUT->GetDataObject();
+      }
+      if (decision) {
+       if (decision->IsA() == AliHLTGlobalTriggerDecision::Class()) {
+         cout << "HLT Global Trigger: " << decision->GetOption() << "   " << decision->GetTitle() << endl;
+         decision->Print();
+         found=true;
+       }
+       pHLTOUT->ReleaseDataObject(decision);
+      }
+    } while (!found && pHLTOUT->SelectNextDataBlock());
+
+    if (!found) {
+      cout << "   no HLT decision found" << endl;
+    }
+    pHLTOUT->Reset();
+  } while (rawReader->NextEvent() && (maxEvent<0 || event<maxEvent));
+}
+
+void print_RAW_HLTdecision()
+{
+  // print usage
+  print_RAW_HLTdecision(NULL);
+}