calibration classes and DB
[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   gr->Print();
142   fWalk.AddAtAndExpand(gr,ipmt);
143   file->Close();
144 }
145
146
147 //________________________________________________________________
148
149 void AliSTARTCalibData::SetSlewingLED(Int_t ipmt,const Char_t *filename)
150 {
151   Float_t mv, ps; 
152   Float_t x[100], y[100];
153   cout<<"capacity  "<<fSlewingLED.Capacity()<<endl;
154   string buffer;
155   
156   ifstream inFile(filename);
157   if(!inFile) {AliError(Form("Cannot open file %s !",filename));}
158   
159   inFile >> mv>>ps;
160   Int_t i=0;
161   
162   while(getline(inFile,buffer)){
163     x[i]=mv; y[i]=ps;   
164     inFile >> mv >> ps;
165     i++;
166   }
167   inFile.close();
168   TGraph* gr = new TGraph(i,x,y);
169   fSlewingLED.AddAtAndExpand(gr,ipmt);
170   cout<<"capacity end "<<fSlewingLED.Capacity()<<endl;
171
172   
173 }
174