]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0CalibTimeEq.cxx
fixes for crashing SHUTLLE
[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 AliT0CalibTimeEq::AliT0CalibTimeEq(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 AliT0CalibTimeEq::AliT0CalibTimeEq(const AliT0CalibTimeEq& calibda):TNamed(calibda)             
55 {
56 // copy constructor
57   SetName(calibda.GetName());
58   SetTitle(calibda.GetName());
59
60
61 }
62
63 //________________________________________________________________
64 AliT0CalibTimeEq &AliT0CalibTimeEq::operator =(const AliT0CalibTimeEq& calibda)
65 {
66 // assignment operator
67   SetName(calibda.GetName());
68   SetTitle(calibda.GetName());
69  
70   return *this;
71 }
72
73 //________________________________________________________________
74 AliT0CalibTimeEq::~AliT0CalibTimeEq()
75 {
76   //
77   // destrictor
78 }
79 //________________________________________________________________
80 void AliT0CalibTimeEq::Reset()
81 {
82   //reset values
83
84   memset(fCFDvalue,0,120*sizeof(Float_t));
85   memset(fTimeEq,1,24*sizeof(Float_t));
86 }
87
88
89 //________________________________________________________________
90 void  AliT0CalibTimeEq::Print(Option_t*) const
91 {
92   // print time values
93
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]);
97
98
99
100 //________________________________________________________________
101 void AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys)
102 {
103   // compute online equalized time
104   Double_t mean=0;
105   gFile = TFile::Open(filePhys);
106
107   if(!gFile) {
108     AliError("No input PHYS data found ");
109   }
110   else
111     {
112       Char_t buf1[30];
113       for (Int_t i=0; i<24; i++)
114         {
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           if(cfd) mean=cfd->GetMean();
119           SetTimeEq(i,mean);
120           if(!cfd) AliWarning(Form("no histograms collected by PHYS DA for channel %i", i));
121     if (cfd) delete cfd;
122         }
123       
124       
125       gFile->Close();
126       delete gFile;
127     } 
128     }
129
130