Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:33

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Author: Mathieu Karamitros
0027 
0028 // The code is developed in the framework of the ESA AO7146
0029 //
0030 // We would be very happy hearing from you, send us your feedback! :)
0031 //
0032 // In order for Geant4-DNA to be maintained and still open-source,
0033 // article citations are crucial. 
0034 // If you use Geant4-DNA chemistry and you publish papers about your software, 
0035 // in addition to the general paper on Geant4-DNA:
0036 //
0037 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178
0038 //
0039 // we would be very happy if you could please also cite the following
0040 // reference papers on chemistry:
0041 //
0042 // J. Comput. Phys. 274 (2014) 841-882
0043 // Prog. Nucl. Sci. Tec. 2 (2011) 503-508 
0044 
0045 #ifndef G4ITMAPROOM_HH
0046 #define G4ITMAPROOM_HH
0047 
0048 #include <map>
0049 //#include <unordered_map>
0050 #include <vector>
0051 #include <deque>
0052 #include <cmath>
0053 #include <iostream>
0054 
0055 #include "G4Types.hh"
0056 
0057 class G4KDNode_Base;
0058 
0059 class __1DSortOut
0060 {
0061 public :
0062   __1DSortOut(std::size_t dimension);
0063   __1DSortOut(const __1DSortOut& right);
0064   G4int GetDimension();
0065   G4KDNode_Base* GetMidle(std::size_t& /*G4KDNode_deque*/);
0066 
0067   std::deque<G4KDNode_Base*>::iterator Insert(G4KDNode_Base*);
0068   G4KDNode_Base* PopOutMiddle();
0069   void Sort();
0070   void Erase(std::deque<G4KDNode_Base*>::iterator &);
0071   std::size_t Size()
0072   {
0073     return fContainer.size();
0074   }
0075 
0076 protected :
0077   struct sortOutNDim
0078   {
0079      sortOutNDim(std::size_t dimension)
0080      {
0081        fDimension = dimension;
0082      }
0083      G4bool operator() (G4KDNode_Base* const& lhs, G4KDNode_Base* const& rhs);
0084      std::size_t fDimension;
0085   };
0086 
0087   std::deque<G4KDNode_Base*> fContainer;
0088   sortOutNDim fSortOutNDim;
0089 };
0090 
0091 class G4KDMap
0092 {
0093 public:
0094   G4KDMap(std::size_t dimensions): fSortOut(dimensions, __1DSortOut(dimensions))
0095   {
0096         fIsSorted = false;
0097 //        for(std::size_t i = 0 ; i < dimensions ; ++i)
0098 //        {
0099 //            fSortOut[i] = new __1DSortOut(i);
0100 //        }
0101   }
0102 
0103   void Insert(G4KDNode_Base* pos);
0104   void Sort();
0105 
0106   G4KDNode_Base* PopOutMiddle(std::size_t dimension);
0107   std::size_t GetDimension()
0108   {
0109       return fSortOut.size();
0110   }
0111 
0112   std::size_t GetSize()
0113   {
0114       return fMap.size();
0115   }
0116 
0117 private:
0118   G4bool fIsSorted;
0119   std::vector<__1DSortOut> fSortOut;
0120   std::map<G4KDNode_Base*, std::vector<std::deque<G4KDNode_Base*>::iterator>> fMap;
0121 
0122   // A mettre directement dans G4KDNode
0123 };
0124 
0125 
0126 #endif // G4ITMAPROOM_HH