test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
36 public:
38  virtual ~FWConversionProxyBuilder();
39 
40  virtual bool haveSingleProduct() const override { return false; }
41  virtual void cleanLocal() override;
42 
44 
45 private:
46  FWConversionProxyBuilder( const FWConversionProxyBuilder& ); // stop default
47  const FWConversionProxyBuilder& operator=( const FWConversionProxyBuilder& ); // stop default
48 
50  virtual void buildViewType(const reco::Conversion& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*) override;
51 
52  TEveElementList* requestCommon();
53 
54  TEveElementList* m_common;
55 };
56 
57 
59  m_common(0)
60 {
61  m_common = new TEveElementList( "common conversion scene" );
62  m_common->IncDenyDestroy();
63 }
64 
66 {
67  m_common->DecDenyDestroy();
68 }
69 
70 TEveElementList*
72 {
73  if( m_common->HasChildren() == false )
74  {
75  for (int i = 0; i < static_cast<int>(item()->size()); ++i)
76  {
78  TEveLine* line = new TEveLine(0);
79  if (conversion.nTracks() == 2) {
80  if (fabs(conversion.zOfPrimaryVertexFromTracks()) < fireworks::Context::caloZ1())
81  line->SetNextPoint(0., 0., conversion.zOfPrimaryVertexFromTracks());
82  else
83  line->SetNextPoint(0., 0., 0.);
84 
85  float phi = conversion.pairMomentum().phi();
86  if (fabs(conversion.pairMomentum().eta()) < fireworks::Context::caloTransEta()) {
88  float z = radius/tan(conversion.pairMomentum().theta());
89  line->SetNextPoint(radius*cos(phi), radius*sin(phi), z);
90  }
91  else {
92  float z = fireworks::Context::caloZ1();
93  float radius = z*tan(conversion.pairMomentum().theta());
94  z *= (conversion.pairMomentum().eta()/fabs(conversion.pairMomentum().eta()));
95  line->SetNextPoint(radius*cos(phi), radius*sin(phi), z);
96  }
97  }
98  else {
99  line->SetNextPoint(0., 0., 0.);
100  line->SetNextPoint(0., 0., 0.);
101  }
102 
103  setupElement( line );
104  m_common->AddElement( line );
105  }
106  }
107 
108  return m_common;
109 }
110 
111 void
113 {
114  m_common->DestroyElements();
115 }
116 
117 void
118 FWConversionProxyBuilder::buildViewType(const reco::Conversion& conversion, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*)
119 {
120  TEveElementList* lines = requestCommon();
121  TEveElement::List_i linIt = lines->BeginChildren();
122  std::advance(linIt, iIndex);
123  TEveLine* line = (TEveLine*)((*linIt)->CloneElement());
124  TEveVector bvec = line->GetLineStart();
125  TEveVector evec = line->GetLineEnd();
126  if (bvec.Mag() != evec.Mag())
127  setupAddElement(*linIt, &oItemHolder );
128 }
129 
static float caloTransEta()
Definition: Context.cc:228
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double zOfPrimaryVertexFromTracks(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.h:145
virtual bool haveSingleProduct() const override
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static float caloR1(bool offset=true)
Definition: Context.cc:208
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
unsigned int nTracks() const
Number of tracks= 0,1,2.
Definition: Conversion.h:101
math::XYZVectorF pairMomentum() const
Conversion tracks momentum from the tracks inner momentum.
Definition: Conversion.cc:223
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
size_t size() const
Definition: FWEventItem.cc:550
const FWConversionProxyBuilder & operator=(const FWConversionProxyBuilder &)
virtual void cleanLocal() override
static float caloZ1(bool offset=true)
Definition: Context.cc:218
volatile std::atomic< bool > shutdown_flag false
virtual void buildViewType(const reco::Conversion &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override
void setupElement(TEveElement *el, bool color=true) const