1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | ! Author(s): Harald Kornmayer 1/2001
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2002
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | //////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // MHMcCollectionAreaCalc
|
---|
29 | //
|
---|
30 | // Remark: The initialization is mainly done in the ReInit function.
|
---|
31 | // Please make sure, that you don't use MReadTree when processing
|
---|
32 | // a file. Use a 'ReInit'-calling task like MReadMarsFile
|
---|
33 | //
|
---|
34 | //////////////////////////////////////////////////////////////////////////////
|
---|
35 |
|
---|
36 | #include "MMcCollectionAreaCalc.h"
|
---|
37 |
|
---|
38 | #include "MParList.h"
|
---|
39 |
|
---|
40 | #include "MLog.h"
|
---|
41 | #include "MLogManip.h"
|
---|
42 |
|
---|
43 | #include "MMcEvt.hxx"
|
---|
44 | #include "MMcTrig.hxx"
|
---|
45 | #include "MMcRunHeader.hxx"
|
---|
46 | #include "MMcCorsikaRunHeader.h"
|
---|
47 |
|
---|
48 | #include "MHMcCollectionArea.h"
|
---|
49 |
|
---|
50 | ClassImp(MMcCollectionAreaCalc);
|
---|
51 |
|
---|
52 | using namespace std;
|
---|
53 |
|
---|
54 | MMcCollectionAreaCalc::MMcCollectionAreaCalc(const char *input,
|
---|
55 | const char *name, const char *title)
|
---|
56 | {
|
---|
57 | fName = name ? name : "MMcCollectionAreaCalc";
|
---|
58 | fTitle = title ? title : "Task to calculate the collection area";
|
---|
59 |
|
---|
60 | fObjName = input ? input : "MMcTrig";
|
---|
61 | AddToBranchList(Form("%s.fNumFirstLevel", input));
|
---|
62 |
|
---|
63 | AddToBranchList("MMcEvt.fEnergy");
|
---|
64 | AddToBranchList("MMcEvt.fImpact");
|
---|
65 | }
|
---|
66 |
|
---|
67 | Int_t MMcCollectionAreaCalc::PreProcess (MParList *pList)
|
---|
68 | {
|
---|
69 | // connect the raw data with this task
|
---|
70 |
|
---|
71 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
|
---|
72 | if (!fMcEvt)
|
---|
73 | {
|
---|
74 | *fLog << err << dbginf << "MMcEvt not found... exit." << endl;
|
---|
75 | return kFALSE;
|
---|
76 | }
|
---|
77 |
|
---|
78 | fCollArea = (MHMcCollectionArea*)pList->FindCreateObj("MHMcCollectionArea");
|
---|
79 | if (!fCollArea)
|
---|
80 | return kFALSE;
|
---|
81 |
|
---|
82 | fTheta = -1;
|
---|
83 | fEmin = -1;
|
---|
84 | fEmax = -1;
|
---|
85 | fSlope = 0;
|
---|
86 | fTotalNumSimulatedShowers = 0;
|
---|
87 | fCorsikaVersion = 0;
|
---|
88 | fAllEvtsTriggered = kFALSE;
|
---|
89 |
|
---|
90 | return kTRUE;
|
---|
91 | }
|
---|
92 |
|
---|
93 | Bool_t MMcCollectionAreaCalc::ReInit(MParList *plist)
|
---|
94 | {
|
---|
95 | MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
|
---|
96 | if (!runheader)
|
---|
97 | {
|
---|
98 | *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl;
|
---|
99 | return kFALSE;
|
---|
100 | }
|
---|
101 |
|
---|
102 | MMcCorsikaRunHeader *corrunheader = (MMcCorsikaRunHeader*)plist->FindObject("MMcCorsikaRunHeader");
|
---|
103 | if (!corrunheader)
|
---|
104 | {
|
---|
105 | *fLog << err << dbginf << "Error - MMcCorsikaRunHeader not found... exit." << endl;
|
---|
106 | return kFALSE;
|
---|
107 | }
|
---|
108 |
|
---|
109 | fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers();
|
---|
110 |
|
---|
111 | *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl;
|
---|
112 |
|
---|
113 | if (fTheta>=0 && fTheta!=runheader->GetTelesTheta())
|
---|
114 | {
|
---|
115 | *fLog << warn << dbginf << "Warning - Read files have different TelesTheta (";
|
---|
116 | *fLog << fTheta << ", " << runheader->GetTelesTheta() << ")..." << endl;
|
---|
117 | }
|
---|
118 |
|
---|
119 | fTheta = runheader->GetTelesTheta();
|
---|
120 |
|
---|
121 | if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
|
---|
122 | *fLog << warn << dbginf << "Warning - Read files have different Corsika versions..." << endl;
|
---|
123 |
|
---|
124 | fCorsikaVersion = runheader->GetCorsikaVersion();
|
---|
125 |
|
---|
126 | if ( fEmin > 0 &&
|
---|
127 | (fEmin != corrunheader->GetELowLim() ||
|
---|
128 | fEmax != corrunheader->GetEUppLim() ||
|
---|
129 | fSlope != corrunheader->GetSlopeSpec()) )
|
---|
130 | *fLog << warn << dbginf << "Warning - Read files have different energy distribution..." << endl;
|
---|
131 |
|
---|
132 | fEmin = corrunheader->GetELowLim();
|
---|
133 | fEmax = corrunheader->GetEUppLim();
|
---|
134 | fSlope = corrunheader->GetSlopeSpec();
|
---|
135 |
|
---|
136 | fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();
|
---|
137 |
|
---|
138 | *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
|
---|
139 |
|
---|
140 | if (fAllEvtsTriggered)
|
---|
141 | return kTRUE;
|
---|
142 |
|
---|
143 | fMcTrig = (MMcTrig*)plist->FindObject(fObjName);
|
---|
144 | if (!fMcTrig)
|
---|
145 | {
|
---|
146 | *fLog << err << dbginf << fObjName << " [MMcTrig] not found... exit." << endl;
|
---|
147 | return kFALSE;
|
---|
148 | }
|
---|
149 |
|
---|
150 | return kTRUE;
|
---|
151 | }
|
---|
152 |
|
---|
153 | Int_t MMcCollectionAreaCalc::Process()
|
---|
154 | {
|
---|
155 | const Double_t energy = fMcEvt->GetEnergy();
|
---|
156 | const Double_t impact = fMcEvt->GetImpact()/100.;
|
---|
157 |
|
---|
158 | //
|
---|
159 | // This happens for camera files created with Camera 0.5
|
---|
160 | //
|
---|
161 | if (TMath::IsNaN(impact))
|
---|
162 | {
|
---|
163 | *fLog << err << dbginf << "ERROR - Impact=NaN (Not a number)... abort." << endl;
|
---|
164 | return kERROR;
|
---|
165 | }
|
---|
166 |
|
---|
167 | if (!fAllEvtsTriggered)
|
---|
168 | {
|
---|
169 | fCollArea->FillAll(energy, impact);
|
---|
170 |
|
---|
171 | if (fMcTrig->GetFirstLevel() <= 0)
|
---|
172 | return kTRUE;
|
---|
173 | }
|
---|
174 |
|
---|
175 | fCollArea->FillSel(energy, impact);
|
---|
176 |
|
---|
177 | return kTRUE;
|
---|
178 | }
|
---|
179 |
|
---|
180 | Int_t MMcCollectionAreaCalc::PostProcess()
|
---|
181 | {
|
---|
182 | //
|
---|
183 | // do the calculation of the effectiv area
|
---|
184 | //
|
---|
185 | *fLog << inf << "Calculation Collection Area..." << endl;
|
---|
186 |
|
---|
187 | if (!fAllEvtsTriggered)
|
---|
188 | fCollArea->CalcEfficiency();
|
---|
189 | else
|
---|
190 | {
|
---|
191 | *fLog << inf << "Total number of showers: " << fTotalNumSimulatedShowers << endl;
|
---|
192 | fCollArea->CalcEfficiency(fTotalNumSimulatedShowers, fEmin, fEmax, fSlope);
|
---|
193 | }
|
---|
194 |
|
---|
195 | return kTRUE;
|
---|
196 | }
|
---|
197 |
|
---|