Skip to content

Commit

Permalink
changing to ES consumes for topology
Browse files Browse the repository at this point in the history
(cherry picked from commit 5c0a4a5)
  • Loading branch information
gkaratha authored and ccaillol committed Sep 15, 2022
1 parent 4e8b4b0 commit ef80134
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
26 changes: 14 additions & 12 deletions L1Trigger/L1TTrackMatch/plugins/L1TrackJetProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class L1TrackJetProducer : public stream::EDProducer<> {

// ----------member data ---------------------------

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
const EDGetTokenT<vector<TTTrack<Ref_Phase2TrackerDigi_>>> trackToken_;
const edm::EDGetTokenT<std::vector<l1t::Vertex>> PVtxToken_;
vector<Ptr<L1TTTrackType>> L1TrkPtrs_;
Expand Down Expand Up @@ -99,7 +100,8 @@ class L1TrackJetProducer : public stream::EDProducer<> {
};

L1TrackJetProducer::L1TrackJetProducer(const ParameterSet &iConfig)
: trackToken_(consumes<vector<TTTrack<Ref_Phase2TrackerDigi_>>>(iConfig.getParameter<InputTag>("L1TrackInputTag"))),
: tTopoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd>(edm::ESInputTag("", ""))),
trackToken_(consumes<vector<TTTrack<Ref_Phase2TrackerDigi_>>>(iConfig.getParameter<InputTag>("L1TrackInputTag"))),
PVtxToken_(consumes<vector<l1t::Vertex>>(iConfig.getParameter<InputTag>("L1PVertexCollection"))) {
trkZMax_ = (float)iConfig.getParameter<double>("trk_zMax");
trkPtMax_ = (float)iConfig.getParameter<double>("trk_ptMax");
Expand Down Expand Up @@ -144,11 +146,7 @@ void L1TrackJetProducer::produce(Event &iEvent, const EventSetup &iSetup) {
unique_ptr<TkJetCollection> L1L1TrackJetProducer(new TkJetCollection);

// Read inputs
ESHandle<TrackerTopology> tTopoHandle;
iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
ESHandle<TrackerGeometry> tGeomHandle;
iSetup.get<TrackerDigiGeometryRecord>().get(tGeomHandle);
const TrackerTopology *const tTopo = tTopoHandle.product();
const TrackerTopology& tTopo = iSetup.getData(tTopoToken_);

edm::Handle<vector<TTTrack<Ref_Phase2TrackerDigi_>>> TTTrackHandle;
iEvent.getByToken(trackToken_, TTTrackHandle);
Expand All @@ -172,8 +170,8 @@ void L1TrackJetProducer::produce(Event &iEvent, const EventSetup &iSetup) {
for (int istub = 0; istub < trk_nstubs; istub++) { // loop over the stubs
DetId detId(trkPtr->getStubRefs().at(istub)->getDetId());
if (detId.det() == DetId::Detector::Tracker) {
if ((detId.subdetId() == StripSubdetector::TOB && tTopo->tobLayer(detId) <= 3) ||
(detId.subdetId() == StripSubdetector::TID && tTopo->tidRing(detId) <= 9))
if ((detId.subdetId() == StripSubdetector::TOB && tTopo.tobLayer(detId) <= 3) ||
(detId.subdetId() == StripSubdetector::TID && tTopo.tidRing(detId) <= 9))
trk_nPS++;
}
}
Expand Down Expand Up @@ -356,14 +354,18 @@ void L1TrackJetProducer::endStream() {}
bool L1TrackJetProducer::trackQualityCuts(int trk_nstub, float trk_chi2, float trk_bendchi2) {
bool PassQuality = false;
if (!displaced_) {
if (trk_nstub == 4 && trk_bendchi2 < nStubs4PromptBend_ && trk_chi2 < nStubs4PromptChi2_) // 4 stubs are the lowest track quality and have different cuts
if (trk_nstub == 4 && trk_bendchi2 < nStubs4PromptBend_ &&
trk_chi2 < nStubs4PromptChi2_) // 4 stubs are the lowest track quality and have different cuts
PassQuality = true;
if (trk_nstub > 4 && trk_bendchi2 < nStubs5PromptBend_ && trk_chi2 < nStubs5PromptChi2_) // above 4 stubs diffent selection imposed (genrally looser)
if (trk_nstub > 4 && trk_bendchi2 < nStubs5PromptBend_ &&
trk_chi2 < nStubs5PromptChi2_) // above 4 stubs diffent selection imposed (genrally looser)
PassQuality = true;
} else {
if (trk_nstub == 4 && trk_bendchi2 < nStubs4DisplacedBend_ && trk_chi2 < nStubs4DisplacedChi2_) // 4 stubs are the lowest track quality and have different cuts
if (trk_nstub == 4 && trk_bendchi2 < nStubs4DisplacedBend_ &&
trk_chi2 < nStubs4DisplacedChi2_) // 4 stubs are the lowest track quality and have different cuts
PassQuality = true;
if (trk_nstub > 4 && trk_bendchi2 < nStubs5DisplacedBend_ && trk_chi2 < nStubs5DisplacedChi2_) // above 4 stubs diffent selection imposed (genrally looser)
if (trk_nstub > 4 && trk_bendchi2 < nStubs5DisplacedBend_ &&
trk_chi2 < nStubs5DisplacedChi2_) // above 4 stubs diffent selection imposed (genrally looser)
PassQuality = true;
}
return PassQuality;
Expand Down
16 changes: 8 additions & 8 deletions L1Trigger/L1TTrackMatch/plugins/L1TrackJetProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct MaxZBin {
float ht; //sum of all cluster pTs--only the zbin with the maximum ht is stored
};

std::vector<EtaPhiBin> L1_clustering(EtaPhiBin *phislice, int etaBins_, float etaStep_) {
inline std::vector<EtaPhiBin> L1_clustering(EtaPhiBin *phislice, int etaBins_, float etaStep_) {
std::vector<EtaPhiBin> clusters;
// Find eta-phibin with maxpT, make center of cluster, add neighbors if not already used
int nclust = 0;
Expand Down Expand Up @@ -117,15 +117,15 @@ std::vector<EtaPhiBin> L1_clustering(EtaPhiBin *phislice, int etaBins_, float et
return clusters;
}

void Fill_L2Cluster(EtaPhiBin &bin, float pt, int ntrk, int ndtrk, std::vector<unsigned int> trkidx) {
inline void Fill_L2Cluster(EtaPhiBin &bin, float pt, int ntrk, int ndtrk, std::vector<unsigned int> trkidx) {
bin.pTtot += pt;
bin.numtracks += ntrk;
bin.numtdtrks += ndtrk;
for (unsigned int itrk = 0; itrk < trkidx.size(); itrk++)
bin.trackidx.push_back(trkidx[itrk]);
}

float DPhi(float phi1, float phi2) {
inline float DPhi(float phi1, float phi2) {
float x = phi1 - phi2;
if (x >= M_PI)
x -= 2 * M_PI;
Expand All @@ -134,13 +134,13 @@ float DPhi(float phi1, float phi2) {
return x;
}

std::vector<EtaPhiBin> L2_clustering(std::vector<std::vector<EtaPhiBin>> &L1clusters,
int phiBins_,
float phiStep_,
float etaStep_) {
inline std::vector<EtaPhiBin> L2_clustering(std::vector<std::vector<EtaPhiBin>> &L1clusters,
int phiBins_,
float phiStep_,
float etaStep_) {
std::vector<EtaPhiBin> clusters;
for (int phibin = 0; phibin < phiBins_; ++phibin) { //Find eta-phibin with highest pT
if (L1clusters[phibin].size() == 0)
if (L1clusters[phibin].empty())
continue;

// sort L1 clusters max -> min
Expand Down

0 comments on commit ef80134

Please sign in to comment.