EICrecon
JANA based reconstruction for the EPIC detector
Loading...
Searching...
No Matches
DumpFlags_processor.h
Go to the documentation of this file.
1#pragma once
2
3#include <JANA/JEventProcessor.h>
4#include <algorithm>
5#include <cctype>
6#include <string>
7#include <vector>
8
10
11class DumpFlags_processor : public JEventProcessor, public eicrecon::SpdlogMixin {
12public:
13 //----------------------------
14 // Init
15 //
16 // This is called once before the first call to the Process method
17 // below. You may, for example, want to open an output file here.
18 // Only one thread will call this.
19 void Init() override;
20
21 //----------------------------
22 // Process
23 //
24 // This is called for every event. Multiple threads may call this
25 // simultaneously. If you write something to an output file here
26 // then make sure to protect it with a mutex or similar mechanism.
27 // Minimize what is done while locked since that directly affects
28 // the multi-threaded performance.
29 void Process(const std::shared_ptr<const JEvent>& event) override;
30
31 //----------------------------
32 // Finish
33 //
34 // This is called once after all events have been processed. You may,
35 // for example, want to close an output file here.
36 // Only one thread will call this.
37 void Finish() override;
38
39private:
41 std::string m_python_file_name = "";
42
44 std::string m_markdown_file_name = "";
45
47 std::string m_json_file_name = "";
48
50 std::string m_janaconfig_file_name = "jana.conf";
51
53 bool m_print_to_screen = true;
54
56 std::vector<std::string> m_reco_prefixes = {
57 "B0TRK", "BEMC", "DRICH", "BTRK", "BVTX", "ECTRK", "EEMC", "FOFFMTRK", "HCAL",
58 "MPGD", "RPOTS", "LOWQ2", "ZDC", "Tracking", "Reco", "Digi", "Calorimetry"};
59
61 bool isReconstructionFlag(
62 std::string
63 flag_name) { // (!) copy value is important here! don't do const& NOLINT(performance-unnecessary-value-param)
64
65 // convert flag_name to lower
66 std::transform(flag_name.begin(), flag_name.end(), flag_name.begin(),
67 static_cast<int (*)(int)>(&std::tolower));
68
69 for (auto subsystem : m_reco_prefixes) { // (!) copy value is important here! don't do auto&
70
71 // Convert subsystem to lower
72 std::transform(subsystem.begin(), subsystem.end(), subsystem.begin(),
73 static_cast<int (*)(int)>(&std::tolower));
74
75 // if not sure, read this
76 // https://stackoverflow.com/questions/1878001/how-do-i-check-if-a-c-stdstring-starts-with-a-certain-string-and-convert-a
77 if (flag_name.rfind(subsystem, 0) == 0) { // pos=0 limits the search to the prefix
78 // s starts with prefix
79 return true;
80 }
81 }
82
83 // flag prefix is not in list
84 return false;
85 }
86
87 std::string findCategory(
88 std::string
89 flag_name) { // (!) copy value is important here! don't do const& NOLINT(performance-unnecessary-value-param)
90
91 // convert flag_name to lower
92 std::transform(flag_name.begin(), flag_name.end(), flag_name.begin(),
93 static_cast<int (*)(int)>(&std::tolower));
94
95 for (auto subsystem : m_reco_prefixes) { // (!) copy value is important here! don't do auto&
96
97 // Convert subsystem to lower
98 std::string original_subsystem_name = subsystem;
99 std::transform(subsystem.begin(), subsystem.end(), subsystem.begin(),
100 static_cast<int (*)(int)>(&std::tolower));
101
102 // if not sure, read this
103 // https://stackoverflow.com/questions/1878001/how-do-i-check-if-a-c-stdstring-starts-with-a-certain-string-and-convert-a
104 if (flag_name.rfind(subsystem, 0) == 0) { // pos=0 limits the search to the prefix
105 // s starts with prefix
106 return original_subsystem_name;
107 }
108 }
109
110 // flag prefix is not in list
111 return "";
112 }
113};
Definition DumpFlags_processor.h:11
void Init() override
Definition DumpFlags_processor.cc:27
void Process(const std::shared_ptr< const JEvent > &event) override
Definition DumpFlags_processor.cc:46
void Finish() override
Definition DumpFlags_processor.cc:59
Definition SpdlogMixin.h:14