LBNFDeDxMap.hh
Go to the documentation of this file.
1 #ifndef LBNFDEDXMAP_HH
2 #define LBNFDEDXMAP_HH
3 #include <fstream>
4 #include <map>
5 #include <vector>
6 #include <string>
7 #include <fstream>
8 #include <cmath>
9 #include "globals.hh"
10 #include "G4Step.hh"
11 
12 class LBNFDeDxCell {
13 
14  public:
15  bool keyedByZ;
16  int nEntries;
17  std::string G4Name; // not necessarily the full name
18  std::string MARSName; // not necessarily the full name
19  // provide
20  double zCenter; // all dimension in mm
21  double zWidth;
22  double rCenter;
23  double rWidth;
24  double phiCenter;
25  double phiWidth;
26  double eDep;
27  double eDepSq;
28 
29 };
31  public:
32  int tag;
33  int pid;
34  double length;
35  double rPre;
36  double zPre;
37  double rPost;
38  double zPost;
39  double eDep;
40  double eKin;
41 };
42 
43 class LBNFDeDxMap {
44 
45  public:
46 
47  explicit LBNFDeDxMap(const std::string &aName);
48  void fill(const G4Step* aStep);
49  void dumpASCII(const std::string &aDirectory, int nEvt);
50 
51  private:
53  double fPhiKeyFact;
54  double fZKeyFact;
55  double fRKeyFact;
56  unsigned int fPhiKeyMult;
57  unsigned int fNumPhiSlices;
58  std::map<unsigned int, LBNFDeDxCell> fMap;
59  std::vector<std::string> G4NamesInMapRTag;
60  std::vector<std::string> G4NamesInMapZTag;
61  std::vector<double> zStarts;
62  std::vector<double> zWidths;
63  std::vector<double> rStarts;
64  std::vector<double> rWidths;
65  std::vector<LBNFDeDxEntryInCell> fVectSpecialCell;
66 
67  void defineInnerCHornA();
68  void defineInnerCHornB();
69  unsigned int getKey(const G4Step* aStep);
70 
71  inline unsigned int getTagFromR(double r, double rStart, double rWidth, double f ) const {
72  size_t kPhi = static_cast<size_t>(f*fNumPhiSlices/(2.0*M_PI));
73  size_t iRC = static_cast<size_t>((r - rStart)/rWidth);
74  const double rc = rStart + iRC*rWidth;
75  unsigned int aKey = kPhi*fPhiKeyMult + static_cast<unsigned int>(fRKeyFact*rc);
76 // std::cerr << " getTagFromR, z = " << r
77 // << " params " << rStart << " / " << rWidth << " key " << aKey << std::endl;
78  return aKey;
79  }
80  inline unsigned int getTagFromZ(double z, double zStart, double zWidth, double f ) const {
81  size_t kPhi = static_cast<size_t>(f*fNumPhiSlices/(2.0*M_PI));
82  size_t iZC = static_cast<size_t>((z - zStart)/zWidth);
83  const double zc = zStart + iZC*zWidth;
84  unsigned int aKey = kPhi*fPhiKeyMult + static_cast<unsigned int>(fZKeyFact*zc);
85 // std::cerr << " getTagFromZ, z = " << z
86 // << " params " << zStart << " / " << zWidth << " key " << aKey << std::endl;
87  return aKey;
88  }
89 };
90 #endif
double fPhiKeyFact
Definition: LBNFDeDxMap.hh:53
std::string string
Definition: nybbler.cc:12
std::vector< std::string > G4NamesInMapZTag
Definition: LBNFDeDxMap.hh:60
std::vector< double > rStarts
Definition: LBNFDeDxMap.hh:63
double phiWidth
Definition: LBNFDeDxMap.hh:25
std::vector< LBNFDeDxEntryInCell > fVectSpecialCell
Definition: LBNFDeDxMap.hh:65
double rCenter
Definition: LBNFDeDxMap.hh:22
double zCenter
Definition: LBNFDeDxMap.hh:20
unsigned int fNumPhiSlices
Definition: LBNFDeDxMap.hh:57
std::vector< double > rWidths
Definition: LBNFDeDxMap.hh:64
unsigned int getTagFromZ(double z, double zStart, double zWidth, double f) const
Definition: LBNFDeDxMap.hh:80
double fRKeyFact
Definition: LBNFDeDxMap.hh:55
std::vector< double > zStarts
Definition: LBNFDeDxMap.hh:61
double zWidth
Definition: LBNFDeDxMap.hh:21
std::string MARSName
Definition: LBNFDeDxMap.hh:18
std::vector< double > zWidths
Definition: LBNFDeDxMap.hh:62
double z
std::string fName
Definition: LBNFDeDxMap.hh:52
double fZKeyFact
Definition: LBNFDeDxMap.hh:54
std::map< unsigned int, LBNFDeDxCell > fMap
Definition: LBNFDeDxMap.hh:58
double phiCenter
Definition: LBNFDeDxMap.hh:24
double eDepSq
Definition: LBNFDeDxMap.hh:27
def fill(s)
Definition: translator.py:93
double rWidth
Definition: LBNFDeDxMap.hh:23
std::vector< std::string > G4NamesInMapRTag
Definition: LBNFDeDxMap.hh:59
std::string G4Name
Definition: LBNFDeDxMap.hh:17
unsigned int getTagFromR(double r, double rStart, double rWidth, double f) const
Definition: LBNFDeDxMap.hh:71
unsigned int fPhiKeyMult
Definition: LBNFDeDxMap.hh:56