00001
00002
00003
00004
00005 #include "instrument/Instrument.h"
00006
00007 #include "reconstruction/data/RecoGlastData.h"
00008 #include "reconstruction/GlastRecon.h"
00009 #include "reconstruction/ReconData.h"
00010 #include "reconstruction/GlastTuple.h"
00011 #include "reconstruction/PrintReconData.h"
00012
00013 #include <iostream>
00014
00015 extern void FATAL ( const char* msg )
00016 {
00017 std::cerr << "FATAL " << msg << std::endl;
00018 }
00019
00020 extern void WARNING ( const char* msg )
00021 {
00022 std::cerr << "WARNING " << msg << std::endl;
00023 }
00024
00025
00026 int main(int argc, char* argv[]) {
00027
00028 Instrument g;
00029
00030
00031 int rc = g.initialize();
00032
00033 if( rc) {
00034 return rc;
00035 }
00036 else std::cout << "Loaded " << g.detector_count() << " elements from detector definition file "
00037 << g.xmlFileName() << std::endl;
00038
00039 if( argc <2 ) {
00040
00041
00042 const char * local_path = ::getenv("INSTRUMENTROOT");
00043
00044 std::string input_file = std::string(local_path? local_path: "");
00045
00046 input_file += std::string("/src/test/muontest.irf");
00047
00048 rc = g.openIRF(input_file);
00049 std::cout << "Opening test irf file "<< input_file << std::endl;
00050 }else {
00051
00052 rc = g.openIRF(argv[1]);
00053 }
00054 if (rc==0 ) {
00055 std::cout << "Opened " << g.irfFileName() << " for reading" << std::endl;
00056 } else {
00057 std::cout << "Failed to open " << g.irfFileName() << " for reading" << std::endl;
00058 return rc;
00059 }
00060
00061 RecoGlastData data;
00062 GlastRecon recon;
00063
00064
00065 int irec=0;
00066 while( rc==0 ) {
00067 rc = g.readIRF();
00068 if(rc==0) std::cout << "Record " << (++irec)
00069 <<": found " << g.detectors_with_data() << " detectors with hits" << std::endl;
00070
00071 data.clear();
00072 recon.clear();
00073
00074
00075 g.accept(data);
00076
00077
00078 data.printOn(std::cout);
00079
00080
00081 recon.accept(ReconData(&data));
00082
00083
00084 recon.accept(PrintReconData(std::cout));
00085
00086
00087 }
00088
00089
00090 return 0;
00091 }