-
Notifications
You must be signed in to change notification settings - Fork 15
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
Update get siblings #255
Open
carriganm95
wants to merge
10
commits into
update_CMSSW_13
Choose a base branch
from
updadeGetSiblings
base: update_CMSSW_13
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update get siblings #255
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
af508e8
fix redirector for get siblings
carriganm95 99b3272
updates to get event lists and run crab jobs
carriganm95 6560be4
add option to create json file at time of running
carriganm95 9a9f2e6
Delete DBTools/scripts/createEventLists.py
carriganm95 9fc85ee
bug fix on json name
carriganm95 51b4868
Merge branch 'updadeGetSiblings' of github.com:OSU-CMS/OSUT3Analysis …
carriganm95 ad6b89d
add in user proxy
carriganm95 83883bd
bug fixes
carriganm95 0e14b0d
updates to fiducial maps, also updates to create event lists for AOD/…
carriganm95 72ec5bb
Update submitCreateEventLists.py
carriganm95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/python3 | ||
|
||
import json | ||
import ROOT as r | ||
import numpy as np | ||
import sys | ||
import os | ||
|
||
r.gInterpreter.Declare( | ||
''' | ||
#include "OSUT3Analysis/DBTools/interface/getEvents.h" | ||
|
||
void dummyWrapper(){ | ||
getEvents(); | ||
} | ||
''' | ||
) | ||
r.gSystem.Load('libOSUT3AnalysisDBTools.so') | ||
|
||
if __name__ == "__main__": | ||
|
||
|
||
if not len(sys.argv) >= 3: | ||
print("Error: Need to provide the input json file") | ||
sys.exit(1) | ||
|
||
outputDir = '/data/users/mcarrigan/condor/EventLists/' | ||
if len(sys.argv) >= 4: | ||
outputDir = sys.argv[3] | ||
|
||
f_json = sys.argv[1] | ||
|
||
job = int(sys.argv[2]) | ||
|
||
dataset = f_json.split('/')[-1].split('-')[0] | ||
|
||
outputPath = outputDir + dataset + '/' | ||
|
||
if not os.path.exists(outputPath): | ||
os.mkdir(outputPath) | ||
|
||
with open(f_json) as secondary_fin: | ||
secondary_dict = json.load(secondary_fin) | ||
filename = list(secondary_dict.keys())[job] | ||
|
||
#for filename in secondary_dict.keys(): | ||
if not filename.startswith('root://'): filename = 'root://cmsxrootd.fnal.gov:/' + filename | ||
events = r.getEventsInFile(filename) | ||
tmpEvents = np.array([str(x.runNum)+':'+str(x.lumiBlock)+':'+str(x.event) for x in events]) | ||
print(tmpEvents, len(tmpEvents)) | ||
fileStr = filename.split('/')[-1] | ||
outputFile = outputPath + fileStr | ||
np.savez(outputFile, eventList=tmpEvents) | ||
#break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/python3 | ||
|
||
import json | ||
import ROOT as r | ||
import numpy as np | ||
import sys | ||
import os | ||
|
||
r.gInterpreter.Declare( | ||
''' | ||
#include "OSUT3Analysis/DBTools/interface/getEvents.h" | ||
|
||
void dummyWrapper(){ | ||
getEvents(); | ||
} | ||
''' | ||
) | ||
r.gSystem.Load('libOSUT3AnalysisDBTools.so') | ||
|
||
if __name__ == "__main__": | ||
|
||
|
||
if not len(sys.argv) >= 3: | ||
print("Error: Need to provide the input json file") | ||
sys.exit(1) | ||
|
||
outputDir = '/data/users/mcarrigan/condor/EventLists/' | ||
if len(sys.argv) >= 4: | ||
outputDir = sys.argv[3] | ||
|
||
f_json = sys.argv[1] | ||
|
||
job = int(sys.argv[2]) | ||
|
||
dataset = f_json.split('/')[-1].split('-')[0] | ||
|
||
outputPath = outputDir + dataset + '/' | ||
|
||
if not os.path.exists(outputPath): | ||
os.mkdir(outputPath) | ||
|
||
with open(f_json) as secondary_fin: | ||
secondary_dict = json.load(secondary_fin) | ||
filename = list(secondary_dict.keys())[job] | ||
|
||
if not filename.startswith('root://'): filename = 'root://cmsxrootd.fnal.gov:/' + filename | ||
events = r.getEventsInFile(filename) | ||
tmpEvents = np.array([str(x.runNum)+':'+str(x.lumiBlock)+':'+str(x.event) for x in events]) | ||
fileStr = filename.split('/')[-1] | ||
outputFile = outputPath + fileStr | ||
np.savez(outputFile, eventList=tmpEvents) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/bash | ||
|
||
export CMSSW_VERSION_LOCAL=$1 | ||
source /cvmfs/cms.cern.ch/cmsset_default.sh | ||
export SCRAM_ARCH=slc7_amd64_gcc820 | ||
eval `scramv1 runtime -sh` | ||
|
||
python3 createEventLists.py $2 $3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import os | ||
import argparse | ||
import json | ||
import shutil | ||
from OSUT3Analysis.DBTools.getSiblings import * | ||
import sys | ||
|
||
def writeCondorSub(exe, nJobs, outDir, jsonFile, requirements, wrapper, cmssw): | ||
f = open('run.sub', 'w') | ||
submitLines = """ | ||
Universe = vanilla | ||
Rank = TARGET.IsLocalSlot | ||
request_disk = {6} | ||
request_memory = {5} | ||
request_cpus = {4} | ||
executable = {7} | ||
arguments = {8} {2} $(PROCESS) | ||
log = {3}/log_$(PROCESS).log | ||
output = {3}/out_$(PROCESS).out | ||
error = {3}/error_$(PROCESS).err | ||
should_transfer_files = Yes | ||
when_to_transfer_output = ON_EXIT | ||
transfer_input_files = {1}, {2}, {7} | ||
transfer_output_files = "" | ||
getenv = true | ||
x509userproxy = /tmp/x509up_u1009 | ||
queue {0} | ||
""".format(nJobs,exe,jsonFile,outDir,requirements[0],requirements[1],requirements[2],wrapper, cmssw) | ||
|
||
f.write(submitLines) | ||
f.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-j", "--json", type=str, help="Input json of dataset to get events from") | ||
parser.add_argument('-d', '--dataset', type=str, help="Dataset to get json from") | ||
args = parser.parse_args() | ||
|
||
jsonFile = '/home/mcarrigan/scratch0/disTracksML/CMSSW_13_0_13/src/DisappTrks/BackgroundEstimation/test/debugMuonSkim/Muon_Run2022E-EXODisappTrk-27Jun2023-v1_AOD.json' | ||
wrapper = os.environ['CMSSW_BASE'] + '/src/OSUT3Analysis/DBTools/scripts/eventListWrapper.sh' | ||
script = os.environ['CMSSW_BASE'] + '/src/OSUT3Analysis/DBTools/python/createEventLists.py' | ||
requirements = ['2', '2000MB', '3000MB'] #CPU, Memory, Disk | ||
cmssw = os.environ['CMSSW_VERSION'] | ||
|
||
if args.json: | ||
jsonFile = args.json | ||
|
||
if args.dataset: | ||
jsonFile = args.dataset.replace('/', '_')[1:] | ||
getSiblings.getDASInfo(args.dataset, jsonName = '{}.json'.format(jsonFile)) | ||
jsonFile = '{}.json'.format(args.dataset) | ||
|
||
outputDir = '/abyss/users/mcarrigan/log/DisappTrks/EventLists_{}'.format(jsonFile.split('/')[-1].split('.')[0]) | ||
|
||
nJobs = 0 | ||
with open(jsonFile) as fin: | ||
f_json = json.load(fin) | ||
nJobs = len(f_json.keys()) | ||
|
||
if not os.path.exists(outputDir): | ||
os.mkdir(outputDir) | ||
|
||
writeCondorSub(script, nJobs, outputDir, jsonFile, requirements, wrapper, cmssw) | ||
|
||
shutil.copy(script, outputDir) | ||
shutil.copy('run.sub', outputDir) | ||
shutil.copy(jsonFile, outputDir) | ||
|
||
os.system('condor_submit run.sub') |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file the same as the one in
DBTools/scripts/createEventLists.py
? If so, maybe this could be removed? I assume the other one to be the correct file, but correct me if I am wrong.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes good catch there should only be the one in python