LCOV - code coverage report
Current view: top level - T0/T0base - AliT0Parameters.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 114 183 62.3 %
Date: 2016-06-14 17:26:59 Functions: 25 28 89.3 %

          Line data    Source code
       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             : // T0 - T0. 
      21             : //
      22             : // This class is a singleton that handles various parameters of
      23             : // the T0 detectors.  
      24             : // Eventually, this class will use the Conditions DB to get the
      25             : // various parameters, which code can then request from here.
      26             : //                                                       
      27             : #include "AliT0.h"
      28             : #include "AliLog.h"             
      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>  
      39             : #include <TMath.h>
      40             : #include <TSystem.h>
      41             : //#include <Riostream.h>
      42             : #include <TGeoManager.h>
      43             : #include <TGeoPhysicalNode.h>
      44             : #include <TGeoMatrix.h>
      45             : #include <AliGeomManager.h>
      46             : 
      47             : AliT0CalibTimeEq* AliT0Parameters::fgCalibData = 0;
      48             : AliT0CalibData* AliT0Parameters::fgLookUp = 0;
      49             : AliT0CalibWalk* AliT0Parameters::fgSlewCorr =0;
      50             : AliT0CalibLatency *AliT0Parameters::fgLatency=0;
      51             : //====================================================================
      52             : using std::cout;
      53          20 : ClassImp(AliT0Parameters)
      54             : #if 0
      55             :   ; // This is here to keep Emacs for indenting the next line
      56             : #endif
      57             : 
      58             : //____________________________________________________________________
      59             : AliT0Parameters* AliT0Parameters::fgInstance = 0;
      60             : //____________________________________________________________________
      61             : AliT0Parameters* AliT0Parameters::Instance() 
      62             : {
      63             :   // Get static instance 
      64          28 :   if (!fgInstance) {
      65           6 :     fgInstance = new AliT0Parameters;
      66           3 :   }
      67          14 :   return fgInstance;
      68           0 : }
      69             : 
      70             : //____________________________________________________________________
      71           3 : AliT0Parameters::AliT0Parameters()
      72           3 :   :fIsInit(kFALSE),
      73           3 :    fPh2Mip(0),fmV2Mip(0),
      74           3 :    fChannelWidth(0),fmV2Channel(0),
      75           3 :    fQTmin(0),fQTmax(0),
      76           3 :    fAmpLEDRec(0), 
      77           3 :    fPMTeff(),
      78           3 :    fWalk(0),
      79           3 :    fQTC(0),
      80           3 :    fAmpLED(0),
      81           3 :    fTimeDelayCFD(0), 
      82             :  //  fTimeV0(0), 
      83           3 :    fTimeDelayTVD(0),
      84           3 :    fMeanT0(512),
      85           3 :    fMeanVertex(0),
      86           3 :    fLatencyHPTDC(0),
      87           3 :    fLatencyL1(0),
      88           3 :    fLatencyL1A(0),
      89           3 :    fLatencyL1C(0),
      90           3 :    fLookUp(0),
      91           3 :    fNumberOfTRMs(2),
      92           3 :    fCalibentry(), 
      93           3 :    fLookUpentry(),
      94           3 :    fSlewCorr(),
      95           3 :    fLatency()
      96             :   
      97          15 : {
      98             :   // Default constructor 
      99         150 :   for (Int_t ipmt=0; ipmt<24; ipmt++)
     100             :     {
     101          72 :       SetPh2Mip();      
     102          72 :       SetmV2Mip();      
     103          72 :       SetChannelWidth();
     104          72 :       SetmV2channel();
     105          72 :       SetQTmin();
     106          72 :       SetQTmax();
     107          72 :       SetPMTeff(ipmt);
     108             :     }
     109           3 :   SetTimeDelayTVD();
     110           3 :   SetZposition();
     111             :     
     112           6 : }
     113             : 
     114             : //__________________________________________________________________
     115             : void
     116             : AliT0Parameters::Init()
     117             : {
     118             :   // Initialize the parameters manager.  We need to get stuff from the
     119             :   // CDB here. 
     120          26 :    if (fIsInit) return;
     121             : 
     122           3 :    AliCDBManager *stor =AliCDBManager::Instance();
     123             :    //time equalizing
     124           6 :    fCalibentry  = stor->Get("T0/Calib/TimeDelay");
     125           3 :    if (fCalibentry)
     126           3 :      fgCalibData  = (AliT0CalibTimeEq*)fCalibentry->GetObject();
     127             :    else {
     128           0 :          AliFatal(" ALARM !!!! No time delays in CDB "); 
     129           0 :      fIsInit = kFALSE;
     130           0 :      return;
     131             :    }
     132             :  //slewing correction
     133           6 :   fSlewCorr  = stor->Get("T0/Calib/Slewing_Walk");
     134           3 :   if (fSlewCorr){
     135           3 :     fgSlewCorr  = (AliT0CalibWalk*)fSlewCorr->GetObject();
     136             :   }
     137             :   else {
     138           0 :       AliFatal(" ALARM !!!! No slewing correction in CDB "); 
     139           0 :     fIsInit = kFALSE;
     140           0 :     return;
     141             :   }
     142             :   //lookup table
     143           6 :   fLookUpentry  = stor->Get("T0/Calib/LookUp_Table");
     144           3 :   if (fLookUpentry){
     145           3 :     fgLookUp  = (AliT0CalibData*)fLookUpentry->GetObject();
     146             :   }
     147             :   else {
     148           0 :      AliFatal(" ALARM !!!! No Lookup table  in CDB "); 
     149           0 :     fIsInit = kFALSE;
     150           0 :     return;
     151             :   }
     152             :   //latency
     153             :   
     154           6 :  fLatency  = stor->Get("T0/Calib/Latency");
     155           3 :   if (fLatency){
     156           3 :     fgLatency  = (AliT0CalibLatency*)fLatency->GetObject();
     157             :   }
     158             :   else {
     159           0 :      AliWarning(" !!! no latency  in CDB "); 
     160           0 :     return;
     161             :   }
     162             :   
     163           3 : fIsInit = kTRUE;
     164          16 : }
     165             : 
     166             : 
     167             : //__________________________________________________________________
     168             : 
     169             : void AliT0Parameters::InitIfOnline()
     170             : {
     171             : // should be used in online
     172             : // for switching to this one should write
     173             :   // AliT0RawReader myrawreader(rawReader);
     174             : //      myrawreader.SetOnlineMode(kTRUE);
     175             :   
     176           0 :   if (fIsInit) return;
     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           0 :   fgLookUp = new AliT0CalibData("T0");
     181             :   
     182           0 :   fNumberOfTRMs = 2;
     183           0 :   fgLookUp-> SetNumberOfTRMs(fNumberOfTRMs);
     184             :   Int_t trm=7;
     185             :   Int_t tdc=0;  Int_t channel=0;
     186             :   Int_t ikey=0; Int_t chain=0;
     187           0 :   for (Int_t ik=0; ik<226; ik++)
     188             :     {
     189           0 :      if (ik==57) {trm=7; chain=1; tdc=0; channel=0;}
     190           0 :       if (ik==107) { trm=9; chain=0; tdc=0; channel=0;}
     191           0 :       if (ik==163) { trm=9; chain=1; tdc=0; channel=0;}
     192           0 :       if (ik==211) { trm=7; chain=1; tdc=14; channel=0;}
     193           0 :       if (ik==215) { trm=9; chain=1; tdc=12; channel=0;}
     194           0 :       AliT0LookUpKey * lookkey= new AliT0LookUpKey();
     195           0 :       AliT0LookUpValue * lookvalue= new AliT0LookUpValue();
     196           0 :       lookvalue->SetTRM(trm);
     197           0 :       lookvalue->SetTDC(tdc);
     198           0 :       lookvalue->SetChain(chain);
     199           0 :       lookvalue->SetChannel(channel);
     200           0 :       lookkey->SetKey(ik);
     201           0 :       fgLookUp->GetMapLookup()->Add((TObject*)lookvalue,(TObject*)lookkey);
     202             :       //       printf(" LookUp ik %i trm %i chain %i tdc %i  channel %i\n",ik, trm, chain, tdc, channel);     
     203           0 :       if (channel<6) channel +=2;
     204           0 :       else {channel = 0; tdc++;}
     205           0 :        ikey++;     
     206             :     }
     207             :   
     208           0 :   fIsInit=kTRUE;
     209           0 : }
     210             : //__________________________________________________________________
     211             : Float_t
     212             : AliT0Parameters::GetTimeDelayCFD(Int_t ipmt) 
     213             :   {
     214             :   // return time delay for CFD channel
     215             :    // 
     216         500 :   if (!fCalibentry) 
     217             :     {
     218           0 :       fTimeDelayCFD = 1000+ipmt*100;
     219           0 :       return fTimeDelayCFD;
     220             :     }
     221             :    
     222         250 :   return fgCalibData->GetTimeEq(ipmt);
     223         250 : }
     224             : //__________________________________________________________________
     225             : Float_t
     226             : AliT0Parameters::GetCFD(Int_t ipmt) 
     227             :   {
     228             :   // return  CFD channel
     229             :    
     230          96 :     return fgCalibData->GetCFDvalue(ipmt,0);
     231             : }
     232             : //__________________________________________________________________
     233             : Float_t
     234             : AliT0Parameters::GetQT1(Int_t ipmt) 
     235             :   {
     236             :   // return  CFD channel
     237             :    
     238          96 :     return fgCalibData->GetCFDvalue(ipmt,1);
     239             : }
     240             : //__________________________________________________________________
     241             : Float_t
     242             : AliT0Parameters::GetPedestalOld(Int_t ipmt) 
     243             :   {
     244             :   // return  CFD channel
     245             :    
     246          96 :     return fgCalibData->GetCFDvalue(ipmt,3);
     247             : }
     248             : //__________________________________________________________________
     249             : Float_t
     250             : AliT0Parameters::GetMeanOrA() 
     251             :   {
     252             :   // return  CFD channel
     253             :    
     254           4 :     return fgCalibData->GetCFDvalue(0,2);
     255             : }
     256             : Float_t
     257             : AliT0Parameters::GetMeanOrC() 
     258             :   {
     259             :   // return  CFD channel
     260             :    
     261           4 :     return fgCalibData->GetCFDvalue(1,2);
     262             : }
     263             : Float_t
     264             : AliT0Parameters::GetMeanTVDC() 
     265             :   {
     266             :   // return  CFD channel
     267             :    
     268           0 :     return fgCalibData->GetMeanVertex();
     269             : }
     270             : 
     271             : //__________________________________________________________________
     272             : Float_t
     273             : AliT0Parameters::GetLatencyHPTDC() 
     274             :   {
     275             :   // return LatencyHPTDC for CFD channel
     276           4 :   if (!fLatency) 
     277             :     {
     278           0 :       fLatencyHPTDC=9000.;
     279           0 :       return fLatencyHPTDC;
     280             :     }
     281             :    
     282           2 :   return fgLatency->GetLatencyHPTDC();
     283           2 : }
     284             : //__________________________________________________________________
     285             : Float_t
     286             : AliT0Parameters::GetLatencyL1() 
     287             :   {
     288             :   // return time delay for CFD channel
     289             :    
     290           4 :   return fgLatency->GetLatencyL1();
     291             : }
     292             : 
     293             : //__________________________________________________________________
     294             : Float_t
     295             : AliT0Parameters::GetLatencyL1A() 
     296             :   {
     297             :   // return time delay for CFD channel
     298             :    
     299           4 :   return fgLatency->GetLatencyL1A();
     300             : }
     301             : 
     302             : //__________________________________________________________________
     303             : Float_t
     304             : AliT0Parameters::GetLatencyL1C() 
     305             :   {
     306             :   // return time delay for CFD channel
     307             :    
     308           4 :   return fgLatency->GetLatencyL1C();
     309             : }
     310             : //__________________________________________________________________
     311             : 
     312             : Float_t
     313             : AliT0Parameters:: GetMeanVertex()
     314             : { 
     315           4 :   if (!fCalibentry) 
     316             :     {
     317           0 :       fMeanVertex=0;
     318           0 :       return fMeanVertex;
     319             :     }
     320             :    
     321           2 :   return fgCalibData->GetMeanVertex();
     322           2 : }
     323             : //__________________________________________________________________
     324             : 
     325             : TGraph *AliT0Parameters::GetAmpLEDRec(Int_t ipmt) const
     326             : {
     327          96 :    if (!fSlewCorr) {
     328           0 :      AliError("No slewing correction is available!");
     329           0 :      return  (TGraph*)fAmpLEDRec.At(ipmt); 
     330             :   } 
     331          48 :   return fgSlewCorr -> GetAmpLEDRec(ipmt) ;
     332          48 : }
     333             : 
     334             : //__________________________________________________________________
     335             : 
     336             : TGraph *AliT0Parameters::GetWalk(Int_t ipmt) const
     337             : {
     338         108 :   if (!fSlewCorr) {
     339           0 :     AliError("No walk correction is available!");
     340           0 :     return  (TGraph*)fWalk.At(ipmt); 
     341             :   } 
     342          54 :   return fgSlewCorr -> GetWalk(ipmt) ;
     343          54 : }
     344             : 
     345             : //__________________________________________________________________
     346             : 
     347             : TGraph *AliT0Parameters::GetQTC(Int_t ipmt) const
     348             : {
     349         144 :   if (!fSlewCorr) {
     350           0 :     AliError("No walk correction is available!");
     351             :     //    return  (TGraph*)fQTC.At(ipmt); 
     352           0 :    return  0; 
     353             :   } 
     354          72 :   return fgSlewCorr -> GetQTC(ipmt) ;
     355          72 : }
     356             : 
     357             : //__________________________________________________________________
     358             : TGraph *AliT0Parameters::GetAmpLED(Int_t ipmt) const
     359             : {
     360         144 :   if (!fSlewCorr) {
     361           0 :     AliError("No walk correction is available!");
     362             :     //    return  (TGraph*)fQTC.At(ipmt); 
     363           0 :    return  0; 
     364             :   } 
     365          72 :   return fgSlewCorr -> GetAmpLED(ipmt) ;
     366          72 : }
     367             : 
     368             : //__________________________________________________________________
     369             : void 
     370             : AliT0Parameters::SetPMTeff(Int_t ipmt)
     371             : {
     372         144 :   Float_t lambda[50];
     373          72 :   Float_t eff[50 ] = {0,        0,       0.23619,  0.202909, 0.177913, 
     374             :                     0.175667, 0.17856, 0.190769, 0.206667, 0.230286,
     375             :                     0.252276, 0.256267,0.26,     0.27125,  0.281818,
     376             :                     0.288118, 0.294057,0.296222, 0.301622, 0.290421, 
     377             :                     0.276615, 0.2666,  0.248,    0.23619,  0.227814, 
     378             :                     0.219818, 0.206667,0.194087, 0.184681, 0.167917, 
     379             :                     0.154367, 0.1364,  0.109412, 0.0834615,0.0725283, 
     380             :                     0.0642963,0.05861, 0.0465,   0.0413333,0.032069, 
     381             :                     0.0252203,0.02066, 0.016262, 0.012,    0.00590476,
     382             :                     0.003875, 0.00190, 0,        0,        0          } ;
     383        7344 :   for (Int_t i=0; i<50; i++) lambda[i]=200+10*i; 
     384             : 
     385          72 :   TGraph* gr = new TGraph(50,lambda,eff);
     386          72 :   fPMTeff.AddAtAndExpand(gr,ipmt);
     387          72 : }
     388             : //________________________________________________________________
     389             : 
     390             : Int_t 
     391             : AliT0Parameters::GetChannel(Int_t trm,  Int_t tdc, Int_t chain, Int_t channel)
     392             : {
     393             : 
     394          48 :   if (fgLookUp) {
     395          24 :     AliT0LookUpValue key(trm,tdc,chain,channel);
     396          48 :       AliT0LookUpKey *val = (AliT0LookUpKey*) fgLookUp->GetMapLookup()->GetValue((TObject*)&key);
     397             :       // AliT0LookUpKey *val = (AliT0LookUpKey*) fLookUp.GetValue((TObject*)&key);
     398          24 :     if (val )
     399          24 :       return val->GetKey();
     400             :     else {
     401           0 :       AliWarning(Form("No such address (%d %d %d %d)!",trm,tdc,chain,channel));
     402           0 :       return -1;
     403             :     }
     404          24 :   }
     405             :   else {
     406           0 :     AliError("No look up table has been loader!");
     407           0 :     return -1;
     408             :   }
     409             : 
     410          24 : }
     411             : //__________________________________________________________________
     412             : TMap *AliT0Parameters::GetMapLookup()
     413             : {
     414           8 :   if (!fgLookUp){
     415           0 :     cout<<" No look up table in OCDB";
     416           0 :     return 0;
     417             :   }
     418           4 :   return   fgLookUp->GetMapLookup();
     419           4 : }
     420             : //__________________________________________________________________
     421             : 
     422             : Int_t
     423             : AliT0Parameters::GetNumberOfTRMs() 
     424             : {
     425             :   // return number of trms
     426             :   // 
     427           8 :   if (!fgLookUp) {
     428             :     //  fNumberOfTRMs = 2;
     429           0 :     return  fNumberOfTRMs;
     430             :   } 
     431           4 :   return  fgLookUp ->GetNumberOfTRMs();
     432           4 : }
     433             : /*
     434             : //________________________________________________________________________________
     435             : Double_t AliT0Parameters::GetZPosition(const char* symname){
     436             : // Get the global z coordinate of the given T0 alignable volume
     437             : //
     438             :   Double_t *tr = AliGeomManager::GetMatrix(symname)->GetTranslation();
     439             : 
     440             :   return tr[2];
     441             : }
     442             : */
     443             : //________________________________________________________________________________
     444             : Double_t AliT0Parameters::GetZPosition(const char* symname){
     445             : // Get the global z coordinate of the given T0 alignable volume
     446             : //
     447             :   Double_t *tr;
     448          24 :   TGeoPNEntry *pne = gGeoManager->GetAlignableEntry(symname);
     449          12 :   if (!pne) return 0;
     450             :   
     451             : 
     452          12 :   TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
     453          12 :   if(pnode){
     454          12 :           TGeoHMatrix* hm = pnode->GetMatrix();
     455          12 :            tr = hm->GetTranslation();
     456          12 :   }else{
     457           0 :           const char* path = pne->GetTitle();
     458           0 :           if(!gGeoManager->cd(path)){
     459           0 :                   AliErrorClass(Form("Volume path %s not valid!",path));
     460           0 :                   return 0;
     461             :           }
     462           0 :          tr = gGeoManager->GetCurrentMatrix()->GetTranslation();
     463           0 :   }
     464          12 :   return tr[2];
     465             : 
     466          12 : }
     467             : //________________________________________________________________________________
     468             : 
     469             : Double_t AliT0Parameters::GetZPositionShift(const char* symname)
     470             : {
     471             : // Get the global z coordinate of the given T0 alignable volume
     472             : //
     473           0 :   Double_t *tr = AliGeomManager::GetMatrix(symname)->GetTranslation();
     474             : 
     475           0 :   TGeoHMatrix origmat;
     476           0 :   AliGeomManager::GetOrigGlobalMatrix(symname,origmat);
     477           0 :   Double_t *otr = origmat.GetTranslation();
     478             : 
     479           0 :   return (tr[2]-otr[2]);
     480           0 : }
     481             : 

Generated by: LCOV version 1.11