Skip to content

Commit

Permalink
Merge pull request #36839 from elfontan/EF_L1Tfixes
Browse files Browse the repository at this point in the history
Update of some L1T producers for L1TNtuples (legacy modules), of the L1TExtCondProducer, and of the L1MenuViewer
  • Loading branch information
cmsbuild committed Feb 2, 2022
2 parents e4a7ec2 + 9699119 commit d732e13
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 134 deletions.
45 changes: 22 additions & 23 deletions L1Trigger/L1TGlobal/plugins/L1TExtCondProducer.cc
Expand Up @@ -7,10 +7,8 @@
/// \author: D. Puigh OSU
///

// system include files

// user include files

// System include files
// User include files
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
Expand All @@ -30,19 +28,18 @@
#include <FWCore/ParameterSet/interface/ConfigurationDescriptions.h>
#include <FWCore/ParameterSet/interface/ParameterSetDescription.h>

//#include <vector>
#include "DataFormats/L1Trigger/interface/BXVector.h"

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

#include "DataFormats/TCDS/interface/TCDSRecord.h"

#include <vector>

using namespace std;
using namespace edm;
using namespace l1t;

//
// class declaration
// Class declaration
//

class L1TExtCondProducer : public stream::EDProducer<> {
Expand All @@ -55,7 +52,7 @@ class L1TExtCondProducer : public stream::EDProducer<> {
private:
void produce(edm::Event&, const edm::EventSetup&) override;

// ----------member data ---------------------------
// ---------- Member data ---------------------------
// unsigned long long m_paramsCacheId; // Cache-ID from current parameters, to check if needs to be updated.
//std::shared_ptr<const CaloParams> m_dbpars; // Database parameters for the trigger, to be updated as needed.
//std::shared_ptr<const FirmwareVersion> m_fwv;
Expand All @@ -82,7 +79,7 @@ class L1TExtCondProducer : public stream::EDProducer<> {
};

//
// constructors and destructor
// Constructors and destructor
//
L1TExtCondProducer::L1TExtCondProducer(const ParameterSet& iConfig)
: bxFirst_(iConfig.getParameter<int>("bxFirst")),
Expand All @@ -97,12 +94,13 @@ L1TExtCondProducer::L1TExtCondProducer(const ParameterSet& iConfig)

m_triggerRulePrefireVetoBit = GlobalExtBlk::maxExternalConditions - 1;

// Note that the tcdsRecord input tag should be used as InputTag("unpackTcds","tcdsRecord") only for data
if (!(tcdsInputTag_ == edm::InputTag(""))) {
tcdsRecordToken_ = consumes<TCDSRecord>(tcdsInputTag_);
makeTriggerRulePrefireVetoBit_ = true;
}

// register what you produce
// Register what you produce
produces<GlobalExtBlkBxCollection>();

// Initialize parameters
Expand All @@ -112,14 +110,14 @@ L1TExtCondProducer::L1TExtCondProducer(const ParameterSet& iConfig)
L1TExtCondProducer::~L1TExtCondProducer() {}

//
// member functions
// Member functions
//

// ------------ method called to produce the data ------------
void L1TExtCondProducer::produce(Event& iEvent, const EventSetup& iSetup) {
LogDebug("L1TExtCondProducer") << "L1TExtCondProducer::produce function called...\n";

// get / update the trigger menu from the EventSetup
// Get / update the trigger menu from the EventSetup
// local cache & check on cacheIdentifier
unsigned long long l1GtMenuCacheID = iSetup.get<L1TUtmTriggerMenuRcd>().cacheIdentifier();

Expand All @@ -137,9 +135,9 @@ void L1TExtCondProducer::produce(Event& iEvent, const EventSetup& iSetup) {
}

bool TriggerRulePrefireVetoBit(false);
if (makeTriggerRulePrefireVetoBit_) {
// code taken from Nick Smith's EventFilter/L1TRawToDigi/plugins/TriggerRulePrefireVetoFilter.cc

// The following list of checks on the tcdsRecord is relevant only for data;
// code taken from Nick Smith's EventFilter/L1TRawToDigi/plugins/TriggerRulePrefireVetoFilter.cc
if (iEvent.isRealData() && makeTriggerRulePrefireVetoBit_) {
edm::Handle<TCDSRecord> tcdsRecordH;
iEvent.getByToken(tcdsRecordToken_, tcdsRecordH);
const auto& tcdsRecord = *tcdsRecordH.product();
Expand All @@ -151,9 +149,10 @@ void L1TExtCondProducer::produce(Event& iEvent, const EventSetup& iSetup) {
eventHistory.push_back(thisEvent - ((l1a.getBXID() - 1) + l1a.getOrbitNr() * 3564ull));
}

// should be 16 according to TCDSRecord.h, we only care about the last 4
// It should be 16 according to TCDSRecord.h, we only care about the last 4
if (eventHistory.size() < 4) {
edm::LogError("L1TExtCondProducer") << "Unexpectedly small L1A history from TCDSRecord";
throw cms::Exception("L1TExtCondProducer")
<< "Unexpectedly small L1A history from TCDSRecord: (size = " << eventHistory.size() << " < 4)";
}

// No more than 1 L1A in 3 BX
Expand Down Expand Up @@ -191,7 +190,7 @@ void L1TExtCondProducer::produce(Event& iEvent, const EventSetup& iSetup) {
// Setup vectors
GlobalExtBlk extCond_bx;

//outputs
// Outputs
std::unique_ptr<GlobalExtBlkBxCollection> extCond(new GlobalExtBlkBxCollection(0, bxFirst_, bxLast_));

bool foundBptxAND = (m_extBitMap.find("BPTX_plus_AND_minus.v0") != m_extBitMap.end());
Expand All @@ -209,7 +208,7 @@ void L1TExtCondProducer::produce(Event& iEvent, const EventSetup& iSetup) {
if (setBptxOR_ && foundBptxOR)
extCond_bx.setExternalDecision(m_extBitMap["BPTX_plus_OR_minus.v0"], true);

//check for updated Bptx names as well
// Check for updated Bptx names as well
foundBptxAND = (m_extBitMap.find("ZeroBias_BPTX_AND_VME") != m_extBitMap.end());
foundBptxPlus = (m_extBitMap.find("BPTX_B1_VME") != m_extBitMap.end());
foundBptxMinus = (m_extBitMap.find("BPTX_B2_VME") != m_extBitMap.end());
Expand All @@ -225,7 +224,7 @@ void L1TExtCondProducer::produce(Event& iEvent, const EventSetup& iSetup) {
if (setBptxOR_ && foundBptxOR)
extCond_bx.setExternalDecision(m_extBitMap["BPTX_OR_VME"], true);

// set the bit for the TriggerRulePrefireVeto if true
// Set the bit for the TriggerRulePrefireVeto if true
if (TriggerRulePrefireVetoBit)
extCond_bx.setExternalDecision(m_triggerRulePrefireVetoBit, true);

Expand All @@ -237,7 +236,7 @@ void L1TExtCondProducer::produce(Event& iEvent, const EventSetup& iSetup) {
iEvent.put(std::move(extCond));
}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
// ------------ Method fills 'descriptions' with the allowed parameters for the module ------------
void L1TExtCondProducer::fillDescriptions(ConfigurationDescriptions& descriptions) {
// simGtExtFakeProd
edm::ParameterSetDescription desc;
Expand All @@ -251,5 +250,5 @@ void L1TExtCondProducer::fillDescriptions(ConfigurationDescriptions& description
descriptions.add("simGtExtFakeProd", desc);
}

//define this as a plug-in
// Define this as a plug-in
DEFINE_FWK_MODULE(L1TExtCondProducer);
18 changes: 7 additions & 11 deletions L1Trigger/L1TGlobal/test/runGlobalFakeInputProducer.py
Expand Up @@ -39,7 +39,7 @@
else:
globals()[k] = v

neventsPerJob = nevents/njob
neventsPerJob = int(nevents/njob)
skip = job * neventsPerJob

if skip>4:
Expand Down Expand Up @@ -79,15 +79,11 @@
process.source = cms.Source("PoolSource",
secondaryFileNames = cms.untracked.vstring(),
fileNames = cms.untracked.vstring(
"/store/mc/RunIISummer19UL18RECO/GluGluToContinToZZTo4mu_13TeV_MCFM701_pythia8/AODSIM/106X_upgrade2018_realistic_v11_L1v1-v2/110000/664BBEBB-93A9-5B40-AD9C-DE835A79B712.root",
#"/store/mc/RunIISummer20UL18RECO/BuToTau_To3Mu_MuFilter_TuneCP5_13TeV-pythia8-evtgen/AODSIM/106X_upgrade2018_realistic_v11_L1v1-v1/20000/00901296-D966-DF40-AA25-5F7A959B79CA.root",
#"/store/mc/RunIISummer20UL18RECO/DsToTau_To3Mu_MuFilter_TuneCP5_13TeV-pythia8-evtgen/AODSIM/106X_upgrade2018_realistic_v11_L1v1-v1/00000/0003B7FD-6C1E-BF4C-8DA9-BA8A27AF0290.root",
#"/store/mc/RunIISummer19UL18RECO/ZZ_TuneCP5_13TeV-pythia8/AODSIM/106X_upgrade2018_realistic_v11_L1v1-v2/280000/04530FC4-E54D-D34A-950E-9F300321E037.root",
#"/store/mc/RunIIFall15DR76/TT_TuneCUETP8M1_13TeV-powheg-pythia8/AODSIM/25nsFlat10to25TSG_76X_mcRun2_asymptotic_v11_ext3-v1/20000/F03B8956-5D87-E511-8AE9-002590D0AFFC.root",
#"/store/mc/RunIISummer19UL18HLT/TTTo2L2Nu_mtop178p5_TuneCP5_13TeV-powheg-pythia8/GEN-SIM-RAW/102X_upgrade2018_realistic_v15-v2/280000/00429618-85B5-124F-9C16-0C9F07A39E73.root+"
#"/store/mc/PhaseIFall16DR/TT_TuneCUETP8M2T4_13TeV-powheg-pythia8/GEN-SIM-RAW/FlatPU28to62HcalNZSRAW_81X_upgrade2017_realistic_v26-v1/110000/444C2036-84FC-E611-A86D-02163E01433C.root",
#"/store/mc/RunIISpring16DR80/TT_TuneCUETP8M1_13TeV-powheg-pythia8/GEN-SIM-RAW/FlatPU20to70HcalNZSRAW_withHLT_80X_mcRun2_asymptotic_v14_ext3-v1/50000/D6D4CAF2-AD65-E611-9642-001EC94BA169.root",
#"/store/relval/CMSSW_7_6_0_pre7/RelValTTbar_13/GEN-SIM/76X_mcRun2_asymptotic_v9_realBS-v1/00000/0A812333-427C-E511-A80A-0025905964A2.root",
# TTbar CMSSW_12X samples
"/store/relval/CMSSW_12_3_0_pre2/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/122X_mcRun3_2021_realistic_v5-v1/2580000/04b2f8e0-57d6-449c-aa9f-a416c9926f31.root",
"/store/relval/CMSSW_12_3_0_pre2/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/122X_mcRun3_2021_realistic_v5-v1/2580000/12bfbbc7-60fe-44c9-8f04-daa8c7b61406.root",
"/store/relval/CMSSW_12_3_0_pre2/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/122X_mcRun3_2021_realistic_v5-v1/2580000/198e5a8c-8f06-4688-ae0d-5cc51b1eef46.root",
"/store/relval/CMSSW_12_3_0_pre2/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/122X_mcRun3_2021_realistic_v5-v1/2580000/2e6c92bb-4997-4232-8475-04a668d8d163.root",
),
skipEvents = cms.untracked.uint32(skip)
)
Expand Down Expand Up @@ -214,7 +210,7 @@

process.load("L1Trigger.L1TGlobal.TriggerMenu_cff")

xmlMenu="L1Menu_test_mass_3_body_reduced_v2.xml"
xmlMenu="L1Menu_Collisions2022_v0_1_2.xml"
process.TriggerMenu.L1TriggerMenuFile = cms.string(xmlMenu)
process.ESPreferL1TXML = cms.ESPrefer("L1TUtmTriggerMenuESProducer","TriggerMenu")

Expand Down
27 changes: 10 additions & 17 deletions L1Trigger/L1TNtuples/plugins/L1EventTreeProducer.cc
Expand Up @@ -22,7 +22,7 @@ Description: Produce L1 Extra tree

// framework
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.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"
Expand All @@ -46,18 +46,18 @@ Description: Produce L1 Extra tree
// class declaration
//

class L1EventTreeProducer : public edm::EDAnalyzer {
class L1EventTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
explicit L1EventTreeProducer(const edm::ParameterSet&);
~L1EventTreeProducer() override;
~L1EventTreeProducer() override = default;

private:
void beginJob(void) override;
void analyze(const edm::Event&, const edm::EventSetup&) override;
void endJob() override;

public:
L1Analysis::L1AnalysisEvent* l1Event;
std::unique_ptr<L1Analysis::L1AnalysisEvent> l1Event;
L1Analysis::L1AnalysisEventDataFormat* l1EventData;

private:
Expand All @@ -67,24 +67,23 @@ class L1EventTreeProducer : public edm::EDAnalyzer {
// tree
TTree* tree_;

edm::EDGetTokenT<edm::TriggerResults> hltSource_;

// EDM input tags
//edm::EDGetTokenT<l1t::EGammaBxCollection> egToken_;
const edm::EDGetTokenT<edm::TriggerResults> hltSource_;
};

L1EventTreeProducer::L1EventTreeProducer(const edm::ParameterSet& iConfig) {
hltSource_ = consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("hltSource"));

L1EventTreeProducer::L1EventTreeProducer(const edm::ParameterSet& iConfig)
: hltSource_(consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("hltSource"))) {
std::string puMCFile = iConfig.getUntrackedParameter<std::string>("puMCFile", "");
std::string puMCHist = iConfig.getUntrackedParameter<std::string>("puMCHist", "pileup");
std::string puDataFile = iConfig.getUntrackedParameter<std::string>("puDataFile", "");
std::string puDataHist = iConfig.getUntrackedParameter<std::string>("puDataHist", "pileup");

usesResource(TFileService::kSharedResource);

bool useAvgVtx = iConfig.getUntrackedParameter<bool>("useAvgVtx", true);
double maxAllowedWeight = iConfig.getUntrackedParameter<double>("maxAllowedWeight", -1);

l1Event = new L1Analysis::L1AnalysisEvent(
std::make_unique<L1Analysis::L1AnalysisEvent>(
puMCFile, puMCHist, puDataFile, puDataHist, useAvgVtx, maxAllowedWeight, consumesCollector());
l1EventData = l1Event->getData();

Expand All @@ -93,12 +92,6 @@ L1EventTreeProducer::L1EventTreeProducer(const edm::ParameterSet& iConfig) {
tree_->Branch("Event", "L1Analysis::L1AnalysisEventDataFormat", &l1EventData, 32000, 3);
}

L1EventTreeProducer::~L1EventTreeProducer() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
delete l1Event;
}

//
// member functions
//
Expand Down
18 changes: 8 additions & 10 deletions L1Trigger/L1TNtuples/plugins/L1HOTreeProducer.cc
Expand Up @@ -9,7 +9,7 @@

// framework
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.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"
Expand All @@ -30,10 +30,10 @@
// class declaration
//

class L1HOTreeProducer : public edm::EDAnalyzer {
class L1HOTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
explicit L1HOTreeProducer(const edm::ParameterSet&);
~L1HOTreeProducer() override;
~L1HOTreeProducer() override = default;

private:
void beginJob(void) override;
Expand All @@ -52,22 +52,20 @@ class L1HOTreeProducer : public edm::EDAnalyzer {
TTree* tree_;

// EDM input tags
edm::EDGetTokenT<edm::SortedCollection<HODataFrame>> hoDataFrameToken_;
const edm::EDGetTokenT<edm::SortedCollection<HODataFrame>> hoDataFrameToken_;
};

L1HOTreeProducer::L1HOTreeProducer(const edm::ParameterSet& iConfig) {
hoDataFrameToken_ =
consumes<edm::SortedCollection<HODataFrame>>(iConfig.getUntrackedParameter<edm::InputTag>("hoDataFrameToken"));

L1HOTreeProducer::L1HOTreeProducer(const edm::ParameterSet& iConfig)
: hoDataFrameToken_(consumes<edm::SortedCollection<HODataFrame>>(
iConfig.getUntrackedParameter<edm::InputTag>("hoDataFrameToken"))) {
l1HOData = l1HO.getData();
usesResource(TFileService::kSharedResource);

// set up output
tree_ = fs_->make<TTree>("L1HOTree", "L1HOTree");
tree_->Branch("L1HO", "L1Analysis::L1AnalysisL1HODataFormat", &l1HOData, 32000, 3);
}

L1HOTreeProducer::~L1HOTreeProducer() {}

//
// member functions
//
Expand Down

0 comments on commit d732e13

Please sign in to comment.