CMS 3D CMS Logo

FWConversionProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Conversions
4 // Class : FWConversionProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Dec 2 14:17:03 EST 2008
11 //
12 #include "TEveCompound.h"
13 #include "TEveLine.h"
14 #include "TEveScalableStraightLineSet.h"
15 
20 
24 
27 
29 //
30 // 3D and RPZ proxy builder with shared track list
31 //
33 
34 class FWConversionProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Conversion> {
35 public:
37  ~FWConversionProxyBuilder() override;
38 
39  bool haveSingleProduct() const override { return false; }
40  void cleanLocal() override;
41 
43 
44  FWConversionProxyBuilder(const FWConversionProxyBuilder&) = delete; // stop default
45  const FWConversionProxyBuilder& operator=(const FWConversionProxyBuilder&) = delete; // stop default
46 
47 private:
49  void buildViewType(const reco::Conversion& iData,
50  unsigned int iIndex,
51  TEveElement& oItemHolder,
53  const FWViewContext*) override;
54 
55  TEveElementList* requestCommon();
56 
57  TEveElementList* m_common;
58 };
59 
61  m_common = new TEveElementList("common conversion scene");
62  m_common->IncDenyDestroy();
63 }
64 
66 
68  if (m_common->HasChildren() == false) {
69  for (int i = 0; i < static_cast<int>(item()->size()); ++i) {
71  TEveLine* line = new TEveLine(0);
72  if (conversion.nTracks() == 2) {
73  if (fabs(conversion.zOfPrimaryVertexFromTracks()) < fireworks::Context::caloZ1())
74  line->SetNextPoint(0., 0., conversion.zOfPrimaryVertexFromTracks());
75  else
76  line->SetNextPoint(0., 0., 0.);
77 
78  float phi = conversion.pairMomentum().phi();
79  if (fabs(conversion.pairMomentum().eta()) < fireworks::Context::caloTransEta()) {
81  float z = radius / tan(conversion.pairMomentum().theta());
82  line->SetNextPoint(radius * cos(phi), radius * sin(phi), z);
83  } else {
84  float z = fireworks::Context::caloZ1();
85  float radius = z * tan(conversion.pairMomentum().theta());
86  z *= (conversion.pairMomentum().eta() / fabs(conversion.pairMomentum().eta()));
87  line->SetNextPoint(radius * cos(phi), radius * sin(phi), z);
88  }
89  } else {
90  line->SetNextPoint(0., 0., 0.);
91  line->SetNextPoint(0., 0., 0.);
92  }
93 
95  m_common->AddElement(line);
96  }
97  }
98 
99  return m_common;
100 }
101 
102 void FWConversionProxyBuilder::cleanLocal() { m_common->DestroyElements(); }
103 
105  unsigned int iIndex,
106  TEveElement& oItemHolder,
108  const FWViewContext*) {
109  TEveElementList* lines = requestCommon();
110  TEveElement::List_i linIt = lines->BeginChildren();
111  std::advance(linIt, iIndex);
112  TEveLine* line = (TEveLine*)((*linIt)->CloneElement());
113  TEveVector bvec = line->GetLineStart();
114  TEveVector evec = line->GetLineEnd();
115  if (bvec.Mag() != evec.Mag())
116  setupAddElement(*linIt, &oItemHolder);
117 }
118 
121  "Conversions",
static float caloTransEta()
Definition: Context.cc:194
size_t size() const
Definition: FWEventItem.cc:457
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:67
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static const int kAll3DBits
Definition: FWViewType.h:68
bool haveSingleProduct() const override
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static float caloR1(bool offset=true)
Definition: Context.cc:187
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
void setupElement(TEveElement *el, bool color=true) const
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
const FWConversionProxyBuilder & operator=(const FWConversionProxyBuilder &)=delete
static float caloZ1(bool offset=true)
Definition: Context.cc:190
void buildViewType(const reco::Conversion &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override
const FWEventItem * item() const