File indexing completed on 2025-01-18 09:14:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DDEve/Calo2DProjection.h>
0016 #include <DDEve/Annotation.h>
0017 #include <DDEve/Factories.h>
0018 #include <DD4hep/InstanceCount.h>
0019
0020
0021 #include <TEveCalo.h>
0022 #include <TEveScene.h>
0023 #include <TGLViewer.h>
0024 #include <TEveArrow.h>
0025
0026 using namespace dd4hep;
0027
0028 ClassImp(Calo2DProjection)
0029 DECLARE_VIEW_FACTORY(Calo2DProjection)
0030
0031
0032 Calo2DProjection::Calo2DProjection(Display* eve, const std::string& nam)
0033 : Projection(eve, nam)
0034 {
0035 InstanceCount::increment(this);
0036 }
0037
0038
0039 Calo2DProjection::~Calo2DProjection() {
0040 InstanceCount::decrement(this);
0041 }
0042
0043
0044 View& Calo2DProjection::Build(TEveWindow* slot) {
0045 CreateGeoScene();
0046 CreateEventScene();
0047 CreateRhoPhiProjection().AddAxis();
0048 AddToGlobalItems(name());
0049 return Map(slot);
0050 }
0051
0052
0053 void Calo2DProjection::ConfigureGeometry(const DisplayConfiguration::ViewConfig& config) {
0054 DisplayConfiguration::Configurations::const_iterator fit;
0055 DisplayConfiguration::Configurations::const_reverse_iterator rit;
0056 float legend_y = Annotation::DefaultTextSize()+Annotation::DefaultMargin();
0057 for(fit = config.subdetectors.begin(); fit != config.subdetectors.end(); ++fit) {
0058 const DisplayConfiguration::Config& cfg = *fit;
0059 if ( cfg.type == DisplayConfiguration::DETELEMENT ) {
0060 TEveElementList& sens = m_eve->GetGeoTopic("Sensitive");
0061 TEveElementList& struc = m_eve->GetGeoTopic("Structure");
0062 for(TEveElementList::List_i i=sens.BeginChildren(); i!=sens.EndChildren(); ++i) {
0063 TEveElementList* ll = dynamic_cast<TEveElementList*>(*i);
0064 if ( ll && cfg.name == ll->GetName() ) {
0065 m_projMgr->ImportElements(*i,m_geoScene);
0066 goto Done;
0067 }
0068 }
0069 for(TEveElementList::List_i i=struc.BeginChildren(); i!=struc.EndChildren(); ++i) {
0070 TEveElementList* ll = dynamic_cast<TEveElementList*>(*i);
0071 if ( ll && cfg.name == ll->GetName() ) {
0072 m_projMgr->ImportElements(*i,m_geoScene);
0073 goto Done;
0074 }
0075 }
0076 Done:
0077 continue;
0078 }
0079 }
0080 float depth = 0.0;
0081 for(rit = config.subdetectors.rbegin(); rit != config.subdetectors.rend(); ++rit) {
0082 const DisplayConfiguration::Config& cfg = *rit;
0083 if ( cfg.type == DisplayConfiguration::CALODATA && cfg.use.empty() ) {
0084 const char* n = cfg.name.c_str();
0085 const Display::CalodataContext& ctx = m_eve->GetCaloHistogram(cfg.name);
0086 const DisplayConfiguration::Calo3D& calo3d = ctx.config.data.calo3d;
0087 TEveCalo2D* calo2d = (TEveCalo2D*)m_projMgr->ImportElements(ctx.calo3D,m_geoScene);
0088 calo2d->SetPlotEt(kFALSE);
0089 calo2d->SetDepth(depth += 1.0);
0090 calo2d->SetAutoRange(kTRUE);
0091 calo2d->SetScaleAbs(kTRUE);
0092 calo2d->SetMainColor(calo3d.color);
0093 calo2d->SetMaxValAbs(calo3d.emax);
0094 calo2d->SetMaxTowerH(calo3d.towerH);
0095 calo2d->SetBarrelRadius(calo3d.rmin);
0096 calo2d->SetEndCapPos(calo3d.dz);
0097 calo2d->InvalidateCellIdCache();
0098 calo2d->AssertCellIdCache();
0099 calo2d->ComputeBBox();
0100 Color_t col = ctx.calo3D->GetDataSliceColor(ctx.slice);
0101 Annotation* a = new Annotation(viewer(),n,Annotation::DefaultMargin(),legend_y,col);
0102 #if 0
0103
0104 TEveArrow* a1 = new TEveArrow(100,100, 100,0., 0., 0.);
0105 a1->SetMainColor(calo3d.color);
0106 a1->SetTubeR(10);
0107 a1->SetPickable(kFALSE);
0108 m_projMgr->ImportElements(a1,m_geoScene);
0109 #endif
0110 legend_y += a->GetTextSize();
0111 printout(INFO,"Calo2DProjection","+++ %s: add detector %s [%s] rmin=%f towerH:%f emax=%f",
0112 name().c_str(),n,ctx.config.hits.c_str(),calo3d.rmin,calo3d.towerH,
0113 calo3d.emax);
0114 }
0115 }
0116 }
0117
0118
0119 void Calo2DProjection::ConfigureEvent(const DisplayConfiguration::ViewConfig& config) {
0120 this->View::ConfigureEvent(config);
0121 }
0122
0123
0124 void Calo2DProjection::ImportGeoTopics(const std::string& ) {
0125 }