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