]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/alice-macros/esd_muon_tracks.C
Recalc ptJet for Missing daugh
[u/mrichter/AliRoot.git] / EVE / alice-macros / esd_muon_tracks.C
CommitLineData
39d6561a 1// $Id$
2
3/**************************************************************************
4 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
5 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
6 * full copyright notice. *
7 **************************************************************************/
8
25b4bdb2 9/// \ingroup evemacros
10/// \file esd_muon_tracks.C
11/// \brief Macro to visualise ESD tracks from MUON spectrometer
12/// (both tracker and trigger).
13///
14/// Use esd_muon_tracks(Bool_t showClusters, Bool_t showDigits) in order to run it
15///
16/// Needs that alieve_init() is already called
17///
18/// \author P. Pillot, L. Aphecetche; Subatech
39d6561a 19
20#if !defined(__CINT__) || defined(__MAKECINT__)
c757605d 21#include <TStyle.h>
22#include <TROOT.h>
39d6561a 23#include <TEveManager.h>
24#include <TEveUtil.h>
25#include <TEveTrack.h>
26#include <TEvePointSet.h>
27#include <TEveQuadSet.h>
28#include <TEveTrackPropagator.h>
29#include <TEveVSDStructs.h>
30
6c49a8e1 31#include <AliMUONESDInterface.h>
32#include <AliMUONTrack.h>
33#include <AliMUONTrackExtrap.h>
34#include <AliMUONTrackParam.h>
35#include <AliMUONConstants.h>
36#include <AliMUONCDB.h>
37#include <AliMUONGeometryTransformer.h>
38#include <AliMUONTriggerCircuit.h>
39#include <AliMpCDB.h>
40#include <AliESDEvent.h>
41#include <AliESDMuonTrack.h>
42#include <AliEveMagField.h>
43#include <AliEveTrack.h>
44#include <AliEveEventManager.h>
39d6561a 45#endif
46
39d6561a 47//______________________________________________________________________________
48void esd_muon_track_propagator_setup(TEveTrackPropagator* trkProp, Bool_t tracker, Bool_t trigger)
49{
50 // set magnetic field
51 if (AliMUONTrackExtrap::IsFieldON())
52 {
53 trkProp->SetMagFieldObj(new AliEveMagField);
54 }
55 else
56 {
57 trkProp->SetMagField(0.0);
58 }
59 trkProp->SetStepper(TEveTrackPropagator::kRungeKutta);
60
61 // set propagation range
62 trkProp->SetMaxR(1000);
63 if (trigger) trkProp->SetMaxZ(-AliMUONConstants::DefaultChamberZ(13)+10.);
64 else trkProp->SetMaxZ(-AliMUONConstants::MuonFilterZBeg());
65
66 // go through pathmarks
67 trkProp->SetFitDaughters(kFALSE);
68 trkProp->SetFitReferences(kTRUE);
69 trkProp->SetFitDecay(kFALSE);
70 trkProp->SetFitCluster2Ds(kFALSE);
71
72 // Render the ref pathmarks
73 trkProp->SetRnrReferences(kTRUE);
74 trkProp->RefPMAtt().SetMarkerSize(0.5);
75 if (trigger) trkProp->RefPMAtt().SetMarkerColor(kGreen);
76 else trkProp->RefPMAtt().SetMarkerColor(kAzure);
77
78 // Render first vertex
79 if (tracker)
80 {
81 trkProp->SetRnrFV(kTRUE);
82 if (trigger) trkProp->RefFVAtt().SetMarkerColor(kGreen);
83 else trkProp->RefFVAtt().SetMarkerColor(kAzure);
84 }
85}
86
87//______________________________________________________________________________
88void add_esd_muon_tracks(AliESDEvent* esd, AliMUONESDInterface* data,
89 TEveTrackList* match, TEveTrackList* nomatch, TEveTrackList* ghost)
90{
2fcde5f6 91 // load trigger circuit
92 static AliMUONTriggerCircuit* gTriggerCircuit = 0x0;
93 if (!gTriggerCircuit)
94 {
95 AliEveEventManager::AssertGeometry();
96 AliMUONGeometryTransformer* fMUONGeometryTransformer = new AliMUONGeometryTransformer();
97 fMUONGeometryTransformer->LoadGeometryData();
98 gTriggerCircuit = new AliMUONTriggerCircuit(fMUONGeometryTransformer);
99 }
100
39d6561a 101 Int_t nTrack(esd->GetNumberOfMuonTracks());
102 TEveRecTrack recTrack;
103 TEveTrack* track;
104
105 // add ESD tracks to the proper list
106 for (Int_t n = 0; n < nTrack; ++n)
107 {
108 AliESDMuonTrack* emt = esd->GetMuonTrack(n);
109
110 // fill general info
111 UInt_t trackId = emt->GetUniqueID();
112 recTrack.fLabel = emt->GetLabel();
113 recTrack.fIndex = (Int_t)trackId;
114
115 // fill tracker track specific info
116 if ( emt->ContainTrackerData() )
117 {
118 recTrack.fStatus = emt->GetMatchTrigger();
119 recTrack.fSign = emt->Charge();
120 recTrack.fV.Set(emt->GetNonBendingCoorAtDCA(),emt->GetBendingCoorAtDCA(),emt->GetZ());
121 recTrack.fP.Set(emt->PxAtDCA(),emt->PyAtDCA(),emt->PzAtDCA());
122 recTrack.fBeta = ( emt->E() > 0 ) ? emt->P()/emt->E() : 0;
123
124 // get proper track list
125 TEveTrackList* trackList = nomatch;
126 if ( emt->GetMatchTrigger() > 0 ) trackList = match;
127
128 // produce eve track
129 track = new AliEveTrack(&recTrack,trackList->GetPropagator());
130 track->SetName(Form("%cmu",emt->Charge()>0 ? '+':'-'));
131 track->SetStdTitle();
132 track->SetSourceObject(emt); // WARNING: Change the UniqueID of the object!!
133
134 // add path mark
135 TIter next(data->FindTrack(trackId)->GetTrackParamAtCluster());
136 AliMUONTrackParam* param;
137 while ( ( param = static_cast<AliMUONTrackParam*>(next()) ) )
138 {
139 TEveVector v(param->GetNonBendingCoor(),param->GetBendingCoor(),param->GetZ());
140 TEveVector p(param->Px(),param->Py(),param->Pz());
141 track->AddPathMark(TEvePathMark(TEvePathMark::kReference,v,p));
142 }
143
144 // add trigger track if any
145 if (emt->ContainTriggerData())
146 {
147 Double_t x11 = gTriggerCircuit->GetX11Pos(emt->LoCircuit(), emt->LoStripY());
148 Double_t y11 = gTriggerCircuit->GetY11Pos(emt->LoCircuit(), emt->LoStripX());
d4731f84 149 Double_t z11 = gTriggerCircuit->GetZ11Pos(emt->LoCircuit(), emt->LoStripX());
39d6561a 150 Double_t y21 = gTriggerCircuit->GetY21Pos(emt->LoCircuit(), emt->LoStripX()+emt->LoDev()+1);
d4731f84 151 Double_t z21 = gTriggerCircuit->GetZ21Pos(emt->LoCircuit(), emt->LoStripX()+emt->LoDev()+1);
39d6561a 152 Double_t pz = -emt->PUncorrected(); // max value
153 TEveVector v(x11, y11, z11);
154 TEveVector p(pz*x11/z11, pz*(y21-y11)/(z21-z11), pz);
155 track->AddPathMark(TEvePathMark(TEvePathMark::kReference,v,p));
156 }
157
158 // add the track to proper list
159 track->SetAttLineAttMarker(trackList);
160 trackList->AddElement(track);
161 }
162 else // fill ghost track specific info
163 {
164 recTrack.fStatus = 0;
165 recTrack.fSign = emt->Charge();
d4731f84 166 Double_t z11 = (emt->GetZUncorrected() < -1.) ? emt->GetZUncorrected() : (Double_t)AliMUONConstants::DefaultChamberZ(10);
167 recTrack.fV.Set(emt->GetNonBendingCoorUncorrected(),emt->GetBendingCoorUncorrected(),z11);
39d6561a 168 recTrack.fP.Set(-TMath::Tan(emt->GetThetaXUncorrected()),-TMath::Tan(emt->GetThetaYUncorrected()),-1.);
169
170 // produce eve track
171 track = new AliEveTrack(&recTrack,ghost->GetPropagator());
172 track->SetName("mu");
173 track->SetTitle("Trigger only");
174 track->SetSourceObject(emt);
175
176 // add the track to proper list
177 track->SetAttLineAttMarker(ghost);
178 ghost->AddElement(track);
179 }
180
181 }
182
183}
184
185//______________________________________________________________________________
186void esd_muon_tracks(Bool_t showClusters, Bool_t showDigits)
187{
188 // load ESD
189 AliESDEvent* esd = AliEveEventManager::AssertESD();
190 if (esd->GetNumberOfMuonTracks() == 0 && !gEve->GetKeepEmptyCont()) return;
191
192 // load field
193 AliEveEventManager::AssertMagField();
194 if (!AliMUONESDInterface::GetTracker()) AliMUONESDInterface::ResetTracker(AliMUONCDB::LoadRecoParam());
195
196 // load mapping
197 AliMpCDB::LoadAll(kFALSE);
198
39d6561a 199 // convert ESD objects to MUON objects
200 AliMUONESDInterface data;
201 data.LoadEvent(*esd);
202
203 // track containers
204 TEveElementList* trackCont = new TEveElementList("ESD MUON Tracks");
205 trackCont->SetTitle(Form("N=%d", esd->GetNumberOfMuonTracks()));
206
207 TEveTrackList* match = new TEveTrackList("Matched");
208 match->SetRnrPoints(kFALSE);
209 match->SetRnrLine(kTRUE);
210 match->SetLineColor(kGreen);
211 esd_muon_track_propagator_setup(match->GetPropagator(), kTRUE, kTRUE);
212 trackCont->AddElement(match);
213
214 TEveTrackList* nomatch = new TEveTrackList("Not matched");
215 nomatch->SetRnrPoints(kFALSE);
216 nomatch->SetRnrLine(kTRUE);
217 nomatch->SetLineColor(kAzure);
218 esd_muon_track_propagator_setup(nomatch->GetPropagator(), kTRUE, kFALSE);
219 trackCont->AddElement(nomatch);
220
221 TEveTrackList* ghost = new TEveTrackList("Ghost");
222 ghost->SetRnrPoints(kFALSE);
223 ghost->SetRnrLine(kTRUE);
224 ghost->SetLineColor(kAzure);
225 esd_muon_track_propagator_setup(ghost->GetPropagator(), kFALSE, kTRUE);
226 trackCont->AddElement(ghost);
227
228 // cluster container
229 TEvePointSet* clusterList = 0x0;
230 if (showClusters && (data.GetNClusters() > 0 || gEve->GetKeepEmptyCont()))
231 {
232 clusterList = new TEvePointSet(10000);
233 clusterList->SetName("ESD MUON Clusters");
234 clusterList->SetTitle(Form("N=%d",data.GetNClusters()));
235 clusterList->SetPickable(kFALSE);
236 clusterList->SetMarkerStyle(5);
237 clusterList->SetMarkerColor(kYellow);
238 clusterList->SetMarkerSize(2.5);
239 }
240
241 // digit containers
242 TEveElementList* digitCont = 0x0;
243 TEveQuadSet* bending = 0x0;
244 TEveQuadSet* nonBending = 0x0;
245 if (showDigits && (data.GetNDigits() > 0 || gEve->GetKeepEmptyCont()))
246 {
247 digitCont = new TEveElementList("ESD MUON Digits");
248 digitCont->SetTitle(Form("N=%d",data.GetNDigits()));
249
250 bending = new TEveQuadSet(TEveQuadSet::kQT_RectangleXY, kFALSE, 32);
251 bending->SetName("Bending");
252 bending->SetRenderMode(TEveDigitSet::kRM_Fill);
253 bending->SetPickable(kFALSE);
254 digitCont->AddElement(bending);
255
256 nonBending = new TEveQuadSet(TEveQuadSet::kQT_RectangleXY, kFALSE, 32);
257 nonBending->SetName("Non bending");
258 nonBending->SetRenderMode(TEveDigitSet::kRM_Line);
259 nonBending->SetPickable(kFALSE);
260 digitCont->AddElement(nonBending);
261 }
262
263 // add tracks to the proper list and propagate them
264 add_esd_muon_tracks(esd, &data, match, nomatch, ghost);
265 match->SetTitle(Form("N=%d",match->NumChildren()));
266 nomatch->SetTitle(Form("N=%d",nomatch->NumChildren()));
267 ghost->SetTitle(Form("N=%d",ghost->NumChildren()));
268 match->MakeTracks();
269 nomatch->MakeTracks();
270 ghost->MakeTracks();
271
272 // add cluster to the container
273 if (clusterList)
274 {
275 TEveUtil::LoadMacro("muon_clusters.C+");
276 TIter next(data.CreateClusterIterator());
277 gROOT->ProcessLine(Form("add_muon_clusters((TIter*)%p, (TEvePointSet*)%p);",&next, clusterList));
278 }
279
280 // add digits to the containers
281 if (digitCont)
282 {
283 TEveUtil::LoadMacro("muon_digits.C+");
284 TIter next(data.CreateDigitIterator());
285 gROOT->ProcessLine(Form("add_muon_digits((TIter*)%p, (TEveQuadSet*)%p, (TEveQuadSet*)%p, kFALSE);",
286 &next, bending, nonBending));
287
288 // set containers' title
289 bending->SetTitle(Form("N=%d",bending->GetPlex()->Size()));
290 nonBending->SetTitle(Form("N=%d",nonBending->GetPlex()->Size()));
291
292 // automatic scaling
293 gStyle->SetPalette(1);
294 bending->AssertPalette();
295 nonBending->AssertPalette();
296 }
297
298 // add graphic containers
299 gEve->DisableRedraw();
300 gEve->AddElement(trackCont);
301 if (clusterList) gEve->AddElement(clusterList);
302 if (digitCont) gEve->AddElement(digitCont);
303 gEve->EnableRedraw();
304 gEve->Redraw3D();
305}