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 |
|
---|
51 | ClassImp(MHTriggerLvl0);
|
---|
52 |
|
---|
53 | using namespace std;
|
---|
54 |
|
---|
55 | // --------------------------------------------------------------------------
|
---|
56 | //
|
---|
57 | // Initialize the name and title of the task.
|
---|
58 | // Resets the sum histogram
|
---|
59 | //
|
---|
60 | MHTriggerLvl0::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 | //
|
---|
74 | MHTriggerLvl0::~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 | //
|
---|
87 | Bool_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 | fSum = new MHCamera(*cam, fNameEvt+";avg", fTitle);
|
---|
107 | fSum->SetYTitle("%");
|
---|
108 |
|
---|
109 | return kTRUE;
|
---|
110 | }
|
---|
111 |
|
---|
112 | // --------------------------------------------------------------------------
|
---|
113 | //
|
---|
114 | // Fill the histograms with data from a MCamEvent-Container.
|
---|
115 | //
|
---|
116 | Bool_t MHTriggerLvl0::Fill(const MParContainer *par, const Stat_t w)
|
---|
117 | {
|
---|
118 | const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
|
---|
119 | if (!evt)
|
---|
120 | {
|
---|
121 | *fLog << err << dbginf << "No MCamEvent found..." << endl;
|
---|
122 | return kFALSE;
|
---|
123 | }
|
---|
124 |
|
---|
125 | fSum->CntCamContent(*evt, fThreshold, fType);
|
---|
126 |
|
---|
127 | return kTRUE;
|
---|
128 | }
|
---|
129 |
|
---|
130 | // --------------------------------------------------------------------------
|
---|
131 | //
|
---|
132 | // Scale by the number of events
|
---|
133 | //
|
---|
134 | Bool_t MHTriggerLvl0::Finalize()
|
---|
135 | {
|
---|
136 | if (fSum->GetEntries()>0)
|
---|
137 | fSum->Scale(100./fSum->GetEntries());
|
---|
138 | return kTRUE;
|
---|
139 | }
|
---|
140 |
|
---|
141 | TH1 *MHTriggerLvl0::GetHistByName(const TString name)
|
---|
142 | {
|
---|
143 | return fSum;
|
---|
144 | }
|
---|
145 |
|
---|
146 | void MHTriggerLvl0::Draw(Option_t *)
|
---|
147 | {
|
---|
148 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
---|
149 | pad->SetBorderMode(0);
|
---|
150 |
|
---|
151 | fSum->Draw();
|
---|
152 | }
|
---|