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

Last change on this file since 1150 was 1150, checked in by blanch, 23 years ago
It is a task used to set up the list of blind pixels. Currently it recognises the CrabNebula starfield and then switch off the Theta Taury pixels. Blind pixels can be also introduced through the macro or analysis program.
File size: 5.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// remove from the analysis the pixels taht are listed in fPixelsID. //
31// //
32// Input Containers: //
33// MCerPhotEvt //
34// //
35// Output Containers: //
36// MBlindPixels //
37// //
38/////////////////////////////////////////////////////////////////////////////
39#include "MBlindPixelCalc.h"
40
41#include "MLog.h"
42#include "MLogManip.h"
43
44#include "MParList.h"
45#include "MCerPhotPix.h"
46#include "MCerPhotEvt.h"
47#include "MBlindPixels.h"
48#include "MMcRunHeader.hxx"
49
50ClassImp(MBlindPixelCalc);
51
52// --------------------------------------------------------------------------
53//
54// Default constructor.
55//
56MBlindPixelCalc::MBlindPixelCalc(const char *name, const char *title)
57
58{
59 fName = name ? name : "MBlindPixelCalc";
60 fTitle = title ? title : "Task which removes a list of pixel from analysis";
61}
62
63// --------------------------------------------------------------------------
64//
65// check if there are blind pixels if not skip this task from task list.
66// check if MCerPhotEvt exists in the Parameter list if not the analysis
67// stops.
68//
69Bool_t MBlindPixelCalc::PreProcess (MParList *pList)
70{
71 fPixels = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
72 if (!fPixels)
73 return kFALSE;
74
75 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
76 if (!fEvt)
77 {
78 *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
79 return kFALSE;
80 }
81
82 const UShort_t size = fPixelsID.GetSize();
83
84 if (size == 0)
85 {
86 if (!pList->FindObject("MMcRunHeader"))
87 {
88 *fLog << warn << "Warning - Neither blind pixels are given nor a MMcRunHeader was found... removing MBlindPixelCalc from list." << endl;
89 return kSKIP;
90 }
91 return kTRUE;
92 }
93
94 // Set as blind pixels the global blind pixels, which are given
95 // through the macros
96
97 UShort_t numids = fPixelsID.GetSize();
98
99 cout<<"HOLA "<<numids<<endl;
100
101 for(Int_t i = 0; i<numids; i++)
102 fPixels->SetPixelBlind(fPixelsID[i]);
103
104 return kTRUE;
105}
106
107
108// --------------------------------------------------------------------------
109//
110// Remove the pixels.
111//
112Bool_t MBlindPixelCalc::Process()
113{
114 const UShort_t entries = fEvt->GetNumPixels();
115
116 //
117 // remove the pixels in fPixelsID if they are set to be used,
118 // (set them to 'unused' state)
119 //
120 for (UShort_t i=0; i<entries; i++ )
121 {
122 MCerPhotPix &pix = (*fEvt)[i];
123
124 if (fPixels->IsBlind(pix.GetPixId()))
125 pix.SetPixelUnused();
126 }
127
128 return kTRUE;
129}
130
131// --------------------------------------------------------------------------
132//
133// Set pixels to no be used.
134// This member function (public) should be called from the macro (or
135// analysis program) setting the desired blind pixels.
136// In the future, the blind pixels may be extracted from information which
137// is already in the root file.
138//
139void MBlindPixelCalc::SetPixels(Int_t num, Short_t *ids)
140{
141 fPixelsID.Adopt(num, ids);
142}
143
144Bool_t MBlindPixelCalc::ReInit(MParList *pList)
145{
146 //
147 // If pixels are given by the user, we are already done
148 //
149 if (fPixelsID.GetSize() > 0)
150 return kTRUE;
151
152 //
153 // Set as blind some particular pixels because of a particular
154 // Star Field of View.
155 //
156 MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
157 if (!mcrun)
158 return kTRUE;
159
160 Int_t rah, ram, ras;
161 Int_t ded, dem, des;
162 mcrun->GetStarFieldRa(&rah, &ram, &ras);
163 mcrun->GetStarFieldDe(&ded, &dem, &des);
164
165 if (rah!=5 || ram!=34 || ras!=32 || ded!=22 || dem!=0 || des!=55)
166 {
167 *fLog << warn << "Warning - Detected Starfield unknown..." << endl;
168 return kSKIP;
169 }
170
171 //
172 // Case for Crab Nebula FOV
173 //
174 fPixels->Clear();
175 fPixels->SetPixelBlind(400);
176 fPixels->SetPixelBlind(401);
177 fPixels->SetPixelBlind(402);
178 fPixels->SetPixelBlind(437);
179 fPixels->SetPixelBlind(438);
180 fPixels->SetPixelBlind(439);
181
182 *fLog << inf;
183 *fLog << "FOV is centered at CRAB NEBULA: Setting 6 blind pixels" << endl;
184 *fLog << "to avoid bias values of analysis due to CRAB NEBULA:" << endl;
185 *fLog << " Pixels: 400, 401, 402, 437, 438, 439" << endl;
186
187 return kTRUE;
188}
189
190
Note: See TracBrowser for help on using the repository browser.