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

Migrate rest of CSCTFTrackProducer to EventSetup consumes #31801

Merged
merged 1 commit into from
Oct 20, 2020
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
29 changes: 21 additions & 8 deletions L1Trigger/CSCTrackFinder/interface/CSCTFPtLUT.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
#ifndef CSCTrackFinder_CSCTFPtLUT_h
#define CSCTrackFinder_CSCTFPtLUT_h

#include <FWCore/ParameterSet/interface/ParameterSet.h>
#include <L1Trigger/CSCTrackFinder/interface/CSCTrackFinderDataTypes.h>
#include <CondFormats/L1TObjects/interface/L1MuTriggerScales.h>
#include <CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h>
#include <L1Trigger/CSCTrackFinder/interface/CSCTFPtMethods.h>
#include <FWCore/ParameterSet/interface/FileInPath.h>
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "L1Trigger/CSCTrackFinder/interface/CSCTrackFinderDataTypes.h"
#include "CondFormats/L1TObjects/interface/L1MuCSCPtLut.h"
#include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
#include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
#include "CondFormats/DataRecord/interface/L1MuCSCPtLutRcd.h"
#include "CondFormats/DataRecord/interface/L1MuTriggerScalesRcd.h"
#include "CondFormats/DataRecord/interface/L1MuTriggerPtScaleRcd.h"
#include "L1Trigger/CSCTrackFinder/interface/CSCTFPtMethods.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
///KK
#include <FWCore/Framework/interface/EventSetup.h>
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/EventSetup.h"
///

