I used to do this, but it was back in Cadence's "Edge"
generation with a simulator that had a decent command
language. I expect that today you'd have to use Ocean
scripting.
Set up one simulation (parametric analysis) which will
run an outer loop of mccnt and an inner loop of your
trim code. Then for each process shot, you will have
all codes' result. Next step is for each mccnt, pick the
code closest to target and stuff that to an array like
trimcode(mccnt) or if the trim is a digital switch based
type, trimcode(mccnt, bit) which would need a wee bit
more loopage. Something like top-hat or tab laser trim
you'd probably want more of a binary-search-to-error-
band (these will go until goal is found; link / fuse /
zener-zap schemes are discrete and limited-resolution.
Stuff that array of right answers to a file by print commands
in a loop. Create yourself a corresponding read-from-file
which you will prepend to any subsequent MC analyses
of trim-affected product electricals. Then down in the guts
of a MC loop (recommend you set up and then save-as-
Ocean-script, to then edit) you will make sure that the
circuit's trim params are set to the mccnt-indexed value.
This all depends on the MC analysis being -pseudo-
random, and not let to go randomizing its seed, which
would make the trim totally unrelated to the subsequent
analyses. Verify that you get the same answer for the
same mccnt, in two separate sessions started at two
different tiimes (have seen one Cadence seed option
is to "randomize" the seed by using clock*calendar).