| 1 | #include <TApplication.h>
|
|---|
| 2 |
|
|---|
| 3 | #include "MAGIC.h"
|
|---|
| 4 |
|
|---|
| 5 | #include "MLog.h"
|
|---|
| 6 | #include "MLogManip.h"
|
|---|
| 7 |
|
|---|
| 8 | #include "MArgs.h"
|
|---|
| 9 | #include "MArray.h"
|
|---|
| 10 | #include "MParContainer.h"
|
|---|
| 11 |
|
|---|
| 12 | #ifdef HAVE_XPM
|
|---|
| 13 | #include "MLogo.h"
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | #include "MCameraDisplay.h"
|
|---|
| 17 | #include "MEventDisplay.h"
|
|---|
| 18 |
|
|---|
| 19 | using namespace std;
|
|---|
| 20 |
|
|---|
| 21 | // **********************************************************************
|
|---|
| 22 | //
|
|---|
| 23 | // MARS main program
|
|---|
| 24 | //
|
|---|
| 25 | // The only job of the main program is the initialization of ROOT and
|
|---|
| 26 | // the start of the GUI interface for the mars program
|
|---|
| 27 | //
|
|---|
| 28 | // started by h. kornmayer january, 3rd 2001
|
|---|
| 29 | static void StartUpMessage()
|
|---|
| 30 | {
|
|---|
| 31 | gLog << all << endl;
|
|---|
| 32 |
|
|---|
| 33 | // 1 2 3 4 5
|
|---|
| 34 | // 12345678901234567890123456789012345678901234567890
|
|---|
| 35 | gLog << "==================================================" << endl;
|
|---|
| 36 | gLog << " MARS V" << MARSVER << endl;
|
|---|
| 37 | gLog << " Magic Analysis and Reconstruction Software" << endl;
|
|---|
| 38 | gLog << " Compiled with ROOT v" << ROOT_RELEASE << " on <" << __DATE__ << ">" << endl;
|
|---|
| 39 | gLog << "==================================================" << endl;
|
|---|
| 40 | gLog << endl;
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | static void Usage()
|
|---|
| 44 | {
|
|---|
| 45 | gLog << all << endl;
|
|---|
| 46 | gLog << "Sorry the usage is:" << endl;
|
|---|
| 47 | gLog << " mars [options] filename|number [path]" << endl << endl;
|
|---|
| 48 | gLog << " Arguments:" << endl;
|
|---|
| 49 | gLog << " filename: Name of a merpped raw file, a calibrated (Y)," << endl;
|
|---|
| 50 | gLog << " sequence file or sequence number." << endl;
|
|---|
| 51 | gLog << " path: Path where the data is stored in case of a" << endl;
|
|---|
| 52 | gLog << " sequence (datacenter default if omitted)." << endl << endl;
|
|---|
| 53 | gLog << " Options:" << endl;
|
|---|
| 54 | gLog.Usage();
|
|---|
| 55 | gLog << " --config=mars.rc: Change configuration file" << endl;
|
|---|
| 56 | gLog << " <not yet implemented!>" << endl;
|
|---|
| 57 | gLog.Usage();
|
|---|
| 58 | gLog << " -?/-h: This help" << endl << endl;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | /*
|
|---|
| 62 | Bool_t InflateRun(TString &run, Bool_t ismc)
|
|---|
| 63 | {
|
|---|
| 64 | if (run.IsDigit())
|
|---|
| 65 | {
|
|---|
| 66 | const Int_t numrun = run.Atoi();
|
|---|
| 67 | seq = "/magic/";
|
|---|
| 68 | if (ismc)
|
|---|
| 69 | seq += ismc ? "montecarlo/" : "rawfiles/";
|
|---|
| 70 | seq += Form("sequences/%04d/sequence%08d.txt", numseq/10000, numseq);
|
|---|
| 71 | gLog << inf << "Inflated sequence file: " << seq << endl;
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | if (!gSystem->AccessPathName(seq, kFileExists))
|
|---|
| 75 | return kTRUE;
|
|---|
| 76 |
|
|---|
| 77 | gLog << err << "Sorry, sequence file '" << seq << "' doesn't exist." << endl;
|
|---|
| 78 | return kFALSE;
|
|---|
| 79 | }
|
|---|
| 80 | */
|
|---|
| 81 |
|
|---|
| 82 | int main(int argc, char **argv)
|
|---|
| 83 | {
|
|---|
| 84 | if (!MARS::CheckRootVer())
|
|---|
| 85 | return 0xff;
|
|---|
| 86 |
|
|---|
| 87 | //
|
|---|
| 88 | // Evaluate arguments
|
|---|
| 89 | //
|
|---|
| 90 | MArgs arg(argc, argv, kTRUE);
|
|---|
| 91 | gLog.Setup(arg);
|
|---|
| 92 |
|
|---|
| 93 | StartUpMessage();
|
|---|
| 94 |
|
|---|
| 95 | if (arg.HasOption("-?") || arg.HasOption("-h") || arg.GetNumArguments()>1)
|
|---|
| 96 | {
|
|---|
| 97 | Usage();
|
|---|
| 98 | return 2;
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | //const Bool_t kIsSequence = arg.HasOnlyAndRemove("--seq");
|
|---|
| 102 | const TString kConfig = arg.GetStringAndRemove("--config=", "mars.rc");
|
|---|
| 103 |
|
|---|
| 104 | if (arg.GetNumOptions()>0)
|
|---|
| 105 | {
|
|---|
| 106 | gLog << warn << "WARNING - Unknown commandline options..." << endl;
|
|---|
| 107 | arg.Print("options");
|
|---|
| 108 | gLog << endl;
|
|---|
| 109 | return 2;
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | //
|
|---|
| 113 | // check for the right usage of the program
|
|---|
| 114 | //
|
|---|
| 115 | if (arg.GetNumArguments()>2)
|
|---|
| 116 | {
|
|---|
| 117 | Usage();
|
|---|
| 118 | return 2;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | //
|
|---|
| 122 | // This is to make argv[i] more readable inside the code
|
|---|
| 123 | //
|
|---|
| 124 | TString kFilename = arg.GetArgumentStr(0);
|
|---|
| 125 | TString kInpathD = arg.GetArgumentStr(1);
|
|---|
| 126 |
|
|---|
| 127 | //if (!kIsSequence && !InflateRun(kFilename))
|
|---|
| 128 | // return 3;
|
|---|
| 129 |
|
|---|
| 130 | #ifdef HAVE_XPM
|
|---|
| 131 | MLogo logo;
|
|---|
| 132 | logo.Popup();
|
|---|
| 133 | #endif
|
|---|
| 134 |
|
|---|
| 135 | //
|
|---|
| 136 | // initialize ROOT
|
|---|
| 137 | //
|
|---|
| 138 | TApplication app("mars", &argc, argv);
|
|---|
| 139 | if (gROOT->IsBatch() || !gClient)
|
|---|
| 140 | {
|
|---|
| 141 | gLog << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
|
|---|
| 142 | return 1;
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | //
|
|---|
| 146 | // Switch of TObject Streamer in our base classes derived from TObject
|
|---|
| 147 | //
|
|---|
| 148 | MArray::Class()->IgnoreTObjectStreamer();
|
|---|
| 149 | MParContainer::Class()->IgnoreTObjectStreamer();
|
|---|
| 150 |
|
|---|
| 151 | #ifdef HAVE_XPM
|
|---|
| 152 | logo.Popdown();
|
|---|
| 153 | #endif
|
|---|
| 154 |
|
|---|
| 155 | /*
|
|---|
| 156 | MEnv env(kConfig);
|
|---|
| 157 | if (!env.IsValid())
|
|---|
| 158 | {
|
|---|
| 159 | gLog << err << "Configuration file " << kConfig << " not found." << endl;
|
|---|
| 160 | return 0xfe;
|
|---|
| 161 | }
|
|---|
| 162 | */
|
|---|
| 163 |
|
|---|
| 164 | //
|
|---|
| 165 | // start the main window
|
|---|
| 166 | //
|
|---|
| 167 | if (kFilename.IsNull())
|
|---|
| 168 | new MCameraDisplay;
|
|---|
| 169 | else
|
|---|
| 170 | {
|
|---|
| 171 | MEventDisplay *d = new MEventDisplay(kFilename, kInpathD);
|
|---|
| 172 | d->SetBit(MStatusDisplay::kExitLoopOnExit);
|
|---|
| 173 | d->SetTitle(kFilename);
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | //
|
|---|
| 177 | // run the application
|
|---|
| 178 | //
|
|---|
| 179 | app.Run();
|
|---|
| 180 |
|
|---|
| 181 | gLog << all << endl;
|
|---|
| 182 |
|
|---|
| 183 | return 0;
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|