1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for T0 calibration TM-AC-AM_6-02-2006 //
22 ///////////////////////////////////////////////////////////////////////////////
30 #include "AliT0CalibData.h"
31 #include "AliT0LookUpValue.h"
32 #include "TObjArray.h"
36 #include "TObjString.h"
43 ClassImp(AliT0CalibData)
45 //________________________________________________________________
46 AliT0CalibData::AliT0CalibData(): TNamed()
52 //________________________________________________________________
53 AliT0CalibData::AliT0CalibData(const char* name):TNamed(),fTimeDelayTVD(0),fWalk(),fSlewingLED(),fSlewingRec()
55 TString namst = "Calib_";
57 SetName(namst.Data());
58 SetTitle(namst.Data());
62 //________________________________________________________________
63 AliT0CalibData::AliT0CalibData(const AliT0CalibData& calibda) :
64 TNamed(calibda),fTimeDelayTVD(0),fWalk(),fSlewingLED(),fSlewingRec()
67 SetName(calibda.GetName());
68 SetTitle(calibda.GetName());
73 //________________________________________________________________
74 AliT0CalibData &AliT0CalibData::operator =(const AliT0CalibData& calibda)
76 // assignment operator
77 SetName(calibda.GetName());
78 SetTitle(calibda.GetName());
83 //________________________________________________________________
84 AliT0CalibData::~AliT0CalibData()
88 //________________________________________________________________
89 void AliT0CalibData::Reset()
91 memset(fTimeDelayCFD,1,24*sizeof(Float_t));
92 memset(fTimeDelayLED,1,24*sizeof(Float_t));
93 memset(fGain,1,24*sizeof(Float_t));
97 //________________________________________________________________
98 void AliT0CalibData::Print(Option_t*) const
101 printf("\n ---- PM Arrays ----\n\n");
102 printf(" Time delay CFD \n");
103 for (Int_t i=0; i<24; i++) printf(" %f",fTimeDelayCFD[i]);
104 printf(" \n LED \n");
105 for (Int_t i=0; i<24; i++) printf(" %f",fTimeDelayLED[i]);
106 printf(" \n Gain \n");
107 for (Int_t i=0; i<24; i++) printf(" %f",fGain[i]);
111 //________________________________________________________________
112 void AliT0CalibData::PrintLookup(Option_t*, Int_t iTRM, Int_t iTDC, Int_t iChannel) const
115 AliT0LookUpKey* lookkey= new AliT0LookUpKey();
116 AliT0LookUpValue* lookvalue= new AliT0LookUpValue();
118 lookvalue->SetTRM(iTRM);
119 lookvalue->SetTDC(iTDC);
120 lookvalue->SetChain(0);
121 lookvalue->SetChannel(iChannel);
123 printf(" AliT0CalibData::PrintLookup ::start GetValue %i %i %i \n",iTRM, iTDC, iChannel);
124 lookkey = (AliT0LookUpKey*) fLookup.GetValue((TObject*)lookvalue);
126 cout<<" AliT0CalibData::PrintLookup :: lookkey "<< lookkey<<endl;
129 cout<<" lookup KEY!!! "<<lookkey->GetKey()<<" VALUE "<<lookvalue->GetTRM()<<" "
130 <<lookvalue->GetTDC()<<" "
131 << lookvalue->GetChain()<<" "
132 <<lookvalue->GetChannel()<<endl;
138 //________________________________________________________________
139 void AliT0CalibData::SetTimeDelayCFD(Float_t* TimeDelay)
141 if(TimeDelay) for(int t=0; t<24; t++) fTimeDelayCFD[t] = TimeDelay[t];
142 // else for(int t=0; t<24; t++) fTimeDelay[t] = 0.;
144 //________________________________________________________________
145 void AliT0CalibData::SetTimeDelayLED(Float_t* TimeDelay)
147 if(TimeDelay) for(int t=0; t<24; t++) fTimeDelayLED[t] = TimeDelay[t];
148 // else for(int t=0; t<24; t++) fTimeDelay[t] = 0.;
151 //________________________________________________________________
152 void AliT0CalibData::SetGain(Float_t* Gain)
154 if(Gain) for(int t=0; t<24; t++) fGain[t] = Gain[t];
155 // else for(int t=0; t<24; t++) fGain[t] = 0.;
159 //________________________________________________________________
160 void AliT0CalibData::SetWalk(Int_t ipmt, const Char_t *filename)
163 TFile *file = new TFile(filename);
165 sprintf(funcname,"CFD%i",ipmt+1);
166 TF1* gr = (TF1*)file->Get(funcname);
167 fWalk.AddAtAndExpand(gr,ipmt);
172 //________________________________________________________________
174 void AliT0CalibData::SetSlewingLED(Int_t ipmt,const Char_t *filename)
177 Float_t x[100], y[100];
180 ifstream inFile(filename);
181 if(!inFile) {AliError(Form("Cannot open file %s !",filename));}
186 while(getline(inFile,buffer)){
192 TGraph* gr = new TGraph(i,x,y);
193 fSlewingLED.AddAtAndExpand(gr,ipmt);
197 //________________________________________________________________
199 void AliT0CalibData::SetSlewingRec(Int_t ipmt,const Char_t *filename)
202 Float_t x[100], y[100];
205 ifstream inFile(filename);
206 if(!inFile) {AliError(Form("Cannot open file %s !",filename));}
211 while(getline(inFile,buffer)){
217 Float_t y1[100], x1[100];
218 for (Int_t ir=0; ir<i; ir++){
219 y1[ir]=y[i-ir]; x1[ir]=x[i-ir];}
220 TGraph* gr = new TGraph(i,y1,x1);
221 fSlewingRec.AddAtAndExpand(gr,ipmt);
226 void AliT0CalibData::ReadAsciiLookup(const Char_t *filename)
230 AliError(Form("Please, specify file with database")) ;
234 // AliT0LookUpKey * lookkey= new AliT0LookUpKey();
235 //AliT0LookUpValue * lookvalue= new AliT0LookUpValue();
238 lookup.open(filename);
239 if(!lookup) {AliError(Form("Cannot open file %s !",filename));}
241 Int_t key, trm, tdc, chain, channel;
242 // while(lookup.eof())
244 for (Int_t i=0; i<108; i++)
245 // for (Int_t i=0;i<3;i++)
247 AliT0LookUpKey * lookkey= new AliT0LookUpKey();
248 AliT0LookUpValue * lookvalue= new AliT0LookUpValue();
250 lookup>>varname>>key>>trm>>chain>>tdc>>channel;
251 lookvalue->SetTRM(trm);
252 lookvalue->SetTDC(tdc);
253 lookvalue->SetChain(chain);
254 lookvalue->SetChannel(channel);
255 lookkey->SetKey(key);
257 // cout<<"TRM="<<trm<<" TDC="<<tdc<<" chain="<<chain<<" channel="<<channel<<" key="<<key<<endl;
259 cout<<"AliT0CalibData:: "<<varname<<" "<<key<<" "<<trm<<" "<<chain<<" "<<tdc<<" "<<channel<<endl;
261 // fLookup.Add((TObject*)lookkey,(TObject*)lookvalue);
262 // ar_key.AddAt(lookkey,i);
263 // ar_val.AddAt(lookvalue,i);
265 fLookup.Add((TObject*)lookvalue,(TObject*)lookkey);
273 //________________________________________________________________
275 Int_t AliT0CalibData::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel)
278 AliT0LookUpKey * lookkey;//= new AliT0LookUpKey();
279 AliT0LookUpValue * lookvalue= new AliT0LookUpValue(trm,tdc,chain,channel);
281 lookkey = (AliT0LookUpKey*) fLookup.GetValue((TObject*)lookvalue);
282 cout<<"AliT0CalibData:: key "<<lookkey->GetKey()<<endl;
283 return lookkey->GetKey();