HerdSoftware  0.3.2
GGSPsdHitsReader.h
Go to the documentation of this file.
1 /*
2  * GGSPsdHitsReader.h
3  *
4  * Created on: 31 May 2021
5  * Author: Valerio Formato
6  */
7 
10 #ifndef HERD_GGSPSDHITSREADER_H_
11 #define HERD_GGSPSDHITSREADER_H_
12 
13 #ifndef GGSSMARTLOG_H_
14 #define HERD_GGSPSDHITSREADER_H_UNDEF_LOGGING
15 #endif
16 
17 // GGS headers
18 #include "montecarlo/readers/GGSTHitsReader.h"
19 #include "montecarlo/readers/GGSTRootReader.h"
20 
21 #ifdef HERD_GGSPSDHITSREADER_H_UNDEF_LOGGING
22 // Remove the definitions of GGS output macros (would conflict with the same macros defined in EventAnalysis)
23 // We only do this if GGSSmartLog.h is being parsed in this TU, otherwise there would be nothing to undef
24 // (or we could even be undefining the EA macros)
25 #undef COUT
26 #undef CCOUT
27 #undef ENDL
28 #endif
29 
30 // EA headers
31 #include "core/ObjectWrapper.h"
32 #include "core/RetrievalResult.h"
33 #include "utils/Memory.h"
34 
35 // HerdSoftware headers
36 #include "common/DefaultValues.h"
40 
41 // c++ headers
42 #include <functional>
43 #include <string>
44 #include <utility>
45 
46 using namespace EA;
47 
48 namespace Herd {
49 
50 namespace Readers {
51 // clang-format off
57 // clang-format on
59 public:
60  enum class DetectorType : int { NONE = -1, TILES = 0, BARS = 1 };
61 
62  explicit GGSPsdHitsReader(std::shared_ptr<GGSTRootReader> ggsReader)
63  : m_ggsReader{std::move(ggsReader)}, m_hitReader{m_ggsReader->GetReader<GGSTHitsReader>()} {};
64 
71  bool IsPsdHitsCollAvailable();
72 
81  RetrievalResult GetPsdHitsColl(ObjectWrapper &wrapper);
82 
91  bool IsPsdParticleHitsCollAvailable();
92 
99  RetrievalResult GetPsdParticleHitsColl(ObjectWrapper &wrapper);
100 
101  std::vector<std::string> FreeObjects(const std::vector<std::string> &objs, Memory::Status memStatus);
102 
109  void SetPsdGeoParamsColl(observer_ptr<PsdGeoParamsColl> psdGeoParamsColl);
110 
116  void SetFileName(const std::string &fileName) { m_fileName = fileName; };
117 
123  void SetPsdType(DetectorType type);
124 
125 private:
126  std::shared_ptr<GGSTRootReader> m_ggsReader;
127  GGSTHitsReader *m_hitReader = nullptr;
128  long long int m_lastHitsReadEvent = std::numeric_limits<long long int>::max();
129  long long int m_lastPartHitsReadEvent = std::numeric_limits<long long int>::max();
130 
131  enum class SidePsdSegmentation : int { NONE = -1, H = 0, V = 1 };
132 
133  struct PsdIDVolInfo {
134  unsigned int ID;
135  unsigned int layer;
137  };
138 
139  bool m_readPsdParticleHits = false;
140 
141  DetectorType m_type = DetectorType::NONE;
142  observer_ptr<PsdGeoParamsColl> m_psdGeoParamsColl = nullptr;
143  int m_topPsdDetIndex = std::numeric_limits<int>::lowest();
144  std::vector<int> m_sidePsdDetIndexes;
145  bool SetupPsdReadout(bool getParticleHits);
146  PsdIDVolInfo SidePsdHitIDLayerSideFromGGSID(int iGGSPsdID, SidePsdSegmentation sidePsdSegmentation);
147 
150 
151  std::string m_fileName;
152 };
153 } // namespace Readers
154 } // namespace Herd
155 
156 #endif
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:24
std::string m_fileName
Definition: GGSPsdHitsReader.h:151
Definition: GGSPsdHitsReader.h:133
unsigned int ID
Definition: GGSPsdHitsReader.h:134
Side
Aliases for the five sides. RefFrame.h common/RefFrame.h.
Definition: RefFrame.h:113
PsdHits reader class.
Definition: GGSPsdHitsReader.h:58
GGSPsdHitsReader(std::shared_ptr< GGSTRootReader > ggsReader)
Definition: GGSPsdHitsReader.h:62
DetectorType
Definition: GGSPsdHitsReader.h:60
RefFrame::Side side
Definition: GGSPsdHitsReader.h:136
SidePsdSegmentation
Definition: GGSPsdHitsReader.h:131
void SetFileName(const std::string &fileName)
Set the name of the input file.
Definition: GGSPsdHitsReader.h:116
unsigned int layer
Definition: GGSPsdHitsReader.h:135
PsdParticleHitsColl m_psdParticleHitsColl
Definition: GGSPsdHitsReader.h:149
std::shared_ptr< GGSTRootReader > m_ggsReader
Definition: GGSPsdHitsReader.h:126
std::vector< int > m_sidePsdDetIndexes
Definition: GGSPsdHitsReader.h:144
PsdHitsColl m_psdHitsColl
Definition: GGSPsdHitsReader.h:148