From 38f7111aa09f793d4ab9dc68807c464d4836588c Mon Sep 17 00:00:00 2001 From: "Stephen A. Wood" <saw@jlab.org> Date: Thu, 7 Feb 2013 15:13:24 -0500 Subject: [PATCH] Also do rounding when double parameter arrays stuffed into Int_t arrays. --- src/THcParmList.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/THcParmList.cxx b/src/THcParmList.cxx index c45b170..0d9a845 100644 --- a/src/THcParmList.cxx +++ b/src/THcParmList.cxx @@ -530,11 +530,20 @@ Int_t THcParmList::ReadArray(const char* attrC, T* array, Int_t size) " which has length " << sz << endl; } if(size<sz) sz = size; + Int_t donint = 0; + if(ty == kDouble && typeid(array[0]) == typeid(Int_t)) { + donint = 1; // Use nint when putting doubles in nint + cout << "*** WARNING!!! Rounded " << attrC << " elements to nearest integer " << endl; + } for(cnt=0;cnt<sz;cnt++) { if(ty == kInt) { array[cnt] = ((Int_t*)vp)[cnt]; } else - array[cnt] = ((Double_t*)vp)[cnt]; + if(donint) { + array[cnt] = TMath::Nint(((Double_t*)vp)[cnt]); + } else { + array[cnt] = ((Double_t*)vp)[cnt]; + } } return(cnt); } -- GitLab