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