1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for T0 calibration TM-AC-AM_6-02-2006
21 // equalize time shift for each time CFD channel
23 ///////////////////////////////////////////////////////////////////////////////
25 #include "AliT0CalibTimeEq.h"
30 #include <TSpectrum.h>
34 ClassImp(AliT0CalibTimeEq)
36 //________________________________________________________________
37 AliT0CalibTimeEq::AliT0CalibTimeEq():TNamed()
42 //________________________________________________________________
43 AliT0CalibTimeEq::AliT0CalibTimeEq(const char* name):TNamed()
47 TString namst = "Calib_";
49 SetName(namst.Data());
50 SetTitle(namst.Data());
53 //________________________________________________________________
54 AliT0CalibTimeEq::AliT0CalibTimeEq(const AliT0CalibTimeEq& calibda):TNamed(calibda)
57 SetName(calibda.GetName());
58 SetTitle(calibda.GetName());
63 //________________________________________________________________
64 AliT0CalibTimeEq &AliT0CalibTimeEq::operator =(const AliT0CalibTimeEq& calibda)
66 // assignment operator
67 SetName(calibda.GetName());
68 SetTitle(calibda.GetName());
73 //________________________________________________________________
74 AliT0CalibTimeEq::~AliT0CalibTimeEq()
79 //________________________________________________________________
80 void AliT0CalibTimeEq::Reset()
84 memset(fCFDvalue,0,120*sizeof(Float_t));
85 memset(fTimeEq,1,24*sizeof(Float_t));
89 //________________________________________________________________
90 void AliT0CalibTimeEq::Print(Option_t*) const
94 printf("\n ---- PM Arrays ----\n\n");
95 printf(" Time delay CFD \n");
96 for (Int_t i=0; i<24; i++) printf(" CFD %f ",fTimeEq[i]);
100 //________________________________________________________________
101 void AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys)
103 // compute online equalized time
104 // Int_t npeaks = 20;
105 // Double_t sigma = 4.;
107 TFile *gFile = TFile::Open(filePhys);
108 // Bool_t down=false;
112 // Float_t p[24][3]={0.,0.,0.};
113 for (Int_t i=0; i<24; i++)
115 sprintf(buf1,"CFD1-CFD%d",i+1);
116 TH1F *cfd = (TH1F*) gFile->Get(buf1);
117 // printf(" i = %d buf1 = %s\n", i, buf1);
118 Double_t mean=cfd->GetMean();
124 TSpectrum *s = new TSpectrum(2*npeaks,1.);
125 printf(" buf1 = %s cfd = %x\n", buf1, cfd);
126 Int_t nfound = s->Search(cfd,sigma,"goff",0.2);
127 printf(" nfound = %d\n", nfound);
130 Float_t *xpeak = s->GetPositionX();
131 TMath::Sort(nfound, xpeak, index,down);
132 Float_t xp = xpeak[index[0]];
133 Float_t hmax = xp+3*sigma;
134 Float_t hmin = xp-3*sigma;
135 cfd->GetXaxis()->SetRange((Int_t)hmin-20,(Int_t)hmax+20);
136 TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
137 cfd->Fit("g1","IRQN");
138 for(Int_t j =0; j<3; j++)
140 p[i][j] = g1->GetParameter(j);
141 // SetCFDvalue(i, j, p[i][j]);
143 SetTimeEq(i,(p[i][2]));
144 cout<<" mean "<<p[i][2]<<endl;
147 SetCFDvalue(i, 3, hmin);
148 SetCFDvalue(i, 4, hmax);
152 SetTimeEq(i,(p[i][2]-p[0][2]));
156 SetTimeEq(i,(p[i][2]-p[12][2]));
165 for(int j=0;j<24;j++)
167 printf("fTimeEq[%d]=%f\n",j,fTimeEq[j]);