75 #ifndef __RUN_ALICE_ESD_SPLIT__
77 void alice_esd_split()
79 TString dir = gSystem->UnixPathName(__FILE__);
80 dir.ReplaceAll(
"alice_esd_split.C",
"");
81 dir.ReplaceAll(
"/./",
"/");
82 gROOT->LoadMacro(dir +
"SplitGLView.C+");
83 const char* esd_file_name =
"http://root.cern.ch/files/alice_ESDs.root";
84 TFile::SetCacheFileDir(
".");
85 TString lib(Form(
"aliesd/aliesd.%s", gSystem->GetSoExt()));
87 if (gSystem->AccessPathName(lib, kReadPermission)) {
88 TFile* f = TFile::Open(esd_file_name,
"CACHEREAD");
90 TTree *tree = (TTree*) f->Get(
"esdTree");
91 tree->SetBranchStatus (
"ESDfriend*", 1);
92 f->MakeProject(
"aliesd",
"*",
"++");
97 gROOT->ProcessLine(
"#define __RUN_ALICE_ESD_SPLIT__ 1");
98 gROOT->ProcessLine(
"#include \"alice_esd_split.C\"");
99 gROOT->ProcessLine(
"run_alice_esd_split()");
100 gROOT->ProcessLine(
"#undef __RUN_ALICE_ESD_SPLIT__");
105 R__EXTERN TEveProjectionManager *gRPhiMgr;
106 R__EXTERN TEveProjectionManager *gRhoZMgr;
107 TEveGeoShape *gGeoShape;
114 class AliExternalTrackParam;
118 void update_projections();
120 void alice_esd_read();
121 TEveTrack* esd_make_track(TEveTrackPropagator* trkProp, Int_t index, AliESDtrack* at,
122 AliExternalTrackParam* tp=0);
123 Bool_t trackIsOn(AliESDtrack* t, Int_t mask);
124 void trackGetPos(AliExternalTrackParam* tp, Double_t r[3]);
125 void trackGetMomentum(AliExternalTrackParam* tp, Double_t p[3]);
126 Double_t trackGetP(AliExternalTrackParam* tp);
131 const char* esd_file_name =
"http://root.cern.ch/files/alice_ESDs.root";
132 const char* esd_friends_file_name =
"http://root.cern.ch/files/alice_ESDfriends.root";
133 const char* esd_geom_file_name =
"http://root.cern.ch/files/alice_ESDgeometry.root";
136 TFile *esd_friends_file = 0;
140 AliESDEvent *esd = 0;
141 AliESDfriend *esd_friend = 0;
143 Int_t esd_event_id = 0;
145 TEveTrackList *track_list = 0;
147 TGTextEntry *gTextEntry;
148 TGHProgressBar *gProgress;
155 void run_alice_esd_split(Bool_t auto_size=kFALSE)
165 TFile::SetCacheFileDir(
".");
167 printf(
"*** Opening ESD ***\n");
168 esd_file = TFile::Open(esd_file_name,
"CACHEREAD");
172 printf(
"*** Opening ESD-friends ***\n");
173 esd_friends_file = TFile::Open(esd_friends_file_name,
"CACHEREAD");
174 if (!esd_friends_file)
177 esd_tree = (TTree*) esd_file->Get(
"esdTree");
179 esd = (AliESDEvent*) esd_tree->GetUserInfo()->FindObject(
"AliESDEvent");
183 TIter next(esd->fESDObjects);
185 while ((el=(TNamed*)next()))
187 TString bname(el->GetName());
188 if(bname.CompareTo(
"AliESDfriend")==0)
191 esd_tree->SetBranchAddress(
"ESDfriend.", esd->fESDObjects->GetObjectRef(el));
195 esd_tree->SetBranchAddress(bname, esd->fESDObjects->GetObjectRef(el));
200 TEveManager::Create();
207 gVirtualX->GetWindowSize(gVirtualX->GetDefaultRootWindow(), qq, qq, ww, hh);
208 Float_t screen_ratio = (Float_t)ww/(Float_t)hh;
209 if (screen_ratio > 1.5) {
210 gEve->GetBrowser()->MoveResize(100, 50, ww - 300, hh - 100);
212 gEve->GetBrowser()->Move(50, 50);
217 TFile* geom = TFile::Open(esd_geom_file_name,
"CACHEREAD");
220 TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get(
"Gentle");
221 gGeoShape = TEveGeoShape::ImportShapeExtract(gse, 0);
224 gEve->AddGlobalElement(gGeoShape);
231 TEveProjectionAxes* a =
new TEveProjectionAxes(gRPhiMgr);
233 gEve->GetScenes()->FindChild(
"R-Phi Projection")->AddElement(a);
234 gRPhiMgr->ImportElements(gGeoShape);
237 TEveProjectionAxes* a =
new TEveProjectionAxes(gRhoZMgr);
239 gEve->GetScenes()->FindChild(
"Rho-Z Projection")->AddElement(a);
240 gRhoZMgr->ImportElements(gGeoShape);
245 update_projections();
247 gEve->Redraw3D(kTRUE);
256 printf(
"Loading event %d.\n", esd_event_id);
257 gTextEntry->SetTextColor(0xff0000);
258 gTextEntry->SetText(Form(
"Loading event %d...",esd_event_id));
259 gSystem->ProcessEvents();
262 track_list->DestroyElements();
264 esd_tree->GetEntry(esd_event_id);
268 gEve->Redraw3D(kFALSE, kTRUE);
269 gTextEntry->SetTextColor((Pixel_t)0x000000);
270 gTextEntry->SetText(Form(
"Event %d loaded",esd_event_id));
271 gROOT->ProcessLine(
"SplitGLView::UpdateSummary()");
275 void update_projections()
280 TEveElement* top = gEve->GetCurrentEvent();
281 if (gRPhiMgr && top) {
282 gRPhiMgr->DestroyElements();
283 gRPhiMgr->ImportElements(gGeoShape);
284 gRPhiMgr->ImportElements(top);
286 if (gRhoZMgr && top) {
287 gRhoZMgr->DestroyElements();
288 gRhoZMgr->ImportElements(gGeoShape);
289 gRhoZMgr->ImportElements(top);
306 if (esd_event_id < esd_tree->GetEntries() - 1) {
309 update_projections();
311 gTextEntry->SetTextColor(0xff0000);
312 gTextEntry->SetText(
"Already at last event");
313 printf(
"Already at last event.\n");
318 if (esd_event_id > 0) {
321 update_projections();
323 gTextEntry->SetTextColor(0xff0000);
324 gTextEntry->SetText(
"Already at first event");
325 printf(
"Already at first event.\n");
335 gROOT->ProcessLine(
".L SplitGLView.C+");
337 TEveBrowser* browser = gEve->GetBrowser();
339 browser->ShowCloseTab(kFALSE);
340 browser->ExecPlugin(
"SplitGLView", 0,
"new SplitGLView(gClient->GetRoot(), 600, 450, kTRUE)");
341 browser->ShowCloseTab(kTRUE);
343 browser->StartEmbedding(TRootBrowser::kLeft);
345 TGMainFrame* frmMain =
new TGMainFrame(gClient->GetRoot(), 1000, 600);
346 frmMain->SetWindowName(
"XX GUI");
347 frmMain->SetCleanup(kDeepCleanup);
349 TGHorizontalFrame* hf =
new TGHorizontalFrame(frmMain);
352 TString icondir( Form(
"%s/icons/", gSystem->Getenv(
"ROOTSYS")) );
353 TGPictureButton* b = 0;
354 EvNavHandler *fh =
new EvNavHandler;
356 b =
new TGPictureButton(hf, gClient->GetPicture(icondir +
"GoBack.gif"));
357 hf->AddFrame(b,
new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 2, 10, 10));
358 b->Connect(
"Clicked()",
"EvNavHandler", fh,
"Bck()");
360 b =
new TGPictureButton(hf, gClient->GetPicture(icondir +
"GoForward.gif"));
361 hf->AddFrame(b,
new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 10, 10, 10));
362 b->Connect(
"Clicked()",
"EvNavHandler", fh,
"Fwd()");
364 gTextEntry =
new TGTextEntry(hf);
365 gTextEntry->SetEnabled(kFALSE);
366 hf->AddFrame(gTextEntry,
new TGLayoutHints(kLHintsLeft | kLHintsCenterY |
367 kLHintsExpandX, 2, 10, 10, 10));
369 frmMain->AddFrame(hf,
new TGLayoutHints(kLHintsTop | kLHintsExpandX,0,0,20,0));
371 gProgress =
new TGHProgressBar(frmMain, TGProgressBar::kFancy, 100);
372 gProgress->ShowPosition(kTRUE, kFALSE,
"%.0f tracks");
373 gProgress->SetBarColor(
"green");
374 frmMain->AddFrame(gProgress,
new TGLayoutHints(kLHintsExpandX, 10, 10, 5, 5));
376 frmMain->MapSubwindows();
378 frmMain->MapWindow();
380 browser->StopEmbedding();
381 browser->SetTabTitle(
"Event Control", 0);
390 kITSin=0x0001,kITSout=0x0002,kITSrefit=0x0004,kITSpid=0x0008,
391 kTPCin=0x0010,kTPCout=0x0020,kTPCrefit=0x0040,kTPCpid=0x0080,
392 kTRDin=0x0100,kTRDout=0x0200,kTRDrefit=0x0400,kTRDpid=0x0800,
393 kTOFin=0x1000,kTOFout=0x2000,kTOFrefit=0x4000,kTOFpid=0x8000,
403 void alice_esd_read()
407 AliESDRun *esdrun = (AliESDRun*) esd->fESDObjects->FindObject(
"AliESDRun");
408 TClonesArray *tracks = (TClonesArray*) esd->fESDObjects->FindObject(
"Tracks");
414 if (track_list == 0) {
415 track_list =
new TEveTrackList(
"ESD Tracks");
416 track_list->SetMainColor(6);
418 track_list->SetMarkerColor(kYellow);
419 track_list->SetMarkerStyle(4);
420 track_list->SetMarkerSize(0.5);
422 gEve->AddElement(track_list);
425 TEveTrackPropagator* trkProp = track_list->GetPropagator();
426 trkProp->SetMagField( 0.1 * esdrun->fMagneticField );
429 gProgress->SetMax(tracks->GetEntriesFast());
430 for (Int_t n=0; n<tracks->GetEntriesFast(); ++n)
432 AliESDtrack* at = (AliESDtrack*) tracks->At(n);
435 AliExternalTrackParam* tp = at;
436 if (! trackIsOn(at, kITSrefit)) {
440 TEveTrack* track = esd_make_track(trkProp, n, at, tp);
441 track->SetAttLineAttMarker(track_list);
442 track_list->AddElement(track);
450 gProgress->Increment(1);
453 track_list->MakeTracks();
457 TEveTrack* esd_make_track(TEveTrackPropagator* trkProp,
460 AliExternalTrackParam* tp)
467 Double_t pbuf[3], vbuf[3];
470 if (tp == 0) tp = at;
472 rt.fLabel = at->fLabel;
474 rt.fStatus = (Int_t) at->fFlags;
475 rt.fSign = (tp->fP[4] > 0) ? 1 : -1;
477 trackGetPos(tp, vbuf); rt.fV.Set(vbuf);
478 trackGetMomentum(tp, pbuf); rt.fP.Set(pbuf);
480 Double_t ep = trackGetP(at);
483 rt.fBeta = ep/TMath::Sqrt(ep*ep + mc*mc);
485 TEveTrack* track =
new TEveTrack(&rt, trkProp);
486 track->SetName(Form(
"TEveTrack %d", rt.fIndex));
487 track->SetStdTitle();
493 Bool_t trackIsOn(AliESDtrack* t, Int_t mask)
497 return (t->fFlags & mask) > 0;
501 void trackGetPos(AliExternalTrackParam* tp, Double_t r[3])
505 r[0] = tp->fX; r[1] = tp->fP[0]; r[2] = tp->fP[1];
507 Double_t cs=TMath::Cos(tp->fAlpha), sn=TMath::Sin(tp->fAlpha), x=r[0];
508 r[0] = x*cs - r[1]*sn; r[1] = x*sn + r[1]*cs;
512 void trackGetMomentum(AliExternalTrackParam* tp, Double_t p[3])
516 p[0] = tp->fP[4]; p[1] = tp->fP[2]; p[2] = tp->fP[3];
518 Double_t pt=1./TMath::Abs(p[0]);
519 Double_t cs=TMath::Cos(tp->fAlpha), sn=TMath::Sin(tp->fAlpha);
520 Double_t r=TMath::Sqrt(1 - p[1]*p[1]);
521 p[0]=pt*(r*cs - p[1]*sn); p[1]=pt*(p[1]*cs + r*sn); p[2]=pt*p[2];
525 Double_t trackGetP(AliExternalTrackParam* tp)
529 return TMath::Sqrt(1.+ tp->fP[3]*tp->fP[3])/TMath::Abs(tp->fP[4]);