Skip to content

Commit a08cd11

Browse files
authored
Merge pull request #45605 from max-zhao0/from-CMSSW_14_1_0_pre5
Add L1TCaloLayer1Summary and necessary changes to emulator
2 parents ab08a21 + 83fe29e commit a08cd11

File tree

8 files changed

+270
-3
lines changed

8 files changed

+270
-3
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// -*- C++ -*-
2+
//
3+
// Package: L1TMonitor/L1TCaloLayer1Summary
4+
// Class: L1TCaloLayer1Summary
5+
//
6+
/**\class L1TCaloLayer1Summary L1TCaloLayer1Summary.cc Demo/L1TCaloLayer1Summary/plugins/L1TCaloLayer1Summary.cc
7+
8+
Description: DQM Analyzer for CaloLayer1 regions and CICADAScore
9+
10+
Implementation:
11+
This module uses emulator sequence for CaloLayer1.
12+
*/
13+
//
14+
// Original Author: Max Zhao <[email protected]>
15+
// Created: 31 Jul 2024
16+
//
17+
//
18+
19+
// system include files
20+
#include <memory>
21+
#include <string>
22+
23+
#include "DQMServices/Core/interface/DQMStore.h"
24+
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
25+
26+
// user include files
27+
#include "FWCore/Framework/interface/Frameworkfwd.h"
28+
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
29+
30+
#include "FWCore/Framework/interface/Event.h"
31+
#include "FWCore/Framework/interface/MakerMacros.h"
32+
33+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
34+
#include "FWCore/Utilities/interface/InputTag.h"
35+
36+
#include "FWCore/ServiceRegistry/interface/Service.h"
37+
38+
#include "DataFormats/L1CaloTrigger/interface/CICADA.h"
39+
#include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
40+
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
41+
#include "EventFilter/L1TXRawToDigi/interface/UCTDAQRawData.h"
42+
#include "EventFilter/L1TXRawToDigi/interface/UCTAMCRawData.h"
43+
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
44+
45+
class L1TCaloLayer1Summary : public DQMEDAnalyzer {
46+
public:
47+
explicit L1TCaloLayer1Summary(const edm::ParameterSet&);
48+
49+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
50+
51+
private:
52+
void analyze(const edm::Event&, const edm::EventSetup&) override;
53+
void bookHistograms(DQMStore::IBooker&, const edm::Run&, const edm::EventSetup&) override;
54+
55+
// ----------member data ---------------------------
56+
edm::EDGetTokenT<l1t::CICADABxCollection> caloLayer1CICADAScoreToken_;
57+
edm::EDGetTokenT<l1t::CICADABxCollection> gtCICADAScoreToken_;
58+
edm::EDGetTokenT<l1t::CICADABxCollection> simCICADAScoreToken_;
59+
edm::EDGetTokenT<L1CaloRegionCollection> caloLayer1RegionsToken_;
60+
edm::EDGetTokenT<L1CaloRegionCollection> simRegionsToken_;
61+
edm::EDGetTokenT<FEDRawDataCollection> fedRawData_;
62+
63+
dqm::reco::MonitorElement* histoCaloLayer1CICADAScore;
64+
dqm::reco::MonitorElement* histoGtCICADAScore;
65+
dqm::reco::MonitorElement* histoSimCICADAScore;
66+
dqm::reco::MonitorElement* histoCaloMinusSim;
67+
dqm::reco::MonitorElement* histoCaloMinusGt;
68+
dqm::reco::MonitorElement* histoSlot7MinusDaqBxid;
69+
dqm::reco::MonitorElement* histoCaloRegions;
70+
dqm::reco::MonitorElement* histoSimRegions;
71+
dqm::reco::MonitorElement* histoCaloMinusSimRegions;
72+
73+
std::string histFolder_;
74+
};

DQM/L1TMonitor/plugins/SealModule.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ DEFINE_FWK_MODULE(L1TGMT);
2727
#include "DQM/L1TMonitor/interface/L1TStage2CaloLayer1.h"
2828
DEFINE_FWK_MODULE(L1TStage2CaloLayer1);
2929

