]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/AliSTARTCalibData.cxx
(martin) pt vs eta correction matrix calculation macro using CorrectionMatrix2D class.
[u/mrichter/AliRoot.git] / START / AliSTARTCalibData.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 // class for T0 calibration                       TM-AC-AM_6-02-2006         //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include <iostream>
25 #include <fstream>
26 #include <iomanip>
27 #include <string>
28 #include <TCanvas.h>
29
30 #include "AliSTARTCalibData.h"
31 #include "TObjArray.h"
32 #include "TGraph.h"
33 #include "TFile.h"
34 #include "AliLog.h"
35 #include "TObjString.h"
36
37 #include "TAxis.h"
38 #include "TH2F.h"
39
40
41
42 ClassImp(AliSTARTCalibData)
43
44 //________________________________________________________________
45   AliSTARTCalibData::AliSTARTCalibData():   TNamed()
46
47 {
48   //
49 }
50
51 //________________________________________________________________
52 AliSTARTCalibData::AliSTARTCalibData(const char* name):TNamed()
53 {
54   TString namst = "Calib_";
55   namst += name;
56   SetName(namst.Data());
57   SetTitle(namst.Data());
58
59 }
60
61 //________________________________________________________________
62 AliSTARTCalibData::AliSTARTCalibData(const AliSTARTCalibData& calibda) :
63   TNamed(calibda)
64 {
65 // copy constructor
66   SetName(calibda.GetName());
67   SetTitle(calibda.GetName());
68
69
70 }
71
72 //________________________________________________________________
73 AliSTARTCalibData &AliSTARTCalibData::operator =(const AliSTARTCalibData& calibda)
74 {
75 // assignment operator
76   SetName(calibda.GetName());
77   SetTitle(calibda.GetName());
78  
79   return *this;
80 }
81
82 //________________________________________________________________
83 AliSTARTCalibData::~AliSTARTCalibData()
84 {
85
86 }
87 //________________________________________________________________
88 void AliSTARTCalibData::Reset()
89 {
90     memset(fTimeDelayCFD,1,24*sizeof(Float_t));
91     memset(fTimeDelayLED,1,24*sizeof(Float_t));
92     memset(fGain,1,24*sizeof(Float_t));
93 }
94
95
96 //________________________________________________________________
97 void  AliSTARTCalibData::Print(Option_t*) const
98 {
99
100   printf("\n    ----    PM Arrays       ----\n\n");
101   printf(" Time delay CFD \n");
102   for (Int_t i=0; i<24; i++) printf("  %f",fTimeDelayCFD[i]);
103   printf(" \n LED \n");
104   for (Int_t i=0; i<24; i++) printf("  %f",fTimeDelayLED[i]);
105   printf(" \n Gain \n");
106   for (Int_t i=0; i<24; i++) printf("  %f",fGain[i]);
107   printf(" \n");
108
109
110
111
112 //________________________________________________________________
113 void AliSTARTCalibData::SetTimeDelayCFD(Float_t* TimeDelay)
114 {
115   if(TimeDelay) for(int t=0; t<24; t++) fTimeDelayCFD[t] = TimeDelay[t];
116   //  else for(int t=0; t<24; t++) fTimeDelay[t] = 0.;
117 }
118 //________________________________________________________________
119 void AliSTARTCalibData::SetTimeDelayLED(Float_t* TimeDelay)
120 {
121   if(TimeDelay) for(int t=0; t<24; t++) fTimeDelayLED[t] = TimeDelay[t];
122   //  else for(int t=0; t<24; t++) fTimeDelay[t] = 0.;
123 }
124
125 //________________________________________________________________
126 void AliSTARTCalibData::SetGain(Float_t* Gain)
127 {
128   if(Gain) for(int t=0; t<24; t++) fGain[t] = Gain[t];
129   // else for(int t=0; t<24; t++) fGain[t] = 0.;
130 }
131
132
133 //________________________________________________________________
134 void AliSTARTCalibData::SetWalk(Int_t ipmt, const Char_t *filename)
135 {
136
137   TFile *file = new TFile(filename);
138   char funcname[256];
139   sprintf(funcname,"CFD%i",ipmt+1);
140   TF1* gr = (TF1*)file->Get(funcname);
141   fWalk.AddAtAndExpand(gr,ipmt);
142   file->Close();
143 }
144
145
146 //________________________________________________________________
147
148 void AliSTARTCalibData::SetSlewingLED(Int_t ipmt,const Char_t *filename)
149 {
150   Float_t mv, ps; 
151   Float_t x[100], y[100];
152   string buffer;
153   
154   ifstream inFile(filename);
155   if(!inFile) {AliError(Form("Cannot open file %s !",filename));}
156   
157   inFile >> mv>>ps;
158   Int_t i=0;
159   
160   while(getline(inFile,buffer)){
161     x[i]=mv; y[i]=ps;   
162     inFile >> mv >> ps;
163     i++;
164   }
165   inFile.close();
166   TGraph* gr = new TGraph(i,x,y);
167   fSlewingLED.AddAtAndExpand(gr,ipmt);
168    
169 }
170
171 //________________________________________________________________
172
173 void AliSTARTCalibData::SetSlewingRec(Int_t ipmt,const Char_t *filename)
174 {
175   Float_t mv, ps; 
176   Float_t x[100], y[100];
177   string buffer;
178   
179   ifstream inFile(filename);
180   if(!inFile) {AliError(Form("Cannot open file %s !",filename));}
181   
182   inFile >> mv>>ps;
183   Int_t i=0;
184   
185   while(getline(inFile,buffer)){
186     x[i]=mv; y[i]=ps;   
187     inFile >> mv >> ps;
188     i++;
189   }
190   inFile.close();
191   Float_t y1[100], x1[100];
192   for (Int_t ir=0; ir<i; ir++){
193     y1[ir]=y[i-ir]; x1[ir]=x[i-ir];}
194   TGraph* gr = new TGraph(i,y1,x1);
195   fSlewingRec.AddAtAndExpand(gr,ipmt);
196   
197 }
198
199