CMS 3D CMS Logo

Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes

FWTrackHitsDetailView Class Reference

#include <FWTrackHitsDetailView.h>

Inheritance diagram for FWTrackHitsDetailView:
FWDetailViewGL< reco::Track > CSGActionSupervisor FWDetailView< reco::Track > FWDetailViewBase

List of all members.

Public Member Functions

 FWTrackHitsDetailView ()
void pickCameraCenter ()
void rnrLabels ()
virtual void setBackgroundColor (Color_t)
void transparencyChanged (int)
virtual ~FWTrackHitsDetailView ()

Protected Attributes

TEveElementList * m_hits
TEveElementList * m_moduleLabels
TEveElementList * m_modules
TGSlider * m_slider
FWIntValueListenerm_sliderListener

Private Member Functions

void addHits (const reco::Track &track, const FWEventItem *iItem, TEveElement *trkList, bool addNearbyHits)
void addModules (const reco::Track &track, const FWEventItem *iItem, TEveElement *trkList, bool addLostHits)
void addTrackerHits3D (std::vector< TVector3 > &points, class TEveElementList *tList, Color_t color, int size)
void build (const FWModelId &id, const reco::Track *)
 FWTrackHitsDetailView (const FWTrackHitsDetailView &)
void makeLegend (void)
const FWTrackHitsDetailViewoperator= (const FWTrackHitsDetailView &)
void setTextInfo (const FWModelId &id, const reco::Track *)

Private Attributes

TLegend * m_legend

Detailed Description

Definition at line 17 of file FWTrackHitsDetailView.h.


Constructor & Destructor Documentation

FWTrackHitsDetailView::FWTrackHitsDetailView ( )

Definition at line 40 of file FWTrackHitsDetailView.cc.

FWTrackHitsDetailView::~FWTrackHitsDetailView ( ) [virtual]

Definition at line 49 of file FWTrackHitsDetailView.cc.

{
}
FWTrackHitsDetailView::FWTrackHitsDetailView ( const FWTrackHitsDetailView ) [private]

Member Function Documentation

void FWTrackHitsDetailView::addHits ( const reco::Track track,
const FWEventItem iItem,
TEveElement *  trkList,
bool  addNearbyHits 
) [private]

Definition at line 318 of file FWTrackHitsDetailView.cc.

References fireworks::addSiStripClusters(), addTrackerHits3D(), FWDisplayProperties::color(), FWEventItem::defaultDisplayProperties(), fireworks::pushNearbyPixelHits(), fireworks::pushPixelHits(), and RecoTauPiZeroBuilderPlugins_cfi::strips.

Referenced by build().

{
   std::vector<TVector3> pixelPoints;
   fireworks::pushPixelHits( pixelPoints, *iItem, track );
   TEveElementList* pixels = new TEveElementList( "Pixels" );
   trkList->AddElement( pixels );
   if( addNearbyHits )
   {
      // get the extra hits
      std::vector<TVector3> pixelExtraPoints;
      fireworks::pushNearbyPixelHits( pixelExtraPoints, *iItem, track );
      // draw first the others
      addTrackerHits3D( pixelExtraPoints, pixels, kRed, 1 );
      // then the good ones, so they're on top
      addTrackerHits3D( pixelPoints, pixels, kGreen, 1 );
   }
   else
   {
      // just add those points with the default color
      addTrackerHits3D( pixelPoints, pixels, iItem->defaultDisplayProperties().color(), 1 );
   }

   // strips
   TEveElementList* strips = new TEveElementList( "Strips" );
   trkList->AddElement( strips );
   fireworks::addSiStripClusters( iItem, track, strips, addNearbyHits, false );
}
void FWTrackHitsDetailView::addModules ( const reco::Track track,
const FWEventItem iItem,
TEveElement *  trkList,
bool  addLostHits 
) [private]

Definition at line 352 of file FWTrackHitsDetailView.cc.

