"MarlinReco"  1.16.0
tkhitbank.h
1 
2 #ifndef Tk_Hit_Bank_h
3 #define Tk_Hit_Bank_h 1
4 
5 #include<vector>
6 #include<cfortran.h>
7 #include<map>
8 #include<string>
9 //stl exception handler
10 #include<stdexcept>
11 
13 {
14 
15  public:
16  Tk_Hit_Bank();
17  ~Tk_Hit_Bank();
18  void clear();
19  void add_hit(float, float, float, float, int, int, int, int, int, float, float);
20  //void add_hit(float, float, float, float, int, float, float, int);
21  // void remove_hit(int);
22  void setX(float X, int hit){hit_bank[hit].x = X;};
23  void setY(float Y, int hit){hit_bank[hit].y = Y;};
24  void setZ(float Z, int hit){hit_bank[hit].z = Z;};
25  void setEnergy(float E, int hit){hit_bank[hit].energy = E;};
26  void setSubdetectorID(int SubID, int hit){hit_bank[hit].subdetector_ID = SubID;};
27  void setTrackID(int TrkID, int hit){hit_bank[hit].track_ID = TrkID;};
28  void setPntToFirstExclusion(int NEx, int hit){hit_bank[hit].pointer_to_first_exclusion = NEx;};
29  void setNExclusion(int PntToEx, int hit){hit_bank[hit].number_of_exclusions = PntToEx;};
30  void setResolutionCode(int ResC, int hit){hit_bank[hit].resolution_code = ResC;};
31  void setResolution1(float Res1, int hit){hit_bank[hit].resolution_1 = Res1;};
32  void setResolution2(float Res2, int hit){hit_bank[hit].resolution_2 = Res2;};
33 
34 
35 
36  int size(){return hit_bank.size();};
37  float getX(int i){return hit_bank[i].x;};
38  float getY(int i){return hit_bank[i].y;};
39  float getZ(int i){return hit_bank[i].z;};
40  float getEnergy(int i){return hit_bank[i].energy;};
41  int getSubdetectorID(int i){return hit_bank[i].subdetector_ID;};
42  int getTrackID(int i){return hit_bank[i].track_ID;};
43  int getPntToFirstExclusion(int i){return hit_bank[i].pointer_to_first_exclusion;};
44  int getNExclusion(int i){return hit_bank[i].number_of_exclusions;};
45  int getResolutionCode(int i){return hit_bank[i].resolution_code;};
46  float getResolution1(int i){return hit_bank[i].resolution_1;};
47  float getResolution2(int i){return hit_bank[i].resolution_2;};
48 
49 
50  // omega>0 ? +1 : -1;
51 
52  // These methods have no protection against using the wrong key e.g. tpc instead of TPC ...
53 
54  void setFirstHitIndex(std::string subdet)
55  { if(firstHitEntry.find(subdet) == firstHitEntry.end()) {firstHitEntry[subdet]=hit_bank.size();}
56  else { throw std::runtime_error("setFirstHitIndex:subdetector does not exit") ;}};
57 
58  unsigned int getFirstHitIndex(std::string subdet)
59  { if(firstHitEntry.find(subdet) != firstHitEntry.end()) {return firstHitEntry[subdet];}
60  else { throw std::runtime_error("getFirstHitIndex:subdetector does not exit") ;}};
61 
62  void setLastHitIndex(std::string subdet)
63  { if(lastHitEntry.find(subdet) == lastHitEntry.end()) {lastHitEntry[subdet]=hit_bank.size()-1;}
64  else { throw std::runtime_error("setLastHitIndex:subdetector does not exit") ;}};
65 
66  unsigned int getLastHitIndex(std::string subdet)
67  { if(lastHitEntry.find(subdet) != lastHitEntry.end()) {return lastHitEntry[subdet];}
68  else { throw std::runtime_error("getLastHitIndex:subdetector does not exit") ;}};
69 
70  int getNumOfSubDetHits(std::string subdet)
71  { if(firstHitEntry.find(subdet) == firstHitEntry.end()) {return 0;}
72  else {return 1 + lastHitEntry[subdet] - firstHitEntry[subdet];}};
73 
74 
75  private:
76 
77 struct tk_hit
78 {
79  float x;
80  float y;
81  float z;
82  float energy;
83  int subdetector_ID;
84  int track_ID;
85  int pointer_to_first_exclusion;
86  int number_of_exclusions;
87  int resolution_code;
88  float resolution_1;
89  float resolution_2;
90 
91 };
92 
93  std::vector <tk_hit> hit_bank;
94 
95  // stores the postion of the first hit from a subdetector
96  std::map <const std::string , unsigned int> firstHitEntry;
97  // stores the postion of the last hit from a subdetector
98  std::map <const std::string , unsigned int> lastHitEntry;
99 
100 };
101 
102 // Global pointer to the Tk_Hit_Bank structure which is defined in Tk_Hit_Bank.cc
103 extern Tk_Hit_Bank * TkHitBank;
104 
105 
106 #endif
Definition: tkhitbank.h:12