Task: find the optimal pairing of r-φ and stereo modules for the TIB layers.
Strategy followed in my macro:
- Count number of modules in the two samples (r-φ and stereo).
- The smallest sample is labeled "sample 1", the other "sample 2".
- The Vdepl average is computed for sample 1.
- Modules in sample 2 are sorted according to the distance in Vdepl from the average of sample 1.
- Since sample 2 is larger than sample 1 (by definition), the extra modules too far from the Vdepl average of sample 1 are thrown away, keeping the same number of modules as in sample 1.
- Both sample 1 and sample 2 are sorted by Vdepl.
- Pair module 1 of the 1st sample with the closest (in Vdepl) module of the 2nd sample, then pair module 2 with the closest of the remaining, and so on.
- Apply "simulated annealing" to check if more optimal pairings are possible.
Files:
Usage:
root
.x ds.C(1,"inputfile1","inputfile2","outputfile",cut,0)
.q
more outputfile
cut is the tolerated discrepancy ratio (I used 0.2). In the output file, * means pairing outside tolerance.