Skip to content

Commit

Permalink
Remove all plane-related codes
Browse files Browse the repository at this point in the history
  • Loading branch information
wcmartylee committed Nov 4, 2024
1 parent 326e0b6 commit 2bfcde6
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 49 deletions.
2 changes: 1 addition & 1 deletion macro/flux_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def main():
pid = hit.PdgCode()
assert pid not in [12, -12, 14, -14, 16, -16]
detector_ID = hit.GetDetectorID()
station = detector_ID // 10000000
station = detector_ID // 1000000
h['T{}_all'.format(station)].Fill(x, y, weight)
if abs(pid) == 13:
muon = True
Expand Down
11 changes: 5 additions & 6 deletions muonShieldOptimization/ana_ShipMuon.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,16 +446,15 @@ def makeProd():
os.chdir('../'+prefix+str(i+1))

def strawEncoding(detid):
# statnb*10000000+vnb*1000000+pnb*100000+lnb*10000+1000+snb
# vnb=view number; pnb=plane number; lnb=layer number; snb=straw number
# statnb*1000000+vnb*100000+lnb*10000+1000+snb
# vnb=view number; lnb=layer number; snb=straw number
# statnb = station number. 1,2,3,4 tracking stations, 5 veto station
vnb = ROOT.Long()
pnb = ROOT.Long()
lnb = ROOT.Long()
snb = ROOT.Long()
statnb = ROOT.Long()
modules['Strawtubes'].StrawDecode(detid,statnb,vnb,pnb,lnb,snb)
return [statnb,vnb,pnb,lnb,snb]
modules['Strawtubes'].StrawDecode(detid,statnb,vnb,lnb,snb)
return [statnb,vnb,lnb,snb]

