Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:20

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWViewEnergyScale
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Alja Mrak-Tadel
0010 //         Created:  Fri Jun 18 20:37:44 CEST 2010
0011 //
0012 
0013 #include <stdexcept>
0014 #include <iostream>
0015 #include <functional>
0016 
0017 #include "Rtypes.h"
0018 #include "TMath.h"
0019 #include "Fireworks/Core/interface/FWEveView.h"
0020 #include "Fireworks/Core/interface/FWViewEnergyScale.h"
0021 #include "Fireworks/Core/interface/Context.h"
0022 #include "Fireworks/Core/interface/CmsShowCommon.h"
0023 
0024 FWViewEnergyScale::FWViewEnergyScale(std::string name, int version)
0025     : FWConfigurableParameterizable(version),
0026       m_scaleMode(this, "ScaleMode", 1l, 1l, 2l),
0027       m_fixedValToHeight(this, "EnergyToLength [GeV/m]", 50.0, 1.0, 1000.0),
0028       m_maxTowerHeight(this, "MaximumLength [m]", 3.0, 0.01, 30.0),
0029       m_plotEt(this, "PlotEt", true),
0030       m_name(name),
0031       m_scaleFactor3D(1.f),
0032       m_scaleFactorLego(0.05f) {
0033   m_scaleMode.addEntry(kFixedScale, "FixedScale");
0034   m_scaleMode.addEntry(kAutoScale, "AutomaticScale");
0035   m_scaleMode.addEntry(kCombinedScale, "CombinedScale");
0036 
0037   m_scaleMode.changed_.connect(std::bind(&FWViewEnergyScale::scaleParameterChanged, this));
0038   m_fixedValToHeight.changed_.connect(std::bind(&FWViewEnergyScale::scaleParameterChanged, this));
0039   m_maxTowerHeight.changed_.connect(std::bind(&FWViewEnergyScale::scaleParameterChanged, this));
0040   m_plotEt.changed_.connect(std::bind(&FWViewEnergyScale::scaleParameterChanged, this));
0041 }
0042 
0043 FWViewEnergyScale::~FWViewEnergyScale() {}
0044 
0045 //________________________________________________________
0046 
0047 void FWViewEnergyScale::scaleParameterChanged() const { parameterChanged_.emit(); }
0048 
0049 float FWViewEnergyScale::calculateScaleFactor(float iMaxVal, bool isLego) const {
0050   // check if in combined mode
0051   int mode = m_scaleMode.value();
0052   if (mode == kCombinedScale) {
0053     mode = (m_maxTowerHeight.value() > 100 * iMaxVal / m_fixedValToHeight.value()) ? kFixedScale : kAutoScale;
0054     // printf("COMBINED  \n");
0055   }
0056   // get converison
0057 
0058   if (mode == kFixedScale) {
0059     //  printf("fixed mode %f \n",m_fixedValToHeight.value());
0060     // apply default constructor height
0061     float length = isLego ? TMath::Pi() : 100;
0062     return length / m_fixedValToHeight.value();
0063   } else {
0064     float length = isLego ? TMath::Pi() : (100 * m_maxTowerHeight.value());
0065     // printf("[%d] length %f max %f  \n", isLego, length, iMaxVal);
0066     return length / iMaxVal;
0067   }
0068 }
0069 
0070 void FWViewEnergyScale::updateScaleFactors(float iMaxVal) {
0071   m_scaleFactor3D = calculateScaleFactor(iMaxVal, false);
0072   m_scaleFactorLego = calculateScaleFactor(iMaxVal, true);
0073 }
0074 
0075 void FWViewEnergyScale::setFrom(const FWConfiguration& iFrom) {
0076   for (const_iterator it = begin(), itEnd = end(); it != itEnd; ++it) {
0077     (*it)->setFrom(iFrom);
0078   }
0079 }
0080 
0081 void FWViewEnergyScale::SetFromCmsShowCommonConfig(long mode, float convert, float maxH, bool et) {
0082   m_scaleMode.set(mode);
0083   m_fixedValToHeight.set(convert);
0084   m_maxTowerHeight.set(maxH);
0085   m_plotEt.set(et > 0);
0086 }