File: GenericPolyconeStruct.h

package info (click to toggle)
vecgeom 1.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 23,928 kB
  • sloc: cpp: 88,717; ansic: 6,894; python: 1,035; sh: 582; sql: 538; makefile: 29
file content (170 lines) | stat: -rw-r--r-- 5,328 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/// @file GenericPolyconeStruct.h
/// @author Raman Sehgal (raman.sehgal@cern.ch)

#ifndef VECGEOM_VOLUMES_GENERICPOLYCONESTRUCT_H_
#define VECGEOM_VOLUMES_GENERICPOLYCONESTRUCT_H_
#include "VecGeom/base/Global.h"
#include "VecGeom/base/Vector3D.h"
#include "VecGeom/base/Vector.h"
#include "VecGeom/volumes/CoaxialConesStruct.h"
#include "VecGeom/volumes/GenericPolyconeSection.h"
namespace vecgeom {

// VECGEOM_DEVICE_DECLARE_CONV_TEMPLATE(struct, GenericPolyconeStruct, typename);

inline namespace VECGEOM_IMPL_NAMESPACE {

template <typename T = double>
struct GenericPolyconeStruct {

  // Data members to store
  Vector<Vector<T>> fVectOfRmin1Vect;
  Vector<Vector<T>> fVectOfRmax1Vect;
  Vector<Vector<T>> fVectOfRmin2Vect;
  Vector<Vector<T>> fVectOfRmax2Vect;
  Vector<T> fVectOfDz;
  T fSPhi;
  T fDPhi;

  VECCORE_ATT_HOST_DEVICE
  GenericPolyconeStruct() {}

  VECCORE_ATT_HOST_DEVICE
  // Special function NOT to be exposed to user, and will be used by constructor
  void Set(Vector<Vector<Precision>> vectOfRmin1Vect, Vector<Vector<Precision>> vectOfRmax1Vect,
           Vector<Vector<Precision>> vectOfRmin2Vect, Vector<Vector<Precision>> vectOfRmax2Vect, Vector<Precision> zS,
           Precision sPhi, Precision dPhi)
  {
    fSPhi = sPhi;
    fDPhi = dPhi;
    for (unsigned int i = 0; i < vectOfRmin1Vect.size(); i++) {

      // Creating and filling the GenericPolyconeSection
      GenericPolyconeSection section;
      // Precision shift                             = zS[i] + 0.5 * (zS[i + 1] - zS[i]);
      Precision dz                                = 0.5 * (zS[i + 1] - zS[i]);
      Precision shift                             = zS[i] + dz;
      CoaxialConesStruct<Precision> *coaxialCones = new CoaxialConesStruct<Precision>(
          vectOfRmin1Vect[i], vectOfRmax1Vect[i], vectOfRmin2Vect[i], vectOfRmax2Vect[i], dz, fSPhi, fDPhi);
      fCubicVolume += coaxialCones->Capacity();
      section.fShift        = shift;
      section.fCoaxialCones = coaxialCones;

      // Inserting the section just created above
      fSections.push_back(section);
    }
    fZs          = zS;
    fCubicVolume = Capacity();
  }

  // Vector of GenericPolyconeSection
  Vector<GenericPolyconeSection> fSections;

  /* Variables to be Cached
   * 1) All the Z Planes fZs
   */

  Vector<Precision> fZs;

  T fSurfaceArea; // area of the surface
  T fCubicVolume; // volume

  // Some Helper function to calculate SurfaceArea
#if (0)
  Precision ConicalSurfaceArea()
  {
    Precision conicalSurfaceArea = 0.;
    for (unsigned int i = 0; i < fSections.size(); i++) {
      conicalSurfaceArea += fSections[i].fCoaxialCones->ConicalSurfaceArea();
    }
    return conicalSurfaceArea;
  }

  Precision SurfaceAreaOfZPlanes()
  {
    Precision surfaceAreaOfZPlanes = 0.;
    if (fSections.size() == 1) {
      return fSections[0].fCoaxialCones->SurfaceAreaOfZPlanes();
    } else if (fSections.size() > 1) {
      CoaxialConesStruct<Precision> *firstSectionCones = fSections[0].fCoaxialCones;
      CoaxialConesStruct<Precision> *lastSectionCones  = fSections[fSections.size() - 1].fCoaxialCones;
      return (firstSectionCones->TotalSurfaceAreaOfLowerZPlanes() + lastSectionCones->TotalSurfaceAreaOfUpperZPlanes());
    }
    /*for(unsigned int i = 0 ; i < fSections.size() ; i++){
      CoaxialConesStruct<Precision> *CoaxialCones = fSections[i].fCoaxialCones;
    }*/
  }
#endif
  /*
    Precision Capacity(){
        Precision volume = 0.;
        for(unsigned int i = 0 ; i < fCoaxialConesStructVector.size() ; i++)
          volume += fCoaxialConesStructVector[i].Capacity();
        return volume;
      }
  */

  /*
    void Print(){
      std::cout << "TotalNum Of Sections : " << fCoaxialConesStructVector.size() << std::endl;
      for(int i = 0 ; i < fCoaxialConesStructVector.size() ; i++){
        fCoaxialConesStructVector[i].Print();
      }
    }
  */
  VECCORE_ATT_HOST_DEVICE
  Precision Capacity()
  {
    Precision volume = 0.;
    for (unsigned int i = 0; i < fSections.size(); i++)
      volume += fSections[i].fCoaxialCones->Capacity();
    return volume;
  }
#if (0)
  Precision SurfaceArea()
  {
    // Precision surfArea = 0.;
    // TODO : Logic to calculate the Surface Area

    return (ConicalSurfaceArea() + SurfaceAreaOfZPlanes());
  }
#endif
  VECCORE_ATT_HOST_DEVICE
  int GetSectionIndex(Precision zposition) const
  {
    // TODO: consider binary search
    // TODO: consider making these comparisons tolerant in case we need it
    if (zposition < fZs[0]) return -1;
    for (unsigned int i = 0; i < fZs.size() - 1; ++i) {
      if (zposition >= fZs[i] && zposition <= fZs[i + 1]) return i;
    }
    return -2;
  }

  VECCORE_ATT_HOST_DEVICE
  int GetNSections() const { return fSections.size(); }

  VECCORE_ATT_HOST_DEVICE
  GenericPolyconeSection const &GetSection(Precision zposition) const
  {
    // TODO: consider binary search
    int i = GetSectionIndex(zposition);
    return fSections[i];
  }

  VECCORE_ATT_HOST_DEVICE
  // GetSection if index is known
  GenericPolyconeSection const &GetSection(int index) const { return fSections[index]; }

  VECCORE_ATT_HOST_DEVICE
  Precision GetZAtPlane(unsigned int index) const
  {
    assert(index <= fSections.size());
    return fZs[index];
  }
};

} // namespace VECGEOM_IMPL_NAMESPACE
} // namespace vecgeom

#endif