source: trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc@ 8526

Last change on this file since 8526 was 6977, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 5.6 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): Abelardo Moralejo, 06/2003 <mailto:moralejo@pd.infn.it>
19! Author(s): Thomas Bretz, 06/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2003
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MHTriggerLvl0
29//
30// This is intended to be a sort of "level 0 trigger display". What it
31// really does is to store the number of events of a data file in which
32// each pixel has gone above a given threshold (fPixelThreshold) which
33// is chosen when calling the constructor. Displaying a camera view with
34// these values can help identify noisy pixels. See the macro pixfixrate.C
35// to see an example of its use.
36//
37/////////////////////////////////////////////////////////////////////////////
38#include "MHTriggerLvl0.h"
39
40#include <TCanvas.h>
41
42#include "MLog.h"
43#include "MLogManip.h"
44
45#include "MParList.h"
46#include "MCamEvent.h"
47#include "MHCamera.h"
48
49#include "MGeomCam.h"
50
51ClassImp(MHTriggerLvl0);
52
53using namespace std;
54
55// --------------------------------------------------------------------------
56//
57// Initialize the name and title of the task.
58// Resets the sum histogram
59//
60MHTriggerLvl0::MHTriggerLvl0(Double_t t, const char *name, const char *title)
61 : fSum(NULL), fEvt(NULL), fType(0), fThreshold(t)
62{
63 //
64 // set the name and title of this object
65 //
66 fName = name ? name : "MHTriggerLvl0";
67 fTitle = title ? title : "Number of hits above threshold per pixel";
68}
69
70// --------------------------------------------------------------------------
71//
72// Delete the corresponding camera display if available
73//
74MHTriggerLvl0::~MHTriggerLvl0()
75{
76 if (fSum)
77 delete fSum;
78}
79
80// --------------------------------------------------------------------------
81//
82// Get the event (MRawEvtData) the histogram might be filled with. If
83// it is not given, it is assumed, that it is filled with the argument
84// of the Fill function.
85// Looks for the camera geometry MGeomCam and resets the sum histogram.
86//
87Bool_t MHTriggerLvl0::SetupFill(const MParList *plist)
88{
89 fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent");
90 if (!fEvt)
91 {
92 if (!fNameEvt.IsNull())
93 {
94 *fLog << err << GetDescriptor() << ": No " << fNameEvt <<" [MCamEvent] available..." << endl;
95 return kFALSE;
96 }
97 *fLog << warn << GetDescriptor() << ": No MCamEvent available..." << endl;
98 }
99
100 MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
101 if (!cam)
102 {
103 *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
104 return kFALSE;
105 }
106
107 if (fSum)
108 delete (fSum);
109
110 const TString name = fNameEvt.IsNull() ? fName : fNameEvt;
111
112 fSum = new MHCamera(*cam, name+";avg", fTitle);
113 fSum->SetBit(MHCamera::kProfile);
114 fSum->SetYTitle("% [1]");
115
116 return kTRUE;
117}
118
119// --------------------------------------------------------------------------
120//
121// Fill the histograms with data from a MCamEvent-Container.
122//
123Bool_t MHTriggerLvl0::Fill(const MParContainer *par, const Stat_t w)
124{
125 const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
126 if (!evt)
127 {
128 *fLog << err << dbginf << "Got no MCamEvent as argument of Fill()..." << endl;
129 return kFALSE;
130 }
131
132 fSum->CntCamContent(*evt, fThreshold, fType);
133
134 return kTRUE;
135}
136
137// --------------------------------------------------------------------------
138//
139// Scale by the number of events
140//
141Bool_t MHTriggerLvl0::Finalize()
142{
143 // if (fSum->GetEntries()>0)
144 // fSum->Scale(100);
145 return kTRUE;
146}
147
148void MHTriggerLvl0::PrintOutliers(Float_t s) const
149{
150 const Double_t mean = fSum->GetMean();
151 const Double_t rms = fSum->GetRMS();
152
153 *fLog << all << underline << GetDescriptor() << ": Mean=" << mean << ", Rms=" << rms << endl;
154
155 for (unsigned int i=0; i<fSum->GetNumPixels(); i++)
156 {
157 if (!fSum->IsUsed(i))
158 continue;
159
160 if ((*fSum)[i+1]>mean+s*rms)
161 *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " > " << s << "*rms" << endl;
162 // if ((*fSum)[i+1]==0)
163 // *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " == 0" << endl;
164 // if ((*fSum)[i+1]<fSum->GetMean()-s*fSum->GetRMS())
165 // *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " < " << s << "*rms" << endl;
166 }
167}
168
169TH1 *MHTriggerLvl0::GetHistByName(const TString name) const
170{
171 return fSum;
172}
173
174void MHTriggerLvl0::Draw(Option_t *)
175{
176 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
177 pad->SetBorderMode(0);
178
179 pad->Divide(1,2);
180
181 pad->cd(1);
182 /*
183 gPad->SetBorderMode(0);
184 gPad->Divide(1,1);
185 gPad->cd(1);
186 gPad->SetBorderMode(0);
187 */
188 fSum->Draw();
189
190 pad->cd(2);
191 gPad->SetBorderMode(0);
192 fSum->Draw("EPhist");
193}
Note: See TracBrowser for help on using the repository browser.