LCOV - code coverage report
Current view: top level - VZERO/VZERObase - AliVZEROCalibData.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 69 381 18.1 %
Date: 2016-06-14 17:26:59 Functions: 11 49 22.4 %

          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: AliVZEROCalibData.cxx,                                            */
      17             : 
      18             : /////////////////////////////////////////////////////////////////////////////
      19             : //                                                                         //
      20             : // class for VZERO calibration                                             //
      21             : //                                                                         //
      22             : /////////////////////////////////////////////////////////////////////////////
      23             : 
      24             : #include <TMath.h>
      25             : #include <TObjString.h>
      26             : #include <TMap.h>
      27             : #include <TH1F.h>
      28             : #include <TH2F.h>
      29             : #include <TF1.h>
      30             : 
      31             : #include "AliDCSValue.h"
      32             : #include "AliCDBManager.h"
      33             : #include "AliCDBEntry.h"
      34             : #include "AliVZEROCalibData.h"
      35             : #include "AliVZERODataDCS.h"
      36             : #include "AliVZEROConst.h"
      37             : #include "AliVZEROTriggerData.h"
      38             : #include "AliLog.h"
      39             : 
      40          44 : ClassImp(AliVZEROCalibData)
      41             : 
      42             : //________________________________________________________________
      43           3 : AliVZEROCalibData::AliVZEROCalibData():
      44           3 :   fIsCalThrInit(kFALSE),
      45           3 :   fLightYields(NULL),
      46           3 :   fPMGainsA(NULL),
      47           3 :   fPMGainsB(NULL)
      48          15 : {
      49             :   // default constructor
      50             :   
      51         390 :     for(int t=0; t<64; t++) {
      52         192 :         fMeanHV[t]      = 100.0;
      53         192 :         fWidthHV[t]     = 0.0; 
      54         192 :         fTimeOffset[t]  = 5.0;
      55         192 :         fTimeGain[t]    = 1.0;
      56         192 :         fDeadChannel[t]= kFALSE;
      57         192 :         fDiscriThr[t]  = 2.5;
      58         192 :         fCalDiscriThr[t] = -1024;
      59             :     }
      60         774 :     for(int t=0; t<128; t++) {
      61         384 :         fPedestal[t]    = 0.0;     
      62         384 :         fSigma[t]       = 0.0;        
      63         384 :         fADCmean[t]     = 0.0;      
      64         384 :         fADCsigma[t]    = 0.0;
      65             :     }
      66          54 :     for(int i=0; i<kNCIUBoards ;i++) {
      67          24 :         fTimeResolution[i]  = 25./256.;     // Default time resolution
      68          24 :         fWidthResolution[i] = 25./64.;     // Default time width resolution
      69          24 :         fMatchWindow[i] = 4;
      70          24 :         fSearchWindow[i] = 16;
      71          24 :         fTriggerCountOffset[i] = 3247;
      72          24 :         fRollOver[i] = 3563;
      73             :     }
      74             : 
      75           6 : }
      76             : 
      77             : //________________________________________________________________
      78             : void AliVZEROCalibData::Reset()
      79             : {
      80             :   // reset 
      81           0 : }
      82             : 
      83             : //________________________________________________________________
      84           0 : AliVZEROCalibData::AliVZEROCalibData(const char* name):
      85           0 :   fIsCalThrInit(kFALSE),
      86           0 :   fLightYields(NULL),
      87           0 :   fPMGainsA(NULL),
      88           0 :   fPMGainsB(NULL)
      89           0 : {
      90             :   // Constructor
      91           0 :    TString namst = "Calib_";
      92           0 :    namst += name;
      93           0 :    SetName(namst.Data());
      94           0 :    SetTitle(namst.Data());
      95           0 :    for(int t=0; t<64; t++) {
      96           0 :        fMeanHV[t]      = 100.0;
      97           0 :        fWidthHV[t]     = 0.0; 
      98           0 :        fTimeOffset[t]  = 5.0;
      99           0 :        fTimeGain[t]    = 1.0;
     100           0 :        fDeadChannel[t]= kFALSE;
     101           0 :        fDiscriThr[t]  = 2.5;
     102           0 :        fCalDiscriThr[t] = -1024;
     103             :     }
     104           0 :    for(int t=0; t<128; t++) {
     105           0 :        fPedestal[t]    = 0.0;     
     106           0 :        fSigma[t]       = 0.0;        
     107           0 :        fADCmean[t]     = 0.0;      
     108           0 :        fADCsigma[t]    = 0.0;
     109             :    }
     110           0 :    for(int i=0; i<kNCIUBoards ;i++) {
     111           0 :        fTimeResolution[i]  = 25./256.;    // Default time resolution in ns / channel
     112           0 :        fWidthResolution[i] = 25./64.;     // Default time width resolution in ns / channel
     113           0 :        fMatchWindow[i] = 4;
     114           0 :        fSearchWindow[i] = 16;
     115           0 :        fTriggerCountOffset[i] = 3247;
     116           0 :        fRollOver[i] = 3563;
     117             :    }
     118             : 
     119           0 : }
     120             : 
     121             : //________________________________________________________________
     122             : AliVZEROCalibData::AliVZEROCalibData(const AliVZEROCalibData& calibda) :
     123           0 :   TNamed(calibda),
     124           0 :   fIsCalThrInit(calibda.fIsCalThrInit),
     125           0 :   fLightYields(NULL),
     126           0 :   fPMGainsA(NULL),
     127           0 :   fPMGainsB(NULL)
     128           0 : {
     129             : // copy constructor
     130             : 
     131           0 :   SetName(calibda.GetName());
     132           0 :   SetTitle(calibda.GetName());
     133             :   
     134           0 :   for(int t=0; t<128; t++) { 
     135           0 :       fPedestal[t] = calibda.GetPedestal(t);
     136           0 :       fSigma[t]    = calibda.GetSigma(t);
     137           0 :       fADCmean[t]  = calibda.GetADCmean(t);
     138           0 :       fADCsigma[t] = calibda.GetADCsigma(t); }
     139             :       
     140           0 :   for(int t=0; t<64; t++) { 
     141           0 :       fMeanHV[t]       = calibda.GetMeanHV(t);
     142           0 :       fWidthHV[t]      = calibda.GetWidthHV(t);        
     143           0 :       fTimeOffset[t]   = calibda.GetTimeOffset(t);
     144           0 :       fTimeGain[t]     = calibda.GetTimeGain(t); 
     145           0 :       fDeadChannel[t]  = calibda.IsChannelDead(t);
     146           0 :       fDiscriThr[t]    = calibda.GetDiscriThr(t);
     147           0 :       fDiscriThr[t]    = calibda.fCalDiscriThr[t];
     148             :   }  
     149             :   
     150           0 :   for(int i=0; i<kNCIUBoards ;i++) {
     151           0 :       fTimeResolution[i]  = calibda.GetTimeResolution(i);
     152           0 :       fWidthResolution[i] = calibda.GetWidthResolution(i);        
     153           0 :       fMatchWindow[i] = calibda.GetMatchWindow(i);
     154           0 :       fSearchWindow[i] = calibda.GetSearchWindow(i);
     155           0 :       fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
     156           0 :       fRollOver[i] = calibda.GetRollOver(i);
     157             :   }
     158             :   
     159           0 : }
     160             : 
     161             : //________________________________________________________________
     162             : AliVZEROCalibData &AliVZEROCalibData::operator =(const AliVZEROCalibData& calibda)
     163             : {
     164             : // assignment operator
     165             : 
     166           0 :   SetName(calibda.GetName());
     167           0 :   SetTitle(calibda.GetName());
     168             : 
     169           0 :   fIsCalThrInit = calibda.fIsCalThrInit;
     170             :   
     171           0 :   for(int t=0; t<128; t++) {
     172           0 :       fPedestal[t] = calibda.GetPedestal(t);
     173           0 :       fSigma[t]    = calibda.GetSigma(t);
     174           0 :       fADCmean[t]  = calibda.GetADCmean(t);
     175           0 :       fADCsigma[t] = calibda.GetADCsigma(t); }
     176             :       
     177           0 :   for(int t=0; t<64; t++) {
     178           0 :       fMeanHV[t]       = calibda.GetMeanHV(t);
     179           0 :       fWidthHV[t]      = calibda.GetWidthHV(t);        
     180           0 :       fTimeOffset[t]   = calibda.GetTimeOffset(t);
     181           0 :       fTimeGain[t]     = calibda.GetTimeGain(t); 
     182           0 :       fDeadChannel[t]  = calibda.IsChannelDead(t);
     183           0 :       fDiscriThr[t]    = calibda.GetDiscriThr(t);
     184           0 :       fDiscriThr[t]    = calibda.fCalDiscriThr[t];
     185             :   }   
     186           0 :   for(int i=0; i<kNCIUBoards ;i++) {
     187           0 :       fTimeResolution[i]  = calibda.GetTimeResolution(i);
     188           0 :       fWidthResolution[i] = calibda.GetWidthResolution(i);        
     189           0 :       fMatchWindow[i] = calibda.GetMatchWindow(i);
     190           0 :       fSearchWindow[i] = calibda.GetSearchWindow(i);
     191           0 :       fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
     192           0 :       fRollOver[i] = calibda.GetRollOver(i);
     193             :   }
     194             :    
     195           0 :   return *this;
     196             :   
     197             : }
     198             : 
     199             : //________________________________________________________________
     200             : AliVZEROCalibData::~AliVZEROCalibData()
     201           0 : {
     202             :   // destructor
     203           0 :   if (fLightYields)
     204           0 :     delete [] fLightYields;
     205           0 :   if (fPMGainsA)
     206           0 :     delete [] fPMGainsA;
     207           0 :   if (fPMGainsB)
     208           0 :     delete [] fPMGainsB;
     209           0 : }
     210             : //_____________________________________________________________________________
     211             : void AliVZEROCalibData::FillDCSData(AliVZERODataDCS * data){
     212             :         // Set all parameters from the data get by the shuttle
     213           0 :         TMap * params = data->GetFEEParameters();
     214           0 :         TIter iter(params);     
     215             :         TObjString* aliasName;
     216             :         
     217           0 :         while ((  aliasName = (TObjString*) iter.Next() ))  {
     218           0 :                 AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName);
     219             :                 Int_t val;
     220           0 :                 if(aValue) {
     221           0 :                         val = aValue->GetUInt();
     222           0 :                         AliInfo(Form("%s : %d",aliasName->String().Data(), val));
     223           0 :                         SetParameter(aliasName->String(),val);
     224           0 :                 }
     225             :         }       
     226             :         
     227           0 :         SetMeanHV(data->GetMeanHV());
     228           0 :         SetWidthHV(data->GetWidthHV());
     229           0 :         SetDeadMap(data->GetDeadMap());
     230             : 
     231           0 : }
     232             : //_____________________________________________________________________________
     233             : void AliVZEROCalibData::SetParameter(TString name, Int_t val){
     234             :         // Set given parameter
     235             :         
     236           0 :         Int_t iBoard = -1;
     237           0 :         Int_t iChannel = -1;
     238             : 
     239           0 :         TSeqCollection* nameSplit = name.Tokenize("/");
     240           0 :         TObjString * boardName = (TObjString *)nameSplit->At(2);
     241           0 :         sscanf(boardName->String().Data(),"CIU%d",&iBoard);
     242             : 
     243           0 :         TString paramName = ((TObjString *)nameSplit->At(3))->String();
     244           0 :         Char_t channel[2] ; channel[1] = '\0';
     245           0 :         channel[0] = paramName[paramName.Sizeof()-2];
     246           0 :         sscanf(channel,"%d",&iChannel);
     247             :                 
     248           0 :         if(name.Contains("TimeResolution")) SetTimeResolution((UShort_t) val,iBoard);
     249           0 :         else if(name.Contains("WidthResolution")) SetWidthResolution((UShort_t) val,iBoard);
     250           0 :         else if(name.Contains("MatchWindow")) SetMatchWindow((UInt_t) val,iBoard);
     251           0 :         else if(name.Contains("SearchWindow")) SetSearchWindow((UInt_t) val,iBoard);
     252           0 :         else if(name.Contains("TriggerCountOffset")) SetTriggerCountOffset((UInt_t) val,iBoard);
     253           0 :         else if(name.Contains("RollOver")) SetRollOver((UInt_t) val,iBoard);
     254           0 :         else if(name.Contains("DelayHit")) SetTimeOffset(0.01*(Float_t)val,iBoard,(iChannel-1));
     255           0 :         else if(name.Contains("DiscriThr")) SetDiscriThr(((Float_t)val-2040.)/112.,iBoard,(iChannel-1));
     256           0 :         else AliError(Form("No Setter found for FEE parameter : %s",name.Data()));
     257             :         //
     258           0 :         delete nameSplit;
     259           0 : }
     260             : 
     261             : //________________________________________________________________
     262             : void AliVZEROCalibData::SetPedestal(const Float_t* Pedestal)
     263             : {
     264           0 :   if(Pedestal) for(int t=0; t<128; t++) fPedestal[t] = Pedestal[t];
     265           0 :   else for(int t=0; t<128; t++) fPedestal[t] = 0.0;
     266           0 : }
     267             : 
     268             : //________________________________________________________________
     269             : void AliVZEROCalibData::SetSigma(const Float_t* Sigma)
     270             : {
     271           0 :   if(Sigma) for(int t=0; t<128; t++) fSigma[t] = Sigma[t];
     272           0 :   else for(int t=0; t<128; t++) fSigma[t] = 0.0;
     273           0 : }
     274             : 
     275             : //________________________________________________________________
     276             : void AliVZEROCalibData::SetADCmean(const Float_t* ADCmean) 
     277             : {
     278           0 :   if(ADCmean) for(int t=0; t<128; t++) fADCmean[t] = ADCmean[t];
     279           0 :   else for(int t=0; t<128; t++) fADCmean[t] = 0.0;
     280           0 : }
     281             : 
     282             : //________________________________________________________________
     283             : void AliVZEROCalibData::SetADCsigma(const Float_t* ADCsigma) 
     284             : {
     285           0 :   if(ADCsigma) for(int t=0; t<128; t++) fADCsigma[t] = ADCsigma[t];
     286           0 :   else for(int t=0; t<128; t++) fADCsigma[t] = 0.0;
     287           0 : }
     288             : 
     289             : //________________________________________________________________
     290             : void AliVZEROCalibData::SetMeanHV(const Float_t* MeanHV) 
     291             : {
     292           0 :   if(MeanHV) for(int t=0; t<64; t++) fMeanHV[t] = MeanHV[t];
     293           0 :   else for(int t=0; t<64; t++) fMeanHV[t] = 0.0;
     294           0 : }
     295             : 
     296             : //________________________________________________________________
     297             : void AliVZEROCalibData::SetWidthHV(const Float_t* WidthHV) 
     298             : {
     299           0 :   if(WidthHV) for(int t=0; t<64; t++) fWidthHV[t] = WidthHV[t];
     300           0 :   else for(int t=0; t<64; t++) fWidthHV[t] = 0.0;
     301           0 : }
     302             : 
     303             : //________________________________________________________________
     304             : void AliVZEROCalibData::SetDeadMap(const Bool_t* deadMap) 
     305             : {
     306           0 :   if(deadMap) for(int t=0; t<64; t++) fDeadChannel[t] = deadMap[t];
     307           0 :   else for(int t=0; t<64; t++) fDeadChannel[t] = kFALSE;
     308           0 : }
     309             : 
     310             : //________________________________________________________________
     311             : void AliVZEROCalibData::SetTimeOffset(Float_t val, Int_t board, Int_t channel)
     312             : {
     313           0 :   Int_t ch = AliVZEROCalibData::GetOfflineChannelNumber(board,channel);
     314           0 :   if(ch >= 0){
     315           0 :     fTimeOffset[ch]=val;
     316           0 :     AliInfo(Form("Time offset for channel %d set to %f",ch,fTimeOffset[ch]));
     317           0 :   }
     318             :   else
     319           0 :     AliError("Board/Channel numbers are not valid");
     320           0 : }
     321             : 
     322             : //________________________________________________________________
     323             : void AliVZEROCalibData::SetTimeOffset(const Float_t* TimeOffset) 
     324             : {
     325           0 :   if(TimeOffset) for(int t=0; t<64; t++) fTimeOffset[t] = TimeOffset[t];
     326           0 :   else for(int t=0; t<64; t++) fTimeOffset[t] = 5.0;
     327           0 : }
     328             : 
     329             : //________________________________________________________________
     330             : void AliVZEROCalibData::SetTimeGain(const Float_t* TimeGain) 
     331             : {
     332           0 :   if(TimeGain) for(int t=0; t<64; t++) fTimeGain[t] = TimeGain[t];
     333           0 :   else for(int t=0; t<64; t++) fTimeGain[t] = 0.0;
     334           0 : }
     335             : 
     336             : //_____________________________________________________________________________
     337             : Float_t AliVZEROCalibData::GetMIPperADC(Int_t channel) {
     338             :         
     339             :         // Computes the MIP conversion factor - MIP per ADC channel - 
     340             :         // Argument passed is the PM number (aliroot numbering)
     341             :         
     342        2048 :   Float_t nPhPerMIP = (channel < 32) ? 6950 : 33690; 
     343        1024 :   return 1./(nPhPerMIP*GetLightYields(channel)*0.18*TMath::Qe()*GetGain(channel)/kChargePerADC);
     344             :         
     345             : }
     346             : 
     347             : //_____________________________________________________________________________
     348             : Float_t AliVZEROCalibData::GetHV(Int_t channel, Float_t adcPerMip) {
     349             :         
     350             :   // Computes the HV value for certain ADC per MIP value
     351             :   // Arguments passed is the PM number (aliroot numbering) and
     352             :   // required value of ADC per MIP
     353           0 :   if (!fPMGainsA) InitPMGains();
     354             : 
     355           0 :   if (adcPerMip <= 0) return 0;
     356           0 :   Float_t nPhPerMIP = (channel < 32) ? 6950 : 33690;
     357           0 :   Float_t gain = adcPerMip/(nPhPerMIP*GetLightYields(channel)*0.18*TMath::Qe())*kChargePerADC;
     358           0 :   return TMath::Exp((TMath::Log(gain)-fPMGainsA[channel])/fPMGainsB[channel]);
     359           0 : }
     360             : 
     361             : //________________________________________________________________
     362             : Float_t AliVZEROCalibData::GetGain(Int_t channel)
     363             : {
     364             :   // Computes the PM gains
     365             :   // Argument passed is the PM number (aliroot numbering)
     366        2471 :   if (!fPMGainsA) InitPMGains();
     367             : 
     368             :   // High Voltage retrieval from Calibration Data Base:  
     369        1234 :   Float_t hv = fMeanHV[channel];
     370             :   Float_t gain = 0;
     371        1234 :   if (hv>0)
     372        1234 :     gain = TMath::Exp(fPMGainsA[channel]+fPMGainsB[channel]*TMath::Log(hv));
     373        1234 :   return gain;
     374             : }
     375             : 
     376             : //________________________________________________________________
     377             : void AliVZEROCalibData::SetTimeResolution(UShort_t *resols){
     378             :         // Set Time Resolution of the TDC
     379           0 :         if(resols)  for(int t=0; t<kNCIUBoards; t++) SetTimeResolution(resols[t],t);
     380           0 :         else AliError("Time Resolution not defined.");
     381             :         
     382           0 : }
     383             : //________________________________________________________________
     384             : void AliVZEROCalibData::SetTimeResolution(UShort_t resol, Int_t board)
     385             : {
     386             :         // Set Time Resolution of the TDC
     387           0 :         if((board>=0) && (board<kNCIUBoards)) {
     388           0 :                 switch(resol){
     389             :                         case 0:
     390           0 :                                 fTimeResolution[board] = 25./256.;
     391           0 :                                 break;
     392             :                         case 1:
     393           0 :                                 fTimeResolution[board] = 25./128.;
     394           0 :                                 break;
     395             :                         case 2:
     396           0 :                                 fTimeResolution[board] = 25./64.;
     397           0 :                                 break;
     398             :                         case 3:
     399           0 :                                 fTimeResolution[board] = 25./32.;
     400           0 :                                 break;
     401             :                         case 4:
     402           0 :                                 fTimeResolution[board] = 25./16.;
     403           0 :                                 break;
     404             :                         case 5:
     405           0 :                                 fTimeResolution[board] = 25./8.;
     406           0 :                                 break;
     407             :                         case 6:
     408           0 :                                 fTimeResolution[board] = 6.25;
     409           0 :                                 break;
     410             :                         case 7:
     411           0 :                                 fTimeResolution[board] = 12.5;
     412           0 :                                 break;
     413             :                 }
     414           0 :                 AliInfo(Form("Time Resolution of board %d set to %f",board,fTimeResolution[board]));
     415           0 :         } else AliError(Form("Board %d is not valid",board));
     416           0 : }
     417             : //________________________________________________________________
     418             : void AliVZEROCalibData::SetWidthResolution(UShort_t *resols){
     419             :         // Set Time Width Resolution of the TDC
     420           0 :         if(resols)  for(int t=0; t<kNCIUBoards; t++) SetWidthResolution(resols[t],t);
     421           0 :         else AliError("Width Resolution not defined.");
     422             :         
     423           0 : }
     424             : //________________________________________________________________
     425             : void AliVZEROCalibData::SetWidthResolution(UShort_t resol, Int_t board)
     426             : {
     427             :         // Set Time Width Resolution of the TDC
     428           0 :         if((board>=0) && (board<kNCIUBoards)){
     429           0 :                 switch(resol){
     430             :                         case 0:
     431           0 :                                 fWidthResolution[board] = 25./256.;
     432           0 :                                 break;
     433             :                         case 1:
     434           0 :                                 fWidthResolution[board] = 25./128.;
     435           0 :                                 break;
     436             :                         case 2:
     437           0 :                                 fWidthResolution[board] = 25./64.;
     438           0 :                                 break;
     439             :                         case 3:
     440           0 :                                 fWidthResolution[board] = 25./32.;
     441           0 :                                 break;
     442             :                         case 4:
     443           0 :                                 fWidthResolution[board] = 25./16.;
     444           0 :                                 break;
     445             :                         case 5:
     446           0 :                                 fWidthResolution[board] = 25./8.;
     447           0 :                                 break;
     448             :                         case 6:
     449           0 :                                 fWidthResolution[board] = 6.25;
     450           0 :                                 break;
     451             :                         case 7:
     452           0 :                                 fWidthResolution[board] = 12.5;
     453           0 :                                 break;
     454             :                         case 8:
     455           0 :                                 fWidthResolution[board] = 25.;
     456           0 :                                 break;
     457             :                         case 9:
     458           0 :                                 fWidthResolution[board] = 50.;
     459           0 :                                 break;
     460             :                         case 10:
     461           0 :                                 fWidthResolution[board] = 100.;
     462           0 :                                 break;
     463             :                         case 11:
     464           0 :                                 fWidthResolution[board] = 200.;
     465           0 :                                 break;
     466             :                         case 12:
     467           0 :                                 fWidthResolution[board] = 400.;
     468           0 :                                 break;
     469             :                         case 13:
     470           0 :                                 fWidthResolution[board] = 800.;
     471           0 :                                 break;
     472             :                                 
     473             :                 }
     474           0 :                 AliInfo(Form("Width Resolution of board %d set to %f",board,fWidthResolution[board]));
     475           0 :         }else AliError(Form("Board %d is not valid",board));
     476           0 : }
     477             : 
     478             : //________________________________________________________________
     479             : void AliVZEROCalibData::SetMatchWindow(UInt_t *windows)
     480             : {
     481             :   // Set Match window of the HPTDC
     482             :   // The units are 25ns
     483           0 :   if(windows)  for(Int_t b=0; b<kNCIUBoards; b++) SetMatchWindow(windows[b],b);
     484           0 :   else AliError("Match windows not defined.");
     485           0 : }
     486             : 
     487             : //________________________________________________________________
     488             : void AliVZEROCalibData::SetMatchWindow(UInt_t window, Int_t board)
     489             : {
     490             :   // Set Match window of the HPTDC
     491             :   // The units are 25ns
     492           0 :   if((board>=0) && (board<kNCIUBoards)){
     493           0 :     fMatchWindow[board] = window;
     494           0 :     AliInfo(Form("Match window of board %d set to %d",board,fMatchWindow[board]));
     495           0 :   }
     496             :   else
     497           0 :     AliError(Form("Board %d is not valid",board));
     498           0 : }
     499             : 
     500             : //________________________________________________________________
     501             : void AliVZEROCalibData::SetSearchWindow(UInt_t *windows)
     502             : {
     503             :   // Set Search window of the HPTDC
     504             :   // The units are 25ns
     505           0 :   if(windows)  for(Int_t b=0; b<kNCIUBoards; b++) SetSearchWindow(windows[b],b);
     506           0 :   else AliError("Search windows not defined.");
     507           0 : }
     508             : 
     509             : //________________________________________________________________
     510             : void  AliVZEROCalibData::SetSearchWindow(UInt_t window, Int_t board)
     511             : {
     512             :   // Set Search window of the HPTDC
     513             :   // The units are 25ns
     514           0 :   if((board>=0) && (board<kNCIUBoards)){
     515           0 :     fSearchWindow[board] = window;
     516           0 :     AliInfo(Form("Search window of board %d set to %d",board,fSearchWindow[board]));
     517           0 :   }
     518             :   else
     519           0 :     AliError(Form("Board %d is not valid",board));
     520           0 : }
     521             : 
     522             : //________________________________________________________________
     523             : void AliVZEROCalibData::SetTriggerCountOffset(UInt_t *offsets)
     524             : {
     525             :   // Set trigger-count offset of the HPTDC
     526             :   // The units are 25ns
     527           0 :   if(offsets)  for(Int_t b=0; b<kNCIUBoards; b++) SetTriggerCountOffset(offsets[b],b);
     528           0 :   else AliError("Trigger count offsets not defined.");
     529           0 : }
     530             : 
     531             : //________________________________________________________________
     532             : void AliVZEROCalibData::SetTriggerCountOffset(UInt_t offset, Int_t board)
     533             : {
     534             :   // Set trigger-count offsets of the HPTDC
     535             :   // The units are 25ns
     536           0 :   if((board>=0) && (board<kNCIUBoards)){
     537           0 :     fTriggerCountOffset[board] = offset;
     538           0 :     AliInfo(Form("Trigger-count offset of board %d set to %d",board,fTriggerCountOffset[board]));
     539           0 :   }
     540             :   else
     541           0 :     AliError(Form("Board %d is not valid",board));
     542           0 : }
     543             : 
     544             : //________________________________________________________________
     545             : void AliVZEROCalibData::SetRollOver(UInt_t *offsets)
     546             : {
     547             :   // Set Roll-over of the HPTDC
     548             :   // The units are 25ns
     549           0 :   if(offsets)  for(Int_t b=0; b<kNCIUBoards; b++) SetRollOver(offsets[b],b);
     550           0 :   else AliError("Roll-over offsets not defined.");
     551           0 : }
     552             : 
     553             : //________________________________________________________________
     554             : void AliVZEROCalibData::SetRollOver(UInt_t offset, Int_t board)
     555             : {
     556             :   // Set Roll-over of the HPTDC
     557             :   // The units are 25ns
     558           0 :   if((board>=0) && (board<kNCIUBoards)){
     559           0 :     fRollOver[board] = offset;
     560           0 :     AliInfo(Form("Roll-over offset of board %d set to %d",board,fRollOver[board]));
     561           0 :   }
     562             :   else
     563           0 :     AliError(Form("Board %d is not valid",board));
     564           0 : }
     565             : 
     566             : //________________________________________________________________
     567             : void AliVZEROCalibData::SetDiscriThr(Float_t thr, Int_t board, Int_t channel)
     568             : {
     569             :   // Set the TDC discriminator
     570             :   // threshold values expressed in units of ADC
     571           0 :   Int_t ch = AliVZEROCalibData::GetOfflineChannelNumber(board,channel);
     572           0 :   if(ch >= 0){
     573           0 :     if (thr > 0) {
     574           0 :       fDiscriThr[ch]=thr;
     575           0 :       AliInfo(Form("Discriminator threshold for channel %d set to %f",ch,fDiscriThr[ch]));
     576           0 :     }
     577             :     else {
     578           0 :       AliWarning(Form("Ignore wrong threshold value (%f) for channel %d !",thr,ch));
     579             :     }
     580             :   }
     581             :   else
     582           0 :     AliError("Board/Channel numbers are not valid");
     583           0 : }
     584             : 
     585             : //________________________________________________________________
     586             : void AliVZEROCalibData::SetDiscriThr(const Float_t* thresholds) 
     587             : {
     588             :   // Set the TDC discriminator
     589             :   // threshold values expressed in units of ADC
     590           0 :   if(thresholds) for(int t=0; t<64; t++) fDiscriThr[t] = thresholds[t];
     591           0 :   else for(int t=0; t<64; t++) fDiscriThr[t] = 2.5;
     592           0 : }
     593             : 
     594             : Int_t AliVZEROCalibData::GetOfflineChannelNumber(Int_t board, Int_t channel)
     595             : {
     596             :   // Get the offline channel number from
     597             :   // the FEE board and channel indexes
     598             : 
     599           0 :   if (board < 0 || board >= 8) {
     600           0 :     AliErrorClass(Form("Wrong FEE board number: %d",board));
     601           0 :     return -1;
     602             :   }
     603           0 :   if (channel < 0 || channel >= 8) {
     604           0 :     AliErrorClass(Form("Wrong FEE channel number: %d",channel));
     605           0 :     return -1;
     606             :   }
     607             : 
     608           0 :   Int_t offCh = (board < 4) ? (8 * board + 32) : (8 * board -32);
     609           0 :   offCh += (7 - channel);
     610             : 
     611             :   return offCh;
     612           0 : }
     613             : 
     614             : Int_t AliVZEROCalibData::GetBoardNumber(Int_t channel)
     615             : {
     616             :   // Get FEE board number
     617             :   // from offline channel index
     618       10240 :   if (channel >= 0 && channel < 32) return (channel / 8 + 4);
     619        4096 :   if (channel >=32 && channel < 64) return (channel / 8 - 4);
     620             : 
     621           0 :   AliErrorClass(Form("Wrong channel index: %d",channel));
     622           0 :   return -1;
     623        4096 : }
     624             : 
     625             : Int_t AliVZEROCalibData::GetFEEChannelNumber(Int_t channel)
     626             : {
     627             :   // Get FEE channel number
     628             :   // from offline channel index
     629        3840 :   if (channel >= 0 && channel < 64) return (7 - (channel % 8));
     630             : 
     631           0 :   AliErrorClass(Form("Wrong channel index: %d",channel));
     632           0 :   return -1;
     633        1280 : }
     634             : 
     635             : Float_t AliVZEROCalibData::GetLightYields(Int_t channel)
     636             : {
     637             :   // Get the light yield efficiency
     638             :   // for a given channel
     639        2179 :   if (!fLightYields) InitLightYields();
     640             : 
     641        1088 :   if (channel >= 0 && channel < 64) {
     642        1088 :     return fLightYields[channel];
     643             :   }
     644             : 
     645           0 :   AliError(Form("Wrong channel index: %d",channel));
     646           0 :   return 0;
     647        1088 : }
     648             : 
     649             : void  AliVZEROCalibData::InitLightYields()
     650             : {
     651             :   // Initialize the light yield factors
     652             :   // Read from a separate OCDB entry
     653           6 :   if (fLightYields) return;
     654             : 
     655           6 :   AliCDBEntry *entry = AliCDBManager::Instance()->Get("VZERO/Calib/LightYields");
     656           3 :   if (!entry) AliFatal("VZERO light yields are not found in OCDB !");
     657           3 :   TH1F *yields = (TH1F*)entry->GetObject();
     658             : 
     659           3 :   fLightYields = new Float_t[64];
     660         390 :   for(Int_t i = 0 ; i < 64; ++i) {
     661         192 :     fLightYields[i] = yields->GetBinContent(i+1);
     662             :   }
     663           6 : }
     664             : 
     665             : void  AliVZEROCalibData::InitPMGains()
     666             : {
     667             :   // Initialize the PM gain factors
     668             :   // Read from a separate OCDB entry
     669           6 :   if (fPMGainsA) return;
     670             : 
     671           6 :   AliCDBEntry *entry = AliCDBManager::Instance()->Get("VZERO/Calib/PMGains");
     672           3 :   if (!entry) AliFatal("VZERO PM gains are not found in OCDB !");
     673           3 :   TH2F *gains = (TH2F*)entry->GetObject();
     674             : 
     675           3 :   fPMGainsA = new Float_t[64];
     676           3 :   fPMGainsB = new Float_t[64];
     677         390 :   for(Int_t i = 0 ; i < 64; ++i) {
     678         192 :     fPMGainsA[i] = gains->GetBinContent(i+1,1);
     679         192 :     fPMGainsB[i] = gains->GetBinContent(i+1,2);
     680             :   }
     681           6 : }
     682             : 
     683             : Float_t AliVZEROCalibData::GetCalibDiscriThr(Int_t channel, Bool_t scaled, Int_t runNumber)
     684             : {
     685             :   // The method returns actual TDC discri threshold
     686             :   // extracted from the data.
     687             :   //
     688             :   // In case scaled flag is set the threshold is scaled
     689             :   // so that to get 4.0 for a FEE threshold of 4.0.
     690             :   // In this way we avoid a change in the slewing correction
     691             :   // for the entire 2010 p-p data.
     692             :   //
     693             :   // The method nas been moved to OCDB for Run2 reconstriction
     694             : 
     695         584 :   Float_t thr = GetDiscriThr(channel);
     696             : 
     697             :   Float_t calThr = 0;
     698             : 
     699         584 :   if (runNumber < 215011) {
     700             :     // Run1
     701         584 :     if (thr <= 1.) 
     702           0 :       calThr = 3.1;
     703         584 :     else if (thr >= 2.)
     704         584 :       calThr = (3.1+1.15*thr-1.7);
     705             :     else
     706           0 :       calThr = (3.1-0.3*thr+0.3*thr*thr);
     707             :     
     708         912 :     if (scaled) calThr *= 4./(3.1+1.15*4.-1.7);
     709             :   }
     710             :   else {
     711             :     // Run2
     712           0 :     if (!fIsCalThrInit) InitCalDiscriThr();
     713           0 :     calThr = fCalDiscriThr[channel];
     714             :   }
     715             : 
     716         584 :   return calThr;
     717             : }
     718             : 
     719             : void  AliVZEROCalibData::InitCalDiscriThr()
     720             : {
     721             :   // Initialize the calibrated threshold values
     722             :   // Used in Run2
     723           0 :   if (fIsCalThrInit) return;
     724             : 
     725           0 :   AliCDBEntry *entry = AliCDBManager::Instance()->Get("VZERO/Calib/Thresholds");
     726           0 :   if (!entry) AliFatal("VZERO thresholds calibration not found in OCDB !");
     727           0 :   TObjArray *arr = (TObjArray*)entry->GetObject();
     728           0 :   if (!arr) AliFatal("No threshold calibration object in the database !");
     729             : 
     730           0 :   AliCDBEntry *entry2 = AliCDBManager::Instance()->Get("VZERO/Trigger/Data");
     731           0 :   if (!entry2) AliFatal("VZERO trigger data not found in OCDB !");
     732           0 :   AliVZEROTriggerData *trigData = (AliVZEROTriggerData *)entry2->GetObject();
     733           0 :   if (!trigData)  AliFatal("No Trigger data in the database !");
     734             : 
     735           0 :   for(Int_t channel = 0; channel < 64; ++channel) {
     736           0 :     Float_t thr = GetDiscriThr(channel);
     737             :     // Fix in case the threshold was set to 0.0 which in shuttle leads to a setting of 2.5 ADC
     738           0 :     Int_t feeBoard   = GetBoardNumber(channel);
     739           0 :     Int_t feeChannel = GetFEEChannelNumber(channel);
     740           0 :     if (TMath::Abs(thr-2.5) < 1e-6 && trigData->GetDiscriThr(feeBoard,feeChannel) == 2040) thr = 0.0;
     741           0 :     TF1 *fThr = (TF1*)arr->UncheckedAt(channel);
     742           0 :     if (!fThr) AliFatal(Form("Threshold calibration is missing for channel %d",channel));
     743           0 :     fCalDiscriThr[channel] = fThr->Eval(thr);
     744             :   }
     745             : 
     746           0 :   fIsCalThrInit = kTRUE;
     747           0 : }

Generated by: LCOV version 1.11