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