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