otsdaq-mu2e-stm  5.02.01
prescale_config.hh
1 #ifndef PRESCALE_CONFIG_HH_
2 #define PRESCALE_CONFIG_HH_
3 
4 // Include config files
5 #include "Mu2e-STMDAQ/config/config.hh"
6 
7 // Spill prescale struct
8 struct spill_t {
9  const int prescale; // Prescale value
10  const int consecutive; // Consecutive events to store
11  const int eff_prescale; // Effective prescale
12  spill_t(int p, int c) :
13  prescale(p), consecutive(c), eff_prescale(c*p) {} // Constructor
14 };
15 
16 // Prescale struct
17 struct prescale_t {
18 
19  // Declare on-spill / off-spill structs
20  const spill_t on_spill;
21  const spill_t off_spill;
22 
23  // Prescale struct constructor
24  prescale_t(int on_p, int on_c, int off_p, int off_c)
25  : on_spill(on_p, on_c), off_spill(off_p, off_c) {}
26 };
27 
28 
29 // Prescale configurable variables
31 
32  // Raw prescale struct
33  const prescale_t raw;
34  // ZS prescale struct
35  const prescale_t zs;
36  // Raw and prescale structs paired together
37  const std::array<std::reference_wrapper<const prescale_t>, 2> prescales;
38 
39  // Constructor
40  prescale_info(Config& cfg,
41  const std::shared_ptr<AsyncLogger> logger):
42  raw(cfg.getValue<int>("stm.prescale.raw.on_spill.prescale_num"),
43  cfg.getValue<int>("stm.prescale.raw.on_spill.store_consecutive"),
44  cfg.getValue<int>("stm.prescale.raw.off_spill.prescale_num"),
45  cfg.getValue<int>("stm.prescale.raw.off_spill.store_consecutive")),
46  zs(cfg.getValue<int>("stm.prescale.zs.on_spill.prescale_num"),
47  cfg.getValue<int>("stm.prescale.zs.on_spill.store_consecutive"),
48  cfg.getValue<int>("stm.prescale.zs.off_spill.prescale_num"),
49  cfg.getValue<int>("stm.prescale.zs.off_spill.store_consecutive")),
50  prescales({raw,zs})
51  {
52 
53  // Notify user
54  if (logger){
55  logger->log("Config:prescale_info: Raw on-spill prescale = " +
56  std::to_string(raw.on_spill.prescale) +
57  ". Storing " +
58  std::to_string(raw.on_spill.consecutive) +
59  " consecutive events. Effective prescale = " +
60  std::to_string(raw.on_spill.eff_prescale) +
61  ".",1);
62  logger->log("Config:prescale_info: Raw off-spill prescale = " +
63  std::to_string(raw.off_spill.prescale) +
64  ". Storing " +
65  std::to_string(raw.off_spill.consecutive) +
66  " consecutive events. Effective prescale = " +
67  std::to_string(raw.off_spill.eff_prescale) +
68  ".",1);
69  logger->log("Config:prescale_info: ZS on-spill prescale = " +
70  std::to_string(zs.on_spill.prescale) +
71  ". Storing " +
72  std::to_string(zs.on_spill.consecutive) +
73  " consecutive events. Effective prescale = " +
74  std::to_string(zs.on_spill.eff_prescale) +
75  ".",1);
76  logger->log("Config:prescale_info: ZS off-spill prescale = " +
77  std::to_string(zs.off_spill.prescale) +
78  ". Storing " +
79  std::to_string(zs.off_spill.consecutive) +
80  " consecutive events. Effective prescale = " +
81  std::to_string(zs.off_spill.eff_prescale) +
82  ".",1);
83 
84  }
85 
86  }
87 
88 };
89 
90 #endif
Definition: config.hh:19