source: trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc@ 1382

Last change on this file since 1382 was 1179, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 6.8 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): Oscar Blanch 12/2001 <mailto:blanch@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MBlindPixelCalc //
28// //
29// This is the specific image cleaning for a list of pixels. This task //
30// sets the pixels listed in fPixelsID to unused so they should not be //
31// used for analysis (eg calculation of hillas parameters). //
32// //
33// If you specify an array of pixel IDs this pixels are disabled. //
34// In all other cases the task tries to determin the starfield from the //
35// MMcRunHeader and disables pixels correspoding to the starfield. //
36// //
37// Implemented star fields: //
38// - Crab: 400, 401, 402, 437, 438, 439 //
39// //
40// Input Containers: //
41// MCerPhotEvt //
42// //
43// Output Containers: //
44// MBlindPixels //
45// //
46/////////////////////////////////////////////////////////////////////////////
47#include "MBlindPixelCalc.h"
48
49#include "MLog.h"
50#include "MLogManip.h"
51
52#include "MParList.h"
53#include "MCerPhotPix.h"
54#include "MCerPhotEvt.h"
55#include "MBlindPixels.h"
56#include "MMcRunHeader.hxx"
57
58ClassImp(MBlindPixelCalc);
59
60// --------------------------------------------------------------------------
61//
62// Default constructor.
63//
64MBlindPixelCalc::MBlindPixelCalc(const char *name, const char *title)
65
66{
67 fName = name ? name : "MBlindPixelCalc";
68 fTitle = title ? title : "Task which removes a list of pixel from analysis";
69}
70
71// --------------------------------------------------------------------------
72//
73// - Try to find or create MBlindPixels in parameter list.
74// - get the MCerPhotEvt from the parlist (abort if missing)
75// - if no pixels are given by the user try to determin the starfield
76// from the monte carlo run header.
77//
78Bool_t MBlindPixelCalc::PreProcess (MParList *pList)
79{
80 fPixels = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
81 if (!fPixels)
82 return kFALSE;
83
84 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
85 if (!fEvt)
86 {
87 *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
88 return kFALSE;
89 }
90
91 const UShort_t size = fPixelsID.GetSize();
92
93 if (size == 0)
94 {
95 if (!pList->FindObject("MMcRunHeader"))
96 {
97 *fLog << warn << "Warning - Neither blind pixels are given nor a MMcRunHeader was found... removing MBlindPixelCalc from list." << endl;
98 return kSKIP;
99 }
100 return kTRUE;
101 }
102
103 // Set as blind pixels the global blind pixels, which are given
104 // through the macros
105
106 UShort_t numids = fPixelsID.GetSize();
107
108 for(Int_t i = 0; i<numids; i++)
109 fPixels->SetPixelBlind(fPixelsID[i]);
110
111 return kTRUE;
112}
113
114
115// --------------------------------------------------------------------------
116//
117// Remove the pixels.
118//
119Bool_t MBlindPixelCalc::Process()
120{
121 const UShort_t entries = fEvt->GetNumPixels();
122
123 //
124 // remove the pixels in fPixelsID if they are set to be used,
125 // (set them to 'unused' state)
126 //
127 for (UShort_t i=0; i<entries; i++)
128 {
129 MCerPhotPix &pix = (*fEvt)[i];
130
131 if (fPixels->IsBlind(pix.GetPixId()))
132 pix.SetPixelUnused();
133 }
134
135 return kTRUE;
136}
137
138// --------------------------------------------------------------------------
139//
140// Set pixels to no be used.
141// This member function (public) should be called from the macro (or
142// analysis program) setting the desired blind pixels.
143// In the future, the blind pixels may be extracted from information which
144// is already in the root file.
145//
146void MBlindPixelCalc::SetPixels(Int_t num, Short_t *ids)
147{
148 fPixelsID.Adopt(num, ids);
149}
150
151// --------------------------------------------------------------------------
152//
153// - Check whether pixels to disable are available. If pixels are
154// given by the user nothing more is done.
155// - Otherwise try to determin the blind pixels from the starfield
156// given in MMcRunHeader.
157//
158Bool_t MBlindPixelCalc::ReInit(MParList *pList)
159{
160 //
161 // If pixels are given by the user, we are already done
162 //
163 if (fPixelsID.GetSize() > 0)
164 return kTRUE;
165
166 //
167 // Set as blind some particular pixels because of a particular
168 // Star Field of View.
169 //
170 MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
171 if (!mcrun)
172 return kTRUE;
173
174 Int_t rah, ram, ras;
175 Int_t ded, dem, des;
176 mcrun->GetStarFieldRa(&rah, &ram, &ras);
177 mcrun->GetStarFieldDec(&ded, &dem, &des);
178
179 if (rah!=5 || ram!=34 || ras!=32 || ded!=22 || dem!=0 || des!=55)
180 {
181 *fLog << warn << "Warning - Detected Starfield unknown..." << endl;
182 return kSKIP;
183 }
184
185 //
186 // Case for Crab Nebula FOV
187 //
188 fPixels->Clear();
189 fPixels->SetPixelBlind(400);
190 fPixels->SetPixelBlind(401);
191 fPixels->SetPixelBlind(402);
192 fPixels->SetPixelBlind(437);
193 fPixels->SetPixelBlind(438);
194 fPixels->SetPixelBlind(439);
195
196 *fLog << inf;
197 *fLog << "FOV is centered at CRAB NEBULA: Setting 6 blind pixels" << endl;
198 *fLog << "to avoid bias values of analysis due to CRAB NEBULA:" << endl;
199 *fLog << " Pixels: 400, 401, 402, 437, 438, 439" << endl;
200
201 return kTRUE;
202}
203
204
Note: See TracBrowser for help on using the repository browser.