--- /dev/null
+// $Id$
+
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
+//* for The ALICE HLT Project. *
+//* *
+//* Permission to use, copy, modify and distribute this software and its *
+//* documentation strictly for non-commercial purposes is hereby granted *
+//* without fee, provided that the above copyright notice appears in all *
+//* copies and that both the copyright notice and this permission notice *
+//* appear in the supporting documentation. The authors make no claims *
+//* about the suitability of this software for any purpose. It is *
+//* provided "as is" without express or implied warranty. *
+//**************************************************************************
+
+/** @file AliHLTReadoutListDumpComponent.cxx
+ @author Matthias Richter
+ @date
+ @brief Base class for writer components to store data in a ROOT file
+
+ */
+
+#include "AliHLTReadoutListDumpComponent.h"
+#include "AliHLTTriggerDecision.h"
+#include "AliHLTCTPData.h"
+#include "TH1I.h"
+#include "TH2I.h"
+#include "TString.h"
+#include "TFile.h"
+#include "TSystem.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTReadoutListDumpComponent)
+
+AliHLTReadoutListDumpComponent::AliHLTReadoutListDumpComponent()
+ : AliHLTFileWriter()
+ , fMode(AliHLTReadoutListDumpComponent::kModeBinaryList)
+ , fBitsHisto(NULL)
+ , fBitsVsCTP(NULL)
+{
+ // see header file for class documentation
+ // or
+ // refer to README to build package
+ // or
+ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTReadoutListDumpComponent::~AliHLTReadoutListDumpComponent()
+{
+ // see header file for class documentation
+}
+
+int AliHLTReadoutListDumpComponent::InitWriter()
+{
+ // see header file for class documentation
+ int iResult=0;
+ fBitsHisto=CreateReadoutListHistogram();
+ fBitsVsCTP=CreateReadoutListVsCTPHistogram();
+ if (!fBitsHisto || !fBitsVsCTP) return -ENOMEM;
+
+ return iResult;
+}
+
+int AliHLTReadoutListDumpComponent::CloseWriter()
+{
+ // see header file for class documentation
+ TString filename=GetDirectory();
+ if (!filename.IsNull() && !filename.EndsWith("/")) filename+="/";
+ filename+=fBitsHisto->GetName();
+ filename+="_";
+ filename+=GetRunNo();
+ filename+=".root";
+
+ TFile out(filename, "RECREATE");
+ fBitsHisto->Write();
+ fBitsVsCTP->Write();
+ out.Close();
+
+ delete fBitsHisto;
+ fBitsHisto=NULL;
+ delete fBitsVsCTP;
+ fBitsVsCTP=NULL;
+ return 0;
+}
+
+int AliHLTReadoutListDumpComponent::DumpEvent( const AliHLTComponentEventData& /*evtData*/,
+ const AliHLTComponentBlockData* /*blocks*/,
+ AliHLTComponentTriggerData& trigData )
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (!IsDataEvent()) return 0;
+
+ if (fMode==AliHLTReadoutListDumpComponent::kModeBinaryList) {
+ const AliHLTComponentDataType hltrdlstdt=AliHLTComponentDataTypeInitializer("HLTRDLST", "HLT ");
+ for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock();
+ pBlock && iResult>=0;
+ pBlock=GetNextInputBlock()) {
+ if (pBlock->fDataType!=hltrdlstdt) continue;
+ if (pBlock->fSize==sizeof(AliHLTEventDDL)) {
+ HLTDebug("Filling histograms from binary buffer");
+ FillReadoutListHistogram(fBitsHisto, reinterpret_cast<AliHLTEventDDL*>(pBlock->fPtr));
+ FillReadoutListVsCTP(fBitsVsCTP, reinterpret_cast<AliHLTEventDDL*>(pBlock->fPtr), &trigData);
+ } else {
+ HLTError("HLTRDLST size missmatch: %d, expected %d", pBlock->fSize, sizeof(AliHLTEventDDL));
+ }
+ }
+ } else if (fMode==AliHLTReadoutListDumpComponent::kModeHLTDecision) {
+ for (const TObject* pObject=GetFirstInputObject();
+ pObject && iResult>=0;
+ pObject=GetNextInputObject()) {
+ const AliHLTTriggerDecision* pDecision=dynamic_cast<const AliHLTTriggerDecision*>(pObject);
+ if (!pDecision) continue;
+
+ AliHLTReadoutList list=pDecision->ReadoutList();
+ HLTDebug("Filling histograms from HLT decision object");
+ FillReadoutListHistogram(fBitsHisto, &list);
+ FillReadoutListVsCTP(fBitsVsCTP, &list, &trigData);
+ }
+ } else {
+ HLTError("invalid mode %d", fMode);
+ iResult=-EFAULT;
+ }
+ return iResult;
+}
+
+int AliHLTReadoutListDumpComponent::ScanArgument(int argc, const char** argv)
+{
+ // see header file for class documentation
+ int iResult=-EINVAL;
+ if (argc<=0) return 0;
+ int i=0;
+ TString argument=argv[i];
+
+ // -binary
+ if (argument.CompareTo("-binary")==0) {
+ fMode=AliHLTReadoutListDumpComponent::kModeBinaryList;
+ return 1;
+ }
+
+ // -decision
+ if (argument.CompareTo("-decision")==0) {
+ fMode=AliHLTReadoutListDumpComponent::kModeHLTDecision;
+ return 1;
+ }
+
+ return iResult;
+}
+
+TH1I* AliHLTReadoutListDumpComponent::CreateReadoutListHistogram()
+{
+ // see header file for class documentation
+ int bins=gkAliHLTDDLListSize*sizeof(AliHLTUInt32_t)*8;
+ TH1I* histo=new TH1I("HLTRDLST","HLT readout list", bins, 0, bins);
+ return histo;
+}
+
+TH2I* AliHLTReadoutListDumpComponent::CreateReadoutListVsCTPHistogram()
+{
+ // see header file for class documentation
+ int bins=gkAliHLTDDLListSize*sizeof(AliHLTUInt32_t)*8;
+ TH2I* histo=new TH2I("HLTRDLSTvsCTP","HLT readout list vs. CTP trigger", bins, 0, bins, gkNCTPTriggerClasses, 0, gkNCTPTriggerClasses);
+ return histo;
+}
+
+int AliHLTReadoutListDumpComponent::FillReadoutListHistogram(TH1I* histo, const AliHLTReadoutList* list)
+{
+ // see header file for class documentation
+ if (!histo || !list) return -EINVAL;
+ if (list->BufferSize()!=sizeof(AliHLTEventDDL)) return -EBADR;
+
+ return FillReadoutListHistogram(histo, list->Buffer());
+}
+
+int AliHLTReadoutListDumpComponent::FillReadoutListHistogram(TH1I* histo, const AliHLTEventDDL* field)
+{
+ // see header file for class documentation
+ if (!histo || !field) return -EINVAL;
+
+ if (field->fCount!=(unsigned)gkAliHLTDDLListSize) return -EBADF;
+
+ for (int word=0; word<gkAliHLTDDLListSize; word++) {
+ for (unsigned bit=0; bit<sizeof(AliHLTUInt32_t)*8; bit++) {
+ if (field->fList[word]&0x1<<bit) histo->Fill(word*sizeof(AliHLTUInt32_t)*8+bit);
+ }
+ }
+
+ return 0;
+}
+
+int AliHLTReadoutListDumpComponent::FillReadoutListVsCTP(TH2I* histo, const AliHLTReadoutList* list, const AliHLTComponentTriggerData* trigData)
+{
+ // see header file for class documentation
+ if (!histo || !list || !trigData) return -EINVAL;
+ if (list->BufferSize()!=sizeof(AliHLTEventDDL)) return -EBADR;
+
+ return FillReadoutListVsCTP(histo, list->Buffer(), trigData);
+}
+
+int AliHLTReadoutListDumpComponent::FillReadoutListVsCTP(TH2I* histo, const AliHLTEventDDL* field, const AliHLTComponentTriggerData* trigData)
+{
+ // see header file for class documentation
+ if (!histo || !field || !trigData) return -EINVAL;
+
+ if (field->fCount!=(unsigned)gkAliHLTDDLListSize) return -EBADF;
+
+ AliHLTUInt64_t triggerMask=AliHLTCTPData::ActiveTriggers(*trigData);
+ AliHLTUInt64_t bit0=0x1;
+ for (int word=0; word<gkAliHLTDDLListSize; word++) {
+ for (unsigned bit=0; bit<sizeof(AliHLTUInt32_t)*8; bit++) {
+ if (field->fList[word]&0x1<<bit) {
+ for (int trigger=0; trigger<gkNCTPTriggerClasses; trigger++) {
+ if ((triggerMask&(bit0<<trigger))!=0) {
+ histo->Fill(word*sizeof(AliHLTUInt32_t)*8+bit, trigger);
+ }
+ }
+ }
+ }
+ }
+
+ return 0;
+}
--- /dev/null
+// -*- Mode: C++ -*-
+// $Id$
+
+#ifndef ALIHLTREADOUTLISTDUMPCOMPONENT_H
+#define ALIHLTREADOUTLISTDUMPCOMPONENT_H
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* See cxx source for full Copyright notice *
+
+/** @file AliHLTReadoutListDumpComponent.h
+ @author Matthias Richter
+ @date
+ @brief Collect ESDs of multiple events and write toi file
+*/
+
+#include "AliHLTFileWriter.h"
+
+class TH1I;
+class TH2I;
+class AliHLTReadoutList;
+
+/**
+ * @class AliHLTReadoutListDumpComponent
+ * The ReadoutListDump component fetches the DAQ readout list object
+ * and can store the information in different ways, like e.g. in a histogram
+ * or a tree.
+ *
+ * <h2>General properties:</h2>
+ *
+ * Component ID: \b ReadoutListDump <br>
+ * Library: \b libAliHLTUtil.so <br>
+ * Input Data Types: {HLTRDLST:HLT }, <br>
+ * Output Data Types: none <br>
+ *
+ * <h2>Mandatory arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <h2>Optional arguments:</h2>
+ * \li -binary <br>
+ * fetch the binary readout list block (default)
+ * \li -decision <br>
+ * fetch the readout list from the HLT decision object
+ * The only AliHLTFileWriter argument of relevance is the \em -directory
+ * argument. See AliHLTFileWriter for full list of arguments.
+ *
+ * <h2>Configuration:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * Configuration by component arguments.
+ *
+ * <h2>Default CDB entries:</h2>
+ * The component loads no CDB entries.
+ *
+ * <h2>Performance:</h2>
+ * The component does not process any event data.
+ *
+ * <h2>Memory consumption:</h2>
+ * The component does not process any event data.
+ *
+ * <h2>Output size:</h2>
+ * No data published (AliHLTDataSink).
+ *
+ * @ingroup alihlt_util_components
+ */
+class AliHLTReadoutListDumpComponent : public AliHLTFileWriter
+{
+ public:
+ /** standard constructor */
+ AliHLTReadoutListDumpComponent();
+ /** destructor */
+ virtual ~AliHLTReadoutListDumpComponent();
+
+ /**
+ * The id of the component.
+ * @return component id (string)
+ */
+ const char* GetComponentID() {return "ReadoutListDump";};
+
+ /**
+ * Spawn function.
+ * @return new class instance
+ */
+ AliHLTComponent* Spawn() {return new AliHLTReadoutListDumpComponent;}
+
+ enum {
+ kModeBinaryList = 1, // fetch the readout list block
+ kModeHLTDecision = 2 // fetch the readout list from the HLT decision object
+ };
+
+ protected:
+ // interface functions
+
+ /// inherited form AliHLTFileWriter
+ int InitWriter();
+
+ /// inherited form AliHLTFileWriter
+ int CloseWriter();
+
+ /// inherited form AliHLTDataSink
+ int DumpEvent( const AliHLTComponentEventData& evtData,
+ const AliHLTComponentBlockData* blocks,
+ AliHLTComponentTriggerData& trigData );
+
+ using AliHLTFileWriter::DumpEvent;
+
+ /// inherited form AliHLTFileWriter
+ int ScanArgument(int argc, const char** argv);
+
+ /**
+ * Create the histogram for monitoring of the readout list.
+ * Each bin corresponds to a bit in the bitfield of the readout
+ * list.
+ * The object has to be deleted by the caller.
+ */
+ static TH1I* CreateReadoutListHistogram();
+
+ /**
+ * Create the histogram for monitoring of the readout list.
+ * Plot readout list bits vs. CTP trigger bit
+ * The object has to be deleted by the caller.
+ */
+ static TH2I* CreateReadoutListVsCTPHistogram();
+
+ /**
+ * Fill histogram from the readout list.
+ */
+ static int FillReadoutListHistogram(TH1I* histo, const AliHLTReadoutList* list);
+ /**
+ * Fill histogram from the readout list.
+ */
+ static int FillReadoutListHistogram(TH1I* histo, const AliHLTEventDDL* field);
+ /**
+ * Fill histogram from the readout list.
+ */
+ static int FillReadoutListVsCTP(TH2I* histo, const AliHLTReadoutList* list, const AliHLTComponentTriggerData* trigData);
+ /**
+ * Fill histogram from the readout list.
+ */
+ static int FillReadoutListVsCTP(TH2I* histo, const AliHLTEventDDL* field, const AliHLTComponentTriggerData* trigData);
+
+private:
+ /** copy constructor prohibited */
+ AliHLTReadoutListDumpComponent(const AliHLTReadoutListDumpComponent&);
+ /** assignment operator prohibited */
+ AliHLTReadoutListDumpComponent& operator=(const AliHLTReadoutListDumpComponent&);
+
+ unsigned fMode; /// how to get the readout list (kModeBinaryList, kModeHLTDecision)
+ TH1I* fBitsHisto; /// the histogram to be filled
+ TH2I* fBitsVsCTP; /// histogram of bits vs. ctp triggers
+
+ ClassDef(AliHLTReadoutListDumpComponent, 0)
+};
+#endif