3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 /** @file AliHLTReadoutListDumpComponent.cxx
20 @author Matthias Richter
22 @brief Base class for writer components to store data in a ROOT file
26 #include "AliHLTReadoutListDumpComponent.h"
27 #include "AliHLTTriggerDecision.h"
28 #include "AliHLTCTPData.h"
35 /** ROOT macro for the implementation of ROOT specific class methods */
36 ClassImp(AliHLTReadoutListDumpComponent)
38 AliHLTReadoutListDumpComponent::AliHLTReadoutListDumpComponent()
40 , fMode(AliHLTReadoutListDumpComponent::kModeBinaryList)
44 // see header file for class documentation
46 // refer to README to build package
48 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
51 AliHLTReadoutListDumpComponent::~AliHLTReadoutListDumpComponent()
53 // see header file for class documentation
56 int AliHLTReadoutListDumpComponent::InitWriter()
58 // see header file for class documentation
60 fBitsHisto=CreateReadoutListHistogram();
61 fBitsVsCTP=CreateReadoutListVsCTPHistogram();
62 if (!fBitsHisto || !fBitsVsCTP) return -ENOMEM;
67 int AliHLTReadoutListDumpComponent::CloseWriter()
69 // see header file for class documentation
70 TString filename=GetDirectory();
71 if (!filename.IsNull() && !filename.EndsWith("/")) filename+="/";
72 filename+=fBitsHisto->GetName();
77 TFile out(filename, "RECREATE");
89 int AliHLTReadoutListDumpComponent::DumpEvent( const AliHLTComponentEventData& /*evtData*/,
90 const AliHLTComponentBlockData* /*blocks*/,
91 AliHLTComponentTriggerData& trigData )
93 // see header file for class documentation
95 if (!IsDataEvent()) return 0;
97 if (fMode==AliHLTReadoutListDumpComponent::kModeBinaryList) {
98 const AliHLTComponentDataType hltrdlstdt=AliHLTComponentDataTypeInitializer("HLTRDLST", "HLT ");
99 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock();
100 pBlock && iResult>=0;
101 pBlock=GetNextInputBlock()) {
102 if (pBlock->fDataType!=hltrdlstdt) continue;
103 if (pBlock->fSize==sizeof(AliHLTEventDDL) or pBlock->fSize==sizeof(AliHLTEventDDLV0)) {
104 HLTDebug("Filling histograms from binary buffer");
105 AliHLTReadoutList readoutlist(*reinterpret_cast<AliHLTEventDDL*>(pBlock->fPtr));
106 FillReadoutListHistogram(fBitsHisto, &readoutlist);
107 FillReadoutListVsCTP(fBitsVsCTP, &readoutlist, &trigData);
109 HLTError("HLTRDLST size missmatch: %d, expected %d or %d", pBlock->fSize, sizeof(AliHLTEventDDL), sizeof(AliHLTEventDDLV0));
112 } else if (fMode==AliHLTReadoutListDumpComponent::kModeHLTDecision) {
113 for (const TObject* pObject=GetFirstInputObject();
114 pObject && iResult>=0;
115 pObject=GetNextInputObject()) {
116 const AliHLTTriggerDecision* pDecision=dynamic_cast<const AliHLTTriggerDecision*>(pObject);
117 if (!pDecision) continue;
119 AliHLTReadoutList list=pDecision->ReadoutList();
120 HLTDebug("Filling histograms from HLT decision object");
121 FillReadoutListHistogram(fBitsHisto, &list);
122 FillReadoutListVsCTP(fBitsVsCTP, &list, &trigData);
125 HLTError("invalid mode %d", fMode);
131 int AliHLTReadoutListDumpComponent::ScanArgument(int argc, const char** argv)
133 // see header file for class documentation
135 if (argc<=0) return 0;
137 TString argument=argv[i];
140 if (argument.CompareTo("-binary")==0) {
141 fMode=AliHLTReadoutListDumpComponent::kModeBinaryList;
146 if (argument.CompareTo("-decision")==0) {
147 fMode=AliHLTReadoutListDumpComponent::kModeHLTDecision;
154 TH1I* AliHLTReadoutListDumpComponent::CreateReadoutListHistogram()
156 // see header file for class documentation
157 int bins=gkAliHLTDDLListSize*sizeof(AliHLTUInt32_t)*8;
158 TH1I* histo=new TH1I("HLTRDLST","HLT readout list", bins, 0, bins);
162 TH2I* AliHLTReadoutListDumpComponent::CreateReadoutListVsCTPHistogram()
164 // see header file for class documentation
165 int bins=gkAliHLTDDLListSize*sizeof(AliHLTUInt32_t)*8;
166 TH2I* histo=new TH2I("HLTRDLSTvsCTP","HLT readout list vs. CTP trigger", bins, 0, bins, gkNCTPTriggerClasses, 0, gkNCTPTriggerClasses);
170 int AliHLTReadoutListDumpComponent::FillReadoutListHistogram(TH1I* histo, const AliHLTReadoutList* list)
172 // see header file for class documentation
173 if (!histo || !list) return -EINVAL;
174 if (list->BufferSize()!=sizeof(AliHLTEventDDL)) return -EBADF;
175 if (list->Buffer()->fCount!=(unsigned)gkAliHLTDDLListSize) return -EBADF;
177 for (int word=0; word<gkAliHLTDDLListSize; word++) {
178 for (unsigned bit=0; bit<sizeof(AliHLTUInt32_t)*8; bit++) {
179 if (list->Buffer()->fList[word]&0x1<<bit) histo->Fill(word*sizeof(AliHLTUInt32_t)*8+bit);
186 int AliHLTReadoutListDumpComponent::FillReadoutListVsCTP(TH2I* histo, const AliHLTReadoutList* list, const AliHLTComponentTriggerData* trigData)
188 // see header file for class documentation
189 if (!histo || !list || !trigData) return -EINVAL;
190 if (list->BufferSize()!=sizeof(AliHLTEventDDL)) return -EBADF;
191 if (list->Buffer()->fCount!=(unsigned)gkAliHLTDDLListSize) return -EBADF;
193 AliHLTUInt64_t triggerMask=AliHLTCTPData::ActiveTriggers(*trigData);
194 AliHLTUInt64_t bit0=0x1;
195 for (int word=0; word<gkAliHLTDDLListSize; word++) {
196 for (unsigned bit=0; bit<sizeof(AliHLTUInt32_t)*8; bit++) {
197 if (list->Buffer()->fList[word]&0x1<<bit) {
198 for (int trigger=0; trigger<gkNCTPTriggerClasses; trigger++) {
199 if ((triggerMask&(bit0<<trigger))!=0) {
200 histo->Fill(word*sizeof(AliHLTUInt32_t)*8+bit, trigger);