Skip to content

Commit

Permalink
make code robust against broken events
Browse files Browse the repository at this point in the history
  • Loading branch information
clelange committed Nov 2, 2017
1 parent d146bd0 commit 6f12a5c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions SingleGammaPt_samples.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_SingleGammaPt100Eta1p6_2p8_PhaseIITDRFall17DR-PU200FEVT_93X_upgrade2023_realistic_v2-v1_GEN-SIM-RECO
_SingleGammaPt35Eta1p6_2p8_PhaseIITDRFall17DR-noPUFEVT_93X_upgrade2023_realistic_v2-v1_GEN-SIM-RECO
_SingleGammaPt50Eta1p6_2p8_PhaseIITDRFall17DR-PU200FEVT_93X_upgrade2023_realistic_v2-v1_GEN-SIM-RECO
5 changes: 3 additions & 2 deletions hgcalHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ def getHighestEnergyObjectIndex(ref_etaphi, obj_etaphi, obj_energy, deltaR=0.1):
# Handle the -pi pi transition
matched_sym = kdtree.query_ball_point([row.eta, row.phi-np.sign(row.phi)*2.*math.pi], deltaR)
matched = np.unique(np.concatenate((matched, matched_sym))).astype(int)
best_match = np.argmax(obj_energy[matched])
matched_indices[index] = best_match
if len(matched) > 0:
best_match = np.argmax(obj_energy[matched])
matched_indices[index] = best_match
return matched_indices


Expand Down
6 changes: 6 additions & 0 deletions megaClustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
maxlayer = 52
energyWeights = list(repeat(1.02, 28)) + list(repeat(0.86, 12)) + list(repeat(1.12, 12))


def getConeRadius(frontRadius, backRadius, z, maxval=9999.):
depthTerm = backRadius * (abs(z)-320.7)/(407.8-320.7)
val = frontRadius + depthTerm
Expand All @@ -39,13 +40,18 @@ def getMegaClusters(genParticles, multiClusters, layerClusters, recHits, gun_typ
selectedGen = selectedGen[(selectedGen.energy >= GEN_engpt*.999)]
# print selectedGen

if multiClusters.shape[0] == 0:
return pd.DataFrame(columns=['pt', 'eta', 'phi', 'energy'])
# for the mega cluster axis, take highest energy multicluster within dR = 0.1
bestMultiClusterIndices = hgcalHelpers.getHighestEnergyObjectIndex(selectedGen[['eta', 'phi']], multiClusters[['eta', 'phi']], multiClusters['energy'], 0.1)
# print bestMultiClusterIndices

megaClusters = []

for idx, genPart in selectedGen.iterrows():
if idx not in bestMultiClusterIndices:
# this is the case if there's no match between gen and multi clusters
continue
matchedMultiCluster = multiClusters.iloc[[bestMultiClusterIndices[idx]]]
energySum = 0
pTSum = 0
Expand Down
6 changes: 3 additions & 3 deletions resolutionScaleFiller_submit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

SAMPLEFILE=$1

OUTDIR="/eos/user/c/clange/HGCal/ScaleResolution/"
OUTDIR="/eos/user/c/clange/HGCal/ScaleResolution/_new/"
PREFIX="root://eoscms.cern.ch//eos/cms/store/cmst3/group/hgcal/CMG_studies/Production/"
GUNTYPE="pt"
POSTFIX="NTUP"
Expand All @@ -12,13 +12,13 @@ QUEUE="8nh"

for SAMPLE in `cat $SAMPLEFILE`; do
SAMPLEDIR="${PREFIX}${SAMPLE}/${POSTFIX}/"
PTVAL=`echo ${SAMPLE} | gawk 'match($0, /.*SinglePiPt(.*)Eta.*/, arr) { print arr[1] }'`
PARTICLE=`echo ${SAMPLE} | gawk 'match($0, /.*Single(.*)Pt.*/, arr) { print arr[1] }'`
PTVAL=`echo ${SAMPLE} | gawk -v part=".*Single${PARTICLE}Pt(.*)Eta.*" 'match($0, part, arr) { print arr[1] }'`
TAG=`echo ${SAMPLE} | gawk 'match($0, /.*Fall17DR-(.*)FEVT.*/, arr) { print arr[1] }'`
PID=0
if [ "$PARTICLE" == "Pi" ]; then
PID=211
elif [ "$PARTICLE" == "Photon" ]; then
elif [ "$PARTICLE" == "Gamma" ]; then
PID=22
fi;
for OBJNAME in $OBJNAMES; do
Expand Down
2 changes: 1 addition & 1 deletion resolutionScaleFiller_submitIlya.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

SAMPLEFILE=$1

OUTDIR="/eos/user/c/clange/HGCal/ScaleResolution/Ilya/"
OUTDIR="/eos/user/c/clange/HGCal/ScaleResolution/_new/Ilya/"
PREFIX="root://eoscms.cern.ch//eos/cms/store/cmst3/group/hgcal/CMG_studies/Production/"
GUNTYPE="pt"
POSTFIX="NTUP"
Expand Down

0 comments on commit 6f12a5c

Please sign in to comment.