30+
#include "DQM/L1TMonitor/interface/L1TCaloLayer1Summary.h"
31+
DEFINE_FWK_MODULE(L1TCaloLayer1Summary);
32+
3033
#include "DQM/L1TMonitor/interface/L1TStage2CaloLayer2.h"
3134
DEFINE_FWK_MODULE(L1TStage2CaloLayer2);
3235

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import FWCore.ParameterSet.Config as cms
2+
3+
from L1Trigger.Configuration.CaloTriggerPrimitives_cff import *
4+
simEcalTriggerPrimitiveDigis.Label = 'ecalDigis'
5+
simHcalTriggerPrimitiveDigis.inputLabel = cms.VInputTag(
6+
cms.InputTag('hcalDigis'),
7+
cms.InputTag('hcalDigis')
8+
)
9+
simHcalTriggerPrimitiveDigis.inputUpgradeLabel = cms.VInputTag(
10+
cms.InputTag('hcalDigis'),
11+
cms.InputTag('hcalDigis')
12+
)
13+
14+
from L1Trigger.L1TCaloLayer1.simCaloStage2Layer1Summary_cfi import *
15+
from L1Trigger.L1TCaloLayer1.simCaloStage2Layer1Digis_cfi import *
16+
from DQM.L1TMonitor.L1TCaloLayer1Summary_cfi import *
17+
18+
simCaloStage2Layer1Summary.caloLayer1Regions = cms.InputTag("caloLayer1Digis", "")
19+
simCaloStage2Layer1Digis.ecalToken = cms.InputTag("ecalDigis", "EcalTriggerPrimitives")
20+
simCaloStage2Layer1Digis.hcalToken = cms.InputTag("hcalDigis", "")
21+
22+
l1tCaloLayer1SummarySeq = cms.Sequence(simEcalTriggerPrimitiveDigis * simHcalTriggerPrimitiveDigis * simCaloStage2Layer1Digis * simCaloStage2Layer1Summary * l1tCaloLayer1Summary)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import FWCore.ParameterSet.Config as cms
2+
from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer
3+
4+
l1tCaloLayer1Summary = DQMEDAnalyzer("L1TCaloLayer1Summary",
5+
caloLayer1CICADAScore = cms.InputTag("caloLayer1Digis", "CICADAScore"),
6+
gtCICADAScore = cms.InputTag("gtTestcrateStage2Digis", "CICADAScore"),
7+
simCICADAScore = cms.InputTag("simCaloStage2Layer1Summary", "CICADAScore"),
8+
caloLayer1Regions = cms.InputTag("caloLayer1Digis", ""),
9+
simRegions = cms.InputTag("simCaloStage2Layer1Digis", ""),
10+
fedRawDataLabel = cms.InputTag("rawDataCollector"),
11+
histFolder = cms.string('L1T/L1TCaloLayer1Summary')
12+
)

DQM/L1TMonitor/python/L1TStage2_cff.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# CaloLayer2
1010
from DQM.L1TMonitor.L1TStage2CaloLayer2_cfi import *
1111

12+
# CaloLayer1Summary
13+
from DQM.L1TMonitor.L1TCaloLayer1Summary_cff import *
14+
1215
# BMTF
1316
from DQM.L1TMonitor.L1TStage2BMTF_cff import *
1417

@@ -47,7 +50,8 @@
4750
l1tStage2RegionalShower +
4851
l1tStage2uGMTOnlineDQMSeq +
4952
l1tObjectsTiming +
50-
l1tStage2uGTOnlineDQMSeq
53+
l1tStage2uGTOnlineDQMSeq +
54+
l1tCaloLayer1SummarySeq
5155
)
5256

