Avoid usage of script-global variables as they get reset on exceptions; rely on stati...
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 19 Jan 2007 16:52:11 +0000 (16:52 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 19 Jan 2007 16:52:11 +0000 (16:52 +0000)
EVE/macros/trackcount_init.C

index 8da5676f29ac9f302ce68f8167c14e8b84302c5a..c7073812b8132b269cb1f2762137d39c0e41e1a5 100644 (file)
@@ -1,5 +1,3 @@
-Reve::TrackCounter* g_trkcnt = 0;
-
 void trackcount_init()
 {
   Reve::LoadMacro("alieve_init.C");
 void trackcount_init()
 {
   Reve::LoadMacro("alieve_init.C");
@@ -13,7 +11,7 @@ void trackcount_init()
     // glv->SetOrthoCamera(TGLViewer::kCameraOrthoZOY, -22, 22, 22, -22);
   }
 
     // glv->SetOrthoCamera(TGLViewer::kCameraOrthoZOY, -22, 22, 22, -22);
   }
 
-  g_trkcnt = new Reve::TrackCounter("Primary Counter");
+  Reve::TrackCounter* g_trkcnt = new Reve::TrackCounter("Primary Counter");
   gReve->AddGlobalRenderElement(g_trkcnt);
 
   Alieve::gEvent->AddNewEventCommand("on_new_event();");
   gReve->AddGlobalRenderElement(g_trkcnt);
 
   Alieve::gEvent->AddNewEventCommand("on_new_event();");
@@ -41,8 +39,7 @@ void on_new_event()
   // First two have reasonable primaries (sigma-to-prim-vertex < 5).
   // Other three are almost certainly secondaries.
   Int_t count = 1;
   // First two have reasonable primaries (sigma-to-prim-vertex < 5).
   // Other three are almost certainly secondaries.
   Int_t count = 1;
-  if (g_trkcnt == 0) // This sometimes happens; linked to macro execution, cint reset.
-    g_trkcnt = Reve::TrackCounter::fgInstance;
+  Reve::TrackCounter* g_trkcnt = Reve::TrackCounter::fgInstance;
   g_trkcnt->Reset();
   g_trkcnt->SetEventId(Alieve::gEvent->GetEventId());
   Reve::RenderElement::List_i i = cont->BeginChildren();
   g_trkcnt->Reset();
   g_trkcnt->SetEventId(Alieve::gEvent->GetEventId());
   Reve::RenderElement::List_i i = cont->BeginChildren();