BmnRoot
Loading...
Searching...
No Matches
BmnFHCalGeo.h
Go to the documentation of this file.
1#ifndef BMNFHCALGEO_H
2#define BMNFHCALGEO_H
3
4#include "BmnFHCalAddress.h"
5#include "BmnFHCalGeoPar.h"
6#include "BmnGeoTemplate.h"
7
8#include <regex>
9
10static const std::regex kFHCalRegex{BmnFHCalGeoPar::fElementPattern};
11
12class BmnFHCalGeo
13 : public FairGeoSet
14 , public BmnGeoTemplate<BmnFHCalGeo>
15{
16 public:
18 : FairGeoSet()
19 {
20 SetName("BmnFHCalGeo");
21 }
22
23 static bool CheckIfSensitive(const std::string& vol) { return BmnFHCalGeoPar::CheckIfSensitive(vol); }
26 static const char* TopVolumeName() { return BmnFHCalGeoPar::fTopVolumeName; }
27
28 uint32_t GetAddressFromPath(const std::string& spath)
29 {
30 std::smatch m;
31 if (std::regex_search(spath, m, kFHCalRegex) && m.size() == 3) {
32 int mod = std::stoi(m[1]);
33 int tyv = std::stoi(m[2]);
34 int sec = ((tyv - 1) / 6) + 1; // calculate section number
35 int sc = ((tyv - 1) % 6) + 1; // calculate scintillator number (in section)
36 int type = (spath.find(BmnFHCalGeoPar::NICA_pattern) == std::string::npos ? 2 : 1);
37 return BmnFHCalAddress::GetAddress(type, mod, sec, sc);
38 }
39 LOG(error) << GetName() << " : No address for path " << spath;
40 return 0;
41 }
42
43 // --- override only the traversal/averaging logic ---
45 {
46 // getting position of 1st scintillator
47 fPositionMap.clear();
48
49 int N = gGeoManager->CountNodes();
50 for (int i = 0; i < N; ++i) {
51 gGeoManager->CdNode(i);
52 auto* node = gGeoManager->GetCurrentNode();
53 if (!node)
54 continue;
55 if (!BmnFHCalGeoPar::CheckIfSensitive(node->GetVolume()->GetName()))
56 continue;
57
58 uint32_t fullAddr = GetAddressFromPath(gGeoManager->GetPath());
59 if (BmnFHCalAddress::GetScintillatorId(fullAddr) != 1)
60 continue;
61
62 uint32_t physAddr = BmnFHCalAddress::GetPhysicalAddress(fullAddr);
63 double loc[3] = {0}, glb[3];
64 gGeoManager->LocalToMaster(loc, glb);
65 TVector3 pos(glb[0], glb[1], glb[2]);
66 TVector3 err = GetPosError(node); // Grab the default half–size error (from the TGeoBBox)
67 err.SetZ(err.Z() * 2 * 5 * 6); // Scale eZ. 2 sides. 1:4 scintillator:lead sampling. 6 layers;
68 fPositionMap[physAddr] = std::make_pair(pos, err);
69 }
70 }
71
72 int GetMaxModuleId() const
73 {
74 uint32_t mx = 0;
75 for (auto& kv : fPositionMap) {
76 mx = std::max(mx, BmnFHCalAddress::GetModuleId(kv.first));
77 }
78 return mx;
79 }
80
81 ClassDef(BmnFHCalGeo, 4)
82};
83
84#endif // BMNFHCALGEO_H
int i
Definition P4_F32vec4.h:22
__m128 m
Definition P4_F32vec4.h:27
static uint32_t GetModuleId(uint32_t address)
Return Module id from address.
static uint32_t GetPhysicalAddress(uint32_t address)
Return Physical address (w/o scintillator id) from address.
static uint32_t GetAddress(uint32_t ModuleType, uint32_t ModuleId, uint32_t SectionId, uint32_t ScintillatorId=0)
Return address from system ID, Module type, Module ID, Section ID, Scintillator ID (optional).
static uint32_t GetScintillatorId(uint32_t address)
Return Scintillator id from address.
static const std::regex fElementPattern
static const TString fPathBeforeLocalSystem
static const TString fTopVolumeName
static bool CheckIfSensitive(std::string name)
static const TString fDetectorVolumeName
static const TString NICA_pattern
static bool CheckIfSensitive(const std::string &vol)
Definition BmnFHCalGeo.h:23
int GetMaxModuleId() const
Definition BmnFHCalGeo.h:72
static const char * PathBeforeLocalSystem()
Definition BmnFHCalGeo.h:24
static const char * DetectorVolumeName()
Definition BmnFHCalGeo.h:25
static const char * TopVolumeName()
Definition BmnFHCalGeo.h:26
uint32_t GetAddressFromPath(const std::string &spath)
Definition BmnFHCalGeo.h:28
void ListNodesImpl()
Definition BmnFHCalGeo.h:44
TVector3 GetPosError(TGeoNode *node) const
by default: box‐half‐sizes
std::map< uint32_t, std::pair< TVector3, TVector3 > > fPositionMap