HerdSoftware  0.2.3
GGSCaloHitsReader.h
Go to the documentation of this file.
1 /*
2  * GGSCaloHitsReader.h
3  *
4  * Created on: 27 May 2021
5  * Author: Valerio Formato
6  */
7 
10 #ifndef HERD_GGSCALOHITSREADER_H_
11 #define HERD_GGSCALOHITSREADER_H_
12 
13 #ifndef GGSSMARTLOG_H_
14 #define HERD_GGSCALOHITSREADER_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_GGSCALOHITSREADER_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"
37 #include "dataobjects/CaloHits.h"
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  GGSCaloHitsReader(std::shared_ptr<GGSTRootReader> ggsReader)
58  : m_ggsReader{ggsReader}, m_hitReader{m_ggsReader->GetReader<GGSTHitsReader>()} {};
59 
68  bool IsCaloHitsAvailable();
69 
76  RetrievalResult GetCaloHits(ObjectWrapper &wrapper);
77 
89  std::vector<std::string> FreeObjects(const std::vector<std::string> &objs, Memory::Status memStatus);
90 
98  void SetCaloHitIDFromGGSPos(std::function<unsigned int(const float *)> conversionFunction) {
99  m_caloVolIDFromGGSPos = conversionFunction;
100  };
101 
102 private:
103  std::shared_ptr<GGSTRootReader> m_ggsReader;
104  GGSTHitsReader *m_hitReader = nullptr;
105  long long int m_lastReadEvent = std::numeric_limits<long long int>::max();
106 
107  std::function<unsigned int(const float *)> m_caloVolIDFromGGSPos;
108  int m_caloDetIndex = std::numeric_limits<int>::lowest();
110 };
111 } // namespace Readers
112 } // namespace Herd
113 
114 #endif
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:24
CaloHits m_caloHits
Definition: GGSCaloHitsReader.h:109
std::shared_ptr< GGSTRootReader > m_ggsReader
Definition: GGSCaloHitsReader.h:100
CaloHits reader class.
Definition: GGSCaloHitsReader.h:55
GGSCaloHitsReader(std::shared_ptr< GGSTRootReader > ggsReader)
Definition: GGSCaloHitsReader.h:57
void SetCaloHitIDFromGGSPos(std::function< unsigned int(const float *)> conversionFunction)
Set the volID calculator for the calorimeter.
Definition: GGSCaloHitsReader.h:98
std::function< unsigned int(const float *)> m_caloVolIDFromGGSPos
Definition: GGSCaloHitsReader.h:107
Container for the hits of a single CALO detector.