source: JEM-EUSO/esaf_cc_at_lal/packages/simulation/detector/optics/src/TestOpticalAdaptor.cc @ 114

Last change on this file since 114 was 114, checked in by moretto, 11 years ago

actual version of ESAF at CCin2p3

File size: 2.8 KB
Line 
1//
2// $Id: TestOpticalAdaptor.cc 2835 2009-07-16 03:22:42Z biktem $
3//
4#include "TRotation.h"
5#include "TestOpticalAdaptor.hh"
6#include "OpticsFactory.hh"
7#include "Photomultiplier.hh"
8#include "EEvent.hh"
9#include "EConst.hh"
10
11using namespace sou;
12using namespace TMath;
13using namespace EConst;
14
15//#define DEBUG
16
17ClassImp(TestOpticalAdaptor)
18
19//______________________________________________________________________________
20TestOpticalAdaptor::TestOpticalAdaptor() {
21    //
22    // Contructor
23    //
24
25    fReflectivity = Conf()->GetNum("TestOpticalAdaptor.fCathode.reflectivity");
26
27    fSide=Conf()->GetNum("TestOpticalAdaptor.fSide")*mm;
28    fHeight=Conf()->GetNum("TestOpticalAdaptor.fHeight")*mm;
29
30}
31
32//______________________________________________________________________________
33Photon *TestOpticalAdaptor::Transport(Photon *p) const {
34    vector<EVector> ips=intPoints(p);
35
36    // find the hit position
37    int hitFace;
38    for(hitFace=0; hitFace<6; hitFace++)
39        if(isInside(ips[hitFace], hitFace)) break;
40    if(hitFace==6) {//throw runtime_error("TestOpticalAdaptor: shouldn't happen. no face hit");
41        cerr<<"warning: photon on OpticalAdaptor edge. Killed"<<endl;
42        return 0;
43    }
44
45#ifdef DEBUG
46    cout<<"hit face: "<<hitFace<<endl;
47    cout<<"hit position (local): "<<ips[hitFace]<<endl;
48#endif /* DEBUG */
49
50    EVector dummy=p->pos;        // previous photon position
51    p->pos=goGlobal(ips[hitFace]);
52    p->pos+=fPos;                    // new photon position
53    p->time+=(p->pos-dummy).Mag()/Clight();
54
55#ifdef DEBUG
56    cout<<"hit position (global): "<<p->pos<<endl;
57#endif /* DEBUG */
58
59    if(hitFace==BOTTOM) {
60        // Cathode reflectivity
61        if(isReflectedByCathode()) {
62            EVector ldir=goLocal(p->dir);
63            ldir[Z] *= -1;
64            p->dir=goGlobal(ldir);
65            p->MChit=false;
66            p->hit=false;
67            return Transport(p);
68        }
69
70        // Add photon to PMT
71        if(!pmt->Pmt()->Add(*p)) {
72#ifdef DEBUG
73            cout<<"photon rejected by PMT"<<endl;
74#endif /* DEBUG */
75        } else {
76#ifdef DEBUG
77            cout<<"photon accepted by PMT"<<endl;
78#endif /* DEBUG */
79        }
80
81        return 0;
82    }
83
84    if(hitFace==TOP) return p;
85#ifdef DEBUG
86    cout<<"photon hit on OA side"<<endl;
87#endif /* DEBUG */
88
89    const PmtGeometry *nearest=pmt->Nearest((OAFace)hitFace);
90    if(!nearest) {
91        // photon hit on PMT wall
92#ifdef DEBUG
93        cout<<"photon destroyed, no nearest"<<endl;
94#endif /* DEBUG */
95        // photon absorbed
96        return 0;
97    }
98#ifdef DEBUG
99    cout<<"cur_PMT_Id: "<<pmt->Pmt()->Id()<<endl;
100    cout<<"near_PMT_Id: "<<nearest->Pmt()->Id()<<endl;
101#endif
102    OpticalAdaptor *oa=nearest->GetOA();
103    // photon doesn't need to be propagated from one OA side to the
104    // other one because unlike PMTs they are stuck together
105    p=oa->Transport(p);
106    delete oa;
107
108        return p;
109}
110
Note: See TracBrowser for help on using the repository browser.