File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -461,6 +461,8 @@ namespace clas12 {
461
461
_event.getStructure (*ibank.get ());
462
462
}
463
463
464
+ // call user's custom read action
465
+ _readEventUserAction (this );
464
466
465
467
return true ;
466
468
}
Original file line number Diff line number Diff line change 44
44
#include < vector>
45
45
#include < string>
46
46
#include < iostream>
47
+ #include < functional>
47
48
48
49
#ifdef RCDB_MYSQL
49
50
#include " rcdb_reader.h"
@@ -257,6 +258,13 @@ namespace clas12 {
257
258
_verbose=level;
258
259
_reader.setVerbose (level);
259
260
}
261
+
262
+ // Set a "read action", a custom lambda function which is executed for every event within `readEvent()`.
263
+ // The lambda argument is a pointer to an instance of this `clas12reader` class
264
+ void SetReadAction (std::function<void (clas12reader*)> readEventUserAction) {
265
+ _readEventUserAction = readEventUserAction;
266
+ }
267
+
260
268
261
269
protected:
262
270
@@ -345,7 +353,10 @@ namespace clas12 {
345
353
bool _useFTBased{false };
346
354
bool _isOpen{false };
347
355
std::vector<std::string> _addBankNames;
348
-
356
+
357
+ // user-definable lambda, called in `readEvent()`
358
+ std::function<void (clas12reader*)> _readEventUserAction = [](clas12reader* r) {};
359
+
349
360
// /////////////////////////////DB
350
361
private:
351
362
int _runNo{0 };
Original file line number Diff line number Diff line change
1
+ // iguana user code
2
+ clas12reader reader;
3
+ iguana::algorithm algo;
4
+ algo.Start();
5
+ auto bank3 = algo.CreateBank(" new::bank" );
6
+ auto read_action = [&algo, &bank3](clas12reader* CR) {
7
+ algo.Run (
8
+ *CR->bank1 (),
9
+ *CR->bank2 (),
10
+ bank3
11
+ );
12
+ }
13
+ reader.SetReadAction(read_action);
14
+
15
+ // FIXME
16
+ // FIXME: handle hipo::bank::rowlist iteration
17
+ // FIXME
You can’t perform that action at this time.
0 commit comments