- rename macro to display TRD digits
authorabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 13 Jul 2010 09:41:33 +0000 (09:41 +0000)
committerabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 13 Jul 2010 09:41:33 +0000 (09:41 +0000)
- update navigation inside TRD detector tree

EVE/EveDet/AliEveTRDModuleImp.cxx
EVE/EveDet/AliEveTRDModuleImp.h
EVE/alice-macros/trd_detectors.C [deleted file]
EVE/alice-macros/trd_digits.C [new file with mode: 0644]

index 657c181..ee6a1f4 100644 (file)
@@ -98,40 +98,40 @@ void AliEveTRDNode::Expand()
 }
 
 //______________________________________________________________________________
-void AliEveTRDNode::EnableListElements()
+void AliEveTRDNode::EnableListElements(Bool_t rnr_self, Bool_t rnr_children)
 {
   // Enable list elements.
 
-  SetRnrSelf(kTRUE);
-  AliEveTRDNode *node = 0x0;
-  AliEveTRDChamber *chmb = 0x0;
+  SetRnrSelf(rnr_self);
+  AliEveTRDNode *node(NULL);
+  AliEveTRDChamber *chmb(NULL);
   List_i iter = fChildren.begin();
   while(iter != fChildren.end()){
     if((node = dynamic_cast<AliEveTRDNode*>(*iter))){
-      node->SetRnrSelf(kTRUE);
-      node->EnableListElements();
+      node->SetRnrSelf(rnr_children);
+      node->EnableListElements(rnr_children, rnr_children);
     }
-    if((chmb = dynamic_cast<AliEveTRDChamber*>(*iter))) chmb->SetRnrSelf(kTRUE);
+    if((chmb = dynamic_cast<AliEveTRDChamber*>(*iter))) chmb->EnableListElements(rnr_children, rnr_children);
     iter++;
   }
   gEve->Redraw3D();
 }
 
 //______________________________________________________________________________
