All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TriggerConfiguration.cxx
Go to the documentation of this file.
1 /**
2  * @file icaruscode/Decode/DataProducts/TriggerConfiguration.cxx
3  * @brief Information from the configuration of a Trigger readout board.
4  * @author Andrea Scarpelli (ascarpell@bnl.gov)
5  * @date March 23, 2022
6  * @see icaruscode/Decode/DataProducts/TriggerConfiguration.h
7  */
8 
9 // library header
11 
12 // C/C++ standard libraries
13 #include <ostream>
14 #include <cassert>
15 
16 
17 //------------------------------------------------------------------------------
19 
20 //------------------------------------------------------------------------------
22  (std::ostream& out, icarus::TriggerConfiguration::GateConfig const& gateConfig, std::string const& indent) const
23 {
24  out << std::boolalpha
25  << indent << "Gate Active: " << gateConfig.hasGate << "\n";
26  if (gateConfig.hasGate) {
27 
28  // gates
29  out
30  << indent << "Drift gate Active: " << gateConfig.hasDriftGate << "\n"
31  << indent << "MinBias Gate Active: " << gateConfig.hasMinBiasGate << "\n"
32  ;
33  if (gateConfig.hasMinBiasGate)
34  out << indent << "MinBias Drift Gate Active: " << gateConfig.hasMinBiasDriftGate << "\n";
35  else if (gateConfig.hasMinBiasDriftGate)
36  out << indent << "MinBias Drift Gate Active: " << gateConfig.hasMinBiasDriftGate << " (ignored)\n";
37 
38  // gate durations and offsets
39  out << indent << "BeamWidth: " << (gateConfig.gateWidth - vetoDelay) << " ns";
40  if (vetoDelay != 0)
41  out << " (plus the veto of " << vetoDelay << " ns)";
42  out << "\n";
43  if (gateConfig.hasDriftGate)
44  out << indent << "EnableWidth: " << gateConfig.driftGateWidth << " ns\n";
45  out << indent << "EarlyWarningOffset: " << gateConfig.earlyWarningOffset << " ns\n";
46  if (gateConfig.hasDriftGate)
47  out << indent << "EarlyEarlyWarningOffset: " << gateConfig.earlyEarlyWarningOffset << " ns\n";
48 
49  if (gateConfig.hasMinBiasGate)
50  out << indent << "MinBias PreScale: " << gateConfig.prescaleMinBias << "\n";
51  }
52  else {
53 
54  if (gateConfig.hasDriftGate)
55  out << indent << "Drift gate Active: " << gateConfig.hasDriftGate << " (ignored)\n";
56  if (gateConfig.hasMinBiasGate)
57  out << indent << "MinBias Gate Active: " << gateConfig.hasMinBiasGate << " (ignored)\n";
58  if (gateConfig.hasMinBiasDriftGate)
59  out << indent << "MinBias Drift Gate Active: " << gateConfig.hasMinBiasDriftGate << " (ignored)\n";
60 
61  }
62 
63  out << std::noboolalpha;
64 }
65 
66 
67 //------------------------------------------------------------------------------
68 void icarus::TriggerConfiguration::dump(std::ostream& out,
69  std::string const& indent, std::string const& firstIndent,
70  unsigned int verbosity /* = MaxDumpVerbosity */
71 ) const{
72 
73  do {
74  // fake look for easy break: `goto` in disguise;
75  // `break` will add a final `'\n'`, `return` will not.
76 
77  // start a new line with indentation:
78  auto const outnl
79  = [&out,&indent]() -> std::ostream& { return out << '\n' << indent; };
80 
81  unsigned int level = 0U;
82 
83 
84  // --- verbosity: 0+ -------------------------------------------------------
85  out << firstIndent
86  << "Basic trigger configuration:";
87  outnl() << " Use WR time: " << std::boolalpha << useWrTime << std::noboolalpha;
88  outnl() << " WR time offset: " << wrTimeOffset << " ns";
89 
90  if (++level > verbosity) break;
91  // --- verbosity: 1+ -------------------------------------------------------
92 
93  auto printWindowMode = [&out](unsigned int slidingWindow){
94  switch (slidingWindow) {
95  case 0: out << "fixed"; break;
96  case 1: out << "sliding"; break;
97  default: out << "unknown";
98  } // switch
99  out << " (" << slidingWindow << ")";
100  };
101 
102  outnl() << "FPGA Configuration:";
103  outnl() << " Veto Delay: " << vetoDelay << " ns";
104  outnl() << " MajLevelBeamCryoEAST: " << cryoConfig[icarus::trigger::kEast].majLevelInTime;
105  outnl() << " MajLevelEnableCryoEAST: " << cryoConfig[icarus::trigger::kEast].majLevelDrift;
106  outnl() << " WindowCryoEAST: ";
107  printWindowMode(cryoConfig[icarus::trigger::kEast].slidingWindow);
108  outnl() << " MajLevelBeamCryoWEST: " << cryoConfig[icarus::trigger::kWest].majLevelInTime;
109  outnl() << " MajLevelEnableCryoWEST: " << cryoConfig[icarus::trigger::kWest].majLevelDrift;
110  outnl() << " WindowCryoWEST: ";
111  printWindowMode(cryoConfig[icarus::trigger::kWest].slidingWindow);
112  outnl() << " MajorityTriggerType: '" << majorityTriggerType << "'";
113  outnl() << " RunType: '" << runType << "'";
114 
115  out << "\n";
116 
117  if (++level > verbosity) return;
118  // --- verbosity: 2+ -------------------------------------------------------
119 
120  out << indent // absorb the newline from the previous level
121  << "SPEXI Configuration:\n";
122 
123  out << indent << " TPCTriggerDelay: " << (tpcTriggerDelay * 0.0004) << " ms ("
124  << tpcTriggerDelay << " x 400 ns)\n";
125 
126  out << indent << " BNB:\n";
127  dumpGateConfig( out, gateConfig[icarus::trigger::kBNB], indent+" - " );
128 
129  out << indent << " NuMI:\n";
130  dumpGateConfig( out, gateConfig[icarus::trigger::kNuMI], indent+" - " );
131 
132  out << indent << " Offbeam BNB:\n";
133  dumpGateConfig( out, gateConfig[icarus::trigger::kOffBeamBNB], indent + " - " );
134 
135  out << indent << " Offbeam NuMI:\n";
136  dumpGateConfig(out, gateConfig[icarus::trigger::kOffBeamNuMI], indent + " - " );
137 
138 
139  out << indent << " Calibration:\n";
140  dumpGateConfig(out, gateConfig[icarus::trigger::kCalibration], indent + " - ");
141  if (gateConfig[icarus::trigger::kCalibration].hasGate) {
142  out << indent << " - " << "Period: " << gateConfig[icarus::trigger::kCalibration].period << " ns\n";
143  }
144 
145  if (++level > verbosity) break;
146  // --- verbosity: 3+ -------------------------------------------------------
147 
148  assert(level == MaxDumpVerbosity + 1U);
149 
150  // this is more debug information than anything else: verbosity was too high
151  outnl() << "No more information available (reached level " << level << ").";
152 
153  } while(false);
154 
155  out << "\n";
156 
157 } // icarus::TriggerConfiguration::dump()
std::string runType
Force the run to be fully a MinBias, if runType==&quot;MinBias&quot;. If runType==&quot;Majority&quot; does a majority ru...
bool hasDriftGate
Return drift gate activation status (for out-of-time light)
static constexpr std::size_t kOffBeamNuMI
Definition: BeamBits.h:370
static constexpr std::size_t kWest
Definition: BeamBits.h:364
std::array< CryoConfig, icarus::trigger::kNTriggerLocation > cryoConfig
Cryostat configuration.
static constexpr std::size_t kBNB
Definition: BeamBits.h:367
Information from the configuration of the ICARUS trigger readout.
void dumpGateConfig(std::ostream &out, icarus::TriggerConfiguration::GateConfig const &gateConfig, std::string const &indent) const
Dumps the content of the gate configuration into out stream.
static constexpr std::size_t kCalibration
Definition: BeamBits.h:371
unsigned int period
Period of two consecutive pulses from the internal pulse generator (valid for calibration gate) in ns...
unsigned int wrTimeOffset
Add an offset between the npt and tai time as used in the wr reference (normally it is 1 or 2 leap se...
static constexpr std::size_t kNuMI
Definition: BeamBits.h:368
bool hasMinBiasGate
Return MinBias triggers activation status.
static constexpr std::size_t kOffBeamBNB
Definition: BeamBits.h:369
unsigned long prescaleMinBias
Prescale for the MinBias triggers (calculated with respect to the number of gates opened) ...
void dump(std::ostream &out, std::string const &indent, std::string const &firstIndent, unsigned int verbosity=MaxDumpVerbosity) const
Dumps the content of the configuration into out stream.
bool useWrTime
Use the WR time reference.
unsigned int tpcTriggerDelay
TPCTriggerDelay: distance between the Global trigger time and the output for the TPC. NB: It is in units of 400 ns.
bool hasMinBiasDriftGate
Return MinBias drift gate activation status (for out-of-time light)
unsigned int vetoDelay
Veto (this delay has to be subtracted to the gate width ). Value is in ns.
static constexpr std::size_t kEast
Definition: BeamBits.h:363
unsigned int gateWidth
Duration of the gate for the in-time activity in ns.
static constexpr unsigned int MaxDumpVerbosity
Maximum supported verbosity level supported by dump().
static constexpr unsigned int DefaultDumpVerbosity
Default verbosity level for dump().
unsigned long earlyEarlyWarningOffset
Early Early warning offset for the BNB (NuMI) $1D ($AE) in ns; used for the drift gate...
unsigned long earlyWarningOffset
Early warning offset for the BNB (NuMI) GatedBES ($MIBS74) in ns; used for the beam gate...
unsigned int driftGateWidth
Duration of the drift gate for the out-of-time activity in ns.
std::string majorityTriggerType
Majority trigger type (consider triggers from one cryostats, either cryostats, or both cryostats) ...