8 void TriggerSystem::configureSystemFromFiles(
const char *hwCfgFile,
const char *topCfgFile,
const char *
key) {
27 void TriggerSystem::addProcessor (
const char *processor,
const char *role,
const char *crate,
const char *slot) {
29 auto p2r = procToRole.find(processor);
30 if( p2r != procToRole.end() && p2r->second != role )
31 throw std::runtime_error(
"Processor: '" +
string(processor) +
"' already exists but with different role: '" + p2r->second +
"'");
33 procEnabled[processor] =
true;
34 procToRole [processor] = role;
35 procToSlot [processor] = slot;
36 procParameters.insert( make_pair(
string(processor),std::map<std::string,Parameter>()) ) ;
37 procMasks.
insert( make_pair(
string(processor),std::map<std::string,Mask>()) ) ;
38 roleForProcs [role].
insert(processor);
39 crateForProcs[crate].insert(processor);
43 void TriggerSystem::addDaq(
const char *daq,
const char *role,
const char *crate) {
44 auto d2r = daqttcToRole.find(daq);
45 if( d2r != daqttcToRole.end() && d2r->second != role )
46 throw runtime_error(
"DAQttc: '" +
string(daq) +
"' already exists but with different role: " + d2r->second);
48 daqttcToRole [daq] = role;
49 daqttcToCrate[daq] = crate;
50 roleForDaqttcs[role].insert(daq);
54 void TriggerSystem::addParameter(
const char *
id,
const char *procOrRole,
const char *
type,
const char *
value,
const char *
delim) {
57 if( strlen(delim) == 0 ) delim =
",";
60 auto processor = procParameters.find(procOrRole);
61 if( processor != procParameters.end() ){
63 auto setting = processor->second.find(
id);
64 if( setting != processor->second.end() ){
70 setting->second =
Parameter(
id,procOrRole,type,value,delim);
72 processor->second.insert(
73 make_pair(
string(
id),
Parameter(
id,procOrRole,type,value,delim))
76 auto p2r = procToRole.find(procOrRole);
77 if( p2r == procToRole.end() )
79 *logs <<
"Warning: TriggerSystem object doesn't yet assign " 80 <<
" a role to the processor " << procOrRole << endl;
86 auto role = roleForProcs.find(procOrRole);
87 if( role != roleForProcs.end() ){
89 for(
auto &
proc : role->second){
90 auto processor = procParameters.find(
proc);
91 if( processor != procParameters.end() ){
94 auto setting = processor->second.find(
id);
95 if( setting == processor->second.end() )
96 processor->second.insert(
97 make_pair(
string(
id),
Parameter(
id,procOrRole,type,value,delim))
100 map<string,Parameter>
tmp;
101 tmp.insert( make_pair(
id,
Parameter(
id,procOrRole,type,value)) );
110 throw runtime_error(
"Processor or Role '" +
string(procOrRole) +
"' was not found");
113 void TriggerSystem::addTable(
const char *
id,
const char *procOrRole,
const char *
columns,
const char *
types,
const vector<string>&
rows,
const char *
delim) {
116 if( strlen(delim) == 0 ) delim =
",";
119 auto processor = procParameters.find(procOrRole);
120 if( processor != procParameters.end() ){
122 auto setting = processor->second.find(
id);
123 if( setting != processor->second.end() )
125 setting->second =
Parameter(
id,procOrRole,types,columns,rows,delim);
127 processor->second.insert(
128 make_pair(
string(
id),
Parameter(
id,procOrRole,types,columns,rows,delim))
131 auto p2r = procToRole.find(procOrRole);
132 if( p2r == procToRole.end() )
134 *logs <<
"Warning: TriggerSystem object doesn't yet assign " 135 <<
" a role to the processor " << procOrRole << endl;
141 auto role = roleForProcs.find(procOrRole);
142 if( role != roleForProcs.end() ){
144 for(
auto &
proc : role->second){
145 auto processor = procParameters.find(
proc );
146 if( processor != procParameters.end() ){
149 auto setting = processor->second.find(
id);
150 if( setting == processor->second.end() )
151 processor->second.insert(
152 make_pair(
string(
id),
Parameter(
id,procOrRole,types,columns,rows,delim))
155 map<string,Parameter>
tmp;
156 tmp.insert( make_pair(
id,
Parameter(
id,procOrRole,types,columns,rows,delim)) );
165 throw runtime_error(
"Processor or Role '" +
string(procOrRole) +
"' was not found");
170 throw runtime_error(
"TriggerSystem is not configured yet. First call the configureSystem method");
172 auto processor = procParameters.find(p);
173 if( processor == procParameters.end() )
174 throw runtime_error(
"Processor '" +
string(p) +
"' was not found in the configuration");
176 return processor->second;
179 void TriggerSystem::addMask(
const char *
id,
const char *procOrRoleOrDaq) {
182 auto processor = procMasks.find(procOrRoleOrDaq);
183 if( processor != procMasks.end() ){
185 auto mask = processor->second.find(
id);
186 if(
mask != processor->second.end() ){
192 mask->second =
Mask(
id, procOrRoleOrDaq);
194 processor->second.insert(
195 make_pair(
string(
id),
Mask(
id, procOrRoleOrDaq))
198 auto p2r = procToRole.find(procOrRoleOrDaq);
199 if( p2r == procToRole.end() )
201 *logs <<
"Warning: TriggerSystem object doesn't yet assign " 202 <<
" a role to the processor " << procOrRoleOrDaq << endl;
207 auto role = roleForProcs.find(procOrRoleOrDaq);
208 if( role != roleForProcs.end() ){
210 for(
auto &
proc : role->second){
211 auto processor = procMasks.find(
proc );
212 if( processor != procMasks.end() ){
215 auto mask = processor->second.find(
id);
216 if(
mask == processor->second.end() )
217 processor->second.insert(
218 make_pair(
string(
id),
Mask(
id, procOrRoleOrDaq))
223 make_pair(
proc, map<string,Mask>( {{
id,
Mask(
id, procOrRoleOrDaq)}} ) )
234 auto d2c = daqttcToCrate.find(procOrRoleOrDaq);
235 if( d2c != daqttcToCrate.end() ){
237 size_t idLen = strlen(
id);
238 string slot =
id + (idLen>2 ? idLen - 2 : 0);
239 auto processors = crateForProcs.find(d2c->second);
240 if( processors != crateForProcs.end() ){
241 for(
auto &
proc : processors->second)
242 if( procToSlot[
proc] == slot )
243 procEnabled[
proc] =
false;
246 *logs <<
"Warning: no processors in daqttc crate for " 247 << procOrRoleOrDaq <<
" ... do nothing" << endl;
252 auto r2d = roleForDaqttcs.find(procOrRoleOrDaq);
253 if( r2d != roleForDaqttcs.end() ){
254 for(
auto &daq : r2d->second){
255 auto processors = crateForProcs.find(daq);
256 if( processors != crateForProcs.end() ){
257 for(
auto &
proc : processors->second)
258 procEnabled[
proc] =
false;
261 *logs <<
"Warning: no processors in daqttc crate " << d2c->second
262 <<
" for " << procOrRoleOrDaq <<
" ... do nothing" << endl;
268 throw runtime_error (
"Processor/DAQ or Role '" +
string(procOrRoleOrDaq) +
"' was not found in the map for masking");
271 const map<string, Mask>& TriggerSystem::getMasks(
const char *
p)
const {
273 throw std::runtime_error(
"TriggerSystem is not configured yet. First call the configureSystem method");
275 auto processor = procMasks.find(p);
276 if( processor == procMasks.end() )
277 throw std::runtime_error(
"Processor '" +
string(p) +
"' was not found in the configuration");
279 return processor->second;
282 bool TriggerSystem::isMasked(
const char *
p,
const char *
id)
const {
283 const std::map<std::string, Mask>&
m = getMasks(p);
285 auto mask = m.find(
id);
286 if(
mask == m.end() )
return false;
291 void TriggerSystem::disableProcOrRoleOrDaq(
const char *procOrRoleOrDaq) {
295 auto processor = procEnabled.find(procOrRoleOrDaq);
296 if( processor != procEnabled.end() ){
297 processor->second =
false;
302 auto role = roleForProcs.find(procOrRoleOrDaq);
303 if( role != roleForProcs.end() ){
305 for(
auto &
proc : role->second)
307 procEnabled[
proc] =
false;
312 auto d2c = daqttcToCrate.find(procOrRoleOrDaq);
313 if( d2c != daqttcToCrate.end() ){
314 auto processors = crateForProcs.find(d2c->second);
315 if( processors != crateForProcs.end() ){
316 for(
auto &
proc : processors->second)
318 procEnabled[
proc] =
false;
321 *logs <<
"Warning: no processors in daqttc crate for " 322 << procOrRoleOrDaq <<
" ... do nothing" << endl;
327 auto r2d = roleForDaqttcs.find(procOrRoleOrDaq);
328 if( r2d != roleForDaqttcs.end() ){
329 for(
auto &daq : r2d->second){
330 auto d2c = daqttcToCrate.find(daq);
331 if( d2c != daqttcToCrate.end() ){
332 auto processors = crateForProcs.find(d2c->second);
333 if( processors != crateForProcs.end() ){
334 for(
auto &
proc : processors->second)
335 procEnabled[
proc] =
false;
338 *logs <<
"Warning: no processors in daqttc crate " << d2c->second
339 <<
" for " << procOrRoleOrDaq <<
" ... do nothing" << endl;
342 *logs <<
"Warning: daqttc " << daq <<
" has no crate " 343 <<
" ... do nothing" << endl;
349 throw runtime_error(
"Processor/DAQ or Role '" +
string(procOrRoleOrDaq) +
"' was not found");
352 bool TriggerSystem::isProcEnabled(
const char *
p)
const {
354 throw std::runtime_error(
"TriggerSystem is not configured yet. First call the configureSystem method");
356 auto processor = procEnabled.find(p);
357 if( processor == procEnabled.end() )
358 throw runtime_error(
"Processor '" +
string(p) +
"' not found");
360 return processor->second;
def getParameters(parameters)
void readDOMFromFile(const std::string &fName, xercesc::DOMDocument *&doc)
TrainProcessor *const proc
void buildGlobalDoc(const std::string &key, const std::string &topPath="")
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
std::vector< std::vector< double > > tmp
void readRootElement(TriggerSystem &aTriggerSystem, const std::string &sysId="")
void readContexts(const std::string &key, const std::string &sysId, TriggerSystem &aTriggerSystem)