]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/util/AliHLTAgentUtil.cxx
update of the CompStatCollector component to handle more complex chains
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTAgentUtil.cxx
1 // $Id$
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8  *                  for The ALICE HLT Project.                            *
9  *                                                                        *
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  **************************************************************************/
18
19 /** @file   AliHLTAgentUtil.cxx
20     @author Matthias Richter
21     @date   
22     @brief  Agent of the libAliHLTUtil library
23 */
24
25 #include <cassert>
26 #include "AliHLTAgentUtil.h"
27 #include "AliHLTOUTHandlerChain.h"
28
29 // header files of library components
30 #include "AliHLTDataGenerator.h"
31 #include "AliHLTRawReaderPublisherComponent.h"
32 #include "AliHLTLoaderPublisherComponent.h"
33 #include "AliHLTRootFileStreamerComponent.h"
34 #include "AliHLTRootFileWriterComponent.h"
35 #include "AliHLTRootFilePublisherComponent.h"
36 #include "AliHLTRootSchemaEvolutionComponent.h"
37 #include "AliHLTRecoParamComponent.h"
38 //#include "AliHLTMCGeneratorComponent.h"
39 #include "AliHLTESDMCEventPublisherComponent.h"
40 #include "AliHLTFileWriter.h"
41 #include "AliHLTFilePublisher.h"
42 #include "AliHLTBlockFilterComponent.h"
43 #include "AliHLTMonitoringRelay.h"
44 #include "AliHLTEsdCollectorComponent.h"
45 #include "AliHLTReadoutListDumpComponent.h"
46 #include "AliHLTOUTPublisherComponent.h"
47 #include "AliHLTCompStatCollector.h"
48 #include "AliHLTCorruptorComponent.h"
49
50 /** global instance for agent registration */
51 AliHLTAgentUtil gAliHLTAgentUtil;
52
53 /** ROOT macro for the implementation of ROOT specific class methods */
54 ClassImp(AliHLTAgentUtil)
55
56 AliHLTAgentUtil::AliHLTAgentUtil()
57   : AliHLTModuleAgent("Util")
58   , fCompStatDataHandler(NULL)
59   , fStreamerInfoDataHandler(NULL)
60 {
61   // see header file for class documentation
62   // or
63   // refer to README to build package
64   // or
65   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
66 }
67
68 AliHLTAgentUtil::~AliHLTAgentUtil()
69 {
70   // see header file for class documentation
71 }
72
73 int AliHLTAgentUtil::CreateConfigurations(AliHLTConfigurationHandler* handler,
74                                           AliRawReader* /*rawReader*/,
75                                           AliRunLoader* /*runloader*/) const
76 {
77   // see header file for class documentation
78   if (!handler) return 0;
79
80   /////////////////////////////////////////////////////////////////////////////////////
81   //
82   // a kChain HLTOUT configuration for processing of {'COMPSTAT':'PRIV'} data blocks
83   // produces a TTree object of the component statistics and writes it to disc
84
85   // publisher component
86   handler->CreateConfiguration("UTIL-hltout-compstat-publisher", "AliHLTOUTPublisher"   , NULL, "-disable-component-stat");
87
88   // collector configuration
89   handler->CreateConfiguration("UTIL-compstat-converter", "StatisticsCollector", "UTIL-hltout-compstat-publisher", "-disable-component-stat");
90
91   // writer configuration
92   handler->CreateConfiguration("UTIL-compstat-writer", "ROOTFileWriter", "UTIL-compstat-converter", "-datafile HLT.statistics.root -concatenate-events -overwrite");
93
94   return 0;
95 }
96
97 const char* AliHLTAgentUtil::GetReconstructionChains(AliRawReader* /*rawReader*/,
98                                                      AliRunLoader* /*runloader*/) const
99 {
100   // see header file for class documentation
101   return NULL;
102 }
103
104 const char* AliHLTAgentUtil::GetRequiredComponentLibraries() const
105 {
106   // see header file for class documentation
107   return NULL;
108 }
109
110 int AliHLTAgentUtil::RegisterComponents(AliHLTComponentHandler* pHandler) const
111 {
112   // see header file for class documentation
113   assert(pHandler);
114   if (!pHandler) return -EINVAL;
115   pHandler->AddComponent(new AliHLTDataGenerator);
116   pHandler->AddComponent(new AliHLTRawReaderPublisherComponent);
117   pHandler->AddComponent(new AliHLTLoaderPublisherComponent);
118   pHandler->AddComponent(new AliHLTRootFileStreamerComponent);
119   pHandler->AddComponent(new AliHLTRootFileWriterComponent);
120   pHandler->AddComponent(new AliHLTRootFilePublisherComponent);
121   pHandler->AddComponent(new AliHLTRootSchemaEvolutionComponent);
122   pHandler->AddComponent(new AliHLTRecoParamComponent);
123   //  pHandler->AddComponent(new AliHLTMCGeneratorComponent);
124   pHandler->AddComponent(new AliHLTESDMCEventPublisherComponent);
125   pHandler->AddComponent(new AliHLTFileWriter);
126   pHandler->AddComponent(new AliHLTFilePublisher);
127   pHandler->AddComponent(new AliHLTBlockFilterComponent);
128   pHandler->AddComponent(new AliHLTMonitoringRelay);
129   pHandler->AddComponent(new AliHLTEsdCollectorComponent);
130   pHandler->AddComponent(new AliHLTReadoutListDumpComponent);
131   pHandler->AddComponent(new AliHLTOUTPublisherComponent);
132   pHandler->AddComponent(new AliHLTCompStatCollector);
133   pHandler->AddComponent(new AliHLTCorruptorComponent);
134   return 0;
135 }
136
137 int AliHLTAgentUtil::GetHandlerDescription(AliHLTComponentDataType dt,
138                                            AliHLTUInt32_t /*spec*/,
139                                            AliHLTOUTHandlerDesc& desc) const
140 {
141   // see header file for class documentation
142
143   // handler for the component statistics data blocks {'COMPSTAT':'PRIV'}
144   if (dt==kAliHLTDataTypeComponentStatistics ||
145       dt==kAliHLTDataTypeComponentTable) {
146       desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
147       return 1;
148   }
149
150   // handler for the component statistics data blocks {'ROOTSTRI':'HLT '}
151   if (dt==kAliHLTDataTypeStreamerInfo) {
152       desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
153       return 1;
154   }
155   return 0;
156 }
157
158 AliHLTOUTHandler* AliHLTAgentUtil::GetOutputHandler(AliHLTComponentDataType dt,
159                                                    AliHLTUInt32_t /*spec*/)
160 {
161   // see header file for class documentation
162
163   // handler for the component statistics data blocks {'COMPSTAT':'PRIV'}
164   if (dt==kAliHLTDataTypeComponentStatistics ||
165       dt==kAliHLTDataTypeComponentTable) {
166     if (fCompStatDataHandler==NULL)
167       fCompStatDataHandler=new AliHLTOUTHandlerChain("chains=UTIL-compstat-writer");
168     return fCompStatDataHandler;
169   }
170
171   // handler for the component statistics data blocks {'ROOTSTRI':'HLT '}
172   if (dt==kAliHLTDataTypeStreamerInfo) {
173     if (fStreamerInfoDataHandler==NULL)
174       fStreamerInfoDataHandler=new AliHLTStreamerInfoHandler;
175     return fStreamerInfoDataHandler;
176   }
177
178   return NULL;
179 }
180
181 int AliHLTAgentUtil::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
182 {
183   // see header file for class documentation
184   if (pInstance==NULL) return -EINVAL;
185
186   if (pInstance==fCompStatDataHandler) {
187     delete fCompStatDataHandler;
188     fCompStatDataHandler=NULL;
189   }
190
191   if (pInstance==fStreamerInfoDataHandler) {
192     delete fStreamerInfoDataHandler;
193     fStreamerInfoDataHandler=NULL;
194   }
195   return 0;
196 }