Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions L1Trigger/L1TGlobal/interface/GlobalDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ namespace l1t {
TypeZDCP,
TypeZDCM,
TypeAXOL1TL,
TypeTOPO,
TypeCICADA,
GtConditionTypeInvalid = -1
};
Expand All @@ -108,6 +109,7 @@ namespace l1t {
CondMuonShower,
CondEnergySumZdc,
CondAXOL1TL,
CondTOPO,
CondCICADA,
GtConditionCategoryInvalid = -1
};
Expand Down
91 changes: 91 additions & 0 deletions L1Trigger/L1TGlobal/interface/TOPOCondition.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#ifndef L1Trigger_L1TGlobal_TOPOCondition_h
#define L1Trigger_L1TGlobal_TOPOCondition_h

/**
* \class TOPOCondition
*
* Description: evaluation of a CondTOPO condition.
*/

#include <iosfwd>
#include <string>
#include <utility>

#include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h"
#include "DataFormats/L1Trigger/interface/L1Candidate.h"

#include "hls4ml/emulator.h"

// forward declarations
class GlobalCondition;
class TOPOTemplate;

namespace l1t {

class L1Candidate;
class GlobalBoard;

// class declaration
class TOPOCondition : public ConditionEvaluation {
public:
/// constructors
/// default
TOPOCondition();

/// from base template condition (from event setup usually)
TOPOCondition(const GlobalCondition*, const GlobalBoard*);

// copy constructor
TOPOCondition(const TOPOCondition&);
// destructor
~TOPOCondition() override;

// assign operator
TOPOCondition& operator=(const TOPOCondition&);

/// the core function to check if the condition matches
const bool evaluateCondition(const int bxEval) const override;

/// print condition
void print(std::ostream& myCout) const override;

/// get / set the pointer to a Condition
inline const TOPOTemplate* gtTOPOTemplate() const { return m_gtTOPOTemplate; }

void setGtTOPOTemplate(const TOPOTemplate*);

/// get / set the pointer to GTL
inline const GlobalBoard* gtGTB() const { return m_gtGTB; }

void setuGtB(const GlobalBoard*);

/// get/set score value
void setScore(const float scoreval) const;

inline float getScore() const { return m_savedscore; }

void loadModel();

inline hls4mlEmulator::ModelLoader const& model_loader() const { return m_model_loader; }

private:
/// copy function for copy constructor and operator=
void copy(const TOPOCondition& cp);

/// pointer to a TOPOTemplate
const TOPOTemplate* m_gtTOPOTemplate;

/// pointer to uGt GlobalBoard, to be able to get the trigger objects
const GlobalBoard* m_gtGTB;

static constexpr char const* kModelNamePrefix = "topo_";

hls4mlEmulator::ModelLoader m_model_loader;
std::shared_ptr<hls4mlEmulator::Model> m_model;

///axo score for possible score saving
mutable float m_savedscore;
};

} // namespace l1t
#endif
79 changes: 79 additions & 0 deletions L1Trigger/L1TGlobal/interface/TOPOTemplate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#ifndef L1Trigger_L1TGlobal_TOPOTemplate_h
#define L1Trigger_L1TGlobal_TOPOTemplate_h

/**
* \class TOPOTemplate
*
*
* Description: L1 Global Trigger TOPO template.
*
* \author: Melissa Quinnan (UC San Diego)
*
*/

// system include files
#include <string>
#include <iosfwd>

// user include files

// base class
#include "L1Trigger/L1TGlobal/interface/GlobalCondition.h"

// forward declarations

// class declaration
class TOPOTemplate : public GlobalCondition {
public:
// constructor
TOPOTemplate();

// constructor
TOPOTemplate(const std::string&);

// constructor
TOPOTemplate(const std::string&, const l1t::GtConditionType&);

// copy constructor
TOPOTemplate(const TOPOTemplate&);

// destructor
~TOPOTemplate() override;

// assign operator
TOPOTemplate& operator=(const TOPOTemplate&);

// typedef for a single object template
struct ObjectParameter {
int minTOPOThreshold;
int maxTOPOThreshold;
};

public:
inline const std::vector<ObjectParameter>* objectParameter() const { return &m_objectParameter; }

inline const std::string& modelVersion() const { return m_modelVersion; }

/// set functions
void setConditionParameter(const std::vector<ObjectParameter>& objParameter);

void setModelVersion(const std::string& modelversion);

/// print the condition
void print(std::ostream& myCout) const override;

/// output stream operator
friend std::ostream& operator<<(std::ostream&, const TOPOTemplate&);

private:
/// copy function for copy constructor and operator=
void copy(const TOPOTemplate& cp);

/// variables containing the parameters
std::vector<ObjectParameter> m_objectParameter;

/// model version
std::string m_modelVersion;
};

