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 | MMcCollectionAreaCalc::MMcCollectionAreaCalc(const char *input,
|
---|
53 | const char *name, const char *title)
|
---|
54 | {
|
---|
55 | fName = name ? name : "MMcCollectionAreaCalc";
|
---|
56 | fTitle = title ? title : "Task to calculate the collection area";
|
---|
57 |
|
---|
58 | fObjName = input ? input : "MMcTrig";
|
---|
59 | AddToBranchList(Form("%s.fNumFirstLevel", input));
|
---|
60 |
|
---|
61 | AddToBranchList("MMcEvt.fEnergy");
|
---|
62 | AddToBranchList("MMcEvt.fImpact");
|
---|
63 | }
|
---|
64 |
|
---|
65 | Bool_t MMcCollectionAreaCalc::PreProcess (MParList *pList)
|
---|
66 | {
|
---|
67 | // connect the raw data with this task
|
---|
68 |
|
---|
69 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
|
---|
70 | if (!fMcEvt)
|
---|
71 | {
|
---|
72 | *fLog << err << dbginf << "MMcEvt not found... exit." << endl;
|
---|
73 | return kFALSE;
|
---|
74 | }
|
---|
75 |
|
---|
76 | fCollArea = (MHMcCollectionArea*)pList->FindCreateObj("MHMcCollectionArea");
|
---|
77 | if (!fCollArea)
|
---|
78 | return kFALSE;
|
---|
79 |
|
---|
80 | fTheta = -1;
|
---|
81 | fEmin = -1;
|
---|
82 | fEmax = -1;
|
---|
83 | fSlope = 0;
|
---|
84 | fTotalNumSimulatedShowers = 0;
|
---|
85 | fCorsikaVersion = 0;
|
---|
86 | fAllEvtsTriggered = kFALSE;
|
---|
87 |
|
---|
88 | return kTRUE;
|
---|
89 | }
|
---|
90 |
|
---|
91 | Bool_t MMcCollectionAreaCalc::ReInit(MParList *plist)
|
---|
92 | {
|
---|
93 | MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
|
---|
94 | if (!runheader)
|
---|
95 | {
|
---|
96 | *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl;
|
---|
97 | return kFALSE;
|
---|
98 | }
|
---|
99 |
|
---|
100 | MMcCorsikaRunHeader *corrunheader = (MMcCorsikaRunHeader*)plist->FindObject("MMcCorsikaRunHeader");
|
---|
101 | if (!corrunheader)
|
---|
102 | {
|
---|
103 | *fLog << err << dbginf << "Error - MMcCorsikaRunHeader not found... exit." << endl;
|
---|
104 | return kFALSE;
|
---|
105 | }
|
---|
106 |
|
---|
107 | fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers();
|
---|
108 |
|
---|
109 | *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl;
|
---|
110 |
|
---|
111 | if (fTheta>=0 && fTheta!=runheader->GetTelesTheta())
|
---|
112 | {
|
---|
113 | *fLog << warn << dbginf << "Warning - Read files have different TelesTheta (";
|
---|
114 | *fLog << fTheta << ", " << runheader->GetTelesTheta() << ")..." << endl;
|
---|
115 | }
|
---|
116 |
|
---|
117 | fTheta = runheader->GetTelesTheta();
|
---|
118 |
|
---|
119 | if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
|
---|
120 | *fLog << warn << dbginf << "Warning - Read files have different Corsika versions..." << endl;
|
---|
121 |
|
---|
122 | fCorsikaVersion = runheader->GetCorsikaVersion();
|
---|
123 |
|
---|
124 | if ( fEmin > 0 &&
|
---|
125 | (fEmin != corrunheader->GetELowLim() ||
|
---|
126 | fEmax != corrunheader->GetEUppLim() ||
|
---|
127 | fSlope != corrunheader->GetSlopeSpec()) )
|
---|
128 | *fLog << warn << dbginf << "Warning - Read files have different energy distribution..." << endl;
|
---|
129 |
|
---|
130 | fEmin = corrunheader->GetELowLim();
|
---|
131 | fEmax = corrunheader->GetEUppLim();
|
---|
132 | fSlope = corrunheader->GetSlopeSpec();
|
---|
133 |
|
---|
134 | fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();
|
---|
135 |
|
---|
136 | *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
|
---|
137 |
|
---|
138 | if (fAllEvtsTriggered)
|
---|
139 | return kTRUE;
|
---|
140 |
|
---|
141 | fMcTrig = (MMcTrig*)plist->FindObject(fObjName);
|
---|
142 | if (!fMcTrig)
|
---|
143 | {
|
---|
144 | *fLog << err << dbginf << fObjName << " [MMcTrig] not found... exit." << endl;
|
---|
145 | return kFALSE;
|
---|
146 | }
|
---|
147 |
|
---|
148 | return kTRUE;
|
---|
149 | }
|
---|
150 |
|
---|
151 | Bool_t MMcCollectionAreaCalc::Process()
|
---|
152 | {
|
---|
153 | const Double_t energy = fMcEvt->GetEnergy();
|
---|
154 | const Double_t impact = fMcEvt->GetImpact()/100.;
|
---|
155 |
|
---|
156 | //
|
---|
157 | // This happens for camera files created with Camera 0.5
|
---|
158 | //
|
---|
159 | if (TMath::IsNaN(impact))
|
---|
160 | {
|
---|
161 | *fLog << err << dbginf << "ERROR - Impact=NaN (Not a number)... abort." << endl;
|
---|
162 | return kERROR;
|
---|
163 | }
|
---|
164 |
|
---|
165 | if (!fAllEvtsTriggered)
|
---|
166 | {
|
---|
167 | fCollArea->FillAll(energy, impact);
|
---|
168 |
|
---|
169 | if (fMcTrig->GetFirstLevel() <= 0)
|
---|
170 | return kTRUE;
|
---|
171 | }
|
---|
172 |
|
---|
173 | fCollArea->FillSel(energy, impact);
|
---|
174 |
|
---|
175 | return kTRUE;
|
---|
176 | }
|
---|
177 |
|
---|
178 | Bool_t MMcCollectionAreaCalc::PostProcess()
|
---|
179 | {
|
---|
180 | //
|
---|
181 | // do the calculation of the effectiv area
|
---|
182 | //
|
---|
183 | *fLog << inf << "Calculation Collection Area..." << endl;
|
---|
184 |
|
---|
185 | if (!fAllEvtsTriggered)
|
---|
186 | fCollArea->CalcEfficiency();
|
---|
187 | else
|
---|
188 | {
|
---|
189 | *fLog << inf << "Total number of showers: " << fTotalNumSimulatedShowers << endl;
|
---|
190 | fCollArea->CalcEfficiency(fTotalNumSimulatedShowers, fEmin, fEmax, fSlope);
|
---|
191 | }
|
---|
192 |
|
---|
193 | return kTRUE;
|
---|
194 | }
|
---|
195 |
|
---|