]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/muondep/AliCheckMuonDetEltResponse.cxx
correcting minor compilation warnings
[u/mrichter/AliRoot.git] / PWG3 / muondep / AliCheckMuonDetEltResponse.cxx
CommitLineData
128a8042 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//Class to check the response of the detection elements of the MUON tracking chambers
17//in function of the position in the detection element.
18//Author: Nicolas LE BRIS - SUBATECH Nantes
19
20//PWG3/muon:
21#include "AliAnalysisTaskMuonTrackingEff.h"
22#include "AliCheckMuonDetEltResponse.h"
23
24//include STEER:
25#include "AliLog.h"
26#include "AliESDEvent.h"
27#include "AliTracker.h"
28#include "AliESDMuonTrack.h"
29
30//include MUON:
31#include "AliMUONTrack.h"
32#include "AliMUONTrackParam.h"
33#include "AliMUONTrackExtrap.h"
34#include "AliMUONVCluster.h"
35#include "AliMUONConstants.h"
36#include "AliMUONGeometryTransformer.h"
37#include "AliMUONESDInterface.h"
38
39//include MUON/mapping:
40#include "mapping/AliMpDEManager.h"
41
42//include ROOT:
43#include <Riostream.h>
44#include <TMath.h>
45#include <TROOT.h>
46#include <TSystem.h>
47#include <TH2F.h>
48#include <TClonesArray.h>
49#include <TPaveLabel.h>
50#include <TList.h>
51
52/// \cond CLASSIMP
53ClassImp(AliCheckMuonDetEltResponse)
54/// \endcond
55
56const Int_t AliCheckMuonDetEltResponse::fNbrOfChamber = 10;
57const Int_t AliCheckMuonDetEltResponse::fNbrOfStation = 5;
58const Int_t AliCheckMuonDetEltResponse::fNbrOfDetectionElt[10] = {4, 4, 4, 4, 18, 18, 26, 26, 26, 26};
59const Int_t AliCheckMuonDetEltResponse::fFirstDetectionElt[10] = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
60const Int_t AliCheckMuonDetEltResponse::fOffset = 100;
61const Int_t AliCheckMuonDetEltResponse::fOverlapSize = 15;
62const Int_t AliCheckMuonDetEltResponse::fYSlatSize = 40;
63
64//_____________________________________________________________________________
65AliCheckMuonDetEltResponse::AliCheckMuonDetEltResponse()
66
67: TObject(),
68 fTransformer(0x0),
69 fESD(0),
70 fTracksTotalNbr(0x0),
71 fTrackParams(0x0),
72 fTrackParam(0x0),
73 fCluster(0x0),
74 fDetEltTDHistList(0x0),
75 fDetEltTTHistList(0x0)
76{
77/// Default constructor
78
79 fNCh = AliCheckMuonDetEltResponse::fNbrOfChamber;
80 fNSt = AliCheckMuonDetEltResponse::fNbrOfStation;
81 fNDE = AliAnalysisTaskMuonTrackingEff::fTotNbrOfDetectionElt;
82
83 for (Int_t iCluster = 0; iCluster<fNCh; ++iCluster)
84 {
85 fNbrClustersCh[iCluster] = 0;
86 }
87
88 for (Int_t i=0; i<2; ++i)
89 {
90 fGetDetElt[i] = 0;
91 }
92 for (Int_t i=0; i<fNCh; ++i)
93 {
94 fTrackFilter[i] = 0;
95 }
96}
97
98
99
100//_____________________________________________________________________________
101AliCheckMuonDetEltResponse::AliCheckMuonDetEltResponse(const AliMUONGeometryTransformer* transformer,
102 AliESDEvent* esd,
103 TClonesArray* detEltTDHistList,
104 TClonesArray* detEltTTHistList)
105: TObject(),
106 fTransformer(transformer),
107 fESD(esd),
108 fTracksTotalNbr(0),
109 fTrackParams(0x0),
110 fTrackParam(0),
111 fCluster(0),
112 fDetEltTDHistList(detEltTDHistList),
113 fDetEltTTHistList(detEltTTHistList)
114
115{
116/// Constructor
117
118 fNCh = AliCheckMuonDetEltResponse::fNbrOfChamber;
119 fNSt = AliCheckMuonDetEltResponse::fNbrOfStation;
120 fNDE = AliAnalysisTaskMuonTrackingEff::fTotNbrOfDetectionElt;
121
122 for (Int_t iCluster = 0; iCluster<fNCh; ++iCluster)
123 {
124 fNbrClustersCh[iCluster] = 0;
125 }
126
127 for (Int_t i = 0; i <2 ; ++i)
128 {
129 fGetDetElt[i] = 0;
130 }
131 for (Int_t i=0; i<fNCh; ++i)
132 {
133 fTrackFilter[i] = 0;
134 }
135}
136
137
138//_____________________________________________________________________________
139AliCheckMuonDetEltResponse::~AliCheckMuonDetEltResponse()
140
141{
142/// Destructor
143 delete fTrackParams;
144}
145
146
147
148//_____________________________________________________________________________
149void AliCheckMuonDetEltResponse::CheckDetEltResponse()
150{
151//
152//Cataloging positions (X,Y) of the clusters detected in the detection elements
153//(fDetEltTDHistList), and positions of crossing points between all the
154//tracks and the detection elements (fDetEltTTHistList).
155//Efficiency = 100 * fDetEltTDHistList / fDetEltTTHistList.
156
157//Loop on tracks
158//--------------
159 TrackLoop();
160}
161
162
163
164//_____________________________________________________________________________
165void AliCheckMuonDetEltResponse::TrackLoop()
166{
167 AliESDMuonTrack* esdTrack;
168 AliMUONTrack track;
169 Int_t nTracks, iTrack;
170
171 nTracks = (Int_t)fESD -> GetNumberOfMuonTracks();
172 fTrackParams = new TClonesArray();
173 ///Begininig of the loop:
174 for (iTrack = 0; iTrack < nTracks; iTrack++)
175 {
176 esdTrack = fESD -> GetMuonTrack(iTrack);
177
178 if( esdTrack->ContainTrackerData() )
179 {
180 AliMUONESDInterface::ESDToMUON(*esdTrack, track);
181 fTrackParams = track.GetTrackParamAtCluster();
182 TrackParamLoop(); //!<Loop on trackParam.
183 }
184 }
185}
186
187
188
189//_____________________________________________________________________________
190void AliCheckMuonDetEltResponse::TrackParamLoop()
191{
192 Int_t nTrackParams = (Int_t) fTrackParams->GetEntriesFast(); //!<Number of trackParams in the track.
193 Int_t iTrackParam = 0; //!<Number of the trackParam of the track.
194 Int_t oldChamber = -1, newChamber = 0; //!<To check if there is 0, 1 or 2 (overlap cases) clusters in the same chamber for a track.
195 Int_t detElt; //!<Detection element Id.
196
197 for (Int_t ch = 0; ch < fNCh; ++ch)
198 {
199 fTrackFilter[ch] = 0;
200 }
201
202 Double_t posXL, posYL, posZL; //!<Local positions.
203 Double_t posXG, posYG, posZG; //!<Global. positions.
204 Int_t chamberResponse [10] = {0}; //!<1 if the chamber has responded; 0 if not
205
206 for (iTrackParam = 0; iTrackParam < nTrackParams; ++iTrackParam)
207 {
208 fTrackParam = (AliMUONTrackParam*) fTrackParams->At(iTrackParam);
209 fCluster = (AliMUONVCluster* ) fTrackParam ->GetClusterPtr();
210 fTrackFilter [fCluster->GetChamberId()] = 1;
211 chamberResponse[fCluster->GetChamberId()] = 1;
212 }
213
214 for (Int_t station = 0; station < fNSt-1; ++station)
215 {
216 Int_t filter; //<!
217 Int_t ch1, ch2, ch3, ch4; //<!
218 ch1 = 2*station; //<!
219 ch2 = 2*station + 1; //<!
220 ch3 = 2*station + 2; //<!
221 ch4 = 2*station + 3; //<!
222 //<!For the efficiency calculation the tracks
223 if (station < 3 ) //<!reconstructed must have responded to the
224 { //<!criteria of the tracking.
225 filter = fTrackFilter[ch1]; //<!And that's why the tracks usable for the
226 fTrackFilter[ch1] = fTrackFilter[ch2]; //<!intrinsic efficiency calculation are
227 fTrackFilter[ch2] = filter; //<!the tracks which have one or two clusters
228 } //<!in each station. So the case where a track
229 //<!hasn't a cluster in a station is not
230 else //<!taking into account.
231 { //<!This part solves the problem. See the ALICE
232 if (chamberResponse[ch3]*chamberResponse[ch4] != 0) //<!note of Diego STOCCO on the trigger efficiency
233 { //<!
234 filter = fTrackFilter[ch1]; //<!
235 fTrackFilter[ch1] = fTrackFilter[ch2]; //<!
236 fTrackFilter[ch2] = filter; //<!
237 } //<!
238 else //<!
239 { //<!
240 fTrackFilter[ch1] = 0; //<!
241 fTrackFilter[ch2] = 0; //<!
242 } //<!
243 //<!
244 if (chamberResponse[ch1]*chamberResponse[ch2] != 0) //<!
245 { //<!
246 filter = fTrackFilter[ch3]; //<!
247 fTrackFilter[ch3] = fTrackFilter[ch4]; //<!
248 fTrackFilter[ch4] = filter; //<!
249 } //<!
250 else //<!
251 { //<!
252 fTrackFilter[ch3] = 0; //<!
253 fTrackFilter[ch4] = 0; //<!
254 } //<!
255 } //<!
256 } //<!
257
258 for (Int_t ch = 0; ch < fNCh; ++ch)
259 {
260 if (fTrackFilter[ch] == 1)
261 {
262 if ( chamberResponse[ch] != 0) ((TH2F*) fDetEltTDHistList->UncheckedAt(fNDE))->Fill(ch, 0);
263 ((TH2F*) fDetEltTTHistList->UncheckedAt(fNDE))->Fill(ch, 0);
264 }
265 }
266
267 ///Begining of the loop:
268 for (iTrackParam = 0; iTrackParam < nTrackParams; ++iTrackParam)
269 {
270 fTrackParam = (AliMUONTrackParam*) fTrackParams->At(iTrackParam);
271 fCluster = (AliMUONVCluster* ) fTrackParam ->GetClusterPtr();
272
273 newChamber = fCluster->GetChamberId();
274 detElt = fCluster->GetDetElemId();
275
276 ///Global and local positions calculation:
277 posXG = fTrackParam->GetNonBendingCoor();
278 posYG = fTrackParam->GetBendingCoor();
279 posZG = fTrackParam->GetZ();
280
281 fTransformer->Global2Local(detElt, posXG, posYG, posZG, posXL, posYL, posZL); //!<Transfomation from global to local positions.
282
283 ///Filling histograms of the cluster positions on the detection element of the TRACKS DETECTED (TD):
284 FillDetEltTDHisto(newChamber, detElt, posXL, posYL);
285
286 ///Filling histograms of the cluster positions on the detection element of ALL THE TRACKS (TT):
287 FillDetEltTTHisto(newChamber, detElt, posXG, posYG, posZG, posXL, posYL, posZL);
288
289 if (newChamber != oldChamber)
290 {
291 if (newChamber > oldChamber + 1) //!<Check if it doesn't miss a chamber.
292 {
293 Int_t nbrOfMissCh = newChamber - (oldChamber+1); //!<Number of missing chambers.
294 CalculMissClusterParam(fTrackParam, oldChamber+1, nbrOfMissCh); //!<Calculation of the parameters of the missing cluster(s).
295 }
296 if ( iTrackParam == nTrackParams - 1 & newChamber != fNCh-1) //!<Check if the last chamber, chamber 9 (from 0 to 9) has responded.
297 {
298 CalculMissClusterParam(fTrackParam, fNCh-1, 1); //!<Calculation of the parameters of the missing cluster(s) in the last chamber.
299 }
300 }
301 oldChamber = newChamber;
302 }
303}
304
305
306
307//_____________________________________________________________________________
308void AliCheckMuonDetEltResponse::FillDetEltTDHisto(Int_t chamber,
309 Int_t detElt,
310 Double_t posXL,
311 Double_t posYL)
312{
313 if(fTrackFilter[chamber]== 1)
314 {
315 Int_t iDet = 0; //!<Position of the detection element in the histograms' list.
316 iDet = FromDetElt2iDet(chamber, detElt);
317 ((TH2F*) fDetEltTDHistList->UncheckedAt(iDet))->Fill(posXL, posYL);
318 }
319}
320
321
322
323//_____________________________________________________________________________
324void AliCheckMuonDetEltResponse::FillDetEltTTHisto(Int_t chamber,
325 Int_t detElt,
326 Double_t posXG,
327 Double_t posYG,
328 Double_t posZG,
329 Double_t posXL,
330 Double_t posYL,
331 Double_t posZL)
332{
333 if(fTrackFilter[chamber] == 1)
334 {
335 Int_t iDet = 0; //!<Position of the detection element in the histograms' list.
336 iDet = FromDetElt2iDet(chamber, detElt);
337 ((TH2F*) fDetEltTTHistList->UncheckedAt(iDet)) -> Fill(posXL, posYL);
338
20e837dc 339 if(TMath::Abs(posYL) > fOverlapSize) //!<It is an overlap area. It can have two clusters for this track in this chamber.
128a8042 340 {
341 GetDetEltFromPosition(chamber, posXG, posYG, posZG);
342 if(fGetDetElt[1] != 0) //<!There is a second detection element for the same (X,Y) in this chamber (overlap).
343 {
344 if(fGetDetElt[1] != detElt)
345 {
346 fTransformer->Global2Local(fGetDetElt[1], posXG, posYG, posZG, posXL, posYL, posZL); //!<Transfomation from global to local positions.
347 iDet = FromDetElt2iDet(chamber, fGetDetElt[1]);
348 ((TH2F*) fDetEltTTHistList->UncheckedAt(iDet)) -> Fill(posXL, posYL);
349 }
350 else
351 {
352 fTransformer->Global2Local(fGetDetElt[0], posXG, posYG, posZG, posXL, posYL, posZL); //!<Transfomation from global to local positions.
353 iDet = FromDetElt2iDet(chamber, fGetDetElt[0]);
354 ((TH2F*) fDetEltTTHistList->UncheckedAt(iDet)) -> Fill(posXL, posYL);
355 }
356 }
357 }
358 }
359}
360
361
362
363//_____________________________________________________________________________
364void AliCheckMuonDetEltResponse::CalculMissClusterParam(AliMUONTrackParam* extrapTrackParam,
365 Int_t firstMissCh,
366 Int_t nbrOfMissCh)
367{
368//Calculation of the cluster parameter which was not detect by
369//the chamber.
370
371 for (Int_t iCh = 0; iCh<nbrOfMissCh; ++iCh)
372 {
373 Double_t exTraXL, exTraYL, exTraZL; //!<Extrapolated local positions.
374 Double_t exTraXG, exTraYG, exTraZG; //!<Extrapolated global positions.
375 Int_t missChamber= firstMissCh + iCh; //!<The missing chamber.
376 Int_t missDetElt = 0;
377
378 exTraZG = AliMUONConstants::DefaultChamberZ(missChamber);
379 AliMUONTrackExtrap::ExtrapToZ(extrapTrackParam, exTraZG); //!<Extrapolation to the missing chamber.
380 exTraXG = extrapTrackParam->GetNonBendingCoor(); //!<Global X position extrapolated to the missing chamber.
381 exTraYG = extrapTrackParam->GetBendingCoor(); //!<Global Y position extrapolated to the missing chamber.
382
383 GetDetEltFromPosition(missChamber, exTraXG, exTraYG, exTraZG); //!<Gives the detection element (fGetDetElt) with the position.
384 missDetElt = fGetDetElt[0];
385
386 if( missDetElt != 0 ) //!<Check if the track has passed trough a detection area
387 {
388 fTransformer->Global2Local(missDetElt, exTraXG, exTraYG, exTraZG, exTraXL, exTraYL, exTraZL); //!<Transfomation from global to local positions.
389 FillDetEltTTHisto(missChamber, missDetElt, exTraXG, exTraYG, exTraZG, exTraXL, exTraYL, exTraZL);
390 }
391 }
392}
393
394
395
396//_____________________________________________________________________________
397Int_t AliCheckMuonDetEltResponse::FromDetElt2iDet(Int_t chamber,
398 Int_t detElt)
399{
400///
401///Connexion between the detection element X and its position in the list of histograms iX.
402///
403
404 Int_t iDet = 0; //!<Position of the detection element (detElt) in the histograms' list.
405
406 if (chamber<4) iDet = detElt-fOffset*(chamber+1)+ 4* chamber ;
407 if (chamber>3 & chamber<6) iDet = detElt-fOffset*(chamber+1)+18*(chamber-4)+16;
408 if (chamber>5) iDet = detElt-fOffset*(chamber+1)+26*(chamber-6)+52;
409
410 return iDet;
411}
412
413
414
415//_____________________________________________________________________________
416void AliCheckMuonDetEltResponse::GetDetEltFromPosition(Int_t chamber,
417 Double_t posX,
418 Double_t posY,
419 Double_t posZ)
420{
421///
422///Gives the detetection element fGetDetElt[0] corresponding to the position. In the case
423///of an overlap (two detection element with the same (X,Y)) fGetDetElt[1] is calculated.
424///
425
426 Int_t nbrOfDetElt = AliMpDEManager::GetNofDEInChamber(chamber, kTRUE); //!<Number of detection elements in the chamber.
427 Int_t detElt = 0, lastDetElt = 0;
428
429 Double_t posXL, posYL, posZL; //!<Local positions.
430 posXL = posYL = posZL = 1000.;
431 fGetDetElt[0] = fGetDetElt[1] = 0;
432
433 if(chamber>3)
434 {
435 Int_t shift = 0; //!<|
436 if(posX<0) shift = nbrOfDetElt /4 + 1; //!<|Method to avoid the loop on all elements of
437 if(posX>0) shift = (3*nbrOfDetElt)/4 + 1; //!<|detection, and just loop through fourth chamber.
438 //!<|
439 detElt = fOffset*(chamber+1) + shift; //!<|
440 lastDetElt = fOffset*(chamber+1) +(shift+nbrOfDetElt/2)%nbrOfDetElt; //!<|
441
442 Int_t nbr = 0;
443 while(detElt != lastDetElt) //!<Loop on fourth chamber.
444 {
445
446 fTransformer->Global2Local(detElt, posX, posY, posZ, posXL, posYL, posZL); //!<Transfomation from global to local positions.
447
20e837dc 448 if(TMath::Abs(posYL)< fYSlatSize) //!<If |posYL|<20 => the cluster is in the detection element (-20<Ylocal<20 for each slat).
128a8042 449 {
450 fGetDetElt[nbr] = detElt;
451 ++nbr;
452 }
453 shift = (shift + 1)%nbrOfDetElt;
454 detElt = fOffset*(chamber+1) + shift;
455 }
456 }
457
458 else //!<For the station 1 & 2 (4 detection elements in each chamber).
459 {
460 if(posX>0 & posY>0) fGetDetElt[0] = fOffset*(chamber+1) ;
461 if(posX<0 & posY>0) fGetDetElt[0] = fOffset*(chamber+1) + 1;
462 if(posX<0 & posY<0) fGetDetElt[0] = fOffset*(chamber+1) + 2;
463 if(posX>0 & posY<0) fGetDetElt[0] = fOffset*(chamber+1) + 3;
464 }
465}