Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <stdexcept>
00015 #include <iostream>
00016 #include <boost/bind.hpp>
00017
00018 #include "Rtypes.h"
00019 #include "TMath.h"
00020 #include "Fireworks/Core/interface/FWEveView.h"
00021 #include "Fireworks/Core/interface/FWViewEnergyScale.h"
00022 #include "Fireworks/Core/interface/Context.h"
00023 #include "Fireworks/Core/interface/CmsShowCommon.h"
00024
00025
00026 FWViewEnergyScale::FWViewEnergyScale(std::string name, int version):
00027 FWConfigurableParameterizable(version),
00028 m_scaleMode(this, "ScaleMode", 1l, 1l, 2l),
00029 m_fixedValToHeight(this, "EnergyToLength [GeV/m]", 50.0, 1.0, 100.0),
00030 m_maxTowerHeight(this, "MaximumLength [m]", 3.0, 0.01, 30.0 ),
00031 m_plotEt(this, "PlotEt", true),
00032 m_name(name),
00033 m_scaleFactor3D(1.f),
00034 m_scaleFactorLego(0.05f)
00035 {
00036 m_scaleMode.addEntry(kFixedScale, "FixedScale");
00037 m_scaleMode.addEntry(kAutoScale, "AutomaticScale");
00038 m_scaleMode.addEntry(kCombinedScale,"CombinedScale");
00039
00040 m_scaleMode.changed_.connect(boost::bind(&FWViewEnergyScale::scaleParameterChanged,this));
00041 m_fixedValToHeight.changed_.connect(boost::bind(&FWViewEnergyScale::scaleParameterChanged,this));
00042 m_maxTowerHeight.changed_.connect(boost::bind(&FWViewEnergyScale::scaleParameterChanged,this));
00043 m_plotEt.changed_.connect(boost::bind(&FWViewEnergyScale::scaleParameterChanged,this));
00044 }
00045
00046 FWViewEnergyScale::~FWViewEnergyScale()
00047 {
00048 }
00049
00050
00051
00052 void
00053 FWViewEnergyScale::scaleParameterChanged() const
00054 {
00055 parameterChanged_.emit();
00056 }
00057
00058 float
00059 FWViewEnergyScale::calculateScaleFactor(float iMaxVal, bool isLego) const
00060 {
00061
00062 int mode = m_scaleMode.value();
00063 if (mode == kCombinedScale)
00064 {
00065 mode = (m_maxTowerHeight.value() > 100*iMaxVal/m_fixedValToHeight.value()) ? kFixedScale : kAutoScale;
00066
00067 }
00068
00069
00070 if (mode == kFixedScale)
00071 {
00072
00073
00074 float length = isLego ? TMath::Pi() : 100;
00075 return length / m_fixedValToHeight.value();
00076 }
00077 else
00078 {
00079 float length = isLego ? TMath::Pi() : (100*m_maxTowerHeight.value()) ;
00080
00081 return length / iMaxVal;
00082 }
00083 }
00084
00085
00086 void
00087 FWViewEnergyScale::updateScaleFactors(float iMaxVal)
00088 {
00089 m_scaleFactor3D = calculateScaleFactor(iMaxVal, false);
00090 m_scaleFactorLego = calculateScaleFactor(iMaxVal, true);
00091 }
00092
00093 void
00094 FWViewEnergyScale::setFrom(const FWConfiguration& iFrom)
00095 {
00096 for(const_iterator it =begin(), itEnd = end();
00097 it != itEnd;
00098 ++it) {
00099 (*it)->setFrom(iFrom);
00100 }
00101 }
00102
00103 void
00104 FWViewEnergyScale::SetFromCmsShowCommonConfig(long mode, float convert, float maxH, bool et)
00105 {
00106 m_scaleMode.set(mode);
00107 m_fixedValToHeight.set(convert);
00108 m_maxTowerHeight.set(maxH);
00109 m_plotEt.set(et > 0);
00110 }