Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 08:35:33

0001 #pragma once
0002 
0003 #include <JANA/JEvent.h>
0004 #include <JANA/JEventProcessor.h>
0005 #include <algorithm>
0006 #include <cctype>
0007 #include <memory>
0008 #include <string>
0009 #include <vector>
0010 
0011 #include "extensions/spdlog/SpdlogMixin.h"
0012 
0013 class DumpFlags_processor : public JEventProcessor, public eicrecon::SpdlogMixin {
0014 public:
0015   //----------------------------
0016   // Init
0017   //
0018   // This is called once before the first call to the Process method
0019   // below. You may, for example, want to open an output file here.
0020   // Only one thread will call this.
0021   void Init() override;
0022 
0023   //----------------------------
0024   // Process
0025   //
0026   // This is called for every event. Multiple threads may call this
0027   // simultaneously. If you write something to an output file here
0028   // then make sure to protect it with a mutex or similar mechanism.
0029   // Minimize what is done while locked since that directly affects
0030   // the multi-threaded performance.
0031   void Process(const std::shared_ptr<const JEvent>& event) override;
0032 
0033   //----------------------------
0034   // Finish
0035   //
0036   // This is called once after all events have been processed. You may,
0037   // for example, want to close an output file here.
0038   // Only one thread will call this.
0039   void Finish() override;
0040 
0041 private:
0042   /// If not empty, a python eicrecon run file is created
0043   std::string m_python_file_name = "";
0044 
0045   /// If not null, such markdown file is created
0046   std::string m_markdown_file_name = "";
0047 
0048   /// If not null, such json file is created
0049   std::string m_json_file_name = "";
0050 
0051   /// If not null, such jana configuration file is created
0052   std::string m_janaconfig_file_name = "jana.conf";
0053 
0054   /// Print parameter summary to screen at end of job
0055   bool m_print_to_screen = true;
0056 
0057   /// Prefixes of flags that belongs to reconstruction parameters
0058   std::vector<std::string> m_reco_prefixes = {
0059       "B0TRK", "BEMC",  "DRICH", "BTRK", "BVTX",     "ECTRK", "EEMC", "FOFFMTRK",   "HCAL",
0060       "MPGD",  "RPOTS", "LOWQ2", "ZDC",  "Tracking", "Reco",  "Digi", "Calorimetry"};
0061 
0062   /// Checks if flags starts with one of m_reco_prefixes
0063   bool isReconstructionFlag(
0064       std::string
0065           flag_name) { // (!) copy value is important here! don't do const& NOLINT(performance-unnecessary-value-param)
0066 
0067     // convert flag_name to lower
0068     std::transform(flag_name.begin(), flag_name.end(), flag_name.begin(),
0069                    static_cast<int (*)(int)>(&std::tolower));
0070 
0071     for (auto subsystem : m_reco_prefixes) { // (!) copy value is important here! don't do auto&
0072 
0073       // Convert subsystem to lower
0074       std::transform(subsystem.begin(), subsystem.end(), subsystem.begin(),
0075                      static_cast<int (*)(int)>(&std::tolower));
0076 
0077       // if not sure, read this
0078       // https://stackoverflow.com/questions/1878001/how-do-i-check-if-a-c-stdstring-starts-with-a-certain-string-and-convert-a
0079       if (flag_name.rfind(subsystem, 0) == 0) { // pos=0 limits the search to the prefix
0080         // s starts with prefix
0081         return true;
0082       }
0083     }
0084 
0085     // flag prefix is not in list
0086     return false;
0087   }
0088 
0089   std::string findCategory(
0090       std::string
0091           flag_name) { // (!) copy value is important here! don't do const& NOLINT(performance-unnecessary-value-param)
0092 
0093     // convert flag_name to lower
0094     std::transform(flag_name.begin(), flag_name.end(), flag_name.begin(),
0095                    static_cast<int (*)(int)>(&std::tolower));
0096 
0097     for (auto subsystem : m_reco_prefixes) { // (!) copy value is important here! don't do auto&
0098 
0099       // Convert subsystem to lower
0100       std::string original_subsystem_name = subsystem;
0101       std::transform(subsystem.begin(), subsystem.end(), subsystem.begin(),
0102                      static_cast<int (*)(int)>(&std::tolower));
0103 
0104       // if not sure, read this
0105       // https://stackoverflow.com/questions/1878001/how-do-i-check-if-a-c-stdstring-starts-with-a-certain-string-and-convert-a
0106       if (flag_name.rfind(subsystem, 0) == 0) { // pos=0 limits the search to the prefix
0107         // s starts with prefix
0108         return original_subsystem_name;
0109       }
0110     }
0111 
0112     // flag prefix is not in list
0113     return "";
0114   }
0115 };