BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnDetectorModel.h
Go to the documentation of this file.
1
/*
2
BM@N alignment routine
3
BM@N experiment at NICA complex, JINR, 2025
4
5
Department: Math & Soft Group of HEP lab
6
Author: Igor Polev, polev@jinr.ru
7
8
BmnDetectorModel abstract class header-only implementation
9
Representation of detector as enumerated elements ID
10
*/
11
12
#ifndef BMNDETECTORMODEL_H
13
#define BMNDETECTORMODEL_H
14
15
#include "
BmnAlignDefines.h
"
16
#include "fairlogger/Logger.h"
17
18
#include <array>
19
#include <map>
20
21
/*
22
* Due to usage of pure virtual mechanics it is not possible to
23
* implement object initialization in constructor.
24
* Therefore, Init() method is mandatory to call right after object creation.
25
*/
26
27
class
BmnDetectorModel
28
{
29
private
:
30
Bool_t
fInitialized
{
false
};
31
// encoded ID to index mapping (and vice versa)
32
std::map<Int_t, Int_t>
fIDtoIdx
;
33
std::array<Int_t, BMN_MODULE_COUNT>
fIdxToID
;
34
35
protected
:
36
// detector modules enumeration interface
37
virtual
void
Reset
() = 0;
// set ID sequense BEFORE first element
38
virtual
Int_t
NextID
() = 0;
// return ID value for the next element in sequense
39
// or NEGATIVE value if sequence is over
40
public
:
41
virtual
Int_t
MaxModulesInStation
()
const
= 0;
// maximum number of modules in one station
42
virtual
Int_t
Alignables
()
const
= 0;
// number of alignable elements
43
// re-encode DetectorID from hit into decector model ID
44
// value must correspond to hit DetectorID as much as possible
45
virtual
Int_t
IDfromHit
(
Int_t
HitDetectorID)
const
= 0;
46
47
BmnDetectorModel
() =
default
;
48
virtual
~BmnDetectorModel
() =
default
;
49
inline
Bool_t
Init
();
// must be called right after object creation
50
inline
Int_t
EncodedID
(
Int_t
idx)
const
{
return
fInitialized
?
fIdxToID
.at(idx) : -1; };
51
inline
Int_t
Idx
(
Int_t
ID)
const
{
return
fInitialized
?
fIDtoIdx
.at(ID) : -1; };
52
inline
Int_t
IdxFromHit
(
Int_t
hitID)
const
{
return
fInitialized
?
fIDtoIdx
.at(
IDfromHit
(hitID)) : -1; };
53
inline
Bool_t
UnknownID
(
Int_t
ID)
const
{
return
fInitialized
?
fIDtoIdx
.find(ID) ==
fIDtoIdx
.end() :
kTRUE
; }
54
};
55
56
inline
Bool_t
BmnDetectorModel::Init
()
57
{
58
// check modules count
59
if
(
BMN_MODULE_COUNT
!=
Alignables
()) {
60
LOG(error) <<
" <!> BmnDetectorModel : wrong detector configuration"
61
<<
"\n modules expected: "
<<
BMN_MODULE_COUNT
<<
"\n modules provided: "
<<
Alignables
();
62
return
kFALSE
;
63
}
64
// build linear enumeration of detector modules
65
Reset
();
66
Int_t
ID{
NextID
()}, idx{0};
67
while
(ID >= 0) {
// negative values indicate end of sequense
68
fIDtoIdx
[ID] = idx;
69
fIdxToID
[idx++] = ID;
70
ID =
NextID
();
71
}
72
return
fInitialized
=
kTRUE
;
73
};
74
75
#endif
// BMNDETECTORMODEL_H
Bool_t
bool Bool_t
Int_t
int Int_t
kFALSE
constexpr Bool_t kFALSE
kTRUE
constexpr Bool_t kTRUE
BMN_MODULE_COUNT
#define BMN_MODULE_COUNT
Definition
BmnAlignDefines.h:19
BmnDetectorModel
Definition
BmnDetectorModel.h:28
BmnDetectorModel::MaxModulesInStation
virtual Int_t MaxModulesInStation() const =0
BmnDetectorModel::EncodedID
Int_t EncodedID(Int_t idx) const
Definition
BmnDetectorModel.h:50
BmnDetectorModel::Init
Bool_t Init()
BmnDetectorModel::fIdxToID
std::array< Int_t, BMN_MODULE_COUNT > fIdxToID
Definition
BmnDetectorModel.h:33
BmnDetectorModel::Alignables
virtual Int_t Alignables() const =0
BmnDetectorModel::BmnDetectorModel
BmnDetectorModel()=default
BmnDetectorModel::UnknownID
Bool_t UnknownID(Int_t ID) const
Definition
BmnDetectorModel.h:53
BmnDetectorModel::fInitialized
Bool_t fInitialized
Definition
BmnDetectorModel.h:30
BmnDetectorModel::NextID
virtual Int_t NextID()=0
BmnDetectorModel::IDfromHit
virtual Int_t IDfromHit(Int_t HitDetectorID) const =0
BmnDetectorModel::Idx
Int_t Idx(Int_t ID) const
Definition
BmnDetectorModel.h:51
BmnDetectorModel::fIDtoIdx
std::map< Int_t, Int_t > fIDtoIdx
Definition
BmnDetectorModel.h:32
BmnDetectorModel::Reset
virtual void Reset()=0
BmnDetectorModel::IdxFromHit
Int_t IdxFromHit(Int_t hitID) const
Definition
BmnDetectorModel.h:52
BmnDetectorModel::~BmnDetectorModel
virtual ~BmnDetectorModel()=default
BmnAlignDefines.h
install
include
BmnDetectorModel.h
Generated on
for BmnRoot by
1.17.0