Skip to content

Commit

Permalink
Updating syntax, fixing a typo in function name. Adding Xcode project…
Browse files Browse the repository at this point in the history
…s to gitignore.
  • Loading branch information
jniedzie committed May 14, 2018
1 parent 0781515 commit ef79c2f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,5 @@ ENV/

# mypy
.mypy_cache/

*.xcodeproj
6 changes: 3 additions & 3 deletions GeoUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def __init__(self, geometry_file_path = default_geometry_file_path):
self.planes = self.read_planes()
# get the layer indecies with basic information
def _get_plane_indices(self, geometry_file_path):
indices = {line_no: line for line_no, line in enumerate(geometry_file_path) if re.search('[a-zA-Z]+', line) is None}
indices = {line_no: line for line_no, line in enumerate(geometry_file_path) if re.search('[a-zA-Z]+', line.decode()) is None}
return indices
# pairs of iterables
def _pairwise(self, iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = itertools.tee(iterable)
next(b, None)
return list(itertools.izip(a, b))
return list(zip(a, b))
# extract info about one plan from the geometry description, and return the plane (with necessary information)
def _read_plane(self, plane_details, start, end):
# read in the plane id, max and min radia
Expand Down Expand Up @@ -97,7 +97,7 @@ def read_planes(self):
# read in individual layers from the geometry description
planes = [self._read_plane(planes_indices[start], start, end) for start, end in pairs]
# return the list
print "Number of planes loaded: ",len(planes)
print("Number of planes loaded: ",len(planes))
return planes
# check if a point (x, y) is contained in the polygon defined with hexagon vertecies for the chosen plane
def point_inside_plane(self, plane_num, p_x, p_y):
Expand Down
22 changes: 11 additions & 11 deletions hgcalNtupleExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def main():
for event in ntuple:
if event.entry() >= maxEvents:
break
print "Event", event.entry()+1
print("Event", event.entry()+1)
tot_nevents += 1
genParts = event.genParticles()
tot_genpart += len(genParts)
Expand All @@ -50,17 +50,17 @@ def main():
tot_track += len(tracks)

# for genPart in genParts:
# print tot_nevents, "genPart pt:", genPart.pt()
# print(tot_nevents, "genPart pt:", genPart.pt()

print "Processed %d events" % tot_nevents
print "On average %f generator particles" % (float(tot_genpart) / tot_nevents)
print "On average %f reconstructed hits" % (float(tot_rechit) / tot_nevents)
print "On average %f layer clusters" % (float(tot_cluster2d) / tot_nevents)
print "On average %f multi-clusters" % (float(tot_multiclus) / tot_nevents)
print "On average %f sim-clusters" % (float(tot_simcluster) / tot_nevents)
print "On average %f PF clusters" % (float(tot_pfcluster) / tot_nevents)
print "On average %f calo particles" % (float(tot_calopart) / tot_nevents)
print "On average %f tracks" % (float(tot_track) / tot_nevents)
print("Processed %d events" % tot_nevents)
print("On average %f generator particles" % (float(tot_genpart) / tot_nevents))
print("On average %f reconstructed hits" % (float(tot_rechit) / tot_nevents))
print("On average %f layer clusters" % (float(tot_cluster2d) / tot_nevents))
print("On average %f multi-clusters" % (float(tot_multiclus) / tot_nevents))
print("On average %f sim-clusters" % (float(tot_simcluster) / tot_nevents))
print("On average %f PF clusters" % (float(tot_pfcluster) / tot_nevents))
print("On average %f calo particles" % (float(tot_calopart) / tot_nevents))
print("On average %f tracks" % (float(tot_track) / tot_nevents))


if __name__ == "__main__":
Expand Down
5 changes: 3 additions & 2 deletions hgcalReClusteringExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def getRecHitsSimAssoc(rechits_raw, simcluster):
for hitIndexArray in simClusHitAssoc[simClusIndex]:
for hitIndex in hitIndexArray:
thisHit = rechits_raw[hitIndex]
if(not recHitAboveTreshold(thisHit, ecut, dependSensor)[1]): continue
if(not recHitAboveThreshold(thisHit, ecut, dependSensor)[1]): continue
# independent of sim cluster, after cleaning
rHitsSimAssocTemp.append(thisHit)
rHitsSimAssoc[simClusIndex]= rHitsSimAssocTemp
Expand Down Expand Up @@ -187,6 +187,7 @@ def main():
ntuple = HGCalNtuple("root://eoscms.cern.ch//eos/cms/store/cmst3/group/hgcal/CMG_studies/Production/FlatRandomEGunProducer_pdgid211_E20_cmssw93X_withPRs_20170817/NTUP/partGun_PDGid211_x100_E20.0To20.0_NTUP_1.root") # CMSSW_9_3_0_pre3 with some pre4 PRs on top
#ntuple = HGCalNtuple("/eos/cms/store/cmst3/group/hgcal/CMG_studies/Production/FlatRandomPtGunProducer_predragm_PDGid22_nPart1_Pt20to100_Eta2p3to2p5_cmssw921_20170605/NTUP/partGun_PDGid22_x400_Pt20.0To100.0_NTUP_1.root") # cmssw921 with all recent fixes as of June 12
#ntuple = HGCalNtuple("/eos/cms/store/cmst3/group/hgcal/CMG_studies/Production/FlatRandomPtGunProducer_predragm_PDGid22_id211_id11_id15_id130_nPart1_Pt20to100_Eta2p3to2p5_cmssw921_20170606/NTUP/partGun_PDGid22_id211_id11_id15_id130_x400_Pt20.0To100.0_NTUP_1.root")# cmssw921 with all recent fixes as of June 12
# ntuple = HGCalNtuple("../data/_SingleGammaPt100Eta1p6_2p8_PhaseIITDRFall17DR-noPUFEVT_93X_upgrade2023_realistic_v2-v1_GEN-SIM-RECO/NTUP/_SingleGammaPt100Eta1p6_2p8_PhaseIITDRFall17DR-noPUFEVT_93X_upgrade2023_realistic_v2-v1_GEN-SIM-RECO_NTUP_1.root");

# prepare some lists for comparions
multiClusters_nClust2DDiff = []
Expand All @@ -210,7 +211,7 @@ def main():
# get flat list of rechist associated to sim-cluster hits
rHitsSimAssoc = getRecHitsSimAssoc(recHitsRaw, simClusters)
# get flat list of raw rechits which satisfy treshold condition
rHitsCleaned = [rechit for rechit in recHitsRaw if recHitAboveTreshold(rechit, ecut, dependSensor)[1]]
rHitsCleaned = [rechit for rechit in recHitsRaw if recHitAboveThreshold(rechit, ecut, dependSensor)[1]]

### Imaging algo run at RECO step (CMSSW)
# get flat list of all clusters 2D produced with algo at RECO step (CMSSW)
Expand Down
Loading

0 comments on commit ef79c2f

Please sign in to comment.