SmartApp prefs - dynamic sections in dynamic pages?

Let me start by saying that I am new to SmartThings and to Groovy, but certainly not to programming. That being said, I am attempting to write a SmartApp specific to my setup that makes use of dynamic preference pages as well as “dynamic” sections in those pages. For instance, my main preference page allows selection of contactSensor devices to perform an audio notification for when opened:

Then in a subsequent page, I ask for the audio to play for each of the selected contactSensor devices:

def page2() {
	dynamicPage(name: "page2")
    {
    	def pos = 1
        
    	notifyOnOpenSensors.each {
        	section("$it.displayName open notification:")
            {
            	input "onOpenAudioDevice" + pos, "capability.audioNotification", title: "Audio player?", required: true
                input "onOpenAudioTrack" + pos, "text", title: "Audio track?", required: true
            }
            
            pos++
        }
	}
}

This appears to “work” fine in the simulator, and it appears that definitions are created for onOpenAudioDevice1, onOpenAudioDevice2, etc. My question is this: if every contactSensor device calls the same handler for contact.open, and I can determine the index of the triggering device in notifyOnOpenSensors, how can I get the proper onOpenAudioDevice and onOpenAudioTrack values? From my searching, I haven’t found a way to get an object reference by name. Is it even possible? Thanks in advance.

Managed to find the answer I was looking for. I was just searching for the wrong terms. Interpolation was the key. For those who might be interested, after finding the index of the triggering device in the list of chosen devices, creating the path to the audio player and track was as simple as:

    def pos = notifyOnOpenSensors.findIndexOf { it.id == evt.deviceId }
    
    if (pos >= 0)
    {
        log.trace "onOpenHandler - device index $pos"

		def audioDeviceName = "onOpenAudioDevice" + pos
		def audioTrackName = "onOpenAudioTrack" + pos
		def audioDevice = this."$audioDeviceName"
		def audioTrack = this."$audioTrackName"
        
        log.trace "onOpenHandler - $audioDevice.displayName play track $audioTrack"
    }