LCOV - code coverage report
Current view: top level - AD/ADbase - AliADCalibData.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 803 0.1 %
Date: 2016-06-14 17:26:59 Functions: 1 91 1.1 %

          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: AliADCalibData.cxx,                                            */
      17             : #include <Riostream.h>
      18             : #include <bitset>
      19             : 
      20             : #include <TMath.h>
      21             : #include <TObjString.h>
      22             : #include <TMap.h>
      23             : #include <TH1F.h>
      24             : #include <TH2F.h>
      25             : 
      26             : #include "AliDCSValue.h"
      27             : #include "AliCDBManager.h"
      28             : #include "AliCDBEntry.h"
      29             : #include "AliADDataDCS.h"
      30             : #include "AliADCalibData.h"
      31             : #include "AliADConst.h"
      32             : #include "AliADLogicalSignal.h"
      33             : #include "AliLog.h"
      34             : 
      35          16 : ClassImp(AliADCalibData);
      36             : 
      37             : //________________________________________________________________
      38           0 : AliADCalibData::AliADCalibData():
      39           0 :   fLightYields(NULL),
      40           0 :   fPMGainsA(NULL),
      41           0 :   fPMGainsB(NULL),
      42           0 :   fThrCalibA(NULL),
      43           0 :   fThrCalibB(NULL),
      44           0 :   fBBAThreshold(0),
      45           0 :   fBBCThreshold(0) ,  
      46           0 :   fBGAThreshold(0) ,  
      47           0 :   fBGCThreshold(0) ,  
      48           0 :   fBBAForBGThreshold(0) ,  
      49           0 :   fBBCForBGThreshold(0) ,   
      50           0 :   fMultADAThrLow(0) ,  
      51           0 :   fMultADAThrHigh(0) , 
      52           0 :   fMultADCThrLow(0) ,  
      53           0 :   fMultADCThrHigh(0)
      54           0 : {
      55             :   // default constructor
      56             :   
      57           0 :   for(int t=0; t<16; t++) {
      58           0 :     fMeanHV[t]      = 1400.0;
      59           0 :     fWidthHV[t]     = 0.0; 
      60           0 :     fTimeOffset[t]  = 250.0;
      61           0 :     fTimeGain[t]    = 1.0;
      62           0 :     fDeadChannel[t]= kFALSE;
      63           0 :     fDiscriThr[t]  = 2.5;
      64             :   }
      65           0 :   for(int t=0; t<32; t++) {
      66           0 :     fPedestal[t]    = 3.0;     
      67           0 :     fSigma[t]       = 1.0;        
      68           0 :     fADCmean[t]     = 0.0;      
      69           0 :     fADCsigma[t]    = 0.0;
      70             :   }
      71           0 :   for(int i=0; i<kNCIUBoards ;i++) {
      72           0 :     fTimeResolution[i]  = 25./256.;     // Default time resolution
      73           0 :     fWidthResolution[i] = 25./64.;     // Default time width resolution
      74           0 :     fMatchWindow[i] = 16;
      75           0 :     fSearchWindow[i] = 16;
      76           0 :     fTriggerCountOffset[i] = 3553;
      77           0 :     fRollOver[i] = 3563;
      78             :   }
      79           0 :   for(int i=0; i<kNCIUBoards ;i++) {
      80           0 :     fClk1Win1[i] = fClk1Win2[i] = 0;
      81           0 :     fDelayClk1Win1[i] = fDelayClk1Win2[i] = 0;
      82           0 :     fClk2Win1[i] = fClk2Win2[i] = 0;
      83           0 :     fDelayClk2Win1[i] = fDelayClk2Win2[i] = 0;
      84           0 :     fLatchWin1[i] = fLatchWin2[i] = 0;
      85           0 :     fResetWin1[i] = fResetWin2[i] = 0;
      86           0 :     fPedestalSubtraction[i] = kFALSE;
      87             :   }
      88           0 :   for(Int_t j = 0; j < 16; ++j) {
      89           0 :     fEnableCharge[j] = kFALSE;
      90           0 :     fEnableTiming[j] = kTRUE;
      91           0 :     fPedestalOdd[j] = fPedestalEven[j] = 0;
      92           0 :     fPedestalCutOdd[j] = fPedestalCutEven[j] = 0;
      93             :   }
      94           0 :   for(Int_t i = 0; i < 5; ++i) fTriggerSelected[i] = 0;
      95             : 
      96           0 : }
      97             : //________________________________________________________________
      98             : void AliADCalibData::Reset()
      99             : {
     100             :   
     101           0 : }
     102             : 
     103             : //________________________________________________________________
     104           0 : AliADCalibData::AliADCalibData(const char* name) :
     105           0 :   fLightYields(NULL),
     106           0 :   fPMGainsA(NULL),
     107           0 :   fPMGainsB(NULL),
     108           0 :   fThrCalibA(NULL),
     109           0 :   fThrCalibB(NULL),
     110           0 :   fBBAThreshold(0),
     111           0 :   fBBCThreshold(0) ,  
     112           0 :   fBGAThreshold(0) ,  
     113           0 :   fBGCThreshold(0) ,  
     114           0 :   fBBAForBGThreshold(0) ,  
     115           0 :   fBBCForBGThreshold(0) ,   
     116           0 :   fMultADAThrLow(0) ,  
     117           0 :   fMultADAThrHigh(0) , 
     118           0 :   fMultADCThrLow(0) ,  
     119           0 :   fMultADCThrHigh(0)
     120           0 : {
     121             :   // Constructor
     122           0 :   TString namst = "Calib_";
     123           0 :   namst += name;
     124           0 :   SetName(namst.Data());
     125           0 :   SetTitle(namst.Data());
     126           0 :   for(int t=0; t<16; t++) {
     127           0 :     fMeanHV[t]      = 1500.0;
     128           0 :     fWidthHV[t]     = 0.0; 
     129           0 :     fTimeOffset[t]  = 5.0;
     130           0 :     fTimeGain[t]    = 1.0;
     131           0 :     fDeadChannel[t]= kFALSE;
     132           0 :     fDiscriThr[t]  = 2.5;
     133             :   }
     134           0 :   for(int t=0; t<32; t++) {
     135           0 :     fPedestal[t]    = 0.0;     
     136           0 :     fSigma[t]       = 0.0;        
     137           0 :     fADCmean[t]     = 0.0;      
     138           0 :     fADCsigma[t]    = 0.0;
     139             :   }
     140           0 :   for(int i=0; i<kNCIUBoards ;i++) {
     141           0 :     fTimeResolution[i]  = 25./256.;    // Default time resolution in ns / channel
     142           0 :     fWidthResolution[i] = 25./64.;     // Default time width resolution in ns / channel
     143           0 :     fMatchWindow[i] = 4;
     144           0 :     fSearchWindow[i] = 16;
     145           0 :     fTriggerCountOffset[i] = 3247;
     146           0 :     fRollOver[i] = 3563;
     147             :   }
     148           0 :   for(int i=0; i<kNCIUBoards ;i++) {
     149           0 :     fClk1Win1[i] = fClk1Win2[i] = 0;
     150           0 :     fDelayClk1Win1[i] = fDelayClk1Win2[i] = 0;
     151           0 :     fClk2Win1[i] = fClk2Win2[i] = 0;
     152           0 :     fDelayClk2Win1[i] = fDelayClk2Win2[i] = 0;
     153           0 :     fLatchWin1[i] = fLatchWin2[i] = 0;
     154           0 :     fResetWin1[i] = fResetWin2[i] = 0;
     155           0 :     fPedestalSubtraction[i] = kFALSE;
     156             :   }
     157           0 :   for(Int_t j = 0; j < 16; ++j) {
     158           0 :     fEnableCharge[j] = kFALSE;
     159           0 :     fEnableTiming[j] = kTRUE;
     160           0 :     fPedestalOdd[j] = fPedestalEven[j] = 0;
     161           0 :     fPedestalCutOdd[j] = fPedestalCutEven[j] = 0;
     162             :   }
     163           0 :   for(Int_t i = 0; i < 5; ++i) fTriggerSelected[i] = 0;
     164           0 : }
     165             : 
     166             : //________________________________________________________________
     167             : AliADCalibData::AliADCalibData(const AliADCalibData& calibda) :
     168           0 :   TNamed(calibda),
     169           0 :   fLightYields(NULL),
     170           0 :   fPMGainsA(NULL),
     171           0 :   fPMGainsB(NULL),
     172           0 :   fThrCalibA(NULL),
     173           0 :   fThrCalibB(NULL)
     174           0 : {
     175             :   // copy constructor
     176             : 
     177           0 :   SetName(calibda.GetName());
     178           0 :   SetTitle(calibda.GetName());
     179           0 :   fBBAThreshold = calibda.GetBBAThreshold();
     180           0 :   fBBCThreshold = calibda.GetBBCThreshold();  
     181           0 :   fBGAThreshold = calibda.GetBGAThreshold();  
     182           0 :   fBGCThreshold = calibda.GetBGCThreshold();  
     183           0 :   fBBAForBGThreshold = calibda.GetBBAForBGThreshold();  
     184           0 :   fBBCForBGThreshold = calibda.GetBBCForBGThreshold();   
     185           0 :   fMultADAThrLow = calibda.GetMultADAThrLow();  
     186           0 :   fMultADAThrHigh = calibda.GetMultADAThrHigh();
     187           0 :   fMultADCThrLow = calibda.GetMultADCThrLow();  
     188           0 :   fMultADCThrHigh = calibda.GetMultADCThrHigh();
     189             :   
     190           0 :   for(int t=0; t<32; t++) { 
     191           0 :     fPedestal[t] = calibda.GetPedestal(t);
     192           0 :     fSigma[t]    = calibda.GetSigma(t);
     193           0 :     fADCmean[t]  = calibda.GetADCmean(t);
     194           0 :     fADCsigma[t] = calibda.GetADCsigma(t); }
     195             :       
     196           0 :   for(int t=0; t<16; t++) { 
     197           0 :     fMeanHV[t]       = calibda.GetMeanHV(t);
     198           0 :     fWidthHV[t]      = calibda.GetWidthHV(t);        
     199           0 :     fTimeOffset[t]   = calibda.GetTimeOffset(t);
     200           0 :     fTimeGain[t]     = calibda.GetTimeGain(t); 
     201           0 :     fDeadChannel[t]  = calibda.IsChannelDead(t);
     202           0 :     fDiscriThr[t]    = calibda.GetDiscriThr(t);
     203             :   }  
     204             :   
     205           0 :   for(int i=0; i<kNCIUBoards ;i++) {
     206           0 :     fTimeResolution[i]  = calibda.GetTimeResolution(i);
     207           0 :     fWidthResolution[i] = calibda.GetWidthResolution(i);          
     208           0 :     fMatchWindow[i] = calibda.GetMatchWindow(i);
     209           0 :     fSearchWindow[i] = calibda.GetSearchWindow(i);
     210           0 :     fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
     211           0 :     fRollOver[i] = calibda.GetRollOver(i);
     212             :   }
     213             :   
     214           0 :   for(int i=0; i<kNCIUBoards ;i++) {
     215           0 :     fClk1Win1[i] = calibda.GetClk1Win1(i);
     216           0 :     fClk1Win2[i] = calibda.GetClk1Win2(i);
     217           0 :     fDelayClk1Win1[i] = calibda.GetDelayClk1Win1(i);
     218           0 :     fDelayClk1Win2[i] = calibda.GetDelayClk1Win2(i);
     219           0 :     fClk2Win1[i] = calibda.GetClk2Win1(i);
     220           0 :     fClk2Win2[i] = calibda.GetClk2Win2(i);
     221           0 :     fDelayClk2Win1[i] = calibda.GetDelayClk2Win1(i);
     222           0 :     fDelayClk2Win2[i] = calibda.GetDelayClk2Win2(i);
     223           0 :     fLatchWin1[i] = calibda.GetLatchWin1(i);
     224           0 :     fLatchWin2[i] = calibda.GetLatchWin2(i);
     225           0 :     fResetWin1[i] = calibda.GetResetWin1(i);
     226           0 :     fResetWin2[i] = calibda.GetResetWin2(i);
     227           0 :     fPedestalSubtraction[i] = GetPedestalSubtraction(i);
     228             :   }
     229           0 :   for(Int_t j = 0; j < 16; ++j) {
     230           0 :     fEnableCharge[j] = calibda.GetEnableCharge(j);
     231           0 :     fEnableTiming[j] = calibda.GetEnableTiming(j);
     232           0 :     fPedestalOdd[j] = calibda.GetOnlinePedestal(0,j);
     233           0 :     fPedestalEven[j] = calibda.GetOnlinePedestal(1,j);;
     234           0 :     fPedestalCutOdd[j] = calibda.GetOnlinePedestalCut(0,j);
     235           0 :     fPedestalCutEven[j] = calibda.GetOnlinePedestal(1,j);
     236             :   }
     237           0 :   for(Int_t i = 0; i < 5; ++i) fTriggerSelected[i] = calibda.GetTriggerSelected(i);
     238             :   
     239           0 : }
     240             : 
     241             : //________________________________________________________________
     242             : AliADCalibData &AliADCalibData::operator =(const AliADCalibData& calibda)
     243             : {
     244             :   // assignment operator
     245             : 
     246           0 :   SetName(calibda.GetName());
     247           0 :   SetTitle(calibda.GetName());
     248             :   
     249           0 :   for(int t=0; t<32; t++) {
     250           0 :     fPedestal[t] = calibda.GetPedestal(t);
     251           0 :     fSigma[t]    = calibda.GetSigma(t);
     252           0 :     fADCmean[t]  = calibda.GetADCmean(t);
     253           0 :     fADCsigma[t] = calibda.GetADCsigma(t); }
     254             :       
     255           0 :   for(int t=0; t<16; t++) {
     256           0 :     fMeanHV[t]       = calibda.GetMeanHV(t);
     257           0 :     fWidthHV[t]      = calibda.GetWidthHV(t);        
     258           0 :     fTimeOffset[t]   = calibda.GetTimeOffset(t);
     259           0 :     fTimeGain[t]     = calibda.GetTimeGain(t); 
     260           0 :     fDeadChannel[t]  = calibda.IsChannelDead(t);
     261           0 :     fDiscriThr[t]    = calibda.GetDiscriThr(t);
     262             :   }   
     263           0 :   for(int i=0; i<kNCIUBoards ;i++) {
     264           0 :     fTimeResolution[i]  = calibda.GetTimeResolution(i);
     265           0 :     fWidthResolution[i] = calibda.GetWidthResolution(i);          
     266           0 :     fMatchWindow[i] = calibda.GetMatchWindow(i);
     267           0 :     fSearchWindow[i] = calibda.GetSearchWindow(i);
     268           0 :     fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
     269           0 :     fRollOver[i] = calibda.GetRollOver(i);
     270             :   }
     271             :   
     272           0 :   for(int i=0; i<kNCIUBoards ;i++) {
     273           0 :     fClk1Win1[i] = calibda.GetClk1Win1(i);
     274           0 :     fClk1Win2[i] = calibda.GetClk1Win2(i);
     275           0 :     fDelayClk1Win1[i] = calibda.GetDelayClk1Win1(i);
     276           0 :     fDelayClk1Win2[i] = calibda.GetDelayClk1Win2(i);
     277           0 :     fClk2Win1[i] = calibda.GetClk2Win1(i);
     278           0 :     fClk2Win2[i] = calibda.GetClk2Win2(i);
     279           0 :     fDelayClk2Win1[i] = calibda.GetDelayClk2Win1(i);
     280           0 :     fDelayClk2Win2[i] = calibda.GetDelayClk2Win2(i);
     281           0 :     fLatchWin1[i] = calibda.GetLatchWin1(i);
     282           0 :     fLatchWin2[i] = calibda.GetLatchWin2(i);
     283           0 :     fResetWin1[i] = calibda.GetResetWin1(i);
     284           0 :     fResetWin2[i] = calibda.GetResetWin2(i);
     285           0 :     fPedestalSubtraction[i] = GetPedestalSubtraction(i);
     286             :   }
     287           0 :   for(Int_t j = 0; j < 16; ++j) {
     288           0 :     fEnableCharge[j] = calibda.GetEnableCharge(j);
     289           0 :     fEnableTiming[j] = calibda.GetEnableTiming(j);
     290           0 :     fPedestalOdd[j] = calibda.GetOnlinePedestal(0,j);
     291           0 :     fPedestalEven[j] = calibda.GetOnlinePedestal(1,j);;
     292           0 :     fPedestalCutOdd[j] = calibda.GetOnlinePedestalCut(0,j);
     293           0 :     fPedestalCutEven[j] = calibda.GetOnlinePedestal(1,j);
     294             :   }
     295           0 :   for(Int_t i = 0; i < 5; ++i) fTriggerSelected[i] = calibda.GetTriggerSelected(i); 
     296             :    
     297           0 :   return *this;
     298             :   
     299             : }
     300             : 
     301             : //________________________________________________________________
     302             : AliADCalibData::~AliADCalibData()
     303           0 : {
     304             :   // destructor
     305           0 :   if (fLightYields)
     306           0 :     delete [] fLightYields;
     307           0 :   if (fPMGainsA)
     308           0 :     delete [] fPMGainsA;
     309           0 :   if (fPMGainsB)
     310           0 :     delete [] fPMGainsB;
     311           0 :   if (fThrCalibA)
     312           0 :     delete [] fThrCalibA;
     313           0 :   if (fThrCalibB)
     314           0 :     delete [] fThrCalibB;
     315           0 : }
     316             : 
     317             : //________________________________________________________________
     318             : Float_t AliADCalibData::GetLightYields(Int_t channel)
     319             : {
     320             :   // Get the light yield efficiency
     321             :   // for a given channel
     322           0 :   if (!fLightYields) InitLightYields();
     323             : 
     324           0 :   if (channel >= 0 && channel < 16) {
     325           0 :     return fLightYields[channel];
     326             :   }
     327             : 
     328           0 :   AliError(Form("Wrong channel index: %d",channel));
     329           0 :   return 0;
     330           0 : }
     331             : 
     332             : //________________________________________________________________
     333             : void  AliADCalibData::InitLightYields()
     334             : {
     335             :   // Initialize the light yield factors
     336             :   // Read from a separate OCDB entry
     337           0 :   if (fLightYields) return;
     338             : 
     339           0 :   AliCDBEntry *entry = AliCDBManager::Instance()->Get("AD/Calib/LightYields");
     340           0 :   if (!entry) AliFatal("AD light yields are not found in OCDB !");
     341           0 :   TH1F *yields = (TH1F*)entry->GetObject();
     342             : 
     343           0 :   fLightYields = new Float_t[16];
     344           0 :   for(Int_t i = 0 ; i < 16; ++i) {
     345           0 :     fLightYields[i] = yields->GetBinContent(i+1);
     346             :   }
     347           0 : }
     348             : 
     349             : //________________________________________________________________
     350             : void  AliADCalibData::InitPMGains()
     351             : {
     352             :   // Initialize the PM gain factors
     353             :   // Read from a separate OCDB entry
     354           0 :   if (fPMGainsA) return;
     355             : 
     356           0 :   AliCDBEntry *entry = AliCDBManager::Instance()->Get("AD/Calib/PMGains");
     357           0 :   if (!entry) AliFatal("AD PM gains are not found in OCDB !");
     358           0 :   TH2F *gains = (TH2F*)entry->GetObject();
     359             : 
     360           0 :   fPMGainsA = new Float_t[16];
     361           0 :   fPMGainsB = new Float_t[16];
     362           0 :   for(Int_t i = 0 ; i < 16; ++i) {
     363           0 :     fPMGainsA[i] = gains->GetBinContent(i+1,1);
     364           0 :     fPMGainsB[i] = gains->GetBinContent(i+1,2);
     365             :   }
     366           0 : }
     367             : 
     368             : //________________________________________________________________
     369             : Float_t AliADCalibData::GetGain(Int_t channel)
     370             : {
     371             :   // Computes the PM gains
     372             :   // Argument passed is the PM number (aliroot numbering)
     373           0 :   if (!fPMGainsA) InitPMGains();
     374             : 
     375             :   // High Voltage retrieval from Calibration Data Base:  
     376           0 :   Float_t hv = fMeanHV[channel];
     377             :   Float_t gain = 0;
     378           0 :   if (hv>0)
     379             :     //gain = TMath::Exp(fPMGainsA[channel]+fPMGainsB[channel]*TMath::Log(hv));
     380           0 :     gain = TMath::Power(hv/fPMGainsA[channel],fPMGainsB[channel])*kADChargePerADC/kNPhotonsPerMIP;
     381           0 :   return gain;
     382             : }
     383             : //________________________________________________________________
     384             : Float_t AliADCalibData::GetADCperMIP(Int_t channel)
     385             : {
     386             :   // Computes the MIP position wrt gain curve and HV
     387             :   // Argument passed is the PM number (aliroot numbering)
     388           0 :   if (!fPMGainsA) InitPMGains();
     389             : 
     390             :   // High Voltage retrieval from Calibration Data Base:  
     391           0 :   Float_t hv = fMeanHV[channel];
     392             :   Float_t ADCperMIP = 0;
     393           0 :   if (hv>0)
     394           0 :     ADCperMIP = TMath::Power(hv/fPMGainsA[channel],fPMGainsB[channel]);
     395           0 :   return ADCperMIP;
     396             : }
     397             : //________________________________________________________________
     398             : void  AliADCalibData::InitCalibThresholds()
     399             : {
     400             :   // Initialize the PM gain factors
     401             :   // Read from a separate OCDB entry
     402           0 :   if (fThrCalibA) return;
     403             : 
     404           0 :   AliCDBEntry *entry = AliCDBManager::Instance()->Get("AD/Calib/Thresholds");
     405           0 :   if (!entry) AliFatal("AD Thresholds are not found in OCDB !");
     406           0 :   TH2F *thrCalib = (TH2F*)entry->GetObject();
     407             : 
     408           0 :   fThrCalibA = new Float_t[16];
     409           0 :   fThrCalibB = new Float_t[16];
     410           0 :   for(Int_t i = 0 ; i < 16; ++i) {
     411           0 :     fThrCalibA[i] = thrCalib->GetBinContent(i+1,1);
     412           0 :     fThrCalibB[i] = thrCalib->GetBinContent(i+1,2);
     413             :   }
     414           0 : }
     415             : 
     416             : //________________________________________________________________
     417             : Float_t AliADCalibData::GetCalibDiscriThr(Int_t channel)
     418             : {
     419             :   // The method returns actual TDC discri threshold
     420             :   // extracted from the data.
     421           0 :   if (!fThrCalibA) InitCalibThresholds();
     422             :   
     423           0 :   Float_t thr = GetDiscriThr(channel);
     424             : 
     425           0 :   Float_t calThr = fThrCalibA[channel]*thr + fThrCalibB[channel];
     426             : 
     427           0 :   return calThr;
     428             : }
     429             : //_____________________________________________________________________________
     430             : void AliADCalibData::FillDCSData(AliADDataDCS * data){
     431             :   // Set all parameters from the data get by the shuttle
     432           0 :   TMap * params = data->GetFEEParameters();
     433           0 :   TIter iter(params);   
     434             :   TObjString* aliasName;
     435             :         
     436           0 :   while ((  aliasName = (TObjString*) iter.Next() ))  {
     437           0 :     AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName);
     438             :     UInt_t val;
     439           0 :     if(aValue) {
     440           0 :       val = aValue->GetUInt();
     441           0 :       SetParameter(aliasName->String(),val);
     442           0 :     }
     443             :   }     
     444             :         
     445           0 :   SetMeanHV(data->GetMeanHV());
     446           0 :   SetWidthHV(data->GetWidthHV());
     447           0 :   SetDeadMap(data->GetDeadMap());
     448             : 
     449           0 : }
     450             : //_____________________________________________________________________________
     451             : void AliADCalibData::SetADCperMIP(Int_t nADCperMIP){
     452             :   //Sets HV in a way to have uniform gains on PM according  
     453             :   //to number of ADC per MIP 
     454           0 :   if (!fPMGainsA) InitPMGains();
     455             :   Double_t hv = 0;
     456           0 :   for(Int_t channel = 0; channel<16; channel++){
     457           0 :     hv = TMath::Power(nADCperMIP,1/fPMGainsB[channel])*fPMGainsA[channel];
     458           0 :     SetMeanHV(hv,channel);
     459           0 :     AliInfo(Form("HV on channel %d set to %f V",channel,hv));
     460             :   }
     461           0 : }
     462             : 
     463             : //_____________________________________________________________________________
     464             : void AliADCalibData::SetParameter(TString name, Int_t val){
     465             :   // Set given parameter
     466             :         
     467           0 :   Int_t iBoard = -1;
     468           0 :   Int_t iChannel = -1;
     469             : 
     470           0 :   TSeqCollection* nameSplit = name.Tokenize("/");
     471           0 :   TObjString * boardName = (TObjString *)nameSplit->At(2);
     472           0 :   sscanf(boardName->String().Data(),"CIU%d",&iBoard);
     473             : 
     474           0 :   TString paramName = ((TObjString *)nameSplit->At(3))->String();
     475           0 :   Char_t channel[2] ; channel[1] = '\0';
     476           0 :   channel[0] = paramName[paramName.Sizeof()-2];
     477           0 :   sscanf(channel,"%d",&iChannel);
     478             :                 
     479           0 :   if(name.Contains("TimeResolution")) SetTimeResolution((UShort_t) val,iBoard);
     480           0 :   else if(name.Contains("WidthResolution")) SetWidthResolution((UShort_t) val,iBoard);
     481           0 :   else if(name.Contains("MatchWindow")) SetMatchWindow((UInt_t) val,iBoard);
     482           0 :   else if(name.Contains("SearchWindow")) SetSearchWindow((UInt_t) val,iBoard);
     483           0 :   else if(name.Contains("TriggerCountOffset")) SetTriggerCountOffset((UInt_t) val,iBoard);
     484           0 :   else if(name.Contains("RollOver")) SetRollOver((UInt_t) val,iBoard);
     485           0 :   else if(name.Contains("DelayHit")) SetTimeOffset(0.01*(Float_t)val,iBoard,(iChannel-1));
     486           0 :   else if(name.Contains("DiscriThr")) SetDiscriThr(((Float_t)val-2040.)/112.,iBoard,(iChannel-1));
     487             :                 
     488           0 :   else if(name.Contains("DelayClk1Win1")) SetDelayClk1Win1((UShort_t) val,iBoard);
     489           0 :   else if(name.Contains("Clk1Win1")) SetClk1Win1((UShort_t) val,iBoard);
     490           0 :   else if(name.Contains("DelayClk1Win2")) SetDelayClk1Win2((UShort_t) val,iBoard);
     491           0 :   else if(name.Contains("Clk1Win2")) SetClk1Win2((UShort_t) val,iBoard);
     492           0 :   else if(name.Contains("DelayClk2Win1")) SetDelayClk2Win1((UShort_t) val,iBoard);
     493           0 :   else if(name.Contains("Clk2Win1")) SetClk2Win1((UShort_t) val,iBoard);
     494           0 :   else if(name.Contains("DelayClk2Win2")) SetDelayClk2Win2((UShort_t) val,iBoard);
     495           0 :   else if(name.Contains("Clk2Win2")) SetClk2Win2((UShort_t) val,iBoard);
     496           0 :   else if(name.Contains("LatchWin1")) SetLatchWin1((UShort_t) val,iBoard);
     497           0 :   else if(name.Contains("LatchWin2")) SetLatchWin2((UShort_t) val,iBoard);
     498           0 :   else if(name.Contains("ResetWin1")) SetResetWin1((UShort_t) val,iBoard);
     499           0 :   else if(name.Contains("ResetWin2")) SetResetWin2((UShort_t) val,iBoard);
     500           0 :   else if(name.Contains("PedestalSubtraction")) SetPedestalSubtraction((Bool_t) val,iBoard);
     501           0 :   else if(name.Contains("BBAThreshold")) SetBBAThreshold((UShort_t) val);
     502           0 :   else if(name.Contains("BBCThreshold")) SetBBCThreshold((UShort_t) val);
     503           0 :   else if(name.Contains("BGAThreshold")) SetBGAThreshold((UShort_t) val);
     504           0 :   else if(name.Contains("BGCThreshold")) SetBGCThreshold((UShort_t) val);
     505           0 :   else if(name.Contains("BBAForBGThreshold")) SetBBAForBGThreshold((UShort_t) val);
     506           0 :   else if(name.Contains("BBCForBGThreshold")) SetBBCForBGThreshold((UShort_t) val);
     507           0 :   else if(name.Contains("MultADAThrLow")) SetMultADAThrLow((UShort_t) val);
     508           0 :   else if(name.Contains("MultADAThrHigh")) SetMultADAThrHigh((UShort_t) val);
     509           0 :   else if(name.Contains("MultADCThrLow")) SetMultADCThrLow((UShort_t) val);
     510           0 :   else if(name.Contains("MultADCThrHigh")) SetMultADCThrHigh((UShort_t) val);
     511           0 :   else if(name.Contains("TriggerSelect")) SetTriggerSelected((UShort_t) val, iChannel-1 );
     512           0 :   else if(name.Contains("EnableCharge")) SetEnableCharge((Bool_t) val, iBoard , iChannel-1);
     513           0 :   else if(name.Contains("EnableTiming")) SetEnableTiming((Bool_t) val, iBoard , iChannel-1);
     514           0 :   else if(name.Contains("PedOdd")) SetOnlinePedestal((UShort_t) val, 1, iBoard, iChannel-1);
     515           0 :   else if(name.Contains("PedEven")) SetOnlinePedestal((UShort_t) val, 0, iBoard, iChannel-1);
     516           0 :   else if(name.Contains("PedCutOdd")) SetOnlinePedestalCut((UShort_t) val, 1, iBoard, iChannel-1);
     517           0 :   else if(name.Contains("PedCutEven")) SetOnlinePedestalCut((UShort_t) val, 0, iBoard, iChannel-1);
     518             :         
     519           0 :   else AliError(Form("No Setter found for FEE parameter : %s",name.Data()));
     520             :   //
     521           0 :   delete nameSplit;
     522           0 : }
     523             : 
     524             : //________________________________________________________________
     525             : void AliADCalibData::SetPedestal(const Float_t* Pedestal)
     526             : {
     527           0 :   if(Pedestal) for(int t=0; t<32; t++) fPedestal[t] = Pedestal[t];
     528           0 :   else for(int t=0; t<32; t++) fPedestal[t] = 0.0;
     529           0 : }
     530             : 
     531             : //________________________________________________________________
     532             : void AliADCalibData::SetSigma(const Float_t* Sigma)
     533             : {
     534           0 :   if(Sigma) for(int t=0; t<32; t++) fSigma[t] = Sigma[t];
     535           0 :   else for(int t=0; t<32; t++) fSigma[t] = 0.0;
     536           0 : }
     537             : 
     538             : //________________________________________________________________
     539             : void AliADCalibData::SetADCmean(const Float_t* ADCmean) 
     540             : {
     541           0 :   if(ADCmean) for(int t=0; t<32; t++) fADCmean[t] = ADCmean[t];
     542           0 :   else for(int t=0; t<32; t++) fADCmean[t] = 0.0;
     543           0 : }
     544             : 
     545             : //________________________________________________________________
     546             : void AliADCalibData::SetADCsigma(const Float_t* ADCsigma) 
     547             : {
     548           0 :   if(ADCsigma) for(int t=0; t<32; t++) fADCsigma[t] = ADCsigma[t];
     549           0 :   else for(int t=0; t<32; t++) fADCsigma[t] = 0.0;
     550           0 : }
     551             : 
     552             : //________________________________________________________________
     553             : void AliADCalibData::SetMeanHV(const Float_t* MeanHV) 
     554             : {
     555           0 :   if(MeanHV) for(int t=0; t<16; t++) fMeanHV[t] = MeanHV[t];
     556           0 :   else for(int t=0; t<16; t++) fMeanHV[t] = 0.0;
     557           0 : }
     558             : 
     559             : //________________________________________________________________
     560             : void AliADCalibData::SetWidthHV(const Float_t* WidthHV) 
     561             : {
     562           0 :   if(WidthHV) for(int t=0; t<16; t++) fWidthHV[t] = WidthHV[t];
     563           0 :   else for(int t=0; t<16; t++) fWidthHV[t] = 0.0;
     564           0 : }
     565             : 
     566             : //________________________________________________________________
     567             : void AliADCalibData::SetDeadMap(const Bool_t* deadMap) 
     568             : {
     569           0 :   if(deadMap) for(int t=0; t<16; t++) fDeadChannel[t] = deadMap[t];
     570           0 :   else for(int t=0; t<16; t++) fDeadChannel[t] = kFALSE;
     571           0 : }
     572             : 
     573             : //________________________________________________________________
     574             : void AliADCalibData::SetTimeOffset(Float_t val, Int_t board, Int_t channel)
     575             : {
     576           0 :   Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
     577           0 :   if(ch >= 0) fTimeOffset[ch]=val;
     578             :   else
     579           0 :     AliError("Board/Channel numbers are not valid");
     580           0 : }
     581             : 
     582             : //________________________________________________________________
     583             : void AliADCalibData::SetTimeOffset(const Float_t* TimeOffset) 
     584             : {
     585           0 :   if(TimeOffset) for(int t=0; t<16; t++) fTimeOffset[t] = TimeOffset[t];
     586           0 :   else for(int t=0; t<16; t++) fTimeOffset[t] = 5.0;
     587           0 : }
     588             : //________________________________________________________________
     589             : void AliADCalibData::SetTimeGain(const Float_t* TimeGain) 
     590             : {
     591           0 :   if(TimeGain) for(int t=0; t<16; t++) fTimeGain[t] = TimeGain[t];
     592           0 :   else for(int t=0; t<16; t++) fTimeGain[t] = 0.0;
     593           0 : }
     594             : //________________________________________________________________
     595             : void AliADCalibData::SetTimeResolution(UShort_t *resols){
     596             :   // Set Time Resolution of the TDC
     597           0 :   if(resols)  for(int t=0; t<kNCIUBoards; t++) SetTimeResolution(resols[t],t);
     598           0 :   else AliError("Time Resolution not defined.");
     599             :         
     600           0 : }
     601             : //________________________________________________________________
     602             : void AliADCalibData::SetTimeResolution(UShort_t resol, Int_t board)
     603             : {
     604             :   // Set Time Resolution of the TDC
     605           0 :   if((board>=0) && (board<kNCIUBoards)) {
     606           0 :     switch(resol){
     607             :     case 0:
     608           0 :       fTimeResolution[board] = 25./256.;
     609           0 :       break;
     610             :     case 1:
     611           0 :       fTimeResolution[board] = 25./128.;
     612           0 :       break;
     613             :     case 2:
     614           0 :       fTimeResolution[board] = 25./64.;
     615           0 :       break;
     616             :     case 3:
     617           0 :       fTimeResolution[board] = 25./32.;
     618           0 :       break;
     619             :     case 4:
     620           0 :       fTimeResolution[board] = 25./16.;
     621           0 :       break;
     622             :     case 5:
     623           0 :       fTimeResolution[board] = 25./8.;
     624           0 :       break;
     625             :     case 6:
     626           0 :       fTimeResolution[board] = 6.25;
     627           0 :       break;
     628             :     case 7:
     629           0 :       fTimeResolution[board] = 12.5;
     630           0 :       break;
     631             :     }
     632           0 :   } else AliError(Form("Board %d is not valid",board));
     633           0 : }
     634             : //________________________________________________________________
     635             : void AliADCalibData::SetWidthResolution(UShort_t *resols){
     636             :   // Set Time Width Resolution of the TDC
     637           0 :   if(resols)  for(int t=0; t<kNCIUBoards; t++) SetWidthResolution(resols[t],t);
     638           0 :   else AliError("Width Resolution not defined.");
     639             :         
     640           0 : }
     641             : //________________________________________________________________
     642             : void AliADCalibData::SetWidthResolution(UShort_t resol, Int_t board)
     643             : {
     644             :   // Set Time Width Resolution of the TDC
     645           0 :   if((board>=0) && (board<kNCIUBoards)){
     646           0 :     switch(resol){
     647             :     case 0:
     648           0 :       fWidthResolution[board] = 25./256.;
     649           0 :       break;
     650             :     case 1:
     651           0 :       fWidthResolution[board] = 25./128.;
     652           0 :       break;
     653             :     case 2:
     654           0 :       fWidthResolution[board] = 25./64.;
     655           0 :       break;
     656             :     case 3:
     657           0 :       fWidthResolution[board] = 25./32.;
     658           0 :       break;
     659             :     case 4:
     660           0 :       fWidthResolution[board] = 25./16.;
     661           0 :       break;
     662             :     case 5:
     663           0 :       fWidthResolution[board] = 25./8.;
     664           0 :       break;
     665             :     case 6:
     666           0 :       fWidthResolution[board] = 6.25;
     667           0 :       break;
     668             :     case 7:
     669           0 :       fWidthResolution[board] = 12.5;
     670           0 :       break;
     671             :     case 8:
     672           0 :       fWidthResolution[board] = 25.;
     673           0 :       break;
     674             :     case 9:
     675           0 :       fWidthResolution[board] = 50.;
     676           0 :       break;
     677             :     case 10:
     678           0 :       fWidthResolution[board] = 100.;
     679           0 :       break;
     680             :     case 11:
     681           0 :       fWidthResolution[board] = 200.;
     682           0 :       break;
     683             :     case 12:
     684           0 :       fWidthResolution[board] = 400.;
     685           0 :       break;
     686             :     case 13:
     687           0 :       fWidthResolution[board] = 800.;
     688           0 :       break;
     689             :                                 
     690             :     }
     691           0 :   }else AliError(Form("Board %d is not valid",board));
     692           0 : }
     693             : 
     694             : //________________________________________________________________
     695             : void AliADCalibData::SetMatchWindow(UInt_t *windows)
     696             : {
     697             :   // Set Match window of the HPTDC
     698             :   // The units are 25ns
     699           0 :   if(windows)  for(Int_t b=0; b<kNCIUBoards; b++) SetMatchWindow(windows[b],b);
     700           0 :   else AliError("Match windows not defined.");
     701           0 : }
     702             : 
     703             : //________________________________________________________________
     704             : void AliADCalibData::SetMatchWindow(UInt_t window, Int_t board)
     705             : {
     706             :   // Set Match window of the HPTDC
     707             :   // The units are 25ns
     708           0 :   if((board>=0) && (board<kNCIUBoards)) fMatchWindow[board] = window;
     709             :   else
     710           0 :     AliError(Form("Board %d is not valid",board));
     711           0 : }
     712             : 
     713             : //________________________________________________________________
     714             : void AliADCalibData::SetSearchWindow(UInt_t *windows)
     715             : {
     716             :   // Set Search window of the HPTDC
     717             :   // The units are 25ns
     718           0 :   if(windows)  for(Int_t b=0; b<kNCIUBoards; b++) SetSearchWindow(windows[b],b);
     719           0 :   else AliError("Search windows not defined.");
     720           0 : }
     721             : 
     722             : //________________________________________________________________
     723             : void  AliADCalibData::SetSearchWindow(UInt_t window, Int_t board)
     724             : {
     725             :   // Set Search window of the HPTDC
     726             :   // The units are 25ns
     727           0 :   if((board>=0) && (board<kNCIUBoards)) fSearchWindow[board] = window;
     728             :   else
     729           0 :     AliError(Form("Board %d is not valid",board));
     730           0 : }
     731             : 
     732             : //________________________________________________________________
     733             : void AliADCalibData::SetTriggerCountOffset(UInt_t *offsets)
     734             : {
     735             :   // Set trigger-count offset of the HPTDC
     736             :   // The units are 25ns
     737           0 :   if(offsets)  for(Int_t b=0; b<kNCIUBoards; b++) SetTriggerCountOffset(offsets[b],b);
     738           0 :   else AliError("Trigger count offsets not defined.");
     739           0 : }
     740             : 
     741             : //________________________________________________________________
     742             : void AliADCalibData::SetTriggerCountOffset(UInt_t offset, Int_t board)
     743             : {
     744             :   // Set trigger-count offsets of the HPTDC
     745             :   // The units are 25ns
     746           0 :   if((board>=0) && (board<kNCIUBoards)) fTriggerCountOffset[board] = offset;
     747             :   else
     748           0 :     AliError(Form("Board %d is not valid",board));
     749           0 : }
     750             : 
     751             : //________________________________________________________________
     752             : void AliADCalibData::SetRollOver(UInt_t *offsets)
     753             : {
     754             :   // Set Roll-over of the HPTDC
     755             :   // The units are 25ns
     756           0 :   if(offsets)  for(Int_t b=0; b<kNCIUBoards; b++) SetRollOver(offsets[b],b);
     757           0 :   else AliError("Roll-over offsets not defined.");
     758           0 : }
     759             : 
     760             : //________________________________________________________________
     761             : void AliADCalibData::SetRollOver(UInt_t offset, Int_t board)
     762             : {
     763             :   // Set Roll-over of the HPTDC
     764             :   // The units are 25ns
     765           0 :   if((board>=0) && (board<kNCIUBoards)) fRollOver[board] = offset;
     766             :   else
     767           0 :     AliError(Form("Board %d is not valid",board));
     768           0 : }
     769             : 
     770             : //________________________________________________________________
     771             : void AliADCalibData::SetDiscriThr(Float_t thr, Int_t board, Int_t channel)
     772             : {
     773             :   // Set the TDC discriminator
     774             :   // threshold values expressed in units of ADC
     775           0 :   Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
     776           0 :   if(ch >= 0) fDiscriThr[ch]=thr;
     777             :   else
     778           0 :     AliError("Board/Channel numbers are not valid");
     779           0 : }
     780             : 
     781             : //________________________________________________________________
     782             : void AliADCalibData::SetDiscriThr(const Float_t* thresholds) 
     783             : {
     784             :   // Set the TDC discriminator
     785             :   // threshold values expressed in units of ADC
     786           0 :   if(thresholds) for(int t=0; t<16; t++) fDiscriThr[t] = thresholds[t];
     787           0 :   else for(int t=0; t<16; t++) fDiscriThr[t] = 2.5;
     788           0 : }
     789             : 
     790             : 
     791             : //________________________________________________________________
     792             : void AliADCalibData::SetOnlinePedestalCut(UShort_t val,Int_t integrator, Int_t channel)
     793             : {
     794             :   // Set Pedestal Cut of individual channel 
     795           0 :   if(channel>=0 && channel<16) {
     796           0 :     if(integrator) fPedestalCutOdd[channel] = val;
     797           0 :     else fPedestalCutEven[channel] = val;
     798           0 :   } else AliError(Form("Impossible to write at : Channel %d",channel));
     799           0 : }
     800             : //________________________________________________________________
     801             : void AliADCalibData::SetOnlinePedestalCut(UShort_t val,Int_t integrator, Int_t board, Int_t channel)
     802             : {
     803           0 :   Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
     804           0 :   if(ch>=0 && ch<16) {
     805           0 :     if(integrator) fPedestalCutOdd[ch] = val;
     806           0 :     else fPedestalCutEven[ch] = val;
     807             :   }
     808             :   else
     809           0 :     AliError("Board/Channel numbers are not valid");
     810           0 : }
     811             : //________________________________________________________________
     812             : UShort_t AliADCalibData::GetOnlinePedestalCut(Int_t integrator, Int_t channel) const
     813             : {
     814             :   // Get Pedestal Cut of individual channel 
     815           0 :   if(channel>=0 && channel<16) {
     816           0 :     if(integrator) return(fPedestalCutOdd[channel]);
     817           0 :     else return(fPedestalCutEven[channel]);
     818           0 :   }else AliError(Form("Impossible to read at : Channel %d",channel));
     819           0 :   return 0;
     820           0 : }
     821             : //________________________________________________________________
     822             : void AliADCalibData::SetOnlinePedestal(UShort_t val, Int_t integrator, Int_t channel)
     823             : {
     824             :   // Set Pedestal of individual channel 
     825           0 :   if(channel>=0 && channel<16) {
     826           0 :     if(integrator) fPedestalOdd[channel] = val;
     827           0 :     else fPedestalEven[channel] = val;
     828           0 :   } else AliError(Form("Impossible to write at : Channel %d ; Integrator %d ",channel,integrator));
     829           0 : }
     830             : //________________________________________________________________
     831             : void AliADCalibData::SetOnlinePedestal(UShort_t val,Int_t integrator, Int_t board, Int_t channel)
     832             : {
     833           0 :   Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
     834           0 :   if(ch>=0 && ch<16) {
     835           0 :     if(integrator) fPedestalOdd[ch] = val;
     836           0 :     else fPedestalEven[ch] = val;
     837             :   }
     838             :   else
     839           0 :     AliError("Board/Channel numbers are not valid");
     840           0 : }
     841             : //________________________________________________________________
     842             : UShort_t AliADCalibData::GetOnlinePedestal(Int_t integrator, Int_t channel) const
     843             : {
     844             :   // Get Pedestal of individual channel 
     845           0 :   if(channel>=0 && channel<16) {
     846           0 :     if(integrator) return(fPedestalOdd[channel]);
     847           0 :     else return(fPedestalEven[channel]);
     848           0 :   } else AliError(Form("Impossible to read at : Channel %d",channel));
     849           0 :   return 0;
     850           0 : }
     851             : //________________________________________________________________
     852             : void AliADCalibData::SetEnableCharge(Bool_t val, Int_t channel)
     853             : {
     854             :   // Set the channels enabled for Charge triggers
     855           0 :   if(channel>=0 && channel<16) fEnableCharge[channel] = val;
     856           0 :   else AliError(Form("Impossible to write at : Channel %d",channel));
     857           0 : }
     858             : //________________________________________________________________
     859             : Bool_t AliADCalibData::GetEnableCharge(Int_t channel) const
     860             : {
     861             :   // Get the channels enabled for Charge triggers
     862           0 :   if(channel>=0 && channel<16) return(fEnableCharge[channel]);
     863           0 :   else AliError(Form("Impossible to read at : Channel %d",channel));
     864           0 :   return kFALSE;
     865           0 : }
     866             : //________________________________________________________________
     867             : void AliADCalibData::SetEnableTiming(Bool_t val, Int_t channel)
     868             : {
     869             :   // Set the channels enabled for Timing triggers
     870           0 :   if(channel>=0 && channel<16) fEnableTiming[channel] = val;
     871           0 :   else AliError(Form("Impossible to write at : Channel %d",channel));
     872           0 : }
     873             : //________________________________________________________________
     874             : Bool_t AliADCalibData::GetEnableTiming(Int_t channel) const
     875             : {
     876             :   // Get the channels enabled for Timing triggers
     877           0 :   if(channel>=0 && channel<16) return(fEnableTiming[channel]);
     878           0 :   else AliError(Form("Impossible to read at : Channel %d",channel));
     879           0 :   return kFALSE;
     880           0 : }
     881             : //________________________________________________________________
     882             : void AliADCalibData::SetEnableCharge(Bool_t val,Int_t board, Int_t channel)
     883             : {
     884           0 :   Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
     885             :   // Set the channels enabled for Charge triggers
     886           0 :   if(ch>=0) fEnableCharge[ch] = val;
     887           0 :   else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
     888           0 : }
     889             : //________________________________________________________________
     890             : void AliADCalibData::SetEnableTiming(Bool_t val,Int_t board, Int_t channel)
     891             : {
     892           0 :   Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
     893             :   // Set the channels enabled for Timing triggers
     894           0 :   if(ch>=0) fEnableTiming[ch] = val;
     895           0 :   else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
     896           0 : }
     897             : //________________________________________________________________
     898             : void AliADCalibData::SetTriggerSelected(UShort_t trigger, Int_t output)
     899             : {
     900             :   // Set the trigger selected on the outputs to CTP
     901           0 :   if(output>=0 && output<5) fTriggerSelected[output] = trigger;
     902           0 :   else AliError(Form("Trigger output number %d not valid",output));
     903           0 : }
     904             : 
     905             : //________________________________________________________________
     906             : void AliADCalibData::SetClk1Win1(UShort_t* clks)
     907             : {
     908             :   // Set Win clock of BB
     909           0 :   if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win1(clks[t],t);
     910           0 :   else AliError("Profil Clock1 Win1 Not defined.");
     911           0 : }
     912             : //________________________________________________________________
     913             : void AliADCalibData::SetClk2Win1(UShort_t* clks)
     914             : {
     915             :   // Set Win clock of BB
     916           0 :   if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win1(clks[t],t);
     917           0 :   else AliError("Profil Clock2 Win1 Not defined.");
     918           0 : }
     919             : //________________________________________________________________
     920             : void AliADCalibData::SetClk1Win1(UShort_t clk, Int_t board)
     921             : {
     922             :   // Set Win clock of BB
     923           0 :   if((board>=0) && (board<kNCIUBoards)) {
     924           0 :     fClk1Win1[board] = clk;
     925           0 :     if(!IsClkValid(clk)) AliWarning(Form("Profil Clock1 Win1 of board %d is not valid : %d",board,clk));
     926             :   }else {
     927           0 :     AliError(Form("Impossible to Write at Board %d",board));
     928             :   }
     929           0 : }
     930             : //________________________________________________________________
     931             : void AliADCalibData::SetClk2Win1(UShort_t clk, Int_t board)
     932             : {
     933             :   // Set Win clock of BB
     934           0 :   if((board>=0) && (board<kNCIUBoards)) {
     935           0 :     fClk2Win1[board] = clk;
     936           0 :     if(!IsClkValid(clk)) AliWarning(Form("Profil Clock2 Win1 of board %d is not valid : %d",board,clk));
     937             :   }else {
     938           0 :     AliError(Form("Impossible to Write at Board %d",board));
     939             :   }
     940           0 : }
     941             : //________________________________________________________________
     942             : void AliADCalibData::SetClk1Win2(UShort_t* clks)
     943             : {
     944             :   // Set Win clock of BG
     945           0 :   if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win2(clks[t],t);
     946           0 :   else AliError("Profil Clock1 Win2 Not defined.");
     947           0 : }
     948             : //________________________________________________________________
     949             : void AliADCalibData::SetClk2Win2(UShort_t* clks)
     950             : {
     951             :   // Set Win clock of BG
     952           0 :   if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win2(clks[t],t);
     953           0 :   else AliError("Profil Clock2 Win2 Not defined.");
     954           0 : }
     955             : //________________________________________________________________
     956             : void AliADCalibData::SetClk1Win2(UShort_t clk, Int_t board)
     957             : {
     958             :   // Set Win clock of BG
     959           0 :   if((board>=0) && (board<kNCIUBoards)) {
     960           0 :     fClk1Win2[board] = clk;
     961           0 :     if(!IsClkValid(clk)) AliWarning(Form("Profil Clock1 Win2 of board %d is not valid : %d",board,clk));
     962             :   }else {
     963           0 :     AliError(Form("Impossible to Write at Board %d",board));
     964             :   }
     965           0 : }
     966             : //________________________________________________________________
     967             : void AliADCalibData::SetClk2Win2(UShort_t clk, Int_t board)
     968             : {
     969             :   // Set Win clock of BG
     970           0 :   if((board>=0) && (board<kNCIUBoards)) {
     971           0 :     fClk2Win2[board] = clk;
     972           0 :     if(!IsClkValid(clk)) AliWarning(Form("Profil Clock2 Win2 of board %d is not valid : %d",board,clk));
     973             :   }else {
     974           0 :     AliError(Form("Impossible to Write at Board %d",board));
     975             :   }
     976           0 : }
     977             : //________________________________________________________________
     978             : void AliADCalibData::SetDelayClk1Win1(UShort_t* delays)
     979             : {
     980             :   // Set Delay for Win clock of BB
     981           0 :   if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win1(delays[t],t);
     982           0 :   else AliError("Profil Clock1 Win1 Delays Not defined.");
     983           0 : }
     984             : //________________________________________________________________
     985             : void AliADCalibData::SetDelayClk1Win1(UShort_t delay, Int_t board)
     986             : {
     987             :   // Set Delay for Win clock of BB
     988           0 :   if(delay>1023){
     989           0 :     AliWarning(Form("Profil Clock1 Win1 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
     990           0 :     delay = delay & 0x3FF;
     991           0 :   }
     992           0 :   if((board>=0) && (board<kNCIUBoards))   fDelayClk1Win1[board] = delay;
     993           0 :   else AliError(Form("Trying to write out of the array Board = %d",board));
     994           0 : }
     995             : //________________________________________________________________
     996             : void AliADCalibData::SetDelayClk2Win1(UShort_t* delays)
     997             : {
     998             :   // Set Delay for Win clock of BB
     999           0 :   if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win1(delays[t],t);
    1000           0 :   else AliError("Profil Clock2 Win1 Delays Not defined.");
    1001           0 : }
    1002             : //________________________________________________________________
    1003             : void AliADCalibData::SetDelayClk2Win1(UShort_t delay, Int_t board)
    1004             : {
    1005             :   // Set Delay for Win clock of BB
    1006           0 :   if(delay>1023){
    1007           0 :     AliWarning(Form("Profil Clock2 Win1 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
    1008           0 :     delay = delay & 0x3FF;
    1009           0 :   }
    1010           0 :   if((board>=0) && (board<kNCIUBoards))   fDelayClk2Win1[board] = delay;
    1011           0 :   else AliError(Form("Trying to write out of the array Board = %d",board));
    1012           0 : }
    1013             : //________________________________________________________________
    1014             : void AliADCalibData::SetDelayClk1Win2(UShort_t* delays)
    1015             : {
    1016             :   // Set Delay for Win clock of BG
    1017           0 :   if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win2(delays[t],t);
    1018           0 :   else AliError("Profil Clock1 Win2 Delays Not defined.");
    1019           0 : }
    1020             : //________________________________________________________________
    1021             : void AliADCalibData::SetDelayClk1Win2(UShort_t delay, Int_t board)
    1022             : {
    1023             :   // Set Delay for Win clock of BG
    1024           0 :   if(delay>1023){
    1025           0 :     AliWarning(Form("Profil Clock1 Win2 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
    1026           0 :     delay = delay & 0x3FF;
    1027           0 :   }
    1028           0 :   if((board>=0) && (board<kNCIUBoards))   fDelayClk1Win2[board] = delay;
    1029           0 :   else AliError(Form("Trying to write out of the array Board = %d",board));
    1030           0 : }
    1031             : //________________________________________________________________
    1032             : void AliADCalibData::SetDelayClk2Win2(UShort_t* delays)
    1033             : {
    1034             :   // Set Delay for Win clock of BG
    1035           0 :   if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win2(delays[t],t);
    1036           0 :   else AliError("Profil Clock2 Win2 Delays Not defined.");
    1037           0 : }
    1038             : //________________________________________________________________
    1039             : void AliADCalibData::SetDelayClk2Win2(UShort_t delay, Int_t board)
    1040             : {
    1041             :   // Set Delay for Win clock of BG
    1042           0 :   if(delay>1023){
    1043           0 :     AliWarning(Form("Profil Clock2 Win2 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
    1044           0 :     delay = delay & 0x3FF;
    1045           0 :   }
    1046           0 :   if((board>=0) && (board<kNCIUBoards))   fDelayClk2Win2[board] = delay;
    1047           0 :   else AliError(Form("Trying to write out of the array Board = %d",board));
    1048           0 : }
    1049             : //________________________________________________________________
    1050             : void AliADCalibData::SetLatchWin1(UShort_t *latchs){
    1051             :   // Set Latch Win clock for BB
    1052           0 :   if(latchs) for(int t=0; t<kNCIUBoards; t++) SetLatchWin1(latchs[t],t);
    1053           0 :   else AliError("Latch Win1 profil Not defined.");
    1054           0 : }
    1055             : //________________________________________________________________
    1056             : void AliADCalibData::SetLatchWin1(UShort_t latch, Int_t board)
    1057             : {
    1058             :   // Set Latch Win clock for BB
    1059           0 :   if((board>=0) && (board<kNCIUBoards)) {
    1060           0 :     fLatchWin1[board] = latch;
    1061           0 :     if(!IsClkValid(latch)) AliWarning(Form("Latch Win1 of board %d is not valid : %d",board,latch));
    1062             :   }else {
    1063           0 :     AliError(Form("Impossible to Write at Board %d",board));
    1064             :   }
    1065           0 : }
    1066             : //________________________________________________________________
    1067             : void AliADCalibData::SetLatchWin2(UShort_t *latchs){
    1068             :   // Set Latch Win clock for BG
    1069           0 :   if(latchs) for(int t=0; t<kNCIUBoards; t++) SetLatchWin2(latchs[t],t);
    1070           0 :   else AliError("Latch Win2 profil Not defined.");
    1071           0 : }
    1072             : //________________________________________________________________
    1073             : void AliADCalibData::SetLatchWin2(UShort_t latch, Int_t board)
    1074             : {
    1075             :   // Set Latch Win clock for BG
    1076           0 :   if((board>=0) && (board<kNCIUBoards)) {
    1077           0 :     fLatchWin2[board] = latch;
    1078           0 :     if(!IsClkValid(latch)) AliWarning(Form("Latch Win2 of board %d is not valid : %d",board,latch));
    1079             :   }else {
    1080           0 :     AliError(Form("Impossible to Write at Board %d",board));
    1081             :   }
    1082           0 : }
    1083             : //________________________________________________________________
    1084             : void AliADCalibData::SetResetWin1(UShort_t *resets){
    1085             :   // Set Reset Win clock for BB
    1086           0 :   if(resets) for(int t=0; t<kNCIUBoards; t++) SetResetWin1(resets[t],t);
    1087           0 :   else AliError("Reset Win1 profil Not defined.");
    1088           0 : }
    1089             : //________________________________________________________________
    1090             : void AliADCalibData::SetResetWin1(UShort_t reset, Int_t board)
    1091             : {
    1092             :   // Set Reset Win clock for BB
    1093           0 :   if((board>=0) && (board<kNCIUBoards)) {
    1094           0 :     fResetWin1[board] = reset;
    1095           0 :     if(!IsClkValid(reset)) AliWarning(Form("Reset Win1 of board %d is not valid : %d",board,reset));
    1096             :   }else {
    1097           0 :     AliError(Form("Impossible to Write at Board %d",board));
    1098             :   }
    1099           0 : }
    1100             : //________________________________________________________________
    1101             : void AliADCalibData::SetResetWin2(UShort_t *resets){
    1102             :   // Set Reset Win clock for BG
    1103           0 :   if(resets)  for(int t=0; t<kNCIUBoards; t++) SetResetWin2(resets[t],t);
    1104           0 :   else AliError("Reset Win2 profil Not defined.");
    1105           0 : }
    1106             : //________________________________________________________________
    1107             : void AliADCalibData::SetResetWin2(UShort_t reset, Int_t board)
    1108             : {
    1109             :   // Set Reset Win clock for BG
    1110           0 :   if((board>=0) && (board<kNCIUBoards)) {
    1111           0 :     fResetWin2[board] = reset;
    1112           0 :     if(!IsClkValid(reset)) AliWarning(Form("Reset Win2 of board %d is not valid : %d",board,reset));
    1113             :   }else {
    1114           0 :     AliError(Form("Impossible to Write at Board %d",board));
    1115             :   }
    1116           0 : }
    1117             : //________________________________________________________________
    1118             : void AliADCalibData::SetPedestalSubtraction(Bool_t *peds){
    1119             :   // Set Pedestal Subtraction Parameter
    1120           0 :   if(peds)  for(int t=0; t<kNCIUBoards; t++) SetPedestalSubtraction(peds[t],t);
    1121           0 :   else AliError("Pedestal Subtraction Not defined.");
    1122             :         
    1123           0 : }
    1124             : //________________________________________________________________
    1125             : void AliADCalibData::SetPedestalSubtraction(Bool_t ped, Int_t board)
    1126             : {
    1127             :   // Set Pedestal Subtraction Parameter
    1128           0 :   if((board>=0) && (board<kNCIUBoards)) fPedestalSubtraction[board] = ped;
    1129           0 :   else AliError(Form("Board %d is not valid",board));
    1130           0 : }
    1131             : 
    1132             : //________________________________________________________________
    1133             : Bool_t  AliADCalibData::IsClkValid(UShort_t clock) const {
    1134             :   // Check if the given clock has a valid profil.
    1135           0 :   Bool_t word[5];
    1136             :   Bool_t isValid = kTRUE;
    1137             :   Short_t risingEdge = 0;
    1138             :   Short_t fallingEdge = 0;
    1139           0 :   for(int i=0 ; i<5 ; i++) word[i] = (clock >> i) & 0x1;
    1140             :         
    1141           0 :   if(word[0] != word[4]){
    1142           0 :     if(word[4]) fallingEdge++;
    1143             :     else risingEdge++;
    1144             :   }     
    1145           0 :   for(int i=1 ; i<5 ; i++){
    1146           0 :     if(word[i] != word[i-1]) {
    1147           0 :       if(word[i-1]) fallingEdge++;
    1148           0 :       else risingEdge++;
    1149             :     }
    1150             :   }
    1151           0 :   if((fallingEdge>1)||(risingEdge>1)) isValid = kFALSE;
    1152           0 :   if(((risingEdge==0)&&(fallingEdge==0)) &&(!word[0]))  isValid = kFALSE;
    1153           0 :   return isValid;
    1154           0 : }
    1155             : 
    1156             : //________________________________________________________________
    1157             : Int_t AliADCalibData::GetOfflineChannelNumber(Int_t board, Int_t channel)
    1158             : {
    1159             :   // Get the offline channel number from
    1160             :   // the FEE board and channel indexes
    1161             : 
    1162           0 :   if (board < 0 || board >= 2) {
    1163           0 :     AliErrorClass(Form("Wrong FEE board number: %d",board));
    1164           0 :     return -1;
    1165             :   }
    1166           0 :   if (channel < 0 || channel >= 8) {
    1167           0 :     AliErrorClass(Form("Wrong FEE channel number: %d",channel));
    1168           0 :     return -1;
    1169             :   }
    1170             : 
    1171           0 :   Int_t offCh = kOfflineChannel[channel+(8*board)];
    1172             : 
    1173             :   return offCh;
    1174           0 : }
    1175             : //________________________________________________________________
    1176             : Int_t AliADCalibData::GetFEEChannelNumber(Int_t channel)
    1177             : {
    1178             :   // Get FEE channel number
    1179             :   // from offline channel index
    1180           0 :   if (channel >= 0 && channel < 16) return ((kOnlineChannel[channel] % 8));
    1181             : 
    1182           0 :   AliErrorClass(Form("Wrong channel index: %d",channel));
    1183           0 :   return -1;
    1184           0 : }
    1185             : //________________________________________________________________
    1186             : Int_t AliADCalibData::GetBoardNumber(Int_t channel)
    1187             : {
    1188             :   // Get FEE board number
    1189             :   // from offline channel index
    1190           0 :   Int_t OnChannel = kOnlineChannel[channel];
    1191           0 :   if (OnChannel >= 0 && OnChannel < 8) return (0);
    1192           0 :   if (OnChannel >= 8 && OnChannel < 16) return (1);
    1193             : 
    1194           0 :   AliErrorClass(Form("Wrong channel index: %d",channel));
    1195           0 :   return -1;
    1196           0 : }
    1197             : //________________________________________________________________
    1198             : void AliADCalibData::PrintConfig()
    1199             : {
    1200             : 
    1201           0 :   printf("\n");  
    1202           0 :   printf("======================================================\n");
    1203           0 :   printf("=======================CCIU config====================\n");
    1204           0 :   printf("======================================================\n");
    1205           0 :   printf("\n"); 
    1206             :  
    1207           0 :   printf("Selected triggers = ");
    1208           0 :   for(Int_t i = 0; i<5 ; i++) printf("%d ",GetTriggerSelected(i));
    1209           0 :   printf("\n");
    1210             : 
    1211           0 :   printf("BBA thr = %d, BBC thr = %d\n",GetBBAThreshold(),GetBBCThreshold());
    1212           0 :   printf("BGA thr = %d, BGC thr = %d\n",GetBGAThreshold(),GetBGCThreshold());
    1213           0 :   printf("BBAforBG thr = %d, BBCforBG thr = %d\n",GetBBAForBGThreshold(),GetBBCForBGThreshold());
    1214             : 
    1215             :   
    1216           0 :   printf("\n"); 
    1217           0 :   printf("======================================================\n");
    1218           0 :   printf("=======================CIUs config====================\n");
    1219           0 :   printf("======================================================\n");
    1220           0 :   printf("\n");
    1221             :  
    1222           0 :   for(Int_t CIUNumber = 0; CIUNumber < 2; ++CIUNumber) {
    1223           0 :     printf("CIU= %d, Time Res= %f, Width Res= %f, RollOver= %d, TrigCountOffset= %d, SearchWin= %d, MatchWin= %d\n",
    1224             :            CIUNumber,
    1225           0 :            GetTimeResolution(CIUNumber),
    1226           0 :            GetWidthResolution(CIUNumber),
    1227           0 :            GetRollOver(CIUNumber),
    1228           0 :            GetTriggerCountOffset(CIUNumber),
    1229           0 :            GetSearchWindow(CIUNumber),
    1230           0 :            GetMatchWindow(CIUNumber));
    1231             :            
    1232             :           
    1233             :   }
    1234             : 
    1235           0 :   printf("\n");
    1236           0 :   printf("=======================Trigger windows================\n"); 
    1237           0 :   printf("\n");
    1238             :   Bool_t gatesOpen = kTRUE;
    1239           0 :   for (Int_t CIUNumber = 0; CIUNumber < 2; ++CIUNumber) {
    1240           0 :     if (GetDelayClk1Win1(CIUNumber)!=0 || GetDelayClk2Win1(CIUNumber)!=0 || GetDelayClk1Win2(CIUNumber)!=0 || GetDelayClk2Win2(CIUNumber)!=0) gatesOpen = kFALSE;
    1241             :   }
    1242           0 :   if(!gatesOpen){
    1243           0 :     for(Int_t CIUNumber = 0; CIUNumber < 2; ++CIUNumber) {
    1244           0 :       std::cout <<"CIU = "<<CIUNumber<<std::endl;
    1245           0 :       std::cout << "P1 BB " << std::bitset<5>(GetClk1Win1(CIUNumber))<<  "   P1 BG " << std::bitset<5>(GetClk1Win2(CIUNumber))<< std::endl;
    1246           0 :       std::cout << "P2 BB " << std::bitset<5>(GetClk2Win1(CIUNumber))<<  "   P2 BG " << std::bitset<5>(GetClk2Win2(CIUNumber))<< std::endl;
    1247           0 :       std::cout << "  L   " << std::bitset<5>(GetLatchWin1(CIUNumber))<< "     L   " << std::bitset<5>(GetLatchWin2(CIUNumber))<< std::endl;
    1248           0 :       std::cout << "  R   " << std::bitset<5>(GetResetWin1(CIUNumber))<< "     R   " << std::bitset<5>(GetResetWin2(CIUNumber))<< std::endl;
    1249           0 :       printf("\n");
    1250           0 :       std::cout << "BB Delay1 = " <<GetDelayClk1Win1(CIUNumber)<< "  BG Delay1 = " <<GetDelayClk1Win2(CIUNumber)<<std::endl;
    1251           0 :       std::cout << "BB Delay2 = " <<GetDelayClk2Win1(CIUNumber)<< "  BG Delay2 = " <<GetDelayClk2Win2(CIUNumber)<<std::endl;
    1252           0 :       printf("\n");
    1253             :   
    1254           0 :       AliADLogicalSignal clk1BB(GetClk1Win1(CIUNumber),GetDelayClk1Win1(CIUNumber),GetLatchWin1(CIUNumber),GetResetWin1(CIUNumber));
    1255           0 :       AliADLogicalSignal clk2BB(GetClk2Win1(CIUNumber),GetDelayClk2Win1(CIUNumber),GetLatchWin1(CIUNumber),GetResetWin1(CIUNumber));
    1256           0 :       AliADLogicalSignal *fBBGate = new AliADLogicalSignal(clk1BB & clk2BB);
    1257             :         
    1258           0 :       std::cout<<"BB window = ["<<fBBGate->GetStartTime()<<" , "<<fBBGate->GetStopTime()<<"]"<<std::endl;
    1259             :         
    1260           0 :       AliADLogicalSignal clk1BG(GetClk1Win2(CIUNumber),GetDelayClk1Win2(CIUNumber),GetLatchWin2(CIUNumber),GetResetWin2(CIUNumber));
    1261           0 :       clk1BG.SetStartTime(clk1BG.GetStartTime()+2);
    1262           0 :       clk1BG.SetStopTime(clk1BG.GetStopTime()+2);
    1263           0 :       AliADLogicalSignal clk2BG(GetClk2Win2(CIUNumber),GetDelayClk2Win2(CIUNumber),GetLatchWin2(CIUNumber),GetResetWin2(CIUNumber));
    1264           0 :       clk2BG.SetStartTime(clk2BG.GetStartTime()-2);
    1265           0 :       clk2BG.SetStopTime(clk2BG.GetStopTime()-2);
    1266           0 :       AliADLogicalSignal *fBGGate = new AliADLogicalSignal(clk1BG & clk2BG);
    1267             :         
    1268           0 :       std::cout<<"BG window = ["<<fBGGate->GetStartTime()<<" , "<<fBGGate->GetStopTime()<<"]"<<std::endl;
    1269           0 :       printf("\n");     
    1270           0 :     }
    1271           0 :   }
    1272           0 :   else printf("Test window 25ns\n");
    1273             : 
    1274           0 :   printf("\n");  
    1275           0 :   printf("======================================================\n");
    1276           0 :   printf("====================Channels config===================\n");
    1277           0 :   printf("======================================================\n");
    1278           0 :   printf("\n"); 
    1279             :  
    1280           0 :   for(Int_t pmNumber = 0; pmNumber < 16; ++pmNumber) {
    1281           0 :     printf("ChOff = %d, ChOn = %d, HV = %.1f, MIP = %.1f ADC, Dead = %s, DelayHit = %.2f, Thr_DCS = %.1f, Thr_Calib = %.1f\n",
    1282             :            pmNumber,
    1283           0 :            kOnlineChannel[pmNumber],
    1284           0 :            GetMeanHV(pmNumber),
    1285           0 :            GetADCperMIP(pmNumber),
    1286           0 :            IsChannelDead(pmNumber)?"yes":"no",
    1287           0 :            GetTimeOffset(pmNumber),
    1288           0 :            GetDiscriThr(pmNumber),
    1289           0 :            GetCalibDiscriThr(pmNumber)
    1290             :            );
    1291             :   }
    1292             :   
    1293           0 :   printf("\n");
    1294           0 :   printf("======================================================\n");
    1295           0 :   printf("======================= Pedestal =====================\n");
    1296           0 :   printf("======================================================\n");
    1297           0 :   printf("\n");
    1298             : 
    1299           0 :   for(Int_t pmNumber = 0; pmNumber < 16; ++pmNumber) {
    1300           0 :     for(Int_t integrator = 0; integrator < 2; ++integrator){
    1301           0 :       if(integrator == 0)printf("ChOff = %d, ChOn = %d, Int = %d, Pedestal = %.3f, Width = %3f,", pmNumber, kOnlineChannel[pmNumber],integrator, GetPedestal(pmNumber+16*integrator),GetSigma(pmNumber+16*integrator));
    1302           0 :       else printf(" Int = %d, Pedestal = %.3f, Width = %3f\n", integrator, GetPedestal(pmNumber+16*integrator),GetSigma(pmNumber+16*integrator));     
    1303             :     }
    1304             :   }
    1305             : 
    1306             : 
    1307             : 
    1308           0 : }
    1309             : 
    1310             : //________________________________________________________________
    1311             : void AliADCalibData::PrintConfigShuttle()
    1312             : {
    1313             : 
    1314           0 :   printf("\n");  
    1315           0 :   printf("======================================================\n");
    1316           0 :   printf("=======================CCIU config====================\n");
    1317           0 :   printf("======================================================\n");
    1318           0 :   printf("\n"); 
    1319             :  
    1320           0 :   printf("Selected triggers = ");
    1321           0 :   for(Int_t i = 0; i<5 ; i++) printf("%d ",GetTriggerSelected(i));
    1322           0 :   printf("\n");
    1323             : 
    1324           0 :   printf("BBA thr = %d, BBC thr = %d\n",GetBBAThreshold(),GetBBCThreshold());
    1325           0 :   printf("BGA thr = %d, BGC thr = %d\n",GetBGAThreshold(),GetBGCThreshold());
    1326           0 :   printf("BBAforBG thr = %d, BBCforBG thr = %d\n",GetBBAForBGThreshold(),GetBBCForBGThreshold());
    1327             : 
    1328             :   
    1329           0 :   printf("\n"); 
    1330           0 :   printf("======================================================\n");
    1331           0 :   printf("=======================CIUs config====================\n");
    1332           0 :   printf("======================================================\n");
    1333           0 :   printf("\n");
    1334             :  
    1335           0 :   for(Int_t CIUNumber = 0; CIUNumber < 2; ++CIUNumber) {
    1336           0 :     printf("CIU= %d, Time Res= %f, Width Res= %f, RollOver= %d, TrigCountOffset= %d, SearchWin= %d, MatchWin= %d\n",
    1337             :            CIUNumber,
    1338           0 :            GetTimeResolution(CIUNumber),
    1339           0 :            GetWidthResolution(CIUNumber),
    1340           0 :            GetRollOver(CIUNumber),
    1341           0 :            GetTriggerCountOffset(CIUNumber),
    1342           0 :            GetSearchWindow(CIUNumber),
    1343           0 :            GetMatchWindow(CIUNumber));
    1344             :            
    1345             :           
    1346             :   }
    1347             : 
    1348           0 :   printf("\n");
    1349           0 :   printf("=======================Trigger windows================\n"); 
    1350           0 :   printf("\n");
    1351             :   Bool_t gatesOpen = kTRUE;
    1352           0 :   for (Int_t CIUNumber = 0; CIUNumber < 2; ++CIUNumber) {
    1353           0 :     if (GetDelayClk1Win1(CIUNumber)!=0 || GetDelayClk2Win1(CIUNumber)!=0 || GetDelayClk1Win2(CIUNumber)!=0 || GetDelayClk2Win2(CIUNumber)!=0) gatesOpen = kFALSE;
    1354             :   }
    1355           0 :   if(!gatesOpen){
    1356           0 :     for(Int_t CIUNumber = 0; CIUNumber < 2; ++CIUNumber) {
    1357           0 :       std::cout <<"CIU = "<<CIUNumber<<std::endl;
    1358           0 :       std::cout << "P1 BB " << std::bitset<5>(GetClk1Win1(CIUNumber))<<  "   P1 BG " << std::bitset<5>(GetClk1Win2(CIUNumber))<< std::endl;
    1359           0 :       std::cout << "P2 BB " << std::bitset<5>(GetClk2Win1(CIUNumber))<<  "   P2 BG " << std::bitset<5>(GetClk2Win2(CIUNumber))<< std::endl;
    1360           0 :       std::cout << "  L   " << std::bitset<5>(GetLatchWin1(CIUNumber))<< "     L   " << std::bitset<5>(GetLatchWin2(CIUNumber))<< std::endl;
    1361           0 :       std::cout << "  R   " << std::bitset<5>(GetResetWin1(CIUNumber))<< "     R   " << std::bitset<5>(GetResetWin2(CIUNumber))<< std::endl;
    1362           0 :       printf("\n");
    1363           0 :       std::cout << "BB Delay1 = " <<GetDelayClk1Win1(CIUNumber)<< "  BG Delay1 = " <<GetDelayClk1Win2(CIUNumber)<<std::endl;
    1364           0 :       std::cout << "BB Delay2 = " <<GetDelayClk2Win1(CIUNumber)<< "  BG Delay2 = " <<GetDelayClk2Win2(CIUNumber)<<std::endl;  
    1365             :     }
    1366           0 :   }
    1367           0 :   else printf("Test window 25ns\n");
    1368             : 
    1369           0 :   printf("\n");  
    1370           0 :   printf("======================================================\n");
    1371           0 :   printf("====================Channels config===================\n");
    1372           0 :   printf("======================================================\n");
    1373           0 :   printf("\n"); 
    1374             :  
    1375           0 :   for(Int_t pmNumber = 0; pmNumber < 16; ++pmNumber) {
    1376           0 :     printf("ChOff = %d, ChOn = %d, HV = %.1f, Dead = %s, DelayHit = %.2f, Thr_DCS = %.1f\n",
    1377             :            pmNumber,
    1378           0 :            kOnlineChannel[pmNumber],
    1379           0 :            GetMeanHV(pmNumber),
    1380           0 :            IsChannelDead(pmNumber)?"yes":"no",
    1381           0 :            GetTimeOffset(pmNumber),
    1382           0 :            GetDiscriThr(pmNumber)
    1383             :            );
    1384             :   }
    1385             :   
    1386           0 :   printf("\n");
    1387           0 :   printf("======================================================\n");
    1388           0 :   printf("======================= Pedestal =====================\n");
    1389           0 :   printf("======================================================\n");
    1390           0 :   printf("\n");
    1391             : 
    1392           0 :   for(Int_t pmNumber = 0; pmNumber < 16; ++pmNumber) {
    1393           0 :     for(Int_t integrator = 0; integrator < 2; ++integrator){
    1394           0 :       if(integrator == 0)printf("ChOff = %d, ChOn = %d, Int = %d, Pedestal = %.3f, Width = %3f,", pmNumber, kOnlineChannel[pmNumber],integrator, GetPedestal(pmNumber+16*integrator),GetSigma(pmNumber+16*integrator));
    1395           0 :       else printf(" Int = %d, Pedestal = %.3f, Width = %3f\n", integrator, GetPedestal(pmNumber+16*integrator),GetSigma(pmNumber+16*integrator));     
    1396             :     }
    1397             :   }
    1398             : 
    1399           0 : }

Generated by: LCOV version 1.11