#endif
8 changes: 8 additions & 0 deletions L1Trigger/L1TGlobal/interface/TriggerMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "L1Trigger/L1TGlobal/interface/EnergySumTemplate.h"
#include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h"
#include "L1Trigger/L1TGlobal/interface/AXOL1TLTemplate.h"
#include "L1Trigger/L1TGlobal/interface/TOPOTemplate.h"
#include "L1Trigger/L1TGlobal/interface/CICADATemplate.h"
#include "L1Trigger/L1TGlobal/interface/ExternalTemplate.h"
#include "L1Trigger/L1TGlobal/interface/CorrelationTemplate.h"
Expand All @@ -62,6 +63,7 @@ class TriggerMenu {
const std::vector<std::vector<EnergySumTemplate> >&,
const std::vector<std::vector<EnergySumZdcTemplate> >&,
const std::vector<std::vector<AXOL1TLTemplate> >&,
const std::vector<std::vector<TOPOTemplate> >&,
const std::vector<std::vector<CICADATemplate> >&,
const std::vector<std::vector<ExternalTemplate> >&,
const std::vector<std::vector<CorrelationTemplate> >&,
Expand Down Expand Up @@ -148,6 +150,11 @@ class TriggerMenu {

void setVecAXOL1TLTemplate(const std::vector<std::vector<AXOL1TLTemplate> >&);

//
inline const std::vector<std::vector<TOPOTemplate> >& vecTOPOTemplate() const { return m_vecTOPOTemplate; }

void setVecTOPOTemplate(const std::vector<std::vector<TOPOTemplate> >&);

//
inline const std::vector<std::vector<CICADATemplate> >& vecCICADATemplate() const { return m_vecCICADATemplate; }

Expand Down Expand Up @@ -256,6 +263,7 @@ class TriggerMenu {
std::vector<std::vector<EnergySumTemplate> > m_vecEnergySumTemplate;
std::vector<std::vector<EnergySumZdcTemplate> > m_vecEnergySumZdcTemplate;
std::vector<std::vector<AXOL1TLTemplate> > m_vecAXOL1TLTemplate;
std::vector<std::vector<TOPOTemplate> > m_vecTOPOTemplate;
std::vector<std::vector<CICADATemplate> > m_vecCICADATemplate;

std::vector<std::vector<ExternalTemplate> > m_vecExternalTemplate;
Expand Down
1 change: 1 addition & 0 deletions L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ void L1TGlobalProducer::beginRun(edm::Run const& iRun, const edm::EventSetup& ev
gtParser.vecEnergySumTemplate(),
gtParser.vecEnergySumZdcTemplate(),
gtParser.vecAXOL1TLTemplate(),
gtParser.vecTOPOTemplate(),
gtParser.vecCICADATemplate(),
gtParser.vecExternalTemplate(),
gtParser.vecCorrelationTemplate(),
Expand Down
108 changes: 108 additions & 0 deletions L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ void l1t::TriggerMenuParser::setVecAXOL1TLTemplate(const std::vector<std::vector
m_vecAXOL1TLTemplate = vecAXOL1TLTempl;
}

void l1t::TriggerMenuParser::setVecTOPOTemplate(const std::vector<std::vector<TOPOTemplate> >& vecTOPOTempl) {
m_vecTOPOTemplate = vecTOPOTempl;
}

void l1t::TriggerMenuParser::setVecCICADATemplate(const std::vector<std::vector<CICADATemplate> >& vecCICADATempl) {
m_vecCICADATemplate = vecCICADATempl;
}
Expand Down Expand Up @@ -233,6 +237,7 @@ void l1t::TriggerMenuParser::parseCondFormats(const L1TUtmTriggerMenu* utmMenu)
m_vecEnergySumTemplate.resize(m_numberConditionChips);
m_vecEnergySumZdcTemplate.resize(m_numberConditionChips);
m_vecAXOL1TLTemplate.resize(m_numberConditionChips);
m_vecTOPOTemplate.resize(m_numberConditionChips);
m_vecCICADATemplate.resize(m_numberConditionChips);
m_vecExternalTemplate.resize(m_numberConditionChips);

Expand Down Expand Up @@ -334,6 +339,10 @@ void l1t::TriggerMenuParser::parseCondFormats(const L1TUtmTriggerMenu* utmMenu)
condition.getType() == esConditionType::AnomalyDetectionTrigger) {
parseAXOL1TL(condition, chipNr);

//parse TOPO
} else if (condition.getType() == esConditionType::TopologicalTrigger) {
parseTOPO(condition, chipNr);

//parse CICADA
} else if (condition.getType() == esConditionType::CicadaTrigger) {
parseCICADA(condition, chipNr);
Expand Down Expand Up @@ -2884,6 +2893,105 @@ bool l1t::TriggerMenuParser::parseAXOL1TL(L1TUtmCondition condAXOL1TL, unsigned
return true;
}

/**
* Parse conditions of Topological Trigger - dummy function so far
*/

bool l1t::TriggerMenuParser::parseTOPO(L1TUtmCondition condTOPO, unsigned int chipNr) {
using namespace tmeventsetup;

std::cout << "#### parse TOPO information ####" << std::endl;
// std::cout << l1t2string(condTOPO.getType()) << std::endl;
// std::cout << l1t2string(condTOPO.getName()) << std::endl;
// std::cout << l1t2string(condTOPO.getObjects().at(0).getType()) << std::endl;

// get condition, particle name and particle type
std::string condition = "axol1tl";
std::string type = l1t2string(condTOPO.getType());
std::string name = l1t2string(condTOPO.getName());

LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
<< " (in parseTOPO) " << std::endl
<< " condition = " << condition << std::endl
<< " type = " << type << std::endl
<< " name = " << name << std::endl;

const int nrObj = 1;
GtConditionType cType = TypeTOPO;

std::vector<TOPOTemplate::ObjectParameter> objParameter(nrObj);

if (int(condTOPO.getObjects().size()) != nrObj) {
edm::LogError("TriggerMenuParser") << " condTOPO objects: nrObj = " << nrObj
<< "condTOPO.getObjects().size() = " << condTOPO.getObjects().size()
<< std::endl;
return false;
}

// Get the axol1tl object
L1TUtmObject object = condTOPO.getObjects().at(0);
int relativeBx = object.getBxOffset();
bool gEq = (object.getComparisonOperator() == esComparisonOperator::GE);

//Loop over cuts for this object
int lowerThresholdInd = 0;
int upperThresholdInd = -1;

//save model and threshold
std::string model = "";

// for UTM v12+
const std::vector<L1TUtmCut>& cuts = object.getCuts();
for (size_t kk = 0; kk < cuts.size(); kk++) {
const L1TUtmCut& cut = cuts.at(kk);

//save model
if (cut.getCutType() == tmeventsetup::Model) {
model = cut.getData();
}
//save score
else if (cut.getCutType() == esCutType::Score) {
lowerThresholdInd = cut.getMinimum().value;
upperThresholdInd = cut.getMaximum().value;
} //end else if
} //end cut loop

// check model version is not empty
if (model.empty()) {
edm::LogError("TriggerMenuParser") << " Error: TOPO movel version is empty" << std::endl;
return false;
}

//fill object params
objParameter[0].minTOPOThreshold = lowerThresholdInd;
objParameter[0].maxTOPOThreshold = upperThresholdInd;

// create a new TOPO condition
TOPOTemplate topoCond(name);
topoCond.setCondType(cType);
topoCond.setCondGEq(gEq);
topoCond.setCondChipNr(chipNr);
topoCond.setCondRelativeBx(relativeBx);
topoCond.setConditionParameter(objParameter);
topoCond.setModelVersion(model);

if (edm::isDebugEnabled()) {
std::ostringstream myCoutStream;
topoCond.print(myCoutStream);
LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
}

// check that the condition does not exist already in the map
if (!insertConditionIntoMap(topoCond, chipNr)) {
edm::LogError("TriggerMenuParser") << " Error: duplicate TOPO condition (" << name << ")" << std::endl;
return false;
}

(m_vecTOPOTemplate[chipNr]).push_back(topoCond);

return true;
}

/**
* parseExternal Parse an External condition and
* insert an entry to the conditions map
Expand Down
Loading