5357
# sequence to run only for validation events
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#include "DQM/L1TMonitor/interface/L1TCaloLayer1Summary.h"
2+
3+
L1TCaloLayer1Summary::L1TCaloLayer1Summary(const edm::ParameterSet& iConfig)
4+
: caloLayer1CICADAScoreToken_(
5+
consumes<l1t::CICADABxCollection>(iConfig.getParameter<edm::InputTag>("caloLayer1CICADAScore"))),
6+
gtCICADAScoreToken_(consumes<l1t::CICADABxCollection>(iConfig.getParameter<edm::InputTag>("gtCICADAScore"))),
7+
simCICADAScoreToken_(consumes<l1t::CICADABxCollection>(iConfig.getParameter<edm::InputTag>("simCICADAScore"))),
8+
caloLayer1RegionsToken_(
9+
consumes<L1CaloRegionCollection>(iConfig.getParameter<edm::InputTag>("caloLayer1Regions"))),
10+
simRegionsToken_(consumes<L1CaloRegionCollection>(iConfig.getParameter<edm::InputTag>("simRegions"))),
11+
fedRawData_(consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("fedRawDataLabel"))),
12+
histFolder_(iConfig.getParameter<std::string>("histFolder")) {}
13+
14+
// ------------ method called for each event ------------
15+
void L1TCaloLayer1Summary::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
16+
edm::Handle<FEDRawDataCollection> fedRawDataCollection;
17+
iEvent.getByToken(fedRawData_, fedRawDataCollection);
18+
if (fedRawDataCollection.isValid()) {
19+
for (int iFed = FEDNumbering::MINRCTFEDID + 4; iFed < FEDNumbering::MAXRCTFEDID; iFed += 2) {
20+
const FEDRawData& fedRawData = fedRawDataCollection->FEDData(iFed);
21+
if (fedRawData.size() == 0) {
22+
continue;
23+
}
24+
const uint64_t* fedRawDataArray = (const uint64_t*)fedRawData.data();
25+
UCTDAQRawData daqData(fedRawDataArray);
26+
27+
if (daqData.nAMCs() == 7) {
28+
UCTAMCRawData amcSlot7(daqData.amcPayload(3));
29+
if (amcSlot7.amcNo() == 7) {
30+
histoSlot7MinusDaqBxid->Fill(amcSlot7.BXID() - daqData.BXID());
31+
}
32+
}
33+
}
34+
}
35+
36+
L1CaloRegionCollection caloLayer1Regions = iEvent.get(caloLayer1RegionsToken_);
37+
L1CaloRegionCollection simRegions = iEvent.get(simRegionsToken_);
38+
int nRegions = caloLayer1Regions.size();
39+
40+
unsigned int maxEtaIdx = 0;
41+
for (int iRegion = 0; iRegion < nRegions; iRegion++) {
42+
if (maxEtaIdx < caloLayer1Regions[iRegion].gctEta()) {
43+
maxEtaIdx = caloLayer1Regions[iRegion].gctEta();
44+
}
45+
}
46+
int matrixSize = maxEtaIdx + 1;
47+
48+
bool foundMatrix[2][matrixSize][matrixSize];
49+
int etMatrix[2][matrixSize][matrixSize];
50+
for (int i = 0; i < 2; i++) {
51+
for (int j = 0; j < matrixSize; j++) {
52+
for (int k = 0; k < matrixSize; k++) {
53+
foundMatrix[i][j][k] = false;
54+
etMatrix[i][j][k] = 0;
55+
}
56+
}
57+
}
58+
59+
for (int iRegion = 0; iRegion < nRegions; iRegion++) {
60+
L1CaloRegion cRegion = caloLayer1Regions[iRegion];
61+
L1CaloRegion sRegion = simRegions[iRegion];
62+
63+
foundMatrix[0][cRegion.gctEta()][cRegion.gctPhi()] = true;
64+
etMatrix[0][cRegion.gctEta()][cRegion.gctPhi()] = cRegion.et();
65+
foundMatrix[1][sRegion.gctEta()][sRegion.gctPhi()] = true;
66+
etMatrix[1][sRegion.gctEta()][sRegion.gctPhi()] = sRegion.et();
67+
}
68+
int iRegion = 0;
69+
for (int iEta = 0; iEta < matrixSize; iEta++) {
70+
for (int iPhi = 0; iPhi < matrixSize; iPhi++) {
71+
if (foundMatrix[0][iEta][iPhi] && foundMatrix[1][iEta][iPhi]) {
72+
histoCaloRegions->Fill(iRegion, etMatrix[0][iEta][iPhi]);
73+
histoSimRegions->Fill(iRegion, etMatrix[1][iEta][iPhi]);
74+
histoCaloMinusSimRegions->Fill(iRegion, etMatrix[0][iEta][iPhi] - etMatrix[1][iEta][iPhi]);
75+
iRegion++;
76+
}
77+
}
78+
}
79+
80+
auto caloCICADAScores = iEvent.get(caloLayer1CICADAScoreToken_);
81+
auto gtCICADAScores = iEvent.get(gtCICADAScoreToken_);
82+
auto simCICADAScores = iEvent.get(simCICADAScoreToken_);
83+
84+
if (caloCICADAScores.size() > 0) {
85+
histoCaloLayer1CICADAScore->Fill(caloCICADAScores[0]);
86+
if (gtCICADAScores.size() > 0) {
87+
histoGtCICADAScore->Fill(gtCICADAScores.at(0, 0));
88+
histoCaloMinusGt->Fill(caloCICADAScores[0] - gtCICADAScores.at(0, 0));
89+
}
90+
if (simCICADAScores.size() > 0) {
91+
histoSimCICADAScore->Fill(simCICADAScores[0]);
92+
histoCaloMinusSim->Fill(caloCICADAScores[0] - simCICADAScores[0]);
93+
}
94+
}
95+
}
96+
97+
void L1TCaloLayer1Summary::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) {
98+
ibooker.setCurrentFolder(histFolder_);
99+
histoSlot7MinusDaqBxid = ibooker.book1D("slot7BXID", "Slot 7- DAQ BXID", 50, -20, 20);
100+
101+
ibooker.setCurrentFolder(histFolder_ + "/CICADAScore");
102+
histoCaloLayer1CICADAScore = ibooker.book1D("caloLayer1CICADAScore", "CaloLayer1 CICADAScore", 50, 0, 200);
103+
histoGtCICADAScore = ibooker.book1D("gtCICADAScore", "GT CICADAScore at BX0", 50, 0, 200);
104+
histoCaloMinusGt = ibooker.book1D("caloMinusGtCICADAScore", "CaloLayer1 - GT CICADAScore at BX0", 50, -50, 50);
105+
histoSimCICADAScore =
106+
ibooker.book1D("simCaloLayer1CICADAScore", "simCaloLayer1 CICADAScore (input: DAQ regions)", 50, 0, 200);
107+
histoCaloMinusSim = ibooker.book1D(
108+
"caloMinusSimCICADAScore", "CaloLayer1 - simCaloLayer1 (input: DAQ regions) CICADAScore", 50, -50, 50);
109+
110+
ibooker.setCurrentFolder(histFolder_ + "/Regions");
111+
histoCaloMinusSimRegions =
112+
ibooker.book2D("caloMinusSumRegions",
113+
"CaloLayer1 - simCaloLayer1 (input: DAQ trigger primatives) Regions;Region;ET Difference",
114+
252,
115+
-0.5,
116+
252.5,
117+
100,
118+
-400,
119+
400);
120+
histoCaloRegions = ibooker.book2D("caloLayer1Regions", "CaloLayer1 Regions;Region;ET", 252, -0.5, 252.5, 100, 0, 800);
121+
histoSimRegions = ibooker.book2D("simCaloLayer1Regions",
122+
"simCaloLayer1 Regions (input: DAQ trigger primatives);Region;ET",
123+
252,
124+
-0.5,
125+
252.5,
126+
100,
127+
0,
128+
800);
129+
}
130+
131+
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
132+
void L1TCaloLayer1Summary::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
133+
// l1tCaloLayer1Summary
134+
edm::ParameterSetDescription desc;
135+
desc.add<edm::InputTag>("caloLayer1CICADAScore", edm::InputTag("caloLayer1Digis", "CICADAScore"));
136+
desc.add<edm::InputTag>("gtCICADAScore", edm::InputTag("gtTestcrateStage2Digis", "CICADAScore"));
137+
desc.add<edm::InputTag>("simCICADAScore", edm::InputTag("simCaloStage2Layer1Summary", "CICADAScore"));
138+
desc.add<edm::InputTag>("caloLayer1Regions", edm::InputTag("caloLayer1Digis"));
139+
desc.add<edm::InputTag>("simRegions", edm::InputTag("simCaloStage2Layer1Digis"));
140+
desc.add<edm::InputTag>("fedRawDataLabel", edm::InputTag("rawDataCollector"));
141+
desc.add<std::string>("histFolder", "L1T/L1TCaloLayer1Summary");
142+
descriptions.add("l1tCaloLayer1Summary", desc);
143+
}

