alice_esd_split.C: Complex example showing ALICE ESD visualization in several views. | Event Display | annotation.C: Demonstrates usage of TGLAnnotation class. |
// @(#)root/eve:$Id: alice_vsd.C 37560 2010-12-13 12:28:23Z matevz $ // Author: Matevz Tadel // Complex example showing ALICE VSD visualization. /* alice_vsd.C - a simple event-display for ALICE ------------------------------------------------------------------------ ------------------------------------------------------------------------ Only standard ROOT is used to process the ALICE VSD files. No ALICE code is needed -- the VSD file is exported from AliRoot into VSD format -- see TEveVSDStructs.h and TEveVSD.h. A simple geometry of 10KB, extracted from the full TGeo-geometry, is used to outline the central detectors of ALICE. All files are access from the web by using the "CACHEREAD" option. */ #if defined(__CINT__) && !defined(__MAKECINT__) { Info("alice_vsd.C", "Has to be run in compiled mode ... doing this for you."); gSystem->CompileMacro("alice_vsd.C"); alice_vsd(); } #else #include <TEveManager.h> #include <TEveEventManager.h> #include <TEveVSD.h> #include <TEveVSDStructs.h> #include <TEveTrack.h> #include <TEveTrackPropagator.h> #include <TEveGeoShape.h> #include <TGTab.h> #include <TGButton.h> #include <TFile.h> #include <TKey.h> #include <TSystem.h> #include <TPRegexp.h> // Include componets -- compile time link :) #include "MultiView.C" MultiView* gMultiView = 0; class TVSDReader { public: // ---------------------------------------------------------- // File / Event Data // ---------------------------------------------------------- TFile *fFile; TDirectory *fDirectory; TObjArray *fEvDirKeys; TEveVSD *fVSD; Int_t fMaxEv, fCurEv; // ---------------------------------------------------------- // Event visualization structures // ---------------------------------------------------------- TEveTrackList *fTrackList; TEvePointSet *fITSClusters; TEvePointSet *fTPCClusters; TEvePointSet *fTRDClusters; TEvePointSet *fTOFClusters; public: TVSDReader(const char* file_name) : fFile(0), fDirectory(0), fEvDirKeys(0), fVSD(0), fMaxEv(-1), fCurEv(-1), fTrackList(0), fITSClusters(0), fTPCClusters(0), fTRDClusters(0), fTOFClusters(0) { fFile = TFile::Open(file_name); if (!fFile) { Error("VSD_Reader", "Can not open file '%s' ... terminating.", file_name); gSystem->Exit(1); } fEvDirKeys = new TObjArray; TPMERegexp name_re("Event\\d+"); TObjLink* lnk = fFile->GetListOfKeys()->FirstLink(); while (lnk) { if (name_re.Match(lnk->GetObject()->GetName())) { fEvDirKeys->Add(lnk->GetObject()); } lnk = lnk->Next(); } fMaxEv = fEvDirKeys->GetEntriesFast(); if (fMaxEv == 0) { Error("VSD_Reader", "No events to show ... terminating."); gSystem->Exit(1); } fVSD = new TEveVSD; } virtual ~TVSDReader() { // Destructor. DropEvent(); delete fVSD; delete fEvDirKeys; fFile->Close(); delete fFile; } void AttachEvent() { // Attach event data from current directory. fVSD->LoadTrees(); fVSD->SetBranchAddresses(); } void DropEvent() { // Drup currently held event data, release current directory. // Drop old visualization structures. gEve->GetViewers()->DeleteAnnotations(); gEve->GetCurrentEvent()->DestroyElements(); // Drop old event-data. fVSD->DeleteTrees(); delete fDirectory; fDirectory = 0; } //--------------------------------------------------------------------------- // Event navigation //--------------------------------------------------------------------------- void NextEvent() { GotoEvent(fCurEv + 1); } void PrevEvent() { GotoEvent(fCurEv - 1); } Bool_t GotoEvent(Int_t ev) { if (ev < 0 || ev >= fMaxEv) { Warning("GotoEvent", "Invalid event id %d.", ev); return kFALSE; } DropEvent(); // Connect to new event-data. fCurEv = ev; fDirectory = (TDirectory*) ((TKey*) fEvDirKeys->At(fCurEv))->ReadObj(); fVSD->SetDirectory(fDirectory); AttachEvent(); // Load event data into visualization structures. LoadClusters(fITSClusters, "ITS", 0); LoadClusters(fTPCClusters, "TPC", 1); LoadClusters(fTRDClusters, "TRD", 2); LoadClusters(fTOFClusters, "TOF", 3); LoadEsdTracks(); // Fill projected views. TEveElement* top = gEve->GetCurrentEvent(); gMultiView->DestroyEventRPhi(); gMultiView->ImportEventRPhi(top); gMultiView->DestroyEventRhoZ(); gMultiView->ImportEventRhoZ(top); gEve->Redraw3D(kFALSE, kTRUE); return kTRUE; } //--------------------------------------------------------------------------- // Cluster loading //--------------------------------------------------------------------------- void LoadClusters(TEvePointSet*& ps, const TString& det_name, Int_t det_id) { if (ps == 0) { ps = new TEvePointSet(det_name); ps->SetMainColor((Color_t)(det_id + 2)); ps->SetMarkerSize(0.5); ps->SetMarkerStyle(2); ps->IncDenyDestroy(); } else { ps->Reset(); } TEvePointSelector ss(fVSD->fTreeC, ps, "fV.fX:fV.fY:fV.fZ", TString::Format("fDetId==%d", det_id)); ss.Select(); ps->SetTitle(TString::Format("N=%d", ps->Size())); gEve->AddElement(ps); } //--------------------------------------------------------------------------- // Track loading //--------------------------------------------------------------------------- enum ESDTrackFlags { kITSin=0x0001,kITSout=0x0002,kITSrefit=0x0004,kITSpid=0x0008, kTPCin=0x0010,kTPCout=0x0020,kTPCrefit=0x0040,kTPCpid=0x0080, kTRDin=0x0100,kTRDout=0x0200,kTRDrefit=0x0400,kTRDpid=0x0800, kTOFin=0x1000,kTOFout=0x2000,kTOFrefit=0x4000,kTOFpid=0x8000, kHMPIDpid=0x20000, kEMCALmatch=0x40000, kTRDbackup=0x80000, kTRDStop=0x20000000, kESDpid=0x40000000, kTIME=0x80000000 }; Bool_t trackIsOn(TEveTrack* t, Int_t mask) { // Check is track-flag specified by mask are set. return (t->GetStatus() & mask) > 0; } void LoadEsdTracks() { // Read reconstructed tracks from current event. if (fTrackList == 0) { fTrackList = new TEveTrackList("ESD Tracks"); fTrackList->SetMainColor(6); fTrackList->SetMarkerColor(kYellow); fTrackList->SetMarkerStyle(4); fTrackList->SetMarkerSize(0.5); fTrackList->IncDenyDestroy(); } else { fTrackList->DestroyElements(); } TEveTrackPropagator* trkProp = fTrackList->GetPropagator(); // !!!! Need to store field on file !!!! // Can store TEveMagField ? trkProp->SetMagField(0.5); trkProp->SetStepper(TEveTrackPropagator::kRungeKutta); Int_t nTracks = fVSD->fTreeR->GetEntries(); for (Int_t n = 0; n < nTracks; ++n) { fVSD->fTreeR->GetEntry(n); TEveTrack* track = new TEveTrack(&fVSD->fR, trkProp); track->SetName(Form("ESD Track %d", fVSD->fR.fIndex)); track->SetStdTitle(); track->SetAttLineAttMarker(fTrackList); fTrackList->AddElement(track); } fTrackList->MakeTracks(); gEve->AddElement(fTrackList); } ClassDef(TVSDReader, 0); }; TVSDReader* gVSDReader = 0; // Forward declaration. void make_gui(); //______________________________________________________________________________ void alice_vsd(const char* vsd_file_name= "http://mtadel.home.cern.ch/mtadel/root/AliVSD.root") { // Main function, initializes the application. // // 1. Load the auto-generated library holding ESD classes and // ESD dictionaries. // 2. Open ESD data-files. // 3. Load cartoon geometry. // 4. Spawn simple GUI. // 5. Load first event. TFile::SetCacheFileDir("."); TEveVSD::DisableTObjectStreamersForVSDStruct(); gVSDReader = new TVSDReader(vsd_file_name); TEveManager::Create(); TEveGeoShape *gentle_geom = 0; { // Simple geometry TFile* geom = TFile::Open("http://mtadel.home.cern.ch/mtadel/root/alice_mini_geom.root", "CACHEREAD"); if (!geom) return; TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle"); gentle_geom = TEveGeoShape::ImportShapeExtract(gse, 0); geom->Close(); delete geom; gEve->AddGlobalElement(gentle_geom); } // Standard multi-view //===================== gMultiView = new MultiView; gMultiView->f3DView->GetGLViewer()->SetStyle(TGLRnrCtx::kOutline); gMultiView->SetDepth(-10); gMultiView->ImportGeomRPhi(gentle_geom); gMultiView->ImportGeomRhoZ(gentle_geom); gMultiView->SetDepth(0); // Final stuff //============= gEve->GetViewers()->SwitchColorSet(); gEve->GetDefaultGLViewer()->SetStyle(TGLRnrCtx::kOutline); gEve->GetBrowser()->GetTabRight()->SetTab(1); make_gui(); gEve->AddEvent(new TEveEventManager("Event", "ALICE VSD Event")); gVSDReader->GotoEvent(0); gEve->Redraw3D(kTRUE); // Reset camera after the first event has been shown. } //______________________________________________________________________________ void make_gui() { // Create minimal GUI for event navigation. TEveBrowser* browser = gEve->GetBrowser(); browser->StartEmbedding(TRootBrowser::kLeft); TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600); frmMain->SetWindowName("XX GUI"); frmMain->SetCleanup(kDeepCleanup); TGHorizontalFrame* hf = new TGHorizontalFrame(frmMain); { TString icondir(TString::Format("%s/icons/", gSystem->Getenv("ROOTSYS"))); TGPictureButton* b = 0; b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif")); hf->AddFrame(b); b->Connect("Clicked()", "TVSDReader", gVSDReader, "PrevEvent()"); b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif")); hf->AddFrame(b); b->Connect("Clicked()", "TVSDReader", gVSDReader, "NextEvent()"); } frmMain->AddFrame(hf); frmMain->MapSubwindows(); frmMain->Resize(); frmMain->MapWindow(); browser->StopEmbedding(); browser->SetTabTitle("Event Control", 0); } #endif alice_vsd.C:1 alice_vsd.C:2 alice_vsd.C:3 alice_vsd.C:4 alice_vsd.C:5 alice_vsd.C:6 alice_vsd.C:7 alice_vsd.C:8 alice_vsd.C:9 alice_vsd.C:10 alice_vsd.C:11 alice_vsd.C:12 alice_vsd.C:13 alice_vsd.C:14 alice_vsd.C:15 alice_vsd.C:16 alice_vsd.C:17 alice_vsd.C:18 alice_vsd.C:19 alice_vsd.C:20 alice_vsd.C:21 alice_vsd.C:22 alice_vsd.C:23 alice_vsd.C:24 alice_vsd.C:25 alice_vsd.C:26 alice_vsd.C:27 alice_vsd.C:28 alice_vsd.C:29 alice_vsd.C:30 alice_vsd.C:31 alice_vsd.C:32 alice_vsd.C:33 alice_vsd.C:34 alice_vsd.C:35 alice_vsd.C:36 alice_vsd.C:37 alice_vsd.C:38 alice_vsd.C:39 alice_vsd.C:40 alice_vsd.C:41 alice_vsd.C:42 alice_vsd.C:43 alice_vsd.C:44 alice_vsd.C:45 alice_vsd.C:46 alice_vsd.C:47 alice_vsd.C:48 alice_vsd.C:49 alice_vsd.C:50 alice_vsd.C:51 alice_vsd.C:52 alice_vsd.C:53 alice_vsd.C:54 alice_vsd.C:55 alice_vsd.C:56 alice_vsd.C:57 alice_vsd.C:58 alice_vsd.C:59 alice_vsd.C:60 alice_vsd.C:61 alice_vsd.C:62 alice_vsd.C:63 alice_vsd.C:64 alice_vsd.C:65 alice_vsd.C:66 alice_vsd.C:67 alice_vsd.C:68 alice_vsd.C:69 alice_vsd.C:70 alice_vsd.C:71 alice_vsd.C:72 alice_vsd.C:73 alice_vsd.C:74 alice_vsd.C:75 alice_vsd.C:76 alice_vsd.C:77 alice_vsd.C:78 alice_vsd.C:79 alice_vsd.C:80 alice_vsd.C:81 alice_vsd.C:82 alice_vsd.C:83 alice_vsd.C:84 alice_vsd.C:85 alice_vsd.C:86 alice_vsd.C:87 alice_vsd.C:88 alice_vsd.C:89 alice_vsd.C:90 alice_vsd.C:91 alice_vsd.C:92 alice_vsd.C:93 alice_vsd.C:94 alice_vsd.C:95 alice_vsd.C:96 alice_vsd.C:97 alice_vsd.C:98 alice_vsd.C:99 alice_vsd.C:100 alice_vsd.C:101 alice_vsd.C:102 alice_vsd.C:103 alice_vsd.C:104 alice_vsd.C:105 alice_vsd.C:106 alice_vsd.C:107 alice_vsd.C:108 alice_vsd.C:109 alice_vsd.C:110 alice_vsd.C:111 alice_vsd.C:112 alice_vsd.C:113 alice_vsd.C:114 alice_vsd.C:115 alice_vsd.C:116 alice_vsd.C:117 alice_vsd.C:118 alice_vsd.C:119 alice_vsd.C:120 alice_vsd.C:121 alice_vsd.C:122 alice_vsd.C:123 alice_vsd.C:124 alice_vsd.C:125 alice_vsd.C:126 alice_vsd.C:127 alice_vsd.C:128 alice_vsd.C:129 alice_vsd.C:130 alice_vsd.C:131 alice_vsd.C:132 alice_vsd.C:133 alice_vsd.C:134 alice_vsd.C:135 alice_vsd.C:136 alice_vsd.C:137 alice_vsd.C:138 alice_vsd.C:139 alice_vsd.C:140 alice_vsd.C:141 alice_vsd.C:142 alice_vsd.C:143 alice_vsd.C:144 alice_vsd.C:145 alice_vsd.C:146 alice_vsd.C:147 alice_vsd.C:148 alice_vsd.C:149 alice_vsd.C:150 alice_vsd.C:151 alice_vsd.C:152 alice_vsd.C:153 alice_vsd.C:154 alice_vsd.C:155 alice_vsd.C:156 alice_vsd.C:157 alice_vsd.C:158 alice_vsd.C:159 alice_vsd.C:160 alice_vsd.C:161 alice_vsd.C:162 alice_vsd.C:163 alice_vsd.C:164 alice_vsd.C:165 alice_vsd.C:166 alice_vsd.C:167 alice_vsd.C:168 alice_vsd.C:169 alice_vsd.C:170 alice_vsd.C:171 alice_vsd.C:172 alice_vsd.C:173 alice_vsd.C:174 alice_vsd.C:175 alice_vsd.C:176 alice_vsd.C:177 alice_vsd.C:178 alice_vsd.C:179 alice_vsd.C:180 alice_vsd.C:181 alice_vsd.C:182 alice_vsd.C:183 alice_vsd.C:184 alice_vsd.C:185 alice_vsd.C:186 alice_vsd.C:187 alice_vsd.C:188 alice_vsd.C:189 alice_vsd.C:190 alice_vsd.C:191 alice_vsd.C:192 alice_vsd.C:193 alice_vsd.C:194 alice_vsd.C:195 alice_vsd.C:196 alice_vsd.C:197 alice_vsd.C:198 alice_vsd.C:199 alice_vsd.C:200 alice_vsd.C:201 alice_vsd.C:202 alice_vsd.C:203 alice_vsd.C:204 alice_vsd.C:205 alice_vsd.C:206 alice_vsd.C:207 alice_vsd.C:208 alice_vsd.C:209 alice_vsd.C:210 alice_vsd.C:211 alice_vsd.C:212 alice_vsd.C:213 alice_vsd.C:214 alice_vsd.C:215 alice_vsd.C:216 alice_vsd.C:217 alice_vsd.C:218 alice_vsd.C:219 alice_vsd.C:220 alice_vsd.C:221 alice_vsd.C:222 alice_vsd.C:223 alice_vsd.C:224 alice_vsd.C:225 alice_vsd.C:226 alice_vsd.C:227 alice_vsd.C:228 alice_vsd.C:229 alice_vsd.C:230 alice_vsd.C:231 alice_vsd.C:232 alice_vsd.C:233 alice_vsd.C:234 alice_vsd.C:235 alice_vsd.C:236 alice_vsd.C:237 alice_vsd.C:238 alice_vsd.C:239 alice_vsd.C:240 alice_vsd.C:241 alice_vsd.C:242 alice_vsd.C:243 alice_vsd.C:244 alice_vsd.C:245 alice_vsd.C:246 alice_vsd.C:247 alice_vsd.C:248 alice_vsd.C:249 alice_vsd.C:250 alice_vsd.C:251 alice_vsd.C:252 alice_vsd.C:253 alice_vsd.C:254 alice_vsd.C:255 alice_vsd.C:256 alice_vsd.C:257 alice_vsd.C:258 alice_vsd.C:259 alice_vsd.C:260 alice_vsd.C:261 alice_vsd.C:262 alice_vsd.C:263 alice_vsd.C:264 alice_vsd.C:265 alice_vsd.C:266 alice_vsd.C:267 alice_vsd.C:268 alice_vsd.C:269 alice_vsd.C:270 alice_vsd.C:271 alice_vsd.C:272 alice_vsd.C:273 alice_vsd.C:274 alice_vsd.C:275 alice_vsd.C:276 alice_vsd.C:277 alice_vsd.C:278 alice_vsd.C:279 alice_vsd.C:280 alice_vsd.C:281 alice_vsd.C:282 alice_vsd.C:283 alice_vsd.C:284 alice_vsd.C:285 alice_vsd.C:286 alice_vsd.C:287 alice_vsd.C:288 alice_vsd.C:289 alice_vsd.C:290 alice_vsd.C:291 alice_vsd.C:292 alice_vsd.C:293 alice_vsd.C:294 alice_vsd.C:295 alice_vsd.C:296 alice_vsd.C:297 alice_vsd.C:298 alice_vsd.C:299 alice_vsd.C:300 alice_vsd.C:301 alice_vsd.C:302 alice_vsd.C:303 alice_vsd.C:304 alice_vsd.C:305 alice_vsd.C:306 alice_vsd.C:307 alice_vsd.C:308 alice_vsd.C:309 alice_vsd.C:310 alice_vsd.C:311 alice_vsd.C:312 alice_vsd.C:313 alice_vsd.C:314 alice_vsd.C:315 alice_vsd.C:316 alice_vsd.C:317 alice_vsd.C:318 alice_vsd.C:319 alice_vsd.C:320 alice_vsd.C:321 alice_vsd.C:322 alice_vsd.C:323 alice_vsd.C:324 alice_vsd.C:325 alice_vsd.C:326 alice_vsd.C:327 alice_vsd.C:328 alice_vsd.C:329 alice_vsd.C:330 alice_vsd.C:331 alice_vsd.C:332 alice_vsd.C:333 alice_vsd.C:334 alice_vsd.C:335 alice_vsd.C:336 alice_vsd.C:337 alice_vsd.C:338 alice_vsd.C:339 alice_vsd.C:340 alice_vsd.C:341 alice_vsd.C:342 alice_vsd.C:343 alice_vsd.C:344 alice_vsd.C:345 alice_vsd.C:346 alice_vsd.C:347 alice_vsd.C:348 alice_vsd.C:349 alice_vsd.C:350 alice_vsd.C:351 alice_vsd.C:352 alice_vsd.C:353 alice_vsd.C:354 alice_vsd.C:355 alice_vsd.C:356 alice_vsd.C:357 alice_vsd.C:358 alice_vsd.C:359 alice_vsd.C:360 alice_vsd.C:361 alice_vsd.C:362 alice_vsd.C:363 alice_vsd.C:364 alice_vsd.C:365 alice_vsd.C:366 alice_vsd.C:367 alice_vsd.C:368 alice_vsd.C:369 alice_vsd.C:370 alice_vsd.C:371 alice_vsd.C:372 alice_vsd.C:373 alice_vsd.C:374 alice_vsd.C:375 alice_vsd.C:376 alice_vsd.C:377 alice_vsd.C:378 alice_vsd.C:379 alice_vsd.C:380 alice_vsd.C:381 alice_vsd.C:382 alice_vsd.C:383 alice_vsd.C:384 alice_vsd.C:385 alice_vsd.C:386 alice_vsd.C:387 alice_vsd.C:388 alice_vsd.C:389 alice_vsd.C:390 alice_vsd.C:391 alice_vsd.C:392 alice_vsd.C:393 alice_vsd.C:394 alice_vsd.C:395 alice_vsd.C:396 alice_vsd.C:397 alice_vsd.C:398 alice_vsd.C:399 alice_vsd.C:400 alice_vsd.C:401 alice_vsd.C:402 alice_vsd.C:403 alice_vsd.C:404 alice_vsd.C:405 alice_vsd.C:406 alice_vsd.C:407 alice_vsd.C:408 alice_vsd.C:409 alice_vsd.C:410 alice_vsd.C:411 alice_vsd.C:412 alice_vsd.C:413 alice_vsd.C:414 alice_vsd.C:415 alice_vsd.C:416 alice_vsd.C:417 alice_vsd.C:418 alice_vsd.C:419 alice_vsd.C:420 alice_vsd.C:421 alice_vsd.C:422 alice_vsd.C:423 alice_vsd.C:424 alice_vsd.C:425 |
|