Warning, file /jana2/src/plugins/janacontrol/JControlEventProcessor.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005 #include "JControlEventProcessor.h"
0006 #include <JANA/JLogger.h>
0007
0008
0009
0010
0011
0012 JControlEventProcessor::JControlEventProcessor():jstringification(new JStringification) {
0013 SetTypeName(NAME_OF_THIS);
0014 }
0015
0016
0017
0018
0019 void JControlEventProcessor::Init() {
0020 LOG << "JControlEventProcessor::Init" << LOG_END;
0021
0022 GetApplication()->GetJParameterManager()->SetDefaultParameter("jana:debug_mode", _debug_mode, "Turn on JANA debug mode for janacontrol plugin. (Will require jana-control.py GUI to step through events)");
0023 }
0024
0025
0026
0027
0028 void JControlEventProcessor::Process(const std::shared_ptr<const JEvent> &event) {
0029
0030
0031 if( _debug_mode ){
0032
0033
0034 static std::mutex mtx;
0035 std::lock_guard<std::mutex> lck(mtx);
0036
0037
0038
0039 _jevent = event;
0040
0041 while(_wait && _debug_mode){
0042 std::chrono::milliseconds wait_time {100};
0043 std::this_thread::sleep_for(wait_time);
0044 }
0045 _wait=true;
0046
0047
0048 _jevent.reset();
0049 }
0050
0051 if( _fetch_flag ) FetchObjects( event );
0052 }
0053
0054
0055
0056
0057 void JControlEventProcessor::Finish() {
0058
0059 LOG << "JControlEventProcessor::Finish" << LOG_END;
0060 }
0061
0062
0063
0064
0065 void JControlEventProcessor::SetDebugMode(bool debug_mode){
0066 _debug_mode = debug_mode;
0067 GetApplication()->SetTimeoutEnabled( !_debug_mode );
0068 }
0069
0070
0071
0072
0073 void JControlEventProcessor::NextEvent(void){
0074 _wait = false;
0075 }
0076
0077
0078
0079
0080
0081
0082
0083 void JControlEventProcessor::GetObjectStatus( std::map<JFactorySummary, std::size_t> &factory_object_counts ){
0084
0085
0086 if(_jevent.get() == nullptr ) return;
0087
0088
0089
0090
0091
0092 auto factories = _jevent->GetAllFactories();
0093 for( auto fac : factories ){
0094 JFactorySummary fac_info;
0095 fac_info.plugin_name = fac->GetPluginName();
0096 fac_info.factory_name = fac->GetFactoryName();
0097 fac_info.factory_tag = fac->GetTag();
0098 fac_info.object_name = fac->GetObjectName();
0099 if(fac_info.factory_name == "") fac_info.factory_name = "JFactoryT<" + fac_info.object_name + ">";
0100 if( fac ) factory_object_counts[fac_info] = fac->GetNumObjects();
0101 }
0102 }
0103
0104
0105
0106
0107
0108
0109 void JControlEventProcessor::GetObjects(const std::string &, const std::string &factory_tag, const std::string &object_name, std::map<std::string, JObjectSummary> &objects){
0110
0111 if(_jevent.get() == nullptr ) return;
0112
0113 jstringification->GetObjectSummaries(objects, _jevent, object_name, factory_tag);
0114 }
0115
0116
0117
0118
0119
0120
0121
0122 void JControlEventProcessor::SetFetchFactories(std::set<std::string> &factorytags){
0123
0124 _fetch_object_summaries.clear();
0125 _fetch_metadata.clear();
0126 _fetch_factorytags = factorytags;
0127 _fetch_flag = true;
0128 }
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140 void JControlEventProcessor::FetchObjects(std::shared_ptr<const JEvent> jevent){
0141
0142 _fetch_object_summaries.clear();
0143 _fetch_metadata.clear();
0144
0145 _fetch_metadata["run_number"] = ToString( GetRunNumber());
0146 _fetch_metadata["event_number"] = ToString( GetEventNumber());
0147
0148
0149 for( const auto& factorytag : _fetch_factorytags){
0150
0151 auto &objects = _fetch_object_summaries[factorytag];
0152
0153
0154 auto pos = factorytag.find(":");
0155 std::string factory_name = factorytag.substr(0, pos);
0156 std::string tag = (pos==std::string::npos ? "":factorytag.substr(pos+1));
0157
0158 jstringification->GetObjectSummaries(objects, jevent, factory_name, tag);
0159 }
0160
0161
0162 _fetch_flag = false;
0163 }
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176 void JControlEventProcessor::FetchObjectsNow(void){
0177
0178 if(_jevent.get() == nullptr ) return;
0179
0180 FetchObjects( _jevent );
0181 }
0182
0183
0184
0185
0186 uint32_t JControlEventProcessor::GetRunNumber(void){
0187 if(_jevent.get() == nullptr ) return 0;
0188 return _jevent->GetRunNumber();
0189 }
0190
0191
0192
0193
0194 uint64_t JControlEventProcessor::GetEventNumber(void){
0195 if(_jevent.get() == nullptr ) return 0;
0196 return _jevent->GetEventNumber();
0197 }