#include "MapsTrackManager.hh" #include "MapsTrack.hh" #include "MapsSensor.hh" #include "MapsException.hh" #include #include #include #include "TRandom2.h" #include "TFile.h" #include "TH1F.h" /** Realignment.cpp * * Extremely useful tool for reprocessing stored tracks, without having to recreate them * from a DAQ binary file. One reads in a file of stored tracks, realigns the sensors, * and writes the new data in a new ROOT file. * * At the moment, all parameters are hardcoded, except for the filenames; copy and * edit this file as requried. * * Jamie Ballin, Imperial College London * February 2008 * * j.ballin06@imperial.ac.uk */ int main(int argc, const char **argv) { if (argc != 3) { std::cout << "Usage: Realignment \n"; return 0; } MapsTrackManager mtm2; std::cout << "Recreating from root file...\n"; std::cout << "NOTE: that this tool uses hardcoded parameters! Adjust and recompile for your own purposes...\n"; char input[100]; strcpy(input, argv[1]); mtm2.recreateFromRootFile(input); std::vector& sensors = mtm2.getSensors(); for (std::vector::iterator it = sensors.begin(); it != sensors.end(); it++) { MapsSensor* s = *it; MapsSensor::physXY align; //Adjust these switches as required. switch (s->id()) { //Sensors 8 and 6 define the world coordinate system for the DESY beam test runs case 8: { mtm2.setRequiredLeftSensor(s); break; } case 6: { s->setPhi(0.0); mtm2.setRequiredRightSensor(s); break; } case 2: { s->setPhi(3.14159265358979323846); align.first = 0.09233; align.second = 0.1428; break; } case 7: { align.first = 0.1513; align.second = -0.1024; break; } } s->setAlignment(align); } std::vector& tracks = mtm2.getTracks(); for (std::vector::iterator it = tracks.begin(); it != tracks.end(); it++) { MapsTrack* t = *it; std::pair error(0.018, 0.018); t->setTrackError(error); //diagnose(std::cout, *t); } std::cout << "Rewriting to new root file...\n"; char output[100]; strcpy(output, argv[2]); mtm2.exportToRootFile(output); std::cout << "Done.\n"; return 0; }