From 50cefdfff79c99be361355a7e31bb5530e6abe3b Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Tue, 31 May 2016 15:12:37 +0200
Subject: [PATCH] fixing negative event numbers. Details:
 https://its.cern.ch/jira/browse/ATLASVPONE-287. (VP1Gui-00-08-11)

    * fixing negative event numbers.
	  Details: https://its.cern.ch/jira/browse/ATLASVPONE-287
	* new tag: VP1Gui-00-08-11


Former-commit-id: d3fad031dfddc1ced3b82cfb77ee621134ebce92
---
 graphics/VP1/VP1Gui/VP1Gui/VP1EventDisplayEditor.h | 4 ++--
 graphics/VP1/VP1Gui/VP1Gui/VP1EventFile.h          | 4 ++--
 graphics/VP1/VP1Gui/VP1Gui/VP1EvtsOnServerInfo.h   | 2 +-
 graphics/VP1/VP1Gui/VP1Gui/VP1ExecutionScheduler.h | 2 +-
 graphics/VP1/VP1Gui/VP1Gui/VP1Gui.h                | 3 ++-
 graphics/VP1/VP1Gui/VP1Gui/VP1MainWindow.h         | 6 +++---
 graphics/VP1/VP1Gui/src/VP1AvailEvents.cxx         | 4 ++--
 graphics/VP1/VP1Gui/src/VP1EventDisplayEditor.cxx  | 2 +-
 graphics/VP1/VP1Gui/src/VP1EventFile.cxx           | 8 ++++----
 graphics/VP1/VP1Gui/src/VP1EvtsOnServerInfo.cxx    | 2 +-
 graphics/VP1/VP1Gui/src/VP1ExecutionScheduler.cxx  | 2 +-
 graphics/VP1/VP1Gui/src/VP1Gui.cxx                 | 8 +++++++-
 graphics/VP1/VP1Gui/src/VP1MainWindow.cxx          | 7 ++++---
 13 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/graphics/VP1/VP1Gui/VP1Gui/VP1EventDisplayEditor.h b/graphics/VP1/VP1Gui/VP1Gui/VP1EventDisplayEditor.h
index 4c49db7f367..cbc80ed5709 100644
--- a/graphics/VP1/VP1Gui/VP1Gui/VP1EventDisplayEditor.h
+++ b/graphics/VP1/VP1Gui/VP1Gui/VP1EventDisplayEditor.h
@@ -37,7 +37,7 @@ class VP1EventDisplayEditor : public QWidget {
 
 public:
 
-	VP1EventDisplayEditor(VP1MainWindow* mainWindow, QList<int> listRunEventNumberTimestamp);
+	VP1EventDisplayEditor(VP1MainWindow* mainWindow, QList<unsigned long long> listRunEventNumberTimestamp);
 	virtual ~VP1EventDisplayEditor();
 
 //	QGraphicsView* getView();
@@ -83,7 +83,7 @@ private:
 	VP1MainWindow* _mainWindow;
 
 	int _runNumber;
-	int _eventNumber;
+	unsigned long long _eventNumber;
 	unsigned _eventTimestamp;
 
 //	QSplitter *h1Splitter;
diff --git a/graphics/VP1/VP1Gui/VP1Gui/VP1EventFile.h b/graphics/VP1/VP1Gui/VP1Gui/VP1EventFile.h
index 5aca69e9211..e5867ed5ace 100644
--- a/graphics/VP1/VP1Gui/VP1Gui/VP1EventFile.h
+++ b/graphics/VP1/VP1Gui/VP1Gui/VP1EventFile.h
@@ -25,7 +25,7 @@ public:
   //The interesting bits:
   //Event identity:
   int runNumber() const;
-  int eventNumber() const;
+  unsigned long long eventNumber() const;
   unsigned rawTime() const;
   QDateTime time() const;
 
@@ -45,7 +45,7 @@ public:
   VP1EventFile(const VP1EventFile & );
   VP1EventFile & operator= (const VP1EventFile & );
   VP1EventFile(const QString& filename,const QString& md5sum,
-	       int runnumber,int eventnumber,unsigned time, bool isvalid = true );
+	       int runnumber, unsigned long long eventnumber,unsigned time, bool isvalid = true );
   VP1EventFile(const QString&, const QString& md5sum = 0);//will attempt to decode from file name (e.g. vp1_234_123_1321334.pool.root). Instance becomes invalid if not succesful.
 private:
   class Imp;
