]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/TenderSupplies/AliTOFcalibESD.cxx
- recalibration of the chamber gain
[u/mrichter/AliRoot.git] / ANALYSIS / TenderSupplies / AliTOFcalibESD.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 ////////////////////////////////////////////////////////////////////
17 //                                                                //
18 // recalculate the TOF signal from the TOF raw signal             //
19 // using the updates in the OCDB                                  //
20 //                                                                //
21 ////////////////////////////////////////////////////////////////////
22
23 #include "AliTOFChannelOnlineStatusArray.h"
24 #include "TObjArray.h"
25 #include "AliTOFDeltaBCOffset.h"
26 #include "AliTOFCTPLatency.h"
27 #include "AliTOFRunParams.h"
28 #include "AliESDEvent.h"
29 #include "AliESDtrack.h"
30 #include "AliCDBManager.h"
31 #include "AliCDBEntry.h"
32 #include "AliTOFChannelOffline.h"
33 #include "AliTOFGeometry.h"
34
35 #include "AliTOFcalibESD.h"
36
37 ClassImp(AliTOFcalibESD)
38
39 //______________________________________________________________-
40
41 AliTOFcalibESD::AliTOFcalibESD() :
42   TObject(),
43   fInitFlag(kFALSE),
44   fChannelStatusArray(NULL),
45   fParOfflineArray(NULL),
46   fDeltaBCOffsetObj(NULL),
47   fCTPLatencyObj(NULL),
48   fRunParamsObj(NULL),
49   fTimeZero(0),
50   fTOFResolution(130)
51 {
52   /*
53    * default constructor
54    */
55 }
56
57 //______________________________________________________________-
58
59 AliTOFcalibESD::~AliTOFcalibESD()
60 {
61   /*
62    * default destructor
63    */
64 }
65
66 //______________________________________________________________-
67
68 Bool_t
69 AliTOFcalibESD::Init(Int_t run)
70 {
71   /*
72    * init
73    */
74
75   /* get cdb instance */
76   AliCDBManager *cdb = AliCDBManager::Instance();
77   AliCDBEntry *entry = NULL;
78
79   /* get channel status array */
80   entry = cdb->Get("TOF/Calib/Status", run);
81   if (!entry || !entry->GetObject()) return kFALSE;
82   fChannelStatusArray = (AliTOFChannelOnlineStatusArray *)entry->GetObject();
83   /* get par offline array */
84   entry = cdb->Get("TOF/Calib/ParOffline", run);
85   if (!entry || !entry->GetObject()) return kFALSE;
86   fParOfflineArray = (TObjArray *)entry->GetObject();
87   /* get deltaBC offset obj */
88   entry = cdb->Get("TOF/Calib/DeltaBCOffset", run);
89   if (!entry || !entry->GetObject()) return kFALSE;
90   fDeltaBCOffsetObj = (AliTOFDeltaBCOffset *)entry->GetObject();
91   /* get CTP latency obj */
92   entry = cdb->Get("TOF/Calib/CTPLatency", run);
93   if (!entry || !entry->GetObject()) return kFALSE;
94   fCTPLatencyObj = (AliTOFCTPLatency *)entry->GetObject();
95   /* get run params obj */
96   entry = cdb->Get("TOF/Calib/RunParams", run);
97   if (!entry || !entry->GetObject()) return kFALSE;
98   fRunParamsObj = (AliTOFRunParams *)entry->GetObject();
99
100   /* all done */
101   fInitFlag = kTRUE;
102   return kTRUE;
103 }
104
105 //______________________________________________________________-
106
107 void
108 AliTOFcalibESD::CalibrateESD(AliESDEvent *event)
109 {
110   /*
111    * calibrate ESD
112    */
113   
114   /* get global calibration params */
115   AliTOFChannelOffline *parOffline = NULL;
116 //   Int_t deltaBCOffset = fDeltaBCOffsetObj->GetDeltaBCOffset();  //see below
117   Float_t ctpLatency = fCTPLatencyObj->GetCTPLatency();
118   Float_t tdcLatencyWindow;
119   Float_t timezero = fRunParamsObj->EvalT0(event->GetTimeStamp());
120   fTimeZero=timezero;
121   fTOFResolution=fRunParamsObj->EvalTOFResolution(event->GetTimeStamp());
122   
123   /* loop over tracks */
124   AliESDtrack *track = NULL;
125   Int_t index, l0l1, deltaBC;
126   Double_t time, tot;
127   for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) {
128
129     /* get track */
130     track = event->GetTrack(itrk);
131     if (!track || !(track->GetStatus() & AliESDtrack::kTOFout)) continue;
132     
133     /* get info */
134     index = track->GetTOFCalChannel();
135     time = track->GetTOFsignalRaw();
136     tot = track->GetTOFsignalToT();
137     l0l1 = track->GetTOFL0L1();
138     deltaBC = track->GetTOFDeltaBC();
139     
140     /* get channel dependent calibration params */
141     parOffline = (AliTOFChannelOffline *)fParOfflineArray->At(index);
142     tdcLatencyWindow = fChannelStatusArray->GetLatencyWindow(index) * 1.e3;
143     
144     /* deltaBC correction (inhibited for the time being) */
145     //  time -= (deltaBC - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth();
146     /* L0-L1 latency correction */
147     time += l0l1 * AliTOFGeometry::BunchCrossingBinWidth();
148     /* CTP latency correction */
149     time += ctpLatency;
150     /* TDC latency window correction */
151     time -= tdcLatencyWindow;
152     /* time-zero correction */
153     time -= timezero;
154     /* time calibration correction */
155     if (tot < AliTOFGeometry::SlewTOTMin()) 
156       tot = AliTOFGeometry::SlewTOTMin();
157     if (tot > AliTOFGeometry::SlewTOTMax()) 
158       tot = AliTOFGeometry::SlewTOTMax();
159     for (Int_t islew = 0; islew < 6; islew++)
160       time -= parOffline->GetSlewPar(islew) * TMath::Power(tot, islew) * 1.e3;
161     
162     /* set new TOF signal */
163     track->SetTOFsignal(time);
164
165   }
166
167 }