tests/src/Realignment.cpp

Go to the documentation of this file.
00001 #include "MapsTrackManager.hh"
00002 #include "MapsTrack.hh"
00003 #include "MapsSensor.hh"
00004 #include "MapsException.hh"
00005 #include <cmath>
00006 #include <algorithm>
00007 #include <iostream>
00008 #include "TRandom2.h"
00009 #include "TFile.h"
00010 #include "TH1F.h"
00011 
00012 
00013 /** Realignment.cpp
00014  * 
00015  * Extremely useful tool for reprocessing stored tracks, without having to recreate them
00016  * from a DAQ binary file. One reads in a file of stored tracks, realigns the sensors,
00017  * and writes the new data in a new ROOT file.
00018  * 
00019  * At the moment, all parameters are hardcoded, except for the filenames; copy and 
00020  * edit this file as requried.
00021  * 
00022  * Jamie Ballin, Imperial College London
00023  *              February 2008
00024  * 
00025  * j.ballin06@imperial.ac.uk
00026  */
00027 int main(int argc, const char **argv) {
00028 
00029         if (argc != 3) {
00030                 std::cout << "Usage: Realignment <input file> <outputfile>\n";
00031                 return 0;
00032         }
00033 
00034 
00035         MapsTrackManager mtm2;
00036         std::cout << "Recreating from root file...\n";
00037         std::cout << "NOTE: that this tool uses hardcoded parameters! Adjust and recompile for your own purposes...\n";
00038         char input[100];
00039         strcpy(input, argv[1]);
00040         mtm2.recreateFromRootFile(input);
00041 
00042         std::vector<MapsSensor*>& sensors = mtm2.getSensors();
00043 
00044         for (std::vector<MapsSensor*>::iterator it = sensors.begin(); it
00045                         != sensors.end(); it++) {
00046                 MapsSensor* s = *it;
00047                 MapsSensor::physXY align;
00048                 //Adjust these switches as required.
00049                 switch (s->id()) {
00050                 //Sensors 8 and 6 define the world coordinate system for the DESY beam test runs
00051                 case 8: {
00052                         mtm2.setRequiredLeftSensor(s);
00053                         break;
00054                 }
00055                 case 6: {
00056                         s->setPhi(0.0);
00057                         mtm2.setRequiredRightSensor(s);
00058                         break;
00059                 }
00060                 case 2: {
00061                         s->setPhi(3.14159265358979323846);
00062                         align.first = 0.09233;
00063                         align.second = 0.1428;
00064                         break;
00065                 }
00066                 case 7: {
00067                         align.first = 0.1513;
00068                         align.second = -0.1024;
00069                         break;
00070                 }
00071                 }
00072                 s->setAlignment(align);
00073 
00074         }
00075 
00076         std::vector<MapsTrack*>& tracks = mtm2.getTracks();
00077         for (std::vector<MapsTrack*>::iterator it = tracks.begin(); it
00078                         != tracks.end(); it++) {
00079                 MapsTrack* t = *it;
00080                 std::pair<double, double> error(0.018, 0.018);
00081                 t->setTrackError(error);
00082                 //diagnose(std::cout, *t);
00083         }
00084 
00085         std::cout << "Rewriting to new root file...\n";
00086         char output[100];
00087         strcpy(output, argv[2]);
00088         mtm2.exportToRootFile(output);
00089 
00090         std::cout << "Done.\n";
00091         return 0;
00092 }
00093 

Generated on Wed Mar 19 17:47:58 2008 for MapsTracks by  doxygen 1.5.2