]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCcalibCalib.cxx
New check for bad SDD modules (F. Prino)
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibCalib.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 //   Component for redoing the reconstruction from the clusters and tracks
20 //      
21 //   The new calibration data used 
22 //
23 //   In reality it overwrites the content of the ESD 
24 //    
25
26 //  marian.ivanov@cern.ch
27 // 
28 #include "AliTPCcalibCalib.h"
29 #include "TSystem.h"
30 #include "TFile.h"
31 #include "TTreeStream.h"
32 #include "AliLog.h"
33 #include "TTimeStamp.h"
34 #include "AliESDEvent.h"
35 #include "AliESDfriend.h"
36 #include "AliESDtrack.h"
37 #include "AliTracker.h"
38
39 #include "AliTPCcalibDB.h"
40 #include "AliTPCTransform.h"
41 #include "AliTPCclusterMI.h"
42 #include "AliTPCseed.h"
43
44 ClassImp(AliTPCcalibCalib)
45
46 AliTPCcalibCalib::AliTPCcalibCalib():
47     AliTPCcalibBase()
48 {
49   //
50   // Constructor
51   //
52 }
53
54
55 AliTPCcalibCalib::AliTPCcalibCalib(const Text_t *name, const Text_t *title) 
56   :AliTPCcalibBase()
57 {  
58   SetName(name);
59   SetTitle(title);
60 }
61
62
63 AliTPCcalibCalib::AliTPCcalibCalib(const AliTPCcalibCalib&calib):
64   AliTPCcalibBase(calib)
65 {
66   //
67   // copy constructor
68   //
69 }
70
71 AliTPCcalibCalib &AliTPCcalibCalib::operator=(const AliTPCcalibCalib&calib){
72   //
73   //
74   //
75   ((AliTPCcalibBase *)this)->operator=(calib);
76   return *this;
77 }
78
79
80 AliTPCcalibCalib::~AliTPCcalibCalib() {
81   //
82   // destructor
83   //
84 }
85
86
87 void     AliTPCcalibCalib::Process(AliESDEvent *event){
88   //
89   // 
90   //
91   if (!event) {
92     return;
93   }  
94   AliESDfriend *ESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
95   if (!ESDfriend) {
96    return;
97   }
98   
99   if (GetDebugLevel()>20) printf("Hallo world: Im here\n");
100   Int_t ntracks=event->GetNumberOfTracks();   
101   //
102   //
103   //
104
105   for (Int_t i=0;i<ntracks;++i) {
106     AliESDtrack *track = event->GetTrack(i);  
107     const AliExternalTrackParam * trackIn = track->GetInnerParam();
108     const AliExternalTrackParam * trackOut = track->GetOuterParam();
109     if (!trackIn) continue;
110     if (!trackOut) continue;
111    
112     AliESDfriendTrack *friendTrack = ESDfriend->GetTrack(i);
113     TObject *calibObject;
114     AliTPCseed *seed = 0;
115     for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
116       if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
117     }
118     if (!seed) continue;
119     RefitTrack(track, seed);
120   }
121   return;
122 }
123
124 Bool_t  AliTPCcalibCalib::RefitTrack(AliESDtrack * track, AliTPCseed *seed){
125   //
126   // Refit track
127   //
128
129   //
130   // First apply calibration
131   //
132
133   AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform();
134   for (Int_t irow=0;irow<159;irow++) {
135     AliTPCclusterMI *cluster=seed->GetClusterPointer(irow);
136     if (!cluster) continue; 
137     AliTPCclusterMI cl0(*cluster);
138     Double_t x[3]={cluster->GetRow(),cluster->GetPad(),cluster->GetTimeBin()};
139     Int_t i[1]={cluster->GetDetector()};
140     transform->Transform(x,i,0,1);
141     if (cluster->GetDetector()%36>17){
142       x[1]*=-1;
143     }
144     //
145     cluster->SetX(x[0]);
146     cluster->SetY(x[1]);
147     cluster->SetZ(x[2]);
148     if (fStreamLevel>2){
149       TTreeSRedirector *cstream = GetDebugStreamer();
150       if (cstream){
151         (*cstream)<<"Clusters"<<
152           "cl0.="<<&cl0<<
153           "cl.="<<cluster<<
154           "\n";
155       }
156     }
157   }
158   Int_t ncl = seed->GetNumberOfClusters();  
159   // 
160   // And now do refit
161   //
162   AliExternalTrackParam * trackInOld  = (AliExternalTrackParam*)track->GetInnerParam();
163   AliExternalTrackParam * trackOutOld = (AliExternalTrackParam*)track->GetOuterParam();
164
165   AliExternalTrackParam trackIn  = *trackOutOld;
166   AliExternalTrackParam trackOut = *trackInOld;
167   trackIn.ResetCovariance(10.);
168   trackOut.ResetCovariance(10.);
169   Double_t xyz[3];
170   Int_t nclIn=0,nclOut=0;
171   //
172   // Refit out
173   //
174   for (Int_t irow=0; irow<160; irow++){
175     AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
176     if (!cl) continue;
177     if (cl->GetX()<80) continue;
178     Int_t sector = cl->GetDetector();
179     Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackOut.GetAlpha();
180
181     if (TMath::Abs(dalpha)>0.01)
182       trackOut.Rotate(TMath::DegToRad()*(sector%18*20.+10.));
183     //if (RejectCluster(cl,&trackOut)) continue;
184     Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()};
185     Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
186     trackOut.GetXYZ(xyz);
187     Double_t bz = AliTracker::GetBz(xyz);
188     if (trackOut.PropagateTo(r[0],bz)) nclOut++;
189     trackOut.Update(&r[1],cov);    
190     
191   }
192   //
193   // Refit in
194   //
195
196   for (Int_t irow=159; irow>0; irow--){
197     AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
198     if (!cl) continue;
199     if (cl->GetX()<80) continue;
200     Int_t sector = cl->GetDetector();
201     Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackIn.GetAlpha();
202     if (TMath::Abs(dalpha)>0.01)
203       trackIn.Rotate(TMath::DegToRad()*(sector%18*20.+10.));
204     //if (RejectCluster(cl,&trackIn)) continue;
205     Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()};
206     Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
207     trackOut.GetXYZ(xyz);
208     Double_t bz = AliTracker::GetBz(xyz);
209
210     if (trackIn.PropagateTo(r[0],bz)) nclIn++;
211     trackIn.Update(&r[1],cov);    
212   }
213
214   if (fStreamLevel>0){
215     TTreeSRedirector *cstream = GetDebugStreamer();
216     if (cstream){
217       (*cstream)<<"Tracks"<<
218         "nclIn="<<nclIn<<
219         "nclOut="<<nclOut<<
220         "ncl="<<ncl<<
221         "TrIn0.="<<trackInOld<<
222         "TrOut0.="<<trackOutOld<<
223         "TrIn1.="<<&trackIn<<
224         "TrOut1.="<<&trackOut<<
225         "\n";
226     }
227   }
228 }
229
230
231
232 Bool_t AliTPCcalibCalib::RejectCluster(AliTPCclusterMI* cl, AliExternalTrackParam * param){
233   //
234   // check the acceptance of cluster
235   // Cut on edge effects
236   //
237   Bool_t isReject = kFALSE;
238   Float_t edgeY = cl->GetX()*TMath::Tan(TMath::Pi()/18);
239   Float_t dist  = edgeY - TMath::Abs(cl->GetY());
240   if (param)  dist  = TMath::Abs(edgeY - TMath::Abs(param->GetY()));
241   if (dist<3) isReject=kTRUE;
242   if (cl->GetType()<0) isReject=kTRUE;
243   return isReject;
244 }
245
246