Belle II Software development
TOPGeometryPar.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <top/dbobjects/TOPGeometry.h>
12#include <top/geometry/FrontEndMapper.h>
13#include <top/geometry/ChannelMapper.h>
14#include <framework/database/DBObjPtr.h>
15#include <framework/database/DBArray.h>
16#include <top/dbobjects/TOPPmtInstallation.h>
17#include <top/dbobjects/TOPPmtQE.h>
18#include <top/dbobjects/TOPNominalQE.h>
19#include <top/dbobjects/TOPCalChannelRQE.h>
20#include <top/dbobjects/TOPCalChannelThresholdEff.h>
21#include <top/dbobjects/TOPCalChannelPulseHeight.h>
22#include <string>
23#include <map>
24#include <cmath>
25
26namespace Belle2 {
31 namespace TOP {
32
36
38
39 public:
40
44 virtual ~TOPGeometryPar();
45
50 static TOPGeometryPar* Instance();
51
56 void Initialize(const GearDir& content);
57
61 void Initialize();
62
67 bool isValid() const {return m_valid;}
68
73 const TOPGeometry* getGeometry() const;
74
80
86
92 {
93 switch (type) {
94 case ChannelMapper::c_IRS3B: return m_channelMapperIRS3B;
95 case ChannelMapper::c_IRSX: return m_channelMapperIRSX;
96 default: return m_channelMapperIRSX;
97 }
98 }
99
106 double getPMTEfficiencyEnvelope(double energy) const;
107
117 double getPMTEfficiency(double energy,
118 int moduleID, int pmtID, double x, double y) const;
119
124 double getRelativePixelEfficiency(int moduleID, int pixelID) const;
125
130 double getRelativePDEonMC(int moduleID, int pixelID) const;
131
138 unsigned getPMTType(int moduleID, int pmtID) const;
139
146 const TOPNominalTTS& getTTS(int moduleID, int pmtID) const;
147
153 static double getPhaseIndex(double energy);
154
160 static double getGroupIndex(double energy);
161
167 static double getPhaseIndexDerivative(double energy);
168
174 static double getGroupIndexDerivative(double energy);
175
181 static double getAbsorptionLength(double energy);
182
183 static const double c_hc;
184
185 private:
186
192
197
202
207
212 static TOPGeometry* createConfiguration(const GearDir& content);
213
219 static TOPGeoBarSegment createBarSegment(const GearDir& content,
220 const std::string& serialNumber);
221
227 static TOPGeoMirrorSegment createMirrorSegment(const GearDir& content,
228 const std::string& serialNumber);
229
235 static TOPGeoPrism createPrism(const GearDir& content,
236 const std::string& serialNumber);
237
244 static std::string addNumber(const std::string& str, unsigned number);
245
249 void clearCache();
250
254 void setEnvelopeQE() const;
255
259 void mapPmtQEToPositions() const;
260
264 void mapPmtTypeToPositions() const;
265
269 void prepareRelEfficiencies() const;
270
274 void prepareRelPDEonMC() const;
275
282 static int getUniquePmtID(int moduleID, int pmtID)
283 {
284 return (moduleID << 16) + pmtID;
285 }
286
293 static int getUniquePixelID(int moduleID, int pixelID)
294 {
295 return (moduleID << 16) + pixelID;
296 }
297
306 double integralOfQE(const std::vector<float>& qe, double ce,
307 double lambdaFirst, double lambdaStep) const;
308
309
315 static double refractiveIndex(double lambda);
316
317 // Geometry
318
321 bool m_fromDB = false;
322 bool m_valid = false;
323 bool m_oldPayload = false;
324 bool m_BfieldOn = true;
325
326 // Mappings
327
331
332 // PMT database
333
339
340 // cache
342 mutable std::map<int, const TOPPmtQE*> m_pmts;
343 mutable std::map<int, double> m_relEfficiencies;
344 mutable std::map<int, double> m_relPDEonMC;
345 mutable std::map<int, unsigned> m_pmtTypes;
346
347 // Other
348
350
351 };
352
353 inline double TOPGeometryPar::refractiveIndex(double lambda)
354 {
355 // parameters of SellMeier equation (Matsuoka-san, 24.11.2018)
356 // from the specs of Corning HPFS 7980
357 // https://www.corning.com/media/worldwide/csm/documents/5bf092438c5546dfa9b08e423348317b.pdf
358 const double b[] = {0.683740494, 0.420323613, 0.585027480};
359 const double c[] = {0.00460352869, 0.0133968856, 64.4932732};
360
361 double lam = lambda * 0.001;
362 double x = lam * lam;
363 double y = 0;
364 for (int i = 0; i < 3; i++) {
365 y += b[i] / (x - c[i]);
366 }
367 y *= x;
368 y += 1;
369 return sqrt(y);
370 }
371
372 inline double TOPGeometryPar::getPhaseIndex(double energy)
373 {
374 double lambda = c_hc / energy;
375 return refractiveIndex(lambda);
376 }
377
378 inline double TOPGeometryPar::getGroupIndex(double energy)
379 {
380 double lambda = c_hc / energy;
381 double dl = 1.0; // [nm]
382 double dlHalf = dl / 2;
383 double n = refractiveIndex(lambda);
384 double dndl = (refractiveIndex(lambda + dlHalf) - refractiveIndex(lambda - dlHalf)) / dl;
385 return n / (1 + lambda / n * dndl);
386 }
387
388 inline double TOPGeometryPar::getPhaseIndexDerivative(double energy)
389 {
390 double dE = 0.01; // [eV]
391 return (getPhaseIndex(energy + dE / 2) - getPhaseIndex(energy - dE / 2)) / dE;
392 }
393
394 inline double TOPGeometryPar::getGroupIndexDerivative(double energy)
395 {
396 double dE = 0.01; // [eV]
397 return (getGroupIndex(energy + dE / 2) - getGroupIndex(energy - dE / 2)) / dE;
398 }
399
400 inline double TOPGeometryPar::getAbsorptionLength(double energy)
401 {
402 double lambda = c_hc / energy;
403 return 15100 * pow(lambda / 405, 4); // Alan Schwartz, 2013 (private communication)
404 }
405
406 } // end of namespace TOP
408} // end of namespace Belle2
Class for accessing objects in the database.
Definition DBObjPtr.h:21
GearDir is the basic class used for accessing the parameter store.
Definition GearDir.h:31
Optional DBArray: This class behaves the same as the DBArray except that it will not raise errors whe...
Definition DBArray.h:97
Geometry parameters of a quartz bar segment.
Geometry parameters of a mirror segment.
Geometry parameters of prism.
Definition TOPGeoPrism.h:27
Geometry parameters of TOP.
Definition TOPGeometry.h:34
Nominal quantum efficiency of PMT.
Nominal time transition spread of PMT.
Provides mapping between electronic channels and pixels.
EType
Enum for electornic types.
Provides mapping between electronics module position within a TOP module and SCROD ID,...
static double getAbsorptionLength(double energy)
Returns bulk absorption length of quartz at given photon energy.
static double getGroupIndexDerivative(double energy)
Returns the derivative (dn_g/dE) of group refractive index of quartz at given photon energy.
double integralOfQE(const std::vector< float > &qe, double ce, double lambdaFirst, double lambdaStep) const
Returns integral of quantum efficiency over photon energies.
static TOPGeoPrism createPrism(const GearDir &content, const std::string &serialNumber)
Create a parameter object from gearbox for prism.
virtual ~TOPGeometryPar()
Destructor.
OptionalDBArray< TOPPmtQE > m_pmtQEData
quantum efficiencies
double getRelativePixelEfficiency(int moduleID, int pixelID) const
Returns relative pixel efficiency (including CE, RQE and threshold efficiency)
bool m_BfieldOn
true if B field is on
double getPMTEfficiencyEnvelope(double energy) const
Returns PMT efficiency envelope, e.g.
bool m_fromDB
parameters from database or Gearbox
static double getPhaseIndex(double energy)
Returns phase refractive index of quartz at given photon energy.
const ChannelMapper & getChannelMapper(ChannelMapper::EType type) const
Returns channel mapper (mapping of channels to pixels) - Gearbox only.
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeoMirrorSegment createMirrorSegment(const GearDir &content, const std::string &serialNumber)
Create a parameter object from gearbox for mirror segment.
DBObjPtr< TOPGeometry > m_geoDB
geometry parameters from database
static int getUniquePmtID(int moduleID, int pmtID)
Returns unique PMT ID within the detector.
unsigned getPMTType(int moduleID, int pmtID) const
Returns PMT type at a given position.
void finalizeInitialization()
finalize initialization
static double getGroupIndex(double energy)
Returns group refractive index of quartz at given photon energy.
TOPGeometryPar(const TOPGeometryPar &)=delete
Deleted copy constructor since it is a singleton class.
const ChannelMapper & getChannelMapper() const
Returns default channel mapper (mapping of channels to pixels)
void prepareRelEfficiencies() const
Prepares a map of relative pixel quantum times collection efficiencies (relative to nominal one)
double getPMTEfficiency(double energy, int moduleID, int pmtID, double x, double y) const
Returns PMT pixel efficiency, a product of quantum and collection efficiency.
static TOPGeometry * createConfiguration(const GearDir &content)
Create a parameter object from gearbox.
bool isValid() const
check if the geometry is available
DBObjPtr< TOPCalChannelThresholdEff > m_thresholdEff
channel threshold effi.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
TOPNominalQE m_envelopeQE
envelope quantum efficiency
std::map< int, unsigned > m_pmtTypes
PMT types mapped to positions.
const FrontEndMapper & getFrontEndMapper() const
Returns front-end mapper (mapping of SCROD's to positions within TOP modules)
TOPGeometryPar & operator=(const TOPGeometryPar &)=delete
Deleted assignment operator since it is a singleton class.
static int getUniquePixelID(int moduleID, int pixelID)
Returns unique pixel ID within the detector.
DBObjPtr< TOPCalChannelRQE > m_channelRQE
channel relative quantum effi.
ChannelMapper m_channelMapperIRS3B
channel-pixel mapper
FrontEndMapper m_frontEndMapper
front end electronics mapper
static std::string addNumber(const std::string &str, unsigned number)
Adds number to string.
static const double c_hc
Planck constant times speed of light in [eV*nm].
const TOPNominalTTS & getTTS(int moduleID, int pmtID) const
Returns TTS of a PMT at given position.
void prepareRelPDEonMC() const
Prepares a map of relative pixel photon detection efficiencies on MC.
static double refractiveIndex(double lambda)
Quartz refractive index (SellMeier equation)
std::map< int, const TOPPmtQE * > m_pmts
QE data mapped to positions.
bool m_valid
true if geometry is available
void clearCache()
Clears cache for PMT dependent QE data - function is used in call backs.
ChannelMapper m_channelMapperIRSX
channel-pixel mapper
static double getPhaseIndexDerivative(double energy)
Returns the derivative (dn/dE) of phase refractive index of quartz at given photon energy.
void Initialize()
Initialize from database.
static TOPGeoBarSegment createBarSegment(const GearDir &content, const std::string &serialNumber)
Create a parameter object from gearbox for bar segment.
double getRelativePDEonMC(int moduleID, int pixelID) const
Returns relative PDE on MC (including CE, tuning factor and threshold efficiency)
bool m_oldPayload
true if old payload found in DB
std::map< int, double > m_relPDEonMC
pixel relative photon detection efficiencies on MC
void mapPmtQEToPositions() const
Maps PMT QE data to positions within the detector.
TOPGeometry * m_geo
geometry parameters from Gearbox
TOPGeometryPar()
Hidden constructor since it is a singleton class.
void setEnvelopeQE() const
Constructs envelope of quantum efficiency from PMT data.
void mapPmtTypeToPositions() const
Maps PMT type to positions within the detector.
DBObjPtr< TOPCalChannelPulseHeight > m_pulseHeights
channel pulse height parametrizations
static TOPGeometryPar * s_instance
Pointer to the class instance.
OptionalDBArray< TOPPmtInstallation > m_pmtInstalled
PMT installation data.
std::map< int, double > m_relEfficiencies
pixel relative QE
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28
Abstract base class for different kinds of events.