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

Last change on this file since 2314 was 2298, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.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): 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 *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
103
104 if (fSum)
105 delete (fSum);
106
107 const TString name = fNameEvt.IsNull() ? fName : fNameEvt;
108
109 fSum = new MHCamera(*cam, name+";avg", fTitle);
110 fSum->SetYTitle("%");
111
112 return kTRUE;
113}
114
115// --------------------------------------------------------------------------
116//
117// Fill the histograms with data from a MCamEvent-Container.
118//
119Bool_t MHTriggerLvl0::Fill(const MParContainer *par, const Stat_t w)
120{
121 const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
122 if (!evt)
123 {
124 *fLog << err << dbginf << "No MCamEvent found..." << endl;
125 return kFALSE;
126 }
127
128 fSum->CntCamContent(*evt, fThreshold, fType);
129
130 return kTRUE;
131}
132
133// --------------------------------------------------------------------------
134//
135// Scale by the number of events
136//
137Bool_t MHTriggerLvl0::Finalize()
138{
139 if (fSum->GetEntries()>0)
140 fSum->Scale(100./fSum->GetEntries());
141 return kTRUE;
142}
143
144void MHTriggerLvl0::PrintOutlayers(Float_t s) const
145{
146 const Double_t mean = fSum->GetMean();
147 const Double_t rms = fSum->GetRMS();
148
149 *fLog << all << underline << GetDescriptor() << ": Mean=" << mean << ", Rms=" << rms << endl;
150
151 for (unsigned int i=0; i<fSum->GetNumPixels(); i++)
152 {
153 if (!fSum->IsUsed(i))
154 continue;
155
156 if ((*fSum)[i+1]>mean+s*rms)
157 *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " > " << s << "*rms" << endl;
158 // if ((*fSum)[i+1]==0)
159 // *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " == 0" << endl;
160 // if ((*fSum)[i+1]<fSum->GetMean()-s*fSum->GetRMS())
161 // *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " < " << s << "*rms" << endl;
162 }
163}
164
165TH1 *MHTriggerLvl0::GetHistByName(const TString name)
166{
167 return fSum;
168}
169
170void MHTriggerLvl0::Draw(Option_t *)
171{
172 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
173 pad->SetBorderMode(0);
174
175 pad->Divide(1,2);
176
177 pad->cd(1);
178 gPad->SetBorderMode(0);
179 gPad->Divide(1,1);
180 gPad->cd(1);
181 gPad->SetBorderMode(0);
182 fSum->Draw();
183
184 pad->cd(2);
185 gPad->SetBorderMode(0);
186 fSum->Draw("EPhist");
187}
Note: See TracBrowser for help on using the repository browser.