]>
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); | |
949fa831 | 94 | list.push_back(kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginAny); |
b9f1d917 | 95 | } |
96 | ||
97 | // ################################################################################# | |
98 | AliHLTComponentDataType AliHLTAnaManagerComponent::GetOutputDataType() { | |
99 | // see header file for class documentation | |
100 | return kAliHLTDataTypeTObject|kAliHLTDataOriginHLT; | |
101 | } | |
102 | ||
103 | // ################################################################################# | |
104 | void AliHLTAnaManagerComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) { | |
105 | // see header file for class documentation | |
106 | constBase = 100000; | |
107 | inputMultiplier = 0.5; | |
108 | } | |
109 | ||
110 | // ################################################################################# | |
111 | void AliHLTAnaManagerComponent::GetOCDBObjectDescription( TMap* const targetMap) { | |
112 | // see header file for class documentation | |
113 | ||
114 | if (!targetMap) return; | |
949fa831 | 115 | /* targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelations"), |
b9f1d917 | 116 | new TObjString("configuration object")); |
117 | targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelationsCentrality"), | |
118 | new TObjString("centrality configuration object")); | |
949fa831 | 119 | */ |
b9f1d917 | 120 | return; |
121 | } | |
122 | ||
123 | // ################################################################################# | |
124 | AliHLTComponent* AliHLTAnaManagerComponent::Spawn() { | |
125 | // see header file for class documentation | |
126 | return new AliHLTAnaManagerComponent; | |
127 | } | |
128 | ||
129 | /* | |
130 | * --------------------------------------------------------------------------------- | |
131 | * Protected functions to implement AliHLTComponent's interface. | |
132 | * These functions provide initialization as well as the actual processing | |
133 | * capabilities of the component. | |
134 | * --------------------------------------------------------------------------------- | |
135 | */ | |
136 | ||
137 | // ################################################################################# | |
afdb0e0d | 138 | Int_t AliHLTAnaManagerComponent::DoInit( Int_t /*argc*/, const Char_t** /*argv*/ ) { |
b9f1d917 | 139 | // see header file for class documentation |
140 | printf("AliHLTAnaManagerComponent::DoInit\n"); | |
141 | ||
142 | Int_t iResult=0; | |
143 | ||
afdb0e0d | 144 | Printf("----> AliHLTAnaManagerComponent::DoInit"); |
b9f1d917 | 145 | fAnalysisManager = new AliAnalysisManager; |
146 | fInputHandler = new AliHLTTestInputHandler; | |
147 | fAnalysisManager->SetInputEventHandler(fInputHandler); | |
148 | fAnalysisManager->SetExternalLoop(kTRUE); | |
149 | ||
150 | AliAnalysisTaskPt *task = new AliAnalysisTaskPt("TaskPt"); | |
828c4c08 | 151 | task->SetUseFriends(kTRUE); |
b9f1d917 | 152 | fAnalysisManager->AddTask(task); |
153 | AliAnalysisDataContainer *cinput = fAnalysisManager->GetCommonInputContainer(); | |
154 | Printf("Defining output file"); | |
949fa831 | 155 | AliAnalysisDataContainer *coutput1 = fAnalysisManager->CreateContainer("pt", TList::Class(), |
b9f1d917 | 156 | AliAnalysisManager::kOutputContainer, "Pt.ESD.root"); |
157 | ||
158 | // connect containers | |
afdb0e0d | 159 | Printf("---> Connecting input..."); |
160 | fAnalysisManager->ConnectInput (task, 0, cinput ); | |
161 | Printf("---> ...connected."); | |
b9f1d917 | 162 | Printf("---> Connecting output..."); |
163 | fAnalysisManager->ConnectOutput (task, 0, coutput1); | |
164 | Printf("---> ...connected."); | |
165 | ||
afdb0e0d | 166 | Printf("----> Calling InitAnalysis"); |
b9f1d917 | 167 | fAnalysisManager->InitAnalysis(); |
afdb0e0d | 168 | Printf("----> Done."); |
169 | Printf("----> Calling StartAnalysis"); | |
b9f1d917 | 170 | fAnalysisManager->StartAnalysis("local", (TTree*)new TTree); |
afdb0e0d | 171 | //fAnalysisManager->StartAnalysis("local", (TTree*)NULL); |
172 | Printf("----> Done."); | |
b9f1d917 | 173 | |
174 | return iResult; | |
175 | } | |
176 | ||
177 | ||
178 | ||
179 | // ################################################################################# | |
180 | Int_t AliHLTAnaManagerComponent::DoDeinit() { | |
181 | // see header file for class documentation | |
182 | ||
183 | fUID = 0; | |
184 | fAnalysisManager->SetSkipTerminate(kTRUE); | |
185 | fAnalysisManager->Terminate(); | |
186 | ||
187 | delete fAnalysisManager; | |
188 | ||
189 | return 0; | |
190 | } | |
191 | ||
192 | // ################################################################################# | |
193 | Int_t AliHLTAnaManagerComponent::DoEvent(const AliHLTComponentEventData& evtData, | |
194 | AliHLTComponentTriggerData& /*trigData*/) { | |
195 | // see header file for class documentation | |
196 | ||
197 | printf("AliHLTAnaManagerComponent::DoEvent\n"); | |
198 | Int_t iResult=0; | |
199 | ||
200 | // -- Only use data event | |
201 | if (!IsDataEvent()) | |
202 | return 0; | |
203 | ||
204 | if( fUID == 0 ){ | |
205 | TTimeStamp t; | |
206 | fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID; | |
207 | } | |
208 | ||
209 | // -- Get ESD object | |
210 | // ------------------- | |
211 | AliESDEvent *esdEvent = NULL; | |
949fa831 | 212 | AliESDfriend *esdFriend = NULL; |
b9f1d917 | 213 | for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) { |
214 | esdEvent = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) ); | |
215 | if( !esdEvent ){ | |
216 | HLTWarning("Wrong ESDEvent object received"); | |
217 | iResult = -1; | |
218 | continue; | |
219 | } | |
220 | esdEvent->GetStdContent(); | |
221 | } | |
afdb0e0d | 222 | printf("----> ESDEvent %p has %d tracks: \n", esdEvent, esdEvent->GetNumberOfTracks()); |
949fa831 | 223 | for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject); iter != NULL; iter = GetNextInputObject() ) { |
224 | esdFriend = dynamic_cast<AliESDfriend*>(const_cast<TObject*>( iter ) ); | |
225 | if( !esdFriend ){ | |
226 | HLTWarning("Wrong ESDFriend object received"); | |
227 | iResult = -1; | |
228 | continue; | |
229 | } | |
230 | } | |
231 | printf("----> ESDFriend %p has %d tracks: \n", esdFriend, esdFriend->GetNumberOfTracks()); | |
b9f1d917 | 232 | |
949fa831 | 233 | fAnalysisManager->InitInputData(esdEvent, esdFriend); |
afdb0e0d | 234 | // fInputHandler->BeginEvent(0); |
b9f1d917 | 235 | fAnalysisManager->ExecAnalysis(); |
236 | fInputHandler->FinishEvent(); | |
237 | ||
238 | ||
239 | // -- Send histlist | |
240 | // PushBack(dynamic_cast<TObject*>(fCorrObj->GetHistList()), | |
241 | // kAliHLTDataTypeTObject|kAliHLTDataOriginHLT,fUID); | |
242 | ||
243 | return iResult; | |
244 | } | |
245 | ||
246 | // ################################################################################# | |
247 | Int_t AliHLTAnaManagerComponent::Reconfigure(const Char_t* cdbEntry, const Char_t* chainId) { | |
248 | // see header file for class documentation | |
249 | ||
250 | Int_t iResult=0; | |
251 | TString cdbPath; | |
252 | if (cdbEntry) { | |
253 | cdbPath=cdbEntry; | |
254 | } else { | |
255 | cdbPath="HLT/ConfigGlobal/"; | |
256 | cdbPath+=GetComponentID(); | |
257 | } | |
258 | ||
259 | AliInfoClass(Form("reconfigure '%s' from entry %s%s", chainId, cdbPath.Data(), cdbEntry?"":" (default)")); | |
260 | iResult=ConfigureFromCDBTObjString(cdbPath); | |
261 | ||
262 | return iResult; | |
263 | } | |
264 | ||
265 | // ################################################################################# | |
266 | Int_t AliHLTAnaManagerComponent::ReadPreprocessorValues(const Char_t* /*modules*/) { | |
267 | // see header file for class documentation | |
268 | ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component"); | |
269 | return 0; | |
270 | } | |
271 |