HerdSoftware  0.4.0
GGSCaloSpdHitsReader.h
Go to the documentation of this file.
1 /*
2  * GGSCaloSpdHitsReader.h
3  *
4  * Created on: 25 June 2022
5  * Author: Pietro Betti
6  */
7 
10 #ifndef HERD_GGSSPDHITSREADER_H_
11 #define HERD_GGSSPDHITSREADER_H_
12 
13 #ifndef GGSSMARTLOG_H_
14 #define HERD_GGSSPDHITSREADER_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_GGSSPDHITSREADER_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
38 
39 // c++ headers
40 #include <functional>
41 #include <string>
42 
43 using namespace EA;
44 
45 namespace Herd {
46 
47 namespace Readers {
48 // clang-format off
54 // clang-format on
56 public:
57  GGSCaloSpdHitsReader(std::shared_ptr<GGSTRootReader> ggsReader)
58  : m_ggsReader{ggsReader}, m_hitReader{m_ggsReader->GetReader<GGSTHitsReader>()}, m_sameIDs{false} {};
59 
68  bool IsCaloSpdHitsAvailable();
69 
76  RetrievalResult GetCaloSpdHits(ObjectWrapper &wrapper);
77 
89  std::vector<std::string> FreeObjects(const std::vector<std::string> &objs, Memory::Status memStatus);
90 
98  void SetCaloSpdHitIDFromGGSPos(std::function<unsigned int(const float *)> conversionFunction) {
99  m_spdVolIDFromGGSPos = conversionFunction;
100  };
101 
110  void SetSameIDs(bool value) { m_sameIDs = value; };
111 
112 private:
113  std::shared_ptr<GGSTRootReader> m_ggsReader;
114  GGSTHitsReader *m_hitReader = nullptr;
115  long long int m_lastReadEvent = std::numeric_limits<long long int>::max();
116 
117  std::function<unsigned int(const float *)> m_spdVolIDFromGGSPos;
118  bool m_sameIDs;
119  int m_caloDetIndex = std::numeric_limits<int>::lowest();
121 };
122 } // namespace Readers
123 } // namespace Herd
124 
125 #endif
Herd::Readers::GGSCaloSpdHitsReader::GGSCaloSpdHitsReader
GGSCaloSpdHitsReader(std::shared_ptr< GGSTRootReader > ggsReader)
Definition: GGSCaloSpdHitsReader.h:57
Herd::Readers::GGSCaloSpdHitsReader::m_spdVolIDFromGGSPos
std::function< unsigned int(const float *)> m_spdVolIDFromGGSPos
Definition: GGSCaloSpdHitsReader.h:117
Herd::Readers::GGSCaloSpdHitsReader
SpdHits reader class.
Definition: GGSCaloSpdHitsReader.h:55
Herd::Readers::GGSCaloSpdHitsReader::m_CaloSpdHits
CaloSpdHits m_CaloSpdHits
Definition: GGSCaloSpdHitsReader.h:120
Herd
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:22
Herd::Readers::GGSCaloSpdHitsReader::SetSameIDs
void SetSameIDs(bool value)
Sets the same IDs flag.
Definition: GGSCaloSpdHitsReader.h:110
Herd::Readers::GGSCaloSpdHitsReader::SetCaloSpdHitIDFromGGSPos
void SetCaloSpdHitIDFromGGSPos(std::function< unsigned int(const float *)> conversionFunction)
Set the volID calculator for the SPD.
Definition: GGSCaloSpdHitsReader.h:98
CaloSpdHits.h
Herd::Readers::GGSCaloSpdHitsReader::m_sameIDs
bool m_sameIDs
Definition: GGSCaloSpdHitsReader.h:118
DefaultValues.h
CaloSpdHits
Container for the hits of a single SPD detector.