source: trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2Calc.cc@ 4692

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