Skip to content

Commit f14758a

Browse files
committed
add BX info to GlobalObjectMap (L1uGT emulation)
1 parent ab76956 commit f14758a

27 files changed

+467
-579
lines changed

DataFormats/L1TGlobal/interface/GlobalObjectMap.h

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef L1GlobalTrigger_L1TGtObjectMap_h
2-
#define L1GlobalTrigger_L1TGtObjectMap_h
1+
#ifndef DataFormats_L1TGlobal_GlobalObjectMap_h
2+
#define DataFormats_L1TGlobal_GlobalObjectMap_h
33

44
/**
55
* \class GlobalObjectMap
@@ -15,28 +15,17 @@
1515
*
1616
*/
1717

18-
// system include files
1918
#include <string>
2019
#include <vector>
21-
2220
#include <iosfwd>
2321

24-
// user include files
2522
#include "DataFormats/L1TGlobal/interface/GlobalObjectMapFwd.h"
26-
2723
#include "DataFormats/L1TGlobal/interface/GlobalLogicParser.h"
2824

29-
// forward declarations
30-
31-
// class declaration
3225
class GlobalObjectMap {
3326
public:
34-
/// constructor(s)
3527
GlobalObjectMap() {}
3628

37-
/// destructor
38-
//~GlobalObjectMap(){}
39-
4029
public:
4130
/// get / set name for algorithm in the object map
4231
inline const std::string& algoName() const { return m_algoName; }
@@ -56,13 +45,13 @@ class GlobalObjectMap {
5645

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

61-
void setCombinationVector(const std::vector<CombinationsInCond>& combinationVectorValue) {
62-
m_combinationVector = combinationVectorValue;
50+
void setCombinationVector(const std::vector<CombinationsWithBxInCond>& combinationVectorValue) {
51+
m_combinationWithBxVector = combinationVectorValue;
6352
}
64-
void swapCombinationVector(std::vector<CombinationsInCond>& combinationVectorValue) {
65-
m_combinationVector.swap(combinationVectorValue);
53+
void swapCombinationVector(std::vector<CombinationsWithBxInCond>& combinationVectorValue) {
54+
m_combinationWithBxVector.swap(combinationVectorValue);
6655
}
6756

6857
/// get / set the vector of operand tokens
@@ -79,6 +68,7 @@ class GlobalObjectMap {
7968
/// get / set the vector of object types
8069
/// return a constant reference to the vector of operand tokens
8170
inline const std::vector<L1TObjectTypeInCond>& objectTypeVector() const { return m_objectTypeVector; }
71+
8272
void setObjectTypeVector(const std::vector<L1TObjectTypeInCond>& objectTypeVectorValue) {
8373
m_objectTypeVector = objectTypeVectorValue;
8474
}
@@ -88,10 +78,10 @@ class GlobalObjectMap {
8878

8979
public:
9080
/// return all the combinations passing the requirements imposed in condition condNameVal
91-
const CombinationsInCond* getCombinationsInCond(const std::string& condNameVal) const;
81+
const CombinationsWithBxInCond* getCombinationsInCond(const std::string& condNameVal) const;
9282

9383
/// return all the combinations passing the requirements imposed in condition condNumberVal
94-
const CombinationsInCond* getCombinationsInCond(const int condNumberVal) const;
84+
const CombinationsWithBxInCond* getCombinationsInCond(const int condNumberVal) const;
9585

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

120110
// vector of combinations for all conditions in an algorithm
121-
std::vector<CombinationsInCond> m_combinationVector;
111+
std::vector<CombinationsWithBxInCond> m_combinationWithBxVector;
122112

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

127-
#endif /* L1GlobalTrigger_L1TGtObjectMap_h */
117+
#endif
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#ifndef L1GlobalTrigger_L1TGtObjectMapFwd_h
2-
#define L1GlobalTrigger_L1TGtObjectMapFwd_h
1+
#ifndef DataFormats_L1TGlobal_L1TGtObjectMapFwd_h
2+
#define DataFormats_L1TGlobal_L1TGtObjectMapFwd_h
33

44
/**
5-
* \class GlobalObjectMap
5+
* \class GlobalObjectMapFwd
66
*
77
*
88
* Description: group typedefs used by GlobalObjectMap.
@@ -16,6 +16,7 @@
1616
*/
1717

1818
// system include files
19+
#include <utility>
1920
#include <vector>
2021

2122
// user include files
@@ -24,14 +25,15 @@
2425
// forward declarations
2526

2627
/// typedefs
28+
typedef int16_t L1TObjBxIndexType;
29+
typedef int L1TObjIndexType;
2730

28-
/// list of object indices corresponding to a condition evaluated to true
29-
typedef std::vector<int> SingleCombInCond;
31+
/// list of object indices:bx pairs corresponding to a condition evaluated to true
32+
typedef std::vector<std::pair<L1TObjBxIndexType, L1TObjIndexType>> SingleCombWithBxInCond;
3033

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

3437
typedef std::vector<l1t::GlobalObject> L1TObjectTypeInCond;
35-
//typedef std::vector<int> ObjectTypeInCond;
3638

37-
#endif /* L1GlobalTrigger_L1TGtObjectMapFwd_h */
39+
#endif

DataFormats/L1TGlobal/interface/GlobalObjectMapRecord.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef L1GlobalTrigger_L1TGtObjectMapRecord_h
2-
#define L1GlobalTrigger_L1TGtObjectMapRecord_h
1+
#ifndef DataFormats_L1TGlobal_GlobalObjectMapRecord_h
2+
#define DataFormats_L1TGlobal_GlobalObjectMapRecord_h
33

44
/**
55
* \class GlobalObjectMapRecord
@@ -45,11 +45,13 @@ class GlobalObjectMapRecord {
4545

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

5051
/// return all the combinations passing the requirements imposed in condition condNameVal
5152
/// from algorithm with bit number algoBitNumberVal
52-
const CombinationsInCond* getCombinationsInCond(const int algoBitNumberVal, const std::string& condNameVal) const;
53+
const CombinationsWithBxInCond* getCombinationsInCond(const int algoBitNumberVal,
54+
const std::string& condNameVal) const;
5355

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

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

76-
#endif /* L1GlobalTrigger_L1TGtObjectMapRecord_h */
78+
#endif

DataFormats/L1TGlobal/src/GlobalObjectMap.cc

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,57 +12,47 @@
1212
*
1313
*/
1414

15-
// this class header
1615
#include "DataFormats/L1TGlobal/interface/GlobalObjectMap.h"
16+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
1717

18-
// system include files
1918
#include <iostream>
2019
#include <iomanip>
2120
#include <iterator>
22-
2321
#include <algorithm>
2422

25-
// user include files
26-
#include "FWCore/MessageLogger/interface/MessageLogger.h"
27-
28-
// forward declarations
29-
30-
// methods
31-
32-
// return all the combinations passing the requirements imposed in condition condNameVal
33-
const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const std::string& condNameVal) const {
23+
/// return all the combinations passing the requirements imposed in condition condNameVal
24+
const CombinationsWithBxInCond* GlobalObjectMap::getCombinationsInCond(const std::string& condNameVal) const {
3425
for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
3526
if ((m_operandTokenVector[i]).tokenName == condNameVal) {
36-
return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
27+
return &(m_combinationWithBxVector.at((m_operandTokenVector[i]).tokenNumber));
3728
}
3829
}
3930

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

4636
return nullptr;
4737
}
4838

4939
/// return all the combinations passing the requirements imposed in condition condNumberVal
50-
const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const int condNumberVal) const {
40+
const CombinationsWithBxInCond* GlobalObjectMap::getCombinationsInCond(const int condNumberVal) const {
5141
for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
5242
if ((m_operandTokenVector[i]).tokenNumber == condNumberVal) {
53-
return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
43+
return &(m_combinationWithBxVector.at((m_operandTokenVector[i]).tokenNumber));
5444
}
5545
}
5646

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

6352
return nullptr;
6453
}
65-
// return the result for the condition condNameVal
54+
55+
/// return the result for the condition condNameVal
6656
const bool GlobalObjectMap::getConditionResult(const std::string& condNameVal) const {
6757
for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
6858
if ((m_operandTokenVector[i]).tokenName == condNameVal) {
@@ -73,8 +63,8 @@ const bool GlobalObjectMap::getConditionResult(const std::string& condNameVal) c
7363
// return false - should not arrive here
7464
edm::LogError("GlobalObjectMap") << "\n\n ERROR: The requested condition with name = " << condNameVal
7565
<< "\n does not exists in the operand token vector."
76-
<< "\n Returning false for getConditionResult\n\n"
77-
<< std::endl;
66+
<< "\n Returning false for getConditionResult\n\n";
67+
7868
return false;
7969
}
8070

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

9484
// vector of combinations for all conditions in an algorithm
95-
m_combinationVector.clear();
85+
m_combinationWithBxVector.clear();
9686
}
9787

9888
void GlobalObjectMap::print(std::ostream& myCout) const {
@@ -117,35 +107,29 @@ void GlobalObjectMap::print(std::ostream& myCout) const {
117107
}
118108
}
119109

120-
myCout << " CombinationVector size: " << m_combinationVector.size() << std::endl;
110+
myCout << " CombinationWithBxVector size: " << m_combinationWithBxVector.size() << std::endl;
121111

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

124-
std::vector<CombinationsInCond>::const_iterator itVVV;
125-
int iCond = 0;
126-
for (itVVV = m_combinationVector.begin(); itVVV != m_combinationVector.end(); itVVV++) {
127-
std::string condName = (m_operandTokenVector[iCond]).tokenName;
128-
bool condResult = (m_operandTokenVector[iCond]).tokenResult;
129-
114+
for (size_t i1 = 0; i1 < m_combinationWithBxVector.size(); ++i1) {
115+
auto const& condName = m_operandTokenVector[i1].tokenName;
116+
auto const condResult = m_operandTokenVector[i1].tokenResult;
130117
myCout << " Condition " << condName << " evaluated to " << condResult << std::endl;
131-
132118
myCout << " List of combinations passing all requirements for this condition:" << std::endl;
133-
134119
myCout << " ";
135120

136-
if ((*itVVV).empty()) {
121+
if (m_combinationWithBxVector[i1].empty()) {
137122
myCout << "(none)";
138123
} else {
139-
CombinationsInCond::const_iterator itVV;
140-
for (itVV = (*itVVV).begin(); itVV != (*itVVV).end(); itVV++) {
124+
for (size_t i2 = 0; i2 < m_combinationWithBxVector[i1].size(); ++i2) {
141125
myCout << "( ";
142-
143-
std::copy((*itVV).begin(), (*itVV).end(), std::ostream_iterator<int>(myCout, " "));
144-
126+
for (size_t i3 = 0; i3 < m_combinationWithBxVector[i1][i2].size(); ++i3) {
127+
myCout << m_combinationWithBxVector[i1][i2][i3].first << ":";
128+
myCout << m_combinationWithBxVector[i1][i2][i3].second << " ";
129+
}
145130
myCout << "); ";
146131
}
147132
}
148-
iCond++;
149133
myCout << "\n\n";
150134
}
151135
}

DataFormats/L1TGlobal/src/GlobalObjectMapRecord.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ const GlobalObjectMap* GlobalObjectMapRecord::getObjectMap(const int algoBitNumb
6464

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

8686
// return all the combinations passing the requirements imposed in condition condNameVal
8787
// from algorithm with bit number algoBitNumberVal
88-
const CombinationsInCond* GlobalObjectMapRecord::getCombinationsInCond(const int algoBitNumberVal,
89-
const std::string& condNameVal) const {
88+
const CombinationsWithBxInCond* GlobalObjectMapRecord::getCombinationsInCond(const int algoBitNumberVal,
89+
const std::string& condNameVal) const {
9090
for (std::vector<GlobalObjectMap>::const_iterator itObj = m_gtObjectMap.begin(); itObj != m_gtObjectMap.end();
9191
++itObj) {
9292
if (itObj->algoBitNumber() == algoBitNumberVal) {

DataFormats/L1TGlobal/src/classes_def.xml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,34 @@
3131
</class>
3232
<class name="edm::Wrapper<GlobalObjectMapRecord>"/>
3333

34-
<class name="GlobalObjectMap" ClassVersion="10">
34+
<class name="GlobalObjectMap" ClassVersion="11">
35+
<version ClassVersion="11" checksum="760424007"/>
3536
<version ClassVersion="10" checksum="1899280385"/>
3637
</class>
3738
<class name="edm::Wrapper<GlobalObjectMap>"/>
3839
<class name="std::vector<GlobalObjectMap>"/>
3940
<class name="edm::Wrapper<std::vector<GlobalObjectMap> >"/>
41+
<!-- Adding ioread rules for backwards compatibility -->
42+
<ioread sourceClass="GlobalObjectMap" version="[3-10]"
43+
source="std::vector<std::vector<std::vector<L1TObjIndexType>>> m_combinationVector;"
44+
targetClass="GlobalObjectMap" target="m_combinationWithBxVector">
45+
<![CDATA[
46+
m_combinationWithBxVector.clear();
47+
m_combinationWithBxVector.reserve(onfile.m_combinationVector.size());
48+
for(auto const& a0 : onfile.m_combinationVector) {
49+
CombinationsWithBxInCond b0;
50+
b0.reserve(a0.size());
51+
for(auto const& a1 : a0) {
52+
SingleCombWithBxInCond b1;
53+
b1.reserve(a1.size());
54+
for(auto const a2 : a1) {
55+
b1.emplace_back(0, a2);
56+
}
57+
b0.emplace_back(b1);
58+
}
59+
m_combinationWithBxVector.emplace_back(b0);
60+
}]]>
61+
</ioread>
4062

4163
<class name="std::vector<l1t::GlobalObject>"/>
4264
<class name="std::vector<std::vector<l1t::GlobalObject> >"/>

DataFormats/L1TGlobal/test/TestGlobalObjectMapRecordFormat.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ function die { echo $1: status $2 ; exit $2; }
44

55
LOCAL_TEST_DIR=${SCRAM_TEST_PATH}
66

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

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

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

0 commit comments

Comments
 (0)