#if defined(__CINT__) && !defined(__MAKECINT__) { // Recursion kills CINT!! Info("PMTs_digis.C", "Has to be run in compiled mode ... doing this for you."); gSystem->CompileMacro("PMTs_digis.C"); PMTs_digis(); } #else #include "TGeoManager.h" #include "TGeoNode.h" #include "TGeoVolume.h" #include "TGeoShape.h" #include "TGeoMatrix.h" #include "TEveManager.h" #include "TEveTrans.h" #include "TEveGeoShape.h" #include "TPRegexp.h" #include "TRandom3.h" #include "TStyle.h" #include void find_node_ids(TPMERegexp& regexp, std::vector& ids) { TGeoNode *node = gGeoManager->GetCurrentNode(); TGeoVolume *vol = node->GetVolume(); if (regexp.Match(vol->GetName())) { printf("Adding '%s', id=%d\n", vol->GetName(), gGeoManager->GetCurrentNodeId()); ids.push_back(gGeoManager->GetCurrentNodeId()); } Int_t nd = vol->GetNdaughters(); for (Int_t i = 0; i < nd; ++i) { gGeoManager->CdDown(i); find_node_ids(regexp, ids); gGeoManager->CdUp(); } } const Int_t kMaxSig = 1024; void PMTs_digis() { TEveUtil::AssertMacro("PMTs.C"); // To select volumes by name. // You might have a better way to find them. TPMERegexp pmt_regexp("^Hexagonal PMT"); std::vector pmd_vec; gGeoManager->CdTop(); find_node_ids(pmt_regexp, pmd_vec); // Init Eve TEveManager::Create(); TEveElementList *pmds = new TEveElementList("PMD XXX"); gStyle->SetPalette(1, 0); const Int_t n_palette = gStyle->GetNumberOfColors(); TRandom3 rnd(0); Int_t n_pmds = pmd_vec.size(); for (Int_t i = 0; i < n_pmds; ++i) { gGeoManager->CdNode(pmd_vec[i]); Int_t sig = rnd.Integer(kMaxSig); TEveGeoShape* pmd = new TEveGeoShape(TString::Format("PMD %d", i), TString::Format("PMD %d, signal=%d", i, sig)); pmd->SetMainColor(gStyle->GetColorPalette(sig * n_palette / kMaxSig)); // To make shapes transparent // pmd->SetMainTransparency(40); pmd->SetPickable(kTRUE); pmd->RefMainTrans().SetFrom(*gGeoManager->GetCurrentMatrix()); pmd->SetShape((TGeoShape*) gGeoManager->GetCurrentVolume()->GetShape()->Clone()); pmds->AddElement(pmd); } // Add to default / event scene. gEve->AddElement(pmds); gEve->Redraw3D(kTRUE); } #endif