New files; macros to demonstrate non-linear projections.
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Jun 2007 09:32:09 +0000 (09:32 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Jun 2007 09:32:09 +0000 (09:32 +0000)
EVE/alice-macros/NLT_demo.C [new file with mode: 0644]
EVE/alice-macros/NLT_geo_demo.C [new file with mode: 0644]

diff --git a/EVE/alice-macros/NLT_demo.C b/EVE/alice-macros/NLT_demo.C
new file mode 100644 (file)
index 0000000..d49f1ce
--- /dev/null
@@ -0,0 +1,33 @@
+// $Id$
+
+void NLT_demo(Int_t type = Reve::NLTProjection::RhoZ, Float_t distortion = 0.)
+{
+  Reve::LoadMacro("alieve_init.C");
+  Reve::LoadMacro("esd_tracks.C");
+  Reve::LoadMacro("its_hits.C");
+  Reve::LoadMacro("NLT_geo_demo.C");
+
+  Reve::NLTProjector* nlt = new  Reve::NLTProjector();
+  nlt->SetProjection(type, distortion);
+
+  // geometry
+  make_geo(nlt);
+
+  // event
+  alieve_init();
+  gReve->DisableRedraw();
+  {
+    // tacks
+    Reve::TrackList* tl  =  esd_tracks();
+    nlt->ProjectTrackList(tl);
+    tl->SetStyle(2);
+    // hits
+    Reve::PointSet* ih = its_hits();
+    nlt->ProjectPointSet(ih);
+  }
+  gReve->EnableRedraw();
+
+  TGLViewer* glv = dynamic_cast<TGLViewer*>(gReve->GetGLCanvas()->GetViewer3D());
+  glv->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
+  gReve->Redraw3D();
+}
diff --git a/EVE/alice-macros/NLT_geo_demo.C b/EVE/alice-macros/NLT_geo_demo.C
new file mode 100644 (file)
index 0000000..e947588
--- /dev/null
@@ -0,0 +1,139 @@
+// $Id$
+
+void NLT_geo_demo(Int_t type = Reve::NLTProjection::CFishEye, Float_t distortion = 0)
+{  
+   Reve::LoadMacro("region_marker.C");
+   region_marker();
+   
+   Reve::NLTProjector* pr = new Reve::NLTProjector();
+   pr->SetProjection(type, distortion);
+
+   make_geo(pr);
+   TGLViewer* glv = dynamic_cast<TGLViewer*>(gReve->GetGLCanvas()->GetViewer3D());
+   glv->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
+}
+
+/**************************************************************************/
+void draw_node(const Text_t* path)
+{
+   gGeoManager->cd(path);
+   TGeoMatrix* mx = gGeoManager->GetCurrentMatrix();
+   
+   Reve::GeoTopNodeRnrEl* currn_re = new Reve::GeoTopNodeRnrEl
+      (gGeoManager, gGeoManager->GetCurrentNode());
+   currn_re->SetGlobalTrans(mx);
+   gReve->AddGlobalRenderElement(currn_re);
+}
+
+/**************************************************************************/
+TBuffer3D* make_buffer(const Text_t* path)
+{
+  TBuffer3D* buff = 0;
+  Bool_t valid = gGeoManager->cd(path);
+  if(valid)  
+  {
+    TBuffer3D* buff = gGeoManager->GetCurrentVolume()->GetShape()->MakeBuffer3D();
+    TGeoMatrix* mx = gGeoManager->GetCurrentMatrix();
+
+    Int_t N = buff->NbPnts();   
+    Double_t* pnts = buff->fPnts;   
+    Double_t  master[4];
+    for(Int_t i = 0; i<N; i++) 
+    {
+      mx->LocalToMaster(&pnts[3*i], master);
+      pnts[3*i] =   master[0];
+      pnts[3*i+1] = master[1];
+      pnts[3*i+2] = master[2];
+    }
+    buff->fColor = gGeoManager->GetCurrentVolume()->GetLineColor();
+  }
+  return buff;
+}
+
+/**************************************************************************/
+Reve::NLTPolygonSet* project_node(Reve::NLTProjector* nlt, const Text_t* path, Int_t useBP)
+{
+  Reve::NLTPolygonSet* ps = 0;
+  TBuffer3D* buff = make_buffer(path); 
+  if(buff) {
+    ps = nlt->ProjectGeoShape(buff, useBP);
+    if(ps)
+    {
+      ps->SetName(Form("NLTPolygonSet %s",path));
+      ps->SetFillColor(Color_t(buff->fColor));
+      ps->SetLineColor((Color_t)TColor::GetColorBright(buff->fColor));
+      //ps->SetLineColor((Color_t)TColor::GetColorDark(buff->fColor));
+    }
+  }
+  return ps;
+}
+
+/**************************************************************************/
+void project_nodes(Reve::NLTProjector* nlt, const Text_t* parent_path, Int_t useBP)
+{
+  gGeoManager->cd(parent_path);
+  TGeoNode* holder = gGeoManager->GetCurrentNode();
+  holder->ls();
+  TIter next_node(holder->GetNodes());
+  TGeoNode* geon;
+
+  Reve::RenderElementList* el = new Reve::RenderElementList(parent_path);
+  gReve->AddGlobalRenderElement(el);
+  while((geon = (TGeoNode*)next_node())) 
+  {
+    TGeoVolume* v = geon->GetVolume();
+    if(v) {      
+      TString path = Form("%s/%s",parent_path, geon->GetName());
+      Reve::NLTPolygonSet* ps = project_node(nlt, path.Data(), useBP);
+      if(ps) {
+       ps->SetName(geon->GetName());
+       gReve->AddGlobalRenderElement(el, ps);
+      }
+    }
+  }
+}
+
+/**************************************************************************/
+void project_to_pointset(Reve::NLTProjector* nlt, const Text_t* path) 
+{  
+  TBuffer3D* buff = make_buffer(path);
+  if(buff)
+  {
+    PointSet* ps = new PointSet(buff->NbPnts());
+    ps->SetMarkerColor(buff->fColor);
+    for(Int_t i = 0; i<buff->NbPnts() ; i++)
+      ps->SetPoint(i,  buff->fPnts[3*i], buff->fPnts[3*i+1], buff->fPnts[3*i+2]);
+   
+    PointSet* pps = nlt->ProjectPointSet(ps);
+    gReve->AddGlobalRenderElement(pps);
+  }
+}
+/**************************************************************************/
+void make_geo(Reve::NLTProjector* nlt)
+{
+  gGeoManager = gReve->GetGeometry("$REVESYS/alice-data/simple_geo.root");
+  Int_t useBuffPols = -1;
+  Reve::NLTPolygonSet* ps;
+
+  project_nodes( nlt, "/ALIC_1/ITSV_holder_1/ITSV_1", useBuffPols);
+  ps = project_node( nlt, "/ALIC_1/TPC_holder_1/TPC_1/TDGN_1", useBuffPols);
+  if(ps) gReve->AddGlobalRenderElement(ps);
+  ps = project_node(nlt, "/ALIC_1/TRD TOF_holder_1/B077_1", useBuffPols);
+  if(ps) gReve->AddGlobalRenderElement(ps);
+  ps = project_node(nlt, "/ALIC_1/TRD TOF_holder_1/BRS4_1", useBuffPols);
+  if(ps) gReve->AddGlobalRenderElement(ps);
+  ps = project_node(nlt, "/ALIC_1/TRD TOF_holder_1/BRS4_2", useBuffPols);
+  if(ps) gReve->AddGlobalRenderElement(ps);
+  ps = project_node(nlt, "/ALIC_1/TRD TOF_holder_1/BFMO_1", useBuffPols);
+  if(ps) gReve->AddGlobalRenderElement(ps);
+  ps = project_node(nlt, "/ALIC_1/TRD TOF_holder_1/BBMO_1", useBuffPols);
+  if(ps) gReve->AddGlobalRenderElement(ps);
+
+  for(Int_t i = 1; i<6; i++) {
+    ps = project_node(nlt, Form("/ALIC_1/PHOS_holder_1/PHOS_%d", i), useBuffPols);
+    ps->SetFillColor((Color_t)(kOrange-4));
+    if(ps) gReve->AddGlobalRenderElement(ps);
+  }
+  project_nodes( nlt, "/ALIC_1/FMD_holder_1", useBuffPols);  
+  project_nodes( nlt, "/ALIC_1/RICH_holder_1", useBuffPols);
+}