CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <boost/bind.hpp>
28 
29 using namespace fireworks;
30 
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 //
55 // constructors and destructor
56 //
58  FWSelectionManager* iSM,
60  FWColorManager* iColorM,
62  ) :
63  m_changeManager(iCM),
64  m_selectionManager(iSM),
65  m_eventItemsManager(iEM),
66  m_colorManager(iColorM),
67  m_metadataManager(iJMDM),
68  m_geom(0),
69  m_propagator(0),
70  m_trackerPropagator(0),
71  m_muonPropagator(0),
72  m_magField(0),
73  m_beamSpot(0),
74  m_commonPrefs(0),
75  m_maxEt(1.f),
76  m_maxEnergy(1.f),
77  m_hidePFBuilders(false),
78  m_caloData(0),
79  m_caloDataHF(0)
80 {
81  if (iColorM) // unit test
82  m_commonPrefs = new CmsShowCommon(this);
83 
84  s_fwContext = this;
85 }
86 
87 
89 {
90  delete m_commonPrefs;
91 }
92 
93 void
95 {
96  m_magField = new FWMagField();
97  m_beamSpot = new FWBeamSpot();
98 
99 
100  float propagatorOffR = 5;
101  float propagatorOffZ = propagatorOffR*caloZ1(false)/caloR1(false);
102 
103  // common propagator, helix stepper
104  m_propagator = new TEveTrackPropagator();
105  m_propagator->SetMagFieldObj(m_magField, false);
106  m_propagator->SetMaxR(caloR2()-propagatorOffR);
107  m_propagator->SetMaxZ(caloZ2()-propagatorOffZ);
108  m_propagator->SetDelta(0.01);
109  m_propagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
110  m_propagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
111  m_propagator->IncDenyDestroy();
112  // tracker propagator
113  m_trackerPropagator = new TEveTrackPropagator();
114  m_trackerPropagator->SetStepper( TEveTrackPropagator::kRungeKutta );
115  m_trackerPropagator->SetMagFieldObj(m_magField, false);
116  m_trackerPropagator->SetDelta(0.01);
117  m_trackerPropagator->SetMaxR(caloR1()-propagatorOffR);
118  m_trackerPropagator->SetMaxZ(caloZ2()-propagatorOffZ);
119  m_trackerPropagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
120  m_trackerPropagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
121  m_trackerPropagator->IncDenyDestroy();
122  // muon propagator
123  m_muonPropagator = new TEveTrackPropagator();
124  m_muonPropagator->SetStepper( TEveTrackPropagator::kRungeKutta );
125  m_muonPropagator->SetMagFieldObj(m_magField, false);
126  m_muonPropagator->SetDelta(0.05);
127  m_muonPropagator->SetMaxR(850.f);
128  m_muonPropagator->SetMaxZ(1100.f);
129  m_muonPropagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
130  m_muonPropagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
131  m_muonPropagator->IncDenyDestroy();
132 
133  // general calo data
134  {
135  m_caloData = new TEveCaloDataHist();
136  m_caloData->IncDenyDestroy();
137 
138  // Phi range is always in the (-Pi, Pi) without a shift.
139  // Set wrap to false for the optimisation on TEveCaloData::GetCellList().
140  m_caloData->SetWrapTwoPi(false);
141 
142  Bool_t status = TH1::AddDirectoryStatus();
143  TH1::AddDirectory(kFALSE); //Keeps histogram from going into memory
144  TH2F* dummy = new TH2F("background",
145  "background",
147  72, -1*TMath::Pi(), TMath::Pi());
148 
149  TH1::AddDirectory(status);
150  Int_t sliceIndex = m_caloData->AddHistogram(dummy);
151  (m_caloData)->RefSliceInfo(sliceIndex).Setup("background", 0., 0);
152  }
153  // HF calo data
154  {
155  m_caloDataHF = new TEveCaloDataVec(1);
156  m_caloDataHF->IncDenyDestroy();
157  m_caloDataHF->SetWrapTwoPi(false);
158  m_caloDataHF->RefSliceInfo(0).Setup("bg", 0.3, kRed);
159  m_caloDataHF->SetEtaBins(new TAxis(fw3dlego::xbins_hf_n - 1, fw3dlego::xbins_hf));
160  Double_t off = 10 * TMath::DegToRad();
161  m_caloDataHF->SetPhiBins(new TAxis(36, -TMath::Pi() -off, TMath::Pi() -off));
162  }
163 }
164 
165 void
167 {
168  // AMT: delete of eve-elements disabled to prevent crash on exit.
169  // A lot of eve objects use this elements (e.g. TEveCalo, TEveTrack ...)
170  // If want to have explicit delete make sure order of destruction
171  // is correct: this should be called after all scenes are destroyed.
172 }
173 
174 
175 
178 {
179  return m_commonPrefs;
180 }
181 
182 void
183 Context::voteMaxEtAndEnergy(float et, float energy) const
184 {
185  m_maxEt = TMath::Max(et , m_maxEt );
187 }
188 
189 void
191 {
192  // should not be zero, problems with infinte bbox
193 
194  m_maxEnergy = 1.f;
195  m_maxEt = 1.f;
196 }
197 
198 float
200 {
201  return isEt ? m_maxEt : m_maxEnergy;
202 }
203 
204 //
205 // static member functions
206 //
207 
209 {
210  return offset ? (s_caloR -offset) :s_caloR;
211 }
212 
214 {
215 
216  return offset ? (s_caloR -offset) :s_caloR;
217 }
219 {
220  return offset ? (s_caloZ -offset) :s_caloZ;
221 }
222 
224 {
225  return offset ? (s_caloZ -offset) :s_caloZ;
226 }
227 
229 {
230  return s_caloTransEta;
231 }
232 
234 {
235  return s_caloTransAngle;
236 }
237 
239 {
241 }
242 
244 {
245  return s_fwContext;
246 }
static float caloTransEta()
Definition: Context.cc:228
const double Pi
FWBeamSpot * m_beamSpot
Definition: Context.h:130
TEveTrackPropagator * m_propagator
Definition: Context.h:125
bool getRnrPTBMarkers() const
Definition: CmsShowCommon.h:77
const double xbins[]
TEveCaloDataHist * m_caloData
Definition: Context.h:139
static float caloTransAngle()
Definition: Context.cc:233
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:183
static const float s_caloOffR
Definition: Context.h:152
TEveTrackPropagator * m_muonPropagator
Definition: Context.h:127
static float caloZ2(bool offset=true)
Definition: Context.cc:223
#define NULL
Definition: scimark2.h:8
CmsShowCommon * m_commonPrefs
Definition: Context.h:132
void initEveElements()
Definition: Context.cc:94
virtual ~Context()
Definition: Context.cc:88
void deleteEveElements()
Definition: Context.cc:166
static const float s_caloZ
Definition: Context.h:149
static Context * s_fwContext
Definition: Context.h:142
static float caloR2(bool offset=true)
Definition: Context.cc:213
UChar_t getProjTrackBreaking() const
Definition: CmsShowCommon.h:76
FWMagField * m_magField
Definition: Context.h:129
void resetMaxEtAndEnergy() const
Definition: Context.cc:190
TEveCaloDataVec * m_caloDataHF
Definition: Context.h:140
static float caloR1(bool offset=true)
Definition: Context.cc:208
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:57
double f[11][100]
float getMaxEnergyInEvent(bool isEt) const
Definition: Context.cc:199
static Context * getInstance()
Definition: Context.cc:243
const int xbins_n
static const float s_caloR
Definition: Context.h:148
T Max(T a, T b)
Definition: MathUtil.h:44
const double xbins_hf[]
static const float s_caloOffZ
Definition: Context.h:153
static const float s_caloTransEta
Definition: Context.h:145
CmsShowCommon * commonPrefs() const
Definition: Context.cc:177
static double caloMaxEta()
Definition: Context.cc:238
static float caloZ1(bool offset=true)
Definition: Context.cc:218
volatile std::atomic< bool > shutdown_flag false
TEveTrackPropagator * m_trackerPropagator
Definition: Context.h:126
static const float s_caloTransAngle
Definition: Context.h:146
const int xbins_hf_n
tuple status
Definition: mps_update.py:57