ATLAS Offline Software
Loading...
Searching...
No Matches
TrigServicesHelper Class Reference

Helper class to call ITrigEventLoopMgr methods from Python. More...

Collaboration diagram for TrigServicesHelper:

Public Member Functions

 TrigServicesHelper ()=default
 ~TrigServicesHelper ()=default
bool prepareForStart (uint32_t run_number, const std::string &det_mask, const std::string &sor_time, uint32_t lb_number=0, uint32_t beam_type=0, uint32_t beam_energy=0, float toroids_current=20400.0f, float solenoid_current=7730.0f, const std::string &run_type="Physics", uint32_t trigger_type=0, bool recording_enabled=false, const std::string &event_loop_name="HltEventLoopMgr")
 Call prepareForStart on the HltEventLoopMgr.
bool prepareForRun (const std::string &event_loop_name="HltEventLoopMgr")
 Call prepareForRun on the HltEventLoopMgr.
bool hltUpdateAfterFork (int worker_id=1, int worker_pid=-1, const std::string &event_loop_name="HltEventLoopMgr")
 Call hltUpdateAfterFork on the HltEventLoopMgr.

Detailed Description

Helper class to call ITrigEventLoopMgr methods from Python.

Definition at line 88 of file TrigServicesHelper.cxx.

Constructor & Destructor Documentation

◆ TrigServicesHelper()

TrigServicesHelper::TrigServicesHelper ( )
default

◆ ~TrigServicesHelper()

TrigServicesHelper::~TrigServicesHelper ( )
default

Member Function Documentation

◆ hltUpdateAfterFork()

bool TrigServicesHelper::hltUpdateAfterFork ( int worker_id = 1,
int worker_pid = -1,
const std::string & event_loop_name = "HltEventLoopMgr" )
inline

Call hltUpdateAfterFork on the HltEventLoopMgr.

This initializes the scheduler and other components that need to be set up after forking. In athenaEF (without PSC), this should be called after prepareForRun() and before running the event loop.

Parameters
worker_idWorker ID (use 1 for single-process mode without forking)
worker_pidWorker PID (defaults to current process PID)
event_loop_nameName of the EventLoopMgr service
Returns
true on success, false on failure

Definition at line 209 of file TrigServicesHelper.cxx.

212 {
213 // Use current PID if not specified
214 if (worker_pid < 0) {
215 worker_pid = getpid();
216 }
217
218 // Get the service locator
219 ISvcLocator* svcLoc = Gaudi::svcLocator();
220 if (!svcLoc) {
221 std::cerr << "TrigServicesHelper: Failed to get ISvcLocator" << std::endl;
222 return false;
223 }
224
225 // Set DataFlow properties via JobOptionsSvc so updateDFProps() can read them
226 // HltEventLoopMgr::updateDFProps() reads from "DataFlowConfig.DF_*" properties
227 auto jobOptSvc = svcLoc->service<Gaudi::Interfaces::IOptionsSvc>("JobOptionsSvc");
228 if (!jobOptSvc) {
229 std::cerr << "TrigServicesHelper: Failed to get JobOptionsSvc" << std::endl;
230 return false;
231 }
232
233 // Set worker ID > 0 to avoid mother process behavior in stop()
234 jobOptSvc->set("DataFlowConfig.DF_WorkerId", std::to_string(worker_id));
235 jobOptSvc->set("DataFlowConfig.DF_Pid", std::to_string(worker_pid));
236 jobOptSvc->set("DataFlowConfig.DF_ApplicationName", "athenaEF");
237
238 std::cout << "TrigServicesHelper: Set DataFlowConfig properties (WorkerId="
239 << worker_id << ", Pid=" << worker_pid << ")" << std::endl;
240
241 // Build an empty ptree - the actual values are read from JobOptionsSvc
242 boost::property_tree::ptree pt;
243
244 // Get the EventLoopMgr service
245 auto evtLoopMgr = svcLoc->service<ITrigEventLoopMgr>(event_loop_name);
246 if (!evtLoopMgr) {
247 std::cerr << "TrigServicesHelper: Failed to retrieve ITrigEventLoopMgr '"
248 << event_loop_name << "'" << std::endl;
249 return false;
250 }
251
252 // Call hltUpdateAfterFork
253 std::cout << "TrigServicesHelper: Calling hltUpdateAfterFork on " << event_loop_name << std::endl;
254 StatusCode sc = evtLoopMgr->hltUpdateAfterFork(pt);
255
256 if (sc.isFailure()) {
257 std::cerr << "TrigServicesHelper: hltUpdateAfterFork failed" << std::endl;
258 return false;
259 }
260
261 std::cout << "TrigServicesHelper: hltUpdateAfterFork completed successfully" << std::endl;
262 return true;
263 }
static Double_t sc
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ prepareForRun()

