This should get you what you want as long as I understood it correctly. I wrote this without testing anything so you may have to modify it.
Code:
~ Loop through all the spells of X
foreach pick in hero from BaseSpell where "thingid.spXXXXXX"
~ Check to see if this spell is bootstrapped by something
if (eachpick.isroot <> 0) then
~ Check the bootstrap to see if its the correct ability
if (eachpick.root.tagis[thingid.AbilityThatBootstrappedSpell] <> 0) then
eachpick.field[trkMax].value = maximum(1,#attrmod[aCHA])
endif
endif
nexteach