- Timestamp:
- 07/11/11 16:05:28 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ftmctrl.cc
r11338 r11344 722 722 return true; 723 723 724 for (int i=0; i<40; i++) 725 data[i].fPrescaling = value; 724 data.SetPrescaling(value); 726 725 727 726 // Maybe move to a "COMMIT" command? … … 837 836 FTM::StaticData data(fStaticData); 838 837 839 data.Enable(FTM::StaticData::kPedestal, d[0]>0); 840 data.Enable(FTM::StaticData::kLPext, d[1]>0); 841 data.Enable(FTM::StaticData::kLPint, d[2]>0); 842 843 data.fTriggerSequence = 844 (uint16_t(d[0])<<10) | (uint16_t(d[2])<<5) | uint16_t(d[1]); 838 /* 839 data.Enable(FTM::StaticData::kPedestal, d[0]>0); 840 data.Enable(FTM::StaticData::kLPext, d[1]>0); 841 data.Enable(FTM::StaticData::kLPint, d[2]>0); 842 */ 843 844 data.SetSequence(d[0], d[2], d[1]); 845 845 846 846 //if (fStaticData.fTriggerSeq !=data.fTriggerSequence || … … 926 926 927 927 for (int i=0; i<8; i++) 928 {929 928 if (reg[i]>0xffffffff) 930 929 return false; 931 930 932 data.fClockConditioner[i] = reg[i]; 933 } 931 data.SetClockRegister(reg); 934 932 935 933 CmdSendStatDat(data); … … 1966 1964 1967 1965 map<uint16_t, boost::array<uint64_t, 8>> fClockCondSetup; 1966 1967 template<class V> 1968 bool CheckConfigVal(const Configuration &conf, V max, const string &name, const string &sub) 1969 { 1970 if (!conf.HasDef(name, sub)) 1971 { 1972 T::Error("Neither "+name+"default nor "+name+sub+" found."); 1973 return false; 1974 } 1975 1976 const V val = conf.GetDef<V>(name, sub); 1977 1978 if (val<=max) 1979 return true; 1980 1981 ostringstream str; 1982 str << name << sub << "=" << val << " exceeds allowed maximum of " << max << "!"; 1983 T::Error(str); 1984 1985 return false; 1986 } 1968 1987 1969 1988 int EvalConfiguration(const Configuration &conf) … … 2004 2023 boost::array<uint64_t, 8> &arr = fClockCondSetup[*it]; 2005 2024 2006 arr[0] = conf.GetDef<Hex<uint 64_t>>("clock-conditioner.R0.", *it);2007 arr[1] = conf.GetDef<Hex<uint 64_t>>("clock-conditioner.R1.", *it);2008 arr[2] = conf.GetDef<Hex<uint 64_t>>("clock-conditioner.R8.", *it);2009 arr[3] = conf.GetDef<Hex<uint 64_t>>("clock-conditioner.R9.", *it);2010 arr[4] = conf.GetDef<Hex<uint 64_t>>("clock-conditioner.R11.", *it);2011 arr[5] = conf.GetDef<Hex<uint 64_t>>("clock-conditioner.R13.", *it);2012 arr[6] = conf.GetDef<Hex<uint 64_t>>("clock-conditioner.R14.", *it);2013 arr[7] = conf.GetDef<Hex<uint 64_t>>("clock-conditioner.R15.", *it);2025 arr[0] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R0.", *it); 2026 arr[1] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R1.", *it); 2027 arr[2] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R8.", *it); 2028 arr[3] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R9.", *it); 2029 arr[4] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R11.", *it); 2030 arr[5] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R13.", *it); 2031 arr[6] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R14.", *it); 2032 arr[7] = conf.GetDef<Hex<uint32_t>>("clock-conditioner.R15.", *it); 2014 2033 2015 2034 ostringstream out; … … 2018 2037 out << " " << setw(8) << arr[i]; 2019 2038 T::Message(out.str()); 2039 } 2040 2041 // ---------- Setup run types --------- 2042 const vector<string> types = conf.Get<vector<string>>("run-type"); 2043 if (types.size()==0) 2044 T::Warn("No run-types defined."); 2045 2046 T::Message("Defining run-types"); 2047 for (vector<string>::const_iterator it=types.begin(); 2048 it!=types.end(); it++) 2049 { 2050 if (fConfigs.count(*it)>0) 2051 { 2052 T::Error("Run-type "+*it+" defined twice."); 2053 return 2; 2054 } 2055 2056 FTM::StaticData data; 2057 2058 const uint16_t frq = conf.GetDef<uint16_t>("sampling-frequency.", *it); 2059 if (fClockCondSetup.count(frq)==0) 2060 { 2061 T::Error("sampling-frequency."+*it+" - frequency not available."); 2062 return 2; 2063 } 2064 2065 data.SetClockRegister(fClockCondSetup[frq].data()); 2066 2067 // Trigger sequence ped:lp1:lp2 2068 // (data. is used here as an abbreviation for FTM::StaticData:: 2069 if (!CheckConfigVal<bool> (conf, true, "enable-trigger.", *it) || 2070 !CheckConfigVal<bool> (conf, true, "enable-external-1.", *it) || 2071 !CheckConfigVal<bool> (conf, true, "enable-external-2.", *it) || 2072 !CheckConfigVal<bool> (conf, true, "enable-veto.", *it) || 2073 !CheckConfigVal<bool> (conf, true, "enable-clock-conditioner.", *it) || 2074 !CheckConfigVal<uint16_t>(conf, data.kMaxSequence, "trigger-sequence-ped.", *it) || 2075 !CheckConfigVal<uint16_t>(conf, data.kMaxSequence, "trigger-sequence-lp-ext.", *it) || 2076 !CheckConfigVal<uint16_t>(conf, data.kMaxSequence, "trigger-sequence-lp-int.", *it) || 2077 !CheckConfigVal<uint16_t>(conf, data.kMaxTriggerInterval, "trigger-interval.", *it) || 2078 !CheckConfigVal<uint16_t>(conf, data.kMaxMultiplicity, "multiplicity-physics.", *it) || 2079 !CheckConfigVal<uint16_t>(conf, data.kMaxMultiplicity, "multiplicity-calib.", *it) || 2080 !CheckConfigVal<uint16_t>(conf, data.kMaxWindow, "coincidence-window-physics.", *it) || 2081 !CheckConfigVal<uint16_t>(conf, data.kMaxWindow, "coincidence-window-calib.", *it) || 2082 !CheckConfigVal<uint16_t>(conf, data.kMaxDeadTime, "dead-time.", *it) || 2083 !CheckConfigVal<uint16_t>(conf, data.kMaxDelayTrigger, "trigger-delay.", *it) || 2084 !CheckConfigVal<uint16_t>(conf, data.kMaxDelayTimeMarker, "time-marker-delay.", *it) || 2085 !CheckConfigVal<uint16_t>(conf, 0xffff, "ftu-report-interval.", *it) || 2086 0) 2087 return 2; 2088 2089 data.Enable(data.kTrigger, conf.GetDef<bool>("enable-trigger.", *it)); 2090 data.Enable(data.kExt1, conf.GetDef<bool>("enable-external-1.", *it)); 2091 data.Enable(data.kExt2, conf.GetDef<bool>("enable-external-2.", *it)); 2092 data.Enable(data.kVeto, conf.GetDef<bool>("enable-veto.", *it)); 2093 data.Enable(data.kClockConditioner, conf.GetDef<bool>("enable-clock-conditioner.", *it)); 2094 2095 // [ms] Interval between two artificial triggers (no matter which type) minimum 1ms, 10 bit 2096 data.fTriggerInterval = conf.GetDef<uint16_t>("trigger-interval.", *it); 2097 data.fMultiplicityPhysics = conf.GetDef<uint16_t>("multiplicity-physics.", *it); 2098 data.fMultiplicityCalib = conf.GetDef<uint16_t>("multiplicity-calib.", *it); 2099 data.fWindowPhysics = conf.GetDef<uint16_t>("coincidence-window-physics.", *it); /// (4ns * x + 8ns) 2100 data.fWindowCalib = conf.GetDef<uint16_t>("coincidence-window-calib.", *it); /// (4ns * x + 8ns) 2101 data.fDelayTrigger = conf.GetDef<uint16_t>("trigger-delay.", *it); /// (4ns * x + 8ns) 2102 data.fDelayTimeMarker = conf.GetDef<uint16_t>("time-marker-delay.", *it); /// (4ns * x + 8ns) 2103 data.fDeadTime = conf.GetDef<uint16_t>("dead-time.", *it); /// (4ns * x + 8ns) 2104 2105 data.SetPrescaling(conf.GetDef<uint16_t>("ftu-report-interval.", *it)); 2106 2107 const uint16_t seqped = conf.GetDef<uint16_t>("trigger-sequence-ped.", *it); 2108 const uint16_t seqint = conf.GetDef<uint16_t>("trigger-sequence-lp-int.", *it); 2109 const uint16_t seqext = conf.GetDef<uint16_t>("trigger-sequence-lp-ext.", *it); 2110 2111 data.SetSequence(seqped, seqint, seqext); 2112 2113 data.EnableAllFTU(); 2114 data.EnableAllPixel(); 2115 2116 const vector<uint16_t> pat1 = conf.Vec<uint16_t>("disable-patch.default"); 2117 const vector<uint16_t> pat2 = conf.Vec<uint16_t>("disable-patch."+*it); 2118 2119 const vector<uint16_t> pix1 = conf.Vec<uint16_t>("disable-pixel.default"); 2120 const vector<uint16_t> pix2 = conf.Vec<uint16_t>("disable-pixel."+*it); 2121 2122 vector<uint16_t> pat, pix; 2123 pat.insert(pat.end(), pat1.begin(), pat1.end()); 2124 pat.insert(pat.end(), pat2.begin(), pat2.end()); 2125 pix.insert(pix.end(), pix1.begin(), pix1.end()); 2126 pix.insert(pix.end(), pix2.begin(), pix2.end()); 2127 2128 for (vector<uint16_t>::const_iterator ip=pat.begin(); ip!=pat.end(); ip++) 2129 { 2130 if (*ip>FTM::StaticData::kMaxPatchIdx) 2131 { 2132 ostringstream str; 2133 str << "disable-patch.*=" << *ip << " exceeds allowed maximum of " << FTM::StaticData::kMaxPatchIdx << "!"; 2134 T::Error(str); 2135 return 2; 2136 } 2137 data.DisableFTU(*ip); 2138 } 2139 for (vector<uint16_t>::const_iterator ip=pix.begin(); ip!=pix.end(); ip++) 2140 { 2141 if (*ip>FTM::StaticData::kMaxPixelIdx) 2142 { 2143 ostringstream str; 2144 str << "disable-pixel.*=" << *ip << " exceeds allowed maximum of " << FTM::StaticData::kMaxPixelIdx << "!"; 2145 T::Error(str); 2146 return 2; 2147 } 2148 data.EnablePixel(*ip, false); 2149 } 2150 2151 fConfigs[*it] = data; 2152 2153 /* 2154 threshold-A data[n].fDAC[0] = val 2155 threshold-B data[n].fDAC[1] = val 2156 threshold-C data[n].fDAC[2] = val 2157 threshold-D data[n].fDAC[3] = val 2158 threshold-H data[n].fDAC[4] = val 2159 */ 2160 2161 // kMaxDAC = 0xfff, 2020 2162 } 2021 2163 … … 2148 2290 po::options_description runtype("Run type configuration"); 2149 2291 runtype.add_options() 2150 ("clock-conditioner.frequency", vars<uint16_t>(), "Frequencies for which to setup the clock-conditioner") 2151 ("clock-conditioner.R0.*", var<Hex<uint64_t>>(), "Clock-conditioner R0 (replace * by the defined frequency)") 2152 ("clock-conditioner.R1.*", var<Hex<uint64_t>>(), "Clock-conditioner R1 (replace * by the defined frequency)") 2153 ("clock-conditioner.R8.*", var<Hex<uint64_t>>(), "Clock-conditioner R8 (replace * by the defined frequency)") 2154 ("clock-conditioner.R9.*", var<Hex<uint64_t>>(), "Clock-conditioner R9 (replace * by the defined frequency)") 2155 ("clock-conditioner.R11.*", var<Hex<uint64_t>>(), "Clock-conditioner R11 (replace * by the defined frequency)") 2156 ("clock-conditioner.R13.*", var<Hex<uint64_t>>(), "Clock-conditioner R13 (replace * by the defined frequency)") 2157 ("clock-conditioner.R14.*", var<Hex<uint64_t>>(), "Clock-conditioner R14 (replace * by the defined frequency)") 2158 ("clock-conditioner.R15.*", var<Hex<uint64_t>>(), "Clock-conditioner R15 (replace * by the defined frequency)") 2292 ("clock-conditioner.frequency", vars<uint16_t>(), "Frequencies for which to setup the clock-conditioner") 2293 ("clock-conditioner.R0.*", var<Hex<uint32_t>>(), "Clock-conditioner R0 (replace * by the defined frequency)") 2294 ("clock-conditioner.R1.*", var<Hex<uint32_t>>(), "Clock-conditioner R1 (replace * by the defined frequency)") 2295 ("clock-conditioner.R8.*", var<Hex<uint32_t>>(), "Clock-conditioner R8 (replace * by the defined frequency)") 2296 ("clock-conditioner.R9.*", var<Hex<uint32_t>>(), "Clock-conditioner R9 (replace * by the defined frequency)") 2297 ("clock-conditioner.R11.*", var<Hex<uint32_t>>(), "Clock-conditioner R11 (replace * by the defined frequency)") 2298 ("clock-conditioner.R13.*", var<Hex<uint32_t>>(), "Clock-conditioner R13 (replace * by the defined frequency)") 2299 ("clock-conditioner.R14.*", var<Hex<uint32_t>>(), "Clock-conditioner R14 (replace * by the defined frequency)") 2300 ("clock-conditioner.R15.*", var<Hex<uint32_t>>(), "Clock-conditioner R15 (replace * by the defined frequency)") 2301 ("run-type", vars<string>(), "") 2302 ("sampling-frequency.*", var<uint16_t>(), "") 2303 ("enable-trigger.*", var<bool>(), "") 2304 ("enable-external-1.*", var<bool>(), "") 2305 ("enable-external-2.*", var<bool>(), "") 2306 ("enable-veto.*", var<bool>(), "") 2307 ("enable-clock-conditioner.*", var<bool>(), "") 2308 ("trigger-interval.*", var<uint16_t>(), "") 2309 ("trigger-sequence-ped.*", var<uint16_t>(), "") 2310 ("trigger-sequence-lp-int.*", var<uint16_t>(), "") 2311 ("trigger-sequence-lp-ext.*", var<uint16_t>(), "") 2312 ("multiplicity-physics.*", var<uint16_t>(), "") 2313 ("multiplicity-calib.*", var<uint16_t>(), "") 2314 ("coincidence-window-physics.*", var<uint16_t>(), "") 2315 ("coincidence-window-calib.*", var<uint16_t>(), "") 2316 ("dead-time.*", var<uint16_t>(), "") 2317 ("trigger-delay.*", var<uint16_t>(), "") 2318 ("time-marker-delay.*", var<uint16_t>(), "") 2319 ("diable-pixel.*", vars<uint16_t>(), "") 2320 ("diable-patch.*", vars<uint16_t>(), "") 2321 ("ftu-report-interval.*", var<uint16_t>(), "") 2159 2322 ; 2160 2323
Note:
See TracChangeset
for help on using the changeset viewer.