Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <math.h>
00017
00018
00019 #include "TEveCaloData.h"
00020 #include "TEveCalo.h"
00021 #include "TH2F.h"
00022 #include "TEveManager.h"
00023 #include "TEveSelection.h"
00024
00025 #include "Fireworks/Core/interface/Context.h"
00026 #include "Fireworks/Core/interface/FWEventItem.h"
00027
00028 #include "Fireworks/Calo/interface/FWCaloDataProxyBuilderBase.h"
00029 #include "Fireworks/Calo/src/FWFromTEveCaloDataSelector.h"
00030
00031 #include "DataFormats/CaloTowers/interface/CaloTower.h"
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 FWCaloDataProxyBuilderBase::FWCaloDataProxyBuilderBase() :
00046 m_caloData(0),
00047 m_sliceIndex(-1)
00048 {
00049 }
00050
00051
00052
00053
00054
00055
00056 FWCaloDataProxyBuilderBase::~FWCaloDataProxyBuilderBase()
00057 {
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 void
00077 FWCaloDataProxyBuilderBase::build(const FWEventItem* iItem,
00078 TEveElementList*, const FWViewContext*)
00079 {
00080 setCaloData(iItem->context());
00081
00082 assertCaloDataSlice();
00083 fillCaloData();
00084
00085 m_caloData->SetSliceColor(m_sliceIndex,item()->defaultDisplayProperties().color());
00086 m_caloData->SetSliceTransparency(m_sliceIndex,item()->defaultDisplayProperties().transparency());
00087 m_caloData->DataChanged();
00088 m_caloData->CellSelectionChanged();
00089 }
00090
00091
00092
00093 void
00094 FWCaloDataProxyBuilderBase::modelChanges(const FWModelIds&, Product* p)
00095 {
00096 if(m_caloData && item())
00097 {
00098 clearCaloDataSelection();
00099 fillCaloData();
00100
00101 TEveCaloData::vCellId_t& selected = m_caloData->GetCellsSelected();
00102 if(!selected.empty()) {
00103 if(0==m_caloData->GetSelectedLevel()) {
00104 gEve->GetSelection()->AddElement(m_caloData);
00105 }
00106 } else {
00107 if(1==m_caloData->GetSelectedLevel()||2==m_caloData->GetSelectedLevel()) {
00108 gEve->GetSelection()->RemoveElement(m_caloData);
00109 }
00110 }
00111
00112 m_caloData->SetSliceColor(m_sliceIndex,item()->defaultDisplayProperties().color());
00113 m_caloData->SetSliceTransparency(m_sliceIndex,item()->defaultDisplayProperties().transparency());
00114 m_caloData->DataChanged();
00115 m_caloData->CellSelectionChanged();
00116 }
00117 }
00118
00119
00120 void
00121 FWCaloDataProxyBuilderBase::itemBeingDestroyed(const FWEventItem* iItem)
00122 {
00123 FWProxyBuilderBase::itemBeingDestroyed(iItem);
00124 if (m_caloData)
00125 {
00126 clearCaloDataSelection();
00127 FWFromTEveCaloDataSelector* sel = reinterpret_cast<FWFromTEveCaloDataSelector*>(m_caloData->GetUserData());
00128 sel->resetSliceSelector(m_sliceIndex);
00129 m_caloData->DataChanged();
00130 }
00131 }
00132
00133
00134
00135 void
00136 FWCaloDataProxyBuilderBase::clearCaloDataSelection()
00137 {
00138
00139
00140
00141
00142 TEveCaloData::vCellId_t& selected = m_caloData->GetCellsSelected();
00143
00144 TEveCaloData::vCellId_t::iterator itEnd = selected.end();
00145 for(TEveCaloData::vCellId_t::iterator it = selected.begin();
00146 it != itEnd;
00147 ++it) {
00148 if(it->fSlice ==m_sliceIndex) {
00149
00150
00151 do {
00152 TEveCaloData::vCellId_t::iterator itLast = itEnd-1;
00153 itEnd = itLast;
00154 } while (itEnd != it && itEnd->fSlice==m_sliceIndex);
00155
00156 if(itEnd != it) {
00157 std::swap(*it,*itEnd);
00158 } else {
00159
00160 break;
00161 }
00162
00163 }
00164 }
00165 selected.erase(itEnd,selected.end());
00166
00167
00168
00169 m_caloData->GetCellsHighlighted().clear();
00170 }