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 AliHLTMonitoringRelay.cxx
20 @author Matthias Richter
22 @brief Relay components for monitoring objects.
27 #include "AliHLTMonitoringRelay.h"
28 #include "AliHLTMessage.h"
32 /** ROOT macro for the implementation of ROOT specific class methods */
33 ClassImp(AliHLTMonitoringRelay)
35 AliHLTMonitoringRelay::AliHLTMonitoringRelay()
40 // see header file for class documentation
42 // refer to README to build package
44 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
47 AliHLTMonitoringRelay::~AliHLTMonitoringRelay()
49 // see header file for class documentation
52 void AliHLTMonitoringRelay::GetInputDataTypes(AliHLTComponentDataTypeList& list)
54 // see header file for class documentation
56 list.push_back(kAliHLTAnyDataType);
59 AliHLTComponentDataType AliHLTMonitoringRelay::GetOutputDataType()
61 // see header file for class documentation
62 return kAliHLTAnyDataType;
65 void AliHLTMonitoringRelay::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
67 // see header file for class documentation
68 constBase=fOutputSize;
72 int AliHLTMonitoringRelay::DoInit( int argc, const char** argv )
74 // see header file for class documentation
78 iResult=ConfigureFromArgumentString(argc, argv);
83 int AliHLTMonitoringRelay::ScanConfigurationArgument(int argc, const char** argv)
85 // see header file for class documentation
86 if (argc<=0) return 0;
88 TString argument=argv[i];
91 if (argument.CompareTo("-verbose")==0) {
99 int AliHLTMonitoringRelay::DoDeinit()
101 // see header file for class documentation
103 AliHLTMonitoringItemPList::iterator element=fItems.begin();
104 while (element!=fItems.end()) {
105 AliHLTMonitoringItem* pItem=*element;
106 element=fItems.erase(element);
114 int AliHLTMonitoringRelay::DoEvent(const AliHLTComponentEventData& /*evtData*/,
115 AliHLTComponentTriggerData& /*trigData*/)
117 // see header file for class documentation
119 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock();
121 pBlock=GetNextInputBlock()) {
122 TObject* pObject=AliHLTMessage::Extract(pBlock->fPtr, pBlock->fSize);
123 if (!pObject) continue; // consider only TObjects
125 AliHLTMonitoringItem* pItem=FindItem(pBlock, pObject);
127 HLTInfo("found block %s 0x%0lx %s %s", DataType2Text(pItem->GetDataType()).c_str(), pItem->GetSpecification(), pObject->GetName(), pObject->GetName());
128 if (pItem->GetSize()<pBlock->fSize) {
129 // update with the new maximum
130 assert(fOutputSize>=pItem->GetSize());
131 fOutputSize-=pItem->GetSize();
132 fOutputSize+=pBlock->fSize;
134 pItem->SetData(pBlock->fPtr, pBlock->fSize);
135 HLTInfo("setting item size %d, total size %d", pItem->GetSize(), fOutputSize);
137 pItem=new AliHLTMonitoringItem(pBlock, pObject);
138 fItems.push_back(pItem);
139 fOutputSize+=pBlock->fSize;
140 HLTInfo("new item size %d (%d), %s 0x%0lx %s %s", pItem->GetSize(), fOutputSize, DataType2Text(pItem->GetDataType()).c_str(), pItem->GetSpecification(), pObject->GetName(), pObject->GetName());
145 for (AliHLTMonitoringItemPList::iterator element=fItems.begin();
146 element!=fItems.end(); element++) {
147 AliHLTMonitoringItem* pItem=*element;
149 HLTInfo("push back item size %d (%d), %s 0x%0lx", pItem->GetSize(), fOutputSize, DataType2Text(pItem->GetDataType()).c_str(), pItem->GetSpecification());
150 PushBack(pItem->GetBuffer(), pItem->GetSize(), pItem->GetDataType(), pItem->GetSpecification());
157 AliHLTMonitoringRelay::AliHLTMonitoringItem* AliHLTMonitoringRelay::FindItem(const AliHLTComponentBlockData* pBlock, const TObject* pObject) const
159 // find an item by data type, specification, name and title
160 for (unsigned i=0; i<fItems.size(); i++) {
161 AliHLTMonitoringItem* pItem=fItems[i];
163 (*pItem)==(*pBlock) &&
164 (pObject==NULL || (*pItem)==(*pObject))) {
171 AliHLTMonitoringRelay::AliHLTMonitoringItem::AliHLTMonitoringItem()
172 : fDt(kAliHLTVoidDataType)
173 , fSpecification(kAliHLTVoidDataSpec)
179 // standard constructor
182 AliHLTMonitoringRelay::AliHLTMonitoringItem::AliHLTMonitoringItem(const AliHLTComponentBlockData* pBlock, const TObject* pObject)
183 : fDt(kAliHLTVoidDataType)
184 , fSpecification(kAliHLTVoidDataSpec)
192 fDt=pBlock->fDataType;
193 fSpecification=pBlock->fSpecification;
195 fData->Set(pBlock->fSize, reinterpret_cast<const Char_t*>(pBlock->fPtr));
196 fDataSize=pBlock->fSize;
200 fName=pObject->GetName();
201 fTitle=pObject->GetTitle();
205 AliHLTMonitoringRelay::AliHLTMonitoringItem::~AliHLTMonitoringItem()
208 if (fData) delete fData;
211 int AliHLTMonitoringRelay::AliHLTMonitoringItem::SetData(void* pBuffer, int size)
213 // copy the data buffer
215 fData=new TArrayC(size, reinterpret_cast<const Char_t*>(pBuffer));
217 if (fData->GetSize()<size) {
218 fData->Set(size, reinterpret_cast<const Char_t*>(pBuffer));
220 memcpy(fData->GetArray(), pBuffer, size);
232 void* AliHLTMonitoringRelay::AliHLTMonitoringItem::GetBuffer() const
234 // get buffer pointer of the current data
235 return fData!=NULL?fData->GetArray():NULL;
238 unsigned AliHLTMonitoringRelay::AliHLTMonitoringItem::GetSize() const
240 // get size of the current data
244 const AliHLTComponentDataType& AliHLTMonitoringRelay::AliHLTMonitoringItem::GetDataType() const
250 AliHLTUInt32_t AliHLTMonitoringRelay::AliHLTMonitoringItem::GetSpecification() const
253 return fSpecification;
256 bool AliHLTMonitoringRelay::AliHLTMonitoringItem::operator==(const AliHLTComponentBlockData& bd) const
258 // equal to data type and specification
259 if (bd.fDataType!=fDt) return false;
260 if (bd.fSpecification!=fSpecification) return false;
264 bool AliHLTMonitoringRelay::AliHLTMonitoringItem::operator!=(const AliHLTComponentBlockData& bd) const
266 // not equal to data type and specification
267 return not operator==(bd);
270 bool AliHLTMonitoringRelay::AliHLTMonitoringItem::operator==(const TObject& object) const
272 // equal to name and title
273 if (fName.CompareTo(object.GetName())!=0) return false;
274 if (!fTitle.IsNull() && fTitle.CompareTo(object.GetTitle())!=0) return false;
278 bool AliHLTMonitoringRelay::AliHLTMonitoringItem::operator!=(const TObject& object) const
280 // not equal to name and title
281 return not operator==(object);