-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45831 from max-zhao0/from-CMSSW_14_1_0_pre5
[14_1] Add L1TCaloLayer1Summary and necessary changes to emulator
- Loading branch information
Showing
8 changed files
with
270 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// -*- C++ -*- | ||
// | ||
// Package: L1TMonitor/L1TCaloLayer1Summary | ||
// Class: L1TCaloLayer1Summary | ||
// | ||
/**\class L1TCaloLayer1Summary L1TCaloLayer1Summary.cc Demo/L1TCaloLayer1Summary/plugins/L1TCaloLayer1Summary.cc | ||
Description: DQM Analyzer for CaloLayer1 regions and CICADAScore | ||
Implementation: | ||
This module uses emulator sequence for CaloLayer1. | ||
*/ | ||
// | ||
// Original Author: Max Zhao <[email protected]> | ||
// Created: 31 Jul 2024 | ||
// | ||
// | ||
|
||
// system include files | ||
#include <memory> | ||
#include <string> | ||
|
||
#include "DQMServices/Core/interface/DQMStore.h" | ||
#include "DQMServices/Core/interface/DQMEDAnalyzer.h" | ||
|
||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/one/EDAnalyzer.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/Utilities/interface/InputTag.h" | ||
|
||
#include "FWCore/ServiceRegistry/interface/Service.h" | ||
|
||
#include "DataFormats/L1CaloTrigger/interface/CICADA.h" | ||
#include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h" | ||
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" | ||
#include "EventFilter/L1TXRawToDigi/interface/UCTDAQRawData.h" | ||
#include "EventFilter/L1TXRawToDigi/interface/UCTAMCRawData.h" | ||
#include "DataFormats/FEDRawData/interface/FEDNumbering.h" | ||
|
||
class L1TCaloLayer1Summary : public DQMEDAnalyzer { | ||
public: | ||
explicit L1TCaloLayer1Summary(const edm::ParameterSet&); | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
||
private: | ||
void analyze(const edm::Event&, const edm::EventSetup&) override; | ||
void bookHistograms(DQMStore::IBooker&, const edm::Run&, const edm::EventSetup&) override; | ||
|
||
// ----------member data --------------------------- | ||
edm::EDGetTokenT<l1t::CICADABxCollection> caloLayer1CICADAScoreToken_; | ||
edm::EDGetTokenT<l1t::CICADABxCollection> gtCICADAScoreToken_; | ||
edm::EDGetTokenT<l1t::CICADABxCollection> simCICADAScoreToken_; | ||
edm::EDGetTokenT<L1CaloRegionCollection> caloLayer1RegionsToken_; | ||
edm::EDGetTokenT<L1CaloRegionCollection> simRegionsToken_; | ||
edm::EDGetTokenT<FEDRawDataCollection> fedRawData_; | ||
|
||
dqm::reco::MonitorElement* histoCaloLayer1CICADAScore; | ||
dqm::reco::MonitorElement* histoGtCICADAScore; | ||
dqm::reco::MonitorElement* histoSimCICADAScore; | ||
dqm::reco::MonitorElement* histoCaloMinusSim; | ||
dqm::reco::MonitorElement* histoCaloMinusGt; | ||
dqm::reco::MonitorElement* histoSlot7MinusDaqBxid; | ||
dqm::reco::MonitorElement* histoCaloRegions; | ||
dqm::reco::MonitorElement* histoSimRegions; | ||
dqm::reco::MonitorElement* histoCaloMinusSimRegions; | ||
|
||
std::string histFolder_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from L1Trigger.Configuration.CaloTriggerPrimitives_cff import * | ||
simEcalTriggerPrimitiveDigis.Label = 'ecalDigis' | ||
simHcalTriggerPrimitiveDigis.inputLabel = cms.VInputTag( | ||
cms.InputTag('hcalDigis'), | ||
cms.InputTag('hcalDigis') | ||
) | ||
simHcalTriggerPrimitiveDigis.inputUpgradeLabel = cms.VInputTag( | ||
cms.InputTag('hcalDigis'), | ||
cms.InputTag('hcalDigis') | ||
) | ||
|
||
from L1Trigger.L1TCaloLayer1.simCaloStage2Layer1Summary_cfi import * | ||
from L1Trigger.L1TCaloLayer1.simCaloStage2Layer1Digis_cfi import * | ||
from DQM.L1TMonitor.L1TCaloLayer1Summary_cfi import * | ||
|
||
simCaloStage2Layer1Summary.caloLayer1Regions = cms.InputTag("caloLayer1Digis", "") | ||
simCaloStage2Layer1Digis.ecalToken = cms.InputTag("ecalDigis", "EcalTriggerPrimitives") | ||
simCaloStage2Layer1Digis.hcalToken = cms.InputTag("hcalDigis", "") | ||
|
||
l1tCaloLayer1SummarySeq = cms.Sequence(simEcalTriggerPrimitiveDigis * simHcalTriggerPrimitiveDigis * simCaloStage2Layer1Digis * simCaloStage2Layer1Summary * l1tCaloLayer1Summary) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer | ||
|
||
l1tCaloLayer1Summary = DQMEDAnalyzer("L1TCaloLayer1Summary", | ||
caloLayer1CICADAScore = cms.InputTag("caloLayer1Digis", "CICADAScore"), | ||
gtCICADAScore = cms.InputTag("gtTestcrateStage2Digis", "CICADAScore"), | ||
simCICADAScore = cms.InputTag("simCaloStage2Layer1Summary", "CICADAScore"), | ||
caloLayer1Regions = cms.InputTag("caloLayer1Digis", ""), | ||
simRegions = cms.InputTag("simCaloStage2Layer1Digis", ""), | ||
fedRawDataLabel = cms.InputTag("rawDataCollector"), | ||
histFolder = cms.string('L1T/L1TCaloLayer1Summary') | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
#include "DQM/L1TMonitor/interface/L1TCaloLayer1Summary.h" | ||
|
||
L1TCaloLayer1Summary::L1TCaloLayer1Summary(const edm::ParameterSet& iConfig) | ||
: caloLayer1CICADAScoreToken_( | ||
consumes<l1t::CICADABxCollection>(iConfig.getParameter<edm::InputTag>("caloLayer1CICADAScore"))), | ||
gtCICADAScoreToken_(consumes<l1t::CICADABxCollection>(iConfig.getParameter<edm::InputTag>("gtCICADAScore"))), | ||
simCICADAScoreToken_(consumes<l1t::CICADABxCollection>(iConfig.getParameter<edm::InputTag>("simCICADAScore"))), | ||
caloLayer1RegionsToken_( | ||
consumes<L1CaloRegionCollection>(iConfig.getParameter<edm::InputTag>("caloLayer1Regions"))), | ||
simRegionsToken_(consumes<L1CaloRegionCollection>(iConfig.getParameter<edm::InputTag>("simRegions"))), | ||
fedRawData_(consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("fedRawDataLabel"))), | ||
histFolder_(iConfig.getParameter<std::string>("histFolder")) {} | ||
|
||
// ------------ method called for each event ------------ | ||
void L1TCaloLayer1Summary::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { | ||
edm::Handle<FEDRawDataCollection> fedRawDataCollection; | ||
iEvent.getByToken(fedRawData_, fedRawDataCollection); | ||
if (fedRawDataCollection.isValid()) { | ||
for (int iFed = FEDNumbering::MINRCTFEDID + 4; iFed < FEDNumbering::MAXRCTFEDID; iFed += 2) { | ||
const FEDRawData& fedRawData = fedRawDataCollection->FEDData(iFed); | ||
if (fedRawData.size() == 0) { | ||
continue; | ||
} | ||
const uint64_t* fedRawDataArray = (const uint64_t*)fedRawData.data(); | ||
UCTDAQRawData daqData(fedRawDataArray); | ||
|
||
if (daqData.nAMCs() == 7) { | ||
UCTAMCRawData amcSlot7(daqData.amcPayload(3)); | ||
if (amcSlot7.amcNo() == 7) { | ||
histoSlot7MinusDaqBxid->Fill(amcSlot7.BXID() - daqData.BXID()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
L1CaloRegionCollection caloLayer1Regions = iEvent.get(caloLayer1RegionsToken_); | ||
L1CaloRegionCollection simRegions = iEvent.get(simRegionsToken_); | ||
int nRegions = caloLayer1Regions.size(); | ||
|
||
unsigned int maxEtaIdx = 0; | ||
for (int iRegion = 0; iRegion < nRegions; iRegion++) { | ||
if (maxEtaIdx < caloLayer1Regions[iRegion].gctEta()) { | ||
maxEtaIdx = caloLayer1Regions[iRegion].gctEta(); | ||
} | ||
} | ||
int matrixSize = maxEtaIdx + 1; | ||
|
||
bool foundMatrix[2][matrixSize][matrixSize]; | ||
int etMatrix[2][matrixSize][matrixSize]; | ||
for (int i = 0; i < 2; i++) { | ||
for (int j = 0; j < matrixSize; j++) { | ||
for (int k = 0; k < matrixSize; k++) { | ||
foundMatrix[i][j][k] = false; | ||
etMatrix[i][j][k] = 0; | ||
} | ||
} | ||
} | ||
|
||
for (int iRegion = 0; iRegion < nRegions; iRegion++) { | ||
L1CaloRegion cRegion = caloLayer1Regions[iRegion]; | ||
L1CaloRegion sRegion = simRegions[iRegion]; | ||
|
||
foundMatrix[0][cRegion.gctEta()][cRegion.gctPhi()] = true; | ||
etMatrix[0][cRegion.gctEta()][cRegion.gctPhi()] = cRegion.et(); | ||
foundMatrix[1][sRegion.gctEta()][sRegion.gctPhi()] = true; | ||
etMatrix[1][sRegion.gctEta()][sRegion.gctPhi()] = sRegion.et(); | ||
} | ||
int iRegion = 0; | ||
for (int iEta = 0; iEta < matrixSize; iEta++) { | ||
for (int iPhi = 0; iPhi < matrixSize; iPhi++) { | ||
if (foundMatrix[0][iEta][iPhi] && foundMatrix[1][iEta][iPhi]) { | ||
histoCaloRegions->Fill(iRegion, etMatrix[0][iEta][iPhi]); | ||
histoSimRegions->Fill(iRegion, etMatrix[1][iEta][iPhi]); | ||
histoCaloMinusSimRegions->Fill(iRegion, etMatrix[0][iEta][iPhi] - etMatrix[1][iEta][iPhi]); | ||
iRegion++; | ||
} | ||
} | ||
} | ||
|
||
auto caloCICADAScores = iEvent.get(caloLayer1CICADAScoreToken_); | ||
auto gtCICADAScores = iEvent.get(gtCICADAScoreToken_); | ||
auto simCICADAScores = iEvent.get(simCICADAScoreToken_); | ||
|
||
if (caloCICADAScores.size() > 0) { | ||
histoCaloLayer1CICADAScore->Fill(caloCICADAScores[0]); | ||
if (gtCICADAScores.size() > 0) { | ||
histoGtCICADAScore->Fill(gtCICADAScores.at(0, 0)); | ||
histoCaloMinusGt->Fill(caloCICADAScores[0] - gtCICADAScores.at(0, 0)); | ||
} | ||
if (simCICADAScores.size() > 0) { | ||
histoSimCICADAScore->Fill(simCICADAScores[0]); | ||
histoCaloMinusSim->Fill(caloCICADAScores[0] - simCICADAScores[0]); | ||
} | ||
} | ||
} | ||
|
||
void L1TCaloLayer1Summary::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) { | ||
ibooker.setCurrentFolder(histFolder_); | ||
histoSlot7MinusDaqBxid = ibooker.book1D("slot7BXID", "Slot 7- DAQ BXID", 50, -20, 20); | ||
|
||
ibooker.setCurrentFolder(histFolder_ + "/CICADAScore"); | ||
histoCaloLayer1CICADAScore = ibooker.book1D("caloLayer1CICADAScore", "CaloLayer1 CICADAScore", 50, 0, 200); | ||
histoGtCICADAScore = ibooker.book1D("gtCICADAScore", "GT CICADAScore at BX0", 50, 0, 200); | ||
histoCaloMinusGt = ibooker.book1D("caloMinusGtCICADAScore", "CaloLayer1 - GT CICADAScore at BX0", 50, -50, 50); | ||
histoSimCICADAScore = | ||
ibooker.book1D("simCaloLayer1CICADAScore", "simCaloLayer1 CICADAScore (input: DAQ regions)", 50, 0, 200); | ||
histoCaloMinusSim = ibooker.book1D( | ||
"caloMinusSimCICADAScore", "CaloLayer1 - simCaloLayer1 (input: DAQ regions) CICADAScore", 50, -50, 50); | ||
|
||
ibooker.setCurrentFolder(histFolder_ + "/Regions"); | ||
histoCaloMinusSimRegions = | ||
ibooker.book2D("caloMinusSumRegions", | ||
"CaloLayer1 - simCaloLayer1 (input: DAQ trigger primatives) Regions;Region;ET Difference", | ||
252, | ||
-0.5, | ||
252.5, | ||
100, | ||
-400, | ||
400); | ||
histoCaloRegions = ibooker.book2D("caloLayer1Regions", "CaloLayer1 Regions;Region;ET", 252, -0.5, 252.5, 100, 0, 800); | ||
histoSimRegions = ibooker.book2D("simCaloLayer1Regions", | ||
"simCaloLayer1 Regions (input: DAQ trigger primatives);Region;ET", | ||
252, | ||
-0.5, | ||
252.5, | ||
100, | ||
0, | ||
800); | ||
} | ||
|
||
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ | ||
void L1TCaloLayer1Summary::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
// l1tCaloLayer1Summary | ||
edm::ParameterSetDescription desc; | ||
desc.add<edm::InputTag>("caloLayer1CICADAScore", edm::InputTag("caloLayer1Digis", "CICADAScore")); | ||
desc.add<edm::InputTag>("gtCICADAScore", edm::InputTag("gtTestcrateStage2Digis", "CICADAScore")); | ||
desc.add<edm::InputTag>("simCICADAScore", edm::InputTag("simCaloStage2Layer1Summary", "CICADAScore")); | ||
desc.add<edm::InputTag>("caloLayer1Regions", edm::InputTag("caloLayer1Digis")); | ||
desc.add<edm::InputTag>("simRegions", edm::InputTag("simCaloStage2Layer1Digis")); | ||
desc.add<edm::InputTag>("fedRawDataLabel", edm::InputTag("rawDataCollector")); | ||
desc.add<std::string>("histFolder", "L1T/L1TCaloLayer1Summary"); | ||
descriptions.add("l1tCaloLayer1Summary", desc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters