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 
bool getRnrPTBMarkers() const
Definition: CmsShowCommon.h:76
static float caloTransEta()
Definition: Context.cc:187
const double Pi
FWBeamSpot * m_beamSpot
Definition: Context.h:118
TEveTrackPropagator * m_propagator
Definition: Context.h:113
void resetMaxEtAndEnergy() const
Definition: Context.cc:167
const double xbins[]
TEveCaloDataHist * m_caloData
Definition: Context.h:127
CmsShowCommon * commonPrefs() const
Definition: Context.cc:160
static float caloTransAngle()
Definition: Context.cc:189
float getMaxEnergyInEvent(bool isEt) const
Definition: Context.cc:174
static const float s_caloOffR
Definition: Context.h:140
TEveTrackPropagator * m_muonPropagator
Definition: Context.h:115
static float caloZ2(bool offset=true)
Definition: Context.cc:185
CmsShowCommon * m_commonPrefs
Definition: Context.h:120
void initEveElements()
Definition: Context.cc:86
virtual ~Context()
Definition: Context.cc:84
void deleteEveElements()
Definition: Context.cc:153
static const float s_caloZ
Definition: Context.h:137
static Context * s_fwContext
Definition: Context.h:130
static float caloR2(bool offset=true)
Definition: Context.cc:182
FWMagField * m_magField
Definition: Context.h:117
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:162
TEveCaloDataVec * m_caloDataHF
Definition: Context.h:128
static float caloR1(bool offset=true)
Definition: Context.cc:180
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:56
double f[11][100]
static Context * getInstance()
Definition: Context.cc:193
const int xbins_n
static const float s_caloR
Definition: Context.h:136
const double xbins_hf[]
static const float s_caloOffZ
Definition: Context.h:141
static const float s_caloTransEta
Definition: Context.h:133
UChar_t getProjTrackBreaking() const
Definition: CmsShowCommon.h:75
static double caloMaxEta()
Definition: Context.cc:191
static float caloZ1(bool offset=true)
Definition: Context.cc:183
TEveTrackPropagator * m_trackerPropagator
Definition: Context.h:114
static const float s_caloTransAngle
Definition: Context.h:134
const int xbins_hf_n