1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliTRDAnalysisTaskTP.cxx 42548 2010-07-27 08:10:51Z cblume $ */
18 ////////////////////////////////////////////////////////////////////////////
20 // Track point maker for the alignment of TRD //
23 // Sebastian Huber (S.Huber@gsi.de) //
25 ////////////////////////////////////////////////////////////////////////////
33 #include <TLinearFitter.h>
35 #include "AliVEvent.h"
36 #include "AliESDEvent.h"
37 #include "AliInputEventHandler.h"
38 #include "AliESDInputHandler.h"
39 #include "AliAnalysisTaskSE.h"
40 #include "AliAnalysisManager.h"
41 #include "AliAlignObjParams.h"
42 #include "AliTrackPointArray.h"
43 #include "AliESDfriend.h"
44 #include "AliESDtrack.h"
45 #include "AliESDfriendTrack.h"
49 #include "TTimeStamp.h"
50 #include "TCollection.h"
52 #include "AliGeomManager.h"
54 #include "AliTRDAnalysisTaskTP.h"
56 ClassImp(AliTRDAnalysisTaskTP)
58 AliTRDAnalysisTaskTP::AliTRDAnalysisTaskTP()
73 // Default constructor
78 //____________________________________________________________
79 AliTRDAnalysisTaskTP::AliTRDAnalysisTaskTP(const char *name) :
80 AliAnalysisTaskSE(name),
97 DefineOutput(1, TTree::Class());
98 DefineOutput(2, TObjArray::Class());
102 //____________________________________________________________
103 AliTRDAnalysisTaskTP::~AliTRDAnalysisTaskTP()
111 //____________________________________________________________
112 void AliTRDAnalysisTaskTP::UserCreateOutputObjects()
115 // Create the output objects
118 AliAlignObjParams alobj; // initialize align obj.
119 TString option = GetOption();
121 if (!fArrHists) fArrHists=new TObjArray;
123 fModpop = new TH2D("modpop","modpop",90,-0.5,89.5,30,-0.5,29.5);
124 fModpop->SetXTitle("module nr");
125 fModpop->SetYTitle("layer nr");
126 fArrHists->Add(fModpop);
129 fTree = new TTree("spTree", "Tree with track space point arrays");
130 fTree->Branch("SP","AliTrackPointArray", &fArray);
134 //____________________________________________________________
135 void AliTRDAnalysisTaskTP::UserExec(Option_t *)
141 //AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent);
142 fESD = dynamic_cast<AliESDEvent *>(fInputEvent);
144 //cout << "ERROR: fESDs not available " << endl;
148 fESDfriend = dynamic_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
150 //cout << "ERROR: fESDfriends not available " << endl;
154 TLinearFitter fitter(2, "pol1");
155 TLinearFitter fitterz(2, "pol1");
158 int tpc = 0; // require tpc
159 int ptu = 0; // require certain pt's (magnetic field and tpc presumably on)
161 const Float_t kMaxDelta = 1;
162 const Float_t kMinNcl = 60;
163 const Float_t kMinPtLow = 0.2;
164 const Float_t kMinNclLow = 100;
165 const Float_t kMinPt0 = 2;
166 const Float_t kMinPt = 0;
167 UInt_t status = AliESDtrack::kTRDrefit;
168 if (tpc) status |= AliESDtrack::kTPCrefit;
170 const Float_t kMinRadius2 = 2*2;
171 const Float_t kMaxRadius2 = 400*400;
172 const Float_t kDeadSpace = 4;
173 const Float_t kTan = TMath::Tan(10*TMath::DegToRad());
174 Int_t ntracks = fESD->GetNumberOfTracks();
175 const AliTrackPointArray *array=0;
176 AliTrackPointArray *tmpArray = 0;
177 // trdarray contains all trd points in this event, for duplication detection
178 AliTrackPointArray *trdarray = new AliTrackPointArray(1000);
181 for (Int_t itrack=0; itrack < ntracks; itrack++) { //track loop
183 AliESDtrack * track = fESD->GetTrack(itrack);
185 if (!track) continue;
187 if (track->GetP() < kMinPt) continue;
188 if (track->GetKinkIndex(0)!=0) continue;
189 if (tpc) if (track->GetTPCNcls()<kMinNcl) continue;
190 if (ptu) if (track->GetP() < kMinPtLow) continue;
191 if (ptu) if (track->GetP() < kMinPt0 && track->GetTPCNcls()<kMinNclLow) continue;
193 AliESDfriendTrack *friendtrack = fESDfriend->GetTrack(itrack);
198 array = friendtrack->GetTrackPointArray();
199 if (!array) continue;
200 Int_t npoints = array->GetNPoints();
201 if (tmpArray) delete tmpArray;
202 tmpArray = new AliTrackPointArray(npoints);
206 for (Int_t ipoint=0; ipoint<npoints; ipoint++){
209 array->GetPoint(p, ipoint);
211 UShort_t volid = array->GetVolumeID()[ipoint];
213 AliGeomManager::ELayerID layer = AliGeomManager::VolUIDToLayer(volid,iModule);
214 if ((layer < AliGeomManager::kFirstLayer) || (layer >= AliGeomManager::kLastLayer)) continue;
216 if ((iModule >= AliGeomManager::LayerSize(layer)) || (iModule < 0)) continue;
218 Float_t r2 = p.GetX()*p.GetX()+p.GetY()*p.GetY();
219 if ( r2<kMinRadius2 || r2 > kMaxRadius2 ) continue;
223 if (layer>=AliGeomManager::kTPC1 && layer<=AliGeomManager::kTPC2){
224 if (p.GetCov()[0]<0 || p.GetCov()[3]<0 || p.GetCov()[5]<0) continue;
226 AliTrackPoint& plocal = p.MasterToLocal();
227 Double_t ylocal = plocal.GetY();
228 Double_t zlocal = plocal.GetZ();
229 Double_t xlocal = plocal.GetX();
230 Float_t edgey = TMath::Abs(plocal.GetX()*kTan);
232 fitter.ClearPoints();
233 fitterz.ClearPoints();
234 for (Int_t jpoint=ipoint-7; jpoint<=ipoint+7; jpoint++){
235 if (jpoint<0 || jpoint>=npoints) continue;
236 if (ipoint==jpoint) continue;
237 UShort_t volidL = array->GetVolumeID()[jpoint];
238 if (volidL!=volid) continue;
240 array->GetPoint(pc, jpoint);
241 AliTrackPoint &pcl= pc.MasterToLocal();
242 Double_t dx = pcl.GetX()-xlocal;
243 fitter.AddPoint(&dx,pcl.GetY(),1);
244 fitterz.AddPoint(&dx,pcl.GetZ(),1);
247 if (nclose<6) continue;
251 Double_t fity =fitter.GetParameter(0);
252 Double_t fitz =fitterz.GetParameter(0);
253 if (TMath::Abs(ylocal-fity)>kMaxDelta) continue;
254 if (TMath::Abs(zlocal-fitz)>kMaxDelta) continue;
255 if (TMath::Abs(fity)>edgey-kDeadSpace) continue;
259 if (layer>=AliGeomManager::kTRD1 && layer<=AliGeomManager::kTRD6){
261 trdarray->AddPoint(ntrdarray++,&p);
262 fModpop->Fill(iModule,layer);
265 tmpArray->AddPoint(current,&p);
268 if (ntpc < 100) continue;
269 if (ntrd < 4) continue;
270 if (fArray) delete fArray;
271 fArray = new AliTrackPointArray(current);
272 for (Int_t ipoint=0; ipoint<current; ipoint++){
274 tmpArray->GetPoint(p, ipoint);
275 fArray->AddPoint(ipoint,&p);
283 PostData(2,fArrHists);
286 //____________________________________________________________
287 void AliTRDAnalysisTaskTP::Terminate(Option_t */*option*/)