CbmRoot
Loading...
Searching...
No Matches
CbmMvdStationPar.cxx
Go to the documentation of this file.
1/* Copyright (C) 2014-2020 Institut fuer Kernphysik, Goethe-Universitaet Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Philipp Sitzmann [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmMvdStationPar source file -----
7// ----- Created 28/10/14 by P.Sitzmann -----
8// -------------------------------------------------------------------------
9
10#include "CbmMvdStationPar.h"
11
12#include <Logger.h> // for Logger, LOG
13
14#include <limits> // for numeric_limits
15
16#include <assert.h> // for assert
17#include <cmath> // for fabs, isnan
18
19
20// ----- Default constructor -------------------------------------------
22// -------------------------------------------------------------------------
23
24// ----- Destructor ----------------------------------------------------
26// -------------------------------------------------------------------------
27
28// ----- Public method Print -------------------------------------------
29void CbmMvdStationPar::Print(Option_t* /*opt*/) const
30{
31 LOG(info) << "MvdStationPar: Initialized parameter file with " << fStationCount << " stations";
32
33 for (int i = 0; i < fStationCount; i++) {
34 LOG(debug) << "Z Postion station " << i << ": " << GetZPosition(i);
35 }
36
37 for (int i = 0; i < fStationCount; i++) {
38 LOG(debug) << "Z Thickness station " << i << ": " << GetZThickness(i);
39 }
40
41 for (int i = 0; i < fStationCount; i++) {
42 LOG(debug) << "Width station " << i << ": " << GetWidth(i);
43 }
44
45 for (int i = 0; i < fStationCount; i++) {
46 LOG(debug) << "Height station " << i << ": " << GetHeight(i);
47 }
48
49 for (int i = 0; i < fStationCount; i++) {
50 LOG(debug) << "Z Radiation Thickness station " << i << ": " << GetZRadThickness(i);
51 }
52}
53// -------------------------------------------------------------------------
54
55void CbmMvdStationPar::Init(Int_t nrOfStations)
56{
57 fStationCount = nrOfStations;
58
59 constexpr float kNaN {std::numeric_limits<float>::signaling_NaN()};
60
61 // resize the arrays and set all initial values to NaN
62 // to ensure that they will be initialized later
63
64 fZPositions.resize(fStationCount, kNaN);
65 fZPositionMin.resize(fStationCount, std::numeric_limits<float>::max());
66 fZPositionMax.resize(fStationCount, -std::numeric_limits<float>::max());
67 fZThicknesses.resize(fStationCount, kNaN);
68 fHeights.resize(fStationCount, 0.);
69 fWidths.resize(fStationCount, 0.);
70 fXResolutions.resize(fStationCount, kNaN);
71 fYResolutions.resize(fStationCount, kNaN);
72 fZRadThickness.resize(fStationCount, kNaN);
73 fBeamHeights.resize(fStationCount, kNaN);
74 fBeamWidths.resize(fStationCount, kNaN);
75}
76
77// -------------------------------------------------------------------------
78Double_t CbmMvdStationPar::GetParameter(const std::vector<Double_t>& parArray, Int_t iStation) const
79{
80 // return a parameter after out-of-range check
81 if ((iStation < 0) || (iStation >= fStationCount)) {
82 LOG(error) << "Station number out of Range ";
83 return 0.;
84 }
85 return parArray.at(iStation);
86}
87// -------------------------------------------------------------------------
88
89// -------------------------------------------------------------------------
90void CbmMvdStationPar::SetParameterMax(std::vector<Double_t>& parArray, Int_t iStation, Double_t value)
91{
92 // add a parameter after out-of-range check
93 value = fabs(value);
94 if ((iStation < 0) || (iStation >= fStationCount)) { LOG(error) << "Station number out of Range "; }
95 else {
96 Double_t& v = parArray[iStation];
97 if (std::isnan(v) || (v < value)) { v = value; }
98 }
99}
100// -------------------------------------------------------------------------
101
102// -------------------------------------------------------------------------
103void CbmMvdStationPar::SetParameterMin(std::vector<Double_t>& parArray, Int_t iStation, Double_t value)
104{
105 // add a parameter after out-of-range check
106 value = fabs(value);
107 if ((iStation < 0) || (iStation >= fStationCount)) { LOG(error) << "Station number out of Range "; }
108 else {
109 Double_t& v = parArray[iStation];
110 if (std::isnan(v) || (v > value)) { v = value; }
111 }
112}
113// -------------------------------------------------------------------------
114
115
116// -------------------------------------------------------------------------
117
118Double_t CbmMvdStationPar::GetZPosition(Int_t iStation) const { return GetParameter(fZPositions, iStation); }
119
120Double_t CbmMvdStationPar::GetZThickness(Int_t iStation) const { return GetParameter(fZThicknesses, iStation); }
121
122Double_t CbmMvdStationPar::GetHeight(Int_t iStation) const { return GetParameter(fHeights, iStation); }
123
124Double_t CbmMvdStationPar::GetWidth(Int_t iStation) const { return GetParameter(fWidths, iStation); }
125
126Double_t CbmMvdStationPar::GetXRes(Int_t iStation) const { return GetParameter(fXResolutions, iStation); }
127
128Double_t CbmMvdStationPar::GetYRes(Int_t iStation) const { return GetParameter(fYResolutions, iStation); }
129
130Double_t CbmMvdStationPar::GetZRadThickness(Int_t iStation) const { return GetParameter(fZRadThickness, iStation); }
131
132Double_t CbmMvdStationPar::GetBeamHeight(Int_t iStation) const { return GetParameter(fBeamHeights, iStation); }
133
134Double_t CbmMvdStationPar::GetBeamWidth(Int_t iStation) const { return GetParameter(fBeamWidths, iStation); }
135
136// -------------------------------------------------------------------------
137
138
139// -------------------------------------------------------------------------
140void CbmMvdStationPar::AddZPosition(Int_t iStation, Double_t z, Double_t zThickness)
141{
142 Double_t& zMin = fZPositionMin[iStation];
143 Double_t& zMax = fZPositionMax[iStation];
144 assert(zThickness >= 0.);
145 if (z - zThickness < zMin) zMin = z - zThickness;
146 if (z + zThickness > zMax) zMax = z + zThickness;
147 fZPositions[iStation] = 0.5 * (zMin + zMax);
148 fZThicknesses[iStation] = zMax - zMin;
149}
150
151void CbmMvdStationPar::AddHeight(Int_t iStation, Double_t value) { SetParameterMax(fHeights, iStation, value); }
152
153void CbmMvdStationPar::AddWidth(Int_t iStation, Double_t value) { SetParameterMax(fWidths, iStation, value); }
154
155void CbmMvdStationPar::AddXRes(Int_t iStation, Double_t value) { SetParameterMax(fXResolutions, iStation, value); }
156
157void CbmMvdStationPar::AddYRes(Int_t iStation, Double_t value) { SetParameterMax(fYResolutions, iStation, value); }
158
159void CbmMvdStationPar::AddZRadThickness(Int_t iStation, Double_t value)
160{
161 SetParameterMax(fZRadThickness, iStation, value);
162}
163
164void CbmMvdStationPar::AddBeamHeight(Int_t iStation, Double_t value) { SetParameterMin(fBeamHeights, iStation, value); }
165
166void CbmMvdStationPar::AddBeamWidth(Int_t iStation, Double_t value) { SetParameterMin(fBeamWidths, iStation, value); }
167// -------------------------------------------------------------------------
168
169
ClassImp(CbmConverterManager)
fscal v[fmask::Size]
Definition KfSimdPseudo.h:4
void AddYRes(Int_t stationNumber, Double_t yres)
void Init(Int_t nrOfStations)
void SetParameterMin(std::vector< Double_t > &parArray, Int_t iStation, Double_t value)
Double_t GetBeamWidth(Int_t stationNumber) const
std::vector< Double_t > fZPositionMax
std::vector< Double_t > fZPositions
std::vector< Double_t > fWidths
Double_t GetParameter(const std::vector< Double_t > &parArray, Int_t iStation) const
void Print(Option_t *opt="") const
void AddZPosition(Int_t stationNumber, Double_t z, Double_t zThickness)
void AddBeamWidth(Int_t stationNumber, Double_t beamwidth)
std::vector< Double_t > fZPositionMin
std::vector< Double_t > fHeights
std::vector< Double_t > fYResolutions
Double_t GetYRes(Int_t stationNumber) const
std::vector< Double_t > fZThicknesses
void AddHeight(Int_t stationNumber, Double_t height)
Double_t GetHeight(Int_t stationNumber) const
Double_t GetZRadThickness(Int_t stationNumber) const
std::vector< Double_t > fZRadThickness
Double_t GetZPosition(Int_t stationNumber) const
std::vector< Double_t > fBeamHeights
Double_t GetXRes(Int_t stationNumber) const
void AddWidth(Int_t stationNumber, Double_t width)
void SetParameterMax(std::vector< Double_t > &parArray, Int_t iStation, Double_t value)
Double_t GetWidth(Int_t stationNumber) const
void AddBeamHeight(Int_t stationNumber, Double_t beamheight)
void AddZRadThickness(Int_t stationNumber, Double_t length)
Double_t GetZThickness(Int_t stationNumber) const
Double_t GetBeamHeight(Int_t stationNumber) const
void AddXRes(Int_t stationNumber, Double_t xres)
std::vector< Double_t > fBeamWidths
std::vector< Double_t > fXResolutions