LDMX Software
ldmx_eve.cxx
Go to the documentation of this file.
1
7// LDMX
8#include <memory>
9#include <string>
10
12
16void printHelp();
17
24int main(int argc, char** argv) {
25 // Parse command line options
26 bool verbose = false;
27 std::string file;
28 for (int iArg = 1; iArg < argc; iArg++) {
29 if (strcmp(argv[iArg], "--help") == 0 or strcmp(argv[iArg], "-h") == 0) {
30 printHelp();
31 return 0;
32 } else if (strcmp(argv[iArg], "--verbose") == 0 or
33 strcmp(argv[iArg], "-v") == 0) {
34 verbose = true;
35 } else if (file.empty()) {
36 file = argv[iArg];
37 } else {
38 printHelp();
39 return 1;
40 }
41 }
42
43 if (verbose) {
44 std::cout << "[ ldmx-eve ] : Starting up ROOT app, manager, and browser."
45 << std::endl;
46 }
47
48 int* dummyArgC;
49 char** dummyArgV;
50 TRint* app = new TRint("app", dummyArgC, dummyArgV, 0, 0, true);
51 app->SetPrompt(""); // no root[#] at beginning of each line
52
53 TEveManager* manager = TEveManager::Create(kTRUE, "FV");
54
55 TEveBrowser* browser = manager->GetBrowser();
56 browser->StartEmbedding(TRootBrowser::kLeft);
57
58 if (verbose) {
59 std::cout << "[ ldmx-eve ] : Constructing Event Display window and drawing "
60 "geometry."
61 << std::endl;
62 }
63
64 eventdisplay::Display display(manager, verbose);
65
66 if (verbose) {
67 std::cout << "[ ldmx-eve ] : Opening file " << file << std::endl;
68 }
69
70 if (!display.SetFile(file)) {
71 std::cerr << "[ ldmx-eve ] : Unable to open file! Exiting..." << std::endl;
72
73 app->Terminate(1);
74 manager->Terminate();
75 browser->ReallyDelete();
76
77 return 1;
78 }
79
80 browser->SetTabTitle("Event Control", 0);
81 browser->StopEmbedding();
82
83 if (verbose) {
84 std::cout << "[ ldmx-eve ] : Event display window has been opened. Enter "
85 "'.q' to quit the root prompt."
86 << std::endl;
87 }
88
89 // TApplication::Terminate is called when quitting root
90 // ROOT owns the hanging pointers and seems to be cleaning them up during
91 // quit
92 app->Run(kFALSE);
93
94 return 0;
95}
96
97void printHelp() {
98 printf("Usage: ldmx-eve [-h,--help] [-v,--verbose] eventFilePath\n");
99 printf(" -h,--help : Print this help message and exit\n");
100 printf(" -v,--verbose : Print debug messages to standard output\n");
101 printf(" eventFilePath : Event file to use in display\n");
102 printf(" Currently, only one input file is supported.\n");
103 printf(
104 " NOTE: You still need to enter '.q' to quit root after closing the "
105 "display window.\n");
106
107 return;
108}
bool SetFile(const TString file)
Opens input file and attempts to obtain the necessary information from it.
Definition Display.cxx:182
void printHelp()
Print Help Message for ldmx-eve.
Definition ldmx_eve.cxx:97