]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0CalibTimeEq.cxx
Remove obsolete macro
[u/mrichter/AliRoot.git] / T0 / AliT0CalibTimeEq.cxx
CommitLineData
a2ad8166 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$ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
59b8a5fc 20// class for T0 calibration TM-AC-AM_6-02-2006
21// equalize time shift for each time CFD channel
a2ad8166 22// //
23///////////////////////////////////////////////////////////////////////////////
24
25#include "AliT0CalibTimeEq.h"
a2ad8166 26
a2ad8166 27#include <TFile.h>
28#include <TMath.h>
29#include <TF1.h>
a2ad8166 30#include <TSpectrum.h>
a2ad8166 31#include <TProfile.h>
a2ad8166 32
33ClassImp(AliT0CalibTimeEq)
34
35//________________________________________________________________
6b7d32f7 36 AliT0CalibTimeEq::AliT0CalibTimeEq():TNamed()
a2ad8166 37{
38 //
39}
40
41//________________________________________________________________
6b7d32f7 42AliT0CalibTimeEq::AliT0CalibTimeEq(const char* name):TNamed()
a2ad8166 43{
59b8a5fc 44 //constructor
45
a2ad8166 46 TString namst = "Calib_";
47 namst += name;
48 SetName(namst.Data());
49 SetTitle(namst.Data());
50}
51
52//________________________________________________________________
6b7d32f7 53AliT0CalibTimeEq::AliT0CalibTimeEq(const AliT0CalibTimeEq& calibda):TNamed(calibda)
a2ad8166 54{
55// copy constructor
56 SetName(calibda.GetName());
57 SetTitle(calibda.GetName());
58
59
60}
61
62//________________________________________________________________
63AliT0CalibTimeEq &AliT0CalibTimeEq::operator =(const AliT0CalibTimeEq& calibda)
64{
65// assignment operator
66 SetName(calibda.GetName());
67 SetTitle(calibda.GetName());
68
69 return *this;
70}
71
72//________________________________________________________________
73AliT0CalibTimeEq::~AliT0CalibTimeEq()
74{
75 //
59b8a5fc 76 // destrictor
a2ad8166 77}
78//________________________________________________________________
79void AliT0CalibTimeEq::Reset()
80{
59b8a5fc 81 //reset values
82
a2ad8166 83 memset(fCFDvalue,0,120*sizeof(Float_t));
84 memset(fTimeEq,1,24*sizeof(Float_t));
85}
86
87
88//________________________________________________________________
89void AliT0CalibTimeEq::Print(Option_t*) const
90{
59b8a5fc 91 // print time values
a2ad8166 92
93 printf("\n ---- PM Arrays ----\n\n");
94 printf(" Time delay CFD \n");
95 for (Int_t i=0; i<24; i++) printf(" CFD %f ",fTimeEq[i]);
96}
97
98
99//________________________________________________________________
6b7d32f7 100void AliT0CalibTimeEq::ComputeOnlineParams(char* name1, Int_t npeaks, Double_t sigma, const char* filePhys)
a2ad8166 101{
59b8a5fc 102 // compute online equalized time
103
8bfd9a3e 104 TFile *gFile = TFile::Open(filePhys);
a2ad8166 105 Bool_t down=false;
106 Int_t index[20];
107 Char_t buf1[15];
108 Char_t temp[10];
6b7d32f7 109 Float_t p[24][3]={0.,0.,0.};
110 for (Int_t i=0; i<24; i++)
111 {
112 sprintf(buf1,name1);
113 sprintf(temp,"%i",i+1);
114 strcat (buf1,temp);
115 //strcat (buf1,name2);
116 TH1F *cfd = (TH1F*) gFile->Get(buf1);
117 printf(" i = %d buf1 = %s\n", i, buf1);
118 TSpectrum *s = new TSpectrum(2*npeaks,1.);
119 printf(" buf1 = %s cfd = %x\n", buf1, cfd);
120 Int_t nfound = s->Search(cfd,sigma,"goff",0.2);
121 printf(" nfound = %d\n", nfound);
122 if(nfound!=0)
a2ad8166 123 {
6b7d32f7 124 Float_t *xpeak = s->GetPositionX();
125 TMath::Sort(nfound, xpeak, index,down);
126 Float_t xp = xpeak[index[0]];
127 Float_t hmax = xp+3*sigma;
128 Float_t hmin = xp-3*sigma;
129 cfd->GetXaxis()->SetRange((Int_t)hmin-20,(Int_t)hmax+20);
130 TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
131 cfd->Fit("g1","IRQN");
132 for(Int_t j =0; j<3; j++)
133 {
134 p[i][j] = g1->GetParameter(j);
135 SetCFDvalue(i, j, p[i][j]);
136 }
137
138 SetCFDvalue(i, 3, hmin);
139 SetCFDvalue(i, 4, hmax);
140
141 if (i<12)
142 {
143 SetTimeEq(i,(p[i][2]-p[0][2]));
144 }
145 else
146 {
147 SetTimeEq(i,(p[i][2]-p[12][2]));
148 }
149 }
150 }
151
152 gFile->Close();
153 delete gFile;
154
155 for(int i=0;i<5;i++)
156 {
157 for(int j=0;j<24;j++)
158 {
159 printf("fCFDvalue[%d][%d]=%f\n",j,i,fCFDvalue[j][i]);
8bfd9a3e 160 }
6b7d32f7 161 }
162 printf("\n\n");
163 for(int j=0;j<24;j++)
164 {
165 printf("fTimeEq[%d]=%f\n",j,fTimeEq[j]);
166 }
a2ad8166 167}
168
8bfd9a3e 169