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

BMTF-KMTF DQM Algo Selector for the DQM/L1TMonitor Subsystem #24557

Merged
Merged
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
7 changes: 4 additions & 3 deletions DQM/L1TMonitor/interface/L1TStage2BMTF.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ L1TStage2BMTF(const edm::ParameterSet & ps);
MonitorElement* bmtf_hwPt_bx;
MonitorElement* bmtf_hwQual_bx;

MonitorElement* bmtf_hwDXY;
MonitorElement* bmtf_hwPt2;


MonitorElement* kbmtf_hwDXY;
MonitorElement* kbmtf_hwPt2;
/* MonitorElement* bmtf_twinmuxInput_PhiBX; */
/* MonitorElement* bmtf_twinmuxInput_PhiPhi; */
/* MonitorElement* bmtf_twinmuxInput_PhiPhiB; */
Expand All @@ -110,7 +111,7 @@ L1TStage2BMTF(const edm::ParameterSet & ps);
/* MonitorElement* bmtf_twinmuxInput_PhiSector; */
/* MonitorElement* bmtf_twinmuxInput_PhiWheel; */
/* MonitorElement* bmtf_twinmuxInput_PhiTrSeg; */
/* MonitorElement* bmtf_twinmuxInput_PhiWheel_PhiSector; */
/* MonitorElement* bmtf_twinmuxInput_PhiWheel_PhiSector; */

/* MonitorElement* bmtf_twinmuxInput_TheBX; */
/* MonitorElement* bmtf_twinmuxInput_ThePhi; */
Expand Down
2 changes: 1 addition & 1 deletion DQM/L1TMonitor/interface/L1TStage2RegionalMuonCandComp.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class L1TStage2RegionalMuonCandComp : public DQMEDAnalyzer {
bool ignoreBadTrkAddr;
std::vector<int> ignoreBin;
bool verbose;
bool kalman;
bool isBmtf;

MonitorElement* summary;
MonitorElement* errorSummaryNum;
Expand Down
111 changes: 111 additions & 0 deletions DQM/L1TMonitor/plugins/L1TBMTFAlgoSelector.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
/P.Katsoulis
/G.Karathanasis
*/

#include "L1TBMTFAlgoSelector.h"

//The Constructor defines what to be consumed and produced
dqmBmtfAlgoSelector::L1TBMTFAlgoSelector::L1TBMTFAlgoSelector(const edm::ParameterSet & ps)
{
bmtfKalmanToken = consumes<l1t::RegionalMuonCandBxCollection>(ps.getParameter<edm::InputTag>("bmtfKalman"));
bmtfLegacyToken = consumes<l1t::RegionalMuonCandBxCollection>(ps.getParameter<edm::InputTag>("bmtfLegacy"));
fedToken = consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("feds"));

produces<l1t::RegionalMuonCandBxCollection>("BMTF");
produces<l1t::RegionalMuonCandBxCollection>("BMTF2");
}


dqmBmtfAlgoSelector::L1TBMTFAlgoSelector::~L1TBMTFAlgoSelector() {
}

