HerdSoftware  0.4.0
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
38 
39 // c++ headers
40 #include <functional>
41 #include <string>
42 
43 namespace Herd::Readers {
44 // clang-format off
50 // clang-format on
52 public:
53  GGSCaloHitsReader(std::shared_ptr<GGSTRootReader> ggsReader)
54  : m_ggsReader{ggsReader}, m_hitReader{m_ggsReader->GetReader<GGSTHitsReader>()}, m_sameIDs{false} {};
55 
64  bool IsCaloHitsAvailable();
65 
72  EA::RetrievalResult GetCaloHits(EA::ObjectWrapper &wrapper);
73 
85  std::vector<std::string> FreeObjects(const std::vector<std::string> &objs, EA::Memory::Status memStatus);
86 
94  void SetCaloHitIDFromGGSPos(std::function<unsigned int(const float *)> conversionFunction) {
95  m_caloVolIDFromGGSPos = conversionFunction;
96  };
97 
106  void SetSameIDs(bool value) { m_sameIDs = value; };
107 
108 private:
109  std::shared_ptr<GGSTRootReader> m_ggsReader;
110  GGSTHitsReader *m_hitReader = nullptr;
111  long long int m_lastReadEvent = std::numeric_limits<long long int>::max();
112 
113  std::function<unsigned int(const float *)> m_caloVolIDFromGGSPos;
114  bool m_sameIDs;
115  int m_caloDetIndex = std::numeric_limits<int>::lowest();
117 };
118 } // namespace Herd::Readers
119 
120 #endif
Herd::Readers::GGSCaloHitsReader
CaloHits reader class.
Definition: GGSCaloHitsReader.h:51
Herd::Readers
Definition: GGSCaloHitsReader.h:43
Herd::Readers::GGSCaloHitsReader::m_sameIDs
bool m_sameIDs
Definition: GGSCaloHitsReader.h:114
Herd::Readers::GGSCaloHitsReader::m_lastReadEvent
long long int m_lastReadEvent
Definition: GGSCaloHitsReader.h:111
Herd::Readers::GGSCaloHitsReader::m_caloHits
CaloHits m_caloHits
Definition: GGSCaloHitsReader.h:116
Herd::Readers::GGSCaloHitsReader::SetSameIDs
void SetSameIDs(bool value)
Sets the same IDs flag.
Definition: GGSCaloHitsReader.h:106
CaloHits
Container for the hits of a single CALO detector.
Herd::Readers::GGSCaloHitsReader::m_caloVolIDFromGGSPos
std::function< unsigned int(const float *)> m_caloVolIDFromGGSPos
Definition: GGSCaloHitsReader.h:113
Herd::Readers::GGSCaloHitsReader::IsCaloHitsAvailable
bool IsCaloHitsAvailable()
Checks if CALO hits are available in the simulation file.
Definition: GGSCaloHitsReader.cpp:14
CaloHits.h
Herd::Readers::GGSCaloHitsReader::SetCaloHitIDFromGGSPos
void SetCaloHitIDFromGGSPos(std::function< unsigned int(const float *)> conversionFunction)
Set the volID calculator for the calorimeter.
Definition: GGSCaloHitsReader.h:94
Herd::Readers::GGSCaloHitsReader::m_hitReader
GGSTHitsReader * m_hitReader
Definition: GGSCaloHitsReader.h:110
Herd::Readers::GGSCaloHitsReader::GGSCaloHitsReader
GGSCaloHitsReader(std::shared_ptr< GGSTRootReader > ggsReader)
Definition: GGSCaloHitsReader.h:53
Herd::Readers::GGSCaloHitsReader::FreeObjects
std::vector< std::string > FreeObjects(const std::vector< std::string > &objs, EA::Memory::Status memStatus)
Free the memory of unneeded objects.
Definition: GGSCaloHitsReader.cpp:66
Herd::Readers::GGSCaloHitsReader::m_ggsReader
std::shared_ptr< GGSTRootReader > m_ggsReader
Definition: GGSCaloHitsReader.h:106
DefaultValues.h
Herd::Readers::GGSCaloHitsReader::m_caloDetIndex
int m_caloDetIndex
Definition: GGSCaloHitsReader.h:115
Herd::Readers::GGSCaloHitsReader::GetCaloHits
EA::RetrievalResult GetCaloHits(EA::ObjectWrapper &wrapper)
Get the CALO Hits.
Definition: GGSCaloHitsReader.cpp:22