]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/global/AliHLTGlobalFlatEsdTestComponent.cxx
Update master to aliroot
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalFlatEsdTestComponent.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   AliHLTGlobalFlatEsdTestComponent.cxx
20 //  @author Matthias Richter
21 //  @date   
22 //  @brief  Global ESD converter component.
23 // 
24
25 // see header file for class documentation
26 // or
27 // refer to README to build package
28 // or
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
30
31 #include <cassert>
32 #include "AliHLTGlobalFlatEsdTestComponent.h"
33 #include "AliFlatESDEvent.h"
34 #include "AliFlatESDTrack.h"
35 #include "AliFlatExternalTrackParam.h"
36 #include "AliExternalTrackParam.h"
37
38 #include "AliHLTGlobalBarrelTrack.h"
39 #include "AliHLTExternalTrackParam.h"
40 #include "AliHLTTrackMCLabel.h"
41 #include "AliHLTCTPData.h"
42 #include "AliHLTErrorGuard.h"
43 #include "AliESDEvent.h"
44 #include "AliESDfriend.h"
45 #include "AliESDtrack.h"
46 #include "AliESDMuonTrack.h"
47 #include "AliESDMuonCluster.h"
48 #include "AliCDBEntry.h"
49 #include "AliCDBManager.h"
50 #include "AliPID.h"
51 #include "TTree.h"
52 #include "TList.h"
53 #include "TClonesArray.h"
54 //#include "AliHLTESDCaloClusterMaker.h"
55 //#include "AliHLTCaloClusterDataStruct.h"
56 //#include "AliHLTCaloClusterReader.h"
57 //#include "AliESDCaloCluster.h"
58 //#include "AliESDVZERO.h"
59 #include "AliHLTGlobalVertexerComponent.h"
60 #include "AliHLTVertexFinderBase.h"
61 #include "AliHLTTPCSpacePointData.h"
62 #include "AliHLTTPCClusterDataFormat.h"
63 #include "AliHLTTPCDefinitions.h"
64 #include "AliHLTTPCClusterMCData.h"
65 #include "AliHLTTPCTransform.h"
66
67 /** ROOT macro for the implementation of ROOT specific class methods */
68 ClassImp(AliHLTGlobalFlatEsdTestComponent)
69
70 AliHLTGlobalFlatEsdTestComponent::AliHLTGlobalFlatEsdTestComponent()
71   : AliHLTProcessor()
72   , fWriteClusters(0)
73   , fVerbosity(0)  
74   , fSolenoidBz(-5.00668)
75   , fBenchmark("FlatEsdTest")
76 {
77   // see header file for class documentation
78   // or
79   // refer to README to build package
80   // or
81   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
82 }
83
84 AliHLTGlobalFlatEsdTestComponent::~AliHLTGlobalFlatEsdTestComponent()
85 {
86   // see header file for class documentation
87 }
88
89 int AliHLTGlobalFlatEsdTestComponent::Configure(const char* arguments)
90 {
91   // see header file for class documentation
92   int iResult=0;
93   if (!arguments) return iResult;
94
95   TString allArgs=arguments;
96   TString argument;
97   int bMissingParam=0;
98
99   TObjArray* pTokens=allArgs.Tokenize(" ");
100   if (pTokens) {
101     for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
102       argument=((TObjString*)pTokens->At(i))->String(); 
103       if (argument.IsNull()) continue;      
104       HLTError("unknown argument %s", argument.Data());
105       iResult=-EINVAL;
106       break;
107     }  
108     delete pTokens;
109   }
110   if (bMissingParam) {
111     HLTError("missing parameter for argument %s", argument.Data());
112     iResult=-EINVAL;
113   }
114
115   return iResult;
116 }
117
118 int AliHLTGlobalFlatEsdTestComponent::Reconfigure(const char* cdbEntry, const char* chainId)
119 {
120   // see header file for class documentation
121   int iResult=0;
122   const char* path=NULL;
123   const char* defaultNotify="";
124   if (cdbEntry) {
125     path=cdbEntry;
126     defaultNotify=" (default)";
127   }
128   if (path) {
129     HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
130     AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
131     if (pEntry) {
132       TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
133       if (pString) {
134         HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
135         iResult=Configure(pString->String().Data());
136       } else {
137         HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
138       }
139     } else {
140       HLTError("can not fetch object \"%s\" from CDB", path);
141     }
142   }
143   
144   return iResult;
145 }
146
147 void AliHLTGlobalFlatEsdTestComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
148 {
149   // see header file for class documentation
150   list.push_back(kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut);
151   list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut);
152   list.push_back(kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut);
153 }
154
155 AliHLTComponentDataType AliHLTGlobalFlatEsdTestComponent::GetOutputDataType()
156 {
157   // see header file for class documentation
158   return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
159 }
160
161 void AliHLTGlobalFlatEsdTestComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
162 {
163   // see header file for class documentation
164   constBase=2000000;
165   inputMultiplier=10.0;
166 }
167
168 int AliHLTGlobalFlatEsdTestComponent::DoInit(int argc, const char** argv)
169 {
170   // see header file for class documentation
171   int iResult=0;
172   TString argument="";
173   int bMissingParam=0;
174
175   // default list of skiped ESD objects
176   TString skipObjects=
177     // "AliESDRun,"
178     // "AliESDHeader,"
179     // "AliESDZDC,"
180     "AliESDFMD,"
181     // "AliESDVZERO,"
182     // "AliESDTZERO,"
183     // "TPCVertex,"
184     // "SPDVertex,"
185     // "PrimaryVertex,"
186     // "AliMultiplicity,"
187     // "PHOSTrigger,"
188     // "EMCALTrigger,"
189     // "SPDPileupVertices,"
190     // "TrkPileupVertices,"
191     "Cascades,"
192     "Kinks,"
193     "AliRawDataErrorLogs,"
194     "AliESDACORDE";
195
196   iResult=Reconfigure(NULL, NULL);
197   TString allArgs = "";
198   for ( int i = 0; i < argc; i++ ) {
199     if ( !allArgs.IsNull() ) allArgs += " ";
200     allArgs += argv[i];
201   }
202
203   TObjArray* pTokens=allArgs.Tokenize(" ");
204   if (pTokens) {
205     for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
206       argument=((TObjString*)pTokens->At(i))->String(); 
207       if (argument.IsNull()) continue;
208
209       // -noclusters
210       if (argument.CompareTo("-noclusters")==0) {
211         fWriteClusters=0;       
212         // -clusters
213       } else if (argument.CompareTo("-clusters")==0) {
214         fWriteClusters=1;
215       } else if (argument.Contains("-skipobject=")) {
216         argument.ReplaceAll("-skipobject=", "");
217         skipObjects=argument;
218       } else {
219         HLTError("unknown argument %s", argument.Data());
220         iResult=-EINVAL;
221         break;
222       }
223     }
224   }
225   if (bMissingParam) {
226     HLTError("missing parameter for argument %s", argument.Data());
227     iResult=-EINVAL;
228   }
229
230   fSolenoidBz=GetBz();
231
232   if (iResult>=0) {
233     SetupCTPData();
234   }
235
236   fBenchmark.SetTimer(0,"total");
237
238   return iResult;
239 }
240
241 int AliHLTGlobalFlatEsdTestComponent::DoDeinit()
242 {
243   // see header file for class documentation
244
245   return 0;
246 }
247
248 int AliHLTGlobalFlatEsdTestComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
249                                                     const AliHLTComponentBlockData* /*blocks*/, 
250                                                     AliHLTComponentTriggerData& /*trigData*/,
251                                                     AliHLTUInt8_t* /*outputPtr*/, 
252                                                     AliHLTUInt32_t& size,
253                                                     AliHLTComponentBlockDataList& /*outputBlocks*/ )
254 {
255   // see header file for class documentation
256   int iResult=0;
257
258   if (!IsDataEvent()) return iResult;
259
260   fBenchmark.StartNewEvent();
261   fBenchmark.Start(0);
262
263   size = 0;
264
265   for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
266     //fBenchmark.AddInput(pBlock->fSize);
267     cout<<"Found ESD in esd test component !!!"<<endl;
268     AliESDEvent *esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(iter));//dynamic_cast<const AliESDEvent*>(iter);
269     if( esd ){
270       esd->GetStdContent();
271       cout<<"N ESD tracks: "<<esd->GetNumberOfTracks()<<endl;
272     } else {
273       cout<<"ESD pointer is NULL "<<endl;
274     }
275   }
276
277   for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {     
278     //fBenchmark.AddInput(pBlock->fSize);
279     cout<<"Found ESD friend in esd test component !!!"<<endl;
280     const AliESDfriend *esdFriend = dynamic_cast<const AliESDfriend*>(iter);
281     if( esdFriend ){
282       cout<<"N friend tracks: "<<esdFriend->GetNumberOfTracks()<<endl;
283     } else {
284       cout<<"ESD friend pointer is NULL "<<endl;
285     }
286   }
287
288   for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut);
289        pBlock!=NULL; pBlock=NULL/*GetNextInputBlock() there is only one block*/) {
290     fBenchmark.AddInput(pBlock->fSize);
291     AliFlatESDEvent *flatEvent = reinterpret_cast<AliFlatESDEvent*>( pBlock->fPtr );
292     cout<<"N flat tracks: "<<flatEvent->GetNumberOfTracks()<<endl;
293   }
294
295   
296   fBenchmark.Stop(0);
297   HLTWarning( fBenchmark.GetStatistics() );
298
299   return iResult;
300 }
301