source: tags/Mars-V0.9.5.1/manalysis/MMcTriggerLvl2Calc.cc

Last change on this file was 7188, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 6.5 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): Antonio Stamerra 1/2003 <mailto:antono.stamerra@pi.infn.it>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MTriggerLvl2Calc //
28// This is a task to calculate the 2nd level trigger selection //
29// parameters //
30// //
31// Input containers: //
32// MMcTriggerLvl2 //
33// //
34/////////////////////////////////////////////////////////////////////////////
35
36#include "MMcTriggerLvl2Calc.h"
37#include "MMcTriggerLvl2.h"
38#include "MHMcTriggerLvl2.h"
39
40#include "MParList.h"
41#include "MLog.h"
42#include "MLogManip.h"
43
44//#include "MMcEvt.hxx"
45#include "MMcTrig.hxx"
46#include "MRawRunHeader.h"
47#include "MMcRunHeader.hxx"
48
49#include "MGeomCam.h"
50
51ClassImp(MMcTriggerLvl2Calc);
52
53using namespace std;
54
55// --------------------------------------------------------------------------
56//
57// Default constructor
58//
59//
60MMcTriggerLvl2Calc::MMcTriggerLvl2Calc(const char *name, const char *title)
61{
62 fName = name ? name : "MMcTriggerLvl2Calc";
63 fTitle = title ? title : "Task to Fill the MMcTriggerLvl2 object";
64}
65
66 // --------------------------------------------------------------------------
67//
68// Check for the run type. Return kTRUE if it is a MC run or if there
69// is no MC run header (old camera files) kFALSE in case of a different
70// run type
71//
72Bool_t MMcTriggerLvl2Calc::IsMCRun(MParList *pList) const
73{
74 const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
75 if (!run)
76 {
77 *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
78 return kTRUE;
79 }
80
81 return run->IsMonteCarloRun();
82}
83
84// --------------------------------------------------------------------------
85//
86// Check for the runtype.
87// Search for .
88//
89Bool_t MMcTriggerLvl2Calc::ReInit(MParList *pList)
90{
91 return kTRUE;
92}
93
94
95
96// --------------------------------------------------------------------------
97//
98// PreProcess
99// Check the exxistence of the MMcTriggerLvl2 containers and the correct
100// setting of the fCompactNN that defines a compact pixel
101//
102Int_t MMcTriggerLvl2Calc::PreProcess (MParList *pList)
103{
104
105 // fMMcTriggerLvl2 = (MMcTriggerLvl2*)pList->FindObject("MMcTriggerLvl2");
106 fMMcTriggerLvl2 = (MMcTriggerLvl2*)pList->FindCreateObj("MMcTriggerLvl2");
107 if (!fMMcTriggerLvl2)
108 {
109 *fLog << err << dbginf << "MMcTriggerLvl2 not found... exit." << endl;
110 return kFALSE;
111 }
112
113 fMHMcTriggerLvl2 = (MHMcTriggerLvl2*)pList->FindCreateObj("MHMcTriggerLvl2");
114 if (!fMHMcTriggerLvl2)
115 {
116 *fLog << err << dbginf << "MHMcTriggerLvl2 not found... exit." << endl;
117 return kFALSE;
118 }
119
120 // Check if the variable fCompactNN has been correctly set;
121 // accepted values for fCompactNN are (up to now) 2 and 3.
122 if (fMMcTriggerLvl2->GetCompactNN()<2 || fMMcTriggerLvl2->GetCompactNN()>3)
123 {
124 *fLog << err << dbginf << "fCompactNN is not correctly set ("<<fMMcTriggerLvl2->GetCompactNN() <<") ... exit" <<endl;
125 return kFALSE;
126 }
127 else
128 *fLog << "Compact pixel is set with at least "<<fMMcTriggerLvl2->GetCompactNN() << " NN" <<endl;
129
130 //------------------------------------------------------------
131 //
132 // If it is no MC file skip this function...
133 //
134 if (!IsMCRun(pList))
135 {
136 *fLog << inf << "Reading a data file...skipping the rest of PreProcess()" << endl;
137 return kTRUE;
138 }
139
140 //
141 // Check all necessary containers in case of a MC run
142 //
143 fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
144 if (!fMcEvt)
145 {
146 *fLog << err << dbginf << "MMcEvt not found... exit." << endl;
147 return kFALSE;
148 }
149
150 fMcTrig = (MMcTrig*)pList->FindObject("MMcTrig");
151 if (!fMcTrig)
152 {
153 *fLog << err << dbginf << "MMcTrig not found... exit." << endl;
154 return kFALSE;
155 }
156
157 fCam = (MGeomCam*)pList->FindObject("MGeomCam");
158 if (!fCam)
159 {
160 *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
161 return kFALSE;
162 }
163 // Check if fCam is a Magic geometry: only MGeomCamMagic geometry and
164 // geometries with 577 pixels are now accepted by MMcTriggerLvl2
165 if (fCam->GetNumPixels()!= 577)
166 {
167 *fLog << warn << "MGeomCam has a wrong geometry; only MAGIC geometry (577 pixels) is accepted by now... the Task is skipped." <<endl;
168 return kSKIP;
169 }
170
171 return kTRUE;
172
173}
174
175
176// --------------------------------------------------------------------------
177//
178// Process
179//
180//
181Int_t MMcTriggerLvl2Calc::Process()
182{
183 // fMMcTriggerLvl2->GetEnergy(fMcEvt);
184
185 fMMcTriggerLvl2->SetLv1(fMcTrig);
186
187 fMMcTriggerLvl2->CalcCompactPixels(fCam);
188
189 fMMcTriggerLvl2->Calc();
190
191 fMMcTriggerLvl2->CalcTriggerPattern(fCam);
192
193 return kTRUE;
194}
195
196
197// --------------------------------------------------------------------------
198//
199// PostProcess : Display the histogram
200// !to be fixed: create an histogram class!
201//
202Int_t MMcTriggerLvl2Calc::PostProcess()
203{
204
205 return kTRUE;
206}
207
208
209
210
Note: See TracBrowser for help on using the repository browser.