From: richterm Date: Tue, 29 Sep 2009 13:06:10 +0000 (+0000) Subject: adding a component for statistics and monitoring of the DAQ readout list X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=209986b4d8674557b1c5f5bf07fa88abee9a252e adding a component for statistics and monitoring of the DAQ readout list --- diff --git a/HLT/BASE/util/AliHLTAgentUtil.cxx b/HLT/BASE/util/AliHLTAgentUtil.cxx index dfcb2784a7c..1d373ce4af1 100644 --- a/HLT/BASE/util/AliHLTAgentUtil.cxx +++ b/HLT/BASE/util/AliHLTAgentUtil.cxx @@ -40,6 +40,7 @@ #include "AliHLTFilePublisher.h" #include "AliHLTBlockFilterComponent.h" #include "AliHLTEsdCollectorComponent.h" +#include "AliHLTReadoutListDumpComponent.h" #include "AliHLTOUTPublisherComponent.h" #include "AliHLTCompStatCollector.h" @@ -120,6 +121,7 @@ int AliHLTAgentUtil::RegisterComponents(AliHLTComponentHandler* pHandler) const pHandler->AddComponent(new AliHLTFilePublisher); pHandler->AddComponent(new AliHLTBlockFilterComponent); pHandler->AddComponent(new AliHLTEsdCollectorComponent); + pHandler->AddComponent(new AliHLTReadoutListDumpComponent); pHandler->AddComponent(new AliHLTOUTPublisherComponent); pHandler->AddComponent(new AliHLTCompStatCollector); return 0; diff --git a/HLT/BASE/util/AliHLTReadoutListDumpComponent.cxx b/HLT/BASE/util/AliHLTReadoutListDumpComponent.cxx new file mode 100644 index 00000000000..2112d824907 --- /dev/null +++ b/HLT/BASE/util/AliHLTReadoutListDumpComponent.cxx @@ -0,0 +1,225 @@ +// $Id$ + +//************************************************************************** +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* * +//* Primary Authors: Matthias Richter * +//* 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(pBlock->fPtr)); + FillReadoutListVsCTP(fBitsVsCTP, reinterpret_cast(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(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; wordfList[word]&0x1<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; wordfList[word]&0x1<Fill(word*sizeof(AliHLTUInt32_t)*8+bit, trigger); + } + } + } + } + } + + return 0; +} diff --git a/HLT/BASE/util/AliHLTReadoutListDumpComponent.h b/HLT/BASE/util/AliHLTReadoutListDumpComponent.h new file mode 100644 index 00000000000..527ef317eb4 --- /dev/null +++ b/HLT/BASE/util/AliHLTReadoutListDumpComponent.h @@ -0,0 +1,152 @@ +// -*- 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. + * + *

General properties:

+ * + * Component ID: \b ReadoutListDump
+ * Library: \b libAliHLTUtil.so
+ * Input Data Types: {HLTRDLST:HLT },
+ * Output Data Types: none
+ * + *

Mandatory arguments:

+ * + * + *

Optional arguments:

+ * \li -binary
+ * fetch the binary readout list block (default) + * \li -decision
+ * 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. + * + *

Configuration:

+ * + * Configuration by component arguments. + * + *

Default CDB entries:

+ * The component loads no CDB entries. + * + *

Performance:

+ * The component does not process any event data. + * + *

Memory consumption:

+ * The component does not process any event data. + * + *

Output size:

+ * 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