示例#1
0
//______________________________________________________________________________
void alice_esd_split(Bool_t auto_size=kFALSE)
{
   // 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(".");

   if (!alice_esd_loadlib(esd_file_name, "aliesd"))
   {
      Error("alice_esd", "Can not load project libraries.");
      return;
   }

   printf("*** Opening ESD ***\n");
   esd_file = TFile::Open(esd_file_name, "CACHEREAD");
   if (!esd_file)
      return;

   printf("*** Opening ESD-friends ***\n");
   esd_friends_file = TFile::Open(esd_friends_file_name, "CACHEREAD");
   if (!esd_friends_file)
      return;

   esd_tree = (TTree*) esd_file->Get("esdTree");

   esd = (AliESDEvent*) esd_tree->GetUserInfo()->FindObject("AliESDEvent");

   // Set the branch addresses.
   {
      TIter next(esd->fESDObjects);
      TObject *el;
      while ((el=(TNamed*)next()))
      {
         TString bname(el->GetName());
         if(bname.CompareTo("AliESDfriend")==0)
         {
            // AliESDfriend needs some '.' magick.
            esd_tree->SetBranchAddress("ESDfriend.", esd->fESDObjects->GetObjectRef(el));
         }
         else
         {
            esd_tree->SetBranchAddress(bname, esd->fESDObjects->GetObjectRef(el));
         }
      }
   }

   TEveManager::Create();

   // Adapt the main frame to the screen size...
   if (auto_size)
   {
      Int_t qq; 
      UInt_t ww, hh;
      gVirtualX->GetWindowSize(gVirtualX->GetDefaultRootWindow(), qq, qq, ww, hh);
      Float_t screen_ratio = (Float_t)ww/(Float_t)hh;
      if (screen_ratio > 1.5) {
         gEve->GetBrowser()->MoveResize(100, 50, ww - 300, hh - 100);
      } else {
         gEve->GetBrowser()->Move(50, 50);
      }
   }

   { // Simple geometry
      TFile* geom = TFile::Open(esd_geom_file_name, "CACHEREAD");
      if (!geom)
         return;
      TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle");
      gGeoShape = TEveGeoShape::ImportShapeExtract(gse, 0);
      geom->Close();
      delete geom;
      gEve->AddGlobalElement(gGeoShape);
   }

   make_gui();

   // import the geometry in the projection managers
   if (gRPhiMgr) {
      TEveProjectionAxes* a = new TEveProjectionAxes(gRPhiMgr);
      a->SetNdivisions(3);
      gEve->GetScenes()->FindChild("R-Phi Projection")->AddElement(a);
      gRPhiMgr->ImportElements(gGeoShape);
   }
   if (gRhoZMgr) {
      TEveProjectionAxes* a = new TEveProjectionAxes(gRhoZMgr);
      a->SetNdivisions(3);
      gEve->GetScenes()->FindChild("Rho-Z Projection")->AddElement(a);
      gRhoZMgr->ImportElements(gGeoShape);
   }

   load_event();

   update_projections();
   
   gEve->Redraw3D(kTRUE); // Reset camera after the first event has been shown.
}
//______________________________________________________________________________
void alice_esd()
{
   // 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.

   const TString weh("alice_esd()");

   if (gROOT->LoadMacro("MultiView.C+") != 0)
   {
      Error(weh, "Failed loading MultiView.C in compiled mode.");
      return;
   }

   TFile::SetCacheFileDir(".");

   if (!alice_esd_loadlib("aliesd"))
   {
      Error("alice_esd", "Can not load project libraries.");
      return;
   }

   printf("*** Opening ESD ***\n");
   esd_file = TFile::Open(esd_file_name, "CACHEREAD");
   if (!esd_file)
      return;

   esd_tree = (TTree*)       esd_file->Get("esdTree");
   esd      = (AliESDEvent*) esd_tree->GetUserInfo()->FindObject("AliESDEvent");
   esd_objs = esd->fESDObjects;

   if (esd_friends_file_name != 0)
   {
      printf("*** Opening ESD-friends ***\n");
      esd_friends_file = TFile::Open(esd_friends_file_name, "CACHEREAD");
      if (!esd_friends_file)
         return;

      esd_tree->SetBranchStatus ("ESDfriend*", 1);
   }

   // Set the branch addresses.
   {
      TIter next(esd_objs);
      TObject *el;
      while ((el = (TNamed*)next()))
      {
         TString bname(el->GetName());
         if (bname == "AliESDfriend")
         {
            // AliESDfriend needs special treatment.
            TBranch *br = esd_tree->GetBranch("ESDfriend.");
            br->SetAddress(esd_objs->GetObjectRef(el));
         }
         else
         {
            TBranch *br = esd_tree->GetBranch(bname);
            if (br)
            {
               br->SetAddress(esd_objs->GetObjectRef(el));
            }
            else
            {
               br = esd_tree->GetBranch(bname + ".");
               if (br)
               {
                  br->SetAddress(esd_objs->GetObjectRef(el));
               }
               else
               {
                  Warning("AliESDEvent::ReadFromTree() "
                          "No Branch found with Name '%s' or '%s.'.",
                          bname.Data(),bname.Data());
               }
            }
         }
      }
   }


   TEveManager::Create();

   { // Simple geometry
      TFile* geom = TFile::Open(esd_geom_file_name, "CACHEREAD");
      if (!geom)
         return;
      TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle");
      gGeomGentle = TEveGeoShape::ImportShapeExtract(gse, 0);
      geom->Close();
      delete geom;
      gEve->AddGlobalElement(gGeomGentle);
   }


   // Standard multi-view
   //=====================

   gMultiView = new MultiView;

   gMultiView->ImportGeomRPhi(gGeomGentle);
   gMultiView->ImportGeomRhoZ(gGeomGentle);


   // HTML summary view
   //===================

   gROOT->LoadMacro("alice_esd_html_summary.C");
   fgHtmlSummary = new HtmlSummary("Alice Event Display Summary Table");
   slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
   fgHtml = new TGHtml(0, 100, 100);
   TEveWindowFrame *wf = slot->MakeFrame(fgHtml);
   fgHtml->MapSubwindows();
   wf->SetElementName("Summary");


   // Final stuff
   //=============

   gEve->GetBrowser()->GetTabRight()->SetTab(1);

   make_gui();

   load_event();

   gEve->Redraw3D(kTRUE); // Reset camera after the first event has been shown.
}