diff --git a/L1Trigger/L1ExtraFromDigis/src/L1MuonParticleExtendedProducer.cc b/L1Trigger/L1ExtraFromDigis/src/L1MuonParticleExtendedProducer.cc index 6ebdf1933ac6f..13627871bc92f 100644 --- a/L1Trigger/L1ExtraFromDigis/src/L1MuonParticleExtendedProducer.cc +++ b/L1Trigger/L1ExtraFromDigis/src/L1MuonParticleExtendedProducer.cc @@ -47,6 +47,10 @@ class L1MuonParticleExtendedProducer : public edm::EDProducer { private: virtual void produce(edm::Event&, const edm::EventSetup&); + //some helper functions + float getSigmaEta(float eta, float etaP, float etaM) const; + float getSigmaPhi(float phi, float phiP, float phiM) const; + edm::InputTag gmtROSource_ ; edm::InputTag csctfSource_ ; @@ -114,7 +118,15 @@ L1MuonParticleExtendedProducer::produce( edm::Event& iEvent, int curMuCollIdx = -1; //index of the GMT-based for (auto gmtRO : gmtROs.getRecords()){ vector cscGmtIdxs(4,-1); //index into muColl for a given CSC cand - for (auto const gmtCand : gmtRO.getGMTCands() ){ + vector dtGmtIdxs(4,-1); //index into muColl for a given DT cand + + auto const gmtCands = gmtRO.getGMTCands(); + auto const dtCands = gmtRO.getDTBXCands(); + auto const cscCands = gmtRO.getCSCCands(); + auto const rpcBrlCands = gmtRO.getBrlRPCCands(); + auto const rpcFwdCands = gmtRO.getFwdRPCCands(); + + for (auto const gmtCand : gmtCands){ if (gmtCand.empty()) continue; float pt = muPtScale->getPtScale()->getLowEdge( gmtCand.ptIndex() ) + 1.e-6 ; @@ -131,39 +143,40 @@ L1MuonParticleExtendedProducer::produce( edm::Event& iEvent, math::PtEtaPhiMLorentzVector p4( pt, eta, phi, muonMassGeV_); L1MuonParticle l1muP(gmtCand.charge(), p4, gmtCand, gmtCand.bx()); int cscGmtIdx = -1; - if (!gmtCand.isRPC() && gmtCand.isFwd()) cscGmtIdx = gmtCand.getDTCSCIndex(); + if ((!gmtCand.isRPC()) && gmtCand.isFwd()) cscGmtIdx = gmtCand.getDTCSCIndex(); + int dtGmtIdx = -1; + if ((!gmtCand.isRPC()) && (!gmtCand.isFwd())) dtGmtIdx = gmtCand.getDTCSCIndex(); + int rpcGmtIdx = -1; + if (gmtCand.isRPC()) rpcGmtIdx = gmtCand.getRPCIndex(); muColl->push_back(L1MuonParticleExtended(l1muP)); curMuCollIdx++; if (cscGmtIdx>=0) cscGmtIdxs[cscGmtIdx] = curMuCollIdx; + if (dtGmtIdx>=0) dtGmtIdxs[dtGmtIdx] = curMuCollIdx; L1MuonParticleExtended* aGmtCand = &muColl->back(); - float sigmaEta=99; - float dEtaP = std::abs(etaP - eta); - float dEtaM = std::abs(etaM - eta); - if (dEtaP < 1 && dEtaM < 1 && dEtaP > 0 && dEtaM > 0){ - sigmaEta = sqrt(dEtaP*dEtaM); //take geom mean for no particular reason - } else if (dEtaP < 1 || dEtaM < 1) { - sigmaEta = dEtaP < dEtaM && dEtaP >0 ? dEtaP : dEtaM; - } - sigmaEta = sigmaEta/sqrt(12.); - - float sigmaPhi=99; - float dPhiP = std::abs(deltaPhi(phiP, phi)); - float dPhiM = std::abs(deltaPhi(phiM, phi)); - if (dPhiP < 1 && dPhiM < 1 && dPhiP > 0 && dPhiM > 0){ - sigmaPhi = sqrt(dPhiP*dPhiM); //take geom mean for no particular reason - } else if (dPhiP < 1 || dPhiM < 1) { - sigmaPhi = dPhiP < dPhiM && dPhiP > 0 ? dPhiP : dPhiM; - } - sigmaPhi = sigmaPhi/sqrt(12.); + float sigmaEta = getSigmaEta(eta, etaP, etaM); + float sigmaPhi = getSigmaPhi(phi, phiP, phiM); aGmtCand->setSigmaEta(sigmaEta); aGmtCand->setSigmaPhi(sigmaPhi); aGmtCand->setQuality(gmtCand.quality()); - + + //set regional candidates known to this GMT candidate here + if (dtGmtIdx>=0) aGmtCand->setDtCand(dtCands.at(dtGmtIdx)); //use .at, don't really trust the size + if (cscGmtIdx>=0) aGmtCand->setCscCand(cscCands.at(cscGmtIdx)); + if (rpcGmtIdx>=0){ + if (gmtCand.isFwd()) aGmtCand->setRpcCand(rpcFwdCands.at(rpcGmtIdx)); + else aGmtCand->setRpcCand(rpcBrlCands.at(rpcGmtIdx)); + } } - if (1< 2){ //at the moment this is not really "ALL", just up to 4 from CSCTF + // I fill station level data derived from different kind of regional candidates below + // this data is filled for both the GMT candidate and the regional candidates before GMT sorting + // to avoid copy-paste, gmt-driven cands (started in the loop above) are modified below + // only CSCTF details are filled in full + + // The intent is to create one L1MuExtended for each CSCTF track available + if (1< 2){ //at the moment this is not really "ALL", just up to 4 from CSCTF showing up in the GMTReadoutRecord unsigned cscInd = -1; for (auto const csctfReg : gmtRO.getCSCCands() ){ cscInd++; @@ -189,29 +202,11 @@ L1MuonParticleExtendedProducer::produce( edm::Event& iEvent, L1MuonParticleExtended cscParticleTmp(l1muP); cscParticleTmp.setCscCand(csctfReg); - if (gmtParticle) gmtParticle->setCscCand(csctfReg); cscColl->push_back(cscParticleTmp); L1MuonParticleExtended* cscParticle = &cscColl->back(); - float sigmaEta=99; - float dEtaP = std::abs(etaP - eta); - float dEtaM = std::abs(etaM - eta); - if (dEtaP < 1 && dEtaM < 1 && dEtaP > 0 && dEtaM > 0){ - sigmaEta = sqrt(dEtaP*dEtaM); //take geom mean for no particular reason - } else if (dEtaP < 1 || dEtaM < 1) { - sigmaEta = dEtaP < dEtaM && dEtaP >0 ? dEtaP : dEtaM; - } - sigmaEta = sigmaEta/sqrt(12.); - - float sigmaPhi=99; - float dPhiP = std::abs(deltaPhi(phiP, phi)); - float dPhiM = std::abs(deltaPhi(phiM, phi)); - if (dPhiP < 1 && dPhiM < 1 && dPhiP > 0 && dPhiM > 0){ - sigmaPhi = sqrt(dPhiP*dPhiM); //take geom mean for no particular reason - } else if (dPhiP < 1 || dPhiM < 1) { - sigmaPhi = dPhiP < dPhiM && dPhiP > 0 ? dPhiP : dPhiM; - } - sigmaPhi = sigmaPhi/sqrt(12.); + float sigmaEta = getSigmaEta(eta, etaP, etaM); + float sigmaPhi = getSigmaPhi(phi, phiP, phiM); cscParticle->setSigmaEta(sigmaEta); cscParticle->setSigmaPhi(sigmaPhi); @@ -295,6 +290,8 @@ L1MuonParticleExtendedProducer::produce( edm::Event& iEvent, sData.sigmaPhi = dPhi/sqrt(12.); //just the roundoff uncertainty (could be worse) sData.sigmaEta = dEta/sqrt(12.); + sData.bendPhi = aDigi->getGEMDPhi(); //FIXME: need something in normal global coordinates + sData.bendPhiInt = aDigi->getCLCTPattern(); if (aDigi->getBend()) sData.bendPhiInt*=-1; } //LCTs for a given anID @@ -312,6 +309,35 @@ L1MuonParticleExtendedProducer::produce( edm::Event& iEvent, if (writeAllCSCTFs_) iEvent.put( cscColl, "csc" ); } +float L1MuonParticleExtendedProducer::getSigmaEta(float eta, float etaP, float etaM) const{ + float sigmaEta=99; + + float dEtaP = std::abs(etaP - eta); + float dEtaM = std::abs(etaM - eta); + if (dEtaP < 1 && dEtaM < 1 && dEtaP > 0 && dEtaM > 0){ + sigmaEta = sqrt(dEtaP*dEtaM); //take geom mean for no particular reason + } else if (dEtaP < 1 || dEtaM < 1) { + sigmaEta = dEtaP < dEtaM && dEtaP >0 ? dEtaP : dEtaM; + } + + sigmaEta = sigmaEta/sqrt(12.); + + return sigmaEta; +} + +float L1MuonParticleExtendedProducer::getSigmaPhi(float phi, float phiP, float phiM) const{ + float sigmaPhi=99; + float dPhiP = std::abs(deltaPhi(phiP, phi)); + float dPhiM = std::abs(deltaPhi(phiM, phi)); + if (dPhiP < 1 && dPhiM < 1 && dPhiP > 0 && dPhiM > 0){ + sigmaPhi = sqrt(dPhiP*dPhiM); //take geom mean for no particular reason + } else if (dPhiP < 1 || dPhiM < 1) { + sigmaPhi = dPhiP < dPhiM && dPhiP > 0 ? dPhiP : dPhiM; + } + sigmaPhi = sigmaPhi/sqrt(12.); + + return sigmaPhi; +} //define this as a plug-in DEFINE_FWK_MODULE(L1MuonParticleExtendedProducer); diff --git a/SLHCUpgradeSimulations/L1TrackTrigger/plugins/L1TkMuonFromExtendedProducer.cc b/SLHCUpgradeSimulations/L1TrackTrigger/plugins/L1TkMuonFromExtendedProducer.cc index c8871bd44064f..39a63c76185f3 100644 --- a/SLHCUpgradeSimulations/L1TrackTrigger/plugins/L1TkMuonFromExtendedProducer.cc +++ b/SLHCUpgradeSimulations/L1TrackTrigger/plugins/L1TkMuonFromExtendedProducer.cc @@ -90,6 +90,7 @@ class L1TkMuonFromExtendedProducer : public edm::EDProducer { // bool closest_ ; bool correctGMTPropForTkZ_; + bool use5ParameterFit_; } ; @@ -114,6 +115,7 @@ L1TkMuonFromExtendedProducer::L1TkMuonFromExtendedProducer(const edm::ParameterS correctGMTPropForTkZ_ = iConfig.getParameter("correctGMTPropForTkZ"); + use5ParameterFit_ = iConfig.getParameter("use5ParameterFit"); produces(); } @@ -175,6 +177,11 @@ L1TkMuonFromExtendedProducer::produce(edm::Event& iEvent, const edm::EventSetup& //apply something specific here } + const auto& rpcCand = l1mu.rpcCand(); + if (!rpcCand.empty()){ + //apply something specific here + } + float drmin = 999; float ptmax = -1; if (ptmax < 0) ptmax = -1; // dummy @@ -186,20 +193,23 @@ L1TkMuonFromExtendedProducer::produce(edm::Event& iEvent, const edm::EventSetup& LogDebug("MDEBUG")<<"have a gmt, look for a match "; for (auto l1tk : l1tks ){ il1tk++; - float l1tk_pt = l1tk.getMomentum().perp(); + + unsigned int nPars = 4; + if (use5ParameterFit_) nPars = 5; + float l1tk_pt = l1tk.getMomentum(nPars).perp(); if (l1tk_pt < PTMINTRA_) continue; - float l1tk_z = l1tk.getPOCA().z(); + float l1tk_z = l1tk.getPOCA(nPars).z(); if (fabs(l1tk_z) > ZMAX_) continue; - float l1tk_chi2 = l1tk.getChi2(); + float l1tk_chi2 = l1tk.getChi2(nPars); if (l1tk_chi2 > CHI2MAX_) continue; int l1tk_nstubs = l1tk.getStubRefs().size(); if ( l1tk_nstubs < nStubsmin_) continue; - float l1tk_eta = l1tk.getMomentum().eta(); - float l1tk_phi = l1tk.getMomentum().phi(); + float l1tk_eta = l1tk.getMomentum(nPars).eta(); + float l1tk_phi = l1tk.getMomentum(nPars).phi(); float dr2 = deltaR2(l1mu_eta, l1mu_phi, l1tk_eta, l1tk_phi); @@ -232,15 +242,18 @@ L1TkMuonFromExtendedProducer::produce(edm::Event& iEvent, const edm::EventSetup& <<" mutk "< l1tkPtr(l1tksH, match_idx); - auto p3 = matchTk.getMomentum(); + + unsigned int nPars = 4; + if (use5ParameterFit_) nPars = 5; + auto p3 = matchTk.getMomentum(nPars); float p4e = sqrt(0.105658369*0.105658369 + p3.mag2() ); math::XYZTLorentzVector l1tkp4(p3.x(), p3.y(), p3.z(), p4e); - auto tkv3=matchTk.getPOCA(); + auto tkv3=matchTk.getPOCA(nPars); math::XYZPoint v3(tkv3.x(), tkv3.y(), tkv3.z()); float trkisol = -999; - int l1tk_q = matchTk.getRInv()>0? 1: -1; + int l1tk_q = matchTk.getRInv(nPars)>0? 1: -1; L1TkMuonParticle l1tkmu(reco::LeafCandidate(l1tk_q, l1tkp4, v3, -13*l1tk_q )); l1tkmu.setTrkPtr(l1tkPtr); diff --git a/SLHCUpgradeSimulations/L1TrackTrigger/python/l1TkMuonsExt_cfi.py b/SLHCUpgradeSimulations/L1TrackTrigger/python/l1TkMuonsExt_cfi.py index 7b1baad9c89d2..b3ad0aeed1ce0 100644 --- a/SLHCUpgradeSimulations/L1TrackTrigger/python/l1TkMuonsExt_cfi.py +++ b/SLHCUpgradeSimulations/L1TrackTrigger/python/l1TkMuonsExt_cfi.py @@ -12,7 +12,8 @@ # DRmax = cms.double( 0.5 ), nStubsmin = cms.int32( 3 ), # minimum number of stubs # closest = cms.bool( True ), - correctGMTPropForTkZ = cms.bool(True) + correctGMTPropForTkZ = cms.bool(True), + use5ParameterFit = cms.bool(False) #use 4-pars by defaults )