source: trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc@ 1613

Last change on this file since 1613 was 1613, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.7 KB
Line 
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//////////////////////////////////////////////////////////////////////////////
31
32#include "MMcCollectionAreaCalc.h"
33
34#include "MParList.h"
35
36#include "MLog.h"
37#include "MLogManip.h"
38
39#include "MMcEvt.hxx"
40#include "MMcTrig.hxx"
41#include "MMcRunHeader.hxx"
42
43#include "MHMcCollectionArea.h"
44
45ClassImp(MMcCollectionAreaCalc);
46
47MMcCollectionAreaCalc::MMcCollectionAreaCalc(const char *input,
48 const char *name, const char *title)
49{
50 fName = name ? name : "MMcCollectionAreaCalc";
51 fTitle = title ? title : "Task to calculate the collection area";
52
53 fObjName = input ? input : "MMcTrig";
54 AddToBranchList(Form("%s.fNumFirstLevel", input));
55
56 AddToBranchList("MMcEvt.fEnergy");
57 AddToBranchList("MMcEvt.fImpact");
58}
59
60Bool_t MMcCollectionAreaCalc::PreProcess (MParList *pList)
61{
62 // connect the raw data with this task
63
64 fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
65 if (!fMcEvt)
66 {
67 *fLog << err << dbginf << "MMcEvt not found... exit." << endl;
68 return kFALSE;
69 }
70
71 fCollArea = (MHMcCollectionArea*)pList->FindCreateObj("MHMcCollectionArea");
72 if (!fCollArea)
73 return kFALSE;
74
75
76 fTotalNumSimulatedShowers = 0;
77 fCorsikaVersion = 0;
78 fAllEvtsTriggered = kFALSE;
79
80 return kTRUE;
81}
82
83Bool_t MMcCollectionAreaCalc::ReInit(MParList *plist)
84{
85 MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
86 if (!runheader)
87 {
88 *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl;
89 return kFALSE;
90 }
91
92 fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers();
93
94 *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl;
95
96 if (fTheta>=0 && fTheta!=runheader->GetTelesTheta())
97 *fLog << warn << dbginf << "Warning - Read files have different TelesTheta..." << endl;
98
99 fTheta = runheader->GetTelesTheta();
100
101 if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
102 *fLog << warn << dbginf << "Warning - Read files have different Corsika versions..." << endl;
103
104 fCorsikaVersion = runheader->GetCorsikaVersion();
105
106 fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();
107
108 *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
109
110 if (fAllEvtsTriggered)
111 return kTRUE;
112
113 fMcTrig = (MMcTrig*)plist->FindObject(fObjName);
114 if (!fMcTrig)
115 {
116 *fLog << err << dbginf << fObjName << " [MMcTrig] not found... exit." << endl;
117 return kFALSE;
118 }
119
120 return kTRUE;
121}
122
123Bool_t MMcCollectionAreaCalc::Process()
124{
125 const Float_t energy = fMcEvt->GetEnergy();
126 const Float_t impact = fMcEvt->GetImpact()/100.;
127
128 if (!fAllEvtsTriggered)
129 {
130 fCollArea->FillAll(energy, impact);
131
132 if (fMcTrig->GetFirstLevel() <= 0)
133 return kTRUE;
134 }
135
136 fCollArea->FillSel(energy, impact);
137
138 return kTRUE;
139}
140
141Bool_t MMcCollectionAreaCalc::PostProcess()
142{
143 //
144 // do the calculation of the effectiv area
145 //
146 *fLog << inf << "Calculation Collection Area..." << endl;
147
148 if (!fAllEvtsTriggered)
149 fCollArea->CalcEfficiency();
150 else
151 {
152 *fLog << inf << "Total number of showers: " << fTotalNumSimulatedShowers << endl;
153 fCollArea->CalcEfficiency(fTotalNumSimulatedShowers,
154 fCorsikaVersion == 5200 ? fTheta : 0);
155 }
156
157 return kTRUE;
158}
159
Note: See TracBrowser for help on using the repository browser.