File indexing completed on 2024-04-06 12:11:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "TH2.h"
0017 #include "TMath.h"
0018 #include "TEveTrackPropagator.h"
0019 #include "TEveCaloData.h"
0020 #include "Fireworks/Core/interface/fw3dlego_xbins.h"
0021
0022 #include "Fireworks/Core/interface/Context.h"
0023 #include "Fireworks/Core/interface/FWMagField.h"
0024 #include "Fireworks/Core/interface/FWBeamSpot.h"
0025 #include "Fireworks/Core/interface/CmsShowCommon.h"
0026
0027 #include <functional>
0028
0029 using namespace fireworks;
0030
0031 Context* Context::s_fwContext = nullptr;
0032
0033 const float Context::s_caloTransEta = 1.479;
0034 const float Context::s_caloTransAngle = 2 * atan(exp(-s_caloTransEta));
0035
0036
0037 const float Context::s_caloZ = 290;
0038 const float Context::s_caloR = s_caloZ * tan(s_caloTransAngle);
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 const float Context::s_caloOffR = 10;
0051 const float Context::s_caloOffZ = s_caloOffR / tan(s_caloTransAngle);
0052
0053
0054 const float Context::s_mtdEtlR1 = 30.;
0055 const float Context::s_mtdEtlR2 = 119.;
0056 const float Context::s_mtdEtlZ1 = 298.9;
0057 const float Context::s_mtdEtlZ2 = 301.25;
0058 const float Context::s_mtdEtlOffZ = 2.5;
0059
0060
0061
0062
0063 Context::Context(FWModelChangeManager* iCM,
0064 FWSelectionManager* iSM,
0065 FWEventItemsManager* iEM,
0066 FWColorManager* iColorM,
0067 FWJobMetadataManager* iJMDM)
0068 : m_changeManager(iCM),
0069 m_selectionManager(iSM),
0070 m_eventItemsManager(iEM),
0071 m_colorManager(iColorM),
0072 m_metadataManager(iJMDM),
0073 m_geom(nullptr),
0074 m_propagator(nullptr),
0075 m_trackerPropagator(nullptr),
0076 m_muonPropagator(nullptr),
0077 m_magField(nullptr),
0078 m_beamSpot(nullptr),
0079 m_commonPrefs(nullptr),
0080 m_maxEt(1.f),
0081 m_maxEnergy(1.f),
0082 m_hidePFBuilders(false),
0083 m_caloData(nullptr),
0084 m_caloDataHF(nullptr) {
0085 if (iColorM)
0086 m_commonPrefs = new CmsShowCommon(this);
0087
0088 s_fwContext = this;
0089 }
0090
0091 Context::~Context() { delete m_commonPrefs; }
0092
0093 void Context::initEveElements() {
0094 m_magField = new FWMagField();
0095 m_beamSpot = new FWBeamSpot();
0096
0097 float propagatorOffR = 5;
0098 float propagatorOffZ = propagatorOffR * caloZ1(false) / caloR1(false);
0099
0100
0101 m_propagator = new TEveTrackPropagator();
0102 m_propagator->SetMagFieldObj(m_magField, false);
0103 m_propagator->SetMaxR(caloR2() - propagatorOffR);
0104 m_propagator->SetMaxZ(caloZ2() - propagatorOffZ);
0105 m_propagator->SetDelta(0.01);
0106 m_propagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
0107 m_propagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
0108 m_propagator->IncDenyDestroy();
0109
0110 m_trackerPropagator = new TEveTrackPropagator();
0111 m_trackerPropagator->SetStepper(TEveTrackPropagator::kRungeKutta);
0112 m_trackerPropagator->SetMagFieldObj(m_magField, false);
0113 m_trackerPropagator->SetDelta(0.01);
0114 m_trackerPropagator->SetMaxR(caloR1() - propagatorOffR);
0115 m_trackerPropagator->SetMaxZ(caloZ2() - propagatorOffZ);
0116 m_trackerPropagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
0117 m_trackerPropagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
0118 m_trackerPropagator->IncDenyDestroy();
0119
0120 m_muonPropagator = new TEveTrackPropagator();
0121 m_muonPropagator->SetStepper(TEveTrackPropagator::kRungeKutta);
0122 m_muonPropagator->SetMagFieldObj(m_magField, false);
0123 m_muonPropagator->SetDelta(0.05);
0124 m_muonPropagator->SetMaxR(850.f);
0125 m_muonPropagator->SetMaxZ(1100.f);
0126 m_muonPropagator->SetProjTrackBreaking(m_commonPrefs->getProjTrackBreaking());
0127 m_muonPropagator->SetRnrPTBMarkers(m_commonPrefs->getRnrPTBMarkers());
0128 m_muonPropagator->IncDenyDestroy();
0129
0130
0131 {
0132 m_caloData = new TEveCaloDataHist();
0133 m_caloData->IncDenyDestroy();
0134
0135
0136
0137 m_caloData->SetWrapTwoPi(false);
0138
0139 Bool_t status = TH1::AddDirectoryStatus();
0140 TH1::AddDirectory(kFALSE);
0141 TH2F* dummy =
0142 new TH2F("background", "background", fw3dlego::xbins_n - 1, fw3dlego::xbins, 72, -1 * TMath::Pi(), TMath::Pi());
0143
0144 TH1::AddDirectory(status);
0145 Int_t sliceIndex = m_caloData->AddHistogram(dummy);
0146 (m_caloData)->RefSliceInfo(sliceIndex).Setup("background", 0., 0);
0147 }
0148
0149 {
0150 m_caloDataHF = new TEveCaloDataVec(1);
0151 m_caloDataHF->IncDenyDestroy();
0152 m_caloDataHF->SetWrapTwoPi(false);
0153 m_caloDataHF->RefSliceInfo(0).Setup("bg", 0.3, kRed);
0154 m_caloDataHF->SetEtaBins(new TAxis(fw3dlego::xbins_hf_n - 1, fw3dlego::xbins_hf));
0155 Double_t off = 10 * TMath::DegToRad();
0156 m_caloDataHF->SetPhiBins(new TAxis(36, -TMath::Pi() - off, TMath::Pi() - off));
0157 }
0158 }
0159
0160 void Context::deleteEveElements() {
0161
0162
0163
0164
0165 }
0166
0167 CmsShowCommon* Context::commonPrefs() const { return m_commonPrefs; }
0168
0169 void Context::voteMaxEtAndEnergy(float et, float energy) const {
0170 m_maxEt = TMath::Max(et, m_maxEt);
0171 m_maxEnergy = TMath::Max(energy, m_maxEnergy);
0172 }
0173
0174 void Context::resetMaxEtAndEnergy() const {
0175
0176
0177 m_maxEnergy = 1.f;
0178 m_maxEt = 1.f;
0179 }
0180
0181 float Context::getMaxEnergyInEvent(bool isEt) const { return isEt ? m_maxEt : m_maxEnergy; }
0182
0183
0184
0185
0186
0187 float Context::caloR1(bool offset) { return offset ? (s_caloR - offset) : s_caloR; }
0188
0189 float Context::caloR2(bool offset) { return offset ? (s_caloR - offset) : s_caloR; }
0190 float Context::caloZ1(bool offset) { return offset ? (s_caloZ - offset) : s_caloZ; }
0191
0192 float Context::caloZ2(bool offset) { return offset ? (s_caloZ - offset) : s_caloZ; }
0193
0194 float Context::caloTransEta() { return s_caloTransEta; }
0195
0196 float Context::caloTransAngle() { return s_caloTransAngle; }
0197
0198 double Context::caloMaxEta() { return fw3dlego::xbins_hf[fw3dlego::xbins_hf_n - 1]; }
0199
0200 float Context::mtdEtlR1() { return s_mtdEtlR1; }
0201 float Context::mtdEtlR2() { return s_mtdEtlR2; }
0202 float Context::mtdEtlZ1(const unsigned int& disk_number) {
0203 return disk_number == 2 ? s_mtdEtlZ1 + s_mtdEtlOffZ : s_mtdEtlZ1;
0204 }
0205 float Context::mtdEtlZ2(const unsigned int& disk_number) {
0206 return disk_number == 2 ? s_mtdEtlZ2 + s_mtdEtlOffZ : s_mtdEtlZ2;
0207 }
0208
0209 Context* Context::getInstance() { return s_fwContext; }