ATLAS Offline Software
CountingConnector.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 
9 
11 #include "L1TopoCommon/Exception.h"
13 
14 using namespace std;
15 using namespace TCS;
16 
17 CountingConnector::CountingConnector(const string & name,
18  const string & input,
19  const string & algorithm,
20  const string & output) :
21  Connector(name, {input}, algorithm, {output}, COUNT),
22  m_countingAlgorithm(0)
23 {}
24 
27 }
28 
29 // TO-DO: Add function to return the counts, but format?
30 
31 
32 
33 TCS::TOBArray const *
34 TCS::CountingConnector::output(const std::string & trigger) const {
35  unsigned int index(0);
36  for(const TrigConf::TriggerLine & tl : m_triggers) {
37  if(tl.name() == trigger)
38  return m_outputData[index];
39  ++index;
40  }
41  TCS_EXCEPTION("Counting connector '" << name() << "' has no output trigger '" << trigger << "'");
42  return nullptr;
43 }
44 
45 
48  for(TOBArray const * x : m_outputData) {
49  delete x;
50  }
51  m_outputData.clear();
52 
53  // set counting to 0
54  m_count.reset();
55 
56  return StatusCode::SUCCESS;
57 }
58 
61  return dynamic_cast<InputConnector*>(m_inputConnectors[0]);
62 }
63 
64 void
67  m_countingAlgorithm = dynamic_cast<CountingAlg*>(alg);
68  if(m_countingAlgorithm == nullptr && alg != nullptr) {
69  TCS_EXCEPTION("Error: algorithm " << alg->name() << " is not a CountingAlg");
70  }
71 }
72 
73 // attaches the selected data to the connector (does take ownership)
74 void
75 CountingConnector::attachOutputData(const std::vector<TOBArray *>& data) {
76  if(m_outputData.size() != 0) {
77  TCS_EXCEPTION("Trying to attach data to multiplicity connector '" << name() <<"' which has already data attached");
78  }
79 
80  for(TOBArray * x : data)
81  m_outputData.push_back( dynamic_cast<const TOBArray*>(x) );
82 }
83 
84 
85 void
86 CountingConnector::setFirstOutputBit(unsigned int firstOutputBit) {
87  m_count.setFirstBit(firstOutputBit);
88 }
89 
90 namespace TCS {
91 
92  ostream &
93  operator<<(ostream&o, const TCS::CountingConnector & conn) {
94  o << "(" << join(conn.inputNames()) << ") ---[" << conn.algorithmName() << "]---> (" << join(conn.outputNames()) << ")";
95  return o;
96 
97  }
98 }
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::CountingConnector::~CountingConnector
virtual ~CountingConnector()
Definition: CountingConnector.cxx:25
TCS::Count::setFirstBit
void setFirstBit(unsigned int startBit)
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Count.h:37
TCS::Connector::m_inputConnectors
std::vector< TCS::Connector * > m_inputConnectors
Definition: Connector.h:98
TCS::Connector
Definition: Connector.h:22
InputConnector.h
TCS::CountingConnector
Definition: CountingConnector.h:26
TCS::CountingConnector::setAlgorithm
void setAlgorithm(TCS::ConfigurableAlg *alg)
Definition: CountingConnector.cxx:65
x
#define x
CountingAlg.h
TCS::CountingConnector::m_countingAlgorithm
TCS::CountingAlg * m_countingAlgorithm
Definition: CountingConnector.h:70
TrigConf::TriggerLine
a TriggerLine entry describes the location of a threshold multiplicity on a cable (connector)
Definition: L1Connector.h:21
TCS::InputConnector
Definition: InputConnector.h:22
CountingConnector.h
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
StringUtils.h
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
TCS::TOBArray
Definition: TOBArray.h:24
merge.output
output
Definition: merge.py:17
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TCS::Connector::name
const std::string & name() const
Definition: Connector.h:44
TCS::CountingConnector::output
TOBArray const * output(const std::string &trigger) const
Definition: CountingConnector.cxx:34
DeMoScan.index
string index
Definition: DeMoScan.py:364
TCS::CountingConnector::m_count
Count m_count
Definition: CountingConnector.h:68
TCS::CountingConnector::attachOutputData
void attachOutputData(const std::vector< TOBArray * > &)
Definition: CountingConnector.cxx:75
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
dqt_zlumi_alleff_HIST.tl
tl
Definition: dqt_zlumi_alleff_HIST.py:73
TCS::CountingConnector::inputConnector
InputConnector * inputConnector() const
Definition: CountingConnector.cxx:60
TCS::CountingConnector::clearOutput
virtual StatusCode clearOutput()
Definition: CountingConnector.cxx:47
TCS::CountingConnector::setFirstOutputBit
void setFirstOutputBit(unsigned int firstOutputBit)
Definition: CountingConnector.cxx:86
TCS::operator<<
std::ostream & operator<<(std::ostream &, const TCS::CountingConnector &)
Definition: CountingConnector.cxx:93
Exception.h
TCS::CountingAlg
Definition: CountingAlg.h:25
TCS::StatusCode
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15
TCS::Connector::setAlgorithm
virtual void setAlgorithm(TCS::ConfigurableAlg *)
Definition: Connector.cxx:42
TCS::CountingConnector::m_outputData
std::vector< TOBArray const * > m_outputData
Definition: CountingConnector.h:75