]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0Calibrator.cxx
90bcad8545975338840147b9046c662a5cd4d697
[u/mrichter/AliRoot.git] / T0 / AliT0Calibrator.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  *      this class doing calibration during reconstruction 
19  *      2 steps:
20  *      - equalizing channels
21  *      - applying walk corrections
22  *
23  * Alla.Maevskaya@cern.ch
24  *
25  **********************************************************************/      
26  
27 //#include <Riostream.h>
28
29 #include "AliLog.h"
30 #include "AliT0Parameters.h"
31 #include "AliT0Calibrator.h"
32 #include <TGraph.h>
33 #include <TH1F.h>
34 //#include "iostream.h"
35
36 ClassImp(AliT0Calibrator)
37
38 //____________________________________________________________________
39   AliT0Calibrator::AliT0Calibrator():TNamed(),
40   fChannelWidth(0),  
41   fWalk(0)
42 {
43   //constructor
44
45   AliT0Parameters* param = AliT0Parameters::Instance();
46   param->Init();
47   
48   fChannelWidth = param->GetChannelWidth() ;  
49  
50   for (Int_t i=0; i<24; i++){
51     fTimeDelayCFD[i] = Int_t (param->GetTimeDelayCFD(i));
52     TGraph* fu = param ->GetWalk(i);
53     fWalk.AddAtAndExpand(fu,i);
54   }
55   
56   //
57 }
58 //_____________________________________________________________________________
59
60 AliT0Calibrator::AliT0Calibrator(const AliT0Calibrator &r): TNamed(),
61   fChannelWidth(0),  
62   fWalk(0)
63
64 {
65   //
66   // AliT0calibartor copy constructor
67   //
68
69   ((AliT0Calibrator &) r).Copy(*this);
70
71 }
72
73 //_____________________________________________________________________________
74 AliT0Calibrator &AliT0Calibrator::operator=(const AliT0Calibrator &r)
75 {
76   //
77   // Assignment operator
78   //
79
80   if (this != &r) ((AliT0Calibrator &) r).Copy(*this);
81   return *this;
82
83 }
84
85
86
87 //____________________________________________________________________
88 Int_t  AliT0Calibrator::WalkCorrection(Int_t ipmt, Int_t qt, Int_t time, TString option) 
89 {
90   //slewing correcion and equalizing channels
91
92   Float_t walk=0;
93      Float_t maxValue=0;
94  Int_t timeEq=0, timeWalk=0;  
95   TGraph *fu1=(TGraph*) fWalk.At(ipmt);
96   if(fu1){
97     walk=fu1->Eval(Float_t(qt));
98     TH1F*hr=fu1->GetHistogram();
99     maxValue=hr->GetMaximum(50);
100   }
101   if (option == "pdc") {
102     timeWalk = time + Int_t((maxValue-walk)/fChannelWidth) ;
103     timeEq= timeWalk - (fTimeDelayCFD[ipmt]-fTimeDelayCFD[0]);
104   }
105   if (option == "cosmic") {
106     timeWalk = time + Int_t((maxValue-walk)) ;
107     if (ipmt<12) timeEq= timeWalk - (fTimeDelayCFD[ipmt]-fTimeDelayCFD[0]);
108     if (ipmt>11)  timeEq= timeWalk - (fTimeDelayCFD[ipmt]-fTimeDelayCFD[12]);
109   }
110   AliDebug(10,Form(" ipmt %i time before %i timeWalk %i ,  qt %i timeEq %i \n ",
111                  ipmt, time,timeWalk, qt, timeEq ));
112   return timeEq;
113 }
114
115
116