Skip to content

Commit

Permalink
Modify L1TGlobal menu code and CondFormats to remove reinterpret_cast…
Browse files Browse the repository at this point in the history
… to and from utm firmware "es" types
  • Loading branch information
aloeliger committed Mar 11, 2023
1 parent 3d761d8 commit 6b6abc0
Show file tree
Hide file tree
Showing 12 changed files with 569 additions and 139 deletions.
2 changes: 2 additions & 0 deletions CondFormats/L1TObjects/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<use name="CondFormats/External"/>
<use name="DataFormats/L1CaloTrigger"/>
<use name="FWCore/MessageLogger"/>
<use name="xerces-c"/>
<use name="utm"/>
<export>
<lib name="1"/>
</export>
Expand Down
29 changes: 29 additions & 0 deletions CondFormats/L1TObjects/interface/L1TUtmAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <string>
#include <vector>
#include "CondFormats/Serialization/interface/Serializable.h"
#include "tmEventSetup/esAlgorithm.hh"

/**
* This class implements data structure for Algorithm
Expand All @@ -29,6 +30,34 @@ class L1TUtmAlgorithm {
module_id_(),
module_index_(),
version(0){};
L1TUtmAlgorithm(std::string name,
std::string expression,
std::string expression_in_condition,
std::vector<std::string> rpn_vector,
unsigned int index,
unsigned int module_id,
unsigned int module_index,
unsigned int ver)
: name_(name),
expression_(expression),
expression_in_condition_(expression_in_condition),
rpn_vector_(rpn_vector),
index_(index),
module_id_(module_id),
module_index_(module_index),
version(ver){};

L1TUtmAlgorithm(tmeventsetup::esAlgorithm esAlg)
: L1TUtmAlgorithm(
esAlg.getName(),
esAlg.getExpression(),
esAlg.getExpressionInCondition(),
esAlg.getRpnVector(),
esAlg.getIndex(),
esAlg.getModuleId(),
esAlg.getModuleIndex(),
0 //There is no version retrieval in esAlgorithm. However, it seems pretty hard coded to 0 TODO: check this.
){};

virtual ~L1TUtmAlgorithm() = default;

Expand Down
3 changes: 3 additions & 0 deletions CondFormats/L1TObjects/interface/L1TUtmBin.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <limits>
#include "CondFormats/Serialization/interface/Serializable.h"
#include "tmEventSetup/esBin.hh"

/**
* This class implements data structure for Bin
Expand All @@ -27,6 +28,8 @@ class L1TUtmBin {
L1TUtmBin(const unsigned int id, const double min, const double max)
: hw_index(id), minimum(min), maximum(max), version(0){};

L1TUtmBin(tmeventsetup::esBin bin) : L1TUtmBin(bin.hw_index, bin.minimum, bin.maximum){};

virtual ~L1TUtmBin() = default;

unsigned int hw_index; /**< HW index of bin */
Expand Down
14 changes: 14 additions & 0 deletions CondFormats/L1TObjects/interface/L1TUtmCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "CondFormats/L1TObjects/interface/L1TUtmObject.h"
#include "CondFormats/Serialization/interface/Serializable.h"

#include "tmEventSetup/esCondition.hh"

#include <string>
#include <vector>

