LCOV - code coverage report
Current view: top level - T0/T0rec - AliT0CalibSeasonTimeShift.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 6 78 7.7 %
Date: 2016-06-14 17:26:59 Functions: 3 15 20.0 %

          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: AliT0CalibSeasonTimeShift.cxx 42881 2010-08-16 10:59:14Z alla $ */
      17             : 
      18             : ///////////////////////////////////////////////////////////////////////////////
      19             : //                                                                           //
      20             : // class for T0 calibration                       TM-AC-AM_6-02-2006  
      21             : // equalize time shift for each time CFD channel
      22             : //                                                                           //
      23             : ///////////////////////////////////////////////////////////////////////////////
      24             : 
      25             : #include "AliT0CalibSeasonTimeShift.h"
      26             : #include "AliLog.h"
      27             : #include <TFile.h>
      28             : #include <TMath.h>
      29             : #include <TF1.h>
      30             : #include <TProfile.h>
      31             : #include <iostream>
      32             : 
      33          20 : ClassImp(AliT0CalibSeasonTimeShift)
      34             : 
      35             : //________________________________________________________________
      36           2 :   AliT0CalibSeasonTimeShift::AliT0CalibSeasonTimeShift():TNamed()
      37          10 : {
      38             :   //
      39          20 :   for (Int_t i=0; i<4; i++)
      40           8 :     fMeanPar[i] = fSigmaPar[i] = 0; 
      41           4 : }
      42             : 
      43             : //________________________________________________________________
      44           0 : AliT0CalibSeasonTimeShift::AliT0CalibSeasonTimeShift(const char* name):TNamed()
      45           0 : {
      46             :     //constructor
      47             :     
      48           0 :   TString namst = "Calib_";
      49           0 :   namst += name;
      50           0 :   SetName(namst.Data());
      51           0 :   SetTitle(namst.Data()); 
      52             :   
      53           0 :   for (Int_t i=0; i<4; i++)
      54           0 :     fMeanPar[i] = fSigmaPar[i] = 0; 
      55             :  
      56           0 : }
      57             : 
      58             : //________________________________________________________________
      59           0 : AliT0CalibSeasonTimeShift::AliT0CalibSeasonTimeShift(const AliT0CalibSeasonTimeShift& calibda):TNamed(calibda)              
      60             : 
      61           0 : {
      62             : // copy constructor
      63           0 :   SetName(calibda.GetName());
      64           0 :   SetTitle(calibda.GetName());
      65           0 :   ((AliT0CalibSeasonTimeShift &) calibda).Copy(*this);
      66             : 
      67             : 
      68           0 : }
      69             : 
      70             : //________________________________________________________________
      71             : AliT0CalibSeasonTimeShift &AliT0CalibSeasonTimeShift::operator =(const AliT0CalibSeasonTimeShift& calibda)
      72             : {
      73             : // assignment operator
      74           0 :   SetName(calibda.GetName());
      75           0 :   SetTitle(calibda.GetName());
      76           0 :   if (this != &calibda) ((AliT0CalibSeasonTimeShift &) calibda).Copy(*this);
      77             :  
      78           0 :   return *this;
      79             : }
      80             : 
      81             : //________________________________________________________________
      82             : AliT0CalibSeasonTimeShift::~AliT0CalibSeasonTimeShift()
      83           0 : {
      84             :   //
      85             :   // destrictor
      86           0 : }
      87             : 
      88             : 
      89             : //________________________________________________________________
      90             : void  AliT0CalibSeasonTimeShift::Print(Option_t*) const
      91             : {
      92             :   // print time values
      93             : 
      94           0 :   printf("\n       ----    T0 results      ----\n\n");
      95           0 :   printf(" (T0A+T0C)/2 = %f; T0A = %f; T0C = %f; resolution = %f  \n", fMeanPar[0], fMeanPar[1],fMeanPar[2],fMeanPar[3]);
      96           0 :   printf(" sigma(T0A+T0C)/2 = %f; sigma(T0 = %f; sigma(T0C) = %f; sigma(resolution) = %f  \n" , fSigmaPar[0], fSigmaPar[1], fSigmaPar[2],fSigmaPar[3]);
      97             :  
      98           0 : } 
      99             : 
     100             : //________________________________________________________________
     101             : Bool_t  AliT0CalibSeasonTimeShift::SetT0Par(Float_t par[4],Float_t spar[4])
     102             : {
     103             :   Bool_t ok=false;
     104           0 :  for (Int_t i=0; i<4; i++)
     105             :     {
     106           0 :       fMeanPar[i] = par[i];
     107           0 :       fSigmaPar[i] = spar[i];
     108           0 :       if ( fSigmaPar[i] == 0 ||  fSigmaPar[i] > 500) ok = false;
     109             :     }
     110           0 :  return ok;
     111             : }
     112             : 
     113             : //________________________________________________________________
     114             : Int_t AliT0CalibSeasonTimeShift::SetT0Par(const char* filePhys, Float_t *cdbtime)
     115             : {
     116             :   // compute shifts fo T0A, T0C, T0AC and resolution
     117             :   //Status : writeok:
     118             :   // 0 OK
     119             :   // 2000 - no data file
     120             :   // 300 no one histogram or it is empty
     121             :   //-100 peak is very narrow
     122             : 
     123           0 :   Float_t mean, sigma;
     124             :   Int_t ok = 0;
     125             :   TH1F *cfd = NULL;
     126             :   TObjArray * tzeroObj = NULL;
     127             : 
     128           0 :   gFile = TFile::Open(filePhys);
     129           0 :   if(!gFile) {
     130           0 :     AliError("No input PHYS data found ");
     131           0 :     return 2000;
     132             :   }
     133             :   else {
     134             :     //    gFile->ls();
     135             :     //    TDirectory *dr = (TDirectory*) gFile->Get("T0Calib");
     136           0 :     tzeroObj = dynamic_cast<TObjArray*>(gFile->Get("T0Calib"));
     137           0 :     TString histname[4]={"fTzeroORAplusORC", "fTzeroORA", "fTzeroORC",  "fResolution"};
     138           0 :     for (Int_t i=0; i<4; i++)
     139             :       {
     140           0 :         if(cfd) cfd->Reset();
     141           0 :         if(tzeroObj) 
     142           0 :           cfd = (TH1F*)tzeroObj->FindObject( histname[i].Data());
     143             :         else
     144           0 :           cfd =  (TH1F*)gFile ->Get(histname[i].Data());
     145             : 
     146           0 :         if(!cfd) {
     147           0 :           AliError(Form("no histograms collected for %s", histname[i].Data()));
     148           0 :           return -300;
     149             :         }
     150           0 :         if(cfd) {
     151           0 :           if( cfd->GetEntries() == 0) {
     152           0 :           AliError(Form("%s histogram is empty", histname[i].Data()));
     153           0 :           return -300;
     154             :           }
     155           0 :           GetMeanAndSigma(cfd, mean, sigma);
     156           0 :           if (sigma == 0 || sigma > 600 || cfd->GetEntries()<50 ){ //!!!
     157           0 :             AliError(Form("%s low statsitics or bad histogram, OCDB value is = %f", histname[i].Data(), cdbtime[i]) );
     158           0 :             return 400;
     159             :           }
     160           0 :           if ( sigma > 0 && sigma < 600 && cfd->GetEntries()>=50) //!!!
     161             :             { 
     162           0 :               fMeanPar[i] =   mean;
     163           0 :               fSigmaPar[i] = sigma;
     164           0 :             }
     165             :         }
     166             :       } 
     167           0 :   }
     168           0 :   gFile->Close();
     169           0 :   delete gFile;
     170           0 :   return ok;
     171           0 : }
     172             : //________________________________________________________________________
     173             : void AliT0CalibSeasonTimeShift::GetMeanAndSigma(TH1F* hist,  Float_t &mean, Float_t &sigma) {
     174             : 
     175             :   const double window =3.;  //fit window 
     176             :  
     177             :   double meanEstimate, sigmaEstimate; 
     178             :   int maxBin;
     179           0 :   maxBin        =  hist->GetMaximumBin(); //position of maximum
     180           0 :   meanEstimate  =  hist->GetBinCenter( maxBin); // mean of gaussian sitting in maximum
     181           0 :   sigmaEstimate = hist->GetRMS();
     182           0 :   TF1* fit= new TF1("fit","gaus", meanEstimate - window*sigmaEstimate, meanEstimate + window*sigmaEstimate);
     183           0 :   fit->SetParameters(hist->GetBinContent(maxBin), meanEstimate, sigmaEstimate);
     184           0 :   hist->Fit("fit","R","");
     185             : 
     186           0 :   mean  = (Float_t) fit->GetParameter(1);
     187           0 :   sigma = (Float_t) fit->GetParameter(2);
     188             : 
     189           0 :   delete fit;
     190           0 : }

Generated by: LCOV version 1.11