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 // mtd data [cm]
54 const float Context::s_mtdEtlR1 = 30.;
55 const float Context::s_mtdEtlR2 = 119.;
56 const float Context::s_mtdEtlZ1 = 298.9;
57 const float Context::s_mtdEtlZ2 = 301.25;
58 const float Context::s_mtdEtlOffZ = 2.5;
59 
60 //
61 // constructors and destructor
62 //
64  FWSelectionManager* iSM,
66  FWColorManager* iColorM,
67  FWJobMetadataManager* iJMDM)
68  : m_changeManager(iCM),
69  m_selectionManager(iSM),
70  m_eventItemsManager(iEM),
71  m_colorManager(iColorM),
72  m_metadataManager(iJMDM),
73  m_geom(nullptr),
74  m_propagator(nullptr),
75  m_trackerPropagator(nullptr),
76  m_muonPropagator(nullptr),
77  m_magField(nullptr),
78  m_beamSpot(nullptr),
79  m_commonPrefs(nullptr),
80  m_maxEt(1.f),
81  m_maxEnergy(1.f),
82  m_hidePFBuilders(false),
83  m_caloData(nullptr),
84  m_caloDataHF(nullptr) {
85  if (iColorM) // unit test
86  m_commonPrefs = new CmsShowCommon(this);
87 
88  s_fwContext = this;
89 }
90 
92 
94  m_magField = new FWMagField();
95  m_beamSpot = new FWBeamSpot();
96 
97  float propagatorOffR = 5;
98  float propagatorOffZ = propagatorOffR * caloZ1(false) / caloR1(false);
99 
100  // common propagator, helix stepper
101  m_propagator = new TEveTrackPropagator();
102  m_propagator->SetMagFieldObj(m_magField, false);
103  m_propagator->SetMaxR(caloR2() - propagatorOffR);
104  m_propagator->SetMaxZ(caloZ2() - propagatorOffZ);
105  m_propagator->SetDelta(0.01);
106  m_propagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
107  m_propagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
108  m_propagator->IncDenyDestroy();
109  // tracker propagator
110  m_trackerPropagator = new TEveTrackPropagator();
111  m_trackerPropagator->SetStepper(TEveTrackPropagator::kRungeKutta);
112  m_trackerPropagator->SetMagFieldObj(m_magField, false);
113  m_trackerPropagator->SetDelta(0.01);
114  m_trackerPropagator->SetMaxR(caloR1() - propagatorOffR);
115  m_trackerPropagator->SetMaxZ(caloZ2() - propagatorOffZ);
116  m_trackerPropagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
117  m_trackerPropagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
118  m_trackerPropagator->IncDenyDestroy();
119  // muon propagator
120  m_muonPropagator = new TEveTrackPropagator();
121  m_muonPropagator->SetStepper(TEveTrackPropagator::kRungeKutta);
122  m_muonPropagator->SetMagFieldObj(m_magField, false);
123  m_muonPropagator->SetDelta(0.05);
124  m_muonPropagator->SetMaxR(850.f);
125  m_muonPropagator->SetMaxZ(1100.f);
126  m_muonPropagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
127  m_muonPropagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
128  m_muonPropagator->IncDenyDestroy();
129 
130  // general calo data
131  {
132  m_caloData = new TEveCaloDataHist();
133  m_caloData->IncDenyDestroy();
134 
135  // Phi range is always in the (-Pi, Pi) without a shift.
136  // Set wrap to false for the optimisation on TEveCaloData::GetCellList().
137  m_caloData->SetWrapTwoPi(false);
138 
139  Bool_t status = TH1::AddDirectoryStatus();
140  TH1::AddDirectory(kFALSE); //Keeps histogram from going into memory
141  TH2F* dummy =
142  new TH2F("background", "background", fw3dlego::xbins_n - 1, fw3dlego::xbins, 72, -1 * TMath::Pi(), TMath::Pi());
143 
144  TH1::AddDirectory(status);
145  Int_t sliceIndex = m_caloData->AddHistogram(dummy);
146  (m_caloData)->RefSliceInfo(sliceIndex).Setup("background", 0., 0);
147  }
148  // HF calo data
149  {
150  m_caloDataHF = new TEveCaloDataVec(1);
151  m_caloDataHF->IncDenyDestroy();
152  m_caloDataHF->SetWrapTwoPi(false);
153  m_caloDataHF->RefSliceInfo(0).Setup("bg", 0.3, kRed);
154  m_caloDataHF->SetEtaBins(new TAxis(fw3dlego::xbins_hf_n - 1, fw3dlego::xbins_hf));
155  Double_t off = 10 * TMath::DegToRad();
156  m_caloDataHF->SetPhiBins(new TAxis(36, -TMath::Pi() - off, TMath::Pi() - off));
157  }
158 }
159 
161  // AMT: delete of eve-elements disabled to prevent crash on exit.
162  // A lot of eve objects use this elements (e.g. TEveCalo, TEveTrack ...)
163  // If want to have explicit delete make sure order of destruction
164  // is correct: this should be called after all scenes are destroyed.
165 }
166 
168 
169 void Context::voteMaxEtAndEnergy(float et, float energy) const {
172 }
173 
175  // should not be zero, problems with infinte bbox
176 
177  m_maxEnergy = 1.f;
178  m_maxEt = 1.f;
179 }
180 
181 float Context::getMaxEnergyInEvent(bool isEt) const { return isEt ? m_maxEt : m_maxEnergy; }
182 
183 //
184 // static member functions
185 //
186 
187 float Context::caloR1(bool offset) { return offset ? (s_caloR - offset) : s_caloR; }
188 
189 float Context::caloR2(bool offset) { return offset ? (s_caloR - offset) : s_caloR; }
190 float Context::caloZ1(bool offset) { return offset ? (s_caloZ - offset) : s_caloZ; }
191 
192 float Context::caloZ2(bool offset) { return offset ? (s_caloZ - offset) : s_caloZ; }
193 
195 
197 
199 
200 float Context::mtdEtlR1() { return s_mtdEtlR1; }
201 float Context::mtdEtlR2() { return s_mtdEtlR2; }
202 float Context::mtdEtlZ1(const unsigned int& disk_number) {
203  return disk_number == 2 ? s_mtdEtlZ1 + s_mtdEtlOffZ : s_mtdEtlZ1;
204 }
205 float Context::mtdEtlZ2(const unsigned int& disk_number) {
206  return disk_number == 2 ? s_mtdEtlZ2 + s_mtdEtlOffZ : s_mtdEtlZ2;
207 }
208 
bool getRnrPTBMarkers() const
Definition: CmsShowCommon.h:76
static float caloTransEta()
Definition: Context.cc:194
const double Pi
FWBeamSpot * m_beamSpot
Definition: Context.h:123
TEveTrackPropagator * m_propagator
Definition: Context.h:118
void resetMaxEtAndEnergy() const
Definition: Context.cc:174
static float mtdEtlZ1(const unsigned int &disk_number=1)
Definition: Context.cc:202
const double xbins[]
TEveCaloDataHist * m_caloData
Definition: Context.h:132
CmsShowCommon * commonPrefs() const
Definition: Context.cc:167
static float caloTransAngle()
Definition: Context.cc:196
static float mtdEtlZ2(const unsigned int &disk_number=1)
Definition: Context.cc:205
float getMaxEnergyInEvent(bool isEt) const
Definition: Context.cc:181
static const float s_caloOffR
Definition: Context.h:145
TEveTrackPropagator * m_muonPropagator
Definition: Context.h:120
static float caloZ2(bool offset=true)
Definition: Context.cc:192
CmsShowCommon * m_commonPrefs
Definition: Context.h:125
void initEveElements()
Definition: Context.cc:93
virtual ~Context()
Definition: Context.cc:91
void deleteEveElements()
Definition: Context.cc:160
static const float s_caloZ
Definition: Context.h:142
static Context * s_fwContext
Definition: Context.h:135
static const float s_mtdEtlZ2
Definition: Context.h:152
static const float s_mtdEtlR2
Definition: Context.h:150
static const float s_mtdEtlZ1
Definition: Context.h:151
static float caloR2(bool offset=true)
Definition: Context.cc:189
FWMagField * m_magField
Definition: Context.h:122
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:169
TEveCaloDataVec * m_caloDataHF
Definition: Context.h:133
static float caloR1(bool offset=true)
Definition: Context.cc:187
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Context(FWModelChangeManager *iCM, FWSelectionManager *iSM, FWEventItemsManager *iEM, FWColorManager *iColorM, FWJobMetadataManager *iJMDM)
Definition: Context.cc:63
double f[11][100]
static const float s_mtdEtlOffZ
Definition: Context.h:153
static Context * getInstance()
Definition: Context.cc:209
const int xbins_n
static const float s_caloR
Definition: Context.h:141
static const float s_mtdEtlR1
Definition: Context.h:149
static float mtdEtlR2()
Definition: Context.cc:201
const double xbins_hf[]
static const float s_caloOffZ
Definition: Context.h:146
static const float s_caloTransEta
Definition: Context.h:138
UChar_t getProjTrackBreaking() const
Definition: CmsShowCommon.h:75
static double caloMaxEta()
Definition: Context.cc:198
static float caloZ1(bool offset=true)
Definition: Context.cc:190
static float mtdEtlR1()
Definition: Context.cc:200
TEveTrackPropagator * m_trackerPropagator
Definition: Context.h:119
static const float s_caloTransAngle
Definition: Context.h:139
const int xbins_hf_n