-Created new libarey AliHLTEve with processor classes for the HLT online display
[u/mrichter/AliRoot.git] / HLT / EVE / AliHLTEveHLT.cxx
CommitLineData
33791895 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Primary Authors: Svein Lindal <slindal@fys.uio.no > *
6 * for The ALICE HLT Project. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17/// @file AliHLTEvePhos.cxx
18/// @author Svein Lindal <slindal@fys.uio.no>
19/// @brief HLT class for the HLT EVE display
20
21#include "AliHLTEveHLT.h"
22#include "AliHLTHOMERBlockDesc.h"
23#include "AliHLTEveBase.h"
24#include "AliEveHOMERManager.h"
25#include "TEveManager.h"
26#include "TEvePointSet.h"
27#include "TEveTrack.h"
28#include "TCanvas.h"
29#include "AliESDEvent.h"
30#include "TEveTrackPropagator.h"
31#include "AliEveTrack.h"
32#include "TEveVSDStructs.h"
33#include "TString.h"
34#include "TPCLib/tracking-ca/AliHLTTPCCATrackParam.h"
35#include "TPCLib/tracking-ca/AliHLTTPCCATrackConvertor.h"
36#include "AliEveMagField.h"
37#include "TH1F.h"
38#include "TH2F.h"
39
40ClassImp(AliHLTEveHLT)
41
42AliHLTEveHLT::AliHLTEveHLT() :
43 AliHLTEveBase(),
44 fTrueField(kFALSE),
45 fUseIpOnFailedITS(kFALSE),
46 fUseRkStepper(kFALSE),
47 fTrackList(NULL)
48{
49 // Constructor.
50}
51
52AliHLTEveHLT::~AliHLTEveHLT()
53{
54 //Destructor, not implemented
55 if(fTrackList)
56 delete fTrackList;
57 fTrackList = NULL;
58}
59
60
61void AliHLTEveHLT::ProcessBlock(AliHLTHOMERBlockDesc * block) {
62 //See header file for documentation
63 if ( ! block->GetDataType().CompareTo("ALIESDV0") ) {
64 if(!fTrackList) CreateTrackList();
65 ProcessEsdBlock(block, fTrackList);
66 }
67
68 else if ( ! block->GetDataType().CompareTo("ROOTTOBJ") ) {
69 //processROOTTOBJ( block, gHLTText );
70 }
71
72 else if ( ! block->GetDataType().CompareTo("HLTRDLST") ) {
73 //processHLTRDLST( block );
74 }
75
76 else if ( !block->GetDataType().CompareTo("ROOTHIST") ) {
77 if( !fCanvas ) {
78 fCanvas = CreateCanvas("Primary Vertex", "Primary Vertex");
79 fCanvas->Divide(2, 2);
80 }
81 ProcessHistograms( block , fCanvas);
82 }
83
84}
85
86
87void AliHLTEveHLT::UpdateElements() {
88 //See header file for documentation
89 if(fCanvas) fCanvas->Update();
90 if(fTrackList) fTrackList->ElementChanged();
91
92}
93
94void AliHLTEveHLT::ResetElements(){
95 //See header file for documentation
96 if(fTrackList) fTrackList->DestroyElements();
97
98 fHistoCount = 0;
99
100}
101
102void AliHLTEveHLT::ProcessHistograms(AliHLTHOMERBlockDesc * block, TCanvas * canvas) {
103 //See header file for documentation
104 if ( ! block->GetClassName().CompareTo("TH1F")) {
105 TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
106 if( histo ){
107 TString name(histo->GetName());
108 if( !name.CompareTo("primVertexZ") ){
109 canvas->cd(2);
110 histo->Draw();
111 }else if( !name.CompareTo("primVertexX") ){
112 canvas->cd(3);
113 histo->Draw();
114 }else if( !name.CompareTo("primVertexY") ){
115 canvas->cd(4);
116 histo->Draw();
117 }
118 }
119 } else if ( ! block->GetClassName().CompareTo("TH2F")) {
120 TH2F *hista = reinterpret_cast<TH2F*>(block->GetTObject());
121 if (hista ){
122 TString name(hista->GetName());
123 if( !name.CompareTo("primVertexXY")) {
124 canvas->cd(1);
125 hista->Draw();
126 }
127 }
128 }
129 canvas->cd();
130
131
132
133
134}
135
136void AliHLTEveHLT::CreateTrackList() {
137 //See header file for documentation
138 fTrackList = new TEveTrackList("ESD Tracks");
139 fTrackList->SetMainColor(6);
140 gEve->AddElement(fTrackList);
141}
142
143
144void AliHLTEveHLT::ProcessEsdBlock( AliHLTHOMERBlockDesc * block, TEveTrackList * cont ) {
145 //See header file for documentation
146
147 AliESDEvent* esd = (AliESDEvent *) (block->GetTObject());
148 esd->GetStdContent();
149
150 SetUpTrackPropagator(cont->GetPropagator(),-0.1*esd->GetMagneticField(), 520);
151
152 for (Int_t iter = 0; iter < esd->GetNumberOfTracks(); ++iter) {
153 AliEveTrack* track = dynamic_cast<AliEveTrack*>(MakeEsdTrack(esd->GetTrack(iter), cont));
154 cont->AddElement(track);
155
156// gTPCPt->Fill(esd->GetTrack(iter)->GetSignedPt()); // KK
157// gTPCEta->Fill(esd->GetTrack(iter)->GetSnp());
158// gTPCPsi->Fill(esd->GetTrack(iter)->GetTgl());
159// gTPCnClusters->Fill(esd->GetTrack(iter)->GetTPCNcls());
160 }
161
162// gTPCMult->Fill(esd->GetNumberOfTracks()); // KK
163
164// Int_t icd = 0;
165// gTPCClustCanvas->Clear();
166// gTPCClustCanvas->Divide(2, 2);
167// gTPCClustCanvas->cd(icd++);
168// gTPCPt->Draw();
169// gTPCClustCanvas->cd(icd++);
170// gTPCEta->Draw();
171// gTPCClustCanvas->cd(icd++);
172// gTPCPsi->Draw();
173// gTPCClustCanvas->cd(icd++);
174// gTPCnClusters->Draw();
175// gTPCClustCanvas->cd(icd++);
176// gTPCMult->Draw();
177// gTPCClustCanvas->Update();
178
179
180 cont->SetTitle(Form("N=%d", esd->GetNumberOfTracks()) );
181 cont->MakeTracks();
182
183}
184
185AliEveTrack* AliHLTEveHLT::MakeEsdTrack (AliESDtrack *at, TEveTrackList* cont) {
186 //See header file for documentation
187
188
189 const double kCLight = 0.000299792458;
190 double bz = - kCLight*10.*( cont->GetPropagator()->GetMagField(0,0,0).fZ);
191
192 Bool_t innerTaken = kFALSE;
193 if ( ! at->IsOn(AliESDtrack::kITSrefit) && fUseIpOnFailedITS)
194 {
195 //tp = at->GetInnerParam();
196 innerTaken = kTRUE;
197 }
198
199 // Add inner/outer track parameters as path-marks.
200
201 Double_t pbuf[3], vbuf[3];
202
203 AliExternalTrackParam trackParam = *at;
204
205 // take parameters constrained to vertex (if they are)
206
207 if( at->GetConstrainedParam() ){
208 trackParam = *at->GetConstrainedParam();
209 }
210 else if( at->GetInnerParam() ){
211 trackParam = *(at->GetInnerParam());
212 }
213 if( at->GetStatus()&AliESDtrack::kTRDin ){
214 // transport to TRD in
215 trackParam = *at;
216 trackParam.PropagateTo( 290.45, -10.*( cont->GetPropagator()->GetMagField(0,0,0).fZ) );
217 }
218
219 TEveRecTrack rt;
220 {
221 rt.fLabel = at->GetLabel();
222 rt.fIndex = (Int_t) at->GetID();
223 rt.fStatus = (Int_t) at->GetStatus();
224 rt.fSign = (Int_t) trackParam.GetSign();
225 trackParam.GetXYZ(vbuf);
226 trackParam.GetPxPyPz(pbuf);
227 rt.fV.Set(vbuf);
228 rt.fP.Set(pbuf);
229 Double_t ep = at->GetP(), mc = at->GetMass();
230 rt.fBeta = ep/TMath::Sqrt(ep*ep + mc*mc);
231 }
232
233 AliEveTrack* track = new AliEveTrack(&rt, cont->GetPropagator());
234 track->SetAttLineAttMarker(cont);
235 track->SetName(Form("AliEveTrack %d", at->GetID()));
236 track->SetElementTitle(CreateTrackTitle(at));
237 track->SetSourceObject(at);
238
239
240 // Set reference points along the trajectory
241 // and the last point
242
243 {
244 TEvePathMark startPoint(TEvePathMark::kReference);
245 trackParam.GetXYZ(vbuf);
246 trackParam.GetPxPyPz(pbuf);
247 startPoint.fV.Set(vbuf);
248 startPoint.fP.Set(pbuf);
249 rt.fV.Set(vbuf);
250 rt.fP.Set(pbuf);
251 Double_t ep = at->GetP(), mc = at->GetMass();
252 rt.fBeta = ep/TMath::Sqrt(ep*ep + mc*mc);
253
254 track->AddPathMark( startPoint );
255 }
256
257
258 if( at->GetTPCPoints(2)>80 ){
259
260 //
261 // use AliHLTTPCCATrackParam propagator
262 // since AliExternalTrackParam:PropagateTo()
263 // has an offset at big distances
264 //
265
266 AliHLTTPCCATrackParam t;
267 AliHLTTPCCATrackConvertor::SetExtParam( t, trackParam );
268
269 Double_t x0 = trackParam.GetX();
270 Double_t dx = at->GetTPCPoints(2) - x0;
271
272 //
273 // set a reference at the half of trajectory for better drawing
274 //
275
276 for( double dxx=dx/2; TMath::Abs(dxx)>=1.; dxx*=.9 ){
277 if( !t.TransportToX(x0+dxx, bz, .99 ) ) continue;
278 AliHLTTPCCATrackConvertor::GetExtParam( t, trackParam, trackParam.GetAlpha() );
279 trackParam.GetXYZ(vbuf);
280 trackParam.GetPxPyPz(pbuf);
281 TEvePathMark midPoint(TEvePathMark::kReference);
282 midPoint.fV.Set(vbuf);
283 midPoint.fP.Set(pbuf);
284 track->AddPathMark( midPoint );
285 break;
286 }
287
288 //
289 // Set a reference at the end of the trajectory
290 // and a "decay point", to let the event display know where the track ends
291 //
292
293 for( ; TMath::Abs(dx)>=1.; dx*=.9 ){
294 if( !t.TransportToX(x0+dx, bz, .99 ) ) continue;
295 AliHLTTPCCATrackConvertor::GetExtParam( t, trackParam, trackParam.GetAlpha() );
296 trackParam.GetXYZ(vbuf);
297 trackParam.GetPxPyPz(pbuf);
298 TEvePathMark endPoint(TEvePathMark::kReference);
299 TEvePathMark decPoint(TEvePathMark::kDecay);
300 endPoint.fV.Set(vbuf);
301 endPoint.fP.Set(pbuf);
302 decPoint.fV.Set(vbuf);
303 decPoint.fP.Set(pbuf);
304 track->AddPathMark( endPoint );
305 track->AddPathMark( decPoint );
306 break;
307 }
308 }
309
310 if (at->IsOn(AliESDtrack::kTPCrefit))
311 {
312 if ( ! innerTaken)
313 {
314 AddTrackParamToTrack(track, at->GetInnerParam());
315 }
316 AddTrackParamToTrack(track, at->GetOuterParam());
317 }
318 return track;
319}
320
321void AliHLTEveHLT::SetUpTrackPropagator(TEveTrackPropagator* trkProp, Float_t magF, Float_t maxR) {
322 //See header file for documentation
323
324 if (fTrueField) {
325 trkProp->SetMagFieldObj(new AliEveMagField);
326
327 } else {
328 trkProp->SetMagField(magF);
329 }
330
331 if (fUseRkStepper) {
332 trkProp->SetStepper(TEveTrackPropagator::kRungeKutta);
333 }
334
335 trkProp->SetMaxR(maxR);
336}
337
338
339void AliHLTEveHLT::AddTrackParamToTrack(AliEveTrack* track, const AliExternalTrackParam* tp) {
340 //See header file for documentation
341
342 if (tp == 0)
343 return;
344
345 Double_t pbuf[3], vbuf[3];
346 tp->GetXYZ(vbuf);
347 tp->GetPxPyPz(pbuf);
348
349 TEvePathMark pm(TEvePathMark::kReference);
350 pm.fV.Set(vbuf);
351 pm.fP.Set(pbuf);
352 track->AddPathMark(pm);
353}
354
355
356
357TString AliHLTEveHLT::CreateTrackTitle(AliESDtrack* t) {
358 // Add additional track parameters as a path-mark to track.
359
360 TString s;
361
362 Int_t label = t->GetLabel(), index = t->GetID();
363 TString idx(index == kMinInt ? "<undef>" : Form("%d", index));
364 TString lbl(label == kMinInt ? "<undef>" : Form("%d", label));
365
366 Double_t p[3], v[3];
367 t->GetXYZ(v);
368 t->GetPxPyPz(p);
369 Double_t pt = t->Pt();
370 Double_t ptsig = TMath::Sqrt(t->GetSigma1Pt2());
371 Double_t ptsq = pt*pt;
372 Double_t ptm = pt / (1.0 + pt*ptsig);
373 Double_t ptM = pt / (1.0 - pt*ptsig);
374
375 s = Form("Index=%s, Label=%s\nChg=%d, Pdg=%d\n"
376 "pT = %.3f + %.3f - %.3f [%.3f]\n"
377 "P = (%.3f, %.3f, %.3f)\n"
378 "V = (%.3f, %.3f, %.3f)\n",
379 idx.Data(), lbl.Data(), t->Charge(), 0,
380 pt, ptM - pt, pt - ptm, ptsig*ptsq,
381 p[0], p[1], p[2],
382 v[0], v[1], v[2]);
383
384 Int_t o;
385 s += "Det (in,out,refit,pid):\n";
386 o = AliESDtrack::kITSin;
387 s += Form("ITS (%d,%d,%d,%d) ", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
388 o = AliESDtrack::kTPCin;
389 s += Form("TPC(%d,%d,%d,%d)\n", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
390 o = AliESDtrack::kTRDin;
391 s += Form("TRD(%d,%d,%d,%d) ", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
392 o = AliESDtrack::kTOFin;
393 s += Form("TOF(%d,%d,%d,%d)\n", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
394 o = AliESDtrack::kHMPIDout;
395 s += Form("HMPID(out=%d,pid=%d)\n", t->IsOn(o), t->IsOn(o<<1));
396 s += Form("ESD pid=%d", t->IsOn(AliESDtrack::kESDpid));
397
398 if (t->IsOn(AliESDtrack::kESDpid))
399 {
400 Double_t pid[5];
401 t->GetESDpid(pid);
402 s += Form("\n[%.2f %.2f %.2f %.2f %.2f]", pid[0], pid[1], pid[2], pid[3], pid[4]);
403 }
404
405 return s;
406}
407