ATLAS Offline Software
Loading...
Searching...
No Matches
PrescaleSet.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6
9#include <iostream>
10#include <iomanip>
11#include <math.h>
12
13using namespace TrigConf;
14
15const int32_t PrescaleSet::maxPrescaleCut = 0xFFFFFF; //2**24 - 1
16
29int32_t
31 int32_t sign = prescale<0 ? -1 : 1;
32 double uprescale = fabs(prescale);
33 return sign * ( 0x1000000 - int32_t(0xFFFFFF/uprescale));
34}
35
48double
50 double sign = cut<0 ? -1 : 1;
51 uint32_t ucut = abs(cut);
52 return (sign * 0xFFFFFF ) / ( 0x1000000 - ucut );
53}
54
56 for(auto& x: m_Prescales_ctp) x=-1;
57 for(auto& x: m_Prescales_float) x=-1;
58 for(auto& x: m_Cuts) x=-maxPrescaleCut;
59 m_null = true;
60}
61
62void
64 m_Prescales_ctp.resize(size,-1);
65 m_Prescales_float.resize(size,-1);
66 m_Cuts.resize(size,2<<10);
67}
68
69void
70TrigConf::PrescaleSet::setCuts(const std::vector<int32_t>& cuts) {
71 for(unsigned int ctpid = 0; ctpid < cuts.size(); ++ctpid )
72 setCut(ctpid, cuts[ctpid]);
73}
74
75
76void
77TrigConf::PrescaleSet::setCut(unsigned int ctpid, int32_t cut) {
78 m_Cuts[ctpid] = cut;
80 m_null = false;
81}
82
83
84void
85TrigConf::PrescaleSet::setPrescale(unsigned int num, float prescaleValue) {
86 int32_t cut = getCutFromPrescale(prescaleValue);
87 m_Prescales_ctp[num] = cut;
88 m_Prescales_float[num] = prescaleValue;
89 m_null = false;
90}
91
92
93void
94TrigConf::PrescaleSet::print(const std::string& indent, unsigned int detail) const {
95 if(detail>=1) {
96 std::cout << indent << "PrescaleSet ";
97 printNameIdV("");
98 if(detail>=3) {
99 int i(0);
100 for( auto ps: m_Prescales_float)
101 std::cout << indent << " ctpid=" << i++ << ": " << " prescale=" << ps << std::endl;
102 }
103 }
104}
105
109void
110TrigConf::PrescaleSet::writeXML(std::ostream & xmlfile, int indentLevel, int indentWidth) const {
111 L1PSNumber psOut;
112 indent(xmlfile, indentLevel, indentWidth)
113 << "<PrescaleSet"
114 << " name=\"" << name() << "\""
115 << " type=\"" << type() << "\""
116 << " menuPartition=\"" << partition() << "\">"
117 << std::endl;
118
119 int ctpid(0);
120 for (int32_t cut: m_Cuts) {
121 indent(xmlfile, indentLevel + 1, indentWidth)
122 << "<Prescale ctpid=\"" << ctpid++
123 << "\" cut=\"" << (cut<0?"-":"") << std::hex << std::setfill('0') << std::setw(6) << abs(cut)
124 << std::setfill(' ') << std::dec << "\" value=\"" << getPrescaleFromCut(cut)
125 << "\"/>" << std::endl;
126 }
127 indent(xmlfile, indentLevel, indentWidth)
128 << "</PrescaleSet>" << std::endl;
129}
size_t size() const
Number of registered mappings.
int sign(int a)
#define x
static int32_t getCutFromPrescale(double prescale)
calculate cut value for hardware configuration cut = 2*24/prescale - 1
const std::string & type() const
Definition PrescaleSet.h:37
void setCuts(const std::vector< int32_t > &cuts)
virtual void print(const std::string &indent="", unsigned int detail=1) const override
void setCut(unsigned int num, int32_t cut)
unsigned int partition() const
Definition PrescaleSet.h:38
const std::vector< int32_t > & cuts() const
Definition PrescaleSet.h:41
static double getPrescaleFromCut(int32_t cut)
prescale = 2*24/(cut+1.)
static const int32_t maxPrescaleCut
Definition PrescaleSet.h:26
std::vector< int32_t > m_Cuts
Definition PrescaleSet.h:67
void writeXML(std::ostream &xmlfile, int indentLevel=0, int indentWidth=2) const
Writes the Prescale item to the XML file.
void setPrescale(unsigned int num, float prescaleValue)
std::vector< float > m_Prescales_float
Definition PrescaleSet.h:66
void resize(size_t size)
std::vector< int64_t > m_Prescales_ctp
Definition PrescaleSet.h:65
std::ostream & indent(std::ostream &o, int lvl, int size) const
void printNameIdV(const std::string &indent="") const
static std::vector< std::string > xmlfile
Definition iLumiCalc.h:29
Forward iterator to traverse the main components of the trigger configuration.