diff --git a/graphics/VP1/VP1Gui/VP1Gui/VP1EvtsOnServerInfo.h b/graphics/VP1/VP1Gui/VP1Gui/VP1EvtsOnServerInfo.h
index 4b4b7ac8ba8..8e549931014 100644
--- a/graphics/VP1/VP1Gui/VP1Gui/VP1EvtsOnServerInfo.h
+++ b/graphics/VP1/VP1Gui/VP1Gui/VP1EvtsOnServerInfo.h
@@ -35,7 +35,7 @@ public:
   QStringList print() const;
 
   //Access the results:
-  int numberOfEvents() const;
+  unsigned long long numberOfEvents() const;
   VP1EventFile newestEvent() const;
   QList<VP1EventFile> events(int timecut = -1, bool requireNewestRunNumber = false ) const;
   //Returns events in order of increasing time.
diff --git a/graphics/VP1/VP1Gui/VP1Gui/VP1ExecutionScheduler.h b/graphics/VP1/VP1Gui/VP1Gui/VP1ExecutionScheduler.h
index 90fb370e7f7..7d44f1574eb 100644
--- a/graphics/VP1/VP1Gui/VP1Gui/VP1ExecutionScheduler.h
+++ b/graphics/VP1/VP1Gui/VP1Gui/VP1ExecutionScheduler.h
@@ -65,7 +65,7 @@ public:
   static void cleanup(VP1ExecutionScheduler*);
 
   //Call when new event data are available (returns false when the user closes the program)