Expand All @@ -23,6 +25,18 @@
class L1TUtmCondition {
public:
L1TUtmCondition() : name_(), type_(-9999), objects_(), cuts_(), version(0){};
L1TUtmCondition(
std::string name, int type, std::vector<L1TUtmObject> objects, std::vector<L1TUtmCut> cuts, unsigned int vers)
: name_(name), type_(type), objects_(objects), cuts_(cuts), version(vers){};

L1TUtmCondition(tmeventsetup::esCondition esCond) : name_(esCond.getName()), type_(esCond.getType()), version(0) {
objects_.reserve(esCond.getObjects().size());
for (auto it = esCond.getObjects().begin(); it != esCond.getObjects().end(); ++it)
objects_.emplace_back(L1TUtmObject(*it));
cuts_.reserve(esCond.getCuts().size());
for (auto it = esCond.getCuts().begin(); it != esCond.getCuts().end(); ++it)
cuts_.emplace_back(L1TUtmCut(*it));
};

virtual ~L1TUtmCondition() = default;

Expand Down
28 changes: 28 additions & 0 deletions CondFormats/L1TObjects/interface/L1TUtmCut.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "CondFormats/L1TObjects/interface/L1TUtmCutValue.h"
#include "CondFormats/Serialization/interface/Serializable.h"

#include "tmEventSetup/esCut.hh"

#include <string>

/**
Expand All @@ -21,6 +23,32 @@
class L1TUtmCut {
public:
L1TUtmCut() : name_(), object_type_(), cut_type_(), minimum_(), maximum_(), data_(), key_(), version(0){};
L1TUtmCut(std::string name,
int object_type,
int cut_type,
L1TUtmCutValue minimum,
L1TUtmCutValue maximum,
std::string data,
std::string key,
unsigned int vers)
: name_(name),
object_type_(object_type),
cut_type_(cut_type),
minimum_(minimum),
maximum_(maximum),
data_(data),
key_(key),
version(vers){};

L1TUtmCut(tmeventsetup::esCut esC)
: L1TUtmCut(esC.getName(),
esC.getObjectType(),
esC.getCutType(),
L1TUtmCutValue(esC.getMinimum()),
L1TUtmCutValue(esC.getMaximum()),
esC.getData(),
esC.getKey(),
0){};

virtual ~L1TUtmCut() = default;

Expand Down
2 changes: 2 additions & 0 deletions CondFormats/L1TObjects/interface/L1TUtmCutValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@

#include <limits>
#include "CondFormats/Serialization/interface/Serializable.h"
#include "tmEventSetup/esCutValue.hh"

/**
* This class implements data structure for CutValue
*/
struct L1TUtmCutValue {
L1TUtmCutValue()
: value(std::numeric_limits<double>::max()), index(std::numeric_limits<unsigned int>::max()), version(0){};
L1TUtmCutValue(tmeventsetup::esCutValue esCV) : value(esCV.value), index(esCV.index), version(esCV.version){};

virtual ~L1TUtmCutValue() = default;

Expand Down
34 changes: 34 additions & 0 deletions CondFormats/L1TObjects/interface/L1TUtmObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "CondFormats/L1TObjects/interface/L1TUtmCut.h"
#include "CondFormats/Serialization/interface/Serializable.h"

#include "tmEventSetup/esObject.hh"

#include <limits>
#include <string>
#include <vector>
Expand All @@ -32,6 +34,38 @@ class L1TUtmObject {
ext_channel_id_(std::numeric_limits<unsigned int>::max()),
cuts_(),
version(0){};
L1TUtmObject(std::string name,
int type,
int comparison_operator,
int bx_offset,
double threshold,
std::string ext_signal_name,
unsigned int ext_channel_id,
std::vector<L1TUtmCut> cuts,
unsigned int vers)
: name_(name),
type_(type),
comparison_operator_(comparison_operator),
bx_offset_(bx_offset),
threshold_(threshold),
ext_signal_name_(ext_signal_name),
ext_channel_id_(ext_channel_id),
cuts_(cuts),
version(vers){};

L1TUtmObject(tmeventsetup::esObject esObj)
: name_(esObj.getName()),
type_(esObj.getType()),
comparison_operator_(esObj.getComparisonOperator()),
bx_offset_(esObj.getBxOffset()),
threshold_(esObj.getThreshold()),
ext_signal_name_(esObj.getExternalSignalName()),
ext_channel_id_(esObj.getExternalChannelId()),
version(0) {
cuts_.reserve(esObj.getCuts().size());
for (auto it = esObj.getCuts().begin(); it != esObj.getCuts().end(); ++it)
cuts_.emplace_back(L1TUtmCut(*it));
};

virtual ~L1TUtmObject() = default;

Expand Down
35 changes: 35 additions & 0 deletions CondFormats/L1TObjects/interface/L1TUtmScale.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "CondFormats/L1TObjects/interface/L1TUtmBin.h"
#include "CondFormats/Serialization/interface/Serializable.h"

#include "tmEventSetup/esScale.hh"

#include <map>
#include <string>
#include <vector>
Expand All @@ -24,6 +26,39 @@ class L1TUtmScale {
public:
L1TUtmScale() : name_(), object_(), type_(), minimum_(), maximum_(), step_(), n_bits_(), bins_(), version(0){};

L1TUtmScale(std::string name,
int object,
int type,
double minimum,
double maximum,
double step,
unsigned int n_bits,
std::vector<L1TUtmBin> bins,
unsigned int vers)
: name_(name),
object_(object),
type_(type),
minimum_(minimum),
maximum_(maximum),
step_(step),
n_bits_(n_bits),
bins_(bins),
version(vers){};

L1TUtmScale(tmeventsetup::esScale esSc)
: name_(esSc.getName()),
object_(esSc.getObjectType()),
type_(esSc.getScaleType()),
minimum_(esSc.getMinimum()),
maximum_(esSc.getMaximum()),
step_(esSc.getStep()),
n_bits_(esSc.getNbits()),
version(0) {
bins_.reserve(esSc.getBins().size());
for (auto it = esSc.getBins().begin(); it != esSc.getBins().end(); ++it)
bins_.emplace_back(L1TUtmBin(*it));
};

virtual ~L1TUtmScale() = default;

/** get scale name */
Expand Down
49 changes: 49 additions & 0 deletions CondFormats/L1TObjects/interface/L1TUtmTriggerMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "CondFormats/L1TObjects/interface/L1TUtmAlgorithm.h"
#include "CondFormats/Serialization/interface/Serializable.h"

#include "tmEventSetup/esTriggerMenu.hh"

#include <map>
#include <string>

Expand All @@ -38,6 +40,53 @@ class L1TUtmTriggerMenu {
scale_set_name_(),
n_modules_(),
version(0){};
L1TUtmTriggerMenu(std::map<std::string, L1TUtmAlgorithm> algorithm_map,
std::map<std::string, L1TUtmCondition> condition_map,
std::map<std::string, L1TUtmScale> scale_map,
//std::map<std::string, unsigned int> external_map,
//std::map<std::string, std::string> token_to_condition,
std::string name,
std::string ver_s,
std::string comment,
std::string datetime,
std::string uuid_firmware,
std::string scale_set_name,
unsigned int n_modules,
unsigned int ver_i)
: algorithm_map_(algorithm_map),
condition_map_(condition_map),
scale_map_(scale_map),
//external_map_(external_map),
external_map_(),
//token_to_condition_(token_to_condition),
token_to_condition_(),
name_(name),
version_(ver_s),
comment_(comment),
datetime_(datetime),
uuid_firmware_(uuid_firmware),
scale_set_name_(scale_set_name),
n_modules_(n_modules),
version(ver_i){};

L1TUtmTriggerMenu(tmeventsetup::esTriggerMenu esMenu)
: external_map_(), //These are null to my best knowledge
token_to_condition_(), //These are null to my best knowledge
name_(esMenu.getName()),
version_(esMenu.getVersion()),
comment_(esMenu.getComment()),
datetime_(esMenu.getDatetime()),
uuid_firmware_(esMenu.getFirmwareUuid()),
scale_set_name_(esMenu.getScaleSetName()),
n_modules_(esMenu.getNmodules()),
version(0) {
for (auto it = esMenu.getAlgorithmMap().begin(); it != esMenu.getAlgorithmMap().end(); ++it)
algorithm_map_.emplace(std::make_pair(it->first, L1TUtmAlgorithm(it->second)));
for (auto it = esMenu.getConditionMap().begin(); it != esMenu.getConditionMap().end(); ++it)
condition_map_.emplace(std::make_pair(it->first, L1TUtmCondition(it->second)));
for (auto it = esMenu.getScaleMap().begin(); it != esMenu.getScaleMap().end(); ++it)
scale_map_.emplace(std::make_pair(it->first, L1TUtmScale(it->second)));
};

virtual ~L1TUtmTriggerMenu() = default;

Expand Down
8 changes: 4 additions & 4 deletions L1Trigger/L1TGlobal/plugins/L1TUtmTriggerMenuESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ L1TUtmTriggerMenuESProducer::~L1TUtmTriggerMenuESProducer() {

// ------------ method called to produce the data ------------
L1TUtmTriggerMenuESProducer::ReturnType L1TUtmTriggerMenuESProducer::produce(const L1TUtmTriggerMenuRcd& iRecord) {
//const L1TUtmTriggerMenu * cmenu = reinterpret_cast<const L1TUtmTriggerMenu *>(tmeventsetup::getTriggerMenu("/afs/cern.ch/user/t/tmatsush/public/tmGui/test-menu.xml"));
const L1TUtmTriggerMenu* cmenu =
reinterpret_cast<const L1TUtmTriggerMenu*>(tmeventsetup::getTriggerMenu(m_L1TriggerMenuFile));
return ReturnType(cmenu);
const tmeventsetup::esTriggerMenu* theEsMenu = tmeventsetup::getTriggerMenu(m_L1TriggerMenuFile);
auto l1Menu = L1TUtmTriggerMenu(*theEsMenu);
delete theEsMenu;
return make_unique<const L1TUtmTriggerMenu>(l1Menu);
}

//define this as a plug-in
Expand Down

0 comments on commit 6b6abc0

Please sign in to comment.