Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production version for quadruplets #13

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ __init__.py
#*#
*.hdf
*/#*.*#
production/mc/crab*
BParkingNano/production/crab/BParkingNANO*
NanoAOD/
1 change: 1 addition & 0 deletions BParkingNano/plugins/BToKLLBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ void BToKLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup cons
//for isolation
edm::Handle<pat::PackedCandidateCollection> iso_tracks;
evt.getByToken(isotracksToken_, iso_tracks);

edm::Handle<pat::PackedCandidateCollection> iso_lostTracks;
evt.getByToken(isolostTracksToken_, iso_lostTracks);
unsigned int nTracks = iso_tracks->size();
Expand Down
315 changes: 283 additions & 32 deletions BParkingNano/plugins/BToKstarLLBuilder.cc

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions BParkingNano/plugins/ElectronMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ void ElectronMerger::produce(edm::StreamID, edm::Event &evt, edm::EventSetup con
ele.addUserFloat("LPEleMvaID_2020Sept15RawValue", mva_id); // was called "mvaId"
ele.addUserFloat("PFEleMvaID_RetrainedRawValue", 20.); // was called "pfmvaId"
// Run-2 PF ele ID
ele.addUserFloat("PFEleMvaID_Fall17NoIsoV2RawValue", 20.); // Run 2 ID
ele.addUserFloat("PFEleMvaID_Fall17NoIsoV2RawValue", 20.0);
ele.addUserInt("PFEleMvaID_Fall17NoIsoV1wpLoose", 0); //@@ to be deprecated
ele.addUserInt("PFEleMvaID_Fall17NoIsoV2wpLoose", 0);
ele.addUserInt("PFEleMvaID_Fall17NoIsoV2wp90", 0);
ele.addUserInt("PFEleMvaID_Fall17NoIsoV2wp80", 0);
// Run-3 PF ele ID
//ele.addUserFloat("PFEleMvaID_Winter22NoIsoV1RawValue", 20.); // Run 3 ID
ele.addUserFloat("chargeMode", ele.gsfTrack()->chargeMode());
Expand Down Expand Up @@ -401,4 +405,4 @@ void ElectronMerger::produce(edm::StreamID, edm::Event &evt, edm::EventSetup con
}

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(ElectronMerger);
DEFINE_FWK_MODULE(ElectronMerger);
6 changes: 3 additions & 3 deletions BParkingNano/plugins/TrackMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ void TrackMerger::produce(edm::StreamID, edm::Event &evt, edm::EventSetup const
// for loop is better to be range based - especially for large ensembles
for( unsigned int iTrk=0; iTrk<totalTracks; ++iTrk ) {
const pat::PackedCandidate & trk = (iTrk < nTracks) ? (*tracks)[iTrk] : (*lostTracks)[iTrk-nTracks];

//arranging cuts for speed
if(!trk.hasTrackDetails()) continue;
if(abs(trk.pdgId()) != 211) continue; //do we want also to keep muons?
if(!trk.hasTrackDetails()) continue; //this will remove netrual hadrons (130)
if(abs(trk.pdgId()) != 211) continue; //do we want also to keep muons?
if(trk.pt() < trkPtCut_ ) continue;
if(fabs(trk.eta()) > trkEtaCut_) continue;

Expand Down
12 changes: 12 additions & 0 deletions BParkingNano/production/condor/BuToKJPsi_1712764458/BuToKJPsi.jdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
universe = vanilla
Executable = cmsRun.sh
Should_Transfer_Files = YES
WhenToTransferOutput = ON_EXIT
Transfer_Input_Files = cmsRun.sh, run_nano_cfg.py, filelist_BuToKJPsi.tgz
Output = /afs/cern.ch/work/x/xuyan/RKProj/BParkingNanoOfficial/CMSSW_13_1_0/src/PhysicsTools/BParkingNano/production/condor/BuToKJPsi_1712764458/out/$(ProcId).out
Error = /afs/cern.ch/work/x/xuyan/RKProj/BParkingNanoOfficial/CMSSW_13_1_0/src/PhysicsTools/BParkingNano/production/condor/BuToKJPsi_1712764458/err/$(ProcId).err
Log = /afs/cern.ch/work/x/xuyan/RKProj/BParkingNanoOfficial/CMSSW_13_1_0/src/PhysicsTools/BParkingNano/production/condor/BuToKJPsi_1712764458/log/$(ProcId).log
Arguments = /eos/home-x/xuyan/RKProj/RKAnalyzer/KStarllStudy/Data/BuToKJPsi_1712764458/ BuToKJPsi CMSSW_13_1_0 $(ProcId) run_nano_cfg.py filelist_tmp_$(ProcId).list /afs/cern.ch/user/x/xuyan/private/x509up/x509up_u93529 True
MY.WantOS = "el7"
+JobFlavour = "tomorrow"
Queue 11
32 changes: 32 additions & 0 deletions BParkingNano/production/condor/cmsRun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
echo "Starting job on " `date` #Date/time of start of job
echo "Running on: `uname -a`" #Condor job is running on this node
echo "System software: `cat /etc/redhat-release`" #Operating System on that node
source /cvmfs/cms.cern.ch/cmsset_default.sh ## if a bash script, use .sh instead of .csh
export X509_USER_PROXY=${7}
voms-proxy-info -all
voms-proxy-info -all -file ${7}
### for case 1. EOS have the following line, otherwise remove this line in case 2.
#Arguments 1)eosDir 2)jobName 3)rel 4)iJob 5)jobCfg 6)inputFile 7)fileName

# You need to move transfered files to the working area
cp ${1}${2}.tgz .
tar -xf ${2}.tgz
rm ${2}.tgz
mv ${5} ${3}/src/PhysicsTools/BParkingNano
mv filelist_${2}.tgz ${3}/src/PhysicsTools/BParkingNano

# export $SCRAM_ARCH=slc7_amd64_gcc700
cd ${3}/src/
scramv1 b ProjectRename -j 8
eval `scramv1 runtime -sh` # cmsenv is an alias not on the workers
cd PhysicsTools/BParkingNano
tar -xf filelist_${2}.tgz
ls ./
touch log.txt
cmsRun ${5} inputFiles_load=${6} isMC=${8} 2>&1 | tee log.txt
cp log.txt ${1}/log_${4}.txt
cp BParkingNANO_Run3_*.root ${1}/myNano_${4}.root
rm BParkingNANO_Run3_*.root
cd ${_CONDOR_SCRATCH_DIR}
rm -rf ${3}
85 changes: 85 additions & 0 deletions BParkingNano/production/condor/condor_sub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env python
import os, re, sys, commands, math, time, calendar

print '\nSTART\n'
ts = calendar.timegm(time.gmtime())

# joblist = ["BuToKEE","BdToK0starEE_postEE","BdToK0starEE_postEE_ext1","BdToK0starEE_preEE","BdToK0starEE_preEE_ext1"]
joblist = ["BuToKJPsi"]

jobdic = {"BuToKJPsi":"BuToKJPsi_JPsiToEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen.list",
# "DataF":"ParkingDoubleElectronLowMass0_Run2022F.list",
# "BuToKEE":"BuToKEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen.list",
# "BdToK0starEE_postEE":"BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen_postEE.list",
# "BdToK0starEE_postEE_ext1":"BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen_postEE_ext1.list",
# "BdToK0starEE_preEE":"BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen_preEE.list",
# "BdToK0starEE_preEE_ext1":"BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen_preEE_ext1.list",
}

for jobName in joblist:
print(jobName, jobdic[jobName])
jobCfg = "run_nano_cfg.py"
jobScript = "cmsRun.sh"
rel = "CMSSW_13_1_0"
eosDir = "/eos/home-x/xuyan/RKProj/RKAnalyzer/KStarllStudy/Data/" + jobName + "_" + str(ts) + "/"
isMC = "True"
if "Data" in jobName:
isMC = "False"
print("Running on MC: ",isMC)

rootDir = os.environ["CMSSW_BASE"] + "/src/PhysicsTools/BParkingNano/production/condor/"
jobDir = rootDir + jobName + "_" + str(ts) + "/"
files_batch = 10

fileList = rootDir + jobdic[jobName]

ret = os.system("rm filelist_tmp_*.list")
ret = os.system("cp ../../test/" + jobCfg + " ./")
ret = os.system("mkdir -p " + jobDir)
ret = os.system("mkdir -p " + eosDir)
ret = os.system("mkdir -p " + jobDir + "out/")
ret = os.system("mkdir -p " + jobDir + "err/")
ret = os.system("mkdir -p " + jobDir + "log/")
ret = os.chdir(os.environ["CMSSW_BASE"]+"/../")
print('Tarballing ' + rel + "/ into " + jobName + ".tgz...")
ret = os.system("tar --exclude='*.root' --exclude='ignore' --exclude='.git' " + "-zcf " + jobName + ".tgz " + rel)
print 'Done!'
ret = os.system("mv " + jobName + ".tgz " + eosDir)
ret = os.chdir(rootDir)
ret = os.system("cp /tmp/x509up_u93529 /afs/cern.ch/user/x/xuyan/private/x509up/x509up_u93529")
proxy_path = "/afs/cern.ch/user/x/xuyan/private/x509up/x509up_u93529"

file1 = open(fileList, 'r')
file_content = file1.readlines()
chunks = len(file_content) / files_batch + 1

ret = os.system("rm filelist_tmp_*.list")
for ichunk in range(chunks):
filelist_name = "filelist_tmp_%i.list" %(ichunk)
filelist_tmp = open(filelist_name, 'w')
for file in file_content[ichunk*files_batch:(ichunk+1)*files_batch]:
filelist_tmp.write(file)
filelist_tmp.close()
ret = os.system("tar -cvf filelist_" + jobName + ".tgz filelist_tmp_*")

with open(jobDir + jobName + '.jdl', 'w') as jdl:
jdl.write("universe = vanilla\n")
jdl.write("Executable = " + jobScript + "\n")
jdl.write("Should_Transfer_Files = YES\n")
jdl.write("WhenToTransferOutput = ON_EXIT\n")
jdl.write("Transfer_Input_Files = " + jobScript + ", " + jobCfg + ", filelist_" + jobName + ".tgz" + "\n")
jdl.write("Output = " + jobDir + "out/$(ProcId).out\n")
jdl.write("Error = " + jobDir + "err/$(ProcId).err\n")
jdl.write("Log = " + jobDir + "log/$(ProcId).log\n")
jdl.write("Arguments = " + eosDir + " " + jobName + " " + rel + " $(ProcId) " + jobCfg + " filelist_tmp_$(ProcId).list " + proxy_path + " " + isMC +"\n")
jdl.write("MY.WantOS = \"el7\"\n")
jdl.write("+JobFlavour = " + "\"tomorrow\"" + "\n")
# jdl.write("+MaxRuntime = 28800\n")
# jdl.write("on_exit_remove = (ExitBySignal == False) && (ExitCode == 0)\n")
# jdl.write("max_retries = 3\n")
# jdl.write("requirements = Machine =!= LastRemoteHost\n")
jdl.write("Queue " + str(chunks) + "\n")

os.system("condor_submit " + jobDir + jobName + ".jdl")
print str(chunks) + " jobs submitted."
os.system("condor_q")
Binary file not shown.
Binary file not shown.
Loading