HerdSoftware  0.1.1
ParametricGeoReader.h
Go to the documentation of this file.
1 /*
2  * ParametricGeoReader.h
3  *
4  * Created on: 07 Jan 2021
5  * Author: Valerio Formato
6  */
7 
10 #ifndef HERD_PARAMETRICGEOREADER_H_
11 #define HERD_PARAMETRICGEOREADER_H_
12 
13 #ifndef GGSSMARTLOG_H_
14 #define HERD_PARAMETRICGEOREADER_H_UNDEF_LOGGING
15 #endif
16 
17 // GGS headers
18 #include "montecarlo/readers/GGSTRootReader.h"
19 
20 #ifdef HERD_PARAMETRICGEOREADER_H_UNDEF_LOGGING
21 // Remove the definitions of GGS output macros (would conflict with the same macros defined in EventAnalysis)
22 // We only do this if GGSSmartLog.h is being parsed in this TU, otherwise there would be nothing to undef
23 // (or we could even be undefining the EA macros)
24 #undef COUT
25 #undef CCOUT
26 #undef ENDL
27 #endif
28 
29 // HerdSoftware headers
30 #include "common/DefaultValues.h"
38 
39 // c++ headers
40 #include <functional>
41 #include <string>
42 
43 using namespace EA;
44 
45 namespace Herd {
46 
47 // clang-format off
54 // clang-format on
55 
57 public:
64  ParametricGeoReader(std::shared_ptr<GGSTRootReader> reader);
65 
66  virtual ~ParametricGeoReader() = default;
67 
76  virtual bool SetCurrentEvent(unsigned int) final { return true; };
77 
85  virtual bool IsObjectAvailable(const std::string &name) final;
86 
94  virtual bool IsObjectKnown(const std::string &name) final;
95 
106  RetrievalResult GetObject(const std::string &name, ObjectCategory category, ObjectWrapper &wrapper,
107  std::string &actualName) final;
108 
118  virtual std::vector<std::string> FreeObjects(const std::vector<std::string> &, Memory::Status) final {
119  return std::vector<std::string>();
120  };
121 
129  std::function<unsigned int(const float *)> CaloHitIDFromGGSPos() { return m_caloVolIDFromGGSPos; };
130 
137  std::array<int, 4> SideFitFirstVolumeID() { return m_sideFitFirstVolumeID; }
138 
145  std::array<int, 4> SideStkFirstWaferID() { return m_sideStkFirstWaferID; }
146 
153  std::array<int, 4> SideStkFirstStripID() { return m_sideStkFirstStripID; }
154 
161  std::array<int, 4> SideScdFirstWaferID() { return m_sideScdFirstWaferID; }
162 
169  std::array<int, 4> SideScdFirstStripID() { return m_sideScdFirstStripID; }
170 
175  std::pair<bool, bool> StkHasStrips() { return {m_topStkHasStrips, m_sideStkHasStrips}; }
176 
181  std::pair<bool, bool> ScdHasStrips() { return {m_topScdHasStrips, m_sideScdHasStrips}; }
182 
183  enum class PsdType : int { NONE = -1, tiles = 0, bars = 1 };
184  PsdType GetPsdType() { return m_psdType; }
185 
186 private:
187  struct ObjDescriptor {
188  std::string name;
189  std::vector<std::string> aliases;
191  ObjectWrapper wrapper;
192  std::function<ObjectWrapper(ParametricGeoReader *)> retriever;
193  std::function<bool(ParametricGeoReader *)> checker;
194  };
195 
196  struct CaloGeoParamsHelpValues; // implemented inside CaloReader.cpp
197 
198  std::vector<ObjDescriptor> m_knownObjects;
199 
200  std::shared_ptr<GGSTRootReader> m_ggsreader;
201 
202  void CheckAvailableObjects();
203 
204  // CALO
206  std::function<unsigned int(const float *)> m_caloVolIDFromGGSPos;
207  bool IsCaloGeoParamsAvailable();
208  ObjectWrapper GetCaloGeoParams();
209  // Methods used for cube mask, which constins the GGS ID
210  int CaloTray(int iGGSCubeID, CaloGeoParamsHelpValues caloValues);
211  int CaloLayer(int iGGSCubeID, CaloGeoParamsHelpValues caloValues);
212  unsigned int CaloHitIDFromGGSID(int iGGSCubeID, CaloGeoParamsHelpValues caloValues);
213 
214  // PSD
216  PsdType m_psdType = PsdType::NONE;
217  bool IsPsdGeoParamsAvailable();
218  ObjectWrapper GetPsdGeoParams();
219 
220  RetrievalResult BuildBarPsdGeoParams(const GGSTGeoParams *params, bool onSource);
221  RetrievalResult BuildTilePsdGeoParams(const GGSTGeoParams *params, bool onSource);
222 
223  // FIT
225  std::array<int, 4> m_sideFitFirstVolumeID;
226  bool IsFitGeoParamsAvailable();
227  ObjectWrapper GetFitGeoParams();
228 
229  // STK
231  std::array<int, 4> m_sideStkFirstWaferID;
232  std::array<int, 4> m_sideStkFirstStripID;
233  bool m_topStkHasStrips = false;
234  bool m_sideStkHasStrips = false;
235  bool IsStkGeoParamsAvailable();
236  ObjectWrapper GetStkGeoParams();
237 
238  // SCD
240  std::array<int, 4> m_sideScdFirstWaferID;
241  std::array<int, 4> m_sideScdFirstStripID;
242  bool m_topScdHasStrips = false;
243  bool m_sideScdHasStrips = false;
244  bool IsScdGeoParamsAvailable();
245  ObjectWrapper GetScdGeoParams();
246 
247  // CSS
249  bool IsCssGeoParamsAvailable();
250  ObjectWrapper GetCssGeoParams();
251 
252  // TGeo
253  bool IsGGSTGeoAvailable();
254  ObjectWrapper GetGGSTGeo();
255 };
256 } // namespace Herd
257 
258 #endif
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:24
std::array< int, 4 > SideScdFirstWaferID()
Get the GGS volID of the first wafer for each side SCD detector.
Definition: ParametricGeoReader.h:161
CaloGeoParams m_caloGeoParams
Definition: ParametricGeoReader.h:205
Base class for ParametricGeoReaders.
Definition: ParametricGeoReader.h:56
std::array< int, 4 > SideStkFirstWaferID()
Get the GGS volID of the first wafer for each side STK detector.
Definition: ParametricGeoReader.h:145
std::array< int, 4 > m_sideStkFirstStripID
Definition: ParametricGeoReader.h:232
PsdType
Definition: ParametricGeoReader.h:183
std::unique_ptr< PsdGeoParamsColl > BuildTilePsdGeoParams(const GGSTGeoParams *, bool)
std::function< unsigned int(const float *)> CaloHitIDFromGGSPos()
Get the volID calculator for the calorimeter.
Definition: ParametricGeoReader.h:129
std::shared_ptr< GGSTRootReader > m_ggsreader
Definition: ParametricGeoReader.h:200
Definition: ParametricGeoReader.h:187
ObjectWrapper wrapper
Definition: ParametricGeoReader.h:191
std::array< int, 4 > m_sideScdFirstWaferID
Definition: ParametricGeoReader.h:240
std::vector< ObjDescriptor > m_knownObjects
Definition: ParametricGeoReader.h:196
Data structure for the Calo geometry parameters.
Definition: CaloGeoParams.h:29
PsdType GetPsdType()
Definition: ParametricGeoReader.h:184
bool isOnSource
Definition: ParametricGeoReader.h:190
ScdGeoParamsColl m_scdGeoParamsColl
Definition: ParametricGeoReader.h:239
StkGeoParamsColl m_stkGeoParamsColl
Definition: ParametricGeoReader.h:230
std::array< int, 4 > SideFitFirstVolumeID()
Get the GGS volID of the first volume for each side FIT detector.
Definition: ParametricGeoReader.h:137
std::array< int, 4 > SideStkFirstStripID()
Get the GGS volID of the first strip for each side STK detector.
Definition: ParametricGeoReader.h:153
virtual std::vector< std::string > FreeObjects(const std::vector< std::string > &, Memory::Status) final
Free the memory of unneeded objects.
Definition: ParametricGeoReader.h:118
std::pair< bool, bool > ScdHasStrips()
Check whether Scd has native strips (Top and Side).
Definition: ParametricGeoReader.h:181
virtual bool SetCurrentEvent(unsigned int) final
Sets the current event.
Definition: ParametricGeoReader.h:76
CssGeoParams m_cssGeoParams
Definition: ParametricGeoReader.h:248
FitGeoParamsColl m_fitGeoParamsColl
Definition: ParametricGeoReader.h:224
PsdGeoParamsColl m_psdGeoParamsColl
Definition: ParametricGeoReader.h:215
std::array< int, 4 > m_sideStkFirstWaferID
Definition: ParametricGeoReader.h:231
std::function< ObjectWrapper(ParametricGeoReader *)> retriever
Definition: ParametricGeoReader.h:192
std::vector< std::string > aliases
Definition: ParametricGeoReader.h:189
std::array< int, 4 > SideScdFirstStripID()
Get the GGS volID of the first strip for each side SCD detector.
Definition: ParametricGeoReader.h:169
std::array< int, 4 > m_sideScdFirstStripID
Definition: ParametricGeoReader.h:241
std::pair< bool, bool > StkHasStrips()
Check whether Stk has native strips (Top and Side).
Definition: ParametricGeoReader.h:175
std::unique_ptr< PsdGeoParamsColl > BuildBarPsdGeoParams(const GGSTGeoParams *, bool)
Base class for DataReaders.
Definition: DataReader.h:38
std::string name
Definition: ParametricGeoReader.h:188
std::function< bool(ParametricGeoReader *)> checker
Definition: ParametricGeoReader.h:193
std::array< int, 4 > m_sideFitFirstVolumeID
Definition: ParametricGeoReader.h:225
std::function< unsigned int(const float *)> m_caloVolIDFromGGSPos
Definition: ParametricGeoReader.h:206
Geometry parameters of the Chinese Space station.
Definition: CssGeoParams.h:22