FACT++  1.0
template<class T , class S >
int StateMachineFTM< T, S >::EvalOptions ( Configuration conf)
inline

(4ns * x + 8ns)

(4ns * x + 8ns)

(4ns * x + 8ns)

(4ns * x + 8ns)

(4ns * x + 8ns)

Definition at line 2482 of file ftmctrl.cc.

References data, Error(), freq, Configuration::Get(), Configuration::GetDef(), Configuration::HasDef(), i, FTM::StaticData::kMaxPatchIdx, FTM::StaticData::kMaxPixelIdx, StaticData(), str, and Configuration::Vec().

2483  {
2484  // ---------- General setup ----------
2485  fFTM.SetVerbose(!conf.Get<bool>("quiet"));
2486  fFTM.SetHexOutput(conf.Get<bool>("hex-out"));
2487  fFTM.SetDynamicOut(conf.Get<bool>("dynamic-out"));
2488 
2489  // ---------- Setup clock conditioner frequencies ----------
2490  const vector<uint16_t> freq = conf.Vec<uint16_t>("clock-conditioner.frequency");
2491  if (freq.empty())
2492  T::Warn("No frequencies for the clock-conditioner defined.");
2493  else
2494  T::Message("Defining clock conditioner frequencies");
2495  for (vector<uint16_t>::const_iterator it=freq.begin();
2496  it!=freq.end(); it++)
2497  {
2498  if (fClockCondSetup.count(*it)>0)
2499  {
2500  T::Error("clock-conditioner frequency defined twice.");
2501  return 1;
2502  }
2503 
2504  if (!conf.HasDef("clock-conditioner.R0.", *it) ||
2505  !conf.HasDef("clock-conditioner.R1.", *it) ||
2506  !conf.HasDef("clock-conditioner.R8.", *it) ||
2507  !conf.HasDef("clock-conditioner.R9.", *it) ||
2508  !conf.HasDef("clock-conditioner.R11.", *it) ||
2509  !conf.HasDef("clock-conditioner.R13.", *it) ||
2510  !conf.HasDef("clock-conditioner.R14.", *it) ||
2511  !conf.HasDef("clock-conditioner.R15.", *it))
2512  {
2513  T::Error("clock-conditioner values incomplete.");
2514  return 1;
2515  }
2516 
2517  array<uint64_t, 8> &arr = fClockCondSetup[*it];
2518 
2519  arr[0] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R0.", *it);
2520  arr[1] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R1.", *it);
2521  arr[2] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R8.", *it);
2522  arr[3] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R9.", *it);
2523  arr[4] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R11.", *it);
2524  arr[5] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R13.", *it);
2525  arr[6] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R14.", *it);
2526  arr[7] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R15.", *it);
2527 
2528  ostringstream out;
2529  out << " -> " << setw(4) << *it << "MHz:" << hex << setfill('0');
2530  for (int i=0; i<8; i++)
2531  out << " " << setw(8) << arr[i];
2532  T::Message(out.str());
2533  }
2534 
2535  // ---------- Setup run types ---------
2536  const vector<string> types = conf.Vec<string>("run-type");
2537  if (types.empty())
2538  T::Warn("No run-types defined.");
2539  else
2540  T::Message("Defining run-types");
2541  for (vector<string>::const_iterator it=types.begin();
2542  it!=types.end(); it++)
2543  {
2544  T::Message(" -> "+ *it);
2545 
2546  if (fConfigs.count(*it)>0)
2547  {
2548  T::Error("Run-type "+*it+" defined twice.");
2549  return 2;
2550  }
2551 
2552  if (!conf.HasDef("sampling-frequency.", *it))
2553  {
2554  T::Error("Neither sampling-frequency."+*it+" nor sampling-frequency.default found.");
2555  return 2;
2556  }
2557 
2558  const uint16_t frq = conf.GetDef<uint16_t>("sampling-frequency.", *it);
2559 
2561  data.SetClockRegister(fClockCondSetup[frq].data());
2562 
2563  // Trigger sequence ped:lp1:lp2
2564  // (data. is used here as an abbreviation for FTM::StaticData::
2565  if (!CheckConfigVal<bool> (conf, true, "trigger.enable-trigger.", *it) ||
2566  !CheckConfigVal<bool> (conf, true, "trigger.enable-external-1.", *it) ||
2567  !CheckConfigVal<bool> (conf, true, "trigger.enable-external-2.", *it) ||
2568  !CheckConfigVal<bool> (conf, true, "trigger.enable-veto.", *it) ||
2569  !CheckConfigVal<bool> (conf, true, "trigger.enable-clock-conditioner.", *it) ||
2570  !CheckConfigVal<bool> (conf, true, "light-pulser.external.enable-group1.", *it) ||
2571  !CheckConfigVal<bool> (conf, true, "light-pulser.external.enable-group2.", *it) ||
2572  !CheckConfigVal<bool> (conf, true, "light-pulser.internal.enable-group1.", *it) ||
2573  !CheckConfigVal<bool> (conf, true, "light-pulser.internal.enable-group2.", *it) ||
2574  !CheckConfigVal<uint16_t>(conf, data.kMaxSequence, "trigger.sequence.pedestal.", *it) ||
2575  !CheckConfigVal<uint16_t>(conf, data.kMaxSequence, "trigger.sequence.lp-ext.", *it) ||
2576  !CheckConfigVal<uint16_t>(conf, data.kMaxSequence, "trigger.sequence.lp-int.", *it) ||
2577  !CheckConfigVal<uint16_t>(conf, data.kMaxTriggerInterval, "trigger.sequence.interval.", *it) ||
2578  !CheckConfigVal<uint16_t>(conf, data.kMaxMultiplicity, "trigger.multiplicity-physics.", *it) ||
2579  !CheckConfigVal<uint16_t>(conf, data.kMaxMultiplicity, "trigger.multiplicity-calib.", *it) ||
2580  !CheckConfigVal<uint16_t>(conf, data.kMaxWindow, "trigger.coincidence-window-physics.", *it) ||
2581  !CheckConfigVal<uint16_t>(conf, data.kMaxWindow, "trigger.coincidence-window-calib.", *it) ||
2582  !CheckConfigVal<uint16_t>(conf, data.kMaxDeadTime, "trigger.dead-time.", *it) ||
2583  !CheckConfigVal<uint16_t>(conf, data.kMaxDelayTrigger, "trigger.delay.", *it) ||
2584  !CheckConfigVal<uint16_t>(conf, data.kMaxDelayTimeMarker, "trigger.time-marker-delay.", *it) ||
2585  !CheckConfigVal<uint16_t>(conf, 0xffff, "ftu-report-interval.", *it) ||
2586  !CheckConfigVal<uint16_t>(conf, data.kMaxIntensity, "light-pulser.external.intensity.", *it) ||
2587  !CheckConfigVal<uint16_t>(conf, data.kMaxIntensity, "light-pulser.internal.intensity.", *it) ||
2588  !CheckConfigVal<uint16_t>(conf, data.kMaxDAC, "trigger.threshold.patch.", *it) ||
2589  !CheckConfigVal<uint16_t>(conf, data.kMaxDAC, "trigger.threshold.logic.", *it) ||
2590  0)
2591  return 2;
2592 
2593  data.Enable(data.kTrigger, conf.GetDef<bool>("trigger.enable-trigger.", *it));
2594  data.Enable(data.kExt1, conf.GetDef<bool>("trigger.enable-external-1.", *it));
2595  data.Enable(data.kExt2, conf.GetDef<bool>("trigger.enable-external-2.", *it));
2596  data.Enable(data.kVeto, conf.GetDef<bool>("trigger.enable-veto.", *it));
2597  data.Enable(data.kClockConditioner, conf.GetDef<bool>("trigger.enable-clock-conditioner.", *it));
2598 
2599  data.EnableLPint(data.kGroup1, conf.GetDef<bool>("light-pulser.internal.enable-group1.", *it));
2600  data.EnableLPint(data.kGroup2, conf.GetDef<bool>("light-pulser.internal.enable-group2.", *it));
2601  data.EnableLPext(data.kGroup1, conf.GetDef<bool>("light-pulser.external.enable-group1.", *it));
2602  data.EnableLPext(data.kGroup2, conf.GetDef<bool>("light-pulser.external.enable-group2.", *it));
2603 
2604  // [ms] Interval between two artificial triggers (no matter which type) minimum 1ms, 10 bit
2605  data.fIntensityLPint = conf.GetDef<uint16_t>("light-pulser.internal.intensity.", *it);
2606  data.fIntensityLPext = conf.GetDef<uint16_t>("light-pulser.external.intensity.", *it);
2607  data.fTriggerInterval = conf.GetDef<uint16_t>("trigger.sequence.interval.", *it);
2608  data.fMultiplicityPhysics = conf.GetDef<uint16_t>("trigger.multiplicity-physics.", *it);
2609  data.fMultiplicityCalib = conf.GetDef<uint16_t>("trigger.multiplicity-calib.", *it);
2610  data.fWindowPhysics = conf.GetDef<uint16_t>("trigger.coincidence-window-physics.", *it);
2611  data.fWindowCalib = conf.GetDef<uint16_t>("trigger.coincidence-window-calib.", *it);
2612  data.fDelayTrigger = conf.GetDef<uint16_t>("trigger.delay.", *it);
2613  data.fDelayTimeMarker = conf.GetDef<uint16_t>("trigger.time-marker-delay.", *it);
2614  data.fDeadTime = conf.GetDef<uint16_t>("trigger.dead-time.", *it);
2615 
2616  data.SetPrescaling(conf.GetDef<uint16_t>("ftu-report-interval.", *it));
2617 
2618  const uint16_t seqped = conf.GetDef<uint16_t>("trigger.sequence.pedestal.", *it);
2619  const uint16_t seqint = conf.GetDef<uint16_t>("trigger.sequence.lp-int.", *it);
2620  const uint16_t seqext = conf.GetDef<uint16_t>("trigger.sequence.lp-ext.", *it);
2621 
2622  data.SetSequence(seqped, seqint, seqext);
2623 
2624  data.EnableAllFTU();
2625  data.EnableAllPixel();
2626 
2627  const vector<uint16_t> pat1 = conf.Vec<uint16_t>("trigger.disable-patch.default");
2628  const vector<uint16_t> pat2 = conf.Vec<uint16_t>("trigger.disable-patch."+*it);
2629 
2630  const vector<uint16_t> pix1 = conf.Vec<uint16_t>("trigger.disable-pixel.default");
2631  const vector<uint16_t> pix2 = conf.Vec<uint16_t>("trigger.disable-pixel."+*it);
2632 
2633  const vector<uint16_t> ftu1 = conf.Vec<uint16_t>("disable-ftu.default");
2634  const vector<uint16_t> ftu2 = conf.Vec<uint16_t>("disable-ftu."+*it);
2635 
2636  vector<uint16_t> ftu, pat, pix;
2637  ftu.insert(ftu.end(), ftu1.begin(), ftu1.end());
2638  ftu.insert(ftu.end(), ftu2.begin(), ftu2.end());
2639  pat.insert(pat.end(), pat1.begin(), pat1.end());
2640  pat.insert(pat.end(), pat2.begin(), pat2.end());
2641  pix.insert(pix.end(), pix1.begin(), pix1.end());
2642  pix.insert(pix.end(), pix2.begin(), pix2.end());
2643 
2644  for (vector<uint16_t>::const_iterator ip=ftu.begin(); ip!=ftu.end(); ip++)
2645  {
2647  {
2648  ostringstream str;
2649  str << "disable-ftu.*=" << *ip << " exceeds allowed maximum of " << FTM::StaticData::kMaxPatchIdx << "!";
2650  T::Error(str);
2651  return 2;
2652  }
2653  data.DisableFTU(*ip);
2654  }
2655  for (vector<uint16_t>::const_iterator ip=pat.begin(); ip!=pat.end(); ip++)
2656  {
2658  {
2659  ostringstream str;
2660  str << "trigger.disable-patch.*=" << *ip << " exceeds allowed maximum of " << FTM::StaticData::kMaxPatchIdx << "!";
2661  T::Error(str);
2662  return 2;
2663  }
2664  data.EnablePatch(*ip, false);
2665  }
2666  for (vector<uint16_t>::const_iterator ip=pix.begin(); ip!=pix.end(); ip++)
2667  {
2669  {
2670  ostringstream str;
2671  str << "trigger.disable-pixel.*=" << *ip << " exceeds allowed maximum of " << FTM::StaticData::kMaxPixelIdx << "!";
2672  T::Error(str);
2673  return 2;
2674  }
2675  data.EnablePixel(*ip, false);
2676  }
2677 
2678  const uint16_t th0 = conf.GetDef<uint16_t>("trigger.threshold.patch.", *it);
2679  const uint16_t th1 = conf.GetDef<uint16_t>("trigger.threshold.logic.", *it);
2680 
2681  for (int i=0; i<40; i++)
2682  {
2683  data[i].fDAC[0] = th0;
2684  data[i].fDAC[1] = th0;
2685  data[i].fDAC[2] = th0;
2686  data[i].fDAC[3] = th0;
2687  data[i].fDAC[4] = th1;
2688  }
2689 
2690  fConfigs[*it] = data;
2691 
2692  // trigger.threshold.dac-0:
2693 
2694  /*
2695  threshold-A data[n].fDAC[0] = val
2696  threshold-B data[n].fDAC[1] = val
2697  threshold-C data[n].fDAC[2] = val
2698  threshold-D data[n].fDAC[3] = val
2699  threshold-H data[n].fDAC[4] = val
2700  */
2701 
2702  // kMaxDAC = 0xfff,
2703  }
2704 
2705  // FIXME: Add a check about unsused configurations
2706 
2707  // ---------- FOR TESTING PURPOSE ---------
2708 
2709  // fFTM.SetDefaultSetup(conf.Get<string>("default-setup"));
2710  fConfigs["test"] = FTM::StaticData();
2711 
2712  // ---------- Setup connection endpoint ---------
2713  SetEndpoint(conf.Get<string>("addr"));
2714 
2715  return -1;
2716  }
int i
Definition: db_dim_client.c:21
char str[80]
Definition: test_client.c:7
T Get(const std::string &var)
void SetEndpoint(const string &url)
Definition: ftmctrl.cc:2454
std::vector< T > Vec(const std::string &var)
Configs fConfigs
Definition: ftmctrl.cc:2011
T GetDef(const std::string &var, const S &val)
float data[4 *1440]
StaticData()
Definition: HeadersFTM.h:245
Error()
Definition: HeadersFTM.h:197
bool HasDef(const std::string &var, const T &val)
map< uint16_t, array< uint64_t, 8 > > fClockCondSetup
Definition: ftmctrl.cc:2459
uint32_t freq
Definition: HeadersSQM.h:90

+ Here is the call graph for this function: