Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "TEveCompound.h"
00014 #include "TEveLine.h"
00015 #include "TEveScalableStraightLineSet.h"
00016
00017 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00018 #include "Fireworks/Core/interface/FWEventItem.h"
00019 #include "Fireworks/Core/interface/FWViewType.h"
00020 #include "Fireworks/Core/interface/Context.h"
00021
00022 #include "Fireworks/Candidates/interface/CandidateUtils.h"
00023 #include "Fireworks/Tracks/interface/TrackUtils.h"
00024 #include "Fireworks/Electrons/interface/makeSuperCluster.h"
00025
00026 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
00027 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00028
00030
00031
00032
00034
00035 class FWConversionProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Conversion> {
00036
00037 public:
00038 FWConversionProxyBuilder() ;
00039 virtual ~FWConversionProxyBuilder();
00040
00041 virtual bool haveSingleProduct() const { return false; }
00042 virtual void cleanLocal();
00043
00044 REGISTER_PROXYBUILDER_METHODS();
00045
00046 private:
00047 FWConversionProxyBuilder( const FWConversionProxyBuilder& );
00048 const FWConversionProxyBuilder& operator=( const FWConversionProxyBuilder& );
00049
00050 virtual void buildViewType(const reco::Conversion& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*);
00051
00052 TEveElementList* requestCommon();
00053
00054 TEveElementList* m_common;
00055 };
00056
00057
00058 FWConversionProxyBuilder::FWConversionProxyBuilder():
00059 m_common(0)
00060 {
00061 m_common = new TEveElementList( "common conversion scene" );
00062 m_common->IncDenyDestroy();
00063 }
00064
00065 FWConversionProxyBuilder::~FWConversionProxyBuilder()
00066 {
00067 m_common->DecDenyDestroy();
00068 }
00069
00070 TEveElementList*
00071 FWConversionProxyBuilder::requestCommon()
00072 {
00073 if( m_common->HasChildren() == false )
00074 {
00075 for (int i = 0; i < static_cast<int>(item()->size()); ++i)
00076 {
00077 const reco::Conversion& conversion = modelData(i);
00078 TEveLine* line = new TEveLine(0);
00079 if (conversion.nTracks() == 2) {
00080 if (fabs(conversion.zOfPrimaryVertexFromTracks()) < fireworks::Context::caloZ1())
00081 line->SetNextPoint(0., 0., conversion.zOfPrimaryVertexFromTracks());
00082 else
00083 line->SetNextPoint(0., 0., 0.);
00084
00085 float phi = conversion.pairMomentum().phi();
00086 if (fabs(conversion.pairMomentum().eta()) < fireworks::Context::caloTransEta()) {
00087 float radius = fireworks::Context::caloR1();
00088 float z = radius/tan(conversion.pairMomentum().theta());
00089 line->SetNextPoint(radius*cos(phi), radius*sin(phi), z);
00090 }
00091 else {
00092 float z = fireworks::Context::caloZ1();
00093 float radius = z*tan(conversion.pairMomentum().theta());
00094 z *= (conversion.pairMomentum().eta()/fabs(conversion.pairMomentum().eta()));
00095 line->SetNextPoint(radius*cos(phi), radius*sin(phi), z);
00096 }
00097 }
00098 else {
00099 line->SetNextPoint(0., 0., 0.);
00100 line->SetNextPoint(0., 0., 0.);
00101 }
00102
00103 setupElement( line );
00104 m_common->AddElement( line );
00105 }
00106 }
00107
00108 return m_common;
00109 }
00110
00111 void
00112 FWConversionProxyBuilder::cleanLocal()
00113 {
00114 m_common->DestroyElements();
00115 }
00116
00117 void
00118 FWConversionProxyBuilder::buildViewType(const reco::Conversion& conversion, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*)
00119 {
00120 TEveElementList* lines = requestCommon();
00121 TEveElement::List_i linIt = lines->BeginChildren();
00122 std::advance(linIt, iIndex);
00123 TEveLine* line = (TEveLine*)((*linIt)->CloneElement());
00124 TEveVector bvec = line->GetLineStart();
00125 TEveVector evec = line->GetLineEnd();
00126 if (bvec.Mag() != evec.Mag())
00127 setupAddElement(*linIt, &oItemHolder );
00128 }
00129
00130 REGISTER_FWPROXYBUILDER( FWConversionProxyBuilder, reco::Conversion, "Conversions", FWViewType::kAll3DBits | FWViewType::kAllRPZBits );