]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/JET/AliHLTJETFastJetComponent.cxx
656ea2c4d1181ba2bc373dac4366953fc9086e57
[u/mrichter/AliRoot.git] / HLT / JET / AliHLTJETFastJetComponent.cxx
1 //-*- Mode: C++ -*-
2 // $Id: $
3
4 //**************************************************************************
5 //* This file is property of and copyright by the ALICE HLT Project        * 
6 //* ALICE Experiment at CERN, All rights reserved.                         *
7 //*                                                                        *
8 //* Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>        *
9 //*                  for The ALICE HLT Project.                            *
10 //*                                                                        *
11 //* Permission to use, copy, modify and distribute this software and its   *
12 //* documentation strictly for non-commercial purposes is hereby granted   *
13 //* without fee, provided that the above copyright notice appears in all   *
14 //* copies and that both the copyright notice and this permission notice   *
15 //* appear in the supporting documentation. The authors make no claims     *
16 //* about the suitability of this software for any purpose. It is          *
17 //* provided "as is" without express or implied warranty.                  *
18 //**************************************************************************
19
20 /** @file   AliHLTJETFastJetComponent.cxx
21     @author Jochen Thaeder <thaeder@kip.uni-heidelberg.de>
22     @date   
23     @brief   Component to run the FastJet jetfinder
24 */
25
26 #if __GNUC__>= 3
27 using namespace std;
28 #endif
29
30 #include <cstdlib>
31 #include <cerrno>
32 #include <sys/time.h>
33
34 #include "AliHLTJETFastJetComponent.h" 
35
36 #include "TString.h"
37 #include "TObjString.h"
38
39 /** ROOT macro for the implementation of ROOT specific class methods */
40 ClassImp(AliHLTJETFastJetComponent)
41
42 /*
43  * ---------------------------------------------------------------------------------
44  *                            Constructor / Destructor
45  * ---------------------------------------------------------------------------------
46  */
47
48 // #################################################################################
49 AliHLTJETFastJetComponent::AliHLTJETFastJetComponent() 
50   :
51   fJetFinder(NULL),
52   fJetHeader(NULL),
53   fJetReader(NULL),
54   fJetReaderHeader(NULL),
55   fJetTrackCuts(NULL) {
56   // see header file for class documentation
57   // or
58   // refer to README to build package
59   // or
60   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
61 }
62
63 // #################################################################################
64 AliHLTJETFastJetComponent::~AliHLTJETFastJetComponent() {
65   // see header file for class documentation
66 }
67
68 /*
69  * ---------------------------------------------------------------------------------
70  * Public functions to implement AliHLTComponent's interface.
71  * These functions are required for the registration process
72  * ---------------------------------------------------------------------------------
73  */
74
75 // #################################################################################
76 const Char_t* AliHLTJETFastJetComponent::GetComponentID() {
77   // see header file for class documentation
78   return "JETFastJetFinder";
79 }
80
81 // #################################################################################
82 void AliHLTJETFastJetComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
83   // see header file for class documentation
84   list.clear(); 
85   list.push_back( kAliHLTDataTypeMCObject|kAliHLTDataOriginOffline );
86   list.push_back( kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT );
87   list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOffline );
88   list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginHLT );
89 }
90
91 // #################################################################################
92 AliHLTComponentDataType AliHLTJETFastJetComponent::GetOutputDataType() {
93   // see header file for class documentation
94   return (kAliHLTDataTypeESDObject| kAliHLTDataOriginHLT);
95 }
96
97 // #################################################################################
98 void AliHLTJETFastJetComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
99   // see header file for class documentation
100
101   constBase = 0;
102   inputMultiplier = 0.3;
103 }
104
105 // #################################################################################
106 AliHLTComponent* AliHLTJETFastJetComponent::Spawn() {
107   // see header file for class documentation
108   return new AliHLTJETFastJetComponent();
109 }
110
111 /*
112  * ---------------------------------------------------------------------------------
113  * Protected functions to implement AliHLTComponent's interface.
114  * These functions provide initialization as well as the actual processing
115  * capabilities of the component. 
116  * ---------------------------------------------------------------------------------
117  */
118
119 // #################################################################################
120 Int_t AliHLTJETFastJetComponent::DoInit( Int_t /*argc*/, const Char_t** /*argv*/ ) {
121   // see header file for class documentation
122
123   if ( fJetFinder || fJetHeader || fJetReader || fJetReader || fJetTrackCuts)
124     return -EINPROGRESS;
125
126   // -- Jet Track Cuts
127   // -------------------------------------------
128   if ( ! (fJetTrackCuts = new AliHLTJETTrackCuts()) ) {
129     HLTError("Error initializing Track Cuts");
130     return -EINPROGRESS;
131   }
132
133   // fJetTrackCuts->Set ...
134   
135   // -- Jet Reader Header
136   // -------------------------------------------
137   if ( ! (fJetReaderHeader = new AliHLTJETReaderHeader()) ) {
138     HLTError("Error initializing Jet Reader Header");
139     return -EINPROGRESS;
140   }
141
142   fJetReaderHeader->SetAnalysisCuts( dynamic_cast<AliAnalysisCuts*>(fJetTrackCuts) );
143
144   // -- Jet Reader
145   // -------------------------------------------
146   if ( ! (fJetReader = new AliHLTJETReader()) ) {
147     HLTError("Error initializing Jet Reader");
148     return -EINPROGRESS;
149   }
150
151   fJetReader->SetReaderHeader(fJetReaderHeader);
152
153   // -- Jet Header
154   // -------------------------------------------
155   if ( ! (fJetHeader = new AliFastJetHeader()) ) {
156     HLTError("Error initializing Jet Header");
157     return -EINPROGRESS;
158   }
159
160   fJetHeader->SetRparam(0.7); 
161
162   // -- Jet Finder
163   // -------------------------------------------
164   if ( ! (fJetFinder = new AliFastJetFinder()) ) {
165     HLTError("Error initializing Jet Finder");
166     return -EINPROGRESS;
167   }
168
169   fJetFinder->SetJetHeader(fJetHeader);
170   fJetFinder->SetJetReader(fJetReader);
171   fJetFinder->SetOutputFile("jets.root");
172
173   // -- Initialize Jet Finder
174   // -------------------------------------------
175   fJetFinder->Init();
176
177   return 0;
178 }
179
180 // #################################################################################
181 Int_t AliHLTJETFastJetComponent::DoDeinit() {
182   // see header file for class documentation
183   /*
184   if ( fJetFinder )
185     delete fJetFinder;
186   fJetFinder = NULL;
187
188   if ( fJetHeader )
189     delete fJetHeader;
190   fJetHeader = NULL;
191  
192   if ( fJetReader )
193     delete fJetReader;
194   fJetReader = NULL;
195  
196   if ( fJetReaderHeader )
197     delete fJetReaderHeader;
198   fJetReaderHeader = NULL;
199
200   if ( fJetTrackCuts )
201     delete fJetTrackCuts;
202   fJetTrackCuts = NULL;
203
204
205   */
206   return 0;
207 }
208
209 // #################################################################################
210 Int_t AliHLTJETFastJetComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
211                                           AliHLTComponentTriggerData& /*trigData*/ ) {
212   // see header file for class documentation
213
214   Int_t iResult = 0;
215
216   const TObject* iter = NULL;
217
218   // -- Start-Of-Run
219   // -----------------
220   if ( GetFirstInputObject(kAliHLTDataTypeSOR) && !iResult ) {
221     HLTInfo("On-line SOR Event");
222   }
223   
224   // -- ADD MC Object -- Off-line
225   // ------------------------------
226   for ( iter=GetFirstInputObject(kAliHLTDataTypeMCObject|kAliHLTDataOriginOffline); iter != NULL && !iResult; iter=GetNextInputObject() ) {
227     HLTInfo("Off-line MC Event");
228   }
229   // -- ADD MC Object -- On-line
230   // ------------------------------
231   for ( iter=GetFirstInputObject(kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT); iter != NULL && !iResult; iter=GetNextInputObject() ) {
232     HLTInfo("On-line MC Event");
233     
234     // -- Set input event
235     fJetReader->SetInputEvent( NULL, NULL, const_cast<TObject*>(iter) );    
236
237     // -- Process one event
238     if ( ! (fJetFinder->ProcessEvent()) )
239       iResult = -1;
240   }
241
242   // -- ADD ESD Object -- Off-line
243   // -------------------------------
244   for ( iter=GetFirstInputObject(kAliHLTDataTypeESDObject|kAliHLTDataOriginOffline); iter != NULL && !iResult; iter=GetNextInputObject() ) {
245     HLTInfo("Off-line ESD Event");
246   }
247
248   // -- ADD ESD Object -- On-line
249   // ------------------------------
250   for ( iter=GetFirstInputObject(kAliHLTDataTypeESDObject|kAliHLTDataOriginHLT); iter != NULL && !iResult; iter=GetNextInputObject() ) {
251     HLTInfo("On-line ESD Event");
252   }
253
254   // -- End-Of-Run
255   // ---------------
256   if ( GetFirstInputObject(kAliHLTDataTypeEOR) && !iResult ) {
257     HLTInfo("On-line EOR Event");
258     
259     // -- Finish Event ?
260     // fJetFinder->FinishRun();
261   }
262   
263   // -- PushBack
264   // -------------
265
266   return 0;
267 }