-void AliEveTRDNode::DisableListElements()
+void AliEveTRDNode::DisableListElements(Bool_t rnr_self, Bool_t rnr_children)
 {
   // Disable list elements.
 
-  SetRnrSelf(kFALSE);
-  AliEveTRDNode *node = 0x0;
-  AliEveTRDChamber *chmb = 0x0;
+  SetRnrSelf(rnr_self);
+  AliEveTRDNode *node(NULL);
+  AliEveTRDChamber *chmb(NULL);
   List_i iter = fChildren.begin();
   while(iter != fChildren.end()){
     if((node = dynamic_cast<AliEveTRDNode*>(*iter))){
-      node->SetRnrSelf(kFALSE);
-      node->DisableListElements();
+      node->SetRnrSelf(rnr_children);
+      node->DisableListElements(rnr_children, rnr_children);
     }
-    if((chmb = dynamic_cast<AliEveTRDChamber*>(*iter))) chmb->SetRnrSelf(kFALSE);
+    if((chmb = dynamic_cast<AliEveTRDChamber*>(*iter))) chmb->DisableListElements(rnr_children, rnr_children);
     iter++;
   }
   gEve->Redraw3D();
index 6038e08..5df28ca 100644 (file)
@@ -91,8 +91,8 @@ public:
 
   void Collapse();            // *MENU*
   void Expand();              // *MENU*
-  void EnableListElements();  // *MENU*
-  void DisableListElements(); // *MENU*
+  void EnableListElements(Bool_t rnr_self = kTRUE, Bool_t rnr_children = kTRUE);  // *MENU*
+  void DisableListElements(Bool_t rnr_self = kTRUE, Bool_t rnr_children = kTRUE); // *MENU*
   void UpdateLeaves();
   void UpdateNode();
 
diff --git a/EVE/alice-macros/trd_detectors.C b/EVE/alice-macros/trd_detectors.C
deleted file mode 100644 (file)
index 167c168..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// How to steer the basic TRD data containers from a macro.
-// 
-// The loading and looping over events is performed by the
-// AliEve mechanism. For a stand alone TRD loop control check 
-// the macro "trd_loader.C"
-// 
-// Usage:
-// .x trd_detectors.C(sector)
-// 
-// Author:
-// Alex Bercuci (A.Bercuci@gsi.de)
-// 
-#ifdef __CINT__
-class TEvePointSet;
-class TEveElement;
-#else
-#include <TEveManager.h>
-#include <TEvePointSet.h>
-#include <EveBase/AliEveEventManager.h>
-#include <EveDet/AliEveTRDModuleImp.h>
-
-#include "AliRunLoader.h"
-#include "AliCluster.h"
-#include "TRD/AliTRDcluster.h"
-#include "TRD/AliTRDgeometry.h"
-#include "TRD/AliTRDdigitsManager.h"
-#endif
-
-TEveElementList* trd_detectors(Int_t sector = -1, TEveElement *cont = 0)
-{
-  // Link data containers
-  AliEveEventManager::AssertGeometry();
-
-  AliRunLoader *rl = AliEveEventManager::AssertRunLoader();
-  
-  // define EVE containers
-  TEveElementList *list = new TEveElementList("TRD Detectors");
-  
-  AliEveTRDNode *sm = 0x0, *stk = 0x0; 
-  AliEveTRDChamber *chm=0x0;
-
-  // Link TRD containers
-  TObjArray *clusters = 0x0;
-  rl->LoadRecPoints("TRD");
-  TTree *tR = rl->GetTreeR("TRD", kFALSE);
-  if (!tR) return 0;
-  tR->SetBranchAddress("TRDcluster", &clusters);
-
-  rl->LoadDigits("TRD");
-  TTree *tD = rl->GetTreeD("TRD", kFALSE);
-  AliTRDdigitsManager dm;
-  if (tD) dm.ReadDigits(tD);
-
-  AliTRDgeometry *geo = new AliTRDgeometry();
-  
-  for(Int_t i=0; i<tR->GetEntries(); i++) {
-    if (!tR->GetEvent(i)) continue;
-    if(!clusters->GetEntries()) continue;
-    Int_t icl=0; AliTRDcluster *c = 0x0;
-    while(!(c = (AliTRDcluster*)clusters->UncheckedAt(icl++))) {;}
-    if(!c) continue;
-
-    Int_t idet, ism, istk, ipla; 
-    idet = c->GetDetector();
-    ism  = geo->GetSector(idet);
-    istk = geo->GetStack(idet);
-    ipla = geo->GetLayer(idet);
-    if(sector>=0 && ism != sector) continue;
-    if(!(sm = (AliEveTRDNode*)list->FindChild(Form("SM%03d", ism)))){ 
-      list->AddElement(sm = new AliEveTRDNode("SM", ism));
-      sm->SetElementTitle(Form("Supermodule %2d", ism));
-    }
-    if(!(stk=(AliEveTRDNode*)sm->FindChild(Form("Stack%03d", istk)))){
-      sm->AddElement(stk = new AliEveTRDNode("Stack", istk));
-      stk->SetElementTitle(Form("SM %2d Stack %1d", ism, istk));
-    }
-    stk->AddElement(chm = new AliEveTRDChamber(idet));
-    chm->SetGeometry(geo);
-    chm->LoadClusters(clusters);
-    if (tD) chm->LoadDigits(&dm);
-
-    //clusters->Clear();
-  }
-
-  rl->UnloadDigits("TRD");
-  rl->UnloadRecPoints("TRD");
-
-  gEve->AddElement(list, cont);
-  gEve->Redraw3D();
-
-  return list;
-}
diff --git a/EVE/alice-macros/trd_digits.C b/EVE/alice-macros/trd_digits.C
new file mode 100644 (file)
index 0000000..b7426e9
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// How to steer the basic TRD data containers from a macro.
+// 
+// The loading and looping over events is performed by the
+// AliEve mechanism. For a stand alone TRD loop control check 
+// the macro "trd_loader.C"
+// 
+// Usage:
+// .x trd_detectors.C(sector)
+// 
+// Author:
+// Alex Bercuci (A.Bercuci@gsi.de)
+// 
+#ifdef __CINT__
+class TEvePointSet;
+class TEveElement;
+#else
+#include <TEveManager.h>
+#include <TEvePointSet.h>
+#include <EveBase/AliEveEventManager.h>
+#include <EveDet/AliEveTRDModuleImp.h>
+
+#include "AliRunLoader.h"
+#include "AliCluster.h"
+#include "TRD/AliTRDcluster.h"
+#include "TRD/AliTRDgeometry.h"
+#include "TRD/AliTRDdigitsManager.h"
+#endif
+
+TEveElementList* trd_digits(Int_t sector = -1, TEveElement *cont = 0)
+{
+  // Link data containers
+  AliEveEventManager::AssertGeometry();
+
+  AliRunLoader *rl = AliEveEventManager::AssertRunLoader();
+  
+  // define EVE containers
+  TEveElementList *list = new TEveElementList("TRD Digits");
+  
+  AliEveTRDNode *sm(NULL), *stk(NULL); 
+  AliEveTRDChamber *chm(NULL);
+  // Link TRD digits
+  rl->LoadDigits("TRD");
+  TTree *tD = rl->GetTreeD("TRD", kFALSE);
+  if(!tD){ 
+    Error("trd_digits", "Missing digits tree");
+    return NULL;
+  }
+  AliTRDdigitsManager dm;
+  dm.ReadDigits(tD);
+
+  AliTRDgeometry *geo = new AliTRDgeometry();
+  Int_t sBegin=sector<0?0:sector,
+        sEnd  =sector<0?(AliTRDgeometry::kNsector):sector+1;
+  Int_t jdet(0);
+  for(Int_t isec=sBegin; isec<sEnd; isec++) {
+    sm = new AliEveTRDNode("Sector", isec);
+    for(Int_t istk(0); istk<AliTRDgeometry::kNstack; istk++) {
+      stk = new AliEveTRDNode("Stack", istk);
+      stk->SetTitle(Form("Index %d", isec*AliTRDgeometry::kNstack+istk));
+      for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++) {
+        Int_t det=AliTRDgeometry::GetDetector(ily, istk, isec);
+        if(!(dm.GetDigits(det)->GetDim())) continue;
+        chm=new AliEveTRDChamber(det);
+        chm->SetGeometry(geo);
+        chm->LoadDigits(&dm);
+        stk->AddElement(chm);
+        jdet++;
+      }
+      if(!stk->HasChildren()){
+        delete stk;
+        continue;
+      }
+      sm->AddElement(stk);
+    }
+    if(!sm->HasChildren()){
+      delete sm;
+      continue;
+    }
+    list->AddElement(sm);
+  }
+  rl->UnloadDigits("TRD");
+  gEve->AddElement(list, cont);
+  gEve->Redraw3D();
+
+  Info("trd_digits", Form("TRD chambers with data for current selection %d.", jdet));
+  return list;
+}