This is the code used for MINOS detector alignment. The alignment is done in two steps: First cosmic muon tracks are written to an ASCII output file within the MINOS offline framework using the BubbleSpeak package. To do this you have to get your private version of BubbleSpeak and replace the 'PlotMuonClusterModule' stuff there with the '.cxx' and '.h' files provided here (help on how to do this can be found at the MINOS Offline Computing web pages). In the second step there are ROOT macros which do the actual alignment calculations. These are called 'run_align_data.C' and 'run_align_mc.C' for real and simulated data. They rely on compiled 'track_class_***.cxx' code (*** = 'data' or 'mc'). The small 'mycomp.***' scripts take care of compilation of the corresponding source files. The alignment is done by re-fitting the tracks omitting one plane at a time an calculating the residuals (cluster_position_on_this_plane - prediction_of_the_fit). These residuals are averaged over all the tracks and the procedure is iterated until a stable result is reached. You can set several parameters for the alignment in the 'track_class_***.h' files (default units are 'cm'): - trackFileName: ASCII track input file; the variables in each line are: event_number plane_orientation hit_count z_position transverse_position plane_number ADC_counts - nTracks: number of tracks used for the alignment - nPlanes: number of planes used for the alignment (U and V planes are treated separately, so the number is half of total planes) - datPointsMin: minimal allowed number of planes in a track - datPointsMax: maximal allowed number of planes in a track - residMax: maximal limit for a calculated residual to be used in the averaging procedure - maxTDiff: maximal allowed transversal distance of hits on a plane to be used as combined point in the fit - maxIter: this is NOT the number of Iterations (this is set in the ROOT macros) but sets the iteration at which the result plots are filled - offsetRMS: RMS of the randomly generated (Gauss) plane offsets for MC Among the output plots are the calculated residuals for each plane and view for the 'data' macro and the comparison of generated plane offset vs. offset - residual (which should be 0 in the case of perfect calculation) for the 'mc' macro (also for each plane in U and V view). Have fun, - Nicolai