bool TrigServicesHelper::prepareForRun ( const std::string & event_loop_name = "HltEventLoopMgr")
inline

Call prepareForRun on the HltEventLoopMgr.

This initializes the COOL folder helper and fires the BeginRun incident. It must be called after start() and before hltUpdateAfterFork().

Parameters
event_loop_nameName of the EventLoopMgr service
Returns
true on success, false on failure

Definition at line 164 of file TrigServicesHelper.cxx.

165 {
166 // Get the service locator
167 ISvcLocator* svcLoc = Gaudi::svcLocator();
168 if (!svcLoc) {
169 std::cerr << "TrigServicesHelper: Failed to get ISvcLocator" << std::endl;
170 return false;
171 }
172
173 // Get the EventLoopMgr service
174 auto evtLoopMgr = svcLoc->service<ITrigEventLoopMgr>(event_loop_name);
175 if (!evtLoopMgr) {
176 std::cerr << "TrigServicesHelper: Failed to retrieve ITrigEventLoopMgr '"
177 << event_loop_name << "'" << std::endl;
178 return false;
179 }
180
181 // Build an empty ptree (prepareForRun doesn't use it currently)
182 boost::property_tree::ptree pt;
183
184 // Call prepareForRun
185 std::cout << "TrigServicesHelper: Calling prepareForRun on " << event_loop_name << std::endl;
186 StatusCode sc ATLAS_THREAD_SAFE = evtLoopMgr->prepareForRun(pt);
187
188 if (sc.isFailure()) {
189 std::cerr << "TrigServicesHelper: prepareForRun failed" << std::endl;
190 return false;
191 }
192
193 std::cout << "TrigServicesHelper: prepareForRun completed successfully" << std::endl;
194 return true;
195 }
#define ATLAS_THREAD_SAFE

◆ prepareForStart()

bool TrigServicesHelper::prepareForStart ( uint32_t run_number,
const std::string & det_mask,
const std::string & sor_time,
uint32_t lb_number = 0,
uint32_t beam_type = 0,
uint32_t beam_energy = 0,
float toroids_current = 20400.0f,
float solenoid_current = 7730.0f,
const std::string & run_type = "Physics",
uint32_t trigger_type = 0,
bool recording_enabled = false,
const std::string & event_loop_name = "HltEventLoopMgr" )
inline

Call prepareForStart on the HltEventLoopMgr.

Parameters
run_numberRun number
det_maskDetector mask (32 hex chars)
sor_timeStart of run time string (format: "dd/mm/yy HH:MM:SS.ffffff")
lb_numberLumi block number
beam_typeBeam type
beam_energyBeam energy
toroids_currentToroids current (default 20400)
solenoid_currentSolenoid current (default 7730)
event_loop_nameName of the EventLoopMgr service
Returns
true on success, false on failure

Definition at line 107 of file TrigServicesHelper.cxx.

120 {
121 // Build the ptree directly
122 boost::property_tree::ptree pt = buildPrepareForStartPtree(
123 run_number, det_mask, sor_time, lb_number,
124 beam_type, beam_energy, toroids_current, solenoid_current,
125 run_type, trigger_type, recording_enabled);
126
127 // Get the service locator
128 ISvcLocator* svcLoc = Gaudi::svcLocator();
129 if (!svcLoc) {
130 std::cerr << "TrigServicesHelper: Failed to get ISvcLocator" << std::endl;
131 return false;
132 }
133
134 // Get the EventLoopMgr service (use template version that returns SmartIF directly)
135 auto evtLoopMgr = svcLoc->service<ITrigEventLoopMgr>(event_loop_name);
136 if (!evtLoopMgr) {
137 std::cerr << "TrigServicesHelper: Failed to retrieve ITrigEventLoopMgr '"
138 << event_loop_name << "'" << std::endl;
139 return false;
140 }
141
142 // Call prepareForStart
143 std::cout << "TrigServicesHelper: Calling prepareForStart on " << event_loop_name << std::endl;
144 StatusCode sc = evtLoopMgr->prepareForStart(pt);
145
146 if (sc.isFailure()) {
147 std::cerr << "TrigServicesHelper: prepareForStart failed" << std::endl;
148 return false;
149 }
150
151 std::cout << "TrigServicesHelper: prepareForStart completed successfully" << std::endl;
152 return true;
153 }

The documentation for this class was generated from the following file: