Skip to content

Commit

Permalink
Merge pull request cms-sw#5 from slava77/CMSSW_6_2_0_SLHC12/tkMuSW-ad…
Browse files Browse the repository at this point in the history
…dCand-5par-gemphi

updates to L1TkMus and extended mus
  • Loading branch information
EmanuelPerez committed Jun 25, 2014
2 parents ab180c4 + 1c5ccc0 commit 34cdf5f
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 52 deletions.
112 changes: 69 additions & 43 deletions L1Trigger/L1ExtraFromDigis/src/L1MuonParticleExtendedProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_ ;

Expand Down Expand Up @@ -114,7 +118,15 @@ L1MuonParticleExtendedProducer::produce( edm::Event& iEvent,
int curMuCollIdx = -1; //index of the GMT-based
for (auto gmtRO : gmtROs.getRecords()){
vector<int> cscGmtIdxs(4,-1); //index into muColl for a given CSC cand
for (auto const gmtCand : gmtRO.getGMTCands() ){
vector<int> 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 ;
Expand All @@ -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++;
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class L1TkMuonFromExtendedProducer : public edm::EDProducer {
// bool closest_ ;
bool correctGMTPropForTkZ_;

bool use5ParameterFit_;
} ;


Expand All @@ -114,6 +115,7 @@ L1TkMuonFromExtendedProducer::L1TkMuonFromExtendedProducer(const edm::ParameterS

correctGMTPropForTkZ_ = iConfig.getParameter<bool>("correctGMTPropForTkZ");

use5ParameterFit_ = iConfig.getParameter<bool>("use5ParameterFit");
produces<L1TkMuonParticleCollection>();
}

Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -232,15 +242,18 @@ L1TkMuonFromExtendedProducer::produce(edm::Event& iEvent, const edm::EventSetup&
<<" mutk "<<l1mu.pt()<<" "<<l1mu.eta()<<" "<<l1mu.phi()<<" delta "<<dEta<<" "<<dPhi<<" cut "<<etaCut<<" "<<phiCut;
if (dEta < etaCut && dPhi < phiCut){
Ptr< L1TkTrackType > 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

)

Expand Down

0 comments on commit 34cdf5f

Please sign in to comment.