Skip to content

Commit ec7b21c

Browse files
authored
ctpdev: ctpproxy publish CTP scalers (#8119)
1 parent c478edf commit ec7b21c

11 files changed

Lines changed: 232 additions & 2 deletions

File tree

DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class CTPConfiguration
100100
CTPInput* isInputInConfig(const std::string inpname);
101101
uint64_t getDecrtiptorInputsMask(const std::string& name) const;
102102
std::map<o2::detectors::DetID::ID, std::vector<CTPInput>> getDet2InputMap();
103+
uint64_t getTriggerClassMask() const;
104+
std::vector<int> getTriggerClassList() const;
103105

104106
private:
105107
std::string mName;

DataFormats/Detectors/CTP/include/DataFormatsCTP/Digits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static constexpr uint32_t NGBT = 80;
3333
static constexpr std::uint32_t NumOfHBInTF = 256;
3434
typedef std::bitset<NGBT> gbtword80_t;
3535
//
36-
static constexpr std::uint32_t CTP_NINPUTS = 46; /// Max number of CTP inputs for all levels
36+
static constexpr std::uint32_t CTP_NINPUTS = 48; /// Max number of CTP inputs for all levels
3737
static constexpr std::uint32_t CTP_NCLASSES = 64; /// Number of classes in hardware
3838
static constexpr std::uint32_t CTP_MAXTRIGINPPERDET = 5; /// Max number of LM/L0inputs per detector
3939
/// Positions of CTP Detector inputs in CTPInputMask: first=offset, second=mask
@@ -57,7 +57,7 @@ struct CTPDigit {
5757
return intRecord == d.intRecord && CTPInputMask == d.CTPInputMask && CTPClassMask == d.CTPClassMask;
5858
}
5959

60-
ClassDefNV(CTPDigit, 2);
60+
ClassDefNV(CTPDigit, 3);
6161
};
6262

6363
std::ostream& operator<<(std::ostream& os, const CTPDigit& d);

DataFormats/Detectors/CTP/include/DataFormatsCTP/Scalers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class CTPRunScalers
8282
int convertRawToO2();
8383
int checkConsistency(const CTPScalerO2& scal0, const CTPScalerO2& scal1) const;
8484
int checkConsistency(const CTPScalerRecordO2& rec0, const CTPScalerRecordO2& rec1) const;
85+
//
86+
int parseZMQScalers(std::string zmqscalers);
8587

8688
private:
8789
// map from class index to overflow

DataFormats/Detectors/CTP/src/Configuration.cxx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,22 @@ std::map<o2::detectors::DetID::ID, std::vector<CTPInput>> CTPConfiguration::getD
326326
}
327327
return det2inp;
328328
}
329+
uint64_t CTPConfiguration::getTriggerClassMask() const
330+
{
331+
uint64_t clsmask = 0;
332+
for (auto const& cls : mCTPClasses) {
333+
clsmask |= cls.classMask;
334+
}
335+
return clsmask;
336+
}
337+
std::vector<int> CTPConfiguration::getTriggerClassList() const
338+
{
339+
uint64_t clsmask = getTriggerClassMask();
340+
std::vector<int> classlist;
341+
for (int i = 0; i < 64; i++) {
342+
if ((1ull << i) & clsmask) {
343+
classlist.push_back(i);
344+
}
345+
}
346+
return classlist;
347+
}

DataFormats/Detectors/CTP/src/Scalers.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,8 @@ int CTPRunScalers::updateOverflows(const CTPScalerRaw& scal0, const CTPScalerRaw
361361
//std::cout << std::endl;
362362
return 0;
363363
}
364+
int CTPRunScalers::parseZMQScalers(std::string zmqscalers)
365+
{
366+
std::vector<std::string> tokens = o2::utils::Str::tokenize(zmqscalers, ' ');
367+
return 0;
368+
}

Detectors/CTP/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ add_subdirectory(simulation)
1313
add_subdirectory(reconstruction)
1414
add_subdirectory(workflow)
1515
add_subdirectory(workflowIO)
16+
add_subdirectory(workflowScalers)
1617
add_subdirectory(macro)

Detectors/CTP/reconstruction/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ o2_add_library(CTPReconstruction
1818
O2::rANS
1919
Microsoft.GSL::GSL)
2020

21+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
o2_add_executable(
2+
proxy
3+
COMPONENT_NAME ctp
4+
SOURCES src/ctp-proxy.cxx
5+
PUBLIC_LINK_LIBRARIES O2::DCStestWorkflow
6+
O2::DataFormatsCTP)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import zmq
2+
import random
3+
import sys
4+
import time
5+
6+
port = "500901"
7+
if len(sys.argv) > 1:
8+
port = sys.argv[1]
9+
int(port)
10+
11+
context = zmq.Context()
12+
socket = context.socket(zmq.PUB)
13+
socket.bind("tcp://*:%s" % port)
14+
while True:
15+
topic = random.randrange(0,2**32)
16+
#messagedata = random.randrange(1,215) - 80
17+
header = "CTP"
18+
messagedata = str(topic)+"1 2 3 4 5"
19+
print("Sending:",header, messagedata)
20+
data = str(messagedata).encode()
21+
header = str(header).encode()
22+
socket.send(memoryview(header),zmq.SNDMORE)
23+
socket.send(memoryview(data))
24+
time.sleep(1)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import sys
2+
import zmq
3+
4+
port = "500901"
5+
if len(sys.argv) > 1:
6+
port = sys.argv[1]
7+
int(port)
8+
9+
if len(sys.argv) > 2:
10+
port1 = sys.argv[2]
11+
int(port1)
12+
13+
# Socket to talk to server
14+
context = zmq.Context()
15+
socket = context.socket(zmq.SUB)
16+
17+
print("Collecting updates from CTP server, port:",port)
18+
socket.connect ("tcp://localhost:%s" % port)
19+
20+
if len(sys.argv) > 2:
21+
socket.connect ("tcp://localhost:%s" % port1)
22+
# Subscribe to zipcode, default is NYC, 10001
23+
topicfilter = "CTP"
24+
socket.setsockopt_string(zmq.SUBSCRIBE, topicfilter)
25+
26+
# Process 5 updates
27+
total_value = 0
28+
while(1):
29+
string = socket.recv_multipart()
30+
#string = stringr.decode()
31+
print("string:",string)
32+
#topic, messagedata = string.split()
33+
#total_value += int(messagedata)
34+
#print(topic, messagedata)
35+
36+
print("Average messagedata value for topic '%s' was %dF" % (topicfilter, total_value / update_nbr))
37+

0 commit comments

Comments
 (0)