Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:11

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework include files
0015 #include <DDEve/CaloLego.h>
0016 #include <DDEve/Annotation.h>
0017 #include <DDEve/Factories.h>
0018 #include <DD4hep/InstanceCount.h>
0019 
0020 // Root include files
0021 #include <TH2.h>
0022 #include <TEveCalo.h>
0023 #include <TEveTrans.h>
0024 #include <TEveScene.h>
0025 #include <TGLViewer.h>
0026 #include <TGLWidget.h>
0027 #include <TEveCaloLegoOverlay.h>
0028 #include <TEveLegoEventHandler.h>
0029 
0030 // C/C++ include files
0031 #include <limits>
0032 
0033 using namespace dd4hep;
0034 
0035 ClassImp(CaloLego)
0036 DECLARE_VIEW_FACTORY(CaloLego)
0037 
0038 /// Initializing constructor
0039 CaloLego::CaloLego(Display* eve, const std::string& nam)
0040 : View(eve, nam)
0041 {
0042   InstanceCount::increment(this);
0043 }
0044 
0045 /// Default destructor
0046 CaloLego::~CaloLego()  {
0047   InstanceCount::decrement(this);
0048 }
0049 
0050 
0051 /// Build the projection view and map it to the given slot
0052 View& CaloLego::Build(TEveWindow* slot)   {
0053   CreateGeoScene();
0054   AddToGlobalItems(name());
0055   return Map(slot);
0056 }
0057 
0058 /// Configure a single geometry view
0059 void CaloLego::ConfigureGeometry(const DisplayConfiguration::ViewConfig& config)    {
0060   DisplayConfiguration::Configurations::const_iterator j = config.subdetectors.begin();
0061   Display::CalodataContext& ctx = m_data;
0062   float legend_y = Annotation::DefaultTextSize()+Annotation::DefaultMargin();
0063 
0064   ctx.eveHist = new TEveCaloDataHist();
0065   for( ; j != config.subdetectors.end(); ++j )   {
0066     const char* n = (*j).name.c_str();
0067     Display::CalodataContext& calo = m_eve->GetCaloHistogram(n);
0068     DisplayConfiguration::Calodata& cd = calo.config.data.calodata;
0069     if ( calo.config.use.empty() )  {
0070       for(int isl = 0; isl<calo.eveHist->GetNSlices(); ++isl)  {
0071     int nslice = ctx.eveHist->GetNSlices();
0072     TH2F* h = new TH2F(*calo.eveHist->GetHist(isl));
0073     ctx.eveHist->AddHistogram(h);
0074     ctx.eveHist->RefSliceInfo(nslice).Setup(n,cd.threshold,cd.color,101);
0075     Annotation* a = new Annotation(viewer(),n,Annotation::DefaultMargin(),legend_y,cd.color);
0076     legend_y += a->GetTextSize();
0077       }
0078     }
0079   }
0080   TEveCaloLego* lego = new TEveCaloLego(ctx.eveHist);
0081   ImportGeo(lego);
0082   ctx.caloViz = lego;
0083   ctx.caloViz->SetPlotEt(kFALSE);
0084   // By the default lego extends is (1x1x1). Resize it to put in 'natural' 
0085   // coordinates, so that y extend in 2*Pi and set height of lego two times
0086   //  smaller than y extend to have better view in 3D perspective.
0087   lego->InitMainTrans();
0088   lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
0089 
0090   // draws scales and axis on borders of window
0091   TGLViewer* glv = viewer()->GetGLViewer();
0092   TEveCaloLegoOverlay* overlay = new TEveCaloLegoOverlay();
0093   glv->AddOverlayElement(overlay);
0094   overlay->SetCaloLego(lego);
0095   
0096   // set event handler to move from perspective to orthographic view.
0097   glv->SetEventHandler(new TEveLegoEventHandler(glv->GetGLWidget(), glv, lego));
0098   glv->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
0099   ctx.eveHist->GetEtaBins()->SetTitleFont(120);
0100   ctx.eveHist->GetEtaBins()->SetTitle("h");
0101   ctx.eveHist->GetPhiBins()->SetTitleFont(120);
0102   ctx.eveHist->GetPhiBins()->SetTitle("f");
0103   ctx.eveHist->IncDenyDestroy();
0104   ctx.eveHist->DataChanged();
0105 }
0106 
0107 /// Configure a single event scene view
0108 void CaloLego::ConfigureEvent(const DisplayConfiguration::ViewConfig& config)  {
0109   DisplayConfiguration::Configurations::const_iterator j = config.subdetectors.begin();
0110   printout(INFO,"CaloLego","+++ Import geometry topics for view %s.",name().c_str());
0111   for(int ihist=0; j != config.subdetectors.end(); ++j)   {
0112     const char* n = (*j).name.c_str();
0113     const Display::CalodataContext& ctx = m_eve->GetCaloHistogram(n);
0114     if ( ctx.config.use.empty() )  {
0115       for(int isl = 0; isl<ctx.eveHist->GetNSlices(); ++isl)  {
0116     TH2F* global = ctx.eveHist->GetHist(isl);
0117     TH2F* local  = m_data.eveHist->GetHist(ihist);
0118     *local = *global;
0119     ihist++;
0120       }
0121     }
0122   }
0123   m_data.eveHist->DataChanged();
0124 }
0125 
0126 /// Call to import geometry topics
0127 void CaloLego::ImportGeoTopics(const std::string&)   {
0128 }