00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <boost/bind.hpp>
00016
00017
00018 #include "TEveManager.h"
00019 #include "TEveTrackPropagator.h"
00020
00021 #include "Fireworks/Core/interface/CmsShowCommon.h"
00022 #include "Fireworks/Core/interface/FWEveView.h"
00023
00024 #include "Fireworks/Core/interface/Context.h"
00025
00026
00027
00028
00029
00030 CmsShowCommon::CmsShowCommon(fireworks::Context* c):
00031 FWConfigurableParameterizable(2),
00032 m_context(c),
00033 m_trackBreak(this, " ", 2l, 0l, 2l),
00034 m_drawBreakPoints(this, "Show y=0 points as markers", true),
00035 m_backgroundColor(this, "backgroundColIdx", 1l, 0l, 1000l),
00036 m_gamma(this, "Brightness", 0l, -15l, 15l),
00037 m_geomTransparency2D(this, "Transparency 2D", long(colorManager()->geomTransparency(true)), 0l, 100l),
00038 m_geomTransparency3D(this, "Transparency 3D", long(colorManager()->geomTransparency(false)), 0l, 100l),
00039 m_energyScale(new FWViewEnergyScale("global", 2))
00040 {
00041
00042 m_trackBreak.addEntry(0, "Jump to proper hemisphere");
00043 m_trackBreak.addEntry(1, "Stay on first point side");
00044 m_trackBreak.addEntry(2, "Stay on last point side");
00045
00046
00047 char name[32];
00048 for (int i = 0; i < kFWGeomColorSize; ++i)
00049 {
00050 snprintf(name, 31, "GeometryColor %d ", i);
00051 m_geomColors[i] = new FWLongParameter(this, name , long(colorManager()->geomColor(FWGeomColorIndex(i))), 1000l, 1100l);
00052 }
00053
00054 m_trackBreak.changed_.connect(boost::bind(&CmsShowCommon::setTrackBreakMode, this));
00055 m_drawBreakPoints.changed_.connect(boost::bind(&CmsShowCommon::setDrawBreakMarkers, this));
00056 m_gamma.changed_.connect(boost::bind(&CmsShowCommon::setGamma, this));
00057 }
00058
00059 CmsShowCommon::~CmsShowCommon()
00060 {
00061 }
00062
00063
00064 const FWColorManager* CmsShowCommon::colorManager() const
00065 {
00066 return m_context->colorManager();
00067 }
00068
00069
00070
00071
00072
00073 void
00074 CmsShowCommon::setTrackBreakMode()
00075 {
00076 if (m_context->getTrackPropagator()->GetProjTrackBreaking() != m_trackBreak.value())
00077 {
00078 m_context->getTrackPropagator()->SetProjTrackBreaking(m_trackBreak.value());
00079 m_context->getTrackerTrackPropagator()->SetProjTrackBreaking(m_trackBreak.value());
00080 m_context->getMuonTrackPropagator()->SetProjTrackBreaking(m_trackBreak.value());
00081 gEve->Redraw3D();
00082 }
00083 }
00084
00085
00086 void
00087 CmsShowCommon::setDrawBreakMarkers()
00088 {
00089 if (m_context->getTrackPropagator()->GetRnrPTBMarkers() != m_drawBreakPoints.value())
00090 {
00091 m_context->getTrackPropagator()->SetRnrPTBMarkers(m_drawBreakPoints.value());
00092 m_context->getTrackerTrackPropagator()->SetRnrPTBMarkers(m_drawBreakPoints.value());
00093 m_context->getMuonTrackPropagator()->SetRnrPTBMarkers(m_drawBreakPoints.value());
00094 gEve->Redraw3D();
00095 }
00096 }
00097
00098 void
00099 CmsShowCommon::setGamma()
00100 {
00101 m_context->colorManager()->setBrightness(m_gamma.value());
00102 }
00103
00104 void
00105 CmsShowCommon::switchBackground()
00106 {
00107 m_context->colorManager()->switchBackground();
00108 m_backgroundColor.set(colorManager()->background());
00109 }
00110
00111 void
00112 CmsShowCommon::setGeomColor(FWGeomColorIndex cidx, Color_t iColor)
00113 {
00114 m_geomColors[cidx]->set(iColor);
00115 m_context->colorManager()->setGeomColor(cidx, iColor);
00116 }
00117
00118 void
00119 CmsShowCommon::setGeomTransparency(int iTransp, bool projected)
00120 {
00121 if (projected)
00122 m_geomTransparency2D.set(iTransp);
00123 else
00124 m_geomTransparency3D.set(iTransp);
00125
00126 m_context->colorManager()->setGeomTransparency(iTransp, projected);
00127 }
00128
00129
00130
00131 void
00132 CmsShowCommon::addTo(FWConfiguration& oTo) const
00133 {
00134 m_backgroundColor.set(int(colorManager()->background()));
00135
00136 FWConfigurableParameterizable::addTo(oTo);
00137 m_energyScale->addTo(oTo);
00138 }
00139
00140 void
00141 CmsShowCommon::setFrom(const FWConfiguration& iFrom)
00142 {
00143 for(const_iterator it =begin(), itEnd = end();
00144 it != itEnd;
00145 ++it) {
00146 (*it)->setFrom(iFrom);
00147 }
00148
00149
00150 if (iFrom.valueForKey("ScaleMode"))
00151 {
00152 long mode = atol(iFrom.valueForKey("ScaleMode")->value().c_str());
00153
00154 float convert;
00155 if (iFrom.valueForKey("EnergyToLength [GeV/m]"))
00156 convert = atof(iFrom.valueForKey("EnergyToLength [GeV/m]")->value().c_str());
00157 else
00158 convert = atof(iFrom.valueForKey("ValueToHeight [GeV/m]")->value().c_str());
00159
00160 float maxH;
00161 if (iFrom.valueForKey("MaximumLength [m]"))
00162 maxH = atof(iFrom.valueForKey("MaximumLength [m]")->value().c_str());
00163 else
00164 maxH = atof(iFrom.valueForKey("MaxTowerH [m]")->value().c_str());
00165
00166 int et = atoi(iFrom.valueForKey("PlotEt")->value().c_str());
00167 m_energyScale->SetFromCmsShowCommonConfig(mode, convert, maxH, et);
00168 }
00169
00170
00171 FWColorManager* cm = m_context->colorManager();
00172 cm->setBackgroundAndBrightness( FWColorManager::BackgroundColorIndex(m_backgroundColor.value()), m_gamma.value());
00173
00174
00175 cm->setGeomTransparency( m_geomTransparency2D.value(), true);
00176 cm->setGeomTransparency( m_geomTransparency3D.value(), false);
00177
00178 for (int i = 0; i < kFWGeomColorSize; ++i)
00179 cm->setGeomColor(FWGeomColorIndex(i), m_geomColors[i]->value());
00180 }