ATLAS Offline Software
PrescaleSet.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 
9 #include <iostream>
10 #include <iomanip>
11 #include <math.h>
12 
13 using namespace std;
14 using namespace TrigConf;
15 
16 //const unsigned int PrescaleSet::N_PRESCALES = 256;
17 
18 const int32_t PrescaleSet::maxPrescaleCut = 0xFFFFFF; //2**24 - 1
19 
32 int32_t
34  int32_t sign = prescale<0 ? -1 : 1;
35  double uprescale = fabs(prescale);
36  return sign * ( 0x1000000 - int32_t(0xFFFFFF/uprescale));
37 }
38 
51 double
53  double sign = cut<0 ? -1 : 1;
54  uint32_t ucut = abs(cut);
55  return (sign * 0xFFFFFF ) / ( 0x1000000 - ucut );
56 }
57 
58 
61  m_null(true),
62  m_newPrescales(true),
63  m_Type("Physics"),
64  m_Partition(0),
65  m_Prescales(),
66  m_Prescales_ctp(),
67  m_Prescales_float(),
68  m_Cuts()
69 {}
70 
72  for(auto& x: m_Prescales) x=-1;
73  for(auto& x: m_Prescales_ctp) x=-1;
74  for(auto& x: m_Prescales_float) x=-1;
75  for(auto& x: m_Cuts) x=-maxPrescaleCut;
76  m_null = true;
77 }
78 
79 void
81  m_Prescales.resize(size,-1);
82  m_Prescales_ctp.resize(size,-1);
83  m_Prescales_float.resize(size,-1);
84  m_Cuts.resize(size,2<<10);
85  //m_Cuts.resize(size,-maxPrescaleCut);
86 }
87 
88 void
89 TrigConf::PrescaleSet::setCuts(const std::vector<int32_t>& cuts) {
90  for(unsigned int ctpid = 0; ctpid < cuts.size(); ++ctpid )
91  setCut(ctpid, cuts[ctpid]);
92 }
93 
94 
95 void
96 TrigConf::PrescaleSet::setCut(unsigned int ctpid, int32_t cut) {
97  m_Cuts[ctpid] = cut;
98 
99  float ps_f = getPrescaleFromCut(cut);
100  m_Prescales_float[ctpid] = ps_f;
101 
102  int sign = ps_f<0 ? -1 : 1;
103  int ps = sign * int(fabs(ps_f)+0.5);
104 
105  m_Prescales[ctpid] = ps;
106 
107  m_null = false;
108 }
109 
110 
114 void
115 TrigConf::PrescaleSet::setPrescales(const std::vector<int64_t>& prescales) {
116  m_Prescales_ctp = prescales;
118  unsigned int i(0);
119  for (auto ps: m_Prescales_ctp) {
120  l1ps = TrigConf::L1PSNumber(ps);
121  m_Prescales[i] = l1ps.getInt32();
122  m_Prescales_float[i] = l1ps.getFloatPrescale();
123  i++;
124  }
125  m_null = false;
126 }
127 
131 void
132 TrigConf::PrescaleSet::setPrescales(const int64_t p[], const unsigned int size) {
134  for (unsigned int i = 0; i < size; ++i) {
135  m_Prescales_ctp[i] = p[i];
136  l1ps = TrigConf::L1PSNumber(p[i]);
137  m_Prescales[i] = l1ps.getInt32();
138  m_Prescales_float[i] = l1ps.getFloatPrescale();
139  }
140  m_null = false;
141 }
142 
143 
149 void TrigConf::PrescaleSet::setPrescales(const int p[], const unsigned int size) {
151  for (unsigned int i = 0; i < size; i++) {
152  m_Prescales_ctp[i] = (int64_t) p[i];
153  l1ps = TrigConf::L1PSNumber((int64_t)p[i]);
154  m_Prescales[i] = l1ps.getInt32();
155  m_Prescales_float[i] = l1ps.getFloatPrescale();
156  }
157  m_null = false;
158 }
159 
165 void
166 TrigConf::PrescaleSet::setPrescale(unsigned int num, int64_t prescaleValue) {
167  TrigConf::L1PSNumber l1ps = TrigConf::L1PSNumber(prescaleValue);
168  m_Prescales[num] = l1ps.getInt32();
169  m_Prescales_ctp[num] = prescaleValue;
170  m_Prescales_float[num] = l1ps.getFloatPrescale();
171  m_null = false;
172 }
173 
177 void
178 TrigConf::PrescaleSet::setPrescale(unsigned int num, int prescaleValue) {
179  m_Prescales_ctp[num] = (int64_t) prescaleValue;
180  TrigConf::L1PSNumber l1ps = TrigConf::L1PSNumber((int64_t)prescaleValue);
181  m_Prescales[num] = l1ps.getInt32();
182  m_Prescales_float[num] = l1ps.getFloatPrescale();
183  m_null = false;
184 }
185 
186 void
187 TrigConf::PrescaleSet::setPrescale(unsigned int num, float prescaleValue) {
188  int32_t cut = getCutFromPrescale(prescaleValue);
189  m_Prescales[num] = cut;
190  m_Prescales_ctp[num] = cut;
191  m_Prescales_float[num] = prescaleValue;
192  m_null = false;
193 }
194 
195 
196 void
197 TrigConf::PrescaleSet::print(const std::string& indent, unsigned int detail) const {
198  if(detail>=1) {
199  cout << indent << "PrescaleSet ";
200  printNameIdV("");
201  if(detail>=3) {
202  int i(0);
203  for( auto ps: m_Prescales_float)
204  cout << indent << " ctpid=" << i++ << ": " << " prescale=" << ps << endl;
205  }
206  }
207 }
208 
212 void
213 TrigConf::PrescaleSet::writeXML(std::ostream & xmlfile, int indentLevel, int indentWidth) const {
214  L1PSNumber psOut;
215  indent(xmlfile, indentLevel, indentWidth)
216  << "<PrescaleSet"
217  << " name=\"" << name() << "\""
218  << " type=\"" << type() << "\""
219  << " menuPartition=\"" << partition() << "\">"
220  << endl;
221 
222  if(newPrescaleStyle()) {
223  int ctpid(0);
224  for (int32_t cut: m_Cuts) {
225  indent(xmlfile, indentLevel + 1, indentWidth)
226  << "<Prescale ctpid=\"" << ctpid++
227  << "\" cut=\"" << (cut<0?"-":"") << hex << setfill('0') << setw(6) << abs(cut) << setfill(' ') << dec
228  << "\" value=\"" << getPrescaleFromCut(cut)
229  << "\"/>" << endl;
230  }
231  } else {
232  int i(0);
233  for (auto& ps: m_Prescales_ctp) {
234  psOut = L1PSNumber(ps);
235  indent(xmlfile, indentLevel + 1, indentWidth)
236  << "<Prescale ctpid=\"" << i++ << "\" ps=\"" << psOut.write() << "\"/>" << endl;
237  }
238  }
239  indent(xmlfile, indentLevel, indentWidth)
240  << "</PrescaleSet>" << endl;
241 }
PrescaleSet.h
TrigConf::L1PSNumber::getFloatPrescale
float getFloatPrescale() const
Definition: L1PSNumber.h:76
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
TrigConf::PrescaleSet::setCuts
void setCuts(const std::vector< int32_t > &cuts)
Definition: PrescaleSet.cxx:89
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TrigConf::PrescaleSet::print
virtual void print(const std::string &indent="", unsigned int detail=1) const override
Definition: PrescaleSet.cxx:197
TrigConf::PrescaleSet::writeXML
void writeXML(std::ostream &xmlfile, int indentLevel=0, int indentWidth=2) const
Writes the Prescale item to the XML file.
Definition: PrescaleSet.cxx:213
TrigConf::PrescaleSet::resize
void resize(size_t size)
Definition: PrescaleSet.cxx:80
detail
Definition: extract_histogram_tag.cxx:14
python.TrigConfigSvcUtils.getPrescaleFromCut
def getPrescaleFromCut(cut)
Definition: TrigConfigSvcUtils.py:761
TrigConf::PrescaleSet::PrescaleSet
PrescaleSet()
Definition: PrescaleSet.cxx:59
x
#define x
RatesAnalysisFullMenu.prescales
prescales
Definition: RatesAnalysisFullMenu.py:119
python.L1.Base.PrescaleHelper.maxPrescaleCut
maxPrescaleCut
Definition: PrescaleHelper.py:22
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
geometry_dat_to_json.indent
indent
Definition: geometry_dat_to_json.py:18
lumiFormat.i
int i
Definition: lumiFormat.py:92
L1PSNumber.h
TrigConf::PrescaleSet::setPrescale
void setPrescale(unsigned int num, int64_t prescaleValue) __attribute__((deprecated))
Set the prescale NUM from the int64 value prescaleValue.
Definition: PrescaleSet.cxx:166
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
plotBeamSpotVert.cuts
string cuts
Definition: plotBeamSpotVert.py:93
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:127
TrigConf::L1PSNumber
Definition: L1PSNumber.h:33
TrigConf::PrescaleSet::setCut
void setCut(unsigned int num, int32_t cut)
Definition: PrescaleSet.cxx:96
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
TrigConf::L1PSNumber::write
std::string write()
Writes nicely the ps value.
Definition: L1PSNumber.cxx:153
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
python.L1.Base.PrescaleHelper.getCutFromPrescale
def getCutFromPrescale(prescale)
Definition: PrescaleHelper.py:24
TrigConf::PrescaleSet::setPrescales
void setPrescales(const std::vector< int64_t > &) __attribute__((deprecated))
DEPRECATED.
Definition: PrescaleSet.cxx:115
TrigConf::L1DataBaseclass
Definition: L1DataBaseclass.h:22
TrigConf::L1PSNumber::getInt32
int getInt32() const
Definition: L1PSNumber.h:78
TrigConf::PrescaleSet::reset
void reset()
Definition: PrescaleSet.cxx:71