]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/SampleLib/AliHLTAgentSample.cxx
added monitoring example component and macro
[u/mrichter/AliRoot.git] / HLT / SampleLib / AliHLTAgentSample.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   AliHLTAgentSample.cxx
20     @author Matthias Richter
21     @date   
22     @brief  Agent of the libAliHLTSample library
23 */
24
25 #include <cassert>
26 #include "AliHLTAgentSample.h"
27 #include "AliHLTConfiguration.h"
28 #include "TSystem.h"
29
30 // header files of library components
31 #include "AliHLTDummyComponent.h"
32 #include "AliHLTSampleComponent1.h"
33 #include "AliHLTSampleComponent2.h"
34 #include "AliHLTSampleMonitoringComponent.h"
35
36 // header file of the module preprocessor
37 #include "AliHLTSamplePreprocessor.h"
38
39 /** global instance for agent registration */
40 AliHLTAgentSample gAliHLTAgentSample;
41
42 const char* AliHLTAgentSample::fgkAliHLTAgentSampleData="/tmp/testdata";
43 const char* AliHLTAgentSample::fgkAliHLTAgentSampleOut="/tmp/hltout";
44
45 /** ROOT macro for the implementation of ROOT specific class methods */
46 ClassImp(AliHLTAgentSample)
47
48 AliHLTAgentSample::AliHLTAgentSample()
49   :
50   AliHLTModuleAgent("Sample")
51 {
52   // see header file for class documentation
53   // or
54   // refer to README to build package
55   // or
56   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
57 }
58
59 AliHLTAgentSample::~AliHLTAgentSample()
60 {
61   // see header file for class documentation
62
63   // delete the test data
64   ofstream dump(fgkAliHLTAgentSampleData, ios::in);
65   if (dump.good()) {
66     TString arg("rm -f ");
67     arg+=fgkAliHLTAgentSampleData;
68     gSystem->Exec(arg.Data());
69   }
70 }
71
72 int AliHLTAgentSample::CreateConfigurations(AliHLTConfigurationHandler* handler,
73                                             AliRawReader* /*rawReader*/,
74                                             AliRunLoader* /*runloader*/) const
75 {
76   // see header file for class documentation
77
78   // create some test data
79   ofstream dump(fgkAliHLTAgentSampleData, (ios::openmode)0);
80   dump << "This is just some test data for the ALICE HLT analysis example";
81   dump << "---- not copied" << endl;
82   dump.close();
83
84   if (handler) {
85     // the publisher configuration for the test data
86     TString arg("-datatype DUMMYDAT TEST -datafile ");
87     arg+=fgkAliHLTAgentSampleData;
88     HLTDebug(arg.Data());
89     handler->CreateConfiguration("sample-fp1"  , "FilePublisher", NULL , arg.Data());
90
91     // the configuration for the dummy component
92     handler->CreateConfiguration("sample-cp"   , "Dummy"        , "sample-fp1", "output_percentage 80");
93
94     // the writer configuration
95     arg="-datafile "; arg+=fgkAliHLTAgentSampleOut;
96     handler->CreateConfiguration("sample-sink1", "FileWriter"   , "sample-cp" , arg.Data());
97
98     // sample offline source
99     handler->CreateConfiguration("sample-offsrc", "AliLoaderPublisher"   , NULL , "-loader TPCLoader -tree digits -verbose");
100
101     // sample offline sink
102     handler->CreateConfiguration("sample-offsnk", "SampleOfflineDataSink"   , "sample-offsrc" , NULL);
103   }
104   return 0;
105 }
106
107 const char* AliHLTAgentSample::GetReconstructionChains(AliRawReader* /*rawReader*/,
108                                                        AliRunLoader* /*runloader*/) const
109 {
110   // see header file for class documentation
111   return "sample-sink1 sample-offsnk";
112 }
113
114 const char* AliHLTAgentSample::GetRequiredComponentLibraries() const
115 {
116   // see header file for class documentation
117   return "libAliHLTUtil.so libAliHLTSample.so";
118 }
119
120 int AliHLTAgentSample::RegisterComponents(AliHLTComponentHandler* pHandler) const
121 {
122   // see header file for class documentation
123   assert(pHandler);
124   if (!pHandler) return -EINVAL;
125   pHandler->AddComponent(new AliHLTDummyComponent);
126   pHandler->AddComponent(new AliHLTSampleComponent1);
127   pHandler->AddComponent(new AliHLTSampleComponent2);
128   pHandler->AddComponent(new AliHLTSampleMonitoringComponent);
129
130   return 0;
131 }
132
133 AliHLTModulePreprocessor* AliHLTAgentSample::GetPreprocessor()
134 {
135   // see header file for class documentation
136   return new AliHLTSamplePreprocessor;
137 }