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

Last change on this file since 1508 was 1330, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.6 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 fMcTrig = (MMcTrig*)pList->FindObject(fObjName);
72 if (!fMcTrig)
73 {
74 *fLog << err << dbginf << fObjName << " [MMcTrig] not found... exit." << endl;
75 return kFALSE;
76 }
77
78 fCollArea = (MHMcCollectionArea*)pList->FindCreateObj("MHMcCollectionArea");
79 if (!fCollArea)
80 return kFALSE;
81
82
83 fTotalNumSimulatedShowers = 0;
84 fCorsikaVersion = 0;
85 fAllEvtsTriggered = kFALSE;
86
87 return kTRUE;
88}
89
90Bool_t MMcCollectionAreaCalc::ReInit(MParList *plist)
91{
92 MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
93 if (!runheader)
94 {
95 *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl;
96 return kFALSE;
97 }
98
99 fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers();
100
101 *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl;
102
103 if (fTheta>=0 && fTheta!=runheader->GetTelesTheta())
104 *fLog << warn << dbginf << "Warning - Read files have different TelesTheta... exit." << endl;
105
106 fTheta = runheader->GetTelesTheta();
107
108 if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
109 *fLog << warn << dbginf << "Warning - Read files have different Corsika versions... exit." << endl;
110
111 fCorsikaVersion = runheader->GetCorsikaVersion();
112
113 fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();
114
115 *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
116
117 return kTRUE;
118}
119
120Bool_t MMcCollectionAreaCalc::Process()
121{
122 const Float_t energy = fMcEvt->GetEnergy();
123 const Float_t impact = fMcEvt->GetImpact()/100.;
124
125 if (!fAllEvtsTriggered)
126 fCollArea->FillAll(energy, impact);
127
128 if (fMcTrig->GetFirstLevel() <= 0)
129 return kTRUE;
130
131 fCollArea->FillSel(energy, impact);
132
133 return kTRUE;
134}
135
136Bool_t MMcCollectionAreaCalc::PostProcess()
137{
138 //
139 // do the calculation of the effectiv area
140 //
141 *fLog << inf << "Calculation Collection Area..." << endl;
142
143 if (!fAllEvtsTriggered)
144 fCollArea->CalcEfficiency();
145 else
146 {
147 *fLog << inf << "Total number of showers: " << fTotalNumSimulatedShowers << endl;
148 fCollArea->CalcEfficiency(fTotalNumSimulatedShowers,
149 fCorsikaVersion == 5200 ? fTheta : 0);
150 }
151
152 return kTRUE;
153}
154
Note: See TracBrowser for help on using the repository browser.