1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // $Id: EDetectorPhotonAdder.cc 3007 2012-01-11 10:06:56Z fenu $ |
---|
3 | // Alessandro Thea created Oct, 24 2003 |
---|
4 | |
---|
5 | #include "EDetectorPhotonAdder.hh" |
---|
6 | #include "EEvent.hh" |
---|
7 | #include "Etypes.hh" |
---|
8 | #include "Photon.hh" |
---|
9 | #include "PmtSignal.hh" |
---|
10 | #include "ParentPhoton.hh" |
---|
11 | |
---|
12 | #include "EDetector.hh" |
---|
13 | #include "EDetPhoton.hh" |
---|
14 | |
---|
15 | ClassImp(EDetectorPhotonAdder) |
---|
16 | |
---|
17 | //______________________________________________________________________________ |
---|
18 | EDetectorPhotonAdder::EDetectorPhotonAdder(Photon* ph, PmtSignal* s, Bool_t newph) |
---|
19 | : EFiller("EDetector") { |
---|
20 | // ctor |
---|
21 | |
---|
22 | fPhoton = ph; |
---|
23 | fSignal = s; |
---|
24 | fNewPh = newph; |
---|
25 | fPhotonHistory.Set(0); |
---|
26 | } |
---|
27 | |
---|
28 | //______________________________________________________________________________ |
---|
29 | EDetectorPhotonAdder::EDetectorPhotonAdder(TArrayI arr) |
---|
30 | : EFiller("EDetector") { |
---|
31 | // ctor |
---|
32 | |
---|
33 | fPhoton = 0; |
---|
34 | fSignal = 0; |
---|
35 | fNewPh = kFALSE; |
---|
36 | fPhotonHistory = arr; |
---|
37 | } |
---|
38 | |
---|
39 | //______________________________________________________________________________ |
---|
40 | EDetectorPhotonAdder::~EDetectorPhotonAdder() { |
---|
41 | // dtor |
---|
42 | |
---|
43 | } |
---|
44 | |
---|
45 | //______________________________________________________________________________ |
---|
46 | void EDetectorPhotonAdder::Fill( EFillable* f ) { |
---|
47 | // filler |
---|
48 | |
---|
49 | EDetector *det; |
---|
50 | if ( !(det = dynamic_cast<EDetector*>(f)) ) { |
---|
51 | MsgForm(EsafMsg::Warning,"Fill(): f is not an EDetector* "); |
---|
52 | return; |
---|
53 | } |
---|
54 | |
---|
55 | // increase the number of photons in the detector status |
---|
56 | EDetStatus *status = &(det->fStatus); |
---|
57 | |
---|
58 | // fill the photons history |
---|
59 | if ( fPhotonHistory.GetSize()!=0 ) { |
---|
60 | status->fPhotonHistory = fPhotonHistory; |
---|
61 | return; |
---|
62 | } |
---|
63 | |
---|
64 | if ( !fPhoton ) return; |
---|
65 | |
---|
66 | if ( fNewPh ) { |
---|
67 | status->fNumPhotons++; |
---|
68 | |
---|
69 | // update the arrival time limits |
---|
70 | if ( fPhoton->time < det->fFirstTime ) |
---|
71 | det->fFirstTime = fPhoton->time; |
---|
72 | if ( fPhoton->time > det->fLastTime ) |
---|
73 | det->fLastTime = fPhoton->time; |
---|
74 | } |
---|
75 | |
---|
76 | // if photons are disabled return |
---|
77 | UInt_t mode = det->GetPhotonFillingMode(); |
---|
78 | Bool_t addPhoton; |
---|
79 | switch(mode) { |
---|
80 | case EDetector::kAllPhotons: |
---|
81 | addPhoton = fNewPh; |
---|
82 | break; |
---|
83 | case EDetector::kMadeSignalOnly: |
---|
84 | if (!fSignal) return; |
---|
85 | addPhoton = kTRUE; |
---|
86 | break; |
---|
87 | default: |
---|
88 | addPhoton = kFALSE; |
---|
89 | return; |
---|
90 | break; |
---|
91 | } |
---|
92 | |
---|
93 | |
---|
94 | if ( addPhoton ) |
---|
95 | // if photons filling is enabled add a new ph |
---|
96 | new ( (*(det->fPhotons))[det->fNumPhotons++] ) EDetPhoton(); |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | EDetPhoton& p = *(EDetPhoton*)(*(det->fPhotons))[det->fNumPhotons-1]; |
---|
101 | |
---|
102 | // photon params at the pupil |
---|
103 | if ( addPhoton ) { |
---|
104 | p.fType = fPhoton->parent->Type(); // type of photon |
---|
105 | p.fStatusBits = 0; // flag to know if phtoton has generated signal |
---|
106 | p.fShowerPosX = fPhoton->parent->ShowerPos()[X]; // X position of origin in shower |
---|
107 | p.fShowerPosY = fPhoton->parent->ShowerPos()[Y]; // Y position of origin in shower |
---|
108 | p.fShowerPosZ = fPhoton->parent->ShowerPos()[Z]; // Z position of origin in shower |
---|
109 | p.fTheta = fPhoton->dir.Theta(); // photon theta direction in Euso detector |
---|
110 | p.fAge =fPhoton->parent->GetShowerAge(); |
---|
111 | p.fPhi = fPhoton->dir.Phi(); // " phi " " " " |
---|
112 | p.fLambda = fPhoton->wl; // photon wavelength |
---|
113 | p.fTime = fPhoton->time; // photon time (detection) |
---|
114 | |
---|
115 | p.fPosX = kHuge; // X position of hit in focal surface |
---|
116 | p.fPosY = kHuge; // Y position of hit in focal surface |
---|
117 | p.fPosZ = kHuge; // Z position of hit in focal surface |
---|
118 | p.fIdealFocalPosX = kHuge; // X position of hit in focal surface |
---|
119 | p.fIdealFocalPosY = kHuge; // Y position of hit in focal surface |
---|
120 | p.fIdealFocalPosZ = kHuge; // Z position of hit in focal surface |
---|
121 | |
---|
122 | p.fSignalId = -1; // id of pmt signal |
---|
123 | p.fCharge = -1.e-12; // charge in C |
---|
124 | p.fIPeak = -1.e-6; // peak current in Amps |
---|
125 | |
---|
126 | p.fHistory = kNotInside; // code of the last position |
---|
127 | p.fFate = 0; // 0 until the photon is alive |
---|
128 | |
---|
129 | p.fMacroCell = 0; // macrocell id (starts from 1) |
---|
130 | p.fFe = 0; // front end chip id (starts from 1) |
---|
131 | p.fXCell = -1; // macrocell X coordinate |
---|
132 | p.fYCell = -1; // macrocell Y coordinate |
---|
133 | |
---|
134 | p.fGtu = -1; // gtu reldetant for this photon |
---|
135 | p.fPixelUID = -1; // unique id of hit pixel |
---|
136 | } |
---|
137 | |
---|
138 | // impact point on focal plane |
---|
139 | p.fPosX = fPhoton->pos[X]; |
---|
140 | p.fPosY = fPhoton->pos[Y]; |
---|
141 | p.fPosZ = fPhoton->pos[Z]; |
---|
142 | p.fIdealFocalPosX = fPhoton->posOnIfs[X]; |
---|
143 | p.fIdealFocalPosY = fPhoton->posOnIfs[Y]; |
---|
144 | p.fIdealFocalPosZ = fPhoton->posOnIfs[Z]; |
---|
145 | |
---|
146 | if ( fPhoton->hitIfs ) p.SetCrossedIFS(); |
---|
147 | |
---|
148 | p.fHistory = fPhoton->history; |
---|
149 | p.fPixelUID = fPhoton->pixelUid; |
---|
150 | p.fFate = fPhoton->fate; |
---|
151 | |
---|
152 | // pmt response |
---|
153 | // if ( addPhoton && fSignal) { |
---|
154 | if ( fSignal) { |
---|
155 | p.SetMadeSignal(); |
---|
156 | |
---|
157 | p.fSignalId = fSignal->Id(); |
---|
158 | p.fCharge = fSignal->Charge(); |
---|
159 | p.fIPeak = fSignal->Current(fSignal->Time()); |
---|
160 | p.fSignalTime = fSignal->Time(); |
---|
161 | } |
---|
162 | } |
---|