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

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