ATLAS Offline Software
TrigConfCoolHLTPayloadConverters.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "CoolKernel/Record.h"
9 #include "CoolKernel/IFolder.h"
10 #include "CoralBase/Attribute.h"
11 #include "CoralBase/AttributeList.h"
12 
14 
22 
23 using namespace std;
24 using namespace cool;
25 using namespace TrigConf;
26 
27 Record
28 TrigConfCoolHLTPayloadConverters::createHltMenuPayload(cool::IFolderPtr fld, const HLTChain & ch, const string& concise ) {
29  Record payload(fld->payloadSpecification());
30  payload["ChainName"] .setValue<cool::String255>(ch.chain_name());
31  payload["ChainVersion"] .setValue<cool::UInt32>(ch.chain_version());
32  payload["ChainCounter"] .setValue<cool::UInt32>(ch.chain_counter());
33  payload["TriggerLevel"] .setValue<cool::String255>(ch.level());
34  payload["Prescale"] .setValue<cool::Float>(ch.prescale());
35  payload["PassThrough"] .setValue<cool::Float>(ch.pass_through());
36  payload["TriggerElements"].setValue<cool::String4k>(concise);
37  if(payload["LowerChainName"].storageType()==cool::StorageType::String4k) {
38  payload["LowerChainName"].setValue<cool::String4k>(ch.lower_chain_name());
39  } else {
40  payload["LowerChainName"].setValue<cool::String255>(ch.lower_chain_name());
41  }
42 
43  // stream info
44  stringstream streamCat;
45  bool first(true);
46  for(HLTStreamTag* stream : ch.streams()) {
47  if(first) { first = false; } else { streamCat << ";"; }
48  streamCat << stream->stream() << "," << stream->type() << "," << stream->prescale();
49  }
50  payload["StreamInfo"].setValue<cool::String255>(streamCat.str());
51 
52  return payload;
53 }
54 
55 
56 Record
58  Record payload(fld->payloadSpecification());
59  string groups(ch.level());
60  groups += ";";
61  bool start(true);
62  for(const string& group : ch.groups()) {
63  if(start) { start=false; } else { groups += ","; }
64  groups += group;
65  }
66  payload["Groups"].setValue<cool::String4k>(groups);
67  payload["ChainCounter"].setValue<cool::UInt32>(ch.chain_counter());
68  return payload;
69 }
70 
71 
72 Record
74  uint hltPrescaleKey, const string& configSource ) {
75  Record payload(fld->payloadSpecification());
76  payload["MasterConfigurationKey"].setValue<cool::UInt32>(masterKey);
77  payload["HltPrescaleConfigurationKey"].setValue<cool::UInt32>(hltPrescaleKey);
78  payload["ConfigSource"].setValue<cool::String255>(configSource);
79  return payload;
80 }
81 
82 Record
84  Record payload(fld->payloadSpecification());
85  payload["MonConfigKey"].setValue<cool::UInt32>(mck);
86  payload["Info"].setValue<cool::String4k>(info);
87  return payload;
88 }
89 
90 Record
92  float passthrough, float rerunprescale) {
93  Record payload(fld->payloadSpecification());
94  payload["Prescale"].setValue<cool::Float>(prescale);
95  payload["Passthrough"].setValue<cool::Float>(passthrough);
96  payload["RerunPrescale"].setValue<cool::Float>(rerunprescale);
97  return payload;
98 }
99 
100 
101 Record
103  Record payload(fld->payloadSpecification());
104  payload["HltPrescaleKey"].setValue<cool::UInt32>(psk);
105  return payload;
106 }
107 
108 
109 HLTChain *
112 
113  // this information of a chain is not in COOL:
114  // int lower_chain_counter, vector<HLTTriggerType*>& trigList
115 
116  ch->set_chain_name ( al["ChainName"]. data<cool::String255>() );
117  ch->set_chain_version ( al["ChainVersion"]. data<cool::UInt32>() );
118  ch->set_chain_counter ( al["ChainCounter"]. data<cool::UInt32>() );
119  ch->set_level ( al["TriggerLevel"]. data<cool::String255>() );
120  if( typeid(cool::UInt32) == al["Prescale"].specification().type()) {
121  ch->set_prescale ( al["Prescale"]. data<cool::UInt32>() );
122  ch->set_pass_through ( al["PassThrough"]. data<cool::UInt32>() );
123  } else if( typeid(cool::Float) == al["Prescale"].specification().type()) {
124  ch->set_prescale ( al["Prescale"]. data<cool::Float>() );
125  ch->set_pass_through ( al["PassThrough"]. data<cool::Float>() );
126  }
127  if(al["LowerChainName"].specification().type()==typeid(cool::String4k)) {
128  ch->set_lower_chain_name( al["LowerChainName"].data<cool::String4k>() );
129  } else {
130  ch->set_lower_chain_name( al["LowerChainName"].data<cool::String255>() );
131  }
132  // read the trigger elements
133  string fullTeString = al["TriggerElements"].data<cool::String4k>();
134 
135  if(fullTeString.find("|")==string::npos ) {
136  // old style
137  int sc(0); // signature counter
138  vector<string> singleSigStrings = split(fullTeString,";");
139  for(const string& sigdef : singleSigStrings ) {
140  if(sigdef=="") { ++sc; continue; } // empty signature (when signaturCounter is not continuious)
141  // the information available in the signature will be the signature counter and the list of TEs
142  HLTSignature * signature = new HLTSignature();
143  ch->signatureList().push_back(signature);
144  signature->set_signature_counter(++sc);
145 
146  vector<string> teStrings = split(sigdef,",");
147  for( const string& te : teStrings) {
148  HLTTriggerElement * outte = new HLTTriggerElement( te );
149  signature->outputTEs().push_back( outte );
150  if(sequences && !sequences->hasTE(te) )
151  sequences->addHLTSequence(new HLTSequence( vector<HLTTriggerElement*>(), outte, vector<string>()) );
152  }
153  }
154  } else {
155 
156  // new style
157  vector<string> singleSigStrings = split(fullTeString,"|");
158  if(singleSigStrings.size()==2) {
159 
160  // the part in front of the '|'
161  vector< string > splitRecursive = HLTTEUtils::splitGroups( singleSigStrings[0] );
162  for( string outtename : splitRecursive ) {
163  if(outtename.find(',')!=string::npos)
164  outtename.erase(0,outtename.rfind(',')+1);
165 
166  if(sequences && !sequences->hasTE(outtename)) {
167  HLTSequence* seq = HLTTEUtils::buildSequence( outtename );
168  sequences->addHLTSequence( seq );
169  }
170  }
171 
172  // the part after the '|'
173  int sc(0); // signature counter
174  vector<string> signatureDesc = split(singleSigStrings[1],";");
175  for(const string& sigdef : signatureDesc) {
176  if(sigdef=="") { sc++; continue; } // empty signature (when signaturCounter is not continous)
177  // the information available in the signature will be the signature counter and the list of TEs
178  HLTSignature * signature = new HLTSignature();
179  ch->signatureList().push_back(signature);
180  signature->set_signature_counter(++sc);
181 
182  vector<string> sequenceDescriptions = HLTTEUtils::splitGroups(sigdef);
183  for(string outtename : sequenceDescriptions) {
184 
185  if(outtename.find(',') != string::npos)
186  outtename.erase(0,outtename.rfind(',')+1);
187 
188  HLTTriggerElement * outte = new HLTTriggerElement( outtename );
189  signature->outputTEs().push_back( outte );
190  if(sequences && !sequences->hasTE(outtename)) {
191  HLTSequence* seq = HLTTEUtils::buildSequence(outtename);
192  sequences->addHLTSequence( seq );
193  }
194  }
195  }
196  }
197  } // new style
198 
199  // read the stream tag info
200  string fullStreamString = al["StreamInfo"].data<cool::String255>();
201  vector<string> singleStreams = split( fullStreamString, ";" );
202 
203  for( const string& stream_def : singleStreams ) {
204  HLTStreamTag * stream = new HLTStreamTag();
205  vector<string> streamInfo = split(stream_def,",");
206  if(streamInfo.size()==2) {
207  stream->set_stream(streamInfo[0]); // old version: name,prescale
208  stream->set_prescale(atoi(streamInfo[1].c_str()));
209  } else if(streamInfo.size()==3) { // new version: name,type,version
210  stream->set_stream(streamInfo[0]);
211  stream->set_type(streamInfo[1]);
212  stream->set_prescale(atoi(streamInfo[2].c_str()));
213  }
214  ch->addStream(stream);
215  }
216 
217  return ch;
218 }
219 
220 
221 void
223  const HLTChainList& chl)
224 {
225  int cc = al["ChainCounter"].data<cool::UInt32>();
226  vector<string> lvlGrp = split(al["Groups"].data<cool::String4k>(),";");
227  string level = lvlGrp[0];
228  if(lvlGrp.size()==2) {
229  vector<string> grV = split(lvlGrp[1],",");
230  for(HLTChain* ch : chl) {
231  if( ch->chain_counter()==cc && ch->level()==level) {
232  for(const string& gr : grV) ch->addGroup(gr);
233  break;
234  }
235  }
236  }
237 }
238 
239 
240 void
242  unsigned int & hltPrescaleKey, string & configSource)
243 {
244  masterConfigKey = al["MasterConfigurationKey"].data<cool::UInt32>();
245  hltPrescaleKey = al["HltPrescaleConfigurationKey"].data<cool::UInt32>();
246  configSource = al["ConfigSource"].data<cool::String255>();
247 }
248 
249 
250 void
252  float& ps, float& pt, float& rrps)
253 {
254  ps = al["Prescale"].data<cool::Float>();
255  pt = al["Passthrough"].data<cool::Float>();
256  rrps = al["RerunPrescale"].data<cool::Float>();
257 }
258 
259 
260 int
262 {
263  return al["HltPrescaleKey"].data<cool::UInt32>();
264 }
265 
grepfile.info
info
Definition: grepfile.py:38
test_athena_ntuple_filter.seq
seq
filter configuration ## -> we use the special sequence 'AthMasterSeq' which is run before any other a...
Definition: test_athena_ntuple_filter.py:18
TrigConf::TrigConfCoolHLTPayloadConverters::createHltPrescaleKeyPayload
cool::Record createHltPrescaleKeyPayload(cool::IFolderPtr, int psk)
build a COOL db record from a HLT prescale value
Definition: TrigConfCoolHLTPayloadConverters.cxx:102
ChainDefInMenu.groups
groups
Definition: ChainDefInMenu.py:44
TrigConf::HLTSequenceList::addHLTSequence
void addHLTSequence(HLTSequence *sequence)
adds an HLTSequence to the menu
Definition: HLTSequenceList.cxx:30
TrigConf::HLTSequenceList::hasTE
bool hasTE(const std::string &name)
Definition: HLTSequenceList.cxx:39
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
HLTChainList.h
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
TrigConf::TrigConfCoolHLTPayloadConverters::readHltPrescaleKey
int readHltPrescaleKey(const coral::AttributeList &al)
build the HLT prescale key from a COOL db record
Definition: TrigConfCoolHLTPayloadConverters.cxx:261
HLTChain.h
test_pyathena.pt
pt
Definition: test_pyathena.py:11
gr
#define gr
TrigConf::TrigConfCoolHLTPayloadConverters::createHltPrescalesPayload
cool::Record createHltPrescalesPayload(cool::IFolderPtr, float prescale, float passthrough, float rerunprescale)
build a COOL db record from a HLT prescale value
Definition: TrigConfCoolHLTPayloadConverters.cxx:91
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
TrigConf::HLTChain
HLT chain configuration information.
Definition: TrigConfHLTData/TrigConfHLTData/HLTChain.h:35
TrigConf::TrigConfCoolHLTPayloadConverters::createHltChainGroupPayload
cool::Record createHltChainGroupPayload(cool::IFolderPtr, const TrigConf::HLTChain &ch)
build a COOL db record from a HLT chain
Definition: TrigConfCoolHLTPayloadConverters.cxx:57
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
trigbs_dumpPrescaleBits.HLTChain
HLTChain
Definition: trigbs_dumpPrescaleBits.py:41
HelperFunctions.h
cool
Definition: CoolTagInfo.h:12
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
HLTUtils.h
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
TrigConf::HLTSignature
HLT signature configuration information.
Definition: HLTSignature.h:29
TrigConf::TrigConfCoolHLTPayloadConverters::createHLTChain
HLTChain * createHLTChain(const coral::AttributeList &al, TrigConf::HLTSequenceList *sequences=0)
build an HLT chain from a COOL db record
Definition: TrigConfCoolHLTPayloadConverters.cxx:110
TrigConf::HLTChainList
list of all HLT chains in a trigger menu
Definition: HLTChainList.h:56
HLTStreamTag.h
HLTSignature.h
TrigConf::TrigConfCoolHLTPayloadConverters::createHltMenuPayload
cool::Record createHltMenuPayload(cool::IFolderPtr, const TrigConf::HLTChain &, const std::string &concise)
build a COOL db record from a HLT chain
Definition: TrigConfCoolHLTPayloadConverters.cxx:28
TrigConf::HLTSignature::set_signature_counter
void set_signature_counter(unsigned int sc)
Definition: HLTSignature.h:64
TrigConf::TrigConfCoolHLTPayloadConverters::createHltConfigKeysPayload
cool::Record createHltConfigKeysPayload(cool::IFolderPtr, unsigned int masterKey, unsigned int hltPrescaleKey, const std::string &configSource)
build a COOL db record from a set of HLT configuration keys
Definition: TrigConfCoolHLTPayloadConverters.cxx:73
Record
Definition: HephProf.cxx:56
TrigConf::TrigConfCoolHLTPayloadConverters::createMonConfigKeyPayload
cool::Record createMonConfigKeyPayload(cool::IFolderPtr fld, uint MCK, std::string &info)
build a COOL db record from a HLT monitoring configuration key
Definition: TrigConfCoolHLTPayloadConverters.cxx:83
TrigConf::HLTSignature::outputTEs
std::vector< HLTTriggerElement * > & outputTEs()
accessor to the list of trigger elements
Definition: HLTSignature.h:60
LArConditions2Ntuple.fld
string fld
Definition: LArConditions2Ntuple.py:283
TrigConf::HLTTriggerElement
HLT trigger element configuration information.
Definition: HLTTriggerElement.h:26
HLTTriggerElement.h
TrigConf::HLTStreamTag
HLT stream configuration information.
Definition: HLTStreamTag.h:23
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
TrigConfCoolHLTPayloadConverters.h
TrigConf::TrigConfCoolHLTPayloadConverters::addGroupsToHltChain
void addGroupsToHltChain(const coral::AttributeList &al, const TrigConf::HLTChainList &chl)
add the groups to and HLT chain from a AttributeList
Definition: TrigConfCoolHLTPayloadConverters.cxx:222
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
HLTSequenceList.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DeMoScan.first
bool first
Definition: DeMoScan.py:534
TrigConfCoolFolderSpec.h
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
TrigConf::TrigConfCoolHLTPayloadConverters::readHltPrescale
void readHltPrescale(const coral::AttributeList &al, float &ps, float &pt, float &rrps)
build the HLT prescale value from a COOL db record
Definition: TrigConfCoolHLTPayloadConverters.cxx:251
TrigConf::TrigConfCoolHLTPayloadConverters::readHltConfigKeys
void readHltConfigKeys(const coral::AttributeList &al, unsigned int &masterConfigKey, unsigned int &hltPrescaleKey, std::string &configSource)
read the HLT configuration keys from a coral::AttributeList
Definition: TrigConfCoolHLTPayloadConverters.cxx:241
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.handimod.cc
int cc
Definition: handimod.py:523
TrigConf::HLTSequence
HLT sequence configuration information.
Definition: HLTSequence.h:28
TrigConf::HLTSequenceList
list of HLT sequences
Definition: HLTSequenceList.h:40