]>
Commit | Line | Data |
---|---|---|
dae0a357 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2009, 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 | // AliAnalysisTask to study the TPC-ITS track matching | |
19 | // | |
20 | // Author: A.Dainese, andrea.dainese@pd.infn.it | |
21 | ///////////////////////////////////////////////////////////// | |
22 | ||
23 | #include <TTree.h> | |
24 | #include <TChain.h> | |
25 | #include <TNtuple.h> | |
26 | #include <TList.h> | |
27 | #include <TH1F.h> | |
28 | #include <TH2F.h> | |
29 | #include <TVector3.h> | |
30 | #include <TGeoManager.h> | |
31 | ||
32 | #include "AliLog.h" | |
33 | #include "AliGeomManager.h" | |
34 | #include "AliTrackPointArray.h" | |
35 | #include "AliESDInputHandler.h" | |
36 | #include "AliESDVertex.h" | |
37 | #include "AliESDtrack.h" | |
38 | #include "AliESDEvent.h" | |
39 | #include "AliESDfriend.h" | |
40 | #include "AliAnalysisTask.h" | |
41 | #include "AliAnalysisManager.h" | |
42 | #include "AliExternalTrackParam.h" | |
43 | #include "AliTrackMatchingTPCITSCosmics.h" | |
44 | ||
45 | ||
46 | ClassImp(AliTrackMatchingTPCITSCosmics) | |
47 | ||
48 | ||
49 | //________________________________________________________________________ | |
50 | AliTrackMatchingTPCITSCosmics::AliTrackMatchingTPCITSCosmics(const char *name): | |
51 | AliAnalysisTask(name,"task"), | |
52 | fOnlySPDFO(kTRUE), | |
53 | fReadHLTESD(kFALSE), | |
54 | fGeometryFileName("geometry.root"), | |
55 | fESD(0), | |
56 | fList(0), | |
57 | fHistEvCount(0), | |
58 | fntTrks(0), | |
59 | fntPairs(0), | |
60 | fntITSPairs(0) | |
61 | { | |
62 | // Constructor | |
63 | ||
64 | // Define input and output slots here | |
65 | // Input slot #0 works with a TChain | |
66 | DefineInput(0, TChain::Class()); | |
67 | // Output slot #0 writes into a TList | |
68 | DefineOutput(0,TList::Class()); //My private output | |
69 | } | |
70 | ||
71 | //________________________________________________________________________ | |
72 | AliTrackMatchingTPCITSCosmics::~AliTrackMatchingTPCITSCosmics() | |
73 | { | |
74 | // Destructor | |
75 | if (fList) { | |
76 | delete fList; | |
77 | fList = 0; | |
78 | } | |
79 | if (fHistEvCount) { | |
80 | delete fHistEvCount; | |
81 | fHistEvCount = 0; | |
82 | } | |
83 | if (fntTrks) { | |
84 | delete fntTrks; | |
85 | fntTrks = 0; | |
86 | } | |
87 | if (fntPairs) { | |
88 | delete fntPairs; | |
89 | fntPairs = 0; | |
90 | } | |
91 | if (fntITSPairs) { | |
92 | delete fntITSPairs; | |
93 | fntITSPairs = 0; | |
94 | } | |
95 | } | |
96 | ||
97 | //________________________________________________________________________ | |
98 | void AliTrackMatchingTPCITSCosmics::ConnectInputData(Option_t *) | |
99 | { | |
100 | // Connect ESD | |
101 | // Called once | |
102 | ||
103 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
104 | if(!tree) { | |
105 | printf("ERROR: Could not read chain from input slot 0\n"); | |
106 | } else { | |
107 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
108 | ||
109 | if(!esdH) { | |
110 | printf("ERROR: Could not get ESDInputHandler\n"); | |
111 | } else { | |
112 | if(!fReadHLTESD) { | |
113 | fESD = esdH->GetEvent(); | |
114 | } else { | |
115 | fESD = esdH->GetHLTEvent(); | |
116 | } | |
117 | } | |
118 | } | |
119 | ||
120 | return; | |
121 | } | |
122 | ||
123 | //________________________________________________________________________ | |
124 | void AliTrackMatchingTPCITSCosmics::Init() | |
125 | { | |
126 | // Initialization | |
127 | ||
128 | return; | |
129 | } | |
130 | ||
131 | //________________________________________________________________________ | |
132 | void AliTrackMatchingTPCITSCosmics::CreateOutputObjects() | |
133 | { | |
134 | // Create the output container | |
135 | // | |
136 | ||
137 | // Several histograms are more conveniently managed in a TList | |
138 | fList = new TList(); | |
139 | fList->SetOwner(); | |
140 | ||
141 | fHistEvCount = new TH1F("fHistEvCount","0: all, 1: SPDFO, 2: vtx, 3: TPCtrks, 4: ITStrks, 5: HLT",11,-0.5,10.5); | |
142 | fList->Add(fHistEvCount); | |
143 | ||
144 | fntTrks = new TNtuple("fntTrks","TPC-ITS matching","ptTPC:nClsTPC:nClsITSSA:nClsITSMI:SSD1:SSD2:phi:z:dx:dy:dz:drphi:dphi:dtgl"); | |
145 | fList->Add(fntTrks); | |
146 | fntPairs = new TNtuple("fntPairs","pairs at vertex","nClsITSSAin:nClsITSSAout:nClsITSMIin:nClsITSMIout:dxyITSSA:dzITSSA:dxyITSMI:dzITSMI:ptITSSAin:ptITSSAout:ptITSMIin:ptITSMIout:sigmad0MIin:sigmad0MIout"); | |
147 | fList->Add(fntPairs); | |
148 | fntITSPairs = new TNtuple("fntITSPairs","pairs at vertex","nClsITSSAin:nClsITSSAout:dxyITSSA:dzITSSA:ptITSSAin:ptITSSAout:d0mu"); | |
149 | fList->Add(fntITSPairs); | |
150 | ||
151 | return; | |
152 | } | |
153 | ||
154 | //________________________________________________________________________ | |
155 | void AliTrackMatchingTPCITSCosmics::Exec(Option_t */*option*/) | |
156 | { | |
157 | // Execute analysis for current event: | |
158 | // write ITS AliTrackPoints for selected tracks to fspTree | |
159 | ||
160 | // load the geometry | |
161 | if(!gGeoManager) { | |
162 | AliGeomManager::LoadGeometry(fGeometryFileName.Data()); | |
163 | if(!gGeoManager) { | |
164 | printf("AliAlignmentDataFilterITS::Exec(): no geometry loaded \n"); | |
165 | return; | |
166 | } | |
167 | } | |
168 | ||
169 | if(!fESD) { | |
170 | printf("AliTrackMatchingTPCITSCosmics::Exec(): no ESD \n"); | |
171 | return; | |
172 | } | |
173 | ||
174 | ||
175 | fHistEvCount->Fill(0); | |
176 | PostData(0,fList); | |
177 | ||
178 | if(fESD->IsHLTTriggerFired()) fHistEvCount->Fill(5); | |
179 | ||
180 | TString triggeredClass = fESD->GetFiredTriggerClasses(); | |
181 | if(triggeredClass.Contains("C0SCO-ABCE-NOPF-CENT")) { | |
182 | fHistEvCount->Fill(1); | |
183 | } else { | |
184 | if(fOnlySPDFO) { PostData(0,fList); return; } | |
185 | } | |
186 | ||
187 | Int_t ntracks = fESD->GetNumberOfTracks(); | |
188 | if(fESD->GetVertex()->GetNContributors()>=0) { | |
189 | fHistEvCount->Fill(2); | |
190 | } | |
191 | ||
192 | Int_t nTrksITSSA=0,nTrksTPC=0,nTrksTPCITS=0; | |
193 | Int_t idxITSSA[10000],idxTPC[10000]; | |
194 | Int_t idxITSSAin=-1,idxITSSAout=-1; | |
195 | Int_t idxTPCin=-1,idxTPCout=-1; | |
196 | for(Int_t itr=0; itr<ntracks; itr++) { | |
197 | AliESDtrack *t = fESD->GetTrack(itr); | |
198 | Int_t nClsTPC = t->GetNcls(1); | |
199 | Int_t nClsITS = t->GetNcls(0); | |
200 | if(nClsITS>=2 && nClsTPC==0) { // ITS SA | |
201 | idxITSSA[nTrksITSSA]=itr; | |
202 | nTrksITSSA++; | |
203 | //printf("%d\n",itr); | |
204 | } | |
205 | if(nClsTPC>=50) { // TPC | |
206 | idxTPC[nTrksTPC]=itr; | |
207 | nTrksTPC++; | |
208 | } | |
209 | if(nClsTPC>=50 && nClsITS>=2) {// TPC+ITS | |
210 | nTrksTPCITS++; | |
211 | /*printf(" --> TPC+ITS: %d + %d (%d,%d,%d,%d,%d,%d) pt = %f\n",nClsTPC,nClsITS, | |
212 | (Int_t)(t->HasPointOnITSLayer(0)), | |
213 | (Int_t)(t->HasPointOnITSLayer(1)), | |
214 | (Int_t)(t->HasPointOnITSLayer(2)), | |
215 | (Int_t)(t->HasPointOnITSLayer(3)), | |
216 | (Int_t)(t->HasPointOnITSLayer(4)), | |
217 | (Int_t)(t->HasPointOnITSLayer(5)), | |
218 | t->Pt());*/ | |
219 | } | |
220 | } | |
221 | ||
222 | //printf("nTrksTPC %d nTrksITSSA %d\n",nTrksTPC,nTrksITSSA); | |
223 | if(nTrksITSSA>0) fHistEvCount->Fill(3); | |
224 | if(nTrksTPC>0) fHistEvCount->Fill(4); | |
225 | ||
226 | if(nTrksTPC>2 || nTrksTPC==0 || nTrksITSSA>2 || nTrksITSSA==0) { PostData(0,fList); return; } | |
227 | ||
228 | for(Int_t itr=0; itr<nTrksTPC; itr++) { | |
229 | AliESDtrack *t = fESD->GetTrack(idxTPC[itr]); | |
230 | if(t->Py()>0) idxTPCin=idxTPC[itr]; | |
231 | if(t->Py()<0) idxTPCout=idxTPC[itr]; | |
232 | } | |
233 | ||
234 | ||
235 | for(Int_t itr=0; itr<nTrksITSSA; itr++) { | |
236 | AliESDtrack *t = fESD->GetTrack(idxITSSA[itr]); | |
237 | if(t->Py()>0) idxITSSAin=idxITSSA[itr]; | |
238 | if(t->Py()<0) idxITSSAout=idxITSSA[itr]; | |
239 | } | |
240 | ||
241 | Double_t xyzITS[3],xyzTPC[3]; | |
242 | ||
243 | // analysis for inward track | |
244 | if(idxITSSAin>-1 && idxTPCin>-1) { | |
245 | //printf(" %d\n",idxITSSAin); | |
246 | AliESDtrack *tITS = fESD->GetTrack(idxITSSAin); | |
247 | const AliExternalTrackParam *outerITS = tITS->GetOuterParam(); | |
248 | xyzITS[0]=-1000.;xyzITS[1]=-1000.;xyzITS[2]=-1000.; | |
249 | if(outerITS) outerITS->GetXYZAt(50.,fESD->GetMagneticField(),xyzITS); | |
250 | AliESDtrack *tTPC = fESD->GetTrack(idxTPCin); | |
251 | AliExternalTrackParam *innerTPC = new AliExternalTrackParam(*(tTPC->GetInnerParam())); | |
252 | innerTPC->Rotate(tITS->GetAlpha()); | |
253 | innerTPC->GetXYZAt(50.,fESD->GetMagneticField(),xyzTPC); | |
254 | fntTrks->Fill(innerTPC->Pt(), | |
255 | tTPC->GetNcls(1), | |
256 | tITS->GetNcls(0), | |
257 | tTPC->GetNcls(0), | |
258 | tITS->HasPointOnITSLayer(4), | |
259 | tITS->HasPointOnITSLayer(5), | |
260 | TMath::ATan2(xyzITS[1],xyzITS[0]), | |
261 | xyzITS[2], | |
262 | xyzITS[0]-xyzTPC[0], | |
263 | xyzITS[1]-xyzTPC[1], | |
264 | xyzITS[2]-xyzTPC[2], | |
265 | 0.5*(TMath::Sqrt(xyzITS[0]*xyzITS[0]+xyzITS[1]*xyzITS[1])+TMath::Sqrt(xyzTPC[0]*xyzTPC[0]+xyzTPC[1]*xyzTPC[1]))*(TMath::ATan2(xyzITS[1],xyzITS[0])-TMath::ATan2(xyzTPC[1],xyzTPC[0])), | |
266 | TMath::ATan2(tITS->Py(),tITS->Px())-TMath::ATan2(innerTPC->Py(),innerTPC->Px()), | |
267 | tITS->Pz()/tITS->Pt()-innerTPC->Pz()/innerTPC->Pt()); | |
268 | delete innerTPC; innerTPC=NULL; | |
269 | } | |
270 | ||
271 | // analysis for outward track | |
272 | if(idxITSSAout>-1 && idxTPCout>-1) { | |
273 | //printf(" %d\n",idxITSSAout); | |
274 | AliESDtrack *tITS = fESD->GetTrack(idxITSSAout); | |
275 | const AliExternalTrackParam *outerITS = tITS->GetOuterParam(); | |
276 | xyzITS[0]=-1000.;xyzITS[1]=-1000.;xyzITS[2]=-1000.; | |
277 | if(outerITS) outerITS->GetXYZAt(50.,fESD->GetMagneticField(),xyzITS); | |
278 | AliESDtrack *tTPC = fESD->GetTrack(idxTPCout); | |
279 | AliExternalTrackParam *innerTPC = new AliExternalTrackParam(*(tTPC->GetInnerParam())); | |
280 | innerTPC->Rotate(tITS->GetAlpha()); | |
281 | innerTPC->GetXYZAt(50.,fESD->GetMagneticField(),xyzTPC); | |
282 | fntTrks->Fill(innerTPC->Pt(), | |
283 | tTPC->GetNcls(1), | |
284 | tITS->GetNcls(0), | |
285 | tTPC->GetNcls(0), | |
286 | tITS->HasPointOnITSLayer(4), | |
287 | tITS->HasPointOnITSLayer(5), | |
288 | TMath::ATan2(xyzITS[1],xyzITS[0]), | |
289 | xyzITS[2], | |
290 | xyzITS[0]-xyzTPC[0], | |
291 | xyzITS[1]-xyzTPC[1], | |
292 | xyzITS[2]-xyzTPC[2], | |
293 | 0.5*(TMath::Sqrt(xyzITS[0]*xyzITS[0]+xyzITS[1]*xyzITS[1])+TMath::Sqrt(xyzTPC[0]*xyzTPC[0]+xyzTPC[1]*xyzTPC[1]))*(TMath::ATan2(xyzITS[1],xyzITS[0])-TMath::ATan2(xyzTPC[1],xyzTPC[0])), | |
294 | TMath::ATan2(tITS->Py(),tITS->Px())-TMath::ATan2(innerTPC->Py(),innerTPC->Px()), | |
295 | tITS->Pz()/tITS->Pt()-innerTPC->Pz()/innerTPC->Pt() | |
296 | ); | |
297 | delete innerTPC; innerTPC=NULL; | |
298 | } | |
299 | ||
300 | // inward-outward track ITS only | |
301 | if(idxITSSAin>-1 && idxITSSAout>-1) { | |
302 | AliESDtrack *tITSin = fESD->GetTrack(idxITSSAin); | |
303 | AliESDtrack *tITSout = fESD->GetTrack(idxITSSAout); | |
304 | if(tITSin->HasPointOnITSLayer(0) && | |
305 | tITSin->HasPointOnITSLayer(1) && | |
306 | tITSout->HasPointOnITSLayer(0) && | |
307 | tITSout->HasPointOnITSLayer(1)) { | |
308 | Double_t alpha = TMath::ATan2(tITSin->Py(),tITSin->Px()); | |
309 | tITSin->Propagate(alpha,0.,fESD->GetMagneticField()); | |
310 | tITSout->Propagate(alpha,0.,fESD->GetMagneticField()); | |
311 | Float_t d0[2],z0[2]; | |
312 | d0[0] = tITSin->GetY(); | |
313 | z0[0] = tITSin->GetZ(); | |
314 | d0[1] = tITSout->GetY(); | |
315 | z0[1] = tITSout->GetZ(); | |
316 | Float_t dxyITS = -(d0[0]-d0[1]); | |
317 | Float_t dzITS = z0[0]-z0[1]; | |
318 | fntITSPairs->Fill(tITSin->GetNcls(0),tITSout->GetNcls(0),dxyITS,dzITS,tITSin->Pt(),tITSout->Pt(),TMath::Abs(d0[0])); | |
319 | } | |
320 | } | |
321 | ||
322 | // inward-outward track TPC+ITS | |
323 | if(idxITSSAin>-1 && idxTPCin>-1 && idxITSSAout>-1 && idxTPCout>-1) { | |
324 | AliESDtrack *tTPCin = fESD->GetTrack(idxTPCin); | |
325 | AliESDtrack *tITSin = fESD->GetTrack(idxITSSAin); | |
326 | AliESDtrack *tTPCout = fESD->GetTrack(idxTPCout); | |
327 | AliESDtrack *tITSout = fESD->GetTrack(idxITSSAout); | |
328 | if(tTPCin->HasPointOnITSLayer(0) && | |
329 | tTPCin->HasPointOnITSLayer(1) && | |
330 | tITSin->HasPointOnITSLayer(0) && | |
331 | tITSin->HasPointOnITSLayer(1) && | |
332 | tTPCout->HasPointOnITSLayer(0) && | |
333 | tTPCout->HasPointOnITSLayer(1) && | |
334 | tITSout->HasPointOnITSLayer(0) && | |
335 | tITSout->HasPointOnITSLayer(1)) { | |
336 | Double_t alpha = TMath::ATan2(tTPCin->Py(),tTPCin->Px()); | |
337 | tTPCin->Propagate(alpha,0.,fESD->GetMagneticField()); | |
338 | tTPCout->Propagate(alpha,0.,fESD->GetMagneticField()); | |
339 | Float_t d0[2],z0[2]; | |
340 | d0[0] = tTPCin->GetY(); | |
341 | z0[0] = tTPCin->GetZ(); | |
342 | d0[1] = tTPCout->GetY(); | |
343 | z0[1] = tTPCout->GetZ(); | |
344 | Float_t dxyTPC = -(d0[0]-d0[1]); | |
345 | Float_t dzTPC = z0[0]-z0[1]; | |
346 | alpha = TMath::ATan2(tITSin->Py(),tITSin->Px()); | |
347 | tITSin->Propagate(alpha,0.,fESD->GetMagneticField()); | |
348 | tITSout->Propagate(alpha,0.,fESD->GetMagneticField()); | |
349 | d0[0] = tITSin->GetY(); | |
350 | z0[0] = tITSin->GetZ(); | |
351 | d0[1] = tITSout->GetY(); | |
352 | z0[1] = tITSout->GetZ(); | |
353 | Float_t dxyITS = -(d0[0]-d0[1]); | |
354 | Float_t dzITS = z0[0]-z0[1]; | |
355 | fntPairs->Fill(tITSin->GetNcls(0),tITSout->GetNcls(0),tTPCin->GetNcls(0),tTPCout->GetNcls(0),dxyITS,dzITS,dxyTPC,dzTPC,tITSin->Pt(),tITSout->Pt(),tTPCin->Pt(),tTPCout->Pt(),tTPCin->GetSigmaY2(),tTPCout->GetSigmaY2()); | |
356 | } | |
357 | } | |
358 | ||
359 | PostData(0,fList); | |
360 | ||
361 | return; | |
362 | } | |
363 | ||
364 | //________________________________________________________________________ | |
365 | void AliTrackMatchingTPCITSCosmics::Terminate(Option_t */*option*/) | |
366 | { | |
367 | // Terminate analysis | |
368 | // | |
369 | AliDebug(2,"AliTrackMatchingTPCITSCosmics: Terminate() \n"); | |
370 | ||
371 | fList = dynamic_cast<TList*> (GetOutputData(0)); | |
372 | if (!fList) { | |
373 | printf("ERROR: fList not available\n"); | |
374 | return; | |
375 | } | |
376 | ||
377 | return; | |
378 | } | |
379 |