File indexing completed on 2024-04-06 12:11:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "TEveCompound.h"
0013 #include "TEveLine.h"
0014 #include "TEveScalableStraightLineSet.h"
0015
0016 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0017 #include "Fireworks/Core/interface/FWEventItem.h"
0018 #include "Fireworks/Core/interface/FWViewType.h"
0019 #include "Fireworks/Core/interface/Context.h"
0020
0021 #include "Fireworks/Candidates/interface/CandidateUtils.h"
0022 #include "Fireworks/Tracks/interface/TrackUtils.h"
0023 #include "Fireworks/Electrons/interface/makeSuperCluster.h"
0024
0025 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
0026 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
0027
0028
0029
0030
0031
0032
0033
0034 class FWConversionProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Conversion> {
0035 public:
0036 FWConversionProxyBuilder();
0037 ~FWConversionProxyBuilder() override;
0038
0039 bool haveSingleProduct() const override { return false; }
0040 void cleanLocal() override;
0041
0042 REGISTER_PROXYBUILDER_METHODS();
0043
0044 FWConversionProxyBuilder(const FWConversionProxyBuilder&) = delete;
0045 const FWConversionProxyBuilder& operator=(const FWConversionProxyBuilder&) = delete;
0046
0047 private:
0048 using FWSimpleProxyBuilderTemplate<reco::Conversion>::buildViewType;
0049 void buildViewType(const reco::Conversion& iData,
0050 unsigned int iIndex,
0051 TEveElement& oItemHolder,
0052 FWViewType::EType type,
0053 const FWViewContext*) override;
0054
0055 TEveElementList* requestCommon();
0056
0057 TEveElementList* m_common;
0058 };
0059
0060 FWConversionProxyBuilder::FWConversionProxyBuilder() : m_common(nullptr) {
0061 m_common = new TEveElementList("common conversion scene");
0062 m_common->IncDenyDestroy();
0063 }
0064
0065 FWConversionProxyBuilder::~FWConversionProxyBuilder() { m_common->DecDenyDestroy(); }
0066
0067 TEveElementList* FWConversionProxyBuilder::requestCommon() {
0068 if (m_common->HasChildren() == false) {
0069 for (int i = 0; i < static_cast<int>(item()->size()); ++i) {
0070 const reco::Conversion& conversion = modelData(i);
0071 TEveLine* line = new TEveLine(0);
0072 if (conversion.nTracks() == 2) {
0073 if (fabs(conversion.zOfPrimaryVertexFromTracks()) < fireworks::Context::caloZ1())
0074 line->SetNextPoint(0., 0., conversion.zOfPrimaryVertexFromTracks());
0075 else
0076 line->SetNextPoint(0., 0., 0.);
0077
0078 float phi = conversion.pairMomentum().phi();
0079 if (fabs(conversion.pairMomentum().eta()) < fireworks::Context::caloTransEta()) {
0080 float radius = fireworks::Context::caloR1();
0081 float z = radius / tan(conversion.pairMomentum().theta());
0082 line->SetNextPoint(radius * cos(phi), radius * sin(phi), z);
0083 } else {
0084 float z = fireworks::Context::caloZ1();
0085 float radius = z * tan(conversion.pairMomentum().theta());
0086 z *= (conversion.pairMomentum().eta() / fabs(conversion.pairMomentum().eta()));
0087 line->SetNextPoint(radius * cos(phi), radius * sin(phi), z);
0088 }
0089 } else {
0090 line->SetNextPoint(0., 0., 0.);
0091 line->SetNextPoint(0., 0., 0.);
0092 }
0093
0094 setupElement(line);
0095 m_common->AddElement(line);
0096 }
0097 }
0098
0099 return m_common;
0100 }
0101
0102 void FWConversionProxyBuilder::cleanLocal() { m_common->DestroyElements(); }
0103
0104 void FWConversionProxyBuilder::buildViewType(const reco::Conversion& conversion,
0105 unsigned int iIndex,
0106 TEveElement& oItemHolder,
0107 FWViewType::EType type,
0108 const FWViewContext*) {
0109 TEveElementList* lines = requestCommon();
0110 TEveElement::List_i linIt = lines->BeginChildren();
0111 std::advance(linIt, iIndex);
0112 TEveLine* line = (TEveLine*)((*linIt)->CloneElement());
0113 TEveVector bvec = line->GetLineStart();
0114 TEveVector evec = line->GetLineEnd();
0115 if (bvec.Mag() != evec.Mag())
0116 setupAddElement(*linIt, &oItemHolder);
0117 }
0118
0119 REGISTER_FWPROXYBUILDER(FWConversionProxyBuilder,
0120 reco::Conversion,
0121 "Conversions",
0122 FWViewType::kAll3DBits | FWViewType::kAllRPZBits);