CMS 3D CMS Logo

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 //
12 
13 #include <stdexcept>
14 #include <iostream>
15 #include <boost/bind.hpp>
16 
17 #include "Rtypes.h"
18 #include "TMath.h"
23 
24 
27 m_scaleMode(this, "ScaleMode", 1l, 1l, 2l),
28 m_fixedValToHeight(this, "EnergyToLength [GeV/m]", 50.0, 1.0, 100.0),
29 m_maxTowerHeight(this, "MaximumLength [m]", 3.0, 0.01, 30.0 ),
30 m_plotEt(this, "PlotEt", true),
31 m_name(name),
32 m_scaleFactor3D(1.f),
33 m_scaleFactorLego(0.05f)
34 {
35  m_scaleMode.addEntry(kFixedScale, "FixedScale");
36  m_scaleMode.addEntry(kAutoScale, "AutomaticScale");
37  m_scaleMode.addEntry(kCombinedScale,"CombinedScale");
38 
43 }
44 
46 {
47 }
48 
49 //________________________________________________________
50 
51 void
53 {
54  parameterChanged_.emit();
55 }
56 
57 float
58 FWViewEnergyScale::calculateScaleFactor(float iMaxVal, bool isLego) const
59 {
60  // check if in combined mode
61  int mode = m_scaleMode.value();
62  if (mode == kCombinedScale)
63  {
64  mode = (m_maxTowerHeight.value() > 100*iMaxVal/m_fixedValToHeight.value()) ? kFixedScale : kAutoScale;
65  // printf("COMBINED \n");
66  }
67  // get converison
68 
69  if (mode == kFixedScale)
70  {
71  // printf("fixed mode %f \n",m_fixedValToHeight.value());
72  // apply default constructor height
73  float length = isLego ? TMath::Pi() : 100;
74  return length / m_fixedValToHeight.value();
75  }
76  else
77  {
78  float length = isLego ? TMath::Pi() : (100*m_maxTowerHeight.value()) ;
79  // printf("[%d] length %f max %f \n", isLego, length, iMaxVal);
80  return length / iMaxVal;
81  }
82 }
83 
84 
85 void
87 {
88  m_scaleFactor3D = calculateScaleFactor(iMaxVal, false);
89  m_scaleFactorLego = calculateScaleFactor(iMaxVal, true);
90 }
91 
92 void
94 {
95  for(const_iterator it =begin(), itEnd = end();
96  it != itEnd;
97  ++it) {
98  (*it)->setFrom(iFrom);
99  }
100 }
101 
102 void
104 {
105  m_scaleMode.set(mode);
106  m_fixedValToHeight.set(convert);
107  m_maxTowerHeight.set(maxH);
108  m_plotEt.set(et > 0);
109 }
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_
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]
def convert(infile, ofile)
FWDoubleParameter m_maxTowerHeight
FWEnumParameter m_scaleMode
et
define resolution functions of each parameter
sigc::signal< void > parameterChanged_
FWViewEnergyScale(std::string name, int version)