From Kalliopi: Updated HLT histogram filling
[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),
353f10b3 47 fTrackList(NULL),
48 fTrCanvas(NULL),
49 fHistPt(NULL),
50 fHistP(NULL),
51 fHistEta(NULL),
52 fHistTheta(NULL),
53 fHistPhi(NULL),
54 fHistnClusters(NULL),
55 fHistMult(NULL)
33791895 56{
57 // Constructor.
353f10b3 58 CreateHistograms();
59
33791895 60}
61
62AliHLTEveHLT::~AliHLTEveHLT()
63{
64 //Destructor, not implemented
65 if(fTrackList)
66 delete fTrackList;
67 fTrackList = NULL;
68}
69
353f10b3 70void AliHLTEveHLT::CreateHistograms(){
71 //See header file for documentation
72 fHistPt = new TH1F("fHistPt", "transverse momentum", 100, 0, 10); // KK
73 fHistP = new TH1F("fHistP", "signed momentum", 100,-7, 7);
74 fHistEta = new TH1F("fHistEta", "pseudorapidity", 100,-2, 2);
75 fHistTheta = new TH1F("fHistTheta", "polar angle", 180, 0,180);
76 fHistPhi = new TH1F("fHistPhi", "azimuthal angle", 180, 0,360);
77 fHistnClusters = new TH1F("fHistnClusters","TPC clusters per track", 160, 0,160);
78 fHistMult = new TH1F("fHistMult", "event track multiplicity",50, 0, 50);
79
80 fHistPt ->SetXTitle("p_{t} (GeV/c)"); // KK
81 fHistP ->SetXTitle("P*charge (GeV/c)");
82 fHistEta ->SetXTitle("#eta");
83 fHistTheta->SetXTitle("#theta (degrees)");
84 fHistPhi ->SetXTitle("#phi (degrees)");
85
86}
33791895 87
88void AliHLTEveHLT::ProcessBlock(AliHLTHOMERBlockDesc * block) {
89 //See header file for documentation
90 if ( ! block->GetDataType().CompareTo("ALIESDV0") ) {
91 if(!fTrackList) CreateTrackList();
92 ProcessEsdBlock(block, fTrackList);
93 }
94
95 else if ( ! block->GetDataType().CompareTo("ROOTTOBJ") ) {
96 //processROOTTOBJ( block, gHLTText );
97 }
98
99 else if ( ! block->GetDataType().CompareTo("HLTRDLST") ) {
100 //processHLTRDLST( block );
101 }
102
103 else if ( !block->GetDataType().CompareTo("ROOTHIST") ) {
104 if( !fCanvas ) {
105 fCanvas = CreateCanvas("Primary Vertex", "Primary Vertex");
dd407e8c 106 fCanvas->Divide(3, 2);
33791895 107 }
108 ProcessHistograms( block , fCanvas);
109 }
110
111}
112
113
114void AliHLTEveHLT::UpdateElements() {
115 //See header file for documentation
116 if(fCanvas) fCanvas->Update();
51d61826 117 DrawHistograms();
33791895 118 if(fTrackList) fTrackList->ElementChanged();
33791895 119}
120
121void AliHLTEveHLT::ResetElements(){
122 //See header file for documentation
123 if(fTrackList) fTrackList->DestroyElements();
33791895 124 fHistoCount = 0;
125
126}
127
128void AliHLTEveHLT::ProcessHistograms(AliHLTHOMERBlockDesc * block, TCanvas * canvas) {
129 //See header file for documentation
130 if ( ! block->GetClassName().CompareTo("TH1F")) {
131 TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
132 if( histo ){
133 TString name(histo->GetName());
134 if( !name.CompareTo("primVertexZ") ){
135 canvas->cd(2);
136 histo->Draw();
137 }else if( !name.CompareTo("primVertexX") ){
138 canvas->cd(3);
139 histo->Draw();
140 }else if( !name.CompareTo("primVertexY") ){
141 canvas->cd(4);
142 histo->Draw();
143 }
144 }
145 } else if ( ! block->GetClassName().CompareTo("TH2F")) {
146 TH2F *hista = reinterpret_cast<TH2F*>(block->GetTObject());
147 if (hista ){
148 TString name(hista->GetName());
149 if( !name.CompareTo("primVertexXY")) {
150 canvas->cd(1);
151 hista->Draw();
152 }
153 }
154 }
155 canvas->cd();
156
157
158
159
160}
161
162void AliHLTEveHLT::CreateTrackList() {
163 //See header file for documentation
164 fTrackList = new TEveTrackList("ESD Tracks");
165 fTrackList->SetMainColor(6);
166 gEve->AddElement(fTrackList);
167}
168
169
170void AliHLTEveHLT::ProcessEsdBlock( AliHLTHOMERBlockDesc * block, TEveTrackList * cont ) {
171 //See header file for documentation
172
173 AliESDEvent* esd = (AliESDEvent *) (block->GetTObject());
174 esd->GetStdContent();
175
176 SetUpTrackPropagator(cont->GetPropagator(),-0.1*esd->GetMagneticField(), 520);
177
178 for (Int_t iter = 0; iter < esd->GetNumberOfTracks(); ++iter) {
179 AliEveTrack* track = dynamic_cast<AliEveTrack*>(MakeEsdTrack(esd->GetTrack(iter), cont));
180 cont->AddElement(track);
353f10b3 181
182 fHistPt->Fill(esd->GetTrack(iter)->Pt()); // KK
183 fHistP->Fill(esd->GetTrack(iter)->P()*esd->GetTrack(iter)->Charge());
184 fHistEta->Fill(esd->GetTrack(iter)->Eta());
185 fHistTheta->Fill(esd->GetTrack(iter)->Theta()*TMath::RadToDeg());
186 fHistPhi->Fill(esd->GetTrack(iter)->Phi()*TMath::RadToDeg());
419e5b41 187 if(esd->GetTrack(iter)->GetStatus()&AliESDtrack::kTPCin || (esd->GetTrack(iter)->GetStatus()&AliESDtrack::kTPCin && esd->GetTrack(iter)->GetStatus()&AliESDtrack::kITSin)){
188 fHistnClusters->Fill(esd->GetTrack(iter)->GetTPCNcls());
189 }
33791895 190 }
191
353f10b3 192 fHistMult->Fill(esd->GetNumberOfTracks()); // KK
33791895 193
33791895 194
195 cont->SetTitle(Form("N=%d", esd->GetNumberOfTracks()) );
196 cont->MakeTracks();
197
198}
199
353f10b3 200
201void AliHLTEveHLT::DrawHistograms(){
202 //See header file for documentation
203
204 if (!fTrCanvas) {
205 fTrCanvas = CreateCanvas("TPC Tr QA", "TPC Track QA");
206 fTrCanvas->Divide(4, 2);
207 }
208
209 Int_t icd = 1;
210 fTrCanvas->cd(icd++);
211 fHistPt->Draw();
212 fTrCanvas->cd(icd++);
213 fHistP->Draw();
214 fTrCanvas->cd(icd++);
215 fHistEta->Draw();
216 fTrCanvas->cd(icd++);
217 fHistTheta->Draw();
218 fTrCanvas->cd(icd++);
219 fHistPhi->Draw();
220 fTrCanvas->cd(icd++);
221 fHistnClusters->Draw();
222 fTrCanvas->cd(icd++);
223 fHistMult->Draw();
224 fTrCanvas->cd();
225
226 fTrCanvas->Update();
227
228}
229
33791895 230AliEveTrack* AliHLTEveHLT::MakeEsdTrack (AliESDtrack *at, TEveTrackList* cont) {
231 //See header file for documentation
232
233
234 const double kCLight = 0.000299792458;
235 double bz = - kCLight*10.*( cont->GetPropagator()->GetMagField(0,0,0).fZ);
236
237 Bool_t innerTaken = kFALSE;
238 if ( ! at->IsOn(AliESDtrack::kITSrefit) && fUseIpOnFailedITS)
239 {
240 //tp = at->GetInnerParam();
241 innerTaken = kTRUE;
242 }
243
244 // Add inner/outer track parameters as path-marks.
245
246 Double_t pbuf[3], vbuf[3];
247
248 AliExternalTrackParam trackParam = *at;
249
250 // take parameters constrained to vertex (if they are)
251
252 if( at->GetConstrainedParam() ){
253 trackParam = *at->GetConstrainedParam();
254 }
255 else if( at->GetInnerParam() ){
256 trackParam = *(at->GetInnerParam());
257 }
258 if( at->GetStatus()&AliESDtrack::kTRDin ){
259 // transport to TRD in
260 trackParam = *at;
261 trackParam.PropagateTo( 290.45, -10.*( cont->GetPropagator()->GetMagField(0,0,0).fZ) );
262 }
263
264 TEveRecTrack rt;
265 {
266 rt.fLabel = at->GetLabel();
267 rt.fIndex = (Int_t) at->GetID();
268 rt.fStatus = (Int_t) at->GetStatus();
269 rt.fSign = (Int_t) trackParam.GetSign();
270 trackParam.GetXYZ(vbuf);
271 trackParam.GetPxPyPz(pbuf);
272 rt.fV.Set(vbuf);
273 rt.fP.Set(pbuf);
274 Double_t ep = at->GetP(), mc = at->GetMass();
275 rt.fBeta = ep/TMath::Sqrt(ep*ep + mc*mc);
276 }
277
278 AliEveTrack* track = new AliEveTrack(&rt, cont->GetPropagator());
279 track->SetAttLineAttMarker(cont);
280 track->SetName(Form("AliEveTrack %d", at->GetID()));
281 track->SetElementTitle(CreateTrackTitle(at));
282 track->SetSourceObject(at);
283
284
285 // Set reference points along the trajectory
286 // and the last point
287
288 {
289 TEvePathMark startPoint(TEvePathMark::kReference);
290 trackParam.GetXYZ(vbuf);
291 trackParam.GetPxPyPz(pbuf);
292 startPoint.fV.Set(vbuf);
293 startPoint.fP.Set(pbuf);
294 rt.fV.Set(vbuf);
295 rt.fP.Set(pbuf);
296 Double_t ep = at->GetP(), mc = at->GetMass();
297 rt.fBeta = ep/TMath::Sqrt(ep*ep + mc*mc);
298
299 track->AddPathMark( startPoint );
300 }
301
302
303 if( at->GetTPCPoints(2)>80 ){
304
305 //
306 // use AliHLTTPCCATrackParam propagator
307 // since AliExternalTrackParam:PropagateTo()
308 // has an offset at big distances
309 //
310
311 AliHLTTPCCATrackParam t;
312 AliHLTTPCCATrackConvertor::SetExtParam( t, trackParam );
313
314 Double_t x0 = trackParam.GetX();
315 Double_t dx = at->GetTPCPoints(2) - x0;
316
317 //
318 // set a reference at the half of trajectory for better drawing
319 //
320
321 for( double dxx=dx/2; TMath::Abs(dxx)>=1.; dxx*=.9 ){
322 if( !t.TransportToX(x0+dxx, bz, .99 ) ) continue;
323 AliHLTTPCCATrackConvertor::GetExtParam( t, trackParam, trackParam.GetAlpha() );
324 trackParam.GetXYZ(vbuf);
325 trackParam.GetPxPyPz(pbuf);
326 TEvePathMark midPoint(TEvePathMark::kReference);
327 midPoint.fV.Set(vbuf);
328 midPoint.fP.Set(pbuf);
329 track->AddPathMark( midPoint );
330 break;
331 }
332
333 //
334 // Set a reference at the end of the trajectory
335 // and a "decay point", to let the event display know where the track ends
336 //
337
338 for( ; TMath::Abs(dx)>=1.; dx*=.9 ){
339 if( !t.TransportToX(x0+dx, bz, .99 ) ) continue;
340 AliHLTTPCCATrackConvertor::GetExtParam( t, trackParam, trackParam.GetAlpha() );
341 trackParam.GetXYZ(vbuf);
342 trackParam.GetPxPyPz(pbuf);
343 TEvePathMark endPoint(TEvePathMark::kReference);
344 TEvePathMark decPoint(TEvePathMark::kDecay);
345 endPoint.fV.Set(vbuf);
346 endPoint.fP.Set(pbuf);
347 decPoint.fV.Set(vbuf);
348 decPoint.fP.Set(pbuf);
349 track->AddPathMark( endPoint );
350 track->AddPathMark( decPoint );
351 break;
352 }
353 }
354
355 if (at->IsOn(AliESDtrack::kTPCrefit))
356 {
357 if ( ! innerTaken)
358 {
359 AddTrackParamToTrack(track, at->GetInnerParam());
360 }
361 AddTrackParamToTrack(track, at->GetOuterParam());
362 }
363 return track;
364}
365
366void AliHLTEveHLT::SetUpTrackPropagator(TEveTrackPropagator* trkProp, Float_t magF, Float_t maxR) {
367 //See header file for documentation
368
369 if (fTrueField) {
370 trkProp->SetMagFieldObj(new AliEveMagField);
371
372 } else {
373 trkProp->SetMagField(magF);
374 }
375
376 if (fUseRkStepper) {
377 trkProp->SetStepper(TEveTrackPropagator::kRungeKutta);
378 }
379
380 trkProp->SetMaxR(maxR);
381}
382
383
384void AliHLTEveHLT::AddTrackParamToTrack(AliEveTrack* track, const AliExternalTrackParam* tp) {
385 //See header file for documentation
386
387 if (tp == 0)
388 return;
389
390 Double_t pbuf[3], vbuf[3];
391 tp->GetXYZ(vbuf);
392 tp->GetPxPyPz(pbuf);
393
394 TEvePathMark pm(TEvePathMark::kReference);
395 pm.fV.Set(vbuf);
396 pm.fP.Set(pbuf);
397 track->AddPathMark(pm);
398}
399
400
401
402TString AliHLTEveHLT::CreateTrackTitle(AliESDtrack* t) {
403 // Add additional track parameters as a path-mark to track.
404
405 TString s;
406
407 Int_t label = t->GetLabel(), index = t->GetID();
408 TString idx(index == kMinInt ? "<undef>" : Form("%d", index));
409 TString lbl(label == kMinInt ? "<undef>" : Form("%d", label));
410
411 Double_t p[3], v[3];
412 t->GetXYZ(v);
413 t->GetPxPyPz(p);
414 Double_t pt = t->Pt();
415 Double_t ptsig = TMath::Sqrt(t->GetSigma1Pt2());
416 Double_t ptsq = pt*pt;
417 Double_t ptm = pt / (1.0 + pt*ptsig);
418 Double_t ptM = pt / (1.0 - pt*ptsig);
419
420 s = Form("Index=%s, Label=%s\nChg=%d, Pdg=%d\n"
421 "pT = %.3f + %.3f - %.3f [%.3f]\n"
422 "P = (%.3f, %.3f, %.3f)\n"
423 "V = (%.3f, %.3f, %.3f)\n",
424 idx.Data(), lbl.Data(), t->Charge(), 0,
425 pt, ptM - pt, pt - ptm, ptsig*ptsq,
426 p[0], p[1], p[2],
427 v[0], v[1], v[2]);
428
429 Int_t o;
430 s += "Det (in,out,refit,pid):\n";
431 o = AliESDtrack::kITSin;
432 s += Form("ITS (%d,%d,%d,%d) ", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
433 o = AliESDtrack::kTPCin;
434 s += Form("TPC(%d,%d,%d,%d)\n", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
435 o = AliESDtrack::kTRDin;
436 s += Form("TRD(%d,%d,%d,%d) ", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
437 o = AliESDtrack::kTOFin;
438 s += Form("TOF(%d,%d,%d,%d)\n", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
439 o = AliESDtrack::kHMPIDout;
440 s += Form("HMPID(out=%d,pid=%d)\n", t->IsOn(o), t->IsOn(o<<1));
441 s += Form("ESD pid=%d", t->IsOn(AliESDtrack::kESDpid));
442
443 if (t->IsOn(AliESDtrack::kESDpid))
444 {
445 Double_t pid[5];
446 t->GetESDpid(pid);
447 s += Form("\n[%.2f %.2f %.2f %.2f %.2f]", pid[0], pid[1], pid[2], pid[3], pid[4]);
448 }
449
450 return s;
451}
452