Skip to content

Commit

Permalink
Merge pull request #24274 from fabiocos/fc-fix24242
Browse files Browse the repository at this point in the history
Technical fixes to L1T code from 24242
  • Loading branch information
cmsbuild committed Aug 13, 2018
2 parents 00d1548 + 7698c92 commit b16f620
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 81 deletions.
90 changes: 42 additions & 48 deletions L1Trigger/L1TCalorimeter/plugins/L1TStage2CaloLayer2Comp.cc
Expand Up @@ -412,22 +412,20 @@ bool L1TStage2CaloLayer2Comp::compareJets(

//bypass sorting bug
if(etGood && !posGood){
l1t::JetBxCollection::const_iterator emulItCheckSort;
l1t::JetBxCollection::const_iterator dataItCheckSort;
for(emulItCheckSort = emulCol->begin(currBx),
dataItCheckSort = jets->begin();
emulItCheckSort != emulCol->end(currBx),
dataItCheckSort != jets->end();
++emulItCheckSort, ++dataItCheckSort){

if(dataItCheckSort->hwEta() > 0) ++nPos;
if(dataItCheckSort->hwEta() < 0) ++nNeg;

if(dataIt->hwPt() == emulItCheckSort->hwPt()
&& dataIt->hwPhi() == emulItCheckSort->hwPhi()
&& dataIt->hwEta() == emulItCheckSort->hwEta())
posGood = true;
}
l1t::JetBxCollection::const_iterator emulItCheckSort;
l1t::JetBxCollection::const_iterator dataItCheckSort;
for(emulItCheckSort = emulCol->begin(currBx) ; emulItCheckSort != emulCol->end(currBx) ; ++emulItCheckSort) {
for (dataItCheckSort = jets->begin(); dataItCheckSort != jets->end(); ++dataItCheckSort){

if(dataItCheckSort->hwEta() > 0) ++nPos;
if(dataItCheckSort->hwEta() < 0) ++nNeg;

if(dataIt->hwPt() == emulItCheckSort->hwPt()
&& dataIt->hwPhi() == emulItCheckSort->hwPhi()
&& dataIt->hwEta() == emulItCheckSort->hwEta())
posGood = true;
}
}
}

if(etGood && dataIt->hwEta() > 0 && ((distance(dataIt, jets->end())-nNeg) < 5))
Expand Down Expand Up @@ -531,22 +529,20 @@ bool L1TStage2CaloLayer2Comp::compareEGs(

//bypass sorting bug
if(etGood && !posGood){
l1t::EGammaBxCollection::const_iterator emulItCheckSort;
l1t::EGammaBxCollection::const_iterator dataItCheckSort;
for(emulItCheckSort = emulCol->begin(currBx),
dataItCheckSort = egs->begin();
emulItCheckSort != emulCol->end(currBx),
dataItCheckSort != egs->end();
++emulItCheckSort, ++dataItCheckSort){

if(dataItCheckSort->hwEta() > 0) ++nPos;
if(dataItCheckSort->hwEta() < 0) ++nNeg;

if(dataIt->hwPt() == emulItCheckSort->hwPt()
&& dataIt->hwPhi() == emulItCheckSort->hwPhi()
&& dataIt->hwEta() == emulItCheckSort->hwEta())
posGood = true;
}
l1t::EGammaBxCollection::const_iterator emulItCheckSort;
l1t::EGammaBxCollection::const_iterator dataItCheckSort;
for(emulItCheckSort = emulCol->begin(currBx); emulItCheckSort != emulCol->end(currBx); ++emulItCheckSort) {
for (dataItCheckSort = egs->begin(); dataItCheckSort != egs->end(); ++dataItCheckSort){

if(dataItCheckSort->hwEta() > 0) ++nPos;
if(dataItCheckSort->hwEta() < 0) ++nNeg;

if(dataIt->hwPt() == emulItCheckSort->hwPt()
&& dataIt->hwPhi() == emulItCheckSort->hwPhi()
&& dataIt->hwEta() == emulItCheckSort->hwEta())
posGood = true;
}
}
}

if(etGood && dataIt->hwEta() > 0 && ((distance(dataIt, egs->end())-nNeg) < 5))
Expand Down Expand Up @@ -650,22 +646,20 @@ bool L1TStage2CaloLayer2Comp::compareTaus(

//bypass sorting bug
if(etGood && !posGood){
l1t::TauBxCollection::const_iterator emulItCheckSort;
l1t::TauBxCollection::const_iterator dataItCheckSort;
for(emulItCheckSort = emulCol->begin(currBx),
dataItCheckSort = taus->begin();
emulItCheckSort != emulCol->end(currBx),
dataItCheckSort != taus->end();
++emulItCheckSort, ++dataItCheckSort){

if(dataItCheckSort->hwEta() > 0) ++nPos;
if(dataItCheckSort->hwEta() < 0) ++nNeg;

if(dataIt->hwPt() == emulItCheckSort->hwPt()
&& dataIt->hwPhi() == emulItCheckSort->hwPhi()
&& dataIt->hwEta() == emulItCheckSort->hwEta())
posGood = true;
}
l1t::TauBxCollection::const_iterator emulItCheckSort;
l1t::TauBxCollection::const_iterator dataItCheckSort;
for(emulItCheckSort = emulCol->begin(currBx); emulItCheckSort != emulCol->end(currBx); ++emulItCheckSort) {
for (dataItCheckSort = taus->begin(); dataItCheckSort != taus->end(); ++dataItCheckSort){

if(dataItCheckSort->hwEta() > 0) ++nPos;
if(dataItCheckSort->hwEta() < 0) ++nNeg;

if(dataIt->hwPt() == emulItCheckSort->hwPt()
&& dataIt->hwPhi() == emulItCheckSort->hwPhi()
&& dataIt->hwEta() == emulItCheckSort->hwEta())
posGood = true;
}
}
}

if(etGood && dataIt->hwEta() > 0 && ((distance(dataIt, taus->end())-nNeg) < 5))
Expand Down
49 changes: 25 additions & 24 deletions L1Trigger/L1TMuonBarrel/test/kalmanTools/kmtfAnalysis.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import ROOT,itertools,math #
from array import array #
from DataFormats.FWLite import Events, Handle
Expand Down Expand Up @@ -68,7 +69,7 @@ def fetchTP(event,etaMax=0.83):
return []
trigger=tH.product()
# for f in range(0,trigger.sizeFilters()):
# print f,trigger.filterLabel(f)
# print(f,trigger.filterLabel(f))
# import pdb;pdb.set_trace()
obj = trigger.getObjects()
index = trigger.filterIndex(ROOT.edm.InputTag("hltL3fL1sMu22Or25L1f0L2f10QL3Filtered27Q::HLT"))
Expand Down Expand Up @@ -278,28 +279,28 @@ def deltaR2( e1, p1, e2, p2):


def log(counter,mystubs,gen,kmtf,bmtf):
print "--------EVENT"+str(counter)+"------------"
print "-----------------------------"
print "-----------------------------"
print 'Stubs:'
print("--------EVENT"+str(counter)+"------------")
print("-----------------------------")
print("-----------------------------")
print('Stubs:')
for stub in mystubs:
print 'wheel={w} sector={sc} station={st} high/low={ts} phi={phi} phiB={phiB} qual={qual} BX={BX} eta1={eta1} eta2={eta2}'.format(w=stub.whNum(),sc=stub.scNum(),st=stub.stNum(),ts=stub.tag(),phi=stub.phi(),phiB=8*stub.phiB(),qual=stub.quality(),BX=stub.bxNum(),eta1=stub.eta1(),eta2=stub.eta2())
print 'Gen muons:'
print('wheel={w} sector={sc} station={st} high/low={ts} phi={phi} phiB={phiB} qual={qual} BX={BX} eta1={eta1} eta2={eta2}'.format(w=stub.whNum(),sc=stub.scNum(),st=stub.stNum(),ts=stub.tag(),phi=stub.phi(),phiB=8*stub.phiB(),qual=stub.quality(),BX=stub.bxNum(),eta1=stub.eta1(),eta2=stub.eta2()))
print('Gen muons:')
for g in gen:
print "Generated muon charge={q} pt={pt} eta={eta} phi={phi}".format(q=g.charge(),pt=g.pt(),eta=g.eta(),phi=g.phi())
print 'BMTF:'
print("Generated muon charge={q} pt={pt} eta={eta} phi={phi}".format(q=g.charge(),pt=g.pt(),eta=g.eta(),phi=g.phi()))
print('BMTF:')
for g in bmtf :
print "BMTF charge={q} pt={pt} eta={eta} phi={phi} qual={qual} dxy={dxy} pt2={pt2} hasFineEta={HF}".format(q=g.charge(),pt=g.pt(),eta=g.eta(),phi=g.phi(),qual=g.quality(),dxy=g.dxy(),pt2=g.ptUnconstrained(),HF=g.hasFineEta())
print 'KMTF:'
print("BMTF charge={q} pt={pt} eta={eta} phi={phi} qual={qual} dxy={dxy} pt2={pt2} hasFineEta={HF}".format(q=g.charge(),pt=g.pt(),eta=g.eta(),phi=g.phi(),qual=g.quality(),dxy=g.dxy(),pt2=g.ptUnconstrained(),HF=g.hasFineEta()))
print('KMTF:')
for g in kmtf :
print "KMTF charge={q} pt={pt} eta={eta} phi={phi} qual={qual} dxy={dxy} pt2={pt2} hasFineEta={HF}".format(q=g.charge(),pt=g.pt(),eta=g.eta(),phi=g.phi(),qual=g.quality(),dxy=g.dxy(),pt2=g.ptUnconstrained(),HF=g.hasFineEta())
print("KMTF charge={q} pt={pt} eta={eta} phi={phi} qual={qual} dxy={dxy} pt2={pt2} hasFineEta={HF}".format(q=g.charge(),pt=g.pt(),eta=g.eta(),phi=g.phi(),qual=g.quality(),dxy=g.dxy(),pt2=g.ptUnconstrained(),HF=g.hasFineEta()))




print "-----------------------------"
print "-----------------------------"
print "c + enter to continue"
print("-----------------------------")
print("-----------------------------")
print("c + enter to continue")
import pdb;pdb.set_trace()

#########Histograms#############
Expand Down Expand Up @@ -395,9 +396,9 @@ def log(counter,mystubs,gen,kmtf,bmtf):
# if counter==1000:
# break;

# print 'OLD stubs'
# print('OLD stubs')
# for s in stubsOLD:
# print s.bxNum(),s.whNum(),s.scNum(),s.stNum(),s.phi(),s.phiB(),s.code()
# print(s.bxNum(),s.whNum(),s.scNum(),s.stNum(),s.phi(),s.phiB(),s.code())


# reco=fetchRECO(event,2.4)
Expand All @@ -417,10 +418,10 @@ def log(counter,mystubs,gen,kmtf,bmtf):
bmtf=[]

# for g in gen:
# print 'GEN', g.pt(),g.eta(),g.phi()
# print('GEN', g.pt(),g.eta(),g.phi())

# for k in kmtf:
# print 'L1', k.pt(),k.eta(),k.phi()
# print('L1', k.pt(),k.eta(),k.phi())



Expand Down Expand Up @@ -533,7 +534,7 @@ def log(counter,mystubs,gen,kmtf,bmtf):
# d=[]
# for i in range(0,7):
# d.append(s.position(i))
# print s.bxNum(),s.scNum(), s.whNum(), s.stNum(),d
# print(s.bxNum(),s.scNum(), s.whNum(), s.stNum(),d)
# log(counter,stubs,gen,kmtf,bmtf)


Expand All @@ -552,18 +553,18 @@ def log(counter,mystubs,gen,kmtf,bmtf):
if bestKMTF==None and bestBMTF!=None and g.pt()<4:
log(counter,stubs,gen,kmtf,bmtf)
# if bestKMTF!=None and bestBMTF!=None and abs(bestKMTF.eta()-g.eta())>abs(bestBMTF.eta()-g.eta()):
# print 'Input Theta stubs'
# print('Input Theta stubs')
# for s in stubsOLDTheta:
# if s.bxNum()!=0:
# continue
# a=[]
# for i in range(0,7):
# a.append(s.position(i))
# print s.whNum(),s.scNum(),s.stNum(),':',a
# print 'Combined stubs'
# print(s.whNum(),s.scNum(),s.stNum(),':',a)
# print('Combined stubs')
#
# for s in stubs:
# print s.whNum(),s.scNum(),s.stNum(),s.eta1(),s.eta2(),s.qeta1(),s.qeta2()
# print(s.whNum(),s.scNum(),s.stNum(),s.eta1(),s.eta2(),s.qeta1(),s.qeta2())
# import pdb;pdb.set_trace()


Expand Down
6 changes: 3 additions & 3 deletions L1Trigger/L1TMuonBarrel/test/kalmanTools/makeInitialState.py
@@ -1,6 +1,6 @@
from __future__ import print_function
import FWCore.ParameterSet.Config as cms


from L1Trigger.L1TMuonBarrel.simKBmtfDigis_cfi import bmtfKalmanTrackingSettings as settings

initialK = settings.initialK
Expand Down Expand Up @@ -56,12 +56,12 @@ def compliment(value):
K=-8191
arr[address]=str(K)
# import pdb;pdb.set_trace()
print '\n\n\n'
print('\n\n\n')
if i in [0,1]:
lut = 'ap_int<14> initialK_'+str(i+1)+'[1024] = {'+','.join(arr)+'};'
if i in [2,3]:
lut = 'ap_int<14> initialK_'+str(i+1)+'[1024] = {'+','.join(arr)+'};'
print lut
print(lut)



Expand Down
7 changes: 4 additions & 3 deletions L1Trigger/L1TMuonBarrel/test/kalmanTools/makePTPhiLUTs.py
@@ -1,7 +1,8 @@
from __future__ import print_function
from math import pi


print int(((-330+1024)*pi/(6.0*2048.0))/(0.625*pi/180.0))
print(int(((-330+1024)*pi/(6.0*2048.0))/(0.625*pi/180.0)))



Expand All @@ -11,7 +12,7 @@
p = int((i*2*pi/(6.0*2048.0))/(0.625*pi/180.0))
phi.append(str(p))

print 'const ap_int<8> phiLUT[2047] = {'+','.join(phi)+'};'
print('const ap_int<8> phiLUT[2047] = {'+','.join(phi)+'};')
#import pdb;pdb.set_trace()
pt=[]
lsb = 1.25/(1<<13)
Expand All @@ -31,4 +32,4 @@
pt.append(str(p))


print 'const ap_uint<9> ptLUT[4096] = {'+','.join(pt)+'};'
print('const ap_uint<9> ptLUT[4096] = {'+','.join(pt)+'};')
@@ -1,4 +1,4 @@

from __future__ import print_function
import FWCore.ParameterSet.Config as cms


Expand All @@ -25,8 +25,8 @@



print 'ap_ufixed<12,12> eLossVertex[2048] = {'+','.join(deltaK)+'};'
print 'ap_ufixed<12,12> dxyVertex[2048] = {'+','.join(dxy)+'};'
print('ap_ufixed<12,12> eLossVertex[2048] = {'+','.join(deltaK)+'};')
print('ap_ufixed<12,12> dxyVertex[2048] = {'+','.join(dxy)+'};')



0 comments on commit b16f620

Please sign in to comment.