-  bool executeNewEvent(const int& runnumber, const int& eventnumber, const unsigned& triggerType = 0, const unsigned& time = 0);//
+  bool executeNewEvent(const int& runnumber, const unsigned long long& eventnumber, const unsigned& triggerType = 0, const unsigned& time = 0);//
 
   VP1ExecutionScheduler(QObject * parent,
 			StoreGateSvc*eventStore,StoreGateSvc*detStore,
diff --git a/graphics/VP1/VP1Gui/VP1Gui/VP1Gui.h b/graphics/VP1/VP1Gui/VP1Gui/VP1Gui.h
index 9fdfef06e68..89a5a5f542e 100644
--- a/graphics/VP1/VP1Gui/VP1Gui/VP1Gui.h
+++ b/graphics/VP1/VP1Gui/VP1Gui/VP1Gui.h
@@ -19,6 +19,7 @@
 
 #include <string>
 #include <vector>
+#include <cstdint> // for uint64_t (unsigned long long)
 
 class StoreGateSvc;
 class IToolSvc;
@@ -45,7 +46,7 @@ public:
 
   //Called every algorithm refresh:
   bool executeNewEvent( const int& run,
-			const int& event,
+			const uint64_t & event,
 			const unsigned& triggerType = 0,//When available
 			const unsigned& time = 0 //When available (seconds since 1970)
 			);
diff --git a/graphics/VP1/VP1Gui/VP1Gui/VP1MainWindow.h b/graphics/VP1/VP1Gui/VP1Gui/VP1MainWindow.h
index 3740f65e675..b0be2f8afb2 100644
--- a/graphics/VP1/VP1Gui/VP1Gui/VP1MainWindow.h
+++ b/graphics/VP1/VP1Gui/VP1Gui/VP1MainWindow.h
@@ -126,7 +126,7 @@ public slots:
   //For use when going to a new event (this updates system lists and quit()'s the app):
   void goToNextEvent();
 public:
-  void setRunEvtNumber(const int& runnumber, const int& eventnumber, const unsigned& triggerType = 0, const unsigned& time = 0, const bool& printmessage = true );
+  void setRunEvtNumber(const int& runnumber, const unsigned long long& eventnumber, const unsigned& triggerType = 0, const unsigned& time = 0, const bool& printmessage = true );
   bool mustQuit() const;
 
   VP1ChannelManager * channelManager() const { return channelmanager; }
@@ -135,7 +135,7 @@ public:
   bool userRequestedExit() { return m_userRequestedExit; }
 
   int getRunNumber() { return runnumber; }
-  int getEventNumber() { return eventnumber; }
+  unsigned long long getEventNumber() { return eventnumber; }
   int getEventTimestamp() { return timestamp; }
 
 protected:
@@ -143,7 +143,7 @@ protected:
   VP1TabManager * tabmanager;
   QString currentconfigfile;
   int runnumber;
-  int eventnumber;
+  unsigned long long eventnumber;
   unsigned timestamp;
   bool betweenevents;
 
diff --git a/graphics/VP1/VP1Gui/src/VP1AvailEvents.cxx b/graphics/VP1/VP1Gui/src/VP1AvailEvents.cxx
index d681dc9fa21..4b2ed835fb4 100644
--- a/graphics/VP1/VP1Gui/src/VP1AvailEvents.cxx
+++ b/graphics/VP1/VP1Gui/src/VP1AvailEvents.cxx
@@ -39,8 +39,8 @@ public:
 
   class EventID {
   public:
-    EventID(int r,int e) : eventNumber(e), runNumber(r) {}
-    int eventNumber;
+    EventID(int r, unsigned long long e) : eventNumber(e), runNumber(r) {}
+    unsigned long long eventNumber;
     int runNumber;
     bool operator==(const EventID & o) const{
       return eventNumber==o.eventNumber && runNumber==o.runNumber;
diff --git a/graphics/VP1/VP1Gui/src/VP1EventDisplayEditor.cxx b/graphics/VP1/VP1Gui/src/VP1EventDisplayEditor.cxx
index e2d4176a16a..1070d758a1f 100644
--- a/graphics/VP1/VP1Gui/src/VP1EventDisplayEditor.cxx
+++ b/graphics/VP1/VP1Gui/src/VP1EventDisplayEditor.cxx
@@ -139,7 +139,7 @@ public:
  * new version
  */
 //____________________________________________________________________
-VP1EventDisplayEditor::VP1EventDisplayEditor(VP1MainWindow* mainWindow, QList<int> listRunEventNumberTimestamp)
+VP1EventDisplayEditor::VP1EventDisplayEditor(VP1MainWindow* mainWindow, QList<unsigned long long> listRunEventNumberTimestamp)
 //: QWidget(0,Qt::WindowStaysOnTopHint), d(new Imp)
 : QWidget(0), d(new Imp)
 {
diff --git a/graphics/VP1/VP1Gui/src/VP1EventFile.cxx b/graphics/VP1/VP1Gui/src/VP1EventFile.cxx
index 7f24e20c724..4da7def0785 100644
--- a/graphics/VP1/VP1Gui/src/VP1EventFile.cxx
+++ b/graphics/VP1/VP1Gui/src/VP1EventFile.cxx
@@ -27,7 +27,7 @@ public:
   QString fileName;
   QString md5Sum;
   int runNumber;
-  int eventNumber;
+  unsigned long long eventNumber;
   unsigned rawTime;
   bool valid;
 
@@ -69,7 +69,7 @@ VP1EventFile::Imp * VP1EventFile::Imp::initFromFilename(const QString& filename,
   if (!ok||time>2058991200/*april 1 2035*/)//No lower bound sanity check, since the events sometimes have faulty ~1970 timestamps!
     return new Imp;
 
-  int eventnumber = eventinfoparts.at(eventinfoparts.count()-2).toInt(&ok);
+  unsigned long long eventnumber = eventinfoparts.at(eventinfoparts.count()-2).toInt(&ok);
   if (!ok)
     return new Imp;
   int runnumber = eventinfoparts.at(eventinfoparts.count()-3).toInt(&ok);
@@ -86,7 +86,7 @@ VP1EventFile::VP1EventFile(const QString& filename, const QString& md5sum)
 
 //____________________________________________________________________
 VP1EventFile::VP1EventFile(const QString& filename,const QString& md5sum,
-			   int runnumber,int eventnumber,unsigned time,bool isvalid)
+		int runnumber, unsigned long long eventnumber,unsigned time,bool isvalid)
   : d(new Imp(filename,md5sum,runnumber,eventnumber,time,isvalid))
 {
 }
@@ -170,7 +170,7 @@ int VP1EventFile::runNumber() const
 }
 
 //____________________________________________________________________
-int VP1EventFile::eventNumber() const
+unsigned long long VP1EventFile::eventNumber() const
 {
   return d->eventNumber;
 }
diff --git a/graphics/VP1/VP1Gui/src/VP1EvtsOnServerInfo.cxx b/graphics/VP1/VP1Gui/src/VP1EvtsOnServerInfo.cxx
index 0f2c8693220..693d5009a0e 100644
--- a/graphics/VP1/VP1Gui/src/VP1EvtsOnServerInfo.cxx
+++ b/graphics/VP1/VP1Gui/src/VP1EvtsOnServerInfo.cxx
@@ -221,7 +221,7 @@ QString VP1EvtsOnServerInfo::Imp::init(const QString& infofile)
 }
 
 //____________________________________________________________________
-int VP1EvtsOnServerInfo::numberOfEvents() const
+unsigned long long VP1EvtsOnServerInfo::numberOfEvents() const
 {
   return d->events.count();
 }
diff --git a/graphics/VP1/VP1Gui/src/VP1ExecutionScheduler.cxx b/graphics/VP1/VP1Gui/src/VP1ExecutionScheduler.cxx
index 477b7cfe8dd..109bde79df0 100644
--- a/graphics/VP1/VP1Gui/src/VP1ExecutionScheduler.cxx
+++ b/graphics/VP1/VP1Gui/src/VP1ExecutionScheduler.cxx
@@ -468,7 +468,7 @@ void VP1ExecutionScheduler::setNextRequestedEventFile(const QString& f)
 }
 
 //___________________________________________________________________
-bool VP1ExecutionScheduler::executeNewEvent(const int& runnumber, const int& eventnumber, const unsigned& triggerType, const unsigned& time)
+bool VP1ExecutionScheduler::executeNewEvent(const int& runnumber, const unsigned long long& eventnumber, const unsigned& triggerType, const unsigned& time)
 {
 	VP1Msg::messageDebug("VP1ExecutionScheduler::executeNewEvent()");
 
diff --git a/graphics/VP1/VP1Gui/src/VP1Gui.cxx b/graphics/VP1/VP1Gui/src/VP1Gui.cxx
index af13e755732..b68737bb216 100644
--- a/graphics/VP1/VP1Gui/src/VP1Gui.cxx
+++ b/graphics/VP1/VP1Gui/src/VP1Gui.cxx
@@ -193,8 +193,14 @@ void VP1Gui::cleanup()
 }
 
 //____________________________________________________________________
-bool VP1Gui::executeNewEvent( const int& run, const int& event, const unsigned& triggerType, const unsigned& time )
+bool VP1Gui::executeNewEvent( const int& run, const uint64_t& event, const unsigned& triggerType, const unsigned& time )
 {
+	//tests
+	int evN = event;
+	qulonglong evNqu = event;
+
+	qDebug() << "tests:" << QString::number(event) << QString::number(evN) << QString::number(evNqu);
+
   VP1Msg::messageDebug("Examining new event ( run# "+QString::number(run)+", event# "+QString::number(event)+" )");
 
   bool b = d->the_scheduler->executeNewEvent(run,event,triggerType,time);
diff --git a/graphics/VP1/VP1Gui/src/VP1MainWindow.cxx b/graphics/VP1/VP1Gui/src/VP1MainWindow.cxx
index dd443f78eef..d75874c74d6 100644
--- a/graphics/VP1/VP1Gui/src/VP1MainWindow.cxx
+++ b/graphics/VP1/VP1Gui/src/VP1MainWindow.cxx
@@ -843,7 +843,7 @@ void VP1MainWindow::closeEvent(QCloseEvent * event)
 }
 
 //_________________________________________________________________________________
-void VP1MainWindow::setRunEvtNumber(const int& r, const int& e, const unsigned& triggerType, const unsigned& time, const bool& printmessage ) {
+void VP1MainWindow::setRunEvtNumber(const int& r, const unsigned long long& e, const unsigned& triggerType, const unsigned& time, const bool& printmessage ) {
 
 	scheduler->setNextRequestedEventFile("");
 	const bool sameasold(runnumber==r&&eventnumber==e);
@@ -862,7 +862,8 @@ void VP1MainWindow::setRunEvtNumber(const int& r, const int& e, const unsigned&
 	}
 
 	if(printmessage) {
-		QString evtstr = "run# "+QString::number(runnumber)+", event# "+QString::number(eventnumber)+(sameasold?" (reused)":"");
+		qulonglong evNumber = eventnumber;
+		QString evtstr = "run# "+QString::number(runnumber)+", event# "+QString::number(evNumber)+(sameasold?" (reused)":"");
 		QString trighex = triggerType > 0 ? "0x"+QString::number(triggerType, 16).toUpper().rightJustified(sizeof(triggerType),'0') : "";
 		QString expandedevtstr = evtstr
 				+ QString(trighex.isEmpty()?QString(""):", triggerType: "+trighex)
@@ -955,7 +956,7 @@ void VP1MainWindow::makeAllChannelsEventDisplay()
 
 	QList<QPixmap> list;
 	QStringList listNames;
-	QList<int> listRunEventNumberTimestamp;
+	QList<unsigned long long> listRunEventNumberTimestamp;
 
 	getAllChannelsIntoSnapshots(list, listNames);
 
-- 
GitLab