L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class L1TCaloSummary : public edm::stream::EDProducer<> {
107107
int fwVersion;
108108

109109
edm::EDGetTokenT<L1CaloRegionCollection> regionToken;
110+
edm::EDGetTokenT<L1CaloRegionCollection> backupRegionToken;
110111

111112
UCTLayer1* layer1;
112113

@@ -141,7 +142,8 @@ L1TCaloSummary<INPUT, OUTPUT>::L1TCaloSummary(const edm::ParameterSet& iConfig)
141142
boostedJetPtFactor(iConfig.getParameter<double>("boostedJetPtFactor")),
142143
verbose(iConfig.getParameter<bool>("verbose")),
143144
fwVersion(iConfig.getParameter<int>("firmwareVersion")),
144-
regionToken(consumes<L1CaloRegionCollection>(edm::InputTag("simCaloStage2Layer1Digis"))),
145+
regionToken(consumes<L1CaloRegionCollection>(iConfig.getParameter<edm::InputTag>("caloLayer1Regions"))),
146+
backupRegionToken(consumes<L1CaloRegionCollection>(edm::InputTag("simCaloStage2Layer1Digis"))),
145147
loader(hls4mlEmulator::ModelLoader(iConfig.getParameter<string>("CICADAModelVersion"))),
146148
overwriteWithTestPatterns(iConfig.getParameter<bool>("useTestPatterns")),
147149
testPatterns(iConfig.getParameter<std::vector<edm::ParameterSet>>("testPatterns")) {
@@ -198,6 +200,12 @@ void L1TCaloSummary<INPUT, OUTPUT>::produce(edm::Event& iEvent, const edm::Event
198200
if (!iEvent.getByToken(regionToken, regionCollection))
199201
edm::LogError("L1TCaloSummary") << "UCT: Failed to get regions from region collection!";
200202
iEvent.getByToken(regionToken, regionCollection);
203+
204+
if (regionCollection->size() == 0) {
205+
iEvent.getByToken(backupRegionToken, regionCollection);
206+
edm::LogWarning("L1TCaloSummary") << "Switched to emulated regions since data regions was empty.\n";
207+
}
208+
201209
//Model input
202210
//This is done as a flat vector input, but future versions may involve 2D input
203211
//This will have to be handled later

L1Trigger/L1TCaloLayer1/python/simCaloStage2Layer1Summary_cfi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@
5252
firmwareVersion = cms.int32(1),
5353
CICADAModelVersion = cms.string("CICADAModel_v2p1p2"),
5454
useTestPatterns = cms.bool(False),
55-
testPatterns = standardCICADATestPatterns
55+
testPatterns = standardCICADATestPatterns,
56+
caloLayer1Regions = cms.InputTag("simCaloStage2Layer1Digis", "")
5657
)

0 commit comments

Comments
 (0)