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 //____________________________________________________________________
22 // This class is a singleton that handles various parameters of
24 // Eventually, this class will use the Conditions DB to get the
25 // various parameters, which code can then request from here.
29 #include "AliT0Parameters.h"
30 #include "AliT0CalibData.h"
31 #include "AliT0CalibWalk.h"
32 #include "AliT0CalibTimeEq.h"
33 #include "AliT0CalibLatency.h"
34 #include "AliT0LookUpKey.h"
35 #include "AliT0LookUpValue.h"
36 #include <AliCDBManager.h>
37 #include <AliCDBEntry.h>
38 #include <AliCDBStorage.h>
41 //#include <Riostream.h>
42 #include <TGeoManager.h>
43 #include <TGeoPhysicalNode.h>
44 #include <TGeoMatrix.h>
45 #include <AliGeomManager.h>
47 AliT0CalibTimeEq* AliT0Parameters::fgCalibData = 0;
48 AliT0CalibData* AliT0Parameters::fgLookUp = 0;
49 AliT0CalibWalk* AliT0Parameters::fgSlewCorr =0;
50 AliT0CalibLatency *AliT0Parameters::fgLatency=0;
51 //====================================================================
53 ClassImp(AliT0Parameters)
55 ; // This is here to keep Emacs for indenting the next line
58 //____________________________________________________________________
59 AliT0Parameters* AliT0Parameters::fgInstance = 0;
60 //____________________________________________________________________
61 AliT0Parameters* AliT0Parameters::Instance()
63 // Get static instance
65 fgInstance = new AliT0Parameters;
70 //____________________________________________________________________
71 AliT0Parameters::AliT0Parameters()
73 fPh2Mip(0),fmV2Mip(0),
74 fChannelWidth(0),fmV2Channel(0),
98 // Default constructor
99 for (Int_t ipmt=0; ipmt<24; ipmt++)
114 //__________________________________________________________________
116 AliT0Parameters::Init()
118 // Initialize the parameters manager. We need to get stuff from the
122 AliCDBManager *stor =AliCDBManager::Instance();
124 fCalibentry = stor->Get("T0/Calib/TimeDelay");
126 fgCalibData = (AliT0CalibTimeEq*)fCalibentry->GetObject();
128 AliFatal(" ALARM !!!! No time delays in CDB ");
133 fSlewCorr = stor->Get("T0/Calib/Slewing_Walk");
135 fgSlewCorr = (AliT0CalibWalk*)fSlewCorr->GetObject();
138 AliFatal(" ALARM !!!! No slewing correction in CDB ");
143 fLookUpentry = stor->Get("T0/Calib/LookUp_Table");
145 fgLookUp = (AliT0CalibData*)fLookUpentry->GetObject();
148 AliFatal(" ALARM !!!! No Lookup table in CDB ");
154 fLatency = stor->Get("T0/Calib/Latency");
156 fgLatency = (AliT0CalibLatency*)fLatency->GetObject();
159 AliWarning(" !!! no latency in CDB ");
167 //__________________________________________________________________
169 void AliT0Parameters::InitIfOnline()
171 // should be used in online
172 // for switching to this one should write
173 // AliT0RawReader myrawreader(rawReader);
174 // myrawreader.SetOnlineMode(kTRUE);
177 //standart configuration (used for simulation)
178 //Int_t trm=0; Int_t tdc=0; Int_t chain=0; Int_t channel=0;
179 // configuration for test Jun07.
180 fgLookUp = new AliT0CalibData("T0");
183 fgLookUp-> SetNumberOfTRMs(fNumberOfTRMs);
184 Int_t trm=7; Int_t tdc=0; Int_t chain=0; Int_t channel=0;
185 for (Int_t ik=0; ik<105; ik++)
187 AliT0LookUpKey * lookkey= new AliT0LookUpKey();
188 AliT0LookUpValue * lookvalue= new AliT0LookUpValue();
189 lookvalue->SetTRM(trm);
190 lookvalue->SetTDC(tdc);
191 lookvalue->SetChain(chain);
192 lookvalue->SetChannel(channel);
194 fgLookUp->GetMapLookup()->Add((TObject*)lookvalue,(TObject*)lookkey);
195 if (channel<6) channel +=2;
196 else {channel = 0; tdc++;}
197 if(ik==56) { tdc=0; channel=0; chain = 1;}
199 //2 recent open channels
200 trm=7; tdc=14; channel=2; chain=0;
201 for (Int_t ik=105; ik<107; ik++)
203 AliT0LookUpKey * lookkey= new AliT0LookUpKey();
204 AliT0LookUpValue * lookvalue= new AliT0LookUpValue();
206 lookvalue->SetTRM(trm);
207 lookvalue->SetTDC(tdc);
208 lookvalue->SetChain(chain);
209 lookvalue->SetChannel(channel);
211 fgLookUp->GetMapLookup()->Add((TObject*)lookvalue,(TObject*)lookkey);
212 if (channel<6) channel +=2;
213 else {channel = 0; tdc++;}
218 //__________________________________________________________________
220 AliT0Parameters::GetTimeDelayCFD(Int_t ipmt)
222 // return time delay for CFD channel
226 fTimeDelayCFD = 1000+ipmt*100;
227 return fTimeDelayCFD;
230 return fgCalibData->GetTimeEq(ipmt);
232 //__________________________________________________________________
234 AliT0Parameters::GetCFD(Int_t ipmt)
236 // return CFD channel
238 return fgCalibData->GetCFDvalue(ipmt,0);
241 //__________________________________________________________________
243 AliT0Parameters::GetLatencyHPTDC()
245 // return LatencyHPTDC for CFD channel
249 return fLatencyHPTDC;
252 return fgLatency->GetLatencyHPTDC();
254 //__________________________________________________________________
256 AliT0Parameters::GetLatencyL1()
258 // return time delay for CFD channel
260 return fgLatency->GetLatencyL1();
263 //__________________________________________________________________
265 AliT0Parameters::GetLatencyL1A()
267 // return time delay for CFD channel
269 return fgLatency->GetLatencyL1A();
272 //__________________________________________________________________
274 AliT0Parameters::GetLatencyL1C()
276 // return time delay for CFD channel
278 return fgLatency->GetLatencyL1C();
280 //__________________________________________________________________
283 AliT0Parameters:: GetMeanVertex()
291 return fgCalibData->GetMeanVertex();
293 //__________________________________________________________________
295 TGraph *AliT0Parameters::GetAmpLEDRec(Int_t ipmt) const
298 AliError("No slewing correction is available!");
299 return (TGraph*)fAmpLEDRec.At(ipmt);
301 return fgSlewCorr -> GetAmpLEDRec(ipmt) ;
304 //__________________________________________________________________
306 TGraph *AliT0Parameters::GetWalk(Int_t ipmt) const
309 AliError("No walk correction is available!");
310 return (TGraph*)fWalk.At(ipmt);
312 return fgSlewCorr -> GetWalk(ipmt) ;
315 //__________________________________________________________________
317 TGraph *AliT0Parameters::GetQTC(Int_t ipmt) const
320 AliError("No walk correction is available!");
321 // return (TGraph*)fQTC.At(ipmt);
324 return fgSlewCorr -> GetQTC(ipmt) ;
327 //__________________________________________________________________
328 TGraph *AliT0Parameters::GetAmpLED(Int_t ipmt) const
331 AliError("No walk correction is available!");
332 // return (TGraph*)fQTC.At(ipmt);
335 return fgSlewCorr -> GetAmpLED(ipmt) ;
338 //__________________________________________________________________
340 AliT0Parameters::SetPMTeff(Int_t ipmt)
343 Float_t eff[50 ] = {0, 0, 0.23619, 0.202909, 0.177913,
344 0.175667, 0.17856, 0.190769, 0.206667, 0.230286,
345 0.252276, 0.256267,0.26, 0.27125, 0.281818,
346 0.288118, 0.294057,0.296222, 0.301622, 0.290421,
347 0.276615, 0.2666, 0.248, 0.23619, 0.227814,
348 0.219818, 0.206667,0.194087, 0.184681, 0.167917,
349 0.154367, 0.1364, 0.109412, 0.0834615,0.0725283,
350 0.0642963,0.05861, 0.0465, 0.0413333,0.032069,
351 0.0252203,0.02066, 0.016262, 0.012, 0.00590476,
352 0.003875, 0.00190, 0, 0, 0 } ;
353 for (Int_t i=0; i<50; i++) lambda[i]=200+10*i;
355 TGraph* gr = new TGraph(50,lambda,eff);
356 fPMTeff.AddAtAndExpand(gr,ipmt);
358 //________________________________________________________________
361 AliT0Parameters::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel)
365 AliT0LookUpValue key(trm,tdc,chain,channel);
366 AliT0LookUpKey *val = (AliT0LookUpKey*) fgLookUp->GetMapLookup()->GetValue((TObject*)&key);
367 // AliT0LookUpKey *val = (AliT0LookUpKey*) fLookUp.GetValue((TObject*)&key);
369 return val->GetKey();
371 AliWarning(Form("No such address (%d %d %d %d)!",trm,tdc,chain,channel));
376 AliError("No look up table has been loader!");
381 //__________________________________________________________________
382 TMap *AliT0Parameters::GetMapLookup()
385 cout<<" No look up table in OCDB";
388 return fgLookUp->GetMapLookup();
390 //__________________________________________________________________
393 AliT0Parameters::GetNumberOfTRMs()
395 // return number of trms
398 // fNumberOfTRMs = 2;
399 return fNumberOfTRMs;
401 return fgLookUp ->GetNumberOfTRMs();
404 //________________________________________________________________________________
405 Double_t AliT0Parameters::GetZPosition(const char* symname){
406 // Get the global z coordinate of the given T0 alignable volume
408 Double_t *tr = AliGeomManager::GetMatrix(symname)->GetTranslation();
413 //________________________________________________________________________________
414 Double_t AliT0Parameters::GetZPosition(const char* symname){
415 // Get the global z coordinate of the given T0 alignable volume
418 TGeoPNEntry *pne = gGeoManager->GetAlignableEntry(symname);
422 TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
424 TGeoHMatrix* hm = pnode->GetMatrix();
425 tr = hm->GetTranslation();
427 const char* path = pne->GetTitle();
428 if(!gGeoManager->cd(path)){
429 AliErrorClass(Form("Volume path %s not valid!",path));
432 tr = gGeoManager->GetCurrentMatrix()->GetTranslation();
437 //________________________________________________________________________________
439 Double_t AliT0Parameters::GetZPositionShift(const char* symname)
441 // Get the global z coordinate of the given T0 alignable volume
443 Double_t *tr = AliGeomManager::GetMatrix(symname)->GetTranslation();
446 AliGeomManager::GetOrigGlobalMatrix(symname,origmat);
447 Double_t *otr = origmat.GetTranslation();
449 return (tr[2]-otr[2]);