void dqmBmtfAlgoSelector::L1TBMTFAlgoSelector::produce(edm::Event & eve, const edm::EventSetup & eveSetup)
{

edm::Handle<FEDRawDataCollection> feds;
eve.getByToken(fedToken, feds);

//Get the fw-ver
int nonEmptyFed=0;
if (feds->FEDData(1376).size() > 0)
nonEmptyFed = 1376;
else if (feds->FEDData(1377).size() > 0)
nonEmptyFed = 1377;
else {
edm::LogError("L1TDQM") << "[L1TBMTFAlgoSelector] Both BMTF feds (1376, 1377) seem empty.";
// return;
}
const FEDRawData& l1tRcd = feds->FEDData(nonEmptyFed);;
edm::LogInfo("L1TDQM") << "L1T Rcd taken from the FEDData.";
edm::LogInfo("L1TDQM") << "l1tRcd.size=" << l1tRcd.size() << " for fed:" << nonEmptyFed;

const unsigned char *data = l1tRcd.data();
FEDHeader header(data);
edm::LogInfo("L1TDQM") << "header and data extracted from the Rcd.";

amc13::Packet packet;
if (!packet.parse( (const uint64_t*) data, (const uint64_t*) (data + 8),
(l1tRcd.size()) / 8,
header.lvl1ID(), header.bxID(), false, false ) ) {

edm::LogError("L1TDQM") << "Could not extract AMC13 Packet.";
return;
}

edm::LogInfo("L1TDQM") << "AMC13-packet-payload size = " << packet.payload().size();
unsigned algo_ver;
if (!packet.payload().empty()) {
auto payload64 = ( packet.payload().at(0) ).data();
const uint32_t *start = (const uint32_t*) payload64.get();
const uint32_t *end = start + (packet.payload().at(0).size() * 2);

l1t::MP7Payload payload(start, end, false);
algo_ver = payload.getAlgorithmFWVersion();

edm::LogInfo("L1TDQM") << "algo-ver = " << algo_ver << std::endl;
}
else {
edm::LogError("L1TDQM") << "amc13 payload is empty, cannot extract AMC13 Packet...";
return;
}

std::cout << "algo-rev obtained: " << algo_ver << std::endl;

// Make the Decision which Algo Triggers
edm::Handle<l1t::RegionalMuonCandBxCollection> bmtfKalman;
eve.getByToken(bmtfKalmanToken, bmtfKalman);
edm::Handle<l1t::RegionalMuonCandBxCollection> bmtfLegacy;
eve.getByToken(bmtfLegacyToken, bmtfLegacy);

auto *bmtfKalman_copy = new l1t::RegionalMuonCandBxCollection(*bmtfKalman);
auto *bmtfLegacy_copy = new l1t::RegionalMuonCandBxCollection(*bmtfLegacy);

edm::LogInfo("L1TDQM") << "copy RegionalMuonCandBxCollections created";
edm::LogInfo("L1TDQM") << "bmtfKalman_copy address: " << bmtfKalman_copy;
edm::LogInfo("L1TDQM") << "bmtfLegacy_copy address: " << bmtfLegacy_copy;

std::unique_ptr<l1t::RegionalMuonCandBxCollection> bmtfTriggering, bmtfSecondary;
if ( algo_ver >= 2499805536) {//95000160(hex)
// kalman triggers
bmtfTriggering.reset(bmtfKalman_copy);
bmtfSecondary.reset(bmtfLegacy_copy);
}
else {
// legacy triggers
bmtfTriggering.reset(bmtfLegacy_copy);
bmtfSecondary.reset(bmtfKalman_copy);
}

edm::LogInfo("L1TDQM") << "Triggering and Secondary pointers filled:";
edm::LogInfo("L1TDQM") << "bmtfTriggering address: " << bmtfTriggering.get();
edm::LogInfo("L1TDQM") << "bmtfSecondary address: " << bmtfSecondary.get();

eve.put(std::move(bmtfTriggering),"BMTF");
eve.put(std::move(bmtfSecondary),"BMTF2");

return;
}

using namespace dqmBmtfAlgoSelector;
DEFINE_FWK_MODULE(L1TBMTFAlgoSelector);
59 changes: 59 additions & 0 deletions DQM/L1TMonitor/plugins/L1TBMTFAlgoSelector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef DQM_L1TMonitor_L1TBMTFAlgoSelector_h
#define DQM_L1TMonitor_L1TBMTFAlgoSelector_h

// system requirements
#include <iosfwd>
#include <memory>
#include <vector>
#include <string>
#include <algorithm>

// general requirements
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "DataFormats/Common/interface/Handle.h"

// stage2 requirements
#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h"
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
#include "DataFormats/FEDRawData/interface/FEDHeader.h"
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
#include "DataFormats/L1Trigger/interface/BXVector.h"
#include "EventFilter/L1TRawToDigi/interface/AMC13Spec.h"
#include "EventFilter/L1TRawToDigi/interface/Block.h"


// class decleration

namespace dqmBmtfAlgoSelector{

class L1TBMTFAlgoSelector: public edm::stream::EDProducer<> {

public:

// class constructor
explicit L1TBMTFAlgoSelector(const edm::ParameterSet & ps);
// class destructor
~L1TBMTFAlgoSelector() override;

// member functions
private:
void produce(edm::Event&, const edm::EventSetup&) override;

// data members
edm::EDGetToken bmtfKalmanToken;
edm::EDGetToken bmtfLegacyToken;
edm::EDGetToken fedToken;
};
}
#endif
10 changes: 10 additions & 0 deletions DQM/L1TMonitor/python/L1TBMTFAlgoSelector_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import FWCore.ParameterSet.Config as cms