def detMap():
sGeo = ROOT.gGeoManager
Expand Down Expand Up @@ -658,7 +657,7 @@ def executeOneFile(fn,output=None,pid=None):
detID = ahit.GetDetectorID()
if ahit.GetName() == 'strawtubesPoint':
tmp = strawEncoding(detID)
# detName = str(tmp[0]*10000000+tmp[1]*1000000+tmp[2]*100000+tmp[3]*10000)
# detName = str(tmp[0]*1000000+tmp[1]*100000+tmp[2]*10000)
detName = "strawstation_"+str(tmp[0])
x = ahit.GetX()
y = ahit.GetY()
Expand Down
2 changes: 1 addition & 1 deletion python/MufluxDigi.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def digitizeMufluxSpectrometer(self):
else:
hitsPerDetId[detID] = index
if aMCPoint.GetDetectorID() in deadChannelsForMC: aHit.setInvalid()
station = int(aMCPoint.GetDetectorID()//10000000)
station = int(aMCPoint.GetDetectorID()//1000000)
if ROOT.gRandom.Rndm() < ineffiency[station]: aHit.setInvalid()
index+=1

Expand Down
44 changes: 20 additions & 24 deletions python/MufluxDigiReco.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def withT0Estimate(self):
if not aDigi.isValid: continue
detID = aDigi.GetDetectorID()
# don't use hits from straw veto
station = int(detID/10000000)
station = int(detID/1000000)
if station > 4 : continue
aDigi.MufluxSpectrometerEndPoints(start,stop)
# MufluxSpectrometerHit::MufluxSpectrometerEndPoints(TVector3 &vbot, TVector3 &vtop)
Expand Down Expand Up @@ -382,17 +382,13 @@ def smearHits(self,no_amb=None):
def stationInfo(self, hit):
# Taken from charmdet/drifttubeMonitoring.py
detid = hit.GetDetectorID()
statnb = detid/10000000;
vnb = (detid - statnb*10000000)/1000000
pnb = (detid - statnb*10000000 - vnb*1000000)/100000
lnb = (detid - statnb*10000000 - vnb*1000000 - pnb*100000)/10000
statnb = detid/1000000;
vnb = (detid - statnb*1000000)/100000
lnb = (detid - statnb*1000000 - vnb*100000)/10000
view = "_x"
if vnb==0 and statnb==2: view = "_v"
if vnb==1 and statnb==1: view = "_u"
if pnb>1:
print("something wrong with detector id",detid)
pnb = 0
return statnb,vnb,pnb,lnb,view
return statnb,vnb,,lnb,view

def correctAlignment(self, hit):
# Taken from charmdet/drifttubeMonitoring.py
Expand Down Expand Up @@ -463,7 +459,7 @@ def smearHits_realData(self):
# distance to wire.
# dist = ahit.GetDigi() * 3.7 / (2000. * 2.)
tdc = ahit.GetDigi()
dist = self.RT(ahit.GetDetectorID()/10000000, tdc)
dist = self.RT(ahit.GetDetectorID()/1000000, tdc)

SmearedHits.append( {'digiHit':key,'xtop':top.x(),'ytop':top.y(),'z':top.z(),'xbot':bot.x(),'ybot':bot.y(),'dist':dist, 'detID':detID} )

Expand Down Expand Up @@ -587,8 +583,8 @@ def recognition_metrics(self, track_hit_ids, mode='all'):
track_id = ahit.GetTrackID()

detID = ahit.GetDetectorID()
statnb = detID // 10000000
vnb = (detID - statnb * 10000000) // 1000000
statnb = detID // 1000000
vnb = (detID - statnb * 1000000) // 100000

is_y12 = (statnb == 1) * (vnb == 0) + (statnb == 2) * (vnb == 1)
is_stereo12 = (statnb == 1) * (vnb == 1) + (statnb == 2) * (vnb == 0)
Expand Down Expand Up @@ -772,8 +768,8 @@ def target_metrics(self, track_hit_ids):
track_id = ahit.GetTrackID()

detID = ahit.GetDetectorID()
statnb = detID // 10000000
vnb = (detID - statnb * 10000000) // 1000000
statnb = detID // 1000000
vnb = (detID - statnb * 1000000) // 100000

is_y12 = (statnb == 1) * (vnb == 0) + (statnb == 2) * (vnb == 1)
is_stereo12 = (statnb == 1) * (vnb == 1) + (statnb == 2) * (vnb == 0)
Expand Down Expand Up @@ -1229,7 +1225,7 @@ def findTracks(self):

# detID = self.digiMufluxSpectrometer[sm['digiHit']].GetDetectorID()
detID = sm['detID']
station = int(detID/10000000)
station = int(detID/1000000)
trID = i_track

# T1-4 for track fit
Expand All @@ -1246,7 +1242,7 @@ def findTracks(self):
trackDigiHits[trID].append(sm['digiHit'])

# T1-3 for track fit
if (int(detID/1000000)!=40):
if (int(detID/100000)!=40):
if trID not in hitPosLists_noT4:
hitPosLists_noT4[trID] = ROOT.std.vector('TVectorD')()
stationCrossed_noT4[trID] = {}
Expand All @@ -1271,8 +1267,8 @@ def findTracks(self):

# detID = self.digiMufluxSpectrometer[sm['digiHit']].GetDetectorID()
detID = sm['detID']
station = int(detID/10000000)
vnb = (detID - station * 10000000) // 1000000
station = int(detID/1000000)
vnb = (detID - station * 1000000) // 100000
is_y12 = (station == 1) * (vnb == 0) + (station == 2) * (vnb == 1)
is_stereo12 = (station == 1) * (vnb == 1) + (station == 2) * (vnb == 0)
is_34 = (station == 3) + (station == 4)
Expand Down Expand Up @@ -1480,8 +1476,8 @@ def findTracks(self):
x_hits_y = []
for ahit in self.SmearedHits:
detID = ahit['detID']
station = int(detID/10000000)
vnb = (detID - station * 10000000) // 1000000
station = int(detID/1000000)
vnb = (detID - station * 1000000) // 100000
is_y12 = (station == 1) * (vnb == 0) + (station == 2) * (vnb == 1)
is_stereo12 = (station == 1) * (vnb == 1) + (station == 2) * (vnb == 0)
is_34 = (station == 3) + (station == 4)
Expand Down Expand Up @@ -1523,8 +1519,8 @@ def findTracks(self):
plt.subplot(1, 2, 2)
for ahit in self.SmearedHits:
detID = ahit['detID']
station = int(detID/10000000)
vnb = (detID - station * 10000000) // 1000000
station = int(detID/1000000)
vnb = (detID - station * 1000000) // 100000
is_y12 = (station == 1) * (vnb == 0) + (station == 2) * (vnb == 1)
is_stereo12 = (station == 1) * (vnb == 1) + (station == 2) * (vnb == 0)
is_34 = (station == 3) + (station == 4)
Expand Down Expand Up @@ -1684,8 +1680,8 @@ def findTracks(self):
track_id = ahit.GetTrackID()

detID = ahit.GetDetectorID()
statnb = detID // 10000000
vnb = (detID - statnb * 10000000) // 1000000
statnb = detID // 1000000
vnb = (detID - statnb * 1000000) // 100000

is_y12 = (statnb == 1) * (vnb == 0) + (statnb == 2) * (vnb == 1)
is_stereo12 = (statnb == 1) * (vnb == 1) + (statnb == 2) * (vnb == 0)
Expand Down
15 changes: 6 additions & 9 deletions python/MufluxPatRec.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def hits_split(SmearedHits):
for i_hit in range(len(SmearedHits)):
ahit = SmearedHits[i_hit]
detID = ahit['detID']
statnb, vnb, pnb, lnb, snb = decodeDetectorID(detID)
statnb, vnb, lnb, snb = decodeDetectorID(detID)
is_y12 = (statnb == 1) * (vnb == 0) + (statnb == 2) * (vnb == 1)
is_stereo12 = (statnb == 1) * (vnb == 1) + (statnb == 2) * (vnb == 0)
is_34 = (statnb == 3) + (statnb == 4)
Expand Down Expand Up @@ -399,21 +399,18 @@ def decodeDetectorID(detID):
Station numbers.
vnb : int or array-like
View numbers.
pnb : int or array-like
Plane numbers.
lnb : int or array-like
Layer numbers.
snb : int or array-like
Straw tube numbers.
"""

statnb = detID // 10000000
vnb = (detID - statnb * 10000000) // 1000000
pnb = (detID - statnb * 10000000 - vnb * 1000000) // 100000
lnb = (detID - statnb * 10000000 - vnb * 1000000 - pnb * 100000) // 10000
snb = detID - statnb * 10000000 - vnb * 1000000 - pnb * 100000 - lnb * 10000 - 2000
statnb = detID // 1000000
vnb = (detID - statnb * 1000000) // 100000
lnb = (detID - statnb * 1000000 - vnb * 100000) // 10000
snb = detID - statnb * 1000000 - vnb * 100000 - lnb * 10000 - 2000

return statnb, vnb, pnb, lnb, snb
return statnb, vnb, lnb, snb


def hit_in_bin(x, y, k_bin, b_bin, k_size, b_size):
Expand Down
12 changes: 6 additions & 6 deletions python/shipDigiReco.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,14 +760,14 @@ def withT0Estimate(self):
key = -1
SmearedHits = []
v_drift = global_variables.modules["Strawtubes"].StrawVdrift()
global_variables.modules["Strawtubes"].StrawEndPoints(10002001, start, stop)
global_variables.modules["Strawtubes"].StrawEndPoints(1002001, start, stop)
z1 = stop.z()
for aDigi in self.digiStraw:
key+=1
if not aDigi.isValid(): continue
detID = aDigi.GetDetectorID()
# don't use hits from straw veto
station = int(detID//10000000)
station = int(detID//1000000)
if station > 4 : continue
global_variables.modules["Strawtubes"].StrawEndPoints(detID, start, stop)
delt1 = (start[2]-z1)/u.speedOfLight
Expand All @@ -785,14 +785,14 @@ def smearHits(self,no_amb=None):
SmearedHits = []
key = -1
v_drift = global_variables.modules["Strawtubes"].StrawVdrift()
global_variables.modules["Strawtubes"].StrawEndPoints(10002001, start, stop)
global_variables.modules["Strawtubes"].StrawEndPoints(1002001, start, stop)
z1 = stop.z()
for aDigi in self.digiStraw:
key+=1
if not aDigi.isValid(): continue
detID = aDigi.GetDetectorID()
# don't use hits from straw veto
station = int(detID//10000000)
station = int(detID//1000000)
if station > 4 : continue
global_variables.modules["Strawtubes"].StrawEndPoints(detID, start, stop)
#distance to wire
Expand Down Expand Up @@ -845,7 +845,7 @@ def findTracks(self):
atrack_smeared_hits = list(atrack_y12) + list(atrack_stereo12) + list(atrack_y34) + list(atrack_stereo34)
for sm in atrack_smeared_hits:
detID = sm['detID']
station = int(detID//10000000)
station = int(detID//1000000)
trID = i_track
# Collect hits for track fit
if trID not in hitPosLists:
Expand All @@ -861,7 +861,7 @@ def findTracks(self):
else: # do fake pattern recognition
for sm in self.SmearedHits:
detID = self.digiStraw[sm['digiHit']].GetDetectorID()
station = int(detID//10000000)
station = int(detID//1000000)
trID = self.sTree.strawtubesPoint[sm['digiHit']].GetTrackID()
if trID not in hitPosLists:
hitPosLists[trID] = ROOT.std.vector('TVectorD')()
Expand Down
2 changes: 1 addition & 1 deletion python/shipPatRec.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def hits_split(smeared_hits):
ahit = smeared_hits[i_hit]

detID = ahit['detID']
statnb, vnb, pnb, lnb, snb = decodeDetectorID(detID)
statnb, vnb, lnb, snb = decodeDetectorID(detID)
is_y12 = ((statnb == 1) + (statnb == 2)) * ((vnb == 0) + (vnb == 3))
is_stereo12 = ((statnb == 1) + (statnb == 2)) * ((vnb == 1) + (vnb == 2))
is_y34 = ((statnb == 3) + (statnb == 4)) * ((vnb == 0) + (vnb == 3))
Expand Down
2 changes: 1 addition & 1 deletion python/shipStrawTracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def run_track_pattern_recognition(input_file, geo_file, output_file, method):
hits[key] = numpy.array(hits[key])

# Decoding
statnb, vnb, pnb, lnb, snb = decodeDetectorID(hits['DetID'])
statnb, vnb, lnb, snb = decodeDetectorID(hits['DetID'])
is_stereo = ((vnb == 1) + (vnb == 2))
is_y = ((vnb == 0) + (vnb == 3))
is_before = ((statnb == 1) + (statnb == 2))
Expand Down

0 comments on commit 2bfcde6

Please sign in to comment.