Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-14 11:45:03

0001 
0002 #include "TGLViewer.h"  // access to over-all bounding box
0003 #include "TEveCalo.h"   // workaround for TEveCalo3D bounding box
0004 #include "TGLFontManager.h"
0005 #include "TEveScene.h"
0006 #include "TEveManager.h"
0007 #include "TEveStraightLineSet.h"
0008 #include "TEveTrack.h"
0009 #include "TEveTrackPropagator.h"
0010 #include "TEveTrans.h"
0011 #include "TEveText.h"
0012 #include "TEveGeoShape.h"
0013 #include "TGSlider.h"
0014 #include "TGButton.h"
0015 #include "TGLabel.h"
0016 #include "TCanvas.h"
0017 #include "TLatex.h"
0018 #include "TLegend.h"
0019 #include "TG3DLine.h"
0020 #include "TEveCaloData.h"
0021 
0022 // CMSSW includes
0023 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
0024 #include "DataFormats/TrackReco/interface/Track.h"
0025 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
0026 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0027 
0028 // Fireworks includes
0029 #include "Fireworks/Core/interface/FWModelId.h"
0030 #include "Fireworks/Core/interface/FWColorManager.h"
0031 #include "Fireworks/Core/interface/FWGeometry.h"
0032 #include "Fireworks/Core/interface/FWEventItem.h"
0033 #include "Fireworks/Core/interface/CSGAction.h"
0034 #include "Fireworks/Core/interface/FWMagField.h"
0035 #include "Fireworks/Core/interface/FWBeamSpot.h"
0036 #include "Fireworks/Core/interface/fwLog.h"
0037 #include "Fireworks/Calo/interface/FWECALCaloDataDetailViewBuilder.h"
0038 
0039 #include "Fireworks/Electrons/plugins/FWConvTrackHitsDetailView.h"
0040 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
0041 #include "Fireworks/Tracks/interface/TrackUtils.h"
0042 
0043 namespace {
0044   void (FWConvTrackHitsDetailView::*foo)();
0045 }
0046 
0047 FWConvTrackHitsDetailView::FWConvTrackHitsDetailView()
0048     : m_modules(nullptr), m_moduleLabels(nullptr), m_hits(nullptr), m_legend(nullptr), m_orthographic(false) {}
0049 
0050 FWConvTrackHitsDetailView::~FWConvTrackHitsDetailView() {}
0051 
0052 namespace {
0053   void setCameraInit(
0054       TGLViewer* v, TGLViewer::ECameraType type, const TEveVectorD b1, TEveVectorD b3, TEveVector center) {
0055     TGLCamera& cam = v->RefCamera(type);
0056     TGLMatrix& trans = cam.RefCamBase();
0057 
0058     trans.Set(trans.GetTranslation(), b3.Arr(), b1.Arr());
0059     cam.Setup(v->RefOverallBoundingBox(), kTRUE);
0060 
0061     cam.SetExternalCenter(true);
0062     cam.SetCenterVec(center.fX, center.fY, center.fZ);
0063   }
0064 
0065   /*
0066     // alternative to setCameraInit
0067 void setCamera(TGLViewer* v, TGLViewer::ECameraType type, const TEveVectorD b1, TEveVectorD b2,  TEveVectorD b3, TEveVector center )
0068 {
0069    // b1 = fwd, b2 = lft, b3 = up
0070 
0071    TGLCamera& cam = v->RefCamera(type); 
0072    TGLMatrix& trans = cam.RefCamBase();
0073    
0074    trans.SetBaseVec(1, b1.Arr());
0075    trans.SetBaseVec(2, b2.Arr());
0076    trans.SetBaseVec(3, b3.Arr());
0077 
0078    cam.SetExternalCenter(true);
0079    cam.SetCenterVec(center.fX, center.fY, center.fZ);
0080 }
0081     */
0082 }  // namespace
0083 void FWConvTrackHitsDetailView::build(const FWModelId& id, const reco::Conversion* conv) {
0084   if (conv->nTracks() < 2)
0085     return;
0086   const reco::Track* track0 = conv->tracks().at(0).get();
0087   const reco::Track* track1 = conv->tracks().at(1).get();
0088 
0089   m_guiFrame->AddFrame(new TGLabel(m_guiFrame, "Camera Views:"), new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
0090 
0091   {
0092     TGHorizontalFrame* f = new TGHorizontalFrame(m_guiFrame);
0093     m_guiFrame->AddFrame(f, new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0));
0094     {
0095       CSGAction* action = new CSGAction(this, "Top");
0096       TGTextButton* b = new TGTextButton(f, action->getName().c_str());
0097       f->AddFrame(b, new TGLayoutHints(kLHintsExpandX));
0098       TQObject::Connect(b, "Clicked()", "CSGAction", action, "activate()");
0099       b->SetToolTipText("plane normal: track0 x track1");
0100       action->activated.connect(sigc::mem_fun(*this, &FWConvTrackHitsDetailView::camera1Callback));
0101     }
0102 
0103     {
0104       CSGAction* action = new CSGAction(this, "Side");
0105       TGTextButton* b = new TGTextButton(f, action->getName().c_str());
0106       f->AddFrame(b, new TGLayoutHints(kLHintsExpandX));
0107       TQObject::Connect(b, "Clicked()", "CSGAction", action, "activate()");
0108       b->SetToolTipText("left fir: track1");
0109       action->activated.connect(sigc::mem_fun(*this, &FWConvTrackHitsDetailView::camera2Callback));
0110     }
0111     {
0112       CSGAction* action = new CSGAction(this, "Front");
0113       TGTextButton* b = new TGTextButton(f, action->getName().c_str());
0114       f->AddFrame(b, new TGLayoutHints(kLHintsExpandX));
0115       TQObject::Connect(b, "Clicked()", "CSGAction", action, "activate()");
0116       action->activated.connect(sigc::mem_fun(*this, &FWConvTrackHitsDetailView::camera3Callback));
0117       b->SetToolTipText("plane normal: track1 ");
0118     }
0119   }
0120 
0121   {
0122     m_camTypeAction = new CSGAction(this, " Set Ortographic Projection ");
0123     m_camTypeAction->createTextButton(m_guiFrame, new TGLayoutHints(kLHintsExpandX, 2, 0, 1, 4));
0124     m_camTypeAction->activated.connect(sigc::mem_fun(*this, &FWConvTrackHitsDetailView::switchProjection));
0125   }
0126   {
0127     CSGAction* action = new CSGAction(this, "Draw Module");
0128     TGCheckButton* b = new TGCheckButton(m_guiFrame, action->getName().c_str());
0129     b->SetState(kButtonDown, false);
0130     m_guiFrame->AddFrame(b, new TGLayoutHints(kLHintsNormal, 2, 3, 1, 4));
0131     TQObject::Connect(b, "Clicked()", "CSGAction", action, "activate()");
0132     action->activated.connect(sigc::mem_fun(*this, &FWConvTrackHitsDetailView::rnrModules));
0133   }
0134   {
0135     CSGAction* action = new CSGAction(this, "Draw Hits");
0136     TGCheckButton* b = new TGCheckButton(m_guiFrame, action->getName().c_str());
0137     b->SetState(kButtonDown, false);
0138     m_guiFrame->AddFrame(b, new TGLayoutHints(kLHintsNormal, 2, 3, 1, 4));
0139     TQObject::Connect(b, "Clicked()", "CSGAction", action, "activate()");
0140     action->activated.connect(sigc::mem_fun(*this, &FWConvTrackHitsDetailView::rnrHits));
0141   }
0142 
0143   TGCompositeFrame* p = (TGCompositeFrame*)m_guiFrame->GetParent();
0144   p->MapSubwindows();
0145   p->Layout();
0146 
0147   m_modules = new TEveElementList("Modules");
0148   m_eveScene->AddElement(m_modules);
0149   m_moduleLabels = new TEveElementList("Modules");
0150   m_eveScene->AddElement(m_moduleLabels);
0151   m_hits = new TEveElementList("Hits");
0152   m_eveScene->AddElement(m_hits);
0153   if (track1->extra().isAvailable()) {
0154     addModules(*track1, id.item(), m_modules, true);
0155     addHits(*track1, id.item(), m_hits, true);
0156   }
0157   if (track0->extra().isAvailable()) {
0158     addModules(*track0, id.item(), m_modules, true);
0159     addHits(*track0, id.item(), m_hits, true);
0160   }
0161   for (TEveElement::List_i i = m_modules->BeginChildren(), end = m_modules->EndChildren(); i != end; ++i) {
0162     TEveGeoShape* gs = dynamic_cast<TEveGeoShape*>(*i);
0163     const auto& rhs = *(*(i));
0164     if (gs == nullptr && (*i != nullptr)) {
0165       std::cerr << "Got a " << typeid(rhs).name() << ", expecting TEveGeoShape. ignoring (it must be the clusters)."
0166                 << std::endl;
0167       continue;
0168     }
0169     // gs->SetMainTransparency(75);
0170     // gs->SetPickable(kFALSE);
0171 
0172     TString name = gs->GetElementTitle();
0173     if (!name.Contains("BAD") && !name.Contains("INACTIVE") && !name.Contains("LOST")) {
0174       gs->SetMainColor(kBlue);
0175     }
0176     TEveText* text = new TEveText(name.Data());
0177     text->PtrMainTrans()->SetFrom(gs->RefMainTrans().Array());
0178     text->SetFontMode(TGLFont::kPixmap);
0179     text->SetFontSize(12);
0180     m_moduleLabels->AddElement(text);
0181   }
0182   m_moduleLabels->SetRnrChildren(false);
0183 
0184   TEveTrackPropagator* prop = new TEveTrackPropagator();
0185   prop->SetMagFieldObj(item()->context().getField(), false);
0186   prop->SetStepper(TEveTrackPropagator::kRungeKutta);
0187   prop->SetMaxR(123);
0188   prop->SetMaxZ(300);
0189   prop->SetMaxStep(1);
0190   prop->SetRnrDaughters(kTRUE);
0191   prop->SetRnrReferences(kTRUE);
0192   prop->SetRnrDecay(kTRUE);
0193 
0194   // first-vertex style
0195   prop->SetRnrFV(kTRUE);
0196   prop->RefFVAtt().SetMarkerColor(id.item()->defaultDisplayProperties().color());
0197   prop->RefFVAtt().SetMarkerSize(0.8);
0198 
0199   // path-mark style
0200   prop->RefPMAtt().SetMarkerSize(0.5);
0201   prop->RefPMAtt().SetMarkerColor(id.item()->defaultDisplayProperties().color());
0202 
0203   TEveTrack* trk1 = fireworks::prepareTrack(*track1, prop);
0204   trk1->MakeTrack();
0205   trk1->SetLineWidth(2);
0206   trk1->SetTitle("Track 1 and its ref states");
0207   trk1->SetMainColor(id.item()->defaultDisplayProperties().color());
0208   trk1->SetLineStyle(7);
0209   m_eveScene->AddElement(trk1);
0210 
0211   TEveTrack* trk0 = fireworks::prepareTrack(*track0, prop);
0212   trk0->MakeTrack();
0213   trk0->SetLineWidth(2);
0214   trk0->SetTitle("Track 0 and its ref states");
0215   trk0->SetMainColor(id.item()->defaultDisplayProperties().color());
0216   m_eveScene->AddElement(trk0);
0217 
0218   // create TEveCalo3D object, fix bounding box
0219   {
0220     float phi = conv->pairMomentum().phi();
0221     float eta = conv->pairMomentum().eta();
0222 
0223     FWECALCaloDataDetailViewBuilder caloBld(id.item()->getEvent(), id.item()->getGeom(), eta, phi, 30);
0224     TEveCaloData* data = caloBld.buildCaloData(false);
0225     // AMT!!! this is memory leak, check why it needs to be added
0226     TEveCalo3D* calo3d = new TEveCalo3D(data);
0227     gEve->AddElement(data);
0228     calo3d->SetBarrelRadius(129.00);
0229     calo3d->SetEndCapPos(268.36);
0230 
0231     float theta = TEveCaloData::EtaToTheta(eta);
0232     float ext = data->GetMaxVal(true) * calo3d->GetValToHeight();
0233     if (TMath::Abs(eta) < calo3d->GetTransitionEta()) {
0234       // printf("barrel\n");
0235       float x = calo3d->GetBarrelRadius() * TMath::Cos(phi);
0236       float y = calo3d->GetBarrelRadius() * TMath::Sin(phi);
0237       float z = calo3d->GetBarrelRadius() / TMath::Tan(theta);
0238 
0239       calo3d->SetupBBoxCube(ext, x, y, z);
0240     } else {
0241       // printf("endcap\n");
0242       float z = TMath::Sign(calo3d->GetEndCapPos(), eta);
0243       float r = z * TMath::Tan(theta);
0244       calo3d->SetupBBoxCube(ext, r * TMath::Cos(phi), r * TMath::Sin(phi), z);
0245     }
0246     m_eveScene->AddElement(calo3d);
0247   }
0248 
0249   //  base vectors
0250   TEveVectorD fwd = trk1->GetMomentum().Cross(trk0->GetMomentum());
0251   fwd.Normalize();
0252   TEveVectorD lft = trk1->GetMomentum();
0253   lft.Normalize();
0254   TEveVectorD up = lft.Cross(fwd);
0255 
0256   TEveVectorD c = (trk1->GetVertex() + trk0->GetVertex()) * 0.5;
0257   if (true) {
0258     setCameraInit(viewerGL(), TGLViewer::kCameraPerspXOZ, fwd, up, c);  //default
0259     setCameraInit(viewerGL(), TGLViewer::kCameraPerspYOZ, up, lft, c);
0260     setCameraInit(viewerGL(), TGLViewer::kCameraPerspXOY, lft, fwd, c);
0261 
0262     setCameraInit(viewerGL(), TGLViewer::kCameraOrthoXOY, fwd, up, c);
0263     setCameraInit(viewerGL(), TGLViewer::kCameraOrthoXOZ, up, lft, c);
0264     setCameraInit(viewerGL(), TGLViewer::kCameraOrthoZOY, lft, fwd, c);
0265   }
0266   {
0267     Float_t sfac = 100;
0268     fwd *= sfac;
0269     lft *= sfac;
0270     up *= sfac;
0271     int transp = 90;
0272     {
0273       TEveStraightLineSet* bls = new TEveStraightLineSet("base1");
0274       bls->AddLine(c, fwd + c);
0275       bls->SetMainColor(kBlue);
0276       bls->SetMainTransparency(transp);
0277       bls->SetPickable(false);
0278       m_eveScene->AddElement(bls);
0279     }
0280 
0281     {
0282       TEveStraightLineSet* bls = new TEveStraightLineSet("base2");
0283       bls->AddLine(c, lft + c);
0284       bls->SetMainColor(kBlue);
0285       bls->SetMainTransparency(transp);
0286       bls->SetPickable(false);
0287       m_eveScene->AddElement(bls);
0288     }
0289 
0290     {
0291       TEveStraightLineSet* bls = new TEveStraightLineSet("base3");
0292       bls->AddLine(c, up + c);
0293       bls->SetMainColor(kBlue);
0294       bls->SetMainTransparency(transp);
0295       bls->SetPickable(false);
0296       m_eveScene->AddElement(bls);
0297     }
0298   }
0299   {
0300     TEveStraightLineSet* bls = new TEveStraightLineSet("Photon", "Photon");
0301     FWBeamSpot* bs = context().getBeamSpot();
0302     bls->AddLine(c.fX, c.fY, c.fZ, bs->x0(), bs->y0(), bs->z0());
0303     bls->SetMainColor(id.item()->defaultDisplayProperties().color());
0304     bls->SetLineStyle(3);
0305     m_eveScene->AddElement(bls);
0306   }
0307 
0308   viewerGL()->SetStyle(TGLRnrCtx::kOutline);
0309   viewerGL()->ResetCamerasAfterNextUpdate();
0310   viewerGL()->UpdateScene(kFALSE);
0311   gEve->Redraw3D();
0312 
0313   setTextInfo(id, conv);
0314   foo = &FWConvTrackHitsDetailView::camera1Callback;
0315 }
0316 
0317 void FWConvTrackHitsDetailView::setTextInfo(const FWModelId& id, const reco::Conversion* conv) {
0318   m_infoCanvas->cd();
0319 
0320   float_t x = 0.02;
0321   float y = 0.95;
0322 
0323   TLatex* latex = new TLatex(x, y, "");
0324   const double textsize(0.07);
0325   latex->SetTextSize(2 * textsize);
0326 
0327   latex->DrawLatex(x, y, id.item()->modelName(id.index()).c_str());
0328   y -= latex->GetTextSize() * 0.6;
0329 
0330   latex->SetTextSize(textsize);
0331   float lineH = latex->GetTextSize() * 0.6;
0332 
0333   latex->DrawLatex(x,
0334                    y,
0335                    Form("p_{T}=%.1f GeV, #eta=%0.2f, #varphi=%0.2f",
0336                         sqrt(conv->pairMomentum().Perp2()),
0337                         conv->pairMomentum().eta(),
0338                         conv->pairMomentum().phi()));
0339   y -= lineH;
0340   latex->DrawLatex(x,
0341                    y,
0342                    Form("vtx=(%.1f, %.1f, %.1f) r=%.1f [cm]",
0343                         conv->conversionVertex().x(),
0344                         conv->conversionVertex().y(),
0345                         conv->conversionVertex().z(),
0346                         conv->conversionVertex().position().rho()));
0347   y -= lineH;
0348   latex->DrawLatex(x, y, Form("#Deltactg#theta=%.3f", conv->pairCotThetaSeparation()));
0349   y -= lineH;
0350   latex->DrawLatex(x, y, Form("#Delta#phi_{vtx}=%.3f", conv->dPhiTracksAtVtx()));
0351   y -= lineH;
0352   latex->DrawLatex(x, y, Form("dist. min. app.=%.3f cm", conv->distOfMinimumApproach()));
0353   y -= lineH;
0354   y -= lineH;
0355 
0356   const reco::Track* track0 = conv->tracks().at(0).get();
0357   latex->DrawLatex(x, y, Form("Trk0 q=%i", track0->charge()));
0358   y -= lineH;
0359   latex->DrawLatex(x, y, Form("p_{T}=%.1f GeV, #eta=%0.2f, #varphi=%0.2f", track0->pt(), track0->eta(), track0->phi()));
0360   y -= lineH;
0361   const reco::HitPattern& hp0 = track0->hitPattern();
0362   int nvalid_tk0 = 0, ninvalid_tk0 = 0, npix_tk0 = 0, nstrip_tk0 = 0;
0363   for (int i_tk0 = 0; i_tk0 < hp0.numberOfAllHits(reco::HitPattern::TRACK_HITS); i_tk0++) {
0364     uint32_t hit = hp0.getHitPattern(reco::HitPattern::TRACK_HITS, i_tk0);
0365     if (reco::HitPattern::validHitFilter(hit)) {
0366       nvalid_tk0++;
0367       if (reco::HitPattern::pixelHitFilter(hit))
0368         npix_tk0++;
0369       else if (reco::HitPattern::stripHitFilter(hit))
0370         nstrip_tk0++;
0371     } else
0372       ninvalid_tk0++;
0373   }
0374   latex->DrawLatex(x, y, Form("valid hits: %i (pix. %i, str. %i)", nvalid_tk0, npix_tk0, nstrip_tk0));
0375   y -= lineH;
0376   latex->DrawLatex(x, y, Form("invalid: %i", ninvalid_tk0));
0377   y -= lineH;
0378 
0379   int npix_mhi_tk0 = 0, nstrip_mhi_tk0 = 0;
0380   for (int i_mhi_tk0 = 0; i_mhi_tk0 < hp0.numberOfAllHits(reco::HitPattern::MISSING_INNER_HITS); i_mhi_tk0++) {
0381     uint32_t hit = hp0.getHitPattern(reco::HitPattern::MISSING_INNER_HITS, i_mhi_tk0);
0382     if (reco::HitPattern::pixelHitFilter(hit))
0383       npix_mhi_tk0++;
0384     else if (reco::HitPattern::stripHitFilter(hit))
0385       nstrip_mhi_tk0++;
0386   }
0387   latex->DrawLatex(x, y, Form("miss. inner hits: pix. %i, str. %i", npix_mhi_tk0, nstrip_mhi_tk0));
0388 
0389   y -= lineH;
0390   y -= lineH;
0391   const reco::Track* track1 = conv->tracks().at(1).get();
0392   latex->DrawLatex(x, y, Form("Trk1 q=%i", track1->charge()));
0393   y -= lineH;
0394   latex->DrawLatex(x, y, Form("p_{T}=%.1f GeV, #eta=%0.2f, #varphi=%0.2f", track1->pt(), track1->eta(), track1->phi()));
0395   y -= lineH;
0396 
0397   const reco::HitPattern& hp1 = track1->hitPattern();
0398   int nvalid_tk1 = 0, ninvalid_tk1 = 0, npix_tk1 = 0, nstrip_tk1 = 0;
0399   for (int i_tk1 = 0; i_tk1 < hp1.numberOfAllHits(reco::HitPattern::TRACK_HITS); i_tk1++) {
0400     uint32_t hit = hp1.getHitPattern(reco::HitPattern::TRACK_HITS, i_tk1);
0401     if (reco::HitPattern::validHitFilter(hit)) {
0402       nvalid_tk1++;
0403       if (reco::HitPattern::pixelHitFilter(hit))
0404         npix_tk1++;
0405       else if (reco::HitPattern::stripHitFilter(hit))
0406         nstrip_tk1++;
0407     } else
0408       ninvalid_tk1++;
0409   }
0410   latex->DrawLatex(x, y, Form("valid hits: %i (pix. %i, str. %i)", nvalid_tk1, npix_tk1, nstrip_tk1));
0411   y -= lineH;
0412   latex->DrawLatex(x, y, Form("invalid: %i", ninvalid_tk1));
0413   y -= lineH;
0414 
0415   int npix_mhi_tk1 = 0, nstrip_mhi_tk1 = 0;
0416   for (int i_mhi_tk1 = 0; i_mhi_tk1 < hp1.numberOfAllHits(reco::HitPattern::MISSING_INNER_HITS); i_mhi_tk1++) {
0417     uint32_t hit = hp1.getHitPattern(reco::HitPattern::MISSING_INNER_HITS, i_mhi_tk1);
0418     if (reco::HitPattern::pixelHitFilter(hit))
0419       npix_mhi_tk1++;
0420     else if (reco::HitPattern::stripHitFilter(hit))
0421       nstrip_mhi_tk1++;
0422   }
0423   latex->DrawLatex(x, y, Form("miss. inner hits: pix. %i, str. %i", npix_mhi_tk1, nstrip_mhi_tk1));
0424   y -= lineH;
0425   y -= lineH;
0426 }
0427 
0428 void FWConvTrackHitsDetailView::addTrackerHits3D(std::vector<TVector3>& points,
0429                                                  class TEveElementList* tList,
0430                                                  Color_t color,
0431                                                  int size) {
0432   // !AMT this is  detail view specific, should move to track hits
0433   // detail view
0434 
0435   TEvePointSet* pointSet = new TEvePointSet();
0436   pointSet->SetMarkerSize(size);
0437   pointSet->SetMarkerStyle(4);
0438   pointSet->SetPickable(kTRUE);
0439   pointSet->SetTitle("Pixel Hits");
0440   pointSet->SetMarkerColor(color);
0441 
0442   for (std::vector<TVector3>::const_iterator it = points.begin(), itEnd = points.end(); it != itEnd; ++it) {
0443     pointSet->SetNextPoint(it->x(), it->y(), it->z());
0444   }
0445   tList->AddElement(pointSet);
0446 }
0447 
0448 void FWConvTrackHitsDetailView::addHits(const reco::Track& track,
0449                                         const FWEventItem* iItem,
0450                                         TEveElement* trkList,
0451                                         bool addNearbyHits) {
0452   std::vector<TVector3> pixelPoints;
0453   fireworks::pushPixelHits(pixelPoints, *iItem, track);
0454   TEveElementList* pixels = new TEveElementList("Pixels");
0455   trkList->AddElement(pixels);
0456   if (addNearbyHits) {
0457     // get the extra hits
0458     std::vector<TVector3> pixelExtraPoints;
0459     fireworks::pushNearbyPixelHits(pixelExtraPoints, *iItem, track);
0460     // draw first the others
0461     addTrackerHits3D(pixelExtraPoints, pixels, kRed, 1);
0462     // then the good ones, so they're on top
0463     addTrackerHits3D(pixelPoints, pixels, kGreen, 1);
0464   } else {
0465     // just add those points with the default color
0466     addTrackerHits3D(pixelPoints, pixels, iItem->defaultDisplayProperties().color(), 1);
0467   }
0468 
0469   // strips
0470   TEveElementList* strips = new TEveElementList("Strips");
0471   trkList->AddElement(strips);
0472   fireworks::addSiStripClusters(iItem, track, strips, addNearbyHits, false);
0473 }
0474 
0475 //______________________________________________________________________________
0476 
0477 void FWConvTrackHitsDetailView::addModules(const reco::Track& track,
0478                                            const FWEventItem* iItem,
0479                                            TEveElement* trkList,
0480                                            bool addLostHits) {
0481   std::set<unsigned int> ids;
0482   for (trackingRecHit_iterator recIt = track.recHitsBegin(), recItEnd = track.recHitsEnd(); recIt != recItEnd;
0483        ++recIt) {
0484     DetId detid = (*recIt)->geographicalId();
0485     if (!addLostHits && !(*recIt)->isValid())
0486       continue;
0487     if (detid.rawId() != 0) {
0488       TString name("");
0489       switch (detid.det()) {
0490         case DetId::Tracker:
0491           switch (detid.subdetId()) {
0492             case SiStripDetId::TIB:
0493               name = "TIB ";
0494               break;
0495             case SiStripDetId::TOB:
0496               name = "TOB ";
0497               break;
0498             case SiStripDetId::TID:
0499               name = "TID ";
0500               break;
0501             case SiStripDetId::TEC:
0502               name = "TEC ";
0503               break;
0504             case PixelSubdetector::PixelBarrel:
0505               name = "Pixel Barrel ";
0506               break;
0507             case PixelSubdetector::PixelEndcap:
0508               name = "Pixel Endcap ";
0509             default:
0510               break;
0511           }
0512           break;
0513 
0514         case DetId::Muon:
0515           switch (detid.subdetId()) {
0516             case MuonSubdetId::DT:
0517               name = "DT";
0518               detid = DetId(DTChamberId(detid));  // get rid of layer bits
0519               break;
0520             case MuonSubdetId::CSC:
0521               name = "CSC";
0522               break;
0523             case MuonSubdetId::RPC:
0524               name = "RPC";
0525               break;
0526             default:
0527               break;
0528           }
0529           break;
0530         default:
0531           break;
0532       }
0533       if (!ids.insert(detid.rawId()).second)
0534         continue;
0535       if (iItem->getGeom()) {
0536         TEveGeoShape* shape = iItem->getGeom()->getEveShape(detid);
0537         if (nullptr != shape) {
0538           shape->SetMainTransparency(65);
0539           shape->SetPickable(kTRUE);
0540           switch ((*recIt)->type()) {
0541             case TrackingRecHit::valid:
0542               shape->SetMainColor(iItem->defaultDisplayProperties().color());
0543               break;
0544             case TrackingRecHit::missing:
0545             case TrackingRecHit::missing_inner:
0546             case TrackingRecHit::missing_outer:
0547               name += "LOST ";
0548               shape->SetMainColor(kRed);
0549               break;
0550             case TrackingRecHit::inactive_inner:
0551             case TrackingRecHit::inactive_outer:
0552             case TrackingRecHit::inactive:
0553               name += "INACTIVE ";
0554               shape->SetMainColor(28);
0555               break;
0556             case TrackingRecHit::bad:
0557               name += "BAD ";
0558               shape->SetMainColor(218);
0559               break;
0560           }
0561           shape->SetTitle(name + ULong_t(detid.rawId()));
0562           trkList->AddElement(shape);
0563         } else {
0564           fwLog(fwlog::kInfo) << "Failed to get shape extract for a tracking rec hit: "
0565                               << "\n"
0566                               << fireworks::info(detid) << std::endl;
0567         }
0568       }
0569     }
0570   }
0571 }
0572 
0573 //______________________________________________________________________________
0574 void FWConvTrackHitsDetailView::pickCameraCenter() {
0575   viewerGL()->PickCameraCenter();
0576   viewerGL()->SetDrawCameraCenter(kTRUE);
0577 }
0578 
0579 void FWConvTrackHitsDetailView::switchProjection() {
0580   m_orthographic = !m_orthographic;
0581   m_camTypeAction->setName(m_orthographic ? "Set Perspective Projection" : "Set Orthographic Projection");
0582 
0583   (this->*foo)();
0584   //printf("current isOrthographic : %d \n",  viewerGL()->CurrentCamera().IsOrthographic());
0585 }
0586 
0587 void FWConvTrackHitsDetailView::rnrLabels() {
0588   m_moduleLabels->SetRnrChildren(!m_moduleLabels->GetRnrChildren());
0589   gEve->Redraw3D();
0590 }
0591 
0592 void FWConvTrackHitsDetailView::rnrModules() {
0593   m_modules->SetRnrChildren(!m_modules->GetRnrChildren());
0594   gEve->Redraw3D();
0595 }
0596 
0597 void FWConvTrackHitsDetailView::rnrHits() {
0598   m_hits->SetRnrChildren(!m_hits->GetRnrChildren());
0599   gEve->Redraw3D();
0600 }
0601 
0602 void FWConvTrackHitsDetailView::camera1Callback() {
0603   foo = &FWConvTrackHitsDetailView::camera1Callback;
0604 
0605   viewerGL()->SetCurrentCamera(m_orthographic ? TGLViewer::kCameraOrthoXOY : TGLViewer::kCameraPerspXOZ);
0606   viewerGL()->ResetCurrentCamera();
0607   viewerGL()->RequestDraw();
0608 }
0609 
0610 void FWConvTrackHitsDetailView::camera2Callback() {
0611   foo = &FWConvTrackHitsDetailView::camera2Callback;
0612 
0613   viewerGL()->SetCurrentCamera(m_orthographic ? TGLViewer::kCameraOrthoXOZ : TGLViewer::kCameraPerspYOZ);
0614   viewerGL()->ResetCurrentCamera();
0615   viewerGL()->RequestDraw();
0616 }
0617 
0618 void FWConvTrackHitsDetailView::camera3Callback() {
0619   foo = &FWConvTrackHitsDetailView::camera3Callback;
0620 
0621   viewerGL()->SetCurrentCamera(m_orthographic ? TGLViewer::kCameraOrthoZOY : TGLViewer::kCameraPerspXOY);
0622   viewerGL()->ResetCurrentCamera();
0623   viewerGL()->RequestDraw();
0624 }
0625 
0626 REGISTER_FWDETAILVIEW(FWConvTrackHitsDetailView, Conversion);
0627 /*
0628 REGISTER_FWDETAILVIEW(FWConvTrackHitsDetailView, Conversion, ecalRecHit);
0629 REGISTER_FWDETAILVIEW(FWConvTrackHitsDetailView, Conversion, reducedEcalRecHitsEB);
0630 REGISTER_FWDETAILVIEW(FWConvTrackHitsDetailView, Conversion, reducedEGamma);
0631 */