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