l1tBmtfAlgoSelector = cms.EDProducer(
'L1TBMTFAlgoSelector',
# verbose = cms.untracked.bool(False),
bmtfKalman = cms.InputTag("simKBmtfDigis:BMTF"),
bmtfLegacy = cms.InputTag("simBmtfDigis:BMTF"),
feds = cms.InputTag("rawDataCollector")
)

16 changes: 8 additions & 8 deletions DQM/L1TMonitor/python/L1TStage2BMTF_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@
l1tStage2BmtfZeroSuppFatEvts.monitorDir = cms.untracked.string("L1T/L1TStage2BMTF/zeroSuppression/FatEvts")
l1tStage2BmtfZeroSuppFatEvts.maxFEDReadoutSize = cms.untracked.int32(25000)

#New Kalman Plots for BMTF
l1tStage2KalmanBmtf = l1tStage2Bmtf.clone()
l1tStage2KalmanBmtf.bmtfSource = cms.InputTag("bmtfDigis","kBMTF")
l1tStage2KalmanBmtf.monitorDir = cms.untracked.string("L1T/L1TStage2BMTF/L1TStage2KalmanBMTF")
l1tStage2KalmanBmtf.verbose = cms.untracked.bool(False)
l1tStage2KalmanBmtf.kalman = cms.untracked.bool(True)
# Plots for BMTF's Secondary Algo
l1tStage2BmtfSecond = l1tStage2Bmtf.clone()
l1tStage2BmtfSecond.bmtfSource = cms.InputTag("bmtfDigis","BMTF2")
l1tStage2BmtfSecond.monitorDir = cms.untracked.string("L1T/L1TStage2BMTF/L1TStage2BMTF-Secondary")
l1tStage2BmtfSecond.verbose = cms.untracked.bool(False)
l1tStage2BmtfSecond.isBmtf = cms.untracked.bool(True)

# sequences
l1tStage2BmtfOnlineDQMSeq = cms.Sequence(
l1tStage2Bmtf +
l1tStage2BmtfZeroSupp +
l1tStage2KalmanBmtf
l1tStage2BmtfSecond +
l1tStage2BmtfZeroSupp

)

Expand Down
22 changes: 14 additions & 8 deletions DQM/L1TMonitor/python/L1TStage2Emulator_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
valCaloStage2Layer2Digis = simCaloStage2Digis.clone()
valCaloStage2Layer2Digis.towerToken = cms.InputTag("caloStage2Digis", "CaloTower")

# BMTF
# BMTF-Legacy
from L1Trigger.L1TMuonBarrel.simBmtfDigis_cfi import *
valBmtfDigis = simBmtfDigis.clone()
valBmtfDigis.DTDigi_Source = cms.InputTag("bmtfDigis")
valBmtfDigis.DTDigi_Theta_Source = cms.InputTag("bmtfDigis")

# KBMTF
# BMTF-Kalman
from L1Trigger.L1TMuonBarrel.simKBmtfDigis_cfi import *
from L1Trigger.L1TMuonBarrel.simKBmtfStubs_cfi import *
valKBmtfStubs = simKBmtfStubs.clone()
Expand All @@ -33,6 +33,12 @@
valKBmtfDigis = simKBmtfDigis.clone()
valKBmtfDigis.src = cms.InputTag("valKBmtfStubs")

# BMTF-AlgoTriggerSelector
from DQM.L1TMonitor.L1TBMTFAlgoSelector_cfi import *
valBmtfAlgoSel = l1tBmtfAlgoSelector.clone()
valBmtfAlgoSel.bmtfKalman = cms.InputTag("valKBmtfDigis:BMTF")
valBmtfAlgoSel.bmtfLegacy = cms.InputTag("valBmtfDigis:BMTF")

# OMTF
from L1Trigger.L1TMuonOverlap.simOmtfDigis_cfi import *
valOmtfDigis = simOmtfDigis.clone()
Expand All @@ -43,7 +49,9 @@

# EMTF
from L1Trigger.L1TMuonEndCap.simEmtfDigis_cfi import *
valEmtfStage2Digis = simEmtfDigisData.clone()
valEmtfStage2Digis = simEmtfDigis.clone()
valEmtfStage2Digis.CSCInput = "emtfStage2Digis"
valEmtfStage2Digis.RPCInput = "muonRPCDigis"

