]>
Commit | Line | Data |
---|---|---|
b9f1d917 | 1 | //-*- Mode: C++ -*- |
2 | // $Id: AliHLTAnaManagerComponent.cxx $ | |
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: David Rohr, Jens Wiechula, C. Zampolli * | |
8 | * * | |
9 | * Permission to use, copy, modify and distribute this software and its * | |
10 | * documentation strictly for non-commercial purposes is hereby granted * | |
11 | * without fee, provided that the above copyright notice appears in all * | |
12 | * copies and that both the copyright notice and this permission notice * | |
13 | * appear in the supporting documentation. The authors make no claims * | |
14 | * about the suitability of this software for any purpose. It is * | |
15 | * provided "as is" without express or implied warranty. * | |
16 | **************************************************************************/ | |
17 | ||
18 | /** @file AliHLTAnaManagerComponent.cxx | |
19 | @author David Rohr, Jens Wiechula, C. Zampolli | |
20 | @brief Component for Testing Analysis Manager inside HLT component | |
21 | */ | |
22 | ||
23 | #include "TMap.h" | |
24 | #include "TSystem.h" | |
25 | #include "TTimeStamp.h" | |
26 | #include "TObjString.h" | |
27 | #include "TH1F.h" | |
28 | #include "TList.h" | |
29 | #include "AliESDtrackCuts.h" | |
afdb0e0d | 30 | #include "AliESDEvent.h" |
b9f1d917 | 31 | #include "AliHLTErrorGuard.h" |
32 | #include "AliHLTDataTypes.h" | |
33 | #include "AliHLTAnaManagerComponent.h" | |
34 | #include "AliHLTITSClusterDataFormat.h" | |
35 | #include "AliAnalysisManager.h" | |
36 | #include "AliHLTTestInputHandler.h" | |
37 | #include "AliAnalysisTaskPt.h" | |
38 | #include "AliAnalysisDataContainer.h" | |
39 | #include "TTree.h" | |
40 | ||
41 | using namespace std; | |
42 | ||
43 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
44 | ClassImp(AliHLTAnaManagerComponent) | |
45 | ||
46 | /* | |
47 | * --------------------------------------------------------------------------------- | |
48 | * Constructor / Destructor | |
49 | * --------------------------------------------------------------------------------- | |
50 | */ | |
51 | ||
52 | // ################################################################################# | |
53 | AliHLTAnaManagerComponent::AliHLTAnaManagerComponent() : | |
54 | AliHLTProcessor(), | |
55 | fUID(0), | |
56 | fAnalysisManager(NULL), | |
afdb0e0d | 57 | fInputHandler(NULL){ |
b9f1d917 | 58 | // an example component which implements the ALICE HLT processor |
59 | // interface and does some analysis on the input raw data | |
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 | // NOTE: all helper classes should be instantiated in DoInit() | |
68 | } | |
69 | ||
70 | // ################################################################################# | |
71 | AliHLTAnaManagerComponent::~AliHLTAnaManagerComponent() { | |
72 | // see header file for class documentation | |
73 | } | |
74 | ||
75 | /* | |
76 | * --------------------------------------------------------------------------------- | |
77 | * Public functions to implement AliHLTComponent's interface. | |
78 | * These functions are required for the registration process | |
79 | * --------------------------------------------------------------------------------- | |
80 | */ | |
81 | ||
82 | // ################################################################################# | |
83 | const Char_t* AliHLTAnaManagerComponent::GetComponentID() { | |
84 | // see header file for class documentation | |
85 | return "AnaManagerComponent"; | |
86 | } | |
87 | ||
88 | // ################################################################################# | |
89 | void AliHLTAnaManagerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { | |
90 | // see header file for class documentation | |
91 | list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginAny); | |
92 | list.push_back(kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD); | |
93 | list.push_back(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO); | |
94 | } | |
95 | ||
96 | // ################################################################################# | |
97 | AliHLTComponentDataType AliHLTAnaManagerComponent::GetOutputDataType() { | |
98 | // see header file for class documentation | |
99 | return kAliHLTDataTypeTObject|kAliHLTDataOriginHLT; | |
100 | } | |
101 | ||
102 | // ################################################################################# | |
103 | void AliHLTAnaManagerComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) { | |
104 | // see header file for class documentation | |
105 | constBase = 100000; | |
106 | inputMultiplier = 0.5; | |
107 | } | |
108 | ||
109 | // ################################################################################# | |
110 | void AliHLTAnaManagerComponent::GetOCDBObjectDescription( TMap* const targetMap) { | |
111 | // see header file for class documentation | |
112 | ||
113 | if (!targetMap) return; | |
114 | targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelations"), | |
115 | new TObjString("configuration object")); | |
116 | targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelationsCentrality"), | |
117 | new TObjString("centrality configuration object")); | |
118 | ||
119 | return; | |
120 | } | |
121 | ||
122 | // ################################################################################# | |
123 | AliHLTComponent* AliHLTAnaManagerComponent::Spawn() { | |
124 | // see header file for class documentation | |
125 | return new AliHLTAnaManagerComponent; | |
126 | } | |
127 | ||
128 | /* | |
129 | * --------------------------------------------------------------------------------- | |
130 | * Protected functions to implement AliHLTComponent's interface. | |
131 | * These functions provide initialization as well as the actual processing | |
132 | * capabilities of the component. | |
133 | * --------------------------------------------------------------------------------- | |
134 | */ | |
135 | ||
136 | // ################################################################################# | |
afdb0e0d | 137 | Int_t AliHLTAnaManagerComponent::DoInit( Int_t /*argc*/, const Char_t** /*argv*/ ) { |
b9f1d917 | 138 | // see header file for class documentation |
139 | printf("AliHLTAnaManagerComponent::DoInit\n"); | |
140 | ||
141 | Int_t iResult=0; | |
142 | ||
afdb0e0d | 143 | Printf("----> AliHLTAnaManagerComponent::DoInit"); |
b9f1d917 | 144 | fAnalysisManager = new AliAnalysisManager; |
145 | fInputHandler = new AliHLTTestInputHandler; | |
146 | fAnalysisManager->SetInputEventHandler(fInputHandler); | |
147 | fAnalysisManager->SetExternalLoop(kTRUE); | |
148 | ||
149 | AliAnalysisTaskPt *task = new AliAnalysisTaskPt("TaskPt"); | |
150 | fAnalysisManager->AddTask(task); | |
151 | AliAnalysisDataContainer *cinput = fAnalysisManager->GetCommonInputContainer(); | |
152 | Printf("Defining output file"); | |
153 | AliAnalysisDataContainer *coutput1 = fAnalysisManager->CreateContainer("pt", TH1::Class(), | |
154 | AliAnalysisManager::kOutputContainer, "Pt.ESD.root"); | |
155 | ||
156 | // connect containers | |
afdb0e0d | 157 | Printf("---> Connecting input..."); |
158 | fAnalysisManager->ConnectInput (task, 0, cinput ); | |
159 | Printf("---> ...connected."); | |
b9f1d917 | 160 | Printf("---> Connecting output..."); |
161 | fAnalysisManager->ConnectOutput (task, 0, coutput1); | |
162 | Printf("---> ...connected."); | |
163 | ||
afdb0e0d | 164 | Printf("----> Calling InitAnalysis"); |
b9f1d917 | 165 | fAnalysisManager->InitAnalysis(); |
afdb0e0d | 166 | Printf("----> Done."); |
167 | Printf("----> Calling StartAnalysis"); | |
b9f1d917 | 168 | fAnalysisManager->StartAnalysis("local", (TTree*)new TTree); |
afdb0e0d | 169 | //fAnalysisManager->StartAnalysis("local", (TTree*)NULL); |
170 | Printf("----> Done."); | |
b9f1d917 | 171 | |
172 | return iResult; | |
173 | } | |
174 | ||
175 | ||
176 | ||
177 | // ################################################################################# | |
178 | Int_t AliHLTAnaManagerComponent::DoDeinit() { | |
179 | // see header file for class documentation | |
180 | ||
181 | fUID = 0; | |
182 | fAnalysisManager->SetSkipTerminate(kTRUE); | |
183 | fAnalysisManager->Terminate(); | |
184 | ||
185 | delete fAnalysisManager; | |
186 | ||
187 | return 0; | |
188 | } | |
189 | ||
190 | // ################################################################################# | |
191 | Int_t AliHLTAnaManagerComponent::DoEvent(const AliHLTComponentEventData& evtData, | |
192 | AliHLTComponentTriggerData& /*trigData*/) { | |
193 | // see header file for class documentation | |
194 | ||
195 | printf("AliHLTAnaManagerComponent::DoEvent\n"); | |
196 | Int_t iResult=0; | |
197 | ||
198 | // -- Only use data event | |
199 | if (!IsDataEvent()) | |
200 | return 0; | |
201 | ||
202 | if( fUID == 0 ){ | |
203 | TTimeStamp t; | |
204 | fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID; | |
205 | } | |
206 | ||
207 | // -- Get ESD object | |
208 | // ------------------- | |
209 | AliESDEvent *esdEvent = NULL; | |
210 | for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) { | |
211 | esdEvent = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) ); | |
212 | if( !esdEvent ){ | |
213 | HLTWarning("Wrong ESDEvent object received"); | |
214 | iResult = -1; | |
215 | continue; | |
216 | } | |
217 | esdEvent->GetStdContent(); | |
218 | } | |
afdb0e0d | 219 | printf("----> ESDEvent %p has %d tracks: \n", esdEvent, esdEvent->GetNumberOfTracks()); |
b9f1d917 | 220 | |
afdb0e0d | 221 | fAnalysisManager->InitInpuData(esdEvent); |
222 | // fInputHandler->BeginEvent(0); | |
b9f1d917 | 223 | fAnalysisManager->ExecAnalysis(); |
224 | fInputHandler->FinishEvent(); | |
225 | ||
226 | ||
227 | // -- Send histlist | |
228 | // PushBack(dynamic_cast<TObject*>(fCorrObj->GetHistList()), | |
229 | // kAliHLTDataTypeTObject|kAliHLTDataOriginHLT,fUID); | |
230 | ||
231 | return iResult; | |
232 | } | |
233 | ||
234 | // ################################################################################# | |
235 | Int_t AliHLTAnaManagerComponent::Reconfigure(const Char_t* cdbEntry, const Char_t* chainId) { | |
236 | // see header file for class documentation | |
237 | ||
238 | Int_t iResult=0; | |
239 | TString cdbPath; | |
240 | if (cdbEntry) { | |
241 | cdbPath=cdbEntry; | |
242 | } else { | |
243 | cdbPath="HLT/ConfigGlobal/"; | |
244 | cdbPath+=GetComponentID(); | |
245 | } | |
246 | ||
247 | AliInfoClass(Form("reconfigure '%s' from entry %s%s", chainId, cdbPath.Data(), cdbEntry?"":" (default)")); | |
248 | iResult=ConfigureFromCDBTObjString(cdbPath); | |
249 | ||
250 | return iResult; | |
251 | } | |
252 | ||
253 | // ################################################################################# | |
254 | Int_t AliHLTAnaManagerComponent::ReadPreprocessorValues(const Char_t* /*modules*/) { | |
255 | // see header file for class documentation | |
256 | ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component"); | |
257 | return 0; | |
258 | } | |
259 |