source: trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.cc@ 2969

Last change on this file since 2969 was 2931, checked in by gaug, 21 years ago
*** empty log message ***
File size: 4.8 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): 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
40ClassImp(MHCalibrationPINDiode);
41
42using namespace std;
43
44// --------------------------------------------------------------------------
45//
46// Default Constructor.
47//
48MHCalibrationPINDiode::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
86MHCalibrationPINDiode::~MHCalibrationPINDiode()
87{
88
89 delete fHPINDiodeCharge;
90 delete fHPINDiodeTime;
91 delete fHPINDiodeChargevsN;
92
93 if (fChargeGausFit)
94 delete fChargeGausFit;
95 if (fTimeGausFit)
96 delete fTimeGausFit;
97 if (fFitLegend)
98 delete fFitLegend;
99}
100
101void 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 fTimeChisquare = -1.;
113 fTimeProb = -1.;
114 fTimeNdf = -1;
115 fTimeMean = -1.;
116 fTimeSigma = -1.;
117
118 fTimeLowerFitRangeHiGain = 0;
119 fTimeUpperFitRangeHiGain = 0;
120 fTimeLowerFitRangeLoGain = 0;
121 fTimeUpperFitRangeLoGain = 0;
122
123 if (fChargeGausFit)
124 delete fChargeGausFit;
125 if (fTimeGausFit)
126 delete fTimeGausFit;
127 if (fFitLegend)
128 delete fFitLegend;
129
130 return;
131
132}
133
134void MHCalibrationPINDiode::Reset()
135{
136
137 Clear();
138
139 fHPINDiodeCharge->Reset();
140 fHPINDiodeTime->Reset();
141 fHPINDiodeChargevsN->Reset();
142}
143
144
145Bool_t MHCalibrationPINDiode::FillCharge(Float_t q)
146{
147 return (fHPINDiodeCharge->Fill(q) > -1);
148}
149
150Bool_t MHCalibrationPINDiode::FillTime(Float_t t)
151{
152 return (fHPINDiodeTime->Fill(t) > -1);
153}
154
155Bool_t MHCalibrationPINDiode::FillChargevsN(Float_t q, Int_t n)
156{
157 return (fHPINDiodeChargevsN->Fill(n,q) > -1);
158}
159
160void MHCalibrationPINDiode::CutAllEdges()
161{
162
163 Int_t nbins = 30;
164
165 CutEdges(fHPINDiodeCharge,nbins);
166
167 fChargeFirstHiGain = fHPINDiodeCharge->GetBinLowEdge(fHPINDiodeCharge->GetXaxis()->GetFirst());
168 fChargeLastHiGain = fHPINDiodeCharge->GetBinLowEdge(fHPINDiodeCharge->GetXaxis()->GetLast())
169 +fHPINDiodeCharge->GetBinWidth(0);
170 CutEdges(fHPINDiodeChargevsN,0);
171
172}
173
Note: See TracBrowser for help on using the repository browser.