# uGMT
from L1Trigger.L1TMuon.simGmtStage2Digis_cfi import *
Expand Down Expand Up @@ -78,6 +86,7 @@
valBmtfDigis +
valKBmtfStubs +
valKBmtfDigis +
valBmtfAlgoSel +
valOmtfDigis +
valEmtfStage2Digis +
valGmtCaloSumDigis +
Expand All @@ -101,9 +110,7 @@

# BMTF
from DQM.L1TMonitor.L1TdeStage2BMTF_cfi import *

# kBMTF
from DQM.L1TMonitor.L1TdeStage2kBMTF_cff import *
from DQM.L1TMonitor.L1TdeStage2BMTFSecond_cff import *

# OMTF
from DQM.L1TMonitor.L1TdeStage2OMTF_cfi import *
Expand All @@ -124,7 +131,7 @@
# sequence to run for every event
l1tStage2EmulatorOnlineDQM = cms.Sequence(
l1tdeStage2Bmtf +
l1tdeStage2KalmanBmtf +
l1tdeStage2BmtfSecond +
l1tdeStage2Omtf +
l1tdeStage2EmtfOnlineDQMSeq +
l1tStage2uGMTEmulatorOnlineDQMSeq +
Expand All @@ -138,4 +145,3 @@
l1tdeStage2CaloLayer2 +
l1tStage2CaloLayer2Emul
)

21 changes: 21 additions & 0 deletions DQM/L1TMonitor/python/L1TdeStage2BMTFSecond_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import FWCore.ParameterSet.Config as cms

# the Emulator kBMTF DQM module
from DQM.L1TMonitor.L1TdeStage2BMTF_cfi import *

# compares the unpacked BMTF2 regional muon collection to the emulated BMTF2 regional muon collection (after the TriggerAlgoSelector decide which is BMTF2)
# Plots for BMTF
l1tdeStage2BmtfSecond = l1tdeStage2Bmtf.clone()
l1tdeStage2BmtfSecond.regionalMuonCollection1 = cms.InputTag("bmtfDigis","BMTF2")
l1tdeStage2BmtfSecond.regionalMuonCollection2 = cms.InputTag("valBmtfAlgoSel", "BMTF2")
l1tdeStage2BmtfSecond.monitorDir = cms.untracked.string("L1TEMU/L1TdeStage2BMTF/L1TdeStage2BMTF-Secondary")
l1tdeStage2BmtfSecond.regionalMuonCollection1Title = cms.untracked.string("BMTF2 data")
l1tdeStage2BmtfSecond.regionalMuonCollection2Title = cms.untracked.string("BMTF2 emulator")
l1tdeStage2BmtfSecond.summaryTitle = cms.untracked.string("Summary of comparison between BMTF2 muons and BMTF2 emulator muons")
l1tdeStage2BmtfSecond.ignoreBin = cms.untracked.vint32(ignoreBinsDeStage2Bmtf)
l1tdeStage2BmtfSecond.verbose = cms.untracked.bool(False)
l1tdeStage2BmtfSecond.isBmtf = cms.untracked.bool(True)



# sequences
4 changes: 3 additions & 1 deletion DQM/L1TMonitor/python/L1TdeStage2BMTF_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
l1tdeStage2Bmtf = DQMEDAnalyzer(
"L1TStage2RegionalMuonCandComp",
regionalMuonCollection1 = cms.InputTag("bmtfDigis", "BMTF"),
regionalMuonCollection2 = cms.InputTag("valBmtfDigis", "BMTF"),
# regionalMuonCollection2 = cms.InputTag("valBmtfDigis", "BMTF"), # didn't remove the default config
regionalMuonCollection2 = cms.InputTag("valBmtfAlgoSel", "BMTF"),
monitorDir = cms.untracked.string("L1TEMU/L1TdeStage2BMTF"),
regionalMuonCollection1Title = cms.untracked.string("BMTF data"),
regionalMuonCollection2Title = cms.untracked.string("BMTF emulator"),
summaryTitle = cms.untracked.string("Summary of comparison between BMTF muons and BMTF emulator muons"),
ignoreBin = cms.untracked.vint32(ignoreBinsDeStage2Bmtf),
verbose = cms.untracked.bool(False),
isBmtf = cms.untracked.bool(True)
)

21 changes: 0 additions & 21 deletions DQM/L1TMonitor/python/L1TdeStage2kBMTF_cff.py

This file was deleted.

Loading