References TrackingRecHit::bad, PXFDetId::blade(), FWDisplayProperties::color(), MuonSubdetId::CSC, FWEventItem::defaultDisplayProperties(), DetId::det(), cond::rpcobgas::detid, PXFDetId::disk(), MuonSubdetId::DT, DTChamberId, fwLog, FWGeometry::getEveShape(), FWEventItem::getGeom(), TrackingRecHit::inactive, info, fwlog::kInfo, PXBDetId::ladder(), PXBDetId::layer(), TrackingRecHit::missing, PXFDetId::module(), PXBDetId::module(), DetId::Muon, mergeVDriftHistosByStation::name, PXFDetId::panel(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, DetId::rawId(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), MuonSubdetId::RPC, edm::second(), PXFDetId::side(), DetId::subdetId(), SiStripDetId::TEC, SiStripDetId::TIB, SiStripDetId::TID, SiStripDetId::TOB, DetId::Tracker, and TrackingRecHit::valid.

Referenced by build().

{
   std::set<unsigned int> ids;
   for( trackingRecHit_iterator recIt = track.recHitsBegin(), recItEnd = track.recHitsEnd();
        recIt != recItEnd; ++recIt )
   {
      DetId detid = (*recIt)->geographicalId();
      if( !addLostHits && !(*recIt)->isValid()) continue;
      if( detid.rawId() != 0 )
      {
         TString name("");
         switch( detid.det())
         {
         case DetId::Tracker:
            switch( detid.subdetId())
            {
            case SiStripDetId::TIB:
               name = "TIB ";
               break;
            case SiStripDetId::TOB:
               name = "TOB ";
               break;
            case SiStripDetId::TID:
               name = "TID ";
               break;
            case SiStripDetId::TEC:
               name = "TEC ";
               break;
            case PixelSubdetector::PixelBarrel:
               name = "Pixel Barrel ";
               { 
                  PXBDetId idid = PXBDetId( detid.rawId() );
                  unsigned int layer = idid.layer();
                  unsigned int ladder = idid.ladder();
                  unsigned int module = idid.module();

                  name += TString::Format( ": Layer=%u, Ladder=%u, Module=%u \n",
                                           layer, ladder, module );
               }
               break;
            case PixelSubdetector::PixelEndcap:
               name = "Pixel Endcap ";
               {    
                  PXFDetId idid = PXFDetId( detid.rawId() );
                  unsigned int side = idid.side();
                  unsigned int disk = idid.disk();
                  unsigned int blade = idid.blade();
                  unsigned int panel = idid.panel();
                  unsigned int module = idid.module();

                  name += TString::Format( ": Side=%u, Disk=%u, Blade=%u, Panel=%u, Module=%u \n",
                                           side, disk, blade, panel, module );
               }
                
            default:
               break;
            }
            break;
            
         case DetId::Muon:
            switch( detid.subdetId())
            {
            case MuonSubdetId::DT:
               name = "DT";
               detid = DetId( DTChamberId( detid )); // get rid of layer bits
               break;
            case MuonSubdetId::CSC:
               name = "CSC";
               break;
            case MuonSubdetId::RPC:
               name = "RPC";
               break;
            default:
               break;
            }
            break;
         default:
            break;
         }
         if( ! ids.insert( detid.rawId()).second ) continue;
         if( iItem->getGeom())
         {
            TEveGeoShape* shape = iItem->getGeom()->getEveShape( detid );
            if( 0 != shape )
            {
               shape->SetMainTransparency( 65 );
               shape->SetPickable( kTRUE );
               switch(( *recIt )->type())
               {
               case TrackingRecHit::valid:
                  shape->SetMainColor( iItem->defaultDisplayProperties().color());
                  break;
               case TrackingRecHit::missing:
                  name += "LOST ";
                  shape->SetMainColor( kRed );
                  break;
               case TrackingRecHit::inactive:
                  name += "INACTIVE ";
                  shape->SetMainColor( 28 );
                  break;
               case TrackingRecHit::bad:
                  name += "BAD ";
                  shape->SetMainColor( 218 );
                  break;
               }
               shape->SetTitle( name + ULong_t( detid.rawId()));
               trkList->AddElement( shape );
            }
            else
            {
               fwLog( fwlog::kInfo ) <<  "Failed to get shape extract for a tracking rec hit: "
                                     << "\n" << fireworks::info( detid ) << std::endl;
            }
         }
      }
   }
}
void FWTrackHitsDetailView::addTrackerHits3D ( std::vector< TVector3 > &  points,
class TEveElementList *  tList,
Color_t  color,
int  size 
) [private]

Definition at line 299 of file FWTrackHitsDetailView.cc.

Referenced by addHits().

{
   // !AT this is  detail view specific, should move to track hits
   // detail view

   TEvePointSet* pointSet = new TEvePointSet();
   pointSet->SetMarkerSize(size);
   pointSet->SetMarkerStyle(4);
   pointSet->SetPickable(kTRUE);
   pointSet->SetTitle("Pixel Hits");
   pointSet->SetMarkerColor(color);
                
   for( std::vector<TVector3>::const_iterator it = points.begin(), itEnd = points.end(); it != itEnd; ++it) {
      pointSet->SetNextPoint(it->x(), it->y(), it->z());
   }
   tList->AddElement(pointSet);
}
void FWTrackHitsDetailView::build ( const FWModelId id,
const reco::Track track 
) [private, virtual]

Implements FWDetailView< reco::Track >.

Definition at line 54 of file FWTrackHitsDetailView.cc.

References alignCSCRings::action, CSGAction::activated, addHits(), addModules(), b, dtNoiseDBValidation_cfg::cerr, FWDetailViewBase::context(), CSGAction::createTextButton(), end, reco::Track::extra(), f, i, FWDetailViewBase::item(), FWDetailViewGL< reco::Track >::m_eveScene, FWDetailViewGL< reco::Track >::m_guiFrame, m_hits, m_moduleLabels, m_modules, m_slider, m_sliderListener, makeLegend(), mergeVDriftHistosByStation::name, AlCaHLTBitMon_ParallelJobs::p, pickCameraCenter(), fireworks::prepareTrack(), rnrLabels(), setTextInfo(), CSGAction::setToolTip(), runonSM::text, transparencyChanged(), FWIntValueListener::valueChanged_, and FWDetailViewGL< reco::Track >::viewerGL().

{      
   {
      TGCompositeFrame* f  = new TGVerticalFrame(m_guiFrame);
      m_guiFrame->AddFrame(f);
      f->AddFrame(new TGLabel(f, "Module Transparency:"), new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
      m_slider = new TGHSlider(f, 120, kSlider1 | kScaleNo);
      f->AddFrame(m_slider, new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 1, 4));
      m_slider->SetRange(0, 100);
      m_slider->SetPosition(75);

      m_sliderListener =  new FWIntValueListener();
      TQObject::Connect(m_slider, "PositionChanged(Int_t)", "FWIntValueListenerBase",  m_sliderListener, "setValue(Int_t)");
      m_sliderListener->valueChanged_.connect(boost::bind(&FWTrackHitsDetailView::transparencyChanged,this,_1));
   }

   {
      CSGAction* action = new CSGAction(this, "Show Module Labels");
      TGCheckButton* b = new TGCheckButton(m_guiFrame, "Show Module Labels" );
      b->SetState(kButtonUp, false);
      m_guiFrame->AddFrame(b, new TGLayoutHints( kLHintsNormal, 2, 3, 1, 4));
      TQObject::Connect(b, "Clicked()", "CSGAction", action, "activate()");
      action->activated.connect(sigc::mem_fun(this, &FWTrackHitsDetailView::rnrLabels));
   }
   {
      CSGAction* action = new CSGAction(this, " Pick Camera Center ");
      action->createTextButton(m_guiFrame, new TGLayoutHints( kLHintsNormal, 2, 0, 1, 4));
      action->setToolTip("Click on object in viewer to set camera center.");
      action->activated.connect(sigc::mem_fun(this, &FWTrackHitsDetailView::pickCameraCenter));
   }
   makeLegend();
   
   TGCompositeFrame* p = (TGCompositeFrame*)m_guiFrame->GetParent();
   p->MapSubwindows();
   p->Layout();

   m_modules = new TEveElementList( "Modules" );
   m_eveScene->AddElement( m_modules );
   m_moduleLabels = new TEveElementList( "Modules" );
   m_eveScene->AddElement( m_moduleLabels );
   m_hits = new TEveElementList( "Hits" );
   m_eveScene->AddElement( m_hits );
   if( track->extra().isAvailable())
   {
      addModules( *track, id.item(), m_modules, true );
      addHits( *track, id.item(), m_hits, true );
   }
   for( TEveElement::List_i i = m_modules->BeginChildren(), end = m_modules->EndChildren(); i != end; ++i )
   {
      TEveGeoShape* gs = dynamic_cast<TEveGeoShape*>(*i);
      if (gs == 0 && (*i != 0)) {
        std::cerr << "Got a " << typeid(**i).name() << ", expecting TEveGeoShape. ignoring (it must be the clusters)." << std::endl;
        continue;
      }
      gs->SetMainTransparency(75);
      gs->SetPickable(kFALSE);

      TString name = gs->GetElementTitle();
      if (!name.Contains("BAD") && !name.Contains("INACTIVE") && !name.Contains("LOST")) {
          gs->SetMainColor(kBlue);
      }
      TEveText* text = new TEveText(name.Data());
      text->PtrMainTrans()->SetFrom(gs->RefMainTrans().Array());
      text->SetFontMode(TGLFont::kPixmap);
      text->SetFontSize(12);
      m_moduleLabels->AddElement(text); 
   }
   m_moduleLabels->SetRnrChildren(false);

   TEveTrackPropagator* prop = new TEveTrackPropagator();
   prop->SetMagFieldObj(item()->context().getField(), false);
   prop->SetStepper(TEveTrackPropagator::kRungeKutta);
   prop->SetMaxR(123);
   prop->SetMaxZ(300);
   prop->SetMaxStep(1);
   TEveTrack* trk = fireworks::prepareTrack( *track, prop );
   trk->MakeTrack();
   trk->SetLineWidth(2);
   trk->SetTitle( "Track and its ref states" );
   prop->SetRnrDaughters(kTRUE);
   prop->SetRnrReferences(kTRUE);
   prop->SetRnrDecay(kTRUE);
   prop->SetRnrFV(kTRUE);
   trk->SetMainColor(id.item()->defaultDisplayProperties().color());
   m_eveScene->AddElement(trk);

   viewerGL()->SetStyle(TGLRnrCtx::kOutline);
   viewerGL()->SetDrawCameraCenter(kTRUE);
   viewerGL()->ResetCamerasAfterNextUpdate();
   viewerGL()->UpdateScene(kFALSE);
   gEve->Redraw3D();

   setTextInfo(id, track);
}
void FWTrackHitsDetailView::makeLegend ( void  ) [private]

Definition at line 257 of file FWTrackHitsDetailView.cc.

References reco::ParticleMasses::kPlus, and m_legend.

Referenced by build().

{
   m_legend = new TLegend( 0.01, 0.01, 0.99, 0.99, 0, "NDC" );
   m_legend->SetFillColor(kWhite);
   m_legend->SetTextSize( 0.07 );
   m_legend->SetBorderSize( 0 );
   m_legend->SetMargin( 0.15 );
   m_legend->SetEntrySeparation( 0.01 );

   TEveStraightLineSet *legend = new TEveStraightLineSet( "siStripCluster" );
   legend->SetLineWidth( 3 );
   legend->SetLineColor( kGreen );
   m_legend->AddEntry( legend, "Exact SiStripCluster", "l");

   TEveStraightLineSet *legend2 = new TEveStraightLineSet( "siStripCluster2" );
   legend2->SetLineWidth( 3 );
   legend2->SetLineColor( kRed );
   m_legend->AddEntry( legend2, "Extra SiStripCluster", "l");

   TEveStraightLineSet *legend3 = new TEveStraightLineSet( "refStates" );
   legend3->SetDepthTest( kFALSE );
   legend3->SetMarkerColor( kYellow );
   legend3->SetMarkerStyle( kPlus );
   legend3->SetMarkerSize( 2 );
   m_legend->AddEntry( legend3, "Inner/Outermost States", "p");

   TEveStraightLineSet *legend4 = new TEveStraightLineSet( "vertex" );
   legend4->SetDepthTest( kFALSE );
   legend4->SetMarkerColor( kRed );
   legend4->SetMarkerStyle( kFullDotLarge );
   legend4->SetMarkerSize( 2 );
   m_legend->AddEntry( legend4, "Vertex", "p");

   TEveStraightLineSet *legend5 = new TEveStraightLineSet( "cameraCenter" );
   legend5->SetDepthTest( kFALSE );
   legend5->SetMarkerColor( kCyan );
   legend5->SetMarkerStyle( kFullDotLarge );
   legend5->SetMarkerSize( 2 );
   m_legend->AddEntry( legend5, "Camera center", "p");
}
const FWTrackHitsDetailView& FWTrackHitsDetailView::operator= ( const FWTrackHitsDetailView ) [private]
void FWTrackHitsDetailView::pickCameraCenter ( )

Definition at line 166 of file FWTrackHitsDetailView.cc.

References FWDetailViewGL< reco::Track >::viewerGL().

Referenced by build().

{
   viewerGL()->PickCameraCenter();
}
void FWTrackHitsDetailView::rnrLabels ( )

Definition at line 474 of file FWTrackHitsDetailView.cc.

References m_moduleLabels.

Referenced by build().

{
   m_moduleLabels->SetRnrChildren(!m_moduleLabels->GetRnrChildren());
   gEve->Redraw3D();
}
void FWTrackHitsDetailView::setBackgroundColor ( Color_t  col) [virtual]

Reimplemented from FWDetailViewGL< reco::Track >.

Definition at line 150 of file FWTrackHitsDetailView.cc.

References i, m_moduleLabels, FWColorManager::setColorSetViewer(), FWDetailViewGL< reco::Track >::viewerGL(), and x.

{
   // Callback for cmsShow change of background

   FWColorManager::setColorSetViewer(viewerGL(), col);

   // adopt label colors to background, this should be implemneted in TEveText
   if (m_moduleLabels)
   {
      Color_t x = viewerGL()->GetRnrCtx()->ColorSet().Foreground().GetColorIndex();
      for (TEveElement::List_i i=m_moduleLabels->BeginChildren(); i!=m_moduleLabels->EndChildren(); ++i)
         (*i)->SetMainColor(x);
   }
}
void FWTrackHitsDetailView::setTextInfo ( const FWModelId id,
const reco::Track track 
) [private, virtual]

Implements FWDetailView< reco::Track >.

Definition at line 182 of file FWTrackHitsDetailView.cc.

References reco::TrackBase::charge(), FWDetailViewBase::drawCanvasBox(), FWDetailViewBase::drawCanvasDot(), reco::TrackBase::eta(), getHLTprescales::index, FWDetailViewBase::item(), FWDetailViewGL< reco::Track >::m_infoCanvas, m_legend, reco::TrackBase::phi(), pos, reco::TrackBase::pt(), alignCSCRings::r, diffTwoXMLs::r2, x, and detailsBasic3DVector::y.

Referenced by build().

{
   m_infoCanvas->cd();

   float_t x  = 0.02;
   float   y  = 0.95;

   TLatex* latex = new TLatex( x, y, "" );
   const double textsize( 0.07 );
   latex->SetTextSize( 2*textsize );

   latex->DrawLatex( x, y, id.item()->modelName( id.index()).c_str());
   y -= latex->GetTextSize()*0.6;

   latex->SetTextSize( textsize );
   float lineH = latex->GetTextSize()*0.6;

   latex->DrawLatex( x, y, Form( " P_{T} = %.1f GeV, #eta = %0.2f, #varphi = %0.2f",
                                 track->pt(), track->eta(), track->phi()));
   y -= lineH;

   if( track->charge() > 0 )
      latex->DrawLatex( x, y, " charge = +1" );
   else
      latex->DrawLatex( x, y, " charge = -1" );
   y -= lineH;
   y -= lineH;

   latex->DrawLatex( x, y, "Track modules:");
   y -= lineH;

   Double_t pos[4];
   pos[0] = x+0.05;
   pos[2] = x+0.20;
   Double_t boxH = 0.25*textsize;

   pos[1] = y; pos[3] = pos[1] + boxH;
   FWDetailViewBase::drawCanvasBox( pos, kBlue );
   latex->DrawLatex( x + 0.25, y, "Module" );
   y -= lineH;

   pos[1] = y; pos[3] = pos[1] + boxH;
   FWDetailViewBase::drawCanvasBox( pos, kRed );
   latex->DrawLatex( x + 0.25, y, "LOST Module" );
   y -= lineH;

   pos[1] = y; pos[3] = pos[1] + boxH;
   FWDetailViewBase::drawCanvasBox( pos, 28 );
   latex->DrawLatex( x + 0.25, y, "INACTIVE Module" );
   y -= lineH;

   pos[1] = y; pos[3] = pos[1] + boxH;
   FWDetailViewBase::drawCanvasBox( pos, 218 );
   latex->DrawLatex( x + 0.25, y, "BAD Module" );
   y -= lineH;

   Float_t r = 0.01;
   Float_t r2 = 0.02;
   y -= lineH;
   drawCanvasDot( x + r2, y, r2, kGreen );
   y -= r;
   latex->DrawLatex( x + 3 * r2, y, "Pixel Hits" );
   y -= lineH;

   drawCanvasDot( x + r2, y, r2, kRed);
   y -= r;
   latex->DrawLatex( x + 3 * r2, y, "Extra Pixel Hits" );
   y -= lineH;

   m_legend->SetY2(y);
   m_legend->Draw();
   m_legend = 0; // Deleted together with TPad.
}
void FWTrackHitsDetailView::transparencyChanged ( int  x)

Definition at line 172 of file FWTrackHitsDetailView.cc.

References i, and m_modules.

Referenced by build().

{
   for (TEveElement::List_i i=m_modules->BeginChildren(); i!=m_modules->EndChildren(); ++i)
   {
      (*i)->SetMainTransparency(x);
   }
   gEve->Redraw3D();
}

Member Data Documentation

TEveElementList* FWTrackHitsDetailView::m_hits [protected]

Definition at line 33 of file FWTrackHitsDetailView.h.

Referenced by build().

TLegend* FWTrackHitsDetailView::m_legend [private]

Definition at line 61 of file FWTrackHitsDetailView.h.

Referenced by makeLegend(), and setTextInfo().

TEveElementList* FWTrackHitsDetailView::m_moduleLabels [protected]

Definition at line 32 of file FWTrackHitsDetailView.h.

Referenced by build(), rnrLabels(), and setBackgroundColor().

TEveElementList* FWTrackHitsDetailView::m_modules [protected]

Definition at line 31 of file FWTrackHitsDetailView.h.

Referenced by build(), and transparencyChanged().

TGSlider* FWTrackHitsDetailView::m_slider [protected]

Definition at line 34 of file FWTrackHitsDetailView.h.

Referenced by build().

Definition at line 35 of file FWTrackHitsDetailView.h.

Referenced by build().