CMS 3D CMS Logo

Context.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : Context
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Sep 30 14:57:12 EDT 2008
11 //
12 
13 // system include files
14 
15 // user include files
16 #include "TH2.h"
17 #include "TMath.h"
18 #include "TEveTrackPropagator.h"
19 #include "TEveCaloData.h"
21 
26 
27 #include <functional>
28 
29 using namespace fireworks;
30 
31 Context* Context::s_fwContext = nullptr;
32 
33 const float Context::s_caloTransEta = 1.479;
34 const float Context::s_caloTransAngle = 2 * atan(exp(-s_caloTransEta));
35 
36 // simplified
37 const float Context::s_caloZ = 290;
38 const float Context::s_caloR = s_caloZ * tan(s_caloTransAngle);
39 
40 /*
41 // barrel
42 const float Context::s_caloR1 = 129;
43 const float Context::s_caloZ1 = s_caloR1/tan(s_caloTransAngle);
44 // endcap
45 const float Context::s_caloZ2 = 315.4;
46 const float Context::s_caloR2 = s_caloZ2*tan(s_caloTransAngle);
47 */
48 
49 // calorimeter offset between TEveCalo and outlines (used by proxy builders)
50 const float Context::s_caloOffR = 10;
51 const float Context::s_caloOffZ = s_caloOffR / tan(s_caloTransAngle);
52 
53 //
54 // constructors and destructor
55 //
57  FWSelectionManager* iSM,
59  FWColorManager* iColorM,
60  FWJobMetadataManager* iJMDM)
61  : m_changeManager(iCM),
62  m_selectionManager(iSM),
63  m_eventItemsManager(iEM),
64  m_colorManager(iColorM),
65  m_metadataManager(iJMDM),
66  m_geom(nullptr),
67  m_propagator(nullptr),
68  m_trackerPropagator(nullptr),
69  m_muonPropagator(nullptr),
70  m_magField(nullptr),
71  m_beamSpot(nullptr),
72  m_commonPrefs(nullptr),
73  m_maxEt(1.f),
74  m_maxEnergy(1.f),
75  m_hidePFBuilders(false),
76  m_caloData(nullptr),
77  m_caloDataHF(nullptr) {
78  if (iColorM) // unit test
79  m_commonPrefs = new CmsShowCommon(this);
80 
81  s_fwContext = this;
82 }
83 
85 
87  m_magField = new FWMagField();
88  m_beamSpot = new FWBeamSpot();
89 
90  float propagatorOffR = 5;
91  float propagatorOffZ = propagatorOffR * caloZ1(false) / caloR1(false);
92 
93  // common propagator, helix stepper
94  m_propagator = new TEveTrackPropagator();
95  m_propagator->SetMagFieldObj(m_magField, false);
96  m_propagator->SetMaxR(caloR2() - propagatorOffR);
97  m_propagator->SetMaxZ(caloZ2() - propagatorOffZ);
98  m_propagator->SetDelta(0.01);
99  m_propagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
100  m_propagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
101  m_propagator->IncDenyDestroy();
102  // tracker propagator
103  m_trackerPropagator = new TEveTrackPropagator();
104  m_trackerPropagator->SetStepper(TEveTrackPropagator::kRungeKutta);
105  m_trackerPropagator->SetMagFieldObj(m_magField, false);
106  m_trackerPropagator->SetDelta(0.01);
107  m_trackerPropagator->SetMaxR(caloR1() - propagatorOffR);
108  m_trackerPropagator->SetMaxZ(caloZ2() - propagatorOffZ);
109  m_trackerPropagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
110  m_trackerPropagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
111  m_trackerPropagator->IncDenyDestroy();
112  // muon propagator
113  m_muonPropagator = new TEveTrackPropagator();
114  m_muonPropagator->SetStepper(TEveTrackPropagator::kRungeKutta);
115  m_muonPropagator->SetMagFieldObj(m_magField, false);
116  m_muonPropagator->SetDelta(0.05);
117  m_muonPropagator->SetMaxR(850.f);
118  m_muonPropagator->SetMaxZ(1100.f);
119  m_muonPropagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
120  m_muonPropagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
121  m_muonPropagator->IncDenyDestroy();
122 
123  // general calo data
124  {
125  m_caloData = new TEveCaloDataHist();
126  m_caloData->IncDenyDestroy();
127 
128  // Phi range is always in the (-Pi, Pi) without a shift.
129  // Set wrap to false for the optimisation on TEveCaloData::GetCellList().
130  m_caloData->SetWrapTwoPi(false);
131 
132  Bool_t status = TH1::AddDirectoryStatus();
133  TH1::AddDirectory(kFALSE); //Keeps histogram from going into memory
134  TH2F* dummy =
135  new TH2F("background", "background", fw3dlego::xbins_n - 1, fw3dlego::xbins, 72, -1 * TMath::Pi(), TMath::Pi());
136 
137  TH1::AddDirectory(status);
138  Int_t sliceIndex = m_caloData->AddHistogram(dummy);
139  (m_caloData)->RefSliceInfo(sliceIndex).Setup("background", 0., 0);
140  }
141  // HF calo data
142  {
143  m_caloDataHF = new TEveCaloDataVec(1);
144  m_caloDataHF->IncDenyDestroy();
145  m_caloDataHF->SetWrapTwoPi(false);
146  m_caloDataHF->RefSliceInfo(0).Setup("bg", 0.3, kRed);
147  m_caloDataHF->SetEtaBins(new TAxis(fw3dlego::xbins_hf_n - 1, fw3dlego::xbins_hf));
148  Double_t off = 10 * TMath::DegToRad();
149  m_caloDataHF->SetPhiBins(new TAxis(36, -TMath::Pi() - off, TMath::Pi() - off));
150  }
151 }
152 
154  // AMT: delete of eve-elements disabled to prevent crash on exit.
155  // A lot of eve objects use this elements (e.g. TEveCalo, TEveTrack ...)
156  // If want to have explicit delete make sure order of destruction
157  // is correct: this should be called after all scenes are destroyed.
158 }
159 
161 
162 void Context::voteMaxEtAndEnergy(float et, float energy) const {
165 }
166 
168  // should not be zero, problems with infinte bbox
169 
170  m_maxEnergy = 1.f;
171  m_maxEt = 1.f;
172 }
173 
174 float Context::getMaxEnergyInEvent(bool isEt) const { return isEt ? m_maxEt : m_maxEnergy; }
175 
176 //
177 // static member functions
178 //
179 
180 float Context::caloR1(bool offset) { return offset ? (s_caloR - offset) : s_caloR; }
181 
182 float Context::caloR2(bool offset) { return offset ? (s_caloR - offset) : s_caloR; }
183 float Context::caloZ1(bool offset) { return offset ? (s_caloZ - offset) : s_caloZ; }
184 
185 float Context::caloZ2(bool offset) { return offset ? (s_caloZ - offset) : s_caloZ; }
186 
188 
190 
192 
fw3dlego::xbins
const double xbins[]
Definition: fw3dlego_xbins.cc:16
fireworks::Context
Definition: Context.h:41
funct::false
false
Definition: Factorize.h:29
fireworks::Context::s_caloTransAngle
static const float s_caloTransAngle
Definition: Context.h:135
fireworks::Context::resetMaxEtAndEnergy
void resetMaxEtAndEnergy() const
Definition: Context.cc:167
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
fireworks::Context::m_propagator
TEveTrackPropagator * m_propagator
Definition: Context.h:114
mps_update.status
status
Definition: mps_update.py:69
FWEventItemsManager
Definition: FWEventItemsManager.h:44
CmsShowCommon::getRnrPTBMarkers
bool getRnrPTBMarkers() const
Definition: CmsShowCommon.h:76
fireworks::Context::s_caloOffZ
static const float s_caloOffZ
Definition: Context.h:142
fireworks::Context::m_trackerPropagator
TEveTrackPropagator * m_trackerPropagator
Definition: Context.h:115
CmsShowCommon::getProjTrackBreaking
UChar_t getProjTrackBreaking() const
Definition: CmsShowCommon.h:75
FWModelChangeManager
Definition: FWModelChangeManager.h:33
fw3dlego::xbins_n
const int xbins_n
Definition: fw3dlego_xbins.cc:15
fireworks::Context::s_caloTransEta
static const float s_caloTransEta
Definition: Context.h:134
fireworks::Context::Context
Context(FWModelChangeManager *iCM, FWSelectionManager *iSM, FWEventItemsManager *iEM, FWColorManager *iColorM, FWJobMetadataManager *iJMDM)
Definition: Context.cc:56
fireworks::Context::~Context
virtual ~Context()
Definition: Context.cc:84
fw3dlego::xbins_hf_n
const int xbins_hf_n
Definition: fw3dlego_xbins.cc:24
fireworks::Context::caloZ2
static float caloZ2(bool offset=true)
Definition: Context.cc:185
FWJobMetadataManager
Definition: FWJobMetadataManager.h:18
fireworks::Context::voteMaxEtAndEnergy
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:162
FWMagField
Definition: FWMagField.h:14
fireworks::Context::caloTransEta
static float caloTransEta()
Definition: Context.cc:187
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
fireworks::Context::caloMaxEta
static double caloMaxEta()
Definition: Context.cc:191
fireworks::Context::m_beamSpot
FWBeamSpot * m_beamSpot
Definition: Context.h:119
fireworks::Context::commonPrefs
CmsShowCommon * commonPrefs() const
Definition: Context.cc:160
FWBeamSpot
Definition: FWBeamSpot.h:11
fireworks::Context::caloR2
static float caloR2(bool offset=true)
Definition: Context.cc:182
FWSelectionManager
Definition: FWSelectionManager.h:34
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
fireworks::Context::m_commonPrefs
CmsShowCommon * m_commonPrefs
Definition: Context.h:121
fireworks::Context::m_caloData
TEveCaloDataHist * m_caloData
Definition: Context.h:128
fireworks::Context::s_caloZ
static const float s_caloZ
Definition: Context.h:138
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
Max
T Max(T a, T b)
Definition: MathUtil.h:44
fireworks::Context::m_caloDataHF
TEveCaloDataVec * m_caloDataHF
Definition: Context.h:129
fireworks::Context::getMaxEnergyInEvent
float getMaxEnergyInEvent(bool isEt) const
Definition: Context.cc:174
FWColorManager
Definition: FWColorManager.h:45
fireworks::Context::caloTransAngle
static float caloTransAngle()
Definition: Context.cc:189
fireworks::Context::initEveElements
void initEveElements()
Definition: Context.cc:86
FWMagField.h
CmsShowCommon.h
fireworks::Context::deleteEveElements
void deleteEveElements()
Definition: Context.cc:153
fireworks::Context::m_muonPropagator
TEveTrackPropagator * m_muonPropagator
Definition: Context.h:116
fireworks::Context::caloZ1
static float caloZ1(bool offset=true)
Definition: Context.cc:183
fireworks::Context::m_magField
FWMagField * m_magField
Definition: Context.h:118
fw3dlego::xbins_hf
const double xbins_hf[]
Definition: fw3dlego_xbins.cc:25
fireworks::Context::s_caloR
static const float s_caloR
Definition: Context.h:137
fireworks::Context::s_fwContext
static Context * s_fwContext
Definition: Context.h:131
fireworks::Context::getInstance
static Context * getInstance()
Definition: Context.cc:193
fireworks::Context::s_caloOffR
static const float s_caloOffR
Definition: Context.h:141
FWBeamSpot.h
fireworks::Context::m_maxEt
float m_maxEt
Definition: Context.h:123
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
fireworks
Definition: FWTauProxyBuilderBase.h:35
dummy
Definition: DummySelector.h:38
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
CmsShowCommon
Definition: CmsShowCommon.h:43
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
fireworks::Context::m_maxEnergy
float m_maxEnergy
Definition: Context.h:124
fw3dlego_xbins.h
fireworks::Context::caloR1
static float caloR1(bool offset=true)
Definition: Context.cc:180
Context.h