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

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