Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:10:04

0001 /*
0002  *  FWBeamSpotProxyBuilder.cc
0003  *  FWorks
0004  *
0005  *  Created by Ianna Osborne on 7/29/10.
0006  *
0007  */
0008 #include "TEveStraightLineSet.h"
0009 
0010 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0011 #include "Fireworks/Core/interface/FWEventItem.h"
0012 
0013 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0014 
0015 class FWBeamSpotProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::BeamSpot> {
0016 public:
0017   FWBeamSpotProxyBuilder(void) {}
0018   ~FWBeamSpotProxyBuilder(void) override {}
0019 
0020   REGISTER_PROXYBUILDER_METHODS();
0021 
0022   // Disable default copy constructor
0023   FWBeamSpotProxyBuilder(const FWBeamSpotProxyBuilder&) = delete;
0024   // Disable default assignment operator
0025   const FWBeamSpotProxyBuilder& operator=(const FWBeamSpotProxyBuilder&) = delete;
0026 
0027 private:
0028   void localModelChanges(const FWModelId& iId,
0029                          TEveElement* parent,
0030                          FWViewType::EType viewType,
0031                          const FWViewContext* vc) override;
0032 
0033   using FWSimpleProxyBuilderTemplate<reco::BeamSpot>::build;
0034   void build(const reco::BeamSpot& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
0035 };
0036 
0037 void FWBeamSpotProxyBuilder::localModelChanges(const FWModelId& iId,
0038                                                TEveElement* parent,
0039                                                FWViewType::EType viewType,
0040                                                const FWViewContext* vc) {
0041   if (TEveStraightLineSet* ls = dynamic_cast<TEveStraightLineSet*>(*parent->BeginChildren())) {
0042     Color_t c = FWProxyBuilderBase::item()->modelInfo(iId.index()).displayProperties().color();
0043     for (TEveProjectable::ProjList_i j = ls->BeginProjecteds(); j != ls->EndProjecteds(); ++j) {
0044       if (TEveStraightLineSet* pls = dynamic_cast<TEveStraightLineSet*>(*j)) {
0045         pls->SetMarkerColor(c);
0046         pls->ElementChanged();
0047       }
0048     }
0049 
0050     ls->SetMarkerColor(c);
0051     ls->ElementChanged();
0052   }
0053 }
0054 
0055 void FWBeamSpotProxyBuilder::build(const reco::BeamSpot& bs,
0056                                    unsigned int iIndex,
0057                                    TEveElement& oItemHolder,
0058                                    const FWViewContext*) {
0059   TEveStraightLineSet* ls = new TEveStraightLineSet();
0060 
0061   double pos[3] = {bs.x0(), bs.y0(), bs.z0()};
0062   double e[3] = {bs.x0Error(), bs.y0Error(), bs.z0Error()};
0063 
0064   const Int_t N = 32;
0065   const Float_t S = 2 * TMath::Pi() / N;
0066 
0067   Float_t a = e[0], b = e[1];
0068   for (Int_t i = 0; i < N; i++)
0069     ls->AddLine(
0070         a * TMath::Cos(i * S), b * TMath::Sin(i * S), 0, a * TMath::Cos(i * S + S), b * TMath::Sin(i * S + S), 0);
0071 
0072   a = e[0];
0073   b = e[2];
0074   for (Int_t i = 0; i < N; i++)
0075     ls->AddLine(
0076         a * TMath::Cos(i * S), 0, b * TMath::Sin(i * S), a * TMath::Cos(i * S + S), 0, b * TMath::Sin(i * S + S));
0077 
0078   a = e[1];
0079   b = e[2];
0080   for (Int_t i = 0; i < N; i++)
0081     ls->AddLine(
0082         0, a * TMath::Cos(i * S), b * TMath::Sin(i * S), 0, a * TMath::Cos(i * S + S), b * TMath::Sin(i * S + S));
0083 
0084   ls->AddLine(0, 0, 0, 0, 0, 0);
0085   ls->AddMarker(0, 0, 0);
0086   ls->SetMarkerStyle(21);
0087   const FWDisplayProperties& dp = FWProxyBuilderBase::item()->defaultDisplayProperties();
0088   ls->SetMarkerColor(dp.color());
0089 
0090   ls->RefMainTrans().SetPos(pos);
0091   setupAddElement(ls, &oItemHolder);
0092 }
0093 
0094 REGISTER_FWPROXYBUILDER(FWBeamSpotProxyBuilder,
0095                         reco::BeamSpot,
0096                         "Beam Spot",
0097                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);