Skip to content

Commit

Permalink
Merge pull request cms-sw#65 from gpetruc/cmg_heppy_76X-part1
Browse files Browse the repository at this point in the history
CMG Heppy 76X part1
  • Loading branch information
cbernet committed Jan 24, 2016
2 parents 272b991 + 8d151df commit f4c265c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ def beginLoop(self, setup):
setup.globalVariables = []
if outname[-1] == '*' :
outname=outname[0:-1]
setup.globalVariables.append( NTupleVariable(outname, eval("lambda ev: ev.%s" % outname), help="Trigger bit %s"%TP) )
if self.saveIsUnprescaled or self.force1prescale: setup.globalVariables.append( NTupleVariable(outname+'_isUnprescaled', eval("lambda ev: ev.%s_isUnprescaled" % outname), help="Trigger bit %s isUnprescaled flag"%TP) )
setup.globalVariables.append( NTupleVariable(outname, eval("lambda ev: ev.%s" % outname), int, help="Trigger bit %s"%TP) )
if self.saveIsUnprescaled or self.force1prescale: setup.globalVariables.append( NTupleVariable(outname+'_isUnprescaled', eval("lambda ev: ev.%s_isUnprescaled" % outname), int, help="Trigger bit %s isUnprescaled flag"%TP) )
self.triggerBitCheckersSingleBits.append( (TP, ROOT.heppy.TriggerBitChecker(trigVecBit)) )

outname="%s_%s"%(self.outprefix,T)
if not hasattr(setup ,"globalVariables") :
setup.globalVariables = []
setup.globalVariables.append( NTupleVariable(outname, eval("lambda ev: ev.%s" % outname), help="OR of %s"%TL) )
if self.saveIsUnprescaled or self.force1prescale: setup.globalVariables.append( NTupleVariable(outname+'_isUnprescaled', eval("lambda ev: ev.%s_isUnprescaled" % outname), help="OR of %s is Unprescaled flag"%TL) )
setup.globalVariables.append( NTupleVariable(outname, eval("lambda ev: ev.%s" % outname), int, help="OR of %s"%TL) )
if self.saveIsUnprescaled or self.force1prescale: setup.globalVariables.append( NTupleVariable(outname+'_isUnprescaled', eval("lambda ev: ev.%s_isUnprescaled" % outname), int, help="OR of %s is Unprescaled flag"%TL) )
self.triggerBitCheckers.append( (T, ROOT.heppy.TriggerBitChecker(trigVec)) )


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def process(self, event):
if self.collToMatch:
for lep in tcoll:
mstring = 'None'
if getattr(lep,'matchedTrgObj'+self.label):
mstring = 'trigger obj with pt=%.2f, eta=%.2f, phi=%.2f, collection=%s'%(ob.pt(),ob.eta(),ob.phi(),ob.collection())
ob = getattr(lep,'matchedTrgObj'+self.label)
if ob: mstring = 'trigger obj with pt=%.2f, eta=%.2f, phi=%.2f, collection=%s'%(ob.pt(),ob.eta(),ob.phi(),ob.collection())
print 'Lepton pt=%.2f, eta=%.2f, phi=%.2f matched to %s'%(lep.pt(),lep.eta(),lep.phi(),mstring)

return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,9 @@ def matchAnyLeptons(self, event):
lep.mcMatchAny = 0
# fix case where the matching with the only prompt leptons failed, but we still ended up with a prompt match
if gen != None and hasattr(lep,'mcMatchId') and lep.mcMatchId == 0:
if isPromptLepton(gen, False): lep.mcMatchId = 100
if isPromptLepton(gen, False):
lep.mcMatchId = 100
lep.mcLep = gen
elif not hasattr(lep,'mcMatchId'):
lep.mcMatchId = 0
if not hasattr(lep,'mcMatchTau'): lep.mcMatchTau = 0
Expand Down
2 changes: 2 additions & 0 deletions PhysicsTools/Heppy/python/analyzers/objects/autophobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
# new version used by EGM in Spring15, 7_4_14:
NTupleVariable("eInvMinusPInv_tkMom", lambda x: ((1.0/x.ecalEnergy()) - (1.0 / x.trackMomentumAtVtx().R() ) if (x.ecalEnergy()>0. and x.trackMomentumAtVtx().R()>0.) else 9e9) if abs(x.pdgId())==11 else 0, help="Electron 1/E - 1/p_tk_vtx (without absolute value!)"),
NTupleVariable("etaSc", lambda x : x.superCluster().eta() if abs(x.pdgId())==11 else -100, help="Electron supercluster pseudorapidity"),
NTupleVariable("mcMatchPdgId", lambda x : x.mcLep.pdgId() if getattr(x,'mcLep',None)!=None else -99, int, mcOnly=True, help="Match to source from hard scatter (pdgId of heaviest particle in chain, 25 for H, 6 for t, 23/24 for W/Z): pdgId of the matched gen-level lepton, zero if non-prompt or fake")
])


