ATLAS Offline Software
DecisionConnector.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
10 
11 using namespace std;
12 using namespace TCS;
13 
14 DecisionConnector::DecisionConnector(const std::string & name,
15  const vector<string> & inputs,
16  const string & algorithm,
17  const vector<string> & outputs) :
18  Connector(name, inputs, algorithm, outputs, DECISION),
19  m_decisionAlgorithm(0)
20 {}
21 
24 }
25 
26 bool
27 TCS::DecisionConnector::decision(const std::string & trigger) const {
28  unsigned int index(0);
29  for(const TrigConf::TriggerLine & tl : m_triggers) {
30  if(tl.name() == trigger)
31  return m_decision.bit(index);
32  ++index;
33  }
34  TCS_EXCEPTION("Decision connector '" << name() << "' has no output trigger '" << trigger << "'");
35  return false;
36 }
37 
38 
39 TCS::TOBArray const *
40 TCS::DecisionConnector::output(const std::string & trigger) const {
41  unsigned int index(0);
42  for(const TrigConf::TriggerLine & tl : m_triggers) {
43  if(tl.name() == trigger)
44  return m_outputData[index];
45  ++index;
46  }
47  TCS_EXCEPTION("Decision connector '" << name() << "' has no output trigger '" << trigger << "'");
48  return nullptr;
49 }
50 
51 
54  for(TOBArray const * x : m_outputData) {
55  delete x;
56  }
57  m_outputData.clear();
58 
59  // set decision to 0
60  m_decision.reset();
61 
62  return StatusCode::SUCCESS;
63 }
64 
65 void
68  m_decisionAlgorithm = dynamic_cast<DecisionAlg*>(alg);
69  if(m_decisionAlgorithm == nullptr && alg != nullptr) {
70  cerr << "Error: algorithm" << alg->name() << " is not a DecisionAlg" << endl;
71  }
72 }
73 
74 
75 // attaches the sorted data to the connector (does take ownership)
76 void
77 DecisionConnector::attachOutputData(const std::vector<TOBArray *>& data) {
78  if(m_outputData.size() != 0) {
79  TCS_EXCEPTION("Trying to attach data to decision connector '" << name() << "' which has already data attached");
80  }
81 
82  //std::vector<TOBArray const *> m_outputData;
83  for(TOBArray * x : data)
84  m_outputData.push_back( (TOBArray const *) x );
85 }
86 
87 
88 void
89 DecisionConnector::setFirstOutputBit(unsigned int firstOutputBit) {
90  m_decision.setFirstBit(firstOutputBit);
91 }
92 
93 
94 namespace TCS {
95 
96 
97 ostream &
98 operator<<(ostream &o, const TCS::DecisionConnector & conn) {
99  o << "(" << join(conn.inputNames()) << ") ---[ " << conn.algorithmName() << " ]---> (" << join(conn.outputNames()) << ")";
100  return o;
101 }
102 
103 
104 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
checkCorrelInHIST.conn
conn
Definition: checkCorrelInHIST.py:25
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
algorithm
std::string algorithm
Definition: hcg.cxx:82
SGout2dot.alg
alg
Definition: SGout2dot.py:243
TCS::Connector
Definition: Connector.h:22
index
Definition: index.py:1
TCS::DecisionConnector::attachOutputData
void attachOutputData(const std::vector< TOBArray * > &)
Definition: DecisionConnector.cxx:77
TCS::DecisionConnector::m_decisionAlgorithm
TCS::DecisionAlg * m_decisionAlgorithm
Definition: DecisionConnector.h:67
x
#define x
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
DecisionConnector.h
TCS::DecisionConnector::m_decision
Decision m_decision
Definition: DecisionConnector.h:65
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
TCS::DecisionConnector::~DecisionConnector
virtual ~DecisionConnector()
Definition: DecisionConnector.cxx:22
TrigConf::TriggerLine
a TriggerLine entry describes the location of a threshold multiplicity on a cable (connector)
Definition: L1Connector.h:21
StringUtils.h
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
TCS::DecisionConnector::output
TOBArray const * output(const std::string &trigger) const
Definition: DecisionConnector.cxx:40
TCS::TOBArray
Definition: TOBArray.h:24
python.CreateTierZeroArgdict.outputs
outputs
Definition: CreateTierZeroArgdict.py:189
TCS::ConfigurableAlg
Definition: ConfigurableAlg.h:30
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
DecisionAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TCS::Connector::name
const std::string & name() const
Definition: Connector.h:44
TCS::DecisionConnector::clearOutput
virtual StatusCode clearOutput()
Definition: DecisionConnector.cxx:53
DeMoScan.index
string index
Definition: DeMoScan.py:364
TCS::DecisionConnector::m_outputData
std::vector< TOBArray const * > m_outputData
Definition: DecisionConnector.h:72
TCS::DecisionConnector::setFirstOutputBit
void setFirstOutputBit(unsigned int firstOutputBit)
Definition: DecisionConnector.cxx:89
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
TCS::DecisionConnector::decision
const Decision & decision() const
Definition: DecisionConnector.h:40
dqt_zlumi_alleff_HIST.tl
tl
Definition: dqt_zlumi_alleff_HIST.py:73
TCS::operator<<
std::ostream & operator<<(std::ostream &, const TCS::CountingConnector &)
Definition: CountingConnector.cxx:93
TCS::Decision::setFirstBit
void setFirstBit(unsigned int startBit)
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:35
Exception.h
TCS::DecisionConnector
Definition: DecisionConnector.h:23
TCS::StatusCode
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15
TCS::Connector::setAlgorithm
virtual void setAlgorithm(TCS::ConfigurableAlg *)
Definition: Connector.cxx:42
TCS::DecisionConnector::setAlgorithm
void setAlgorithm(TCS::ConfigurableAlg *alg)
Definition: DecisionConnector.cxx:66