CbmRoot
Loading...
Searching...
No Matches
CbmStsAnaBase.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Dario Ramirez [committer] */
4
5#include "CbmStsAnaBase.h"
6
7#include "CbmStsModule.h"
8#include "CbmStsStation.h"
9#include "FairRootManager.h"
10
11#include <TGeoBBox.h> // for Geometry loading from file
12#include <TGeoManager.h> // for Geometry loading from file
13#include <TGeoMatrix.h> // for Geometry loading from file
14#include <TGeoNode.h> // for Geometry loading from file
15#include <TGeoPhysicalNode.h> // for Geometry loading from file
16#include <TGeoVolume.h> // for Geometry loading from file
17
18#include <cassert>
19
20
22{
23 assert(cuts_map != nullptr);
24 fAnalysisCuts = cuts_map;
25}
26
28{
30 if (!sts_setup->IsInit()) {
31 sts_setup->Init(nullptr);
32 }
33
34 if (sts_setup == nullptr) {
35 LOG(warning) << "Something is wrong with the setup ...";
36 return;
37 }
38
39 nb_sts_station_ = sts_setup->GetNofStations();
40 assert(nb_sts_station_ != 0);
41
42 for (unsigned short unit_idx = 0; unit_idx < nb_sts_station_; unit_idx++) {
43 CbmStsStation* sts_unit = sts_setup->GetStation(unit_idx);
44 fStsGeoInfo[unit_idx] = std::vector<double>(5, 0);
45 fStsGeoInfo[unit_idx][0] = sts_unit->GetXmin();
46 fStsGeoInfo[unit_idx][1] = sts_unit->GetXmax();
47 fStsGeoInfo[unit_idx][2] = sts_unit->GetYmin();
48 fStsGeoInfo[unit_idx][3] = sts_unit->GetYmax();
49 fStsGeoInfo[unit_idx][4] = sts_unit->GetZ();
50 }
51
52 for (unsigned short module_idx = 0; module_idx < sts_setup->GetNofModules(); module_idx++) { // Loop over modules
53 CbmStsModule* sts_module = sts_setup->GetModule(module_idx);
54 assert(sts_module);
55 int32_t address = sts_module->GetAddress();
56 assert(sts_module->GetNofDaughters() == 1);
57
58 CbmStsElement* sts_sensor = sts_module->GetDaughter(0);
59 TGeoPhysicalNode* sensor_node = sts_sensor->GetPnode();
60 TGeoVolume* sensor_volume = sensor_node->GetVolume();
61 TGeoBBox* sensor_shape = (TGeoBBox*) sensor_volume->GetShape();
62 TGeoMatrix* sensor_matrix = sensor_node->GetMatrix();
63
64 // const double* local = sensor_shape->GetOrigin();
65 const double* trans = sensor_matrix->GetTranslation();
66 fStsGeoInfo[address] = std::vector<double>(6, 0);
67 fStsGeoInfo[address][0] = trans[0] - sensor_shape->GetDX(); // Xmin
68 fStsGeoInfo[address][1] = trans[0] + sensor_shape->GetDX(); // Xmax
69 fStsGeoInfo[address][2] = trans[1] - sensor_shape->GetDY(); // Ymin
70 fStsGeoInfo[address][3] = trans[1] + sensor_shape->GetDY(); // Ymax
71 fStsGeoInfo[address][4] = trans[2] - sensor_shape->GetDZ(); // Zmin
72 fStsGeoInfo[address][5] = trans[2] + sensor_shape->GetDZ(); // Zmax
73
74 if (address > 8) {
75 switch (2 * (int) sensor_shape->GetDY()) {
76 case 2: fFirstZStrip[address] = 2048 - 32; break;
77 case 4: fFirstZStrip[address] = 2048 - 88; break;
78 case 6: fFirstZStrip[address] = 2048 - 134; break;
79 case 12: fFirstZStrip[address] = 2048 - 274; break;
80 default:
81 LOG(warning) << Form("Unknown sensor shape 0x%x: [%0.3f , %0.3f , %0.3f]", address, sensor_shape->GetDX(),
82 sensor_shape->GetDY(), sensor_shape->GetDZ());
83 break;
84 }
85 }
86 }
87
88 LOG(debug) << "Loaded setup information:\n";
89 for (auto& [address, geo] : fStsGeoInfo) {
90 LOG(debug) << Form("0x%x: [%+0.3f, %+0.3f] ^ [%+0.3f, %+0.3f] ^ [%+0.3f, %+0.3f]", address, geo[0], geo[1], geo[2],
91 geo[3], geo[4], geo[5]);
92 }
93}
94
96{
97 FairRootManager* ioman = FairRootManager::Instance();
98 auto sink = ioman->GetSink();
99
100 if (!sink) {
101 LOG(fatal) << "Check the configuration: sink is invalid!";
102 return;
103 }
104
105 LOG(info) << Form("Task histograms will be saved to %s ...", sink->GetFileName().Data());
106
107 for (auto& [name, gr] : fG1D) {
108 if (gr == nullptr) continue;
109 sink->WriteObject(gr.get(), name.c_str());
110 }
111 for (auto& [name, h] : fH1D) {
112 if (h == nullptr) continue;
113 sink->WriteObject(h.get(), name.c_str());
114 }
115 for (auto& [name, h] : fH2D) {
116 if (h == nullptr) continue;
117 sink->WriteObject(h.get(), name.c_str());
118 }
119 for (auto& [name, h] : fH2DShared) {
120 if (h == nullptr) continue;
121 sink->WriteObject(h.get(), name.c_str());
122 }
123}
Char_t * gr
Manages a map of cuts associated with their IDs.
Definition CbmCutMap.h:19
CbmCutMap * fAnalysisCuts
std::map< std::string, std::unique_ptr< TGraphErrors > > fG1D
std::unordered_map< int32_t, int > fFirstZStrip
std::map< std::string, std::unique_ptr< TH2D > > fH2D
std::map< std::string, std::shared_ptr< TH2D > > fH2DShared
void SaveToFile()
It write all mapped objects to the FairRunAna sink file.
void LoadSetup()
Load the STS setup and fill the map with XYZ boundaries for each STS setup element....
std::unordered_map< int32_t, std::vector< double > > fStsGeoInfo
std::map< std::string, std::unique_ptr< TH1D > > fH1D
void SetCutMap(CbmCutMap *map)
Set the cut map for analysis.
Class representing an element of the STS setup.
Int_t GetAddress() const
TGeoPhysicalNode * GetPnode() const
Int_t GetNofDaughters() const
CbmStsElement * GetDaughter(Int_t index) const
Class representing an instance of a readout unit in the CBM-STS.
Class representing the top level of the STS setup.
Definition CbmStsSetup.h:43
Bool_t Init(const char *geometryFile=nullptr)
Initialise the setup.
CbmStsModule * GetModule(Int_t index) const
Get a module from the module array.
Definition CbmStsSetup.h:72
Int_t GetNofStations() const
Definition CbmStsSetup.h:94
static CbmStsSetup * Instance()
CbmStsStation * GetStation(Int_t stationId) const
Int_t GetNofModules() const
Definition CbmStsSetup.h:86
Bool_t IsInit() const
Initialisation status for sensor parameters.
Class representing a station of the StsSystem.
Double_t GetXmax() const
Double_t GetYmin() const
Double_t GetXmin() const
Double_t GetYmax() const
Double_t GetZ() const
Data class with information on a STS local track.