//<<<<<< INCLUDES >>>>>> #include "Utilities/Configuration/interface/Architecture.h" #include "VisOrca/VisCustomTracker/interface/VisCuTkSimHitsTwig.h" #include "Ig_Modules/Ig3DModel/interface/Ig3DRep.h" #include "Ig_Modules/IgTextModel/interface/IgTextRep.h" #include "Tracker/TkLayout/interface/FullTracker.h" #include "Tracker/TkLayout/interface/CmsTracker.h" #include "CommonDet/BasicDet/interface/SimHit.h" #include "CommonDet/BasicDet/interface/DetUnit.h" #include "CommonDet/BasicDet/interface/DetType.h" #include "CommonDet/BasicDet/interface/SimDet.h" #include "CommonDet/DetLayout/interface/DetLayer.h" #include "ClassReuse/GeomVector/interface/GlobalPoint.h" #include #include #include #include #include #include #include //<<<<<< PRIVATE DEFINES >>>>>> //<<<<<< PRIVATE CONSTANTS >>>>>> //<<<<<< PRIVATE TYPES >>>>>> //<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> //<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> //<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> //<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> //<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> //<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> /** Initialise the tracker sim hits twig. */ VisCuTkSimHitsTwig::VisCuTkSimHitsTwig (IgState *state, IgTwig *parent) : VisG3EventObserverTwig (state, parent, "Sim Hits") { } /** Update object property description. */ void VisCuTkSimHitsTwig::update (IgTextRep *rep) { // Get debugging dump. VisG3EventObserverTwig::update (rep); // Prepare the property description. std::ostringstream text; text << "Sim Hits
"; int nTkBPixel = 0; int nTkFPixel = 0; int nTkBSilicon = 0; int nTkFSilicon = 0; const CmsTracker::LayerContainer& al = FullTracker::instance ()->allLayers (); CmsTracker::LayerIterator ilayer; for (ilayer = al.begin(); ilayer != al.end(); ilayer++) { Det::DetUnitContainer theDetUnits = (*ilayer).detUnits (); for (Det::DetUnitContainer::const_iterator idet = theDetUnits.begin (); idet != theDetUnits.end (); idet++) { const SimDet* simDetP = (**idet).simDet (); if (simDetP != 0) { for (SimDet::SimHitIterator ihit = simDetP->simHits ().begin (); ihit != simDetP->simHits().end(); ihit++) { if (ilayer->module () == pixel) { if (ilayer->part () == barrel) { nTkBPixel++; } else if (ilayer->part () == forward) { nTkFPixel++; } } else if (ilayer->module () == silicon) { if (ilayer->part() == barrel) { nTkBSilicon++; } else if (ilayer->part () == forward) { nTkFSilicon++; } } } } else { text << "Warning: DetUnit does not have a SimDet" << endl; } } } text << "Tracker SimHits: " << nTkBPixel << "/" << nTkFPixel << "(Pixel barrel/forward) " << nTkBSilicon << "/" << nTkFSilicon << "(Silicon barrel/forward)" << endl; // Send it over. qApp->lock (); rep->setText (text.str ()); qApp->unlock (false); } /** Update object property description. */ void VisCuTkSimHitsTwig::update (Ig3DRep *rep) { // Get debugging dump. VisG3EventObserverTwig::update (rep); qApp->lock (); // Define material // --------------- SoSeparator *simHitsSep = new SoSeparator; SoMaterial *simHitMat = new SoMaterial; simHitMat->diffuseColor.setValue (0.0, 0.0, 1.0); // blue colour simHitsSep->addChild (simHitMat); SoSeparator *level1Sep = new SoSeparator; SoDrawStyle *level1DrawStyle = new SoDrawStyle; level1DrawStyle->pointSize = 2.0; level1Sep->addChild (level1DrawStyle); SoSeparator *level2Sep = new SoSeparator; SoDrawStyle *level2DrawStyle = new SoDrawStyle; level2DrawStyle->pointSize = 1.0; level2Sep->addChild (level2DrawStyle); SoLevelOfDetail *lod = new SoLevelOfDetail; simHitsSep->addChild (lod); lod->screenArea.set1Value (0, 110000.); lod->screenArea.set1Value (1, 1000.); lod->addChild (level1Sep); lod->addChild (level2Sep); // Count up total number of SimHit's // --------------------------------- int nSimHits = 0; int nVrx = 0; const CmsTracker::DetContainer& dets = FullTracker::instance ()->dets (); CmsTracker::DetIterator iDet; SoVertexProperty *verticies = new SoVertexProperty; for (iDet = dets.begin (); iDet != dets.end (); iDet++) { SimDet *simDet = iDet->simDet (); if (simDet && !simDet->simHits ().empty ()) { const SimDet::SimHitContainer& sits = simDet->simHits (); for (SimDet::SimhitIterator is = sits.begin (); is != sits.end (); is++) { float x = (*is).globalPosition ().x () / 100.0; // cm -> m float y = (*is).globalPosition ().y () / 100.0; // cm -> m float z = (*is).globalPosition ().z () / 100.0; // cm -> m verticies->vertex.set1Value (nVrx, SbVec3f (x, y, z)); nVrx++; } nSimHits += sits.size (); } } verticies->vertex.setNum (nSimHits); if (nSimHits > 0) { SoPointSet *points = new SoPointSet; points->vertexProperty.setValue (verticies); points->numPoints.setValue (nSimHits); level1Sep->addChild (points); level2Sep->addChild (points); } // Send it over. rep->clear (); rep->node ()->addChild (simHitsSep); qApp->unlock (false); }