]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0CalibTimeEq.cxx
calibration Zposition of vertex added
[u/mrichter/AliRoot.git] / T0 / AliT0CalibTimeEq.cxx
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 //                                                                           //
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 "AliT0CalibTimeEq.h"
26 #include "AliLog.h"
27 #include <TFile.h>
28 #include <TMath.h>
29 #include <TF1.h>
30 #include <TSpectrum.h>
31 #include <TProfile.h>
32 #include <iostream>
33
34 ClassImp(AliT0CalibTimeEq)
35
36 //________________________________________________________________
37   AliT0CalibTimeEq::AliT0CalibTimeEq():TNamed()
38 {
39   //
40
41 }
42
43 //________________________________________________________________
44 AliT0CalibTimeEq::AliT0CalibTimeEq(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
54 //________________________________________________________________
55 AliT0CalibTimeEq::AliT0CalibTimeEq(const AliT0CalibTimeEq& calibda):TNamed(calibda)             
56 {
57 // copy constructor
58   SetName(calibda.GetName());
59   SetTitle(calibda.GetName());
60
61
62 }
63
64 //________________________________________________________________
65 AliT0CalibTimeEq &AliT0CalibTimeEq::operator =(const AliT0CalibTimeEq& calibda)
66 {
67 // assignment operator
68   SetName(calibda.GetName());
69   SetTitle(calibda.GetName());
70  
71   return *this;
72 }
73
74 //________________________________________________________________
75 AliT0CalibTimeEq::~AliT0CalibTimeEq()
76 {
77   //
78   // destrictor
79 }
80 //________________________________________________________________
81 void AliT0CalibTimeEq::Reset()
82 {
83   //reset values
84
85   memset(fCFDvalue,0,120*sizeof(Float_t));
86   memset(fTimeEq,1,24*sizeof(Float_t));
87 }
88
89
90 //________________________________________________________________
91 void  AliT0CalibTimeEq::Print(Option_t*) const
92 {
93   // print time values
94
95   printf("\n    ----    PM Arrays       ----\n\n");
96   printf(" Time delay CFD \n");
97   for (Int_t i=0; i<24; i++) printf(" CFD  %f ",fTimeEq[i]);
98   printf("\n Mean Vertex %f \n", fMeanVertex);
99
100
101
102 //________________________________________________________________
103 void AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys)
104 {
105   // compute online equalized time
106   Double_t mean=0, meanver=0;
107   gFile = TFile::Open(filePhys);
108   
109   if(!gFile) {
110     AliError("No input PHYS data found ");
111   }
112   else
113     {
114       Char_t buf1[30];
115       for (Int_t i=0; i<24; i++)
116         {
117           sprintf(buf1,"CFD1-CFD%d",i+1);
118           TH1F *cfd = (TH1F*) gFile->Get(buf1);
119           if(!cfd) AliWarning(Form("no histograms collected by PHYS DA for channel %i", i));
120           //      printf(" i = %d buf1 = %s\n", i, buf1);
121           if(cfd) mean=cfd->GetMean();
122           SetTimeEq(i,mean);
123           if (cfd) delete cfd;
124         }
125       TH1F *ver = (TH1F*) gFile->Get("hVertex");
126       if(!ver) AliWarning("no Vertex histograms collected by PHYS DA for Zvertex");
127       if(ver)  meanver = ver->GetMean();
128       SetMeanVertex(meanver);
129       
130       gFile->Close();
131       delete gFile;
132     } 
133     }
134
135