Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:58

0001 //
0002 //    *************************************
0003 //    *                                   *
0004 //    *          PHField3DCylindrical.h            *
0005 //    *                                   *
0006 //    *************************************
0007 //
0008 // **************************************************************
0009 //
0010 // GEANT Field Map, for use in converting ROOT maps of
0011 // PHENIX magnetic field.  Written by Michael Stone, July 2011
0012 //
0013 // **************************************************************
0014 //
0015 // The structure of the indices has little to do with physics and
0016 // has much more to do with the way the PHENIX field map is formatted
0017 // in SimMap3D++.root i.e.  The z value is incremented only after
0018 // every phi and r point has been accounted for in that plane.
0019 
0020 #ifndef PHFIELD_PHFIELD3DCYLINDRICAL_H
0021 #define PHFIELD_PHFIELD3DCYLINDRICAL_H
0022 
0023 #include "PHField.h"
0024 
0025 #include <map>
0026 #include <string>
0027 #include <tuple>
0028 #include <vector>
0029 
0030 class PHField3DCylindrical : public PHField
0031 {
0032   typedef std::tuple<float, float, float> trio;
0033 
0034  public:
0035   PHField3DCylindrical(const std::string& filename, int verb = 0, const float magfield_rescale = 1.0);
0036   ~PHField3DCylindrical() override {}
0037   void GetFieldValue(const double Point[4], double* Bfield) const override;
0038   void GetFieldCyl(const double CylPoint[4], double* Bfield) const;
0039 
0040  protected:
0041   // < i, j, k > , this allows i and i+1 to be neighbors ( <i,j,k>=<z,r,phi> )
0042   std::vector<std::vector<std::vector<float> > > BFieldZ_;
0043   std::vector<std::vector<std::vector<float> > > BFieldR_;
0044   std::vector<std::vector<std::vector<float> > > BFieldPHI_;
0045 
0046   // maps indices to values z_map[i] = z_value that corresponds to ith index
0047   std::vector<float> z_map_;    // < i >
0048   std::vector<float> r_map_;    // < j >
0049   std::vector<float> phi_map_;  // < k >
0050 
0051   float maxz_, minz_;  // boundaries of magnetic field map cyl
0052 
0053  private:
0054   bool bin_search(const std::vector<float>& vec, unsigned start, unsigned end, const float& key, unsigned& index) const;
0055   void print_map(std::map<trio, trio>::iterator& it) const;
0056 };
0057 
0058 #endif