CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWViewEnergyScale.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWViewEnergyScale
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Alja Mrak-Tadel
10 // Created: Fri Jun 18 20:37:44 CEST 2010
11 // $Id: FWViewEnergyScale.cc,v 1.10 2010/11/27 22:08:24 amraktad Exp $
12 //
13 
14 #include <stdexcept>
15 #include <iostream>
16 #include <boost/bind.hpp>
17 
18 #include "Rtypes.h"
19 #include "TMath.h"
24 
25 
28 m_scaleMode(this, "ScaleMode", 1l, 1l, 2l),
29 m_fixedValToHeight(this, "EnergyToLength [GeV/m]", 50.0, 1.0, 100.0),
30 m_maxTowerHeight(this, "MaximumLength [m]", 3.0, 0.01, 30.0 ),
31 m_plotEt(this, "PlotEt", true),
32 m_name(name),
33 m_scaleFactor3D(1.f),
34 m_scaleFactorLego(0.05f)
35 {
36  m_scaleMode.addEntry(kFixedScale, "FixedScale");
37  m_scaleMode.addEntry(kAutoScale, "AutomaticScale");
38  m_scaleMode.addEntry(kCombinedScale,"CombinedScale");
39 
44 }
45 
47 {
48 }
49 
50 //________________________________________________________
51 
52 void
54 {
55  parameterChanged_.emit();
56 }
57 
58 float
59 FWViewEnergyScale::calculateScaleFactor(float iMaxVal, bool isLego) const
60 {
61  // check if in combined mode
62  int mode = m_scaleMode.value();
63  if (mode == kCombinedScale)
64  {
65  mode = (m_maxTowerHeight.value() > 100*iMaxVal/m_fixedValToHeight.value()) ? kFixedScale : kAutoScale;
66  // printf("COMBINED \n");
67  }
68  // get converison
69 
70  if (mode == kFixedScale)
71  {
72  // printf("fixed mode %f \n",m_fixedValToHeight.value());
73  // apply default constructor height
74  float length = isLego ? TMath::Pi() : 100;
75  return length / m_fixedValToHeight.value();
76  }
77  else
78  {
79  float length = isLego ? TMath::Pi() : (100*m_maxTowerHeight.value()) ;
80  // printf("[%d] length %f max %f \n", isLego, length, iMaxVal);
81  return length / iMaxVal;
82  }
83 }
84 
85 
86 void
88 {
89  m_scaleFactor3D = calculateScaleFactor(iMaxVal, false);
90  m_scaleFactorLego = calculateScaleFactor(iMaxVal, true);
91 }
92 
93 void
95 {
96  for(const_iterator it =begin(), itEnd = end();
97  it != itEnd;
98  ++it) {
99  (*it)->setFrom(iFrom);
100  }
101 }
102 
103 void
105 {
106  m_scaleMode.set(mode);
107  m_fixedValToHeight.set(convert);
108  m_maxTowerHeight.set(maxH);
109  m_plotEt.set(et > 0);
110 }
const double Pi
FWDoubleParameter m_fixedValToHeight
virtual ~FWViewEnergyScale()
std::vector< FWParameterBase * >::const_iterator const_iterator
void scaleParameterChanged() const
const_iterator begin() const
FWBoolParameter m_plotEt
void updateScaleFactors(float iMaxVal)
sigc::signal< void, T > changed_
void convert(uint32 i, char_uint32 v)
Definition: MsgTools.h:46
virtual void setFrom(const FWConfiguration &)
float calculateScaleFactor(float iMaxVal, bool isLego) const
void SetFromCmsShowCommonConfig(long mode, float convert, float maxH, bool et)
const_iterator end() const
bool addEntry(Long_t id, const std::string &txt)
double f[11][100]
FWDoubleParameter m_maxTowerHeight
FWEnumParameter m_scaleMode
sigc::signal< void > parameterChanged_
FWViewEnergyScale(std::string name, int version)