Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "TEveBoxSet.h"
00009 #include "TEveChunkManager.h"
00010 #include "Fireworks/Core/interface/FWDigitSetProxyBuilder.h"
00011 #include "Fireworks/Core/interface/FWEventItem.h"
00012 #include "Fireworks/Core/interface/FWGeometry.h"
00013 #include "Fireworks/Core/interface/FWViewEnergyScale.h"
00014 #include "Fireworks/Core/interface/BuilderUtils.h"
00015 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00016 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00017
00018 class FWEcalRecHitProxyBuilder : public FWDigitSetProxyBuilder
00019 {
00020 public:
00021 FWEcalRecHitProxyBuilder():FWDigitSetProxyBuilder(), m_plotEt(true) {}
00022 virtual ~FWEcalRecHitProxyBuilder() {}
00023
00024 virtual bool havePerViewProduct(FWViewType::EType) const { return true; }
00025 virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc);
00026
00027 REGISTER_PROXYBUILDER_METHODS();
00028
00029 private:
00030 FWEcalRecHitProxyBuilder( const FWEcalRecHitProxyBuilder& );
00031 const FWEcalRecHitProxyBuilder& operator=( const FWEcalRecHitProxyBuilder& );
00032
00033 virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* );
00034
00035 bool m_plotEt;
00036 };
00037
00038
00039
00040
00041 void
00042 FWEcalRecHitProxyBuilder::scaleProduct(TEveElementList* parent, FWViewType::EType type, const FWViewContext* vc)
00043 {
00044
00045 if (m_plotEt != vc->getEnergyScale()->getPlotEt() )
00046 {
00047 m_plotEt = !m_plotEt;
00048
00049 const EcalRecHitCollection* collection = 0;
00050 item()->get( collection );
00051 if (! collection)
00052 return;
00053
00054 int index = 0;
00055 std::vector<float> scaledCorners(24);
00056 for (std::vector<EcalRecHit>::const_iterator it = collection->begin() ; it != collection->end(); ++it, ++index)
00057 {
00058 const float* corners = item()->getGeom()->getCorners((*it).detid());
00059 if (corners == 0)
00060 continue;
00061
00062 Float_t scale = 10.0;
00063 bool reflect = false;
00064 if (EcalSubdetector( (*it).detid().subdetId() ) == EcalPreshower)
00065 {
00066 scale = 1000.0;
00067 reflect = corners[2] < 0;
00068 }
00069
00070 FWDigitSetProxyBuilder::BFreeBox_t* b = (FWDigitSetProxyBuilder::BFreeBox_t*)getBoxSet()->GetPlex()->Atom(index);
00071
00072
00073
00074
00075
00076
00077 if (m_plotEt)
00078 fireworks::etTower3DCorners(corners, (*it).energy() * scale, scaledCorners, reflect);
00079 else
00080 fireworks::energyTower3DCorners(corners, (*it).energy() * scale, scaledCorners, reflect);
00081
00082 memcpy(b->fVertices, &scaledCorners[0], sizeof(b->fVertices));
00083
00084
00085
00086
00087
00088
00089 }
00090 getBoxSet()->ElementChanged();
00091 }
00092 }
00093
00094
00095
00096 void FWEcalRecHitProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext* vc)
00097 {
00098 m_plotEt = vc->getEnergyScale()->getPlotEt();
00099
00100 const EcalRecHitCollection* collection = 0;
00101 iItem->get( collection );
00102 if (! collection)
00103 return;
00104
00105 TEveBoxSet* boxSet = addBoxSetToProduct(product);
00106 std::vector<float> scaledCorners(24);
00107 int index = 0;
00108 for (std::vector<EcalRecHit>::const_iterator it = collection->begin() ; it != collection->end(); ++it)
00109 {
00110 const float* corners = item()->getGeom()->getCorners((*it).detid());
00111 if (corners == 0)
00112 continue;
00113
00114 Float_t scale = 10.0;
00115 bool reflect = false;
00116 if (EcalSubdetector( (*it).detid().subdetId() ) == EcalPreshower)
00117 {
00118 scale = 1000.0;
00119 reflect = corners[2] < 0;
00120 }
00121
00122 if (m_plotEt)
00123 fireworks::energyTower3DCorners(corners, (*it).energy() * scale, scaledCorners, reflect);
00124 else
00125 fireworks::energyTower3DCorners(corners, (*it).energy() * scale, scaledCorners, reflect);
00126
00127 addBox(boxSet, &scaledCorners[0], iItem->modelInfo(index++).displayProperties());
00128 }
00129 }
00130
00131 REGISTER_FWPROXYBUILDER( FWEcalRecHitProxyBuilder, EcalRecHitCollection, "Ecal RecHit", FWViewType::kISpyBit );