]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/JET/analysis/AliHLTJETAnalysisComponent.cxx
correcting placement of 'using' statements (Thorsten)
[u/mrichter/AliRoot.git] / HLT / JET / analysis / AliHLTJETAnalysisComponent.cxx
1 //-*- Mode: C++ -*-
2 // $Id: AliHLTJETAnalysisComponent.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: Jochen Thaeder <jochen@thaeder.de>                    *
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   AliHLTJETAnalysisComponent.cxx    
20     @author Jochen Thaeder <jochen@thaeder.de>
21     @brief  Component to run the analysis for the jetfinder
22 */
23
24 #include <cstdlib>
25 #include <cerrno>
26 #include <sys/time.h>
27
28 #include "TString.h"
29 #include "TObjString.h"
30 #include "TObjArray.h"
31
32 #include "AliHLTJETAnalysisComponent.h" 
33
34 using namespace std;
35
36 /** ROOT macro for the implementation of ROOT specific class methods */
37 ClassImp(AliHLTJETAnalysisComponent)
38
39 /*
40  * ---------------------------------------------------------------------------------
41  *                            Constructor / Destructor
42  * ---------------------------------------------------------------------------------
43  */
44
45 // #################################################################################
46 AliHLTJETAnalysisComponent::AliHLTJETAnalysisComponent() :
47   fAnalysisJets(NULL) {
48   // see header file for class documentation
49   // or
50   // refer to README to build package
51   // or
52   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
53
54 }
55
56 // #################################################################################
57 AliHLTJETAnalysisComponent::~AliHLTJETAnalysisComponent() {
58   // see header file for class documentation
59 }
60
61 /*
62  * ---------------------------------------------------------------------------------
63  * Public functions to implement AliHLTComponent's interface.
64  * These functions are required for the registration process
65  * ---------------------------------------------------------------------------------
66  */
67
68 // #################################################################################
69 const Char_t* AliHLTJETAnalysisComponent::GetComponentID() {
70   // see header file for class documentation
71   return "JETAnalysis";
72 }
73
74 // #################################################################################
75 void AliHLTJETAnalysisComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
76   // see header file for class documentation
77   list.clear(); 
78   list.push_back( kAliHLTDataTypeJet|kAliHLTDataOriginHLT );
79   list.push_back( kAliHLTDataTypeJet|kAliHLTDataOriginOffline );
80   list.push_back( kAliHLTDataTypeMCObject|kAliHLTDataOriginOffline );
81   list.push_back( kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT );
82 }
83
84 // #################################################################################
85 AliHLTComponentDataType AliHLTJETAnalysisComponent::GetOutputDataType() {
86   // see header file for class documentation
87   return (kAliHLTDataTypeESDObject|kAliHLTDataOriginHLT); // XXX To Be CHANGED
88 }
89
90 // #################################################################################
91 void AliHLTJETAnalysisComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
92   // see header file for class documentation
93
94   constBase = 20000000;
95   inputMultiplier = 0.3;
96 }
97
98 // #################################################################################
99 AliHLTComponent* AliHLTJETAnalysisComponent::Spawn() {
100   // see header file for class documentation
101   return new AliHLTJETAnalysisComponent();
102 }
103
104 /*
105  * ---------------------------------------------------------------------------------
106  * Protected functions to implement AliHLTComponent's interface.
107  * These functions provide initialization as well as the actual processing
108  * capabilities of the component. 
109  * ---------------------------------------------------------------------------------
110  */
111
112 // #################################################################################
113 Int_t AliHLTJETAnalysisComponent::DoInit( Int_t argc, const Char_t** argv ) {
114   // see header file for class documentation
115
116   Int_t iResult = 0;
117
118   if ( fAnalysisJets )
119     return -EINPROGRESS;
120
121   Int_t bMissingParam=0;
122   TString argument="";
123
124   // -- Loop over all arguments
125   for ( Int_t iter = 0; iter<argc && iResult>=0; iter++) {
126     argument=argv[iter];
127
128     if (argument.IsNull()) 
129       continue;
130
131 #if 0
132     /*
133     // -- nEvents
134     if ( !argument.CompareTo("-nevents") ) {
135     if ((bMissingParam=(++iter>=argc))) break;
136     
137     TString parameter(argv[iter]);
138     parameter.Remove(TString::kLeading, ' ');
139     
140     if ( parameter.IsDigit() ) {
141     fNEventsMax = parameter.Atoi() - 1;
142     }
143     else {
144     HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
145     iResult=-EINVAL;
146     }
147     } 
148     
149     // -- Argument not known
150     else {
151     HLTError("Unknown argument %s.", argument.Data());
152     iResult = -EINVAL;
153     }
154     */
155 #endif
156   } // for ( Int iter = 0; iter<argc && iResult>=0; iter++) {
157   
158   // -- Check if parameter is missing
159   if ( bMissingParam ) {
160     HLTError("Missing parameter for argument %s.", argument.Data());
161     iResult=-EINVAL;
162   }
163
164   if ( !iResult ) {
165     fAnalysisJets = new AliHLTJETAnalysisJets();
166     fAnalysisJets->Initialize();
167   }
168   
169   return iResult;
170 }
171
172 // #################################################################################
173 Int_t AliHLTJETAnalysisComponent::DoDeinit() {
174   // see header file for class documentation
175
176   if ( fAnalysisJets )
177     delete fAnalysisJets;
178   fAnalysisJets = NULL;
179
180   return 0;
181 }
182
183 // #################################################################################
184 Int_t AliHLTJETAnalysisComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
185                                           AliHLTComponentTriggerData& /*trigData*/ ) {
186   // see header file for class documentation
187
188   Int_t iResult = 0;
189
190   const TObject* iter = NULL;
191
192   // ------------------------------------------------
193   // -- DATA Event 
194   // ------------------------------------------------
195   if ( IsDataEvent() ) {
196
197     fAnalysisJets->ResetEvent();
198     
199     // -- Loop over jet objects
200     // ------------------------------
201     for ( iter=GetFirstInputObject(kAliHLTDataTypeJet|kAliHLTDataOriginHLT); 
202           iter != NULL && !iResult; iter=GetNextInputObject() ) {
203       
204       fAnalysisJets->SetJetsRec(reinterpret_cast<AliHLTJets*>(const_cast<TObject*>(iter)));
205     }
206     
207     // -- ADD MC Object -- On-line
208     // ------------------------------
209     for ( iter=GetFirstInputObject(kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT); 
210           iter != NULL && !iResult; iter=GetNextInputObject() ) {
211       
212       fAnalysisJets->SetJetsCmp(reinterpret_cast<AliHLTMCEvent*>(const_cast<TObject*>(iter)),
213                                 NULL,
214                                 NULL);
215     }         
216     // -- Process event
217     // ------------------
218     iResult = fAnalysisJets->Analyze();
219   }
220
221   // ------------------------------------------------
222   // -- EOR Event 
223   // ------------------------------------------------
224   else {
225     if ( GetFirstInputBlock(kAliHLTDataTypeEOR) ) {
226       PushBack(fAnalysisJets, kAliHLTDataTypeJet|kAliHLTDataOriginHLT, GetSpecification());
227     }
228   }
229    
230   return iResult;
231 }