Skip to content

Commit

Permalink
Merge pull request cms-sw#45476 from elfontan/EF_tvCodeForGT_CMSSW140X
Browse files Browse the repository at this point in the history
Adds muon shower triggers for MC-based test vector production
  • Loading branch information
cmsbuild authored Jul 31, 2024
2 parents 5b23424 + 187569e commit af87a54
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 71 deletions.
57 changes: 57 additions & 0 deletions L1Trigger/L1TGlobal/plugins/GenToInputProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "DataFormats/L1Trigger/interface/EGamma.h"
#include "DataFormats/L1Trigger/interface/Muon.h"
#include "DataFormats/L1Trigger/interface/MuonShower.h"
#include "DataFormats/L1Trigger/interface/Tau.h"
#include "DataFormats/L1Trigger/interface/Jet.h"
#include "DataFormats/L1Trigger/interface/EtSum.h"
Expand Down Expand Up @@ -85,12 +86,14 @@ namespace l1t {
//std::shared_ptr<FirmwareVersion> m_fwv; //not const during testing.

TRandom3* gRandom;
TRandom3* mushowerRandom;

// BX parameters
int bxFirst_;
int bxLast_;

int maxNumMuCands_;
int maxNumMuShowerCands_;
int maxNumJetCands_;
int maxNumEGCands_;
int maxNumTauCands_;
Expand All @@ -115,6 +118,11 @@ namespace l1t {
std::vector<l1t::Muon> muonVec_bx0;
std::vector<l1t::Muon> muonVec_bxp1;

std::vector<l1t::MuonShower> muonShowerVec_bxm2;
std::vector<l1t::MuonShower> muonShowerVec_bxm1;
std::vector<l1t::MuonShower> muonShowerVec_bx0;
std::vector<l1t::MuonShower> muonShowerVec_bxp1;

std::vector<l1t::EGamma> egammaVec_bxm2;
std::vector<l1t::EGamma> egammaVec_bxm1;
std::vector<l1t::EGamma> egammaVec_bx0;
Expand Down Expand Up @@ -148,6 +156,7 @@ namespace l1t {
// register what you produce
produces<BXVector<l1t::EGamma>>();
produces<BXVector<l1t::Muon>>();
produces<BXVector<l1t::MuonShower>>();
produces<BXVector<l1t::Tau>>();
produces<BXVector<l1t::Jet>>();
produces<BXVector<l1t::EtSum>>();
Expand All @@ -158,6 +167,7 @@ namespace l1t {
bxLast_ = iConfig.getParameter<int>("bxLast");

maxNumMuCands_ = iConfig.getParameter<int>("maxMuCand");
maxNumMuShowerCands_ = iConfig.getParameter<int>("maxMuShowerCand");
maxNumJetCands_ = iConfig.getParameter<int>("maxJetCand");
maxNumEGCands_ = iConfig.getParameter<int>("maxEGCand");
maxNumTauCands_ = iConfig.getParameter<int>("maxTauCand");
Expand Down Expand Up @@ -193,6 +203,7 @@ namespace l1t {

// Setup vectors
std::vector<l1t::Muon> muonVec;
std::vector<l1t::MuonShower> muonShowerVec;
std::vector<l1t::EGamma> egammaVec;
std::vector<l1t::Tau> tauVec;
std::vector<l1t::Jet> jetVec;
Expand Down Expand Up @@ -224,6 +235,7 @@ namespace l1t {
//outputs
std::unique_ptr<l1t::EGammaBxCollection> egammas(new l1t::EGammaBxCollection(0, bxFirst, bxLast));
std::unique_ptr<l1t::MuonBxCollection> muons(new l1t::MuonBxCollection(0, bxFirst, bxLast));
std::unique_ptr<l1t::MuonShowerBxCollection> muonShowers(new l1t::MuonShowerBxCollection(0, bxFirst, bxLast));
std::unique_ptr<l1t::TauBxCollection> taus(new l1t::TauBxCollection(0, bxFirst, bxLast));
std::unique_ptr<l1t::JetBxCollection> jets(new l1t::JetBxCollection(0, bxFirst, bxLast));
std::unique_ptr<l1t::EtSumBxCollection> etsums(new l1t::EtSumBxCollection(0, bxFirst, bxLast));
Expand Down Expand Up @@ -259,6 +271,23 @@ namespace l1t {
LogTrace("GtGenToInputProducer") << ">>> GenParticles collection not found!" << std::endl;
}

// Muon Shower Collection

bool mus0 = (bool)mushowerRandom->Integer(2); // should be [0,1] = 1 bit;
bool mus1 = (bool)mushowerRandom->Integer(2);
bool mus2 = (bool)mushowerRandom->Integer(2);
bool mus2Loose = (bool)mushowerRandom->Integer(2);
bool musoot0 = (bool)mushowerRandom->Integer(2);
bool musoot1 = (bool)mushowerRandom->Integer(2);
bool musoot2Loose = (bool)mushowerRandom->Integer(2);
//fill a vector of MuonShower objs with only one obj per BX, not one obj per muon obj
cout << "GenToInputProducer MuonShower = (MUS0, MUS1, MUS2, MUSOOT0, MUSOOT1) = (" << mus0 << "," << mus1 << ","
<< mus2 << "," << musoot0 << "," << musoot1 << ")" << endl;
l1t::MuonShower muShower(mus0, musoot0, mus2Loose, musoot2Loose, mus1, musoot1, mus2);
muShower.setMusOutOfTime0(musoot0);
muShower.setMusOutOfTime1(musoot1);
muonShowerVec.push_back(muShower);

// Muon Collection
int numMuCands = int(mu_cands_index.size());
Int_t idxMu[numMuCands];
Expand Down Expand Up @@ -635,6 +664,28 @@ namespace l1t {
muonVec.clear();
}

// Fill MuonShowers
for (int iMuShower = 0; iMuShower < int(muonShowerVec_bxm2.size()); iMuShower++) {
muonShowers->push_back(-2, muonShowerVec_bxm2[iMuShower]);
}
for (int iMuShower = 0; iMuShower < int(muonShowerVec_bxm1.size()); iMuShower++) {
muonShowers->push_back(-1, muonShowerVec_bxm1[iMuShower]);
}
for (int iMuShower = 0; iMuShower < int(muonShowerVec_bx0.size()); iMuShower++) {
muonShowers->push_back(0, muonShowerVec_bx0[iMuShower]);
}
for (int iMuShower = 0; iMuShower < int(muonShowerVec_bxp1.size()); iMuShower++) {
muonShowers->push_back(1, muonShowerVec_bxp1[iMuShower]);
}
if (emptyBxTrailer_ <= (emptyBxEvt_ - eventCnt_)) {
for (int iMuShower = 0; iMuShower < int(muonShowerVec.size()); iMuShower++) {
muonShowers->push_back(2, muonShowerVec[iMuShower]);
}
} else {
// this event is part of empty trailer...clear out data
muonShowerVec.clear();
}

// Fill Egammas
for (int iEG = 0; iEG < int(egammaVec_bxm2.size()); iEG++) {
egammas->push_back(-2, egammaVec_bxm2[iEG]);
Expand Down Expand Up @@ -737,34 +788,39 @@ namespace l1t {

iEvent.put(std::move(egammas));
iEvent.put(std::move(muons));
iEvent.put(std::move(muonShowers));
iEvent.put(std::move(taus));
iEvent.put(std::move(jets));
iEvent.put(std::move(etsums));
iEvent.put(std::move(extCond));

// Now shift the bx data by one to prepare for next event.
muonVec_bxm2 = muonVec_bxm1;
muonShowerVec_bxm2 = muonShowerVec_bxm1;
egammaVec_bxm2 = egammaVec_bxm1;
tauVec_bxm2 = tauVec_bxm1;
jetVec_bxm2 = jetVec_bxm1;
etsumVec_bxm2 = etsumVec_bxm1;
extCond_bxm2 = extCond_bxm1;

muonVec_bxm1 = muonVec_bx0;
muonShowerVec_bxm1 = muonShowerVec_bx0;
egammaVec_bxm1 = egammaVec_bx0;
tauVec_bxm1 = tauVec_bx0;
jetVec_bxm1 = jetVec_bx0;
etsumVec_bxm1 = etsumVec_bx0;
extCond_bxm1 = extCond_bx0;

muonVec_bx0 = muonVec_bxp1;
muonShowerVec_bx0 = muonShowerVec_bxp1;
egammaVec_bx0 = egammaVec_bxp1;
tauVec_bx0 = tauVec_bxp1;
jetVec_bx0 = jetVec_bxp1;
etsumVec_bx0 = etsumVec_bxp1;
extCond_bx0 = extCond_bxp1;

muonVec_bxp1 = muonVec;
muonShowerVec_bxp1 = muonShowerVec;
egammaVec_bxp1 = egammaVec;
tauVec_bxp1 = tauVec;
jetVec_bxp1 = jetVec;
Expand All @@ -786,6 +842,7 @@ namespace l1t {
srand(0);

gRandom = new TRandom3();
mushowerRandom = new TRandom3();
}

// ------------ method called when ending the processing of a run ------------
Expand Down
Loading

0 comments on commit af87a54

Please sign in to comment.