1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // $Id: HmaxForProtonModule.cc 2633 2006-03-28 09:13:43Z thea $ |
---|
3 | // Naumov Dmitry created Jul, 4 2004 |
---|
4 | |
---|
5 | #include "HmaxForProtonModule.hh" |
---|
6 | #include "RecoRootEvent.hh" |
---|
7 | #include "RecoEvent.hh" |
---|
8 | #include "RecoPixelData.hh" |
---|
9 | #include "utils.hh" |
---|
10 | #include "Atmosphere.hh" |
---|
11 | |
---|
12 | using namespace sou; |
---|
13 | using namespace TMath; |
---|
14 | |
---|
15 | ClassImp(HmaxForProtonModule) |
---|
16 | HmaxForProtonModule* tmpHMaxProtonPointer = NULL; |
---|
17 | |
---|
18 | //_____________________________________________________________________________ |
---|
19 | float HmaxForProton_depthToAltitude(float h) { |
---|
20 | // Root of this function is the Altitude along the direction Theta which correspond to GIL estimation of the |
---|
21 | // Shower Maximum |
---|
22 | Double_t Theta = tmpHMaxProtonPointer->GetTheta(); |
---|
23 | return Atmosphere::Get()->Depth(h*km,Theta) - tmpHMaxProtonPointer->XMaxEstimate(); |
---|
24 | } |
---|
25 | |
---|
26 | //_____________________________________________________________________________ |
---|
27 | Double_t HmaxForProtonModule::XMaxEstimate() { |
---|
28 | Double_t t0 = 37*g/cm2; |
---|
29 | return t0*(1.7+0.76*TMath::Log(fEnergy/0.81e8)); |
---|
30 | } |
---|
31 | |
---|
32 | //_____________________________________________________________________________ |
---|
33 | HmaxForProtonModule::HmaxForProtonModule() : RecoModule("HmaxForProton") { |
---|
34 | // ctor |
---|
35 | fUseTrueAngles = kFALSE; |
---|
36 | tmpHMaxProtonPointer = this; |
---|
37 | } |
---|
38 | |
---|
39 | //_____________________________________________________________________________ |
---|
40 | HmaxForProtonModule::~HmaxForProtonModule() { |
---|
41 | // dtor |
---|
42 | } |
---|
43 | |
---|
44 | //_____________________________________________________________________________ |
---|
45 | Bool_t HmaxForProtonModule::Init() { |
---|
46 | Msg(EsafMsg::Info) << "Initializing " << MsgDispatch; |
---|
47 | fUseTrueAngles = (Int_t)Conf()->GetNum("HmaxForProtonModule.fUseTrueAngles"); |
---|
48 | return kTRUE; |
---|
49 | } |
---|
50 | |
---|
51 | //_____________________________________________________________________________ |
---|
52 | Bool_t HmaxForProtonModule::PreProcess() { |
---|
53 | return kTRUE; |
---|
54 | } |
---|
55 | |
---|
56 | //_____________________________________________________________________________ |
---|
57 | Bool_t HmaxForProtonModule::Process(RecoEvent *ev) { |
---|
58 | const RecoModuleData *td = ev->GetModuleData("TrackDirection"); |
---|
59 | if ( td == NULL ) td = ev->GetModuleData("TrackDirection2"); // try to get TrackDirection2 |
---|
60 | if (fUseTrueAngles) { |
---|
61 | fTheta = ev->GetHeader().GetTrueTheta(); |
---|
62 | fPhi = ev->GetHeader().GetTruePhi(); |
---|
63 | } |
---|
64 | else { |
---|
65 | if ( td == NULL ) Msg(EsafMsg::Panic) << "None of TrackDirectionModule and TrackDirectionModule2 is not found." << MsgDispatch; |
---|
66 | fTheta = td->GetDouble("Theta"); |
---|
67 | fPhi = td->GetDouble("Phi"); |
---|
68 | if(IsNaN(fTheta) || IsNaN(fPhi)) return kFALSE; |
---|
69 | } |
---|
70 | |
---|
71 | const RecoModuleData *en = ev->GetModuleData("Energy"); |
---|
72 | fEnergy = 1.e20; // default guess |
---|
73 | if ( en != NULL ) |
---|
74 | fEnergy = en->GetDouble("Energy"); |
---|
75 | Msg(EsafMsg::Debug) << "Processing Theta " << fTheta*RadToDeg() << " deg, Phi " << fPhi*RadToDeg() << " deg" << MsgDispatch; |
---|
76 | |
---|
77 | if (fTheta*RadToDeg() < 0 || fTheta*RadToDeg() > 92) return kFALSE; |
---|
78 | |
---|
79 | Float_t t1(0),t2(100); |
---|
80 | Float_t (*f)(float)= &HmaxForProton_depthToAltitude; |
---|
81 | zbrac(f,&t1,&t2); |
---|
82 | fAltitude = rtbis(f,t1,t2,0.01)*km; |
---|
83 | MyData()->Add("Altitude",fAltitude); |
---|
84 | Msg(EsafMsg::Debug) << "Hmax = " << fAltitude/km << " km " << MsgDispatch; |
---|
85 | |
---|
86 | return kTRUE; |
---|
87 | } |
---|
88 | |
---|
89 | //_____________________________________________________________________________ |
---|
90 | Bool_t HmaxForProtonModule::PostProcess() { |
---|
91 | return kTRUE; |
---|
92 | } |
---|
93 | |
---|
94 | //_____________________________________________________________________________ |
---|
95 | Bool_t HmaxForProtonModule::SaveRootData(RecoRootEvent *fRecoRootEvent) { |
---|
96 | fRecoRootEvent->GetRecoHmaxForProton().SetHmax(fAltitude); |
---|
97 | fRecoRootEvent->GetRecoHmaxForProton().SetQuality(1); |
---|
98 | Double_t HmaxError = fRecoRootEvent->GetTruth().GetHmax() - fAltitude; |
---|
99 | fRecoRootEvent->GetRecoHmaxForProton().SetErrorHmax(HmaxError); |
---|
100 | return kTRUE; |
---|
101 | } |
---|
102 | //_____________________________________________________________________________ |
---|
103 | Bool_t HmaxForProtonModule::Done() { |
---|
104 | Msg(EsafMsg::Info) << "Completed" << MsgDispatch; |
---|
105 | return kTRUE; |
---|
106 | } |
---|
107 | |
---|
108 | //______________________________________________________________________________ |
---|
109 | void HmaxForProtonModule::UserMemoryClean() { |
---|
110 | |
---|
111 | } |
---|
112 | |
---|
113 | //______________________________________________________________________________ |
---|
114 | void HmaxForProtonModule::TmpMemoryClean() { |
---|
115 | |
---|
116 | } |
---|