Project
Loading...
Searching...
No Matches
ModuleConfig.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
13#include "Framework/Logger.h"
14
15using namespace o2::zdc;
16
17//______________________________________________________________________________
18void Module::printCh() const
19{
20 printf("Module %d [ChID/FEEID R:T ]", id);
21 for (int ic = 0; ic < MaxChannels; ic++) {
22 printf("[%s{%2d}/L%02d %c:%c ]", channelName(channelID[ic]), channelID[ic], feeID[ic], readChannel[ic] ? 'R' : ' ', trigChannel[ic] ? 'T' : ' ');
23 }
24 printf("\n");
25}
26
27//______________________________________________________________________________
29{
30 printf("Trigger conf %d: ", id);
31 for (int ic = 0; ic < MaxChannels; ic++) {
32 const auto& cnf = trigChannelConf[ic];
33 if (trigChannel[ic]) {
34 printf("[TRIG %s: F:%2d L:%2d S:%2d T:%2d] ", channelName(channelID[ic]), cnf.first, cnf.last, cnf.shift, cnf.threshold);
35 } else if (cnf.shift > 0 && cnf.threshold > 0) {
36 printf("[DISC %s: F:%2d L:%2d S:%2d T:%2d] ", channelName(channelID[ic]), cnf.first, cnf.last, cnf.shift, cnf.threshold);
37 }
38 }
39 printf("\n");
40}
41
42//______________________________________________________________________________
43void Module::print() const
44{
45 printCh();
46 printTrig();
47}
48
50{
51 printf("Modules configuration: baselineFactor = %f\n", baselineFactor);
52 for (const auto& md : modules) {
53 if (md.id >= 0) {
54 md.printCh();
55 }
56 }
57 for (const auto& md : modules) {
58 if (md.id >= 0) {
59 md.printTrig();
60 }
61 }
62 int ib = 0, nb = 0;
63 uint64_t one = 0x1;
64 std::string blist;
65 for (int i = 0; i < NWMap; i++) {
67 for (int j = 0; j < 64; j++) {
68 if ((val & (one << j)) != 0) { // Empty bunch
69 blist += (" " + std::to_string(ib));
70 nb++;
71 }
72 ib++;
73 if (ib == o2::constants::lhc::LHCMaxBunches) {
74 break;
75 }
76 }
77 }
78 LOG(info) << "Bunch list for baseline calculation:" << (nb == 0 ? " EMPTY" : blist);
79}
80
81//______________________________________________________________________________
83{
84 for (int i = 0; i < NWMap; i++) {
85 emptyMap[i] = 0;
86 }
87}
88
89//______________________________________________________________________________
90void ModuleConfig::addBunch(int ibunch)
91{
92 if (ibunch < 0 || ibunch >= o2::constants::lhc::LHCMaxBunches) {
93 LOG(fatal) << "ModuleConfig::addBunch out of range [0:3563] " << ibunch;
94 }
95 int iw = ibunch / 64;
96 int is = ibunch % 64;
97 uint64_t one = 0x1;
98 emptyMap[iw] = emptyMap[iw] | (one << is);
99}
100
101//______________________________________________________________________________
103{
104 for (const auto& md : modules) {
105 md.check();
106 }
107}
108
109//______________________________________________________________________________
110void Module::check() const
111{
112 // make sure that the channel has <= 2 triggers
113 int ntr = 0;
114 for (int i = MaxChannels; i--;) {
115 ntr += trigChannel[i];
116 }
117 if (ntr > Module::MaxTriggChannels) {
118 print();
119 LOG(fatal) << "ZDC Module can have at most " << Module::MaxTriggChannels << " trigger channels";
120 }
121}
122
123//______________________________________________________________________________
124void Module::setChannel(int slot, int8_t chID, int16_t fID, bool read, bool trig, int tF, int tL, int tS, int tT)
125{
126 if (slot < 0 || slot >= MaxChannels || chID < 0 || chID > NChannels) {
127 LOG(fatal) << "Improper module channel settings" << slot << ' ' << chID << ' ' << fID << ' ' << read << ' ' << trig
128 << ' ' << tF << ' ' << tL << ' ' << tS << ' ' << tT;
129 }
130 feeID[slot] = fID;
131 channelID[slot] = chID;
132 readChannel[slot] = read;
133 // In the 2020 firmware implementation, autotrigger bits are computed for each channel
134 // Therefore we put the trig flag just for the triggering channels
135 // Discriminator parameters are stored for all modules
136 trigChannel[slot] = trig;
137 if (tS > 0 && tT > 0) {
138 if (tL + tS + 1 >= NTimeBinsPerBC) {
139 LOG(fatal) << "Sum of Last and Shift trigger parameters exceed allowed range";
140 }
141 trigChannelConf[slot].id = chID;
142 trigChannelConf[slot].first = tF;
143 trigChannelConf[slot].last = tL;
144 trigChannelConf[slot].shift = tS;
145 trigChannelConf[slot].threshold = tT;
146 }
147}
148
149//______________________________________________________________________________
151{
152 uint32_t triggermask = 0;
153 for (int im = 0; im < NModules; im++) {
154 for (int ic = 0; ic < NChPerModule; ic++) {
155 if (modules[im].trigChannel[ic]) {
156 uint32_t tmask = 0x1 << (im * NChPerModule + ic);
157 triggermask = triggermask | tmask;
158 }
159 }
160 }
161 return triggermask;
162}
163
165{
166 std::string printTriggerMask{};
167 for (int im = 0; im < NModules; im++) {
168 if (im > 0) {
169 printTriggerMask += " ";
170 }
171 printTriggerMask += std::to_string(im);
172 printTriggerMask += "[";
173 for (int ic = 0; ic < NChPerModule; ic++) {
174 if (modules[im].trigChannel[ic]) {
175 printTriggerMask += "T";
176 } else {
177 printTriggerMask += " ";
178 }
179 }
180 printTriggerMask += "]";
181 }
182 return printTriggerMask;
183}
unsigned int uint32_t
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
uint32_t one
Definition RawData.h:4
uint32_t j
Definition RawData.h:0
GLuint GLfloat * val
Definition glcorearb.h:1582
constexpr int NModules
Definition Constants.h:68
constexpr int NTimeBinsPerBC
Definition Constants.h:53
constexpr int NChPerModule
Definition Constants.h:69
constexpr int NChannels
Definition Constants.h:65
constexpr const char * channelName(int channel)
Definition Constants.h:318
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
std::array< uint64_t, NWMap > emptyMap
uint32_t getTriggerMask() const
std::string getPrintTriggerMask() const
void addBunch(int ibunch)
static constexpr int NWMap
std::array< Module, MaxNModules > modules
void check() const
std::array< bool, MaxChannels > trigChannel
void setChannel(int slot, int8_t chID, int16_t fID, bool read, bool trig=false, int tF=0, int tL=0, int tS=0, int tT=0)
void printCh() const
std::array< TriggerChannelConfig, MaxChannels > trigChannelConf
std::array< bool, MaxChannels > readChannel
void print() const
static constexpr int MaxChannels
std::array< int8_t, MaxChannels > channelID
static constexpr int MaxTriggChannels
std::array< int16_t, MaxChannels > feeID
void printTrig() const
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"