From 39c7b933946c765ef487377f78855b3963acfc0d Mon Sep 17 00:00:00 2001
From: Markus Frank <markus.frank@cern.ch>
Date: Fri, 19 Dec 2014 18:17:53 +0000
Subject: [PATCH] Improve output

---
 DDG4/scripts/dumpDDG4.C | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/DDG4/scripts/dumpDDG4.C b/DDG4/scripts/dumpDDG4.C
index 871da4dfd..a0c2290ad 100644
--- a/DDG4/scripts/dumpDDG4.C
+++ b/DDG4/scripts/dumpDDG4.C
@@ -17,6 +17,7 @@
 #include <vector>
 #include <cstdio>
 #include <memory>
+#include <cerrno>
 
 #include "TFile.h"
 #include "TTree.h"
@@ -35,6 +36,15 @@ namespace {
   static const char* line = "+-------------------------------------------------------------+";
   static bool have_geometry = false;
 
+  int usage()  {
+    printf("\ndumpDDG4 -opt [-opt]                                                                   \n"
+	   "    -compact <compact-geometry>   Supply geometry file to check hits with volume manager.\n"
+	   "    -input   <root-file>          File generated with DDG4                               \n"
+	   "    -event   <event-number>       Specify event to be dumped. Default: ALL.              \n"
+	   "\n\n");
+    return EINVAL;
+  }
+
   int printHits(const string& container, vector<Geant4Tracker::Hit*>* hits)   {
     typedef vector<Geant4Tracker::Hit*> _H;
     if ( !hits )  {
@@ -155,6 +165,7 @@ int dumpDDG4(const char* fname, int event_num)  {
   TFile* data = TFile::Open(fname);
   if ( !data || data->IsZombie() )   {
     printf("+  File seems to not exist. Exiting\n");
+    usage();
     return -1;
   }
   TTree* tree = (TTree*)data->Get("EVENT");
@@ -220,6 +231,9 @@ int main(int argc, char** argv)  {                            // Main program if
 	event_num = ::atol(argv[++i]);
     }
   }
+  if ( !fname )  {
+    return usage();
+  }
   return dumpDDG4(fname,event_num);
 }
 #endif
-- 
GitLab