source: trunk/Mars/mdrs/MDrsCalibrationTime.cc@ 18154

Last change on this file since 18154 was 18151, checked in by tbretz, 10 years ago
Added SetDelays(const TGraph&)
File size: 2.7 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): Thomas Bretz 2013 <mailto:tbretz@physik.rwth-aachen.de>
19!
20! Copyright: MAGIC Software Development, 2000-2015
21!
22!
23\* ======================================================================== */
24
25///////////////////////////////////////////////////////////////////////
26//
27// MHDrsCalibration
28//
29///////////////////////////////////////////////////////////////////////
30#include "MDrsCalibrationTime.h"
31
32#include <TH1.h>
33#include <TGraph.h>
34
35ClassImp(MDrsCalibrationTime);
36
37using namespace std;
38
39bool MDrsCalibrationTime::SetDelays(const TH1 &cam)
40{
41 if (cam.GetDimension()!=1)
42 return false;
43
44 fDelays.assign(cam.GetNbinsX(), 0);
45
46 for (int i=0; i<cam.GetNbinsX(); i++)
47 fDelays[i] = cam.GetBinContent(i+1);
48
49 return true;
50}
51
52void MDrsCalibrationTime::SetDelays(const TGraph &g)
53{
54 fDelays.assign(g.GetY(), g.GetY()+g.GetN());
55}
56
57bool MDrsCalibrationTime::ReadFits(TString fname)
58{
59 gSystem->ExpandPathName(fname);
60
61 string msg;
62 try
63 {
64 msg = DrsCalibrateTime::ReadFitsImp(fname.Data());
65 }
66 catch (const exception &e)
67 {
68 msg = e.what();
69 }
70
71 if (msg.empty())
72 {
73 *fLog << inf << "Read DRS calibration file " << fname << endl;
74 return true;
75 }
76
77 *fLog << err << "Error reading from " << fname << ": " << msg << endl;
78 return false;
79}
80
81bool MDrsCalibrationTime::WriteFits(const string &fname) const
82{
83 const Bool_t exists = !gSystem->AccessPathName(fname.c_str(), kFileExists);
84 if (exists)
85 {
86 *fLog << err << "File '" << fname << "' already exists." << endl;
87 return false;
88 }
89
90 string msg;
91 try
92 {
93 msg = DrsCalibrateTime::WriteFitsImp(fname);
94 }
95 catch (const exception &e)
96 {
97 msg = e.what();
98 }
99
100 if (msg.empty())
101 {
102 *fLog << inf << "Wrote DRS calibration file " << fname << endl;
103 return true;
104 }
105
106 *fLog << err << "Error writing to " << fname << ": " << msg << endl;
107 return false;
108}
Note: See TracBrowser for help on using the repository browser.