class CSCTFPtLUT {
public:
struct Tokens {
edm::ESGetToken<L1MuCSCPtLut, L1MuCSCPtLutRcd> ptLUT;
edm::ESGetToken<L1MuTriggerScales, L1MuTriggerScalesRcd> scales;
edm::ESGetToken<L1MuTriggerPtScale, L1MuTriggerPtScaleRcd> ptScale;
};

static Tokens consumes(edm::ConsumesCollector iC);

///KK
CSCTFPtLUT(const edm::EventSetup& c);
CSCTFPtLUT(const edm::EventSetup& c, const Tokens& tokens);
///

CSCTFPtLUT(const edm::ParameterSet&, const L1MuTriggerScales* scales, const L1MuTriggerPtScale* ptScale);
Expand Down
29 changes: 19 additions & 10 deletions L1Trigger/CSCTrackFinder/interface/CSCTFSectorProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,29 @@
#include <vector>
#include <map>
#include <string>
#include <DataFormats/L1CSCTrackFinder/interface/L1CSCTrackCollection.h>
#include <DataFormats/L1CSCTrackFinder/interface/TrackStub.h>
#include <DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h>
#include <FWCore/ParameterSet/interface/ParameterSet.h>

#include <L1Trigger/CSCTrackFinder/interface/CSCSectorReceiverLUT.h>
#include <L1Trigger/CSCTrackFinder/interface/CSCTFSPCoreLogic.h>
#include <L1Trigger/CSCTrackFinder/interface/CSCTFPtLUT.h>
#include "CondFormats/L1TObjects/interface/L1MuCSCTFConfiguration.h"
#include "CondFormats/DataRecord/interface/L1MuCSCTFConfigurationRcd.h"
#include "DataFormats/L1CSCTrackFinder/interface/L1CSCTrackCollection.h"
#include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h"
#include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "L1Trigger/CSCTrackFinder/interface/CSCSectorReceiverLUT.h"
#include "L1Trigger/CSCTrackFinder/interface/CSCTFSPCoreLogic.h"
#include "L1Trigger/CSCTrackFinder/interface/CSCTFPtLUT.h"
///KK
#include <FWCore/Framework/interface/EventSetup.h>
#include "FWCore/Framework/interface/EventSetup.h"
///

class CSCTFSectorProcessor {
public:
struct Tokens {
CSCTFPtLUT::Tokens ptLUT;
edm::ESGetToken<L1MuCSCTFConfiguration, L1MuCSCTFConfigurationRcd> config;
};

static Tokens consumes(const edm::ParameterSet& pset, edm::ConsumesCollector iC);

CSCTFSectorProcessor(const unsigned& endcap,
const unsigned& sector,
const edm::ParameterSet& pset,
Expand All @@ -33,7 +42,7 @@ class CSCTFSectorProcessor {
const L1MuTriggerPtScale* ptScale);

///KK
void initialize(const edm::EventSetup& c);
void initialize(const edm::EventSetup& c, const Tokens& tokens);
///

~CSCTFSectorProcessor();
Expand Down
6 changes: 3 additions & 3 deletions L1Trigger/CSCTrackFinder/plugins/CSCTFTrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ CSCTFTrackProducer::CSCTFTrackProducer(const edm::ParameterSet& pset)
m_scalesToken(esConsumes<L1MuTriggerScales, L1MuTriggerScalesRcd>()),
m_ptScaleToken(esConsumes<L1MuTriggerPtScale, L1MuTriggerPtScaleRcd>()),
m_pDDToken(esConsumes<CSCGeometry, MuonGeometryRecord>()),
sp_pset{pset.getParameter<edm::ParameterSet>("SectorProcessor")} {
sp_pset{pset.getParameter<edm::ParameterSet>("SectorProcessor")},
m_builderTokens(CSCTFTrackBuilder::consumes(sp_pset, consumesCollector())) {
m_scalesCacheID = 0ULL;
m_ptScaleCacheID = 0ULL;
produces<L1CSCTrackCollection>();
Expand All @@ -48,10 +49,9 @@ void CSCTFTrackProducer::produce(edm::Event& e, const edm::EventSetup& c) {
edm::ESHandle<L1MuTriggerScales> scales = c.getHandle(m_scalesToken);

edm::ESHandle<L1MuTriggerPtScale> ptScale = c.getHandle(m_ptScaleToken);
c.get<L1MuTriggerPtScaleRcd>().get(ptScale);

my_builder = std::make_unique<CSCTFTrackBuilder>(sp_pset, TMB07, scales.product(), ptScale.product());
my_builder->initialize(c);
my_builder->initialize(c, m_builderTokens);

m_scalesCacheID = c.get<L1MuTriggerScalesRcd>().cacheIdentifier();
m_ptScaleCacheID = c.get<L1MuTriggerPtScaleRcd>().cacheIdentifier();
Expand Down
1 change: 1 addition & 0 deletions L1Trigger/CSCTrackFinder/plugins/CSCTFTrackProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class CSCTFTrackProducer : public edm::one::EDProducer<edm::one::SharedResources
const edm::ESGetToken<L1MuTriggerPtScale, L1MuTriggerPtScaleRcd> m_ptScaleToken;
const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> m_pDDToken;
const edm::ParameterSet sp_pset;
const CSCTFTrackBuilder::Tokens m_builderTokens;
unsigned long long m_scalesCacheID;
unsigned long long m_ptScaleCacheID;
std::unique_ptr<CSCTFTrackBuilder> my_builder;
Expand Down
37 changes: 16 additions & 21 deletions L1Trigger/CSCTrackFinder/src/CSCTFPtLUT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,8 @@ bool CSCTFPtLUT::lut_read_in = false;
// CSCTFPtMethods CSCTFPtLUT::ptMethods;

///KK
#include "CondFormats/L1TObjects/interface/L1MuCSCPtLut.h"
#include "CondFormats/DataRecord/interface/L1MuCSCPtLutRcd.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include <L1Trigger/CSCTrackFinder/interface/CSCTFPtLUT.h>

#include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
#include "CondFormats/DataRecord/interface/L1MuTriggerScalesRcd.h"
#include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
#include "CondFormats/DataRecord/interface/L1MuTriggerPtScaleRcd.h"

// info for getPtScale() pt scale in GeV
// low edges of pt bins
/* const float ptscale[33] = { */
Expand Down Expand Up @@ -92,31 +84,34 @@ const int CSCTFPtLUT::dEtaCut_Open[24] = {7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,

const int CSCTFPtLUT::getPtbyMLH = 0xFFFF; // all modes on

CSCTFPtLUT::CSCTFPtLUT(const edm::EventSetup& es) : read_pt_lut(true), isBinary(false) {
CSCTFPtLUT::Tokens CSCTFPtLUT::consumes(edm::ConsumesCollector iC) {
Tokens tok;
if (not lut_read_in) {
tok.ptLUT = iC.esConsumes();
}
tok.scales = iC.esConsumes();
tok.ptScale = iC.esConsumes();
return tok;
}

CSCTFPtLUT::CSCTFPtLUT(const edm::EventSetup& es, const Tokens& tokens) : read_pt_lut(true), isBinary(false) {
pt_method = 34;
//std::cout << "pt_method from 4 " << std::endl;
lowQualityFlag = 4;
isBeamStartConf = true;
if (!lut_read_in) {
pt_lut = new ptdat[1 << 21];

edm::ESHandle<L1MuCSCPtLut> ptLUT;
es.get<L1MuCSCPtLutRcd>().get(ptLUT);
const L1MuCSCPtLut* myConfigPt_ = ptLUT.product();
const L1MuCSCPtLut& myConfigPt_ = es.getData(tokens.ptLUT);

memcpy((void*)pt_lut, (void*)myConfigPt_->lut(), (1 << 21) * sizeof(ptdat));
memcpy((void*)pt_lut, (void*)myConfigPt_.lut(), (1 << 21) * sizeof(ptdat));

lut_read_in = true;
}
edm::ESHandle<L1MuTriggerScales> scales;
es.get<L1MuTriggerScalesRcd>().get(scales);
trigger_scale = scales.product();

edm::ESHandle<L1MuTriggerPtScale> ptScale;
es.get<L1MuTriggerPtScaleRcd>().get(ptScale);
trigger_ptscale = ptScale.product();
trigger_scale = &es.getData(tokens.scales);
trigger_ptscale = &es.getData(tokens.ptScale);

ptMethods = CSCTFPtMethods(ptScale.product());
ptMethods = CSCTFPtMethods(trigger_ptscale);
}
///

Expand Down
21 changes: 13 additions & 8 deletions L1Trigger/CSCTrackFinder/src/CSCTFSectorProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@

#include <FWCore/MessageLogger/interface/MessageLogger.h>

#include "CondFormats/L1TObjects/interface/L1MuCSCTFConfiguration.h"
#include "CondFormats/DataRecord/interface/L1MuCSCTFConfigurationRcd.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include <cstdlib>
#include <sstream>
#include <strings.h>

const std::string CSCTFSectorProcessor::FPGAs[5] = {"F1", "F2", "F3", "F4", "F5"};

CSCTFSectorProcessor::Tokens CSCTFSectorProcessor::consumes(const edm::ParameterSet& pset, edm::ConsumesCollector iC) {
Tokens tok;
if (not pset.getParameter<bool>("initializeFromPSet")) {
tok.ptLUT = CSCTFPtLUT::consumes(iC);
tok.config = iC.esConsumes();
}
return tok;
}

CSCTFSectorProcessor::CSCTFSectorProcessor(const unsigned& endcap,
const unsigned& sector,
const edm::ParameterSet& pset,
Expand Down Expand Up @@ -179,21 +185,20 @@ CSCTFSectorProcessor::CSCTFSectorProcessor(const unsigned& endcap,
firmSP_Map.insert(std::pair<int, int>(20140515, 20140515));
}

void CSCTFSectorProcessor::initialize(const edm::EventSetup& c) {
void CSCTFSectorProcessor::initialize(const edm::EventSetup& c, const Tokens& tokens) {
initFail_ = false;
if (!initializeFromPSet) {
// Only pT lut can be initialized from EventSetup, all front LUTs are initialized locally from their parametrizations
LogDebug("CSCTFSectorProcessor") << "Initializing endcap: " << m_endcap << " sector:" << m_sector
<< "SP:" << (m_endcap - 1) * 6 + (m_sector - 1);
LogDebug("CSCTFSectorProcessor") << "Initializing pT LUT from EventSetup";

ptLUT_ = new CSCTFPtLUT(c);
ptLUT_ = new CSCTFPtLUT(c, tokens.ptLUT);

// Extract from EventSetup alternative (to the one, used in constructor) ParameterSet
edm::ESHandle<L1MuCSCTFConfiguration> config;
c.get<L1MuCSCTFConfigurationRcd>().get(config);
const L1MuCSCTFConfiguration& config = c.getData(tokens.config);
// And initialize only those parameters, which left uninitialized during construction
readParameters(config.product()->parameters((m_endcap - 1) * 6 + (m_sector - 1)));
readParameters(config.parameters((m_endcap - 1) * 6 + (m_sector - 1)));
}

// ---------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions L1Trigger/CSCTrackFinder/src/CSCTFTrackBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "CondFormats/L1TObjects/interface/L1MuCSCTFConfiguration.h"
#include "CondFormats/DataRecord/interface/L1MuCSCTFConfigurationRcd.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include <sstream>
#include <cstdlib>

Expand All @@ -30,11 +29,11 @@ CSCTFTrackBuilder::CSCTFTrackBuilder(const edm::ParameterSet& pset,
}
}

void CSCTFTrackBuilder::initialize(const edm::EventSetup& c) {
void CSCTFTrackBuilder::initialize(const edm::EventSetup& c, const Tokens& tokens) {
//my_dtrc->initialize(c);
for (int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e) {
for (int s = CSCTriggerNumbering::minTriggerSectorId(); s <= CSCTriggerNumbering::maxTriggerSectorId(); ++s) {
my_SPs[e - 1][s - 1]->initialize(c);
my_SPs[e - 1][s - 1]->initialize(c, tokens);
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions L1Trigger/CSCTrackFinder/src/CSCTFTrackBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@
#include <cstring>
#include <FWCore/Framework/interface/EventSetup.h>
#include <FWCore/ParameterSet/interface/ParameterSet.h>
#include "L1Trigger/CSCTrackFinder/interface/CSCTFSectorProcessor.h"

class CSCMuonPortCard;
class CSCTFSectorProcessor;
class L1MuTriggerScales;
class L1MuTriggerPtScale;

class CSCTFTrackBuilder {
public:
void initialize(const edm::EventSetup& c);
using Tokens = CSCTFSectorProcessor::Tokens;
static Tokens consumes(const edm::ParameterSet& pset, edm::ConsumesCollector iC) {
return CSCTFSectorProcessor::consumes(pset, iC);
}

void initialize(const edm::EventSetup& c, const Tokens& tokens);

enum { nEndcaps = 2, nSectors = 6 };

Expand Down