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): Markus Gaug 11/2003 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2002
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MHCalibrationPINDiode
|
---|
28 | //
|
---|
29 | // Performs all the necessary fits to extract the mean number of photons
|
---|
30 | // out of the derived light flux
|
---|
31 | //
|
---|
32 | //////////////////////////////////////////////////////////////////////////////
|
---|
33 | #include "MHCalibrationPINDiode.h"
|
---|
34 | #include "MHCalibrationConfig.h"
|
---|
35 |
|
---|
36 | #include <TH1.h>
|
---|
37 | #include <TF1.h>
|
---|
38 | #include <TPaveText.h>
|
---|
39 |
|
---|
40 | ClassImp(MHCalibrationPINDiode);
|
---|
41 |
|
---|
42 | using namespace std;
|
---|
43 |
|
---|
44 | // --------------------------------------------------------------------------
|
---|
45 | //
|
---|
46 | // Default Constructor.
|
---|
47 | //
|
---|
48 | MHCalibrationPINDiode::MHCalibrationPINDiode(const char *name, const char *title)
|
---|
49 | : fChargeNbins(1000),
|
---|
50 | fTimeNbins(64),
|
---|
51 | fChargevsNbins(10000),
|
---|
52 | fTimeFirst(-0.25),
|
---|
53 | fTimeLast(31.75)
|
---|
54 | {
|
---|
55 |
|
---|
56 | fName = name ? name : "MHCalibrationPINDiode";
|
---|
57 | fTitle = title ? title : "Fill the accumulated charges and times all PINDiode events and perform fits";
|
---|
58 |
|
---|
59 | // Create a large number of bins, later we will rebin
|
---|
60 | fChargeFirstHiGain = -100.5;
|
---|
61 | fChargeLastHiGain = 1999.5;
|
---|
62 |
|
---|
63 | fHPINDiodeCharge = new TH1F("HPINDiodeCharge","Distribution of Summed FADC Slices PINDiode",
|
---|
64 | fChargeNbins,fChargeFirstHiGain,fChargeLastHiGain);
|
---|
65 | fHPINDiodeCharge->SetXTitle("Sum FADC Slices");
|
---|
66 | fHPINDiodeCharge->SetYTitle("Nr. of events");
|
---|
67 | fHPINDiodeCharge->Sumw2();
|
---|
68 | fHPINDiodeCharge->SetDirectory(NULL);
|
---|
69 |
|
---|
70 | fHPINDiodeTime = new TH1F("HPINDiodeTime","Distribution of Mean Arrival Times PINDiode",
|
---|
71 | fTimeNbins,fTimeFirst,fTimeLast);
|
---|
72 | fHPINDiodeTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
|
---|
73 | fHPINDiodeTime->SetYTitle("Nr. of events");
|
---|
74 | fHPINDiodeTime->Sumw2();
|
---|
75 | fHPINDiodeTime->SetDirectory(NULL);
|
---|
76 |
|
---|
77 | fHPINDiodeChargevsN = new TH1I("HPINDiodeChargevsN","Sum of Hi Gain Charges vs. Event Number Pixel ",
|
---|
78 | fChargevsNbins,-0.5,(Axis_t)fChargevsNbins - 0.5);
|
---|
79 | fHPINDiodeChargevsN->SetXTitle("Event Nr.");
|
---|
80 | fHPINDiodeChargevsN->SetYTitle("Sum of Hi Gain FADC slices");
|
---|
81 | fHPINDiodeChargevsN->SetDirectory(NULL);
|
---|
82 |
|
---|
83 | Clear();
|
---|
84 | }
|
---|
85 |
|
---|
86 | MHCalibrationPINDiode::~MHCalibrationPINDiode()
|
---|
87 | {
|
---|
88 |
|
---|
89 | delete fHPINDiodeCharge;
|
---|
90 | delete fHPINDiodeTime;
|
---|
91 | delete fHPINDiodeChargevsN;
|
---|
92 |
|
---|
93 | if (fChargeGausFit)
|
---|
94 | delete fChargeGausFit;
|
---|
95 | if (fRelTimeGausFit)
|
---|
96 | delete fRelTimeGausFit;
|
---|
97 | if (fFitLegend)
|
---|
98 | delete fFitLegend;
|
---|
99 | }
|
---|
100 |
|
---|
101 | void MHCalibrationPINDiode::Clear(Option_t *o)
|
---|
102 | {
|
---|
103 |
|
---|
104 | fTotalEntries = 0;
|
---|
105 |
|
---|
106 | fChargeFirstHiGain = -100.5;
|
---|
107 | fChargeLastHiGain = 1999.5;
|
---|
108 |
|
---|
109 | fChargeChisquare = -1.;
|
---|
110 | fChargeProb = -1.;
|
---|
111 | fChargeNdf = -1;
|
---|
112 | fRelTimeProb = -1.;
|
---|
113 | fRelTimeNdf = -1;
|
---|
114 | fRelTimeMean = -1.;
|
---|
115 | fRelTimeSigma = -1.;
|
---|
116 |
|
---|
117 | fRelTimeLowerFitRangeHiGain = -99.;
|
---|
118 | fRelTimeUpperFitRangeHiGain = -99.;
|
---|
119 | fRelTimeLowerFitRangeLoGain = -99.;
|
---|
120 | fRelTimeUpperFitRangeLoGain = -99.;
|
---|
121 |
|
---|
122 | if (fChargeGausFit)
|
---|
123 | delete fChargeGausFit;
|
---|
124 | if (fRelTimeGausFit)
|
---|
125 | delete fRelTimeGausFit;
|
---|
126 | if (fFitLegend)
|
---|
127 | delete fFitLegend;
|
---|
128 |
|
---|
129 | return;
|
---|
130 |
|
---|
131 | }
|
---|
132 |
|
---|
133 | void MHCalibrationPINDiode::Reset()
|
---|
134 | {
|
---|
135 |
|
---|
136 | Clear();
|
---|
137 |
|
---|
138 | fHPINDiodeCharge->Reset();
|
---|
139 | fHPINDiodeTime->Reset();
|
---|
140 | fHPINDiodeChargevsN->Reset();
|
---|
141 | }
|
---|
142 |
|
---|
143 |
|
---|
144 | Bool_t MHCalibrationPINDiode::FillCharge(Float_t q)
|
---|
145 | {
|
---|
146 | return (fHPINDiodeCharge->Fill(q) > -1);
|
---|
147 | }
|
---|
148 |
|
---|
149 | Bool_t MHCalibrationPINDiode::FillTime(Float_t t)
|
---|
150 | {
|
---|
151 | return (fHPINDiodeTime->Fill(t) > -1);
|
---|
152 | }
|
---|
153 |
|
---|
154 | Bool_t MHCalibrationPINDiode::FillChargevsN(Float_t q, Int_t n)
|
---|
155 | {
|
---|
156 | return (fHPINDiodeChargevsN->Fill(n,q) > -1);
|
---|
157 | }
|
---|
158 |
|
---|
159 | void MHCalibrationPINDiode::CutAllEdges()
|
---|
160 | {
|
---|
161 |
|
---|
162 | Int_t nbins = 30;
|
---|
163 |
|
---|
164 | CutEdges(fHPINDiodeCharge,nbins);
|
---|
165 |
|
---|
166 | fChargeFirstHiGain = fHPINDiodeCharge->GetBinLowEdge(fHPINDiodeCharge->GetXaxis()->GetFirst());
|
---|
167 | fChargeLastHiGain = fHPINDiodeCharge->GetBinLowEdge(fHPINDiodeCharge->GetXaxis()->GetLast())
|
---|
168 | +fHPINDiodeCharge->GetBinWidth(0);
|
---|
169 | CutEdges(fHPINDiodeChargevsN,0);
|
---|
170 |
|
---|
171 | }
|
---|
172 |
|
---|