]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/global/AliHLTGlobalTrackMergerComponent.cxx
Update master to aliroot
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalTrackMergerComponent.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: Jacek Otwinowski <Jacek.Otwinowski@gsi.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   AliHLTGlobalTrackMergerComponent.cxx
20     @author Jacek Otwinowski
21     @date   
22     @brief  HLT global track merger component.
23 */
24
25 #include <climits>
26 #include <cassert>
27 #include <cstdlib>
28 #include <cerrno>
29
30 #include "AliESDEvent.h"
31 #include "AliTracker.h"
32 #include "AliHLTGlobalTrackMerger.h"
33 #include "AliHLTGlobalTrackMergerComponent.h"
34
35 using namespace std;
36
37 /** ROOT macro for the implementation of ROOT specific class methods */
38 ClassImp(AliHLTGlobalTrackMergerComponent)
39
40 //_____________________________________________________________________________
41 AliHLTGlobalTrackMergerComponent::AliHLTGlobalTrackMergerComponent() : AliHLTGlobalEsdConverterComponent(), 
42   fGlobalTrackMerger(0)
43 {
44 }
45
46 //_____________________________________________________________________________
47 AliHLTGlobalTrackMergerComponent::~AliHLTGlobalTrackMergerComponent()
48 {
49   // see header file for class documentation
50 }
51
52 //_____________________________________________________________________________
53 const char* AliHLTGlobalTrackMergerComponent::GetComponentID()
54 {
55   // see header file for class documentation
56   return "GlobalTrackMerger";
57 }
58
59 //_____________________________________________________________________________
60 void AliHLTGlobalTrackMergerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
61 {
62   // see header file for class documentation
63   list.push_back( kAliHLTDataTypeTrack );
64 }
65
66 //_____________________________________________________________________________
67 // AliHLTComponentDataType AliHLTGlobalTrackMergerComponent::GetOutputDataType()
68 // {
69 //   // see header file for class documentation
70 //   return kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC;
71 // }
72
73 //_____________________________________________________________________________
74 // void AliHLTGlobalTrackMergerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
75 // {
76 //   // see header file for class documentation
77 //   // XXX TODO: Find more realistic values.
78 //   constBase = 20000;
79 //   inputMultiplier = 1.0;
80 // }
81
82 //_____________________________________________________________________________
83 AliHLTComponent* AliHLTGlobalTrackMergerComponent::Spawn()
84 {
85   // see header file for class documentation
86   return new AliHLTGlobalTrackMergerComponent;
87 }
88
89 //_____________________________________________________________________________
90 void AliHLTGlobalTrackMergerComponent::SetMergerParameters(Double_t maxy,Double_t maxz,Double_t maxkappa,Double_t maxpsi,Double_t maxtgl)
91 {
92   // see header file for class documentation
93   fGlobalTrackMerger->SetParameter( maxy, maxz, maxkappa, maxpsi, maxtgl );
94 }
95
96 //_____________________________________________________________________________
97 int AliHLTGlobalTrackMergerComponent::DoInit( int /*argc*/, const char** /*argv*/ )
98 {
99   // see header file for class documentation
100   const char* argv = "-notree";
101   AliHLTGlobalEsdConverterComponent::DoInit(1,&argv);
102
103   int iResult = 0;
104   
105   // Init merger
106   fGlobalTrackMerger = new AliHLTGlobalTrackMerger();
107
108   if (!fGlobalTrackMerger ) {
109      HLTError("failed creating internal objects");
110      iResult=-ENOMEM;
111      return iResult;
112   }
113
114   SetMergerParameters();
115
116   return iResult;
117 }
118
119 //_____________________________________________________________________________
120 int AliHLTGlobalTrackMergerComponent::DoDeinit()
121 {
122   // see header file for class documentation
123   if(fGlobalTrackMerger) delete fGlobalTrackMerger; fGlobalTrackMerger =0;
124   AliHLTGlobalEsdConverterComponent::DoDeinit();
125   return 0;
126 }
127
128 //_____________________________________________________________________________
129 int AliHLTGlobalTrackMergerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, 
130                                               AliHLTComponentTriggerData& /*trigData*/)
131 {
132   //
133   // global track merger function
134   // takes TRD and TPC tracks and merges them
135   //
136   HLTInfo("DoEvent processing data");
137
138   // see header file for class documentation
139   int iResult=0;
140
141   if(!fGlobalTrackMerger || !fESD) {
142     HLTError("component not initialized");
143     iResult=-ENOMEM;
144     return iResult;
145   }
146
147   fESD->Reset(); 
148   fESD->SetMagneticField(fSolenoidBz);
149   //fESD->SetMagneticField(AliTracker::GetBz());
150
151   if ((iResult=ProcessBlocks(NULL, fESD, NULL))<0) return iResult;
152   if(!fESD->GetNumberOfTracks()>0) return iResult;
153
154    // merge tracks
155    Bool_t isMerged = fGlobalTrackMerger->Merge(fESD);
156    if(!isMerged) {
157      HLTInfo("No merged tracks");
158    }
159
160    // try to propagate all tracks to DCA to primary vertex
161    fGlobalTrackMerger->PropagateTracksToDCA(fESD);
162
163    // calculate specification
164    // AliHLTUInt32_t iSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, 0, 5 );
165    // HLTInfo("minSlice %d, maxSlice %d", minSlice, maxSlice);
166
167    // send output data
168    //PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC, iSpecification);
169    PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginOut);
170
171    // clean ESD event content
172    fESD->Reset();
173   
174 return iResult;
175 }
176
177