Obsolete.
[u/mrichter/AliRoot.git] / T0 / AliT0Calibrator.cxx
CommitLineData
8d72d1c2 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$ */
94249139 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>
8d72d1c2 28
29#include "AliLog.h"
30#include "AliT0Parameters.h"
31#include "AliT0Calibrator.h"
8d72d1c2 32#include <TGraph.h>
7d95281b 33#include <TH1F.h>
2e6a5ee0 34#include <TMath.h>
35#include "iostream.h"
8d72d1c2 36
37ClassImp(AliT0Calibrator)
38
39//____________________________________________________________________
9e1b06a2 40 AliT0Calibrator::AliT0Calibrator():TNamed(),
2e6a5ee0 41 fChannelWidth(0),
42 fWalk(0)
43
8d72d1c2 44{
94249139 45 //constructor
46
2e6a5ee0 47 AliT0Parameters* param = AliT0Parameters::Instance();
48 param->Init();
8d72d1c2 49
50 fChannelWidth = param->GetChannelWidth() ;
12e9daf9 51 Double_t *grY ; //= new grY[2500] ;
52 // Double_t *grX ;
53 Int_t index[25000];
2e6a5ee0 54 Bool_t down=true;
8d72d1c2 55 for (Int_t i=0; i<24; i++){
2e6a5ee0 56 fMaxValue[i]=0;
8d72d1c2 57 fTimeDelayCFD[i] = Int_t (param->GetTimeDelayCFD(i));
2e6a5ee0 58
12e9daf9 59 TGraph* fu = param ->GetWalk(i);
60 // TGraph* fu = param ->GetAmpLEDRec(i);
61 fWalk.AddAtAndExpand(fu,i);
62
63 if(fu) {
2e6a5ee0 64 Int_t np=fu->GetN();
65 if(np>0) {
66 grY = fu->GetY();
12e9daf9 67 // grX[i] = fu->GetX();
2e6a5ee0 68 TMath::Sort(np, grY, index,down);
69 fMaxValue[i]=Int_t(grY[index[0]]);
12e9daf9 70
2e6a5ee0 71 }
72 }
12e9daf9 73
8d72d1c2 74 }
12e9daf9 75
2e6a5ee0 76 // delete [] grY;
77 // delete [] grX;
8d72d1c2 78
79 //
80}
81//_____________________________________________________________________________
82
9e1b06a2 83AliT0Calibrator::AliT0Calibrator(const AliT0Calibrator &r): TNamed(),
8d72d1c2 84 fChannelWidth(0),
74adb36a 85 fWalk(0)
8d72d1c2 86
87{
88 //
89 // AliT0calibartor copy constructor
90 //
91
92 ((AliT0Calibrator &) r).Copy(*this);
93
94}
95
96//_____________________________________________________________________________
97AliT0Calibrator &AliT0Calibrator::operator=(const AliT0Calibrator &r)
98{
99 //
100 // Assignment operator
101 //
102
103 if (this != &r) ((AliT0Calibrator &) r).Copy(*this);
104 return *this;
105
106}
107
108
109
110//____________________________________________________________________
aaa0a98f 111Int_t AliT0Calibrator::WalkCorrection(Int_t ipmt, Int_t qt, Int_t time, TString option)
8d72d1c2 112{
113 //slewing correcion and equalizing channels
114
2e6a5ee0 115 Int_t walk=0;
116
117 Int_t timeEq=0, timeWalk=0;
118 // TGraph* fu1 = param ->GetWalk(ipmt);
119 // TGraph* fu1 = param ->GetAmpLEDRec(ipmt);
120 TGraph *fu1=(TGraph*) fWalk.At(ipmt);
121 if(fu1 && fu1->GetN()>0) {
122 walk=Int_t(fu1->Eval(Double_t(qt)));
e8ed1cd0 123 }
124 if (option == "pdc") {
12e9daf9 125 timeWalk = time + Int_t(fMaxValue[ipmt]-walk) ;
126 timeEq= timeWalk - fTimeDelayCFD[ipmt];
29ed1d0e 127 AliDebug(10,Form(" ipmt %i time before %i timeWalk %i , qt %i timeEq %i \n ",
128 ipmt, time,timeWalk, qt, timeEq ));
e8ed1cd0 129 }
130 if (option == "cosmic") {
2e6a5ee0 131 timeWalk = time + Int_t((fMaxValue[ipmt]-walk)) ;
132 if(walk <1 ) timeWalk = time ;
133 timeEq= timeWalk - fTimeDelayCFD[ipmt];
134 AliDebug(10,Form(" ipmt %i time before %i timeWalk %i , qt %i timeEq %i \n ",
e8ed1cd0 135 ipmt, time,timeWalk, qt, timeEq ));
2e6a5ee0 136 }
137
8d72d1c2 138 return timeEq;
139}
140
141
142