]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - T0/AliT0CalibSeasonTimeShift.cxx
Moving the copy constructors and assignment operators to private: and removing the...
[u/mrichter/AliRoot.git] / T0 / AliT0CalibSeasonTimeShift.cxx
... / ...
CommitLineData
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
33ClassImp(AliT0CalibSeasonTimeShift)
34
35//________________________________________________________________
36 AliT0CalibSeasonTimeShift::AliT0CalibSeasonTimeShift():TNamed()
37{
38 //
39 for (Int_t i=0; i<4; i++)
40 fMeanPar[i] = fSigmaPar[i] = 0;
41}
42
43//________________________________________________________________
44AliT0CalibSeasonTimeShift::AliT0CalibSeasonTimeShift(const char* name):TNamed()
45{
46 //constructor
47
48 TString namst = "Calib_";
49 namst += name;
50 SetName(namst.Data());
51 SetTitle(namst.Data());
52
53 for (Int_t i=0; i<4; i++)
54 fMeanPar[i] = fSigmaPar[i] = 0;
55
56}
57
58//________________________________________________________________
59AliT0CalibSeasonTimeShift::AliT0CalibSeasonTimeShift(const AliT0CalibSeasonTimeShift& calibda):TNamed(calibda)
60
61{
62// copy constructor
63 SetName(calibda.GetName());
64 SetTitle(calibda.GetName());
65 ((AliT0CalibSeasonTimeShift &) calibda).Copy(*this);
66
67
68}
69
70//________________________________________________________________
71AliT0CalibSeasonTimeShift &AliT0CalibSeasonTimeShift::operator =(const AliT0CalibSeasonTimeShift& calibda)
72{
73// assignment operator
74 SetName(calibda.GetName());
75 SetTitle(calibda.GetName());
76 if (this != &calibda) ((AliT0CalibSeasonTimeShift &) calibda).Copy(*this);
77
78 return *this;
79}
80
81//________________________________________________________________
82AliT0CalibSeasonTimeShift::~AliT0CalibSeasonTimeShift()
83{
84 //
85 // destrictor
86}
87
88
89//________________________________________________________________
90void AliT0CalibSeasonTimeShift::Print(Option_t*) const
91{
92 // print time values
93
94 printf("\n ---- T0 results ----\n\n");
95 printf(" (T0A+T0C)/2 = %f; T0A = %f; T0C = %f; resolution = %f \n", fMeanPar[0], fMeanPar[1],fMeanPar[2],fMeanPar[3]);
96 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}
99
100//________________________________________________________________
101Bool_t AliT0CalibSeasonTimeShift::SetT0Par(Float_t par[4],Float_t spar[4])
102{
103 Bool_t ok=false;
104 for (Int_t i=0; i<4; i++)
105 {
106 fMeanPar[i] = par[i];
107 fSigmaPar[i] = spar[i];
108 if ( fSigmaPar[i] == 0 || fSigmaPar[i] > 500) ok = false;
109 }
110 return ok;
111}
112
113//________________________________________________________________
114Int_t AliT0CalibSeasonTimeShift::SetT0Par(const char* filePhys, Float_t *cdbtime)
115{
116 // compute online equalized time
117 Float_t mean, sigma;
118 Int_t ok = 0;
119 TH1F *cfd = NULL;
120 TObjArray * tzeroObj = NULL;
121
122 gFile = TFile::Open(filePhys);
123 if(!gFile) {
124 AliError("No input PHYS data found ");
125 ok = 2000;
126 }
127 else {
128 // gFile->ls();
129 // TDirectory *dr = (TDirectory*) gFile->Get("T0Calib");
130 tzeroObj = dynamic_cast<TObjArray*>(gFile->Get("T0Calib"));
131 TString histname[4]={"fTzeroORAplusORC", "fTzeroORA", "fTzeroORC", "fResolution"};
132 for (Int_t i=0; i<4; i++)
133 {
134 if(cfd) cfd->Reset();
135 if(tzeroObj)
136 cfd = (TH1F*)tzeroObj->FindObject( histname[i].Data());
137 else
138 cfd = (TH1F*)gFile ->Get(histname[i].Data());
139
140 if(!cfd) {
141 ok=300;
142 AliError(Form("no histograms collected for %s", histname[i].Data()));
143 return ok;
144 }
145 if(cfd) {
146 if( cfd->GetEntries() == 0) {
147 ok=300;
148 AliError(Form("%s histogram is empty", histname[i].Data()));
149 return ok;
150 }
151 GetMeanAndSigma(cfd, mean, sigma);
152 if (sigma == 0 || sigma > 500 || cfd->GetEntries()<200 ){
153 ok = -100;
154 fMeanPar[i] = cdbtime[i];
155 fSigmaPar[i] = -1;
156 }
157 if ( sigma > 0 && sigma < 500 && cfd->GetEntries()>200)
158 {
159 fMeanPar[i] = mean;
160 fSigmaPar[i] = sigma;
161 }
162 }
163 }
164 }
165 gFile->Close();
166 delete gFile;
167 return ok;
168}
169//________________________________________________________________________
170void AliT0CalibSeasonTimeShift::GetMeanAndSigma(TH1F* hist, Float_t &mean, Float_t &sigma) {
171
172 const double window =2.; //fit window
173
174 double meanEstimate, sigmaEstimate;
175 int maxBin;
176 maxBin = hist->GetMaximumBin(); //position of maximum
177 meanEstimate = hist->GetBinCenter( maxBin); // mean of gaussian sitting in maximum
178 sigmaEstimate = hist->GetRMS();
179 TF1* fit= new TF1("fit","gaus", meanEstimate - window*sigmaEstimate, meanEstimate + window*sigmaEstimate);
180 fit->SetParameters(hist->GetBinContent(maxBin), meanEstimate, sigmaEstimate);
181 hist->Fit("fit","RQ","Q");
182
183 mean = (Float_t) fit->GetParameter(1);
184 sigma = (Float_t) fit->GetParameter(2);
185
186 delete fit;
187}