From ea83a6070a3d03d2b5e0c5c161c785ef258b701d Mon Sep 17 00:00:00 2001
From: adrien-matta <a.matta@surrey.ac.uk>
Date: Mon, 23 Jul 2018 13:50:48 +0200
Subject: [PATCH] * Suppressing Warning with clang * Fixing pile up in silicon
 scorers

---
 NPLib/Core/NPOptionManager.cxx                |  2 +-
 NPLib/Core/NPSpectraServer.cxx                | 31 ++++++++++---------
 NPLib/Detectors/Actar/TActarPhysics.cxx       |  1 +
 NPLib/Physics/NPDecay.cxx                     | 10 ++++--
 NPSimulation/Detectors/Actar/Actar.cc         | 12 +++----
 NPSimulation/Detectors/Tigress/Tigress.cc     | 15 +++------
 NPSimulation/Detectors/Tigress/Tigress.hh     |  4 +--
 .../Detectors/Tigress/TigressScorers.cc       |  2 +-
 NPSimulation/Scorers/SiliconScorers.cc        | 11 ++++---
 9 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/NPLib/Core/NPOptionManager.cxx b/NPLib/Core/NPOptionManager.cxx
index 7f299c009..7c797e36a 100644
--- a/NPLib/Core/NPOptionManager.cxx
+++ b/NPLib/Core/NPOptionManager.cxx
@@ -115,7 +115,7 @@ void NPOptionManager::ReadTheInputArgument(int argc, char** argv){
 
     else if (argument == "-R" && argc >= i + 1)                   fRunToReadFileName   = argv[++i] ;
 
-    else if (argument == "-T" && argc >= i + 2)                   CreateRunToTreatFile(argv[++i],argv[++i]);
+    else if (argument == "-T" && argc >= i + 2)                   { std::string file = argv[++i] ; std::string tree = argv[++i]; CreateRunToTreatFile(file,tree);}
 
     else if (argument == "--cal" && argc >= i + 1)                fCalibrationFileName = argv[++i] ;
 
diff --git a/NPLib/Core/NPSpectraServer.cxx b/NPLib/Core/NPSpectraServer.cxx
index 940c81391..ddfbf1bb1 100644
--- a/NPLib/Core/NPSpectraServer.cxx
+++ b/NPLib/Core/NPSpectraServer.cxx
@@ -1,4 +1,3 @@
-
 /*****************************************************************************
  * Copyright (C) 2009-2016   this file is part of the NPTool Project         *
  *                                                                           *
@@ -68,7 +67,7 @@ void NPL::SpectraServer::CheckRequest(){
     m_Monitor->ResetInterrupt();
     if((s=m_Monitor->Select(1))!=(TSocket*)-1){
       HandleSocket(s);
-      }
+    }
   }
 }
 
@@ -106,8 +105,8 @@ void NPL::SpectraServer::HandleSocket(TSocket* s){
     answer.SetCompressionLevel(1);
     answer.Reset();
     TObject* h =NULL;
-   if (!strcmp(request, "RequestSpectra")){
-     std::cout << "Prepare" << std::endl;
+    if (!strcmp(request, "RequestSpectra")){
+      std::cout << "Prepare" << std::endl;
       answer.WriteObject(m_Spectra);
       std::cout << "Compress" << std::endl;
       answer.Compress();
@@ -115,18 +114,22 @@ void NPL::SpectraServer::HandleSocket(TSocket* s){
       s->Send(answer);
       std::cout << "done" << std::endl;
     }
-  
-    else if (h=m_Spectra->FindObject(request)){
-     answer.WriteObject(h);
-     s->Send(answer);
-    }
 
     else if (!strcmp(request, "RequestClear")){
-     // TO DO 
+      // TO DO 
     }
-    else{ // answer nothing
-      std::cout << "Fail to respond to request : " << request << std::endl; 
-      s->Send(answer);
+
+    else{
+      h = m_Spectra->FindObject(request);
+      if (h){
+        answer.WriteObject(h);
+        s->Send(answer);
+      }
+
+      else{ // answer nothing
+        std::cout << "Fail to respond to request : " << request << std::endl; 
+        s->Send(answer);
+      }
     }
   }
 }
@@ -139,7 +142,7 @@ void NPL::SpectraServer::FillSpectra(const std::string& name,const double& valx)
 void NPL::SpectraServer::FillSpectra(const std::string& name,const double& valx,const double& valy){
   // Fill the local histo
   ((TH2*) m_Spectra->FindObject(name.c_str()))->Fill(valx,valy);
-  
+
 }
 ////////////////////////////////////////////////////////////////////////////////
 void NPL::SpectraServer::AddSpectra(TH1* h){
diff --git a/NPLib/Detectors/Actar/TActarPhysics.cxx b/NPLib/Detectors/Actar/TActarPhysics.cxx
index c1b79c0d8..644cbd4d1 100644
--- a/NPLib/Detectors/Actar/TActarPhysics.cxx
+++ b/NPLib/Detectors/Actar/TActarPhysics.cxx
@@ -302,6 +302,7 @@ vector<TCanvas*> TActarPhysics::GetCanvas() {
     //vector<TCanvas*> empty;
     //return empty;
   //}
+  return vector<TCanvas*>();
 }
 
 
diff --git a/NPLib/Physics/NPDecay.cxx b/NPLib/Physics/NPDecay.cxx
index 68a6eb6db..76312bfef 100644
--- a/NPLib/Physics/NPDecay.cxx
+++ b/NPLib/Physics/NPDecay.cxx
@@ -216,7 +216,9 @@ bool NPL::SingleDecay::GenerateEvent(double MEx, double MEK, double MPX, double
    DPx[pos]=NucleiLV.X();
    DPy[pos]=NucleiLV.Y();
    DPz[pos]=NucleiLV.Z();
+   return true;
   }
+  return false;
 }
 ////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////// Decay ///////////////////////////////////////
@@ -388,10 +390,12 @@ void NPL::DecayStore::GenerateEvent(std::string MotherName, double MEx,
 }
 ////////////////////////////////////////////////////////////////////////////////
 bool NPL::DecayStore::AnyAboveThreshold(std::string MotherName, double MEx){
-  if(m_Store.find(MotherName)!=m_Store.end())
+  if(m_Store.find(MotherName)!=m_Store.end()){
     m_Store[MotherName].AnyAboveThreshold(MEx);
-  else
-    return false;
+    return true;
+  }
+    
+  return false;
 }
 ////////////////////////////////////////////////////////////////////////////////
 std::set<std::string> NPL::DecayStore::GetAllMotherName(){
diff --git a/NPSimulation/Detectors/Actar/Actar.cc b/NPSimulation/Detectors/Actar/Actar.cc
index 741f247d3..090dcc5b5 100644
--- a/NPSimulation/Detectors/Actar/Actar.cc
+++ b/NPSimulation/Detectors/Actar/Actar.cc
@@ -1,18 +1,18 @@
 /*****************************************************************************
- * Copyright (C) 2009-2017   this file is part of the NPTool Project       *
+ * Copyright (C) 2009-2017   this file is part of the NPTool Project         *
  *                                                                           *
  * For the licensing terms see $NPTOOL/Licence/NPTool_Licence                *
  * For the list of contributors see $NPTOOL/Licence/Contributors             *
  *****************************************************************************/
 
 /*****************************************************************************
- * Original Author: Pierre Morfouace  contact address: morfouac@nscl.msu.edu                        *
+ * Original Author: Pierre Morfouace  contact address: morfouac@nscl.msu.edu *
  *                                                                           *
  * Creation Date  : September 2017                                           *
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
- *  This class describe  Actar simulation                             *
+ *  This class describe  Actar simulation                                    *
  *                                                                           *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
@@ -186,8 +186,8 @@ G4LogicalVolume* Actar::BuildDetector(){
                                  1*um*0.5,2*mm*0.5);
 
         // Cathode
-        G4Box* sCathode = new G4Box("Actar_Cathode",26.5*cm*0.5,
-                                    1*um*0.5,25.6*cm*0.5);
+        //G4Box* sCathode = new G4Box("Actar_Cathode",26.5*cm*0.5,
+        //                            1*um*0.5,25.6*cm*0.5);
 
 
 
@@ -244,7 +244,7 @@ G4LogicalVolume* Actar::BuildDetector(){
         G4LogicalVolume* logicGas = new G4LogicalVolume(sCage,DriftGasMaterial,"logic_Gas",0,0,0);
         G4LogicalVolume* logicNose = new G4LogicalVolume(sNose,Al,"logic_Nose",0,0,0);
         G4LogicalVolume* logicPad = new G4LogicalVolume(sPad,Cu,"logic_Pad",0,0,0);
-        G4LogicalVolume* logicCathode = new G4LogicalVolume(sCathode,Cu,"logic_Cathode",0,0,0);
+        //G4LogicalVolume* logicCathode = new G4LogicalVolume(sCathode,Cu,"logic_Cathode",0,0,0);
         G4LogicalVolume* logicWindows = new G4LogicalVolume(sWindows,Mylar,"logic_Windows",0,0,0);
 
         G4RotationMatrix* Rot = new G4RotationMatrix();
diff --git a/NPSimulation/Detectors/Tigress/Tigress.cc b/NPSimulation/Detectors/Tigress/Tigress.cc
index c0aa303e3..95d0be928 100644
--- a/NPSimulation/Detectors/Tigress/Tigress.cc
+++ b/NPSimulation/Detectors/Tigress/Tigress.cc
@@ -592,11 +592,11 @@ void Tigress::ReadSensitive(const G4Event* event){
 
 		G4double* Info = *(HPGE_itr->second);
 
-		G4double Energy   =  Info[0]; // RandGauss::shoot(Info[0], ResoEnergy/2.334);
-		G4double Time     =  Info[1];
-		G4int CloverNbr   = (int)Info[7];
+//		G4double Energy   =  Info[0]; // RandGauss::shoot(Info[0], ResoEnergy/2.334);
+//		G4double Time     =  Info[1];
+//		G4int CloverNbr   = (int)Info[7];
 		G4int CrystalNbr  = (int)Info[8];
-    
+   
 		// Figure out segment number, in progress
 		G4int SegmentNbr = 0;
 		G4double zpos = Info[4]; // mm
@@ -604,13 +604,6 @@ void Tigress::ReadSensitive(const G4Event* event){
 		else if(CrystalNbr == 1 || CrystalNbr == 4) { SegmentNbr = 1; } // RIGHT
 		else                                        { SegmentNbr = 3; } // LEFT
 		
-		// To avoid warning for now, in progress
-    Energy=Energy;
-    Time=Time;
-    CloverNbr=CloverNbr;
-    CrystalNbr=CrystalNbr;
-    SegmentNbr=SegmentNbr;
-    
 		//m_TigressData->SetCoreE(CloverNbr, CrystalNbr, Energy/keV);
 		//m_TigressData->SetCoreT(CloverNbr, CrystalNbr, Time/ns);
 		//m_TigressData->SetSegmentE(CloverNbr, SegmentNbr, Energy/keV);
diff --git a/NPSimulation/Detectors/Tigress/Tigress.hh b/NPSimulation/Detectors/Tigress/Tigress.hh
index 807b35640..ca56bc9b7 100644
--- a/NPSimulation/Detectors/Tigress/Tigress.hh
+++ b/NPSimulation/Detectors/Tigress/Tigress.hh
@@ -161,8 +161,8 @@ private:
   vector<double> m_BetaZ;
     
   // Frame: true if the frame is to be done
-  bool m_LeftFrame;
-  bool m_RightFrame;
+  //  bool m_LeftFrame;
+  //  bool m_RightFrame;
   
 private:/// Visualisation Attribute:
   G4VisAttributes* BlueVisAtt;
diff --git a/NPSimulation/Detectors/Tigress/TigressScorers.cc b/NPSimulation/Detectors/Tigress/TigressScorers.cc
index 2bbf0ca9d..b4b78912a 100644
--- a/NPSimulation/Detectors/Tigress/TigressScorers.cc
+++ b/NPSimulation/Detectors/Tigress/TigressScorers.cc
@@ -15,7 +15,7 @@ using namespace TIGRESSSCORERS;
 
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-PS_Tigress::PS_Tigress(G4String name,G4int Level,G4int depth)
+PS_Tigress::PS_Tigress(G4String name,G4int ,G4int depth)
   :G4VPrimitiveScorer(name, depth),HCID(-1){
 	m_Position = G4ThreeVector(-1000,-1000,-1000);
 	m_CloverNumber  = -1;
diff --git a/NPSimulation/Scorers/SiliconScorers.cc b/NPSimulation/Scorers/SiliconScorers.cc
index 961783ee1..052ccbd3b 100644
--- a/NPSimulation/Scorers/SiliconScorers.cc
+++ b/NPSimulation/Scorers/SiliconScorers.cc
@@ -23,7 +23,8 @@
 #include "G4UnitsTable.hh"
 using namespace SILICONSCORERS ;
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-PS_Silicon_Images::PS_Silicon_Images(G4String name, string imageFront,string imageBack,double scalingFront, double scalingBack, double centerOffsetX,double centerOffsetY,unsigned int ignoreValue, G4int depth)  :G4VPrimitiveScorer(name, depth),HCID(-1){
+PS_Silicon_Images::PS_Silicon_Images(G4String name, string imageFront,string imageBack,double scalingFront, double scalingBack, double centerOffsetX,double centerOffsetY,unsigned int ignoreValue, G4int depth)  :G4VPrimitiveScorer(name, depth){
+    HCID=-1;
     m_ImageFront = new NPL::Image(imageFront,scalingFront,scalingFront);
     m_ImageBack  = new NPL::Image(imageBack,scalingBack,scalingBack);
     m_ScalingFront = scalingFront;
@@ -61,7 +62,7 @@ G4bool PS_Silicon_Images::ProcessHits(G4Step* aStep, G4TouchableHistory*){
   if(t_PixelFront == m_IgnoreValue && t_PixelBack == m_IgnoreValue)
     return FALSE;
 
-  t_Index =  aStep->GetTrack()->GetTrackID() + t_DetectorNbr * 1e3 ;
+  t_Index = t_DetectorNbr * 1e3 + t_PixelFront * 1e6 + t_PixelBack * 1e9 ;
   // Check if the particle has interact before, if yes, add up the energies.
   map<unsigned int, double>::iterator it;
   it= m_Energy.find(t_Index);
@@ -237,7 +238,7 @@ G4bool PS_Silicon_Rectangle::ProcessHits(G4Step* aStep, G4TouchableHistory*){
     Infos[8] = m_StripLengthNumber;
     Infos[9] = m_StripWidthNumber;
 
-    m_Index =  aStep->GetTrack()->GetTrackID() + m_DetectorNumber * 1e3 + m_StripLengthNumber * 1e6 + m_StripWidthNumber * 1e9;
+    m_Index = m_DetectorNumber * 1e3 + m_StripLengthNumber * 1e6 + m_StripWidthNumber * 1e9;
 
     // Check if the particle has interact before, if yes, add up the energies.
     map<G4int, G4double**>::iterator it;
@@ -357,7 +358,7 @@ G4bool PS_Silicon_Annular::ProcessHits(G4Step* aStep, G4TouchableHistory*){
     Infos[9] = m_StripSectorNumber;
     Infos[10] = m_StripQuadrantNumber;
 
-    m_Index =  aStep->GetTrack()->GetTrackID() + m_DetectorNumber * 1e3 + m_StripRingNumber * 1e6 + m_NumberOfStripSector * 1e9;
+    m_Index = m_DetectorNumber * 1e3 + m_StripRingNumber * 1e6 + m_NumberOfStripSector * 1e9;
 
     // Check if the particle has interact before, if yes, add up the energies.
     map<G4int, G4double**>::iterator it;
@@ -462,7 +463,7 @@ G4bool PS_Silicon_Resistive::ProcessHits(G4Step* aStep, G4TouchableHistory*){
     //Rare case where particle is close to edge of silicon plan
     if (m_StripWidthNumber > m_NumberOfStripWidth) m_StripWidthNumber = m_NumberOfStripWidth;
 
-    m_Index =  aStep->GetTrack()->GetTrackID() + m_DetectorNumber * 1e3 + m_StripWidthNumber * 1e6;
+    m_Index = m_DetectorNumber * 1e3 + m_StripWidthNumber * 1e6;
 
     // Check if the particle has interact before, if yes, add up the energies.
     map<G4int, G4double**>::iterator it;
-- 
GitLab