Expand Down Expand Up @@ -182,6 +183,7 @@
NTupleVariable("rawPt", lambda x : x.pt() * x.rawFactor(), help="p_{T} before JEC"),
NTupleVariable("mcPt", lambda x : x.mcJet.pt() if getattr(x,"mcJet",None) else 0., mcOnly=True, help="p_{T} of associated gen jet"),
NTupleVariable("mcFlavour", lambda x : x.partonFlavour(), int, mcOnly=True, help="parton flavour (physics definition, i.e. including b's from shower)"),
NTupleVariable("partonFlavour", lambda x : x.partonFlavour(), int, mcOnly=True, help="purely parton-based flavour"),
NTupleVariable("hadronFlavour", lambda x : x.hadronFlavour(), int, mcOnly=True, help="hadron flavour (ghost matching to B/C hadrons)"),
NTupleVariable("mcMatchId", lambda x : getattr(x, 'mcMatchId', -99), int, mcOnly=True, help="Match to source from hard scatter (pdgId of heaviest particle in chain, 25 for H, 6 for t, 23/24 for W/Z), zero if non-prompt or fake"),
NTupleVariable("corr_JECUp", lambda x : getattr(x, 'corrJECUp', -99), float, help=""),
Expand Down
31 changes: 22 additions & 9 deletions PhysicsTools/HeppyCore/scripts/heppy_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,38 @@ def batchScriptCERN( jobDir, remoteDir=''):
elif remoteDir.startswith("root://eoscms.cern.ch//eos/cms/store/"):
cpCmd="""echo 'sending root files to remote dir'
export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH #
for f in Loop/tree*.root
for f in Loop/*/tree*.root
do
ff=`basename $f | cut -d . -f 1`
rm Loop/cmsswPreProcessing.root
ff=`echo $f | cut -d/ -f2`
ff="${{ff}}_`basename $f | cut -d . -f 1`"
echo $f
echo $ff
export VO_CMS_SW_DIR=/cvmfs/cms.cern.ch
source $VO_CMS_SW_DIR/cmsset_default.sh
echo "gfal-copy file://`pwd`/Loop/$ff.root {srm}/${{ff}}_{idx}.root"
gfal-copy file://`pwd`/Loop/$ff.root {srm}/${{ff}}_{idx}.root
echo $idx
echo "/afs/cern.ch/project/eos/installation/pro/bin/eos.select mkdir {srm}"
/afs/cern.ch/project/eos/installation/pro/bin/eos.select mkdir {srm}
echo "/afs/cern.ch/project/eos/installation/pro/bin/eos.select cp `pwd`/$f {srm}/${{ff}}_{idx}.root"
/afs/cern.ch/project/eos/installation/pro/bin/eos.select cp `pwd`/$f {srm}/${{ff}}_{idx}.root
echo $idx
if [ $? -ne 0 ]; then
echo "ERROR: remote copy failed for file $ff"
else
echo "remote copy succeeded"
rm Loop/$ff.root
rm $f
echo root://eoscms.cern.ch/{srm}/${{ff}}_{idx}.root > $f.url
fi
done
#fi
""".format(idx=jobDir[jobDir.find("_Chunk")+6:].strip("/"), srm=""+remoteDir+jobDir[jobDir.rfind("/"):jobDir.find("_Chunk")])
cp -r Loop/* $LS_SUBCWD
if [ $? -ne 0 ]; then
echo 'ERROR: problem copying job directory back'
else
echo 'job directory copy succeeded'
fi
""".format(
idx = jobDir[jobDir.find("_Chunk")+6:].strip("/") if '_Chunk' in jobDir else 'all',
srm = (""+remoteDir+jobDir[ jobDir.rfind("/") : (jobDir.find("_Chunk") if '_Chunk' in jobDir else len(jobDir)) ]).replace("root://eoscms.cern.ch/","")
)
else:
print "chosen location not supported yet: ", remoteDir
print 'path must start with /store/'
Expand Down Expand Up @@ -276,7 +289,7 @@ def PrepareJobUser(self, jobDir, value ):
storeDir = self.remoteOutputDir_.replace('/castor/cern.ch/cms','')
mode = self.RunningMode(options.batch)
if mode == 'LXPLUS':
scriptFile.write( batchScriptCERN( jobDir, storeDir) )
scriptFile.write( batchScriptCERN( jobDir, storeDir ) )
elif mode == 'PSI':
scriptFile.write( batchScriptPSI ( value, jobDir, storeDir ) ) # storeDir not implemented at the moment
elif mode == 'LOCAL':
Expand Down

0 comments on commit f4c265c

Please sign in to comment.