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