]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/TenderSupplies/AliTOFTenderSupply.cxx
changing default for cut on tracks which have shared TPC clusters to ***OFF*** (was...
[u/mrichter/AliRoot.git] / ANALYSIS / TenderSupplies / AliTOFTenderSupply.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 //                                                                           //
19 // TOF tender: 
20 //             load updated calibration if needed
21 //             reapply TOF pid on the fly                                    //
22 //                                                                           //
23 ///////////////////////////////////////////////////////////////////////////////
24 #include <AliLog.h>
25 #include <AliESDEvent.h>
26 #include <AliESDtrack.h>
27 #include <AliESDInputHandler.h>
28 #include <AliAnalysisManager.h>
29 #include <AliESDpid.h>
30 #include <AliTender.h>
31
32 #include <AliTOFcalib.h>
33 #include <AliTOFT0maker.h>
34
35 #include <AliCDBManager.h>
36 #include <AliCDBEntry.h>
37 #include <AliT0CalibSeasonTimeShift.h>
38
39 #include "AliTOFTenderSupply.h"
40
41 AliTOFTenderSupply::AliTOFTenderSupply() :
42   AliTenderSupply(),
43   fESDpid(0x0),
44   fIsMC(kFALSE),
45   fApplyT0(kFALSE),
46   fTimeZeroType(3),
47   fCorrectExpTimes(kTRUE),
48   fLHC10dPatch(kFALSE),
49   fTOFCalib(0x0),
50   fTOFT0maker(0x0),
51   fTOFres(100.)
52
53
54 {
55   //
56   // default ctor
57   //
58
59   fT0shift[0] = 0;
60   fT0shift[1] = 0;
61   fT0shift[2] = 0;
62   fT0shift[3] = 0;
63 }
64
65 //_____________________________________________________
66 AliTOFTenderSupply::AliTOFTenderSupply(const char *name, const AliTender *tender) :
67   AliTenderSupply(name,tender),
68   fESDpid(0x0),
69   fIsMC(kFALSE),
70   fApplyT0(kFALSE),
71   fTimeZeroType(3),
72   fCorrectExpTimes(kTRUE),
73   fLHC10dPatch(kFALSE),
74   fTOFCalib(0x0),
75   fTOFT0maker(0x0),
76   fTOFres(100.) 
77  
78 {
79   //
80   // named ctor
81   //
82
83   fT0shift[0] = 0;
84   fT0shift[1] = 0;
85   fT0shift[2] = 0;
86   fT0shift[3] = 0;
87 }
88
89 //_____________________________________________________
90 void AliTOFTenderSupply::Init()
91 {
92   //
93   // Initialise TOF tender
94   //
95   Printf("|******************************************************|");
96   Printf("|    Alice TOF Tender Initialisation                   |");
97
98
99
100   //
101   // Setup PID object
102   //
103
104   // Check if another detector already created the esd pid object
105   // if not we create it and set it to the ESD input handler
106   fESDpid=fTender->GetESDhandler()->GetESDpid();
107   if (!fESDpid) {
108     fESDpid=new AliESDpid;
109     fTender->GetESDhandler()->SetESDpid(fESDpid);
110   }
111
112   //Set proper resolution in case of MC
113   AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
114   if (mgr->GetMCtruthEventHandler()) fIsMC=kTRUE;
115
116
117   //
118   // Create TOF calibration classes
119   //
120   if (!fTOFCalib){
121       fTOFCalib=new AliTOFcalib();
122       fTOFCalib->SetRemoveMeanT0(!(fIsMC));        // must be kFALSE on MC (default is kTRUE)
123       fTOFCalib->SetCalibrateTOFsignal(!(fIsMC));  // must be kFALSE on MC (no new calibration) (default is kTRUE)
124       fTOFCalib->SetCorrectTExp(fCorrectExpTimes); // apply a fine tuning on the expected times at low momenta
125 //      fTOFCalib->Init();
126   }
127   if (!fTOFT0maker) {
128       fTOFT0maker = new AliTOFT0maker(fESDpid,fTOFCalib);
129       fTOFT0maker->SetTimeResolution(fTOFres); // set TOF resolution for the PID
130   }
131   Printf("|    Settings:                                         |");
132   Printf("|    Correct Exp Times              :  %d               |",fCorrectExpTimes);
133   Printf("|    LHC10d patch                   :  %d               |",fLHC10dPatch);
134   Printf("|    TOF resolution for TOFT0 maker :  %5.2f (ps)     |",fTOFres);
135   Printf("|    timeZero selection             :  %d               |",fTimeZeroType);
136   Printf("|******************************************************|");
137
138
139 }
140
141 //_____________________________________________________
142 void AliTOFTenderSupply::ProcessEvent()
143 {
144   //
145   // Reapply pid information
146   //
147
148   //no corrections for MC
149   AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
150   if (mgr->GetMCtruthEventHandler()) return;
151
152   AliESDEvent *event=fTender->GetEvent();
153   if (!event) return;
154
155   //  Printf("AliTOFTenderSupply: process event\n");
156     
157   //recalculate TOF signal
158   if (fTender->RunChanged()){
159     Printf("AliTOFTenderSupply: INIT at run %d\n",fTender->GetRun());
160     fTOFCalib->Init(fTender->GetRun());
161     
162     if(event->GetT0TOF()){ // read T0 detector correction from OCDB
163       // OCDB instance
164       AliCDBManager* ocdbMan = AliCDBManager::Instance();
165       ocdbMan->SetRun(fTender->GetRun());    
166       AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");
167       if(entry) {
168         AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();
169         Float_t *t0means= clb->GetT0Means();
170         //      Float_t *t0sigmas = clb->GetT0Sigmas();
171         fT0shift[0] = t0means[0];
172         fT0shift[1] = t0means[1];
173         fT0shift[2] = t0means[2];
174         fT0shift[3] = t0means[3];
175       }   
176     }
177   }
178   fTOFCalib->CalibrateESD(event);
179
180   if (fLHC10dPatch) RecomputeTExp(event);
181
182   if(fIsMC){
183     Float_t t0true = fTOFT0maker->TuneForMC(event);
184     
185     if(event->GetT0TOF()){// add the t0 smearing also to the T0 detector information
186       event->SetT0TOF(0,event->GetT0TOF(0) + t0true);
187       event->SetT0TOF(1,event->GetT0TOF(1) + t0true);
188       event->SetT0TOF(2,event->GetT0TOF(2) + t0true);  
189     }
190   }
191   
192   if(event->GetT0TOF()){ // write the T0 detector corrected times
193     if(event->GetT0TOF(0) == 0) event->SetT0TOF(0, 9999999.);
194     if(event->GetT0TOF(1) == 0) event->SetT0TOF(1, 99999.);
195     if(event->GetT0TOF(2) == 0) event->SetT0TOF(2, 99999.);
196
197     if(! fIsMC){
198       event->SetT0TOF(0,event->GetT0TOF(0) - fT0shift[0]);
199       event->SetT0TOF(1,event->GetT0TOF(1) - fT0shift[1]);
200       event->SetT0TOF(2,event->GetT0TOF(2) - fT0shift[2]);
201       
202       if(event->GetT0TOF(0) > 9000000) event->SetT0TOF(0, 9999999.);
203       if(event->GetT0TOF(1) > 90000) event->SetT0TOF(1, 99999.);
204       if(event->GetT0TOF(2) > 90000) event->SetT0TOF(2, 99999.);
205     }
206   }
207   
208   //Calculate event time zero
209   fTOFT0maker->ComputeT0TOF(event);
210   fTOFT0maker->WriteInESD(event);
211
212   // subtract the T0-TOF information to the TOF times
213   if(fApplyT0){
214     fTOFT0maker->ApplyT0TOF(event);
215     event->SetT0(0.0);
216   }
217
218   //
219   // recalculate PID probabilities
220   //
221
222   fESDpid->SetTOFResponse(event, (AliESDpid::EStartTimeType_t)fTimeZeroType);
223   
224   Int_t ntracks=event->GetNumberOfTracks();
225   for(Int_t itrack = 0; itrack < ntracks; itrack++){
226     fESDpid->MakeTOFPID(event->GetTrack(itrack),0);
227   }
228   
229   
230 }
231
232
233 //_____________________________________________________
234 void AliTOFTenderSupply::RecomputeTExp(AliESDEvent *event) const
235 {
236   /*
237    * calibrate TExp
238    */
239
240   
241   /* loop over tracks */
242   AliESDtrack *track = NULL;
243   for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) {
244     /* get track and calibrate */
245     track = event->GetTrack(itrk);
246     RecomputeTExp(track);
247   }
248   
249 }
250
251 //_____________________________________________________
252 void AliTOFTenderSupply::RecomputeTExp(AliESDtrack *track) const
253 {
254   /*** 
255        THIS METHOD IS BASED ON THEORETICAL EXPECTED TIME COMPUTED
256        USING AVERAGE MOMENTUM BETWEEN INNER/OUTER TRACK PARAMS 
257        IT IS A ROUGH APPROXIMATION APPLIED TO FIX LHC10d-pass2 DATA
258        WHERE A WRONG GEOMETRY (FULL TRD) WAS INSERTED
259   ***/
260
261   Double_t texp[AliPID::kSPECIES];
262   if (!track || !(track->GetStatus() & AliESDtrack::kTOFout)) return;
263
264
265   /* get track params */
266   Float_t l = track->GetIntegratedLength();
267   Float_t p = track->P();
268   if (track->GetInnerParam() && track->GetOuterParam()) {
269     Float_t pin = track->GetInnerParam()->P();
270     Float_t pout = track->GetOuterParam()->P();
271     p = 0.5 * (pin + pout);
272   }
273   /* loop over particle types and compute expected time */
274   for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++)
275     texp[ipart] = GetExpTimeTh(AliPID::ParticleMass(ipart), p, l) - 37.; 
276   // 37 is a final semiempirical offset to further adjust (calibrations were
277   // done with "standard" integratedTimes)
278   /* set integrated times */
279   track->SetIntegratedTimes(texp);
280
281 }