Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:07

0001 /// @file GenericPolyconeStruct.h
0002 /// @author Raman Sehgal (raman.sehgal@cern.ch)
0003 
0004 #ifndef VECGEOM_VOLUMES_GENERICPOLYCONESTRUCT_H_
0005 #define VECGEOM_VOLUMES_GENERICPOLYCONESTRUCT_H_
0006 #include "VecGeom/base/Global.h"
0007 #include "VecGeom/base/Vector3D.h"
0008 #include "VecGeom/base/Vector.h"
0009 #include "VecGeom/volumes/CoaxialConesStruct.h"
0010 #include "VecGeom/volumes/GenericPolyconeSection.h"
0011 namespace vecgeom {
0012 
0013 // VECGEOM_DEVICE_DECLARE_CONV_TEMPLATE(struct, GenericPolyconeStruct, typename);
0014 
0015 inline namespace VECGEOM_IMPL_NAMESPACE {
0016 
0017 template <typename T = double>
0018 struct GenericPolyconeStruct {
0019 
0020   // Data members to store
0021   Vector<Vector<T>> fVectOfRmin1Vect;
0022   Vector<Vector<T>> fVectOfRmax1Vect;
0023   Vector<Vector<T>> fVectOfRmin2Vect;
0024   Vector<Vector<T>> fVectOfRmax2Vect;
0025   Vector<T> fVectOfDz;
0026   T fSPhi;
0027   T fDPhi;
0028 
0029   VECCORE_ATT_HOST_DEVICE
0030   GenericPolyconeStruct() {}
0031 
0032   VECCORE_ATT_HOST_DEVICE
0033   // Special function NOT to be exposed to user, and will be used by constructor
0034   void Set(Vector<Vector<Precision>> vectOfRmin1Vect, Vector<Vector<Precision>> vectOfRmax1Vect,
0035            Vector<Vector<Precision>> vectOfRmin2Vect, Vector<Vector<Precision>> vectOfRmax2Vect, Vector<Precision> zS,
0036            Precision sPhi, Precision dPhi)
0037   {
0038     fSPhi = sPhi;
0039     fDPhi = dPhi;
0040     for (unsigned int i = 0; i < vectOfRmin1Vect.size(); i++) {
0041 
0042       // Creating and filling the GenericPolyconeSection
0043       GenericPolyconeSection section;
0044       // Precision shift                             = zS[i] + 0.5 * (zS[i + 1] - zS[i]);
0045       Precision dz                                = 0.5 * (zS[i + 1] - zS[i]);
0046       Precision shift                             = zS[i] + dz;
0047       CoaxialConesStruct<Precision> *coaxialCones = new CoaxialConesStruct<Precision>(
0048           vectOfRmin1Vect[i], vectOfRmax1Vect[i], vectOfRmin2Vect[i], vectOfRmax2Vect[i], dz, fSPhi, fDPhi);
0049       fCubicVolume += coaxialCones->Capacity();
0050       section.fShift        = shift;
0051       section.fCoaxialCones = coaxialCones;
0052 
0053       // Inserting the section just created above
0054       fSections.push_back(section);
0055     }
0056     fZs          = zS;
0057     fCubicVolume = Capacity();
0058   }
0059 
0060   // Vector of GenericPolyconeSection
0061   Vector<GenericPolyconeSection> fSections;
0062 
0063   /* Variables to be Cached
0064    * 1) All the Z Planes fZs
0065    */
0066 
0067   Vector<Precision> fZs;
0068 
0069   T fSurfaceArea; // area of the surface
0070   T fCubicVolume; // volume
0071 
0072   // Some Helper function to calculate SurfaceArea
0073 #if (0)
0074   Precision ConicalSurfaceArea()
0075   {
0076     Precision conicalSurfaceArea = 0.;
0077     for (unsigned int i = 0; i < fSections.size(); i++) {
0078       conicalSurfaceArea += fSections[i].fCoaxialCones->ConicalSurfaceArea();
0079     }
0080     return conicalSurfaceArea;
0081   }
0082 
0083   Precision SurfaceAreaOfZPlanes()
0084   {
0085     Precision surfaceAreaOfZPlanes = 0.;
0086     if (fSections.size() == 1) {
0087       return fSections[0].fCoaxialCones->SurfaceAreaOfZPlanes();
0088     } else if (fSections.size() > 1) {
0089       CoaxialConesStruct<Precision> *firstSectionCones = fSections[0].fCoaxialCones;
0090       CoaxialConesStruct<Precision> *lastSectionCones  = fSections[fSections.size() - 1].fCoaxialCones;
0091       return (firstSectionCones->TotalSurfaceAreaOfLowerZPlanes() + lastSectionCones->TotalSurfaceAreaOfUpperZPlanes());
0092     }
0093     /*for(unsigned int i = 0 ; i < fSections.size() ; i++){
0094       CoaxialConesStruct<Precision> *CoaxialCones = fSections[i].fCoaxialCones;
0095     }*/
0096   }
0097 #endif
0098   /*
0099     Precision Capacity(){
0100         Precision volume = 0.;
0101         for(unsigned int i = 0 ; i < fCoaxialConesStructVector.size() ; i++)
0102           volume += fCoaxialConesStructVector[i].Capacity();
0103         return volume;
0104       }
0105   */
0106 
0107   /*
0108     void Print(){
0109       std::cout << "TotalNum Of Sections : " << fCoaxialConesStructVector.size() << std::endl;
0110       for(int i = 0 ; i < fCoaxialConesStructVector.size() ; i++){
0111         fCoaxialConesStructVector[i].Print();
0112       }
0113     }
0114   */
0115   VECCORE_ATT_HOST_DEVICE
0116   Precision Capacity()
0117   {
0118     Precision volume = 0.;
0119     for (unsigned int i = 0; i < fSections.size(); i++)
0120       volume += fSections[i].fCoaxialCones->Capacity();
0121     return volume;
0122   }
0123 #if (0)
0124   Precision SurfaceArea()
0125   {
0126     // Precision surfArea = 0.;
0127     // TODO : Logic to calculate the Surface Area
0128 
0129     return (ConicalSurfaceArea() + SurfaceAreaOfZPlanes());
0130   }
0131 #endif
0132   VECCORE_ATT_HOST_DEVICE
0133   int GetSectionIndex(Precision zposition) const
0134   {
0135     // TODO: consider binary search
0136     // TODO: consider making these comparisons tolerant in case we need it
0137     if (zposition < fZs[0]) return -1;
0138     for (unsigned int i = 0; i < fZs.size() - 1; ++i) {
0139       if (zposition >= fZs[i] && zposition <= fZs[i + 1]) return i;
0140     }
0141     return -2;
0142   }
0143 
0144   VECCORE_ATT_HOST_DEVICE
0145   int GetNSections() const { return fSections.size(); }
0146 
0147   VECCORE_ATT_HOST_DEVICE
0148   GenericPolyconeSection const &GetSection(Precision zposition) const
0149   {
0150     // TODO: consider binary search
0151     int i = GetSectionIndex(zposition);
0152     return fSections[i];
0153   }
0154 
0155   VECCORE_ATT_HOST_DEVICE
0156   // GetSection if index is known
0157   GenericPolyconeSection const &GetSection(int index) const { return fSections[index]; }
0158 
0159   VECCORE_ATT_HOST_DEVICE
0160   Precision GetZAtPlane(unsigned int index) const
0161   {
0162     assert(index <= fSections.size());
0163     return fZs[index];
0164   }
0165 };
0166 
0167 } // namespace VECGEOM_IMPL_NAMESPACE
0168 } // namespace vecgeom
0169 
0170 #endif