Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add BX info to GlobalObjectMap (L1uGT emulation) #47030

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
34 changes: 12 additions & 22 deletions DataFormats/L1TGlobal/interface/GlobalObjectMap.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef L1GlobalTrigger_L1TGtObjectMap_h
#define L1GlobalTrigger_L1TGtObjectMap_h
#ifndef DataFormats_L1TGlobal_GlobalObjectMap_h
#define DataFormats_L1TGlobal_GlobalObjectMap_h

/**
* \class GlobalObjectMap
Expand All @@ -15,28 +15,17 @@
*
*/

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

#include <iosfwd>

// user include files
#include "DataFormats/L1TGlobal/interface/GlobalObjectMapFwd.h"

#include "DataFormats/L1TGlobal/interface/GlobalLogicParser.h"

// forward declarations

// class declaration
class GlobalObjectMap {
public:
/// constructor(s)
GlobalObjectMap() {}

/// destructor
//~GlobalObjectMap(){}

public:
/// get / set name for algorithm in the object map
inline const std::string& algoName() const { return m_algoName; }
Expand All @@ -56,13 +45,13 @@ class GlobalObjectMap {

/// get / set the vector of combinations for the algorithm
/// return a constant reference to the vector of combinations for the algorithm
inline const std::vector<CombinationsInCond>& combinationVector() const { return m_combinationVector; }
inline const std::vector<CombinationsWithBxInCond>& combinationVector() const { return m_combinationWithBxVector; }

void setCombinationVector(const std::vector<CombinationsInCond>& combinationVectorValue) {
m_combinationVector = combinationVectorValue;
void setCombinationVector(const std::vector<CombinationsWithBxInCond>& combinationVectorValue) {
m_combinationWithBxVector = combinationVectorValue;
}
void swapCombinationVector(std::vector<CombinationsInCond>& combinationVectorValue) {
m_combinationVector.swap(combinationVectorValue);
void swapCombinationVector(std::vector<CombinationsWithBxInCond>& combinationVectorValue) {
m_combinationWithBxVector.swap(combinationVectorValue);
}

/// get / set the vector of operand tokens
Expand All @@ -79,6 +68,7 @@ class GlobalObjectMap {
/// get / set the vector of object types
/// return a constant reference to the vector of operand tokens
inline const std::vector<L1TObjectTypeInCond>& objectTypeVector() const { return m_objectTypeVector; }

void setObjectTypeVector(const std::vector<L1TObjectTypeInCond>& objectTypeVectorValue) {
m_objectTypeVector = objectTypeVectorValue;
}
Expand All @@ -88,10 +78,10 @@ class GlobalObjectMap {

public:
/// return all the combinations passing the requirements imposed in condition condNameVal
const CombinationsInCond* getCombinationsInCond(const std::string& condNameVal) const;
const CombinationsWithBxInCond* getCombinationsInCond(const std::string& condNameVal) const;

/// return all the combinations passing the requirements imposed in condition condNumberVal
const CombinationsInCond* getCombinationsInCond(const int condNumberVal) const;
const CombinationsWithBxInCond* getCombinationsInCond(const int condNumberVal) const;

/// return the result for the condition condNameVal
const bool getConditionResult(const std::string& condNameVal) const;
Expand All @@ -118,10 +108,10 @@ class GlobalObjectMap {
std::vector<GlobalLogicParser::OperandToken> m_operandTokenVector;

// vector of combinations for all conditions in an algorithm
std::vector<CombinationsInCond> m_combinationVector;
std::vector<CombinationsWithBxInCond> m_combinationWithBxVector;

// vector of object type vectors for all conditions in an algorithm
std::vector<L1TObjectTypeInCond> m_objectTypeVector;
};

#endif /* L1GlobalTrigger_L1TGtObjectMap_h */
#endif
20 changes: 11 additions & 9 deletions DataFormats/L1TGlobal/interface/GlobalObjectMapFwd.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef L1GlobalTrigger_L1TGtObjectMapFwd_h
#define L1GlobalTrigger_L1TGtObjectMapFwd_h
#ifndef DataFormats_L1TGlobal_L1TGtObjectMapFwd_h
#define DataFormats_L1TGlobal_L1TGtObjectMapFwd_h

/**
* \class GlobalObjectMap
* \class GlobalObjectMapFwd
*
*
* Description: group typedefs used by GlobalObjectMap.
Expand All @@ -16,6 +16,7 @@
*/

// system include files
#include <utility>
#include <vector>

// user include files
Expand All @@ -24,14 +25,15 @@
// forward declarations

/// typedefs
typedef int16_t L1TObjBxIndexType;
typedef int L1TObjIndexType;

/// list of object indices corresponding to a condition evaluated to true
typedef std::vector<int> SingleCombInCond;
/// list of object indices:bx pairs corresponding to a condition evaluated to true
typedef std::vector<std::pair<L1TObjBxIndexType, L1TObjIndexType>> SingleCombWithBxInCond;

/// all the object combinations evaluated to true in the condition
typedef std::vector<SingleCombInCond> CombinationsInCond;
/// all the object combinations evaluated to true in the condition (object indices + BX indices)
typedef std::vector<SingleCombWithBxInCond> CombinationsWithBxInCond;

typedef std::vector<l1t::GlobalObject> L1TObjectTypeInCond;
//typedef std::vector<int> ObjectTypeInCond;

#endif /* L1GlobalTrigger_L1TGtObjectMapFwd_h */
#endif
12 changes: 7 additions & 5 deletions DataFormats/L1TGlobal/interface/GlobalObjectMapRecord.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef L1GlobalTrigger_L1TGtObjectMapRecord_h
#define L1GlobalTrigger_L1TGtObjectMapRecord_h
#ifndef DataFormats_L1TGlobal_GlobalObjectMapRecord_h
#define DataFormats_L1TGlobal_GlobalObjectMapRecord_h

/**
* \class GlobalObjectMapRecord
Expand Down Expand Up @@ -45,11 +45,13 @@ class GlobalObjectMapRecord {

/// return all the combinations passing the requirements imposed in condition condNameVal
/// from algorithm with name algoNameVal
const CombinationsInCond* getCombinationsInCond(const std::string& algoNameVal, const std::string& condNameVal) const;
const CombinationsWithBxInCond* getCombinationsInCond(const std::string& algoNameVal,
const std::string& condNameVal) const;

/// return all the combinations passing the requirements imposed in condition condNameVal
/// from algorithm with bit number algoBitNumberVal
const CombinationsInCond* getCombinationsInCond(const int algoBitNumberVal, const std::string& condNameVal) const;
const CombinationsWithBxInCond* getCombinationsInCond(const int algoBitNumberVal,
const std::string& condNameVal) const;

/// return the result for the condition condNameVal
/// from algorithm with name algoNameVal
Expand All @@ -73,4 +75,4 @@ class GlobalObjectMapRecord {

inline void swap(GlobalObjectMapRecord& lh, GlobalObjectMapRecord& rh) { lh.swap(rh); }

#endif /* L1GlobalTrigger_L1TGtObjectMapRecord_h */
#endif
62 changes: 23 additions & 39 deletions DataFormats/L1TGlobal/src/GlobalObjectMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,47 @@
*
*/

// this class header
#include "DataFormats/L1TGlobal/interface/GlobalObjectMap.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

// system include files
#include <iostream>
#include <iomanip>
#include <iterator>

#include <algorithm>

// user include files
#include "FWCore/MessageLogger/interface/MessageLogger.h"

// forward declarations

// methods

// return all the combinations passing the requirements imposed in condition condNameVal
const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const std::string& condNameVal) const {
/// return all the combinations passing the requirements imposed in condition condNameVal
const CombinationsWithBxInCond* GlobalObjectMap::getCombinationsInCond(const std::string& condNameVal) const {
for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
if ((m_operandTokenVector[i]).tokenName == condNameVal) {
return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
return &(m_combinationWithBxVector.at((m_operandTokenVector[i]).tokenNumber));
}
}

// return a null address - should not arrive here
edm::LogError("GlobalObjectMap") << "\n\n ERROR: The requested condition with tokenName = " << condNameVal
<< "\n does not exists in the operand token vector."
<< "\n Returning zero pointer for getCombinationsInCond\n\n"
<< std::endl;
<< "\n Returning zero pointer for getCombinationsInCond\n\n";

return nullptr;
}

/// return all the combinations passing the requirements imposed in condition condNumberVal
const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const int condNumberVal) const {
const CombinationsWithBxInCond* GlobalObjectMap::getCombinationsInCond(const int condNumberVal) const {
for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
if ((m_operandTokenVector[i]).tokenNumber == condNumberVal) {
return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
return &(m_combinationWithBxVector.at((m_operandTokenVector[i]).tokenNumber));
}
}

// return a null address - should not arrive here
edm::LogError("GlobalObjectMap") << "\n\n ERROR: The requested condition with tokenNumber = " << condNumberVal
<< "\n does not exists in the operand token vector."
<< "\n Returning zero pointer for getCombinationsInCond\n\n"
<< std::endl;
<< "\n Returning zero pointer for getCombinationsInCond\n\n";

return nullptr;
}
// return the result for the condition condNameVal

/// return the result for the condition condNameVal
const bool GlobalObjectMap::getConditionResult(const std::string& condNameVal) const {
for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
if ((m_operandTokenVector[i]).tokenName == condNameVal) {
Expand All @@ -73,8 +63,8 @@ const bool GlobalObjectMap::getConditionResult(const std::string& condNameVal) c
// return false - should not arrive here
edm::LogError("GlobalObjectMap") << "\n\n ERROR: The requested condition with name = " << condNameVal
<< "\n does not exists in the operand token vector."
<< "\n Returning false for getConditionResult\n\n"
<< std::endl;
<< "\n Returning false for getConditionResult\n\n";

return false;
}

Expand All @@ -92,7 +82,7 @@ void GlobalObjectMap::reset() {
m_operandTokenVector.clear();

// vector of combinations for all conditions in an algorithm
m_combinationVector.clear();
m_combinationWithBxVector.clear();
}

void GlobalObjectMap::print(std::ostream& myCout) const {
Expand All @@ -117,35 +107,29 @@ void GlobalObjectMap::print(std::ostream& myCout) const {
}
}

myCout << " CombinationVector size: " << m_combinationVector.size() << std::endl;
myCout << " CombinationWithBxVector size: " << m_combinationWithBxVector.size() << std::endl;

myCout << " conditions: " << std::endl;

std::vector<CombinationsInCond>::const_iterator itVVV;
int iCond = 0;
for (itVVV = m_combinationVector.begin(); itVVV != m_combinationVector.end(); itVVV++) {
std::string condName = (m_operandTokenVector[iCond]).tokenName;
bool condResult = (m_operandTokenVector[iCond]).tokenResult;

for (size_t i1 = 0; i1 < m_combinationWithBxVector.size(); ++i1) {
auto const& condName = m_operandTokenVector[i1].tokenName;
auto const condResult = m_operandTokenVector[i1].tokenResult;
myCout << " Condition " << condName << " evaluated to " << condResult << std::endl;

myCout << " List of combinations passing all requirements for this condition:" << std::endl;

myCout << " ";

if ((*itVVV).empty()) {
if (m_combinationWithBxVector[i1].empty()) {
myCout << "(none)";
} else {
CombinationsInCond::const_iterator itVV;
for (itVV = (*itVVV).begin(); itVV != (*itVVV).end(); itVV++) {
for (size_t i2 = 0; i2 < m_combinationWithBxVector[i1].size(); ++i2) {
myCout << "( ";

std::copy((*itVV).begin(), (*itVV).end(), std::ostream_iterator<int>(myCout, " "));

for (size_t i3 = 0; i3 < m_combinationWithBxVector[i1][i2].size(); ++i3) {
myCout << m_combinationWithBxVector[i1][i2][i3].first << ":";
myCout << m_combinationWithBxVector[i1][i2][i3].second << " ";
}
myCout << "); ";
}
}
iCond++;
myCout << "\n\n";
}
}
8 changes: 4 additions & 4 deletions DataFormats/L1TGlobal/src/GlobalObjectMapRecord.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const GlobalObjectMap* GlobalObjectMapRecord::getObjectMap(const int algoBitNumb

// return all the combinations passing the requirements imposed in condition condNameVal
// from algorithm algoNameVal
const CombinationsInCond* GlobalObjectMapRecord::getCombinationsInCond(const std::string& algoNameVal,
const std::string& condNameVal) const {
const CombinationsWithBxInCond* GlobalObjectMapRecord::getCombinationsInCond(const std::string& algoNameVal,
const std::string& condNameVal) const {
for (std::vector<GlobalObjectMap>::const_iterator itObj = m_gtObjectMap.begin(); itObj != m_gtObjectMap.end();
++itObj) {
if (itObj->algoName() == algoNameVal) {
Expand All @@ -85,8 +85,8 @@ const CombinationsInCond* GlobalObjectMapRecord::getCombinationsInCond(const std

// return all the combinations passing the requirements imposed in condition condNameVal
// from algorithm with bit number algoBitNumberVal
const CombinationsInCond* GlobalObjectMapRecord::getCombinationsInCond(const int algoBitNumberVal,
const std::string& condNameVal) const {
const CombinationsWithBxInCond* GlobalObjectMapRecord::getCombinationsInCond(const int algoBitNumberVal,
const std::string& condNameVal) const {
for (std::vector<GlobalObjectMap>::const_iterator itObj = m_gtObjectMap.begin(); itObj != m_gtObjectMap.end();
++itObj) {
if (itObj->algoBitNumber() == algoBitNumberVal) {
Expand Down
24 changes: 23 additions & 1 deletion DataFormats/L1TGlobal/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,34 @@
</class>
<class name="edm::Wrapper<GlobalObjectMapRecord>"/>

<class name="GlobalObjectMap" ClassVersion="10">
<class name="GlobalObjectMap" ClassVersion="11">
<version ClassVersion="11" checksum="760424007"/>
<version ClassVersion="10" checksum="1899280385"/>
</class>
<class name="edm::Wrapper<GlobalObjectMap>"/>
<class name="std::vector<GlobalObjectMap>"/>
<class name="edm::Wrapper<std::vector<GlobalObjectMap> >"/>
<!-- Adding ioread rules for backwards compatibility -->
<ioread sourceClass="GlobalObjectMap" version="[3-10]"
source="std::vector<std::vector<std::vector<L1TObjIndexType>>> m_combinationVector;"
targetClass="GlobalObjectMap" target="m_combinationWithBxVector">
<![CDATA[
m_combinationWithBxVector.clear();
m_combinationWithBxVector.reserve(onfile.m_combinationVector.size());
for(auto const& a0 : onfile.m_combinationVector) {
CombinationsWithBxInCond b0;
b0.reserve(a0.size());
for(auto const& a1 : a0) {
SingleCombWithBxInCond b1;
b1.reserve(a1.size());
for(auto const a2 : a1) {
b1.emplace_back(0, a2);
}
b0.emplace_back(b1);
}
m_combinationWithBxVector.emplace_back(b0);
}]]>
</ioread>

<class name="std::vector<l1t::GlobalObject>"/>
<class name="std::vector<std::vector<l1t::GlobalObject> >"/>
Expand Down
16 changes: 10 additions & 6 deletions DataFormats/L1TGlobal/test/TestGlobalObjectMapRecordFormat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ function die { echo $1: status $2 ; exit $2; }

LOCAL_TEST_DIR=${SCRAM_TEST_PATH}

cmsRun ${LOCAL_TEST_DIR}/create_GlobalObjectMapRecord_test_file_cfg.py || die 'Failure using create_GlobalObjectMapRecord_test_file_cfg.py' $?

file=testGlobalObjectMapRecord.root

cmsRun ${LOCAL_TEST_DIR}/test_readGlobalObjectMapRecord_cfg.py "$file" || die "Failure using test_readGlobalObjectMapRecord_cfg.py $file" $?
tmpfile=testGlobalObjectMapRecord.root
cmsRun ${LOCAL_TEST_DIR}/create_GlobalObjectMapRecord_test_file_cfg.py --outputFileName "${tmpfile}" || die 'Failure using create_GlobalObjectMapRecord_test_file_cfg.py' $?
cmsRun ${LOCAL_TEST_DIR}/test_readGlobalObjectMapRecord_cfg.py --inputFileName "${tmpfile}" --globalObjectMapClassVersion 11 || die "Failure using test_readGlobalObjectMapRecord_cfg.py ${tmpfile}" $?

# The old files read below were generated as follows.
#
Expand All @@ -28,7 +26,13 @@ oldFiles="testGlobalObjectMapRecord_CMSSW_13_0_0_split_99.root testGlobalObjectM
oldFiles+=" testGlobalObjectMapRecord_CMSSW_13_1_0_pre3_split_99.root testGlobalObjectMapRecord_CMSSW_13_1_0_pre3_split_0.root"
for file in $oldFiles; do
inputfile=$(edmFileInPath DataFormats/L1TGlobal/data/$file) || die "Failure edmFileInPath DataFormats/L1TGlobal/data/$file" $?
cmsRun ${LOCAL_TEST_DIR}/test_readGlobalObjectMapRecord_cfg.py "$inputfile" || die "Failed to read old file $file" $?
cmsRun ${LOCAL_TEST_DIR}/test_readGlobalObjectMapRecord_cfg.py --inputFileName "$inputfile" --globalObjectMapClassVersion 10 || die "Failed to read old file $file" $?
done

#oldFiles="testGlobalObjectMapRecord_CMSSW_15_0_0_pre2_split_99.root testGlobalObjectMapRecord_CMSSW_15_0_0_pre2_split_0.root"
#for file in $oldFiles; do
# inputfile=$(edmFileInPath DataFormats/L1TGlobal/data/$file) || die "Failure edmFileInPath DataFormats/L1TGlobal/data/$file" $?
# cmsRun ${LOCAL_TEST_DIR}/test_readGlobalObjectMapRecord_cfg.py --inputFileName "$inputfile" --globalObjectMapClassVersion 11 || die "Failed to read old file $file" $?
#done

Comment on lines +32 to +37
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part could be removed. It is supposed to be un-commented once new files are added to cms-data with the first (pre-)release built after this PR is merged (CMSSW_15_0_0_pre2, if one is optimistic).

exit 0
Loading