From 330d783c43b75caaba42f5b8be5037ff96ada1a2 Mon Sep 17 00:00:00 2001
From: Walter Lampl <Walter.Lampl@cern.ch>
Date: Sun, 25 Sep 2022 04:28:38 +0200
Subject: [PATCH] AtlXYZBSEvent.cxx: Use 64 bits for event number

---
 Event/ByteStreamCnvSvc/test/AtlCopyBSEvent.cxx | 18 +++++++++---------
 Event/ByteStreamCnvSvc/test/AtlFindBSEvent.cxx | 10 +++++-----
 .../ByteStreamCnvSvc/test/AtlListBSEvents.cxx  |  2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/Event/ByteStreamCnvSvc/test/AtlCopyBSEvent.cxx b/Event/ByteStreamCnvSvc/test/AtlCopyBSEvent.cxx
index 462be7a87eb5..094739b927b4 100644
--- a/Event/ByteStreamCnvSvc/test/AtlCopyBSEvent.cxx
+++ b/Event/ByteStreamCnvSvc/test/AtlCopyBSEvent.cxx
@@ -41,7 +41,7 @@
 
 #include "CxxUtils/checker_macros.h"
 
-void eventLoop(DataReader*, EventStorage::DataWriter*, unsigned&, const std::vector<uint32_t>*, uint32_t, bool, bool, bool, const std::vector<long long int>* = 0);
+void eventLoop(DataReader*, EventStorage::DataWriter*, unsigned&, const std::vector<uint64_t>*, uint32_t, bool, bool, bool, const std::vector<long long int>* = 0);
 
 int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[]) {
   using namespace eformat;
@@ -63,7 +63,7 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[]) {
   std::vector<std::string> collNames, collTypes;
   std::string collConnect;
   std::string collQuery;
-  std::vector<uint32_t> searchEvents;
+  std::vector<uint64_t> searchEvents;
   std::vector<std::string> searchTokens;
   uint32_t searchRun=0; 
   bool searchEventSet=false;
@@ -83,7 +83,7 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[]) {
       if (arg2.size()>0 && isdigit(arg2[0])) {
 	size_t p=0;
 	while (p!=std::string::npos) {
-	  searchEvents.push_back(atol(arg2.c_str()+p));
+	  searchEvents.push_back(atoll(arg2.c_str()+p));
 	  p=arg2.find(',',p);
 	  if (p!=std::string::npos) p++;
 	}
@@ -176,7 +176,7 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[]) {
   }// End loop over arguments
 
   std::map<Guid, std::string> guidPfn;
-  std::map<std::string, std::vector<uint32_t> > searchEventByPFN;
+  std::map<std::string, std::vector<uint64_t> > searchEventByPFN;
   std::map<std::string, std::vector<long long int> > offsetEventByPFN;
   // If no event search set, then we need a POOL collections as input
   if (!searchEventSet && !collNames.empty()) {
@@ -233,12 +233,12 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[]) {
               guidPfn.insert(std::pair<Guid, std::string>(guid, pfn));
               // add pfn to list
               fileNames.push_back(pfn);
-              std::vector<uint32_t> evts;
+              std::vector<uint64_t> evts;
               std::vector<long long int> offs;
               evts.push_back(*evNum);
               offs.push_back(pos);
               // fill map of pfn to event number list
-              searchEventByPFN.insert(std::pair<std::string, std::vector<uint32_t> >(pfn, evts));
+              searchEventByPFN.insert(std::pair<std::string, std::vector<uint64_t> >(pfn, evts));
               // fill map of pfn to offset list
               offsetEventByPFN.insert(std::pair<std::string, std::vector<long long int> >(pfn, offs));
             } else {   // guid already in map guid to pfn map
@@ -269,7 +269,7 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[]) {
 
   std::sort(searchEvents.begin(),searchEvents.end());
   std::cout << "Events to copy: ";
-  for (std::vector<uint32_t>::const_iterator itEvt1=searchEvents.begin(), itEvt2=searchEvents.end(); itEvt1!=itEvt2; ++itEvt1) {
+  for (std::vector<uint64_t>::const_iterator itEvt1=searchEvents.begin(), itEvt2=searchEvents.end(); itEvt1!=itEvt2; ++itEvt1) {
     std::cout << *itEvt1 << " ";
   }
   std::cout << std::endl;
@@ -364,7 +364,7 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[]) {
   return 0;
 }
 
-void eventLoop(DataReader* pDR, EventStorage::DataWriter* pDW, unsigned& nFound, const std::vector<uint32_t>* pSearchEvents, uint32_t searchRun, bool searchRunSet, bool listEvents, bool checkEvents, const std::vector<long long int>* pOffsetEvents) {
+void eventLoop(DataReader* pDR, EventStorage::DataWriter* pDW, unsigned& nFound, const std::vector<uint64_t>* pSearchEvents, uint32_t searchRun, bool searchRunSet, bool listEvents, bool checkEvents, const std::vector<long long int>* pOffsetEvents) {
   using namespace eformat;
   // the event loop
   uint32_t eventCounter=0;
@@ -414,7 +414,7 @@ void eventLoop(DataReader* pDR, EventStorage::DataWriter* pDW, unsigned& nFound,
       FullEventFragment<const uint32_t*> fe(fragment);
       if (checkEvents) fe.check_tree();
       
-      uint32_t eventNo=fe.global_id();
+      uint64_t eventNo=fe.global_id();
       uint32_t runNo=fe.run_no();
       if (listEvents)
         std::cout << "Index=" << eventCounter <<" Run=" << runNo << " Event=" << eventNo 
diff --git a/Event/ByteStreamCnvSvc/test/AtlFindBSEvent.cxx b/Event/ByteStreamCnvSvc/test/AtlFindBSEvent.cxx
index 2a312e536f0f..8303b86c1720 100644
--- a/Event/ByteStreamCnvSvc/test/AtlFindBSEvent.cxx
+++ b/Event/ByteStreamCnvSvc/test/AtlFindBSEvent.cxx
@@ -53,7 +53,7 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[])
   }
 
   std::vector<std::string> fileNames;
-  uint32_t searchEvent=std::numeric_limits<uint32_t>::max();
+  uint64_t searchEvent=std::numeric_limits<uint64_t>::max();
   uint32_t searchRun=std::numeric_limits<uint32_t>::max(); 
   uint32_t eventCounter=0;
   bool listevents=false;
@@ -67,7 +67,7 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[])
     if (arg1=="-e" || arg1=="--event") {
       //try read event number
       if (arg2.size() && isdigit(arg2[0])) 
-	searchEvent=atoi(arg2.c_str());
+	searchEvent=atoll(arg2.c_str());
       else {
 	std::cout << "ERROR: no numerical argument found after '" << arg1 << "'" << std::endl;
 	return -1;
@@ -99,7 +99,7 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[])
     return -1;
   }
 
-  if (searchEvent==std::numeric_limits<uint32_t>::max()) 
+  if (searchEvent==std::numeric_limits<uint64_t>::max()) 
     listevents=true;
 
 
@@ -182,7 +182,7 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[])
       
 	if (checkevents) fe.check_tree();
 	
-	const uint32_t eventNo=fe.global_id();
+	const uint64_t eventNo=fe.global_id();
 	const uint32_t runNo=fe.run_no();
 	const time_t sec=fe.bc_time_seconds();
 	if (listevents) {
@@ -229,7 +229,7 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[])
   if (!found) {
     if (searchRun!=std::numeric_limits<uint32_t>::max()) 
       std::cout << "Run " << searchRun << " ";
-    if (searchEvent!=std::numeric_limits<uint32_t>::max()) 
+    if (searchEvent!=std::numeric_limits<uint64_t>::max()) 
       std::cout << "Event " << searchEvent << " not found in given files" 
 		<< std::endl;
     return -1;
diff --git a/Event/ByteStreamCnvSvc/test/AtlListBSEvents.cxx b/Event/ByteStreamCnvSvc/test/AtlListBSEvents.cxx
index 80019d150d9e..2084a7c6a33d 100644
--- a/Event/ByteStreamCnvSvc/test/AtlListBSEvents.cxx
+++ b/Event/ByteStreamCnvSvc/test/AtlListBSEvents.cxx
@@ -181,7 +181,7 @@ int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[])
 	if (checkevents) fe.check_tree();
 	totalSize+=fe.readable_payload_size_word()*4;
 	
-	const uint32_t eventNo=fe.global_id();
+	const uint64_t eventNo=fe.global_id();
 	const uint32_t runNo=fe.run_no();
 	const time_t sec=fe.bc_time_seconds();
 	if (listevents) {
-- 
GitLab