1 /**************************************************************************
2 * Copyright(c) 2007-2009, 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 **************************************************************************/
18 //_________________________________________________________________________
20 // Implementation of the ITS-SPD trackleter class
22 // It retrieves clusters in the pixels (theta and phi) and finds tracklets.
23 // These can be used to extract charged particle multiplicity from the ITS.
25 // A tracklet consists of two ITS clusters, one in the first pixel layer and
26 // one in the second. The clusters are associated if the differences in
27 // Phi (azimuth) and Theta (polar angle) are within fiducial windows.
28 // In case of multiple candidates the candidate with minimum
29 // distance is selected.
31 // Two methods return the number of tracklets and the number of unassociated
32 // clusters (i.e. not used in any tracklet) in the first SPD layer
33 // (GetNTracklets and GetNSingleClusters)
35 // The cuts on phi and theta depend on the interacting system (p-p or Pb-Pb)
36 // and can be set via AliITSRecoParam class
37 // (SetPhiWindow and SetThetaWindow)
39 // Origin: Tiziano Virgili
41 // Current support and development:
42 // Domenico Elia, Maria Nicassio (INFN Bari)
43 // Domenico.Elia@ba.infn.it, Maria.Nicassio@ba.infn.it
45 // Most recent updates:
46 // - multiple association forbidden (fOnlyOneTrackletPerC2 = kTRUE)
47 // - phi definition changed to ALICE convention (0,2*TMath::pi())
48 // - cluster coordinates taken with GetGlobalXYZ()
49 // - fGeometry removed
50 // - number of fired chips on the two layers
51 // - option to cut duplicates in the overlaps
52 // - options and fiducial cuts via AliITSRecoParam
53 // - move from DeltaZeta to DeltaTheta cut
54 // - update to the new algorithm by Mariella and Jan Fiete
55 // - store also DeltaTheta in the ESD
56 // - less new and delete calls when creating the needed arrays
57 //_________________________________________________________________________
59 #include <TClonesArray.h>
65 #include "AliITSMultReconstructor.h"
66 #include "AliITSReconstructor.h"
67 #include "AliITSsegmentationSPD.h"
68 #include "AliITSRecPoint.h"
69 #include "AliITSgeom.h"
71 #include "TGeoGlobalMagField.h"
74 //____________________________________________________________________
75 ClassImp(AliITSMultReconstructor)
78 //____________________________________________________________________
79 AliITSMultReconstructor::AliITSMultReconstructor():
83 fDetectorIndexClustersLay1(0),
84 fDetectorIndexClustersLay2(0),
85 fOverlapFlagClustersLay1(0),
86 fOverlapFlagClustersLay2(0),
96 fRemoveClustersFromOverlaps(0),
100 fhClustersDPhiAcc(0),
101 fhClustersDThetaAcc(0),
102 fhClustersDPhiAll(0),
103 fhClustersDThetaAll(0),
104 fhDPhiVsDThetaAll(0),
105 fhDPhiVsDThetaAcc(0),
108 fhetaClustersLay1(0),
109 fhphiClustersLay1(0){
114 // Method to reconstruct the charged particles multiplicity with the
120 if(AliITSReconstructor::GetRecoParam()) {
121 SetPhiWindow(AliITSReconstructor::GetRecoParam()->GetTrackleterPhiWindow());
122 SetThetaWindow(AliITSReconstructor::GetRecoParam()->GetTrackleterThetaWindow());
123 SetPhiShift(AliITSReconstructor::GetRecoParam()->GetTrackleterPhiShift());
124 SetRemoveClustersFromOverlaps(AliITSReconstructor::GetRecoParam()->GetTrackleterRemoveClustersFromOverlaps());
125 SetPhiOverlapCut(AliITSReconstructor::GetRecoParam()->GetTrackleterPhiOverlapCut());
126 SetZetaOverlapCut(AliITSReconstructor::GetRecoParam()->GetTrackleterZetaOverlapCut());
131 SetRemoveClustersFromOverlaps();
139 fDetectorIndexClustersLay1 = 0;
140 fDetectorIndexClustersLay2 = 0;
141 fOverlapFlagClustersLay1 = 0;
142 fOverlapFlagClustersLay2 = 0;
146 // definition of histograms
147 Bool_t oldStatus = TH1::AddDirectoryStatus();
148 TH1::AddDirectory(kFALSE);
150 fhClustersDPhiAcc = new TH1F("dphiacc", "dphi", 100,-0.1,0.1);
151 fhClustersDThetaAcc = new TH1F("dthetaacc","dtheta",100,-0.1,0.1);
153 fhDPhiVsDThetaAcc = new TH2F("dphiVsDthetaAcc","",100,-0.1,0.1,100,-0.1,0.1);
155 fhClustersDPhiAll = new TH1F("dphiall", "dphi", 100,0.0,0.5);
156 fhClustersDThetaAll = new TH1F("dthetaall","dtheta",100,0.0,0.5);
158 fhDPhiVsDThetaAll = new TH2F("dphiVsDthetaAll","",100,0.,0.5,100,0.,0.5);
160 fhetaTracklets = new TH1F("etaTracklets", "eta", 100,-2.,2.);
161 fhphiTracklets = new TH1F("phiTracklets", "phi", 100, 0., 2*TMath::Pi());
162 fhetaClustersLay1 = new TH1F("etaClustersLay1", "etaCl1", 100,-2.,2.);
163 fhphiClustersLay1 = new TH1F("phiClustersLay1", "phiCl1", 100, 0., 2*TMath::Pi());
165 TH1::AddDirectory(oldStatus);
168 //______________________________________________________________________
169 AliITSMultReconstructor::AliITSMultReconstructor(const AliITSMultReconstructor &mr) : TObject(mr),
170 fClustersLay1(mr.fClustersLay1),
171 fClustersLay2(mr.fClustersLay2),
172 fDetectorIndexClustersLay1(mr.fDetectorIndexClustersLay1),
173 fDetectorIndexClustersLay2(mr.fDetectorIndexClustersLay2),
174 fOverlapFlagClustersLay1(mr.fOverlapFlagClustersLay1),
175 fOverlapFlagClustersLay2(mr.fOverlapFlagClustersLay2),
176 fTracklets(mr.fTracklets),
177 fSClusters(mr.fSClusters),
178 fNClustersLay1(mr.fNClustersLay1),
179 fNClustersLay2(mr.fNClustersLay2),
180 fNTracklets(mr.fNTracklets),
181 fNSingleCluster(mr.fNSingleCluster),
182 fPhiWindow(mr.fPhiWindow),
183 fThetaWindow(mr.fThetaWindow),
184 fPhiShift(mr.fPhiShift),
185 fRemoveClustersFromOverlaps(mr.fRemoveClustersFromOverlaps),
186 fPhiOverlapCut(mr.fPhiOverlapCut),
187 fZetaOverlapCut(mr.fZetaOverlapCut),
189 fhClustersDPhiAcc(mr.fhClustersDPhiAcc),
190 fhClustersDThetaAcc(mr.fhClustersDThetaAcc),
191 fhClustersDPhiAll(mr.fhClustersDPhiAll),
192 fhClustersDThetaAll(mr.fhClustersDThetaAll),
193 fhDPhiVsDThetaAll(mr.fhDPhiVsDThetaAll),
194 fhDPhiVsDThetaAcc(mr.fhDPhiVsDThetaAcc),
195 fhetaTracklets(mr.fhetaTracklets),
196 fhphiTracklets(mr.fhphiTracklets),
197 fhetaClustersLay1(mr.fhetaClustersLay1),
198 fhphiClustersLay1(mr.fhphiClustersLay1) {
203 //______________________________________________________________________
204 AliITSMultReconstructor& AliITSMultReconstructor::operator=(const AliITSMultReconstructor& mr){
205 // Assignment operator
206 this->~AliITSMultReconstructor();
207 new(this) AliITSMultReconstructor(mr);
211 //______________________________________________________________________
212 AliITSMultReconstructor::~AliITSMultReconstructor(){
216 delete fhClustersDPhiAcc;
217 delete fhClustersDThetaAcc;
218 delete fhClustersDPhiAll;
219 delete fhClustersDThetaAll;
220 delete fhDPhiVsDThetaAll;
221 delete fhDPhiVsDThetaAcc;
222 delete fhetaTracklets;
223 delete fhphiTracklets;
224 delete fhetaClustersLay1;
225 delete fhphiClustersLay1;
228 for(Int_t i=0; i<fNClustersLay1; i++)
229 delete [] fClustersLay1[i];
231 for(Int_t i=0; i<fNClustersLay2; i++)
232 delete [] fClustersLay2[i];
234 for(Int_t i=0; i<fNTracklets; i++)
235 delete [] fTracklets[i];
237 for(Int_t i=0; i<fNSingleCluster; i++)
238 delete [] fSClusters[i];
240 delete [] fClustersLay1;
241 delete [] fClustersLay2;
242 delete [] fDetectorIndexClustersLay1;
243 delete [] fDetectorIndexClustersLay2;
244 delete [] fOverlapFlagClustersLay1;
245 delete [] fOverlapFlagClustersLay2;
246 delete [] fTracklets;
247 delete [] fSClusters;
250 //____________________________________________________________________
251 void AliITSMultReconstructor::Reconstruct(TTree* clusterTree, Float_t* vtx, Float_t* /* vtxRes*/) {
253 // - calls LoadClusterArray that finds the position of the clusters
255 // - convert the cluster coordinates to theta, phi (seen from the
256 // interaction vertex).
257 // - makes an array of tracklets
259 // After this method has been called, the clusters of the two layers
260 // and the tracklets can be retrieved by calling the Get'er methods.
268 // loading the clusters
269 LoadClusterArrays(clusterTree);
271 const Double_t pi = TMath::Pi();
273 // dPhi shift is field dependent
274 // get average magnetic field
277 if (TGeoGlobalMagField::Instance())
278 field = dynamic_cast<AliMagF*>(TGeoGlobalMagField::Instance()->GetField());
281 AliError("Could not retrieve magnetic field. Assuming no field. Delta Phi shift will be deactivated in AliITSMultReconstructor.")
284 bz = TMath::Abs(field->SolenoidField());
286 const Double_t dPhiShift = fPhiShift / 5 * bz;
287 AliDebug(1, Form("Using phi shift of %f", dPhiShift));
289 const Double_t dPhiWindow2 = fPhiWindow * fPhiWindow;
290 const Double_t dThetaWindow2 = fThetaWindow * fThetaWindow;
292 Int_t* partners = new Int_t[fNClustersLay2];
293 Float_t* minDists = new Float_t[fNClustersLay2];
294 Int_t* associatedLay1 = new Int_t[fNClustersLay1];
295 TArrayI** blacklist = new TArrayI*[fNClustersLay1];
297 for (Int_t i=0; i<fNClustersLay2; i++) {
301 for (Int_t i=0; i<fNClustersLay1; i++)
302 associatedLay1[i] = 0;
303 for (Int_t i=0; i<fNClustersLay1; i++)
306 // find the tracklets
307 AliDebug(1,"Looking for tracklets... ");
309 //###########################################################
310 // Loop on layer 1 : finding theta, phi and z
311 for (Int_t iC1=0; iC1<fNClustersLay1; iC1++) {
312 Float_t x = fClustersLay1[iC1][0] - vtx[0];
313 Float_t y = fClustersLay1[iC1][1] - vtx[1];
314 Float_t z = fClustersLay1[iC1][2] - vtx[2];
316 Float_t r = TMath::Sqrt(x*x + y*y + z*z);
318 fClustersLay1[iC1][0] = TMath::ACos(z/r); // Store Theta
319 fClustersLay1[iC1][1] = TMath::Pi() + TMath::ATan2(-y,-x); // Store Phi
322 Float_t eta=fClustersLay1[iC1][0];
323 eta= TMath::Tan(eta/2.);
324 eta=-TMath::Log(eta);
325 fhetaClustersLay1->Fill(eta);
326 fhphiClustersLay1->Fill(fClustersLay1[iC1][1]);
330 // Loop on layer 2 : finding theta, phi and r
331 for (Int_t iC2=0; iC2<fNClustersLay2; iC2++) {
332 Float_t x = fClustersLay2[iC2][0] - vtx[0];
333 Float_t y = fClustersLay2[iC2][1] - vtx[1];
334 Float_t z = fClustersLay2[iC2][2] - vtx[2];
336 Float_t r = TMath::Sqrt(x*x + y*y + z*z);
338 fClustersLay2[iC2][0] = TMath::ACos(z/r); // Store Theta
339 fClustersLay2[iC2][1] = TMath::Pi() + TMath::ATan2(-y,-x); // Store Phi
342 //###########################################################
347 // Step1: find all tracklets allowing double assocation
349 for (Int_t iC1=0; iC1<fNClustersLay1; iC1++) {
351 // already used or in the overlap ?
352 if (associatedLay1[iC1] != 0 || fOverlapFlagClustersLay1[iC1]) continue;
356 // reset of variables for multiple candidates
357 Int_t iC2WithBestDist = -1; // reset
358 Double_t minDist = 2; // reset
361 for (Int_t iC2=0; iC2<fNClustersLay2; iC2++) {
364 if (fOverlapFlagClustersLay2[iC2]) continue;
366 if (blacklist[iC1]) {
367 Bool_t blacklisted = kFALSE;
368 for (Int_t i=0; i<blacklist[iC1]->GetSize(); i++) {
369 if (blacklist[iC1]->At(i) == iC2) {
374 if (blacklisted) continue;
377 // find the difference in angles
378 Double_t dTheta = TMath::Abs(fClustersLay2[iC2][0] - fClustersLay1[iC1][0]);
379 Double_t dPhi = TMath::Abs(fClustersLay2[iC2][1] - fClustersLay1[iC1][1]);
380 // take into account boundary condition
381 if (dPhi>pi) dPhi=2.*pi-dPhi;
384 fhClustersDPhiAll->Fill(dPhi);
385 fhClustersDThetaAll->Fill(dTheta);
386 fhDPhiVsDThetaAll->Fill(dTheta, dPhi);
391 // make "elliptical" cut in Phi and Theta!
392 Float_t d = dPhi*dPhi/dPhiWindow2 + dTheta*dTheta/dThetaWindow2;
394 // look for the minimum distance: the minimum is in iC2WithBestDist
395 if (d<1 && d<minDist) {
397 iC2WithBestDist = iC2;
399 } // end of loop over clusters in layer 2
401 if (minDist<1) { // This means that a cluster in layer 2 was found that matches with iC1
403 if (minDists[iC2WithBestDist] > minDist) {
404 Int_t oldPartner = partners[iC2WithBestDist];
405 partners[iC2WithBestDist] = iC1;
406 minDists[iC2WithBestDist] = minDist;
409 associatedLay1[iC1] = 1;
411 if (oldPartner != -1) {
412 // redo partner search for cluster in L0 (oldPartner), putting this one (iC2WithBestDist) on its blacklist
413 if (blacklist[oldPartner] == 0) {
414 blacklist[oldPartner] = new TArrayI(1);
415 } else blacklist[oldPartner]->Set(blacklist[oldPartner]->GetSize()+1);
417 blacklist[oldPartner]->AddAt(iC2WithBestDist, blacklist[oldPartner]->GetSize()-1);
420 associatedLay1[oldPartner] = 0;
423 // try again to find a cluster without considering iC2WithBestDist
424 if (blacklist[iC1] == 0) {
425 blacklist[iC1] = new TArrayI(1);
428 blacklist[iC1]->Set(blacklist[iC1]->GetSize()+1);
430 blacklist[iC1]->AddAt(iC2WithBestDist, blacklist[iC1]->GetSize()-1);
433 } else // cluster has no partner; remove
434 associatedLay1[iC1] = 2;
435 } // end of loop over clusters in layer 1
438 // Step2: store tracklets; remove used clusters
439 for (Int_t iC2=0; iC2<fNClustersLay2; iC2++) {
441 if (partners[iC2] == -1) continue;
443 if (fOverlapFlagClustersLay1[partners[iC2]] || fOverlapFlagClustersLay2[iC2]) continue;
444 if (fRemoveClustersFromOverlaps) FlagClustersInOverlapRegions (partners[iC2],iC2);
446 fTracklets[fNTracklets] = new Float_t[6];
448 // use the theta from the clusters in the first layer
449 fTracklets[fNTracklets][0] = fClustersLay1[partners[iC2]][0];
450 // use the phi from the clusters in the first layer
451 fTracklets[fNTracklets][1] = fClustersLay1[partners[iC2]][1];
452 // store the difference between phi1 and phi2
453 fTracklets[fNTracklets][2] = fClustersLay1[partners[iC2]][1] - fClustersLay2[iC2][1];
455 // define dphi in the range [0,pi] with proper sign (track charge correlated)
456 if (fTracklets[fNTracklets][2] > TMath::Pi())
457 fTracklets[fNTracklets][2] = fTracklets[fNTracklets][2]-2.*TMath::Pi();
458 if (fTracklets[fNTracklets][2] < -TMath::Pi())
459 fTracklets[fNTracklets][2] = fTracklets[fNTracklets][2]+2.*TMath::Pi();
461 // store the difference between theta1 and theta2
462 fTracklets[fNTracklets][3] = fClustersLay1[partners[iC2]][0] - fClustersLay2[iC2][0];
465 fhClustersDPhiAcc->Fill(fTracklets[fNTracklets][2]);
466 fhClustersDThetaAcc->Fill(fTracklets[fNTracklets][3]);
467 fhDPhiVsDThetaAcc->Fill(fTracklets[fNTracklets][3],fTracklets[fNTracklets][2]);
471 // if equal label in both clusters found this label is assigned
472 // if no equal label can be found the first labels of the L1 AND L2 cluster are assigned
476 if ((Int_t) fClustersLay1[partners[iC2]][3+label1] != -2 && (Int_t) fClustersLay1[partners[iC2]][3+label1] == (Int_t) fClustersLay2[iC2][3+label2])
485 AliDebug(AliLog::kDebug, Form("Found label %d == %d for tracklet candidate %d\n", (Int_t) fClustersLay1[partners[iC2]][3+label1], (Int_t) fClustersLay2[iC2][3+label2], fNTracklets));
486 fTracklets[fNTracklets][4] = fClustersLay1[partners[iC2]][3+label1];
487 fTracklets[fNTracklets][5] = fClustersLay2[iC2][3+label2];
489 AliDebug(AliLog::kDebug, Form("Did not find label %d %d %d %d %d %d for tracklet candidate %d\n", (Int_t) fClustersLay1[partners[iC2]][3], (Int_t) fClustersLay1[partners[iC2]][4], (Int_t) fClustersLay1[partners[iC2]][5], (Int_t) fClustersLay2[iC2][3], (Int_t) fClustersLay2[iC2][4], (Int_t) fClustersLay2[iC2][5], fNTracklets));
490 fTracklets[fNTracklets][4] = fClustersLay1[partners[iC2]][3];
491 fTracklets[fNTracklets][5] = fClustersLay2[iC2][3];
495 Float_t eta=fTracklets[fNTracklets][0];
496 eta= TMath::Tan(eta/2.);
497 eta=-TMath::Log(eta);
498 fhetaTracklets->Fill(eta);
499 fhphiTracklets->Fill(fTracklets[fNTracklets][1]);
502 AliDebug(1,Form(" Adding tracklet candidate %d ", fNTracklets));
503 AliDebug(1,Form(" Cl. %d of Layer 1 and %d of Layer 2", partners[iC2], iC2));
506 associatedLay1[partners[iC2]] = 1;
509 // Delete the following else if you do not want to save Clusters!
511 for (Int_t iC1=0; iC1<fNClustersLay1; iC1++) {
512 if (associatedLay1[iC1]==2||associatedLay1[iC1]==0) {
513 fSClusters[fNSingleCluster] = new Float_t[2];
514 fSClusters[fNSingleCluster][0] = fClustersLay1[iC1][0];
515 fSClusters[fNSingleCluster][1] = fClustersLay1[iC1][1];
516 AliDebug(1,Form(" Adding a single cluster %d (cluster %d of layer 1)",
517 fNSingleCluster, iC1));
525 for (Int_t i=0; i<fNClustersLay1; i++)
530 AliDebug(1,Form("%d tracklets found", fNTracklets));
533 //____________________________________________________________________
535 AliITSMultReconstructor::LoadClusterArrays(TTree* itsClusterTree) {
537 // - gets the clusters from the cluster tree
538 // - convert them into global coordinates
539 // - store them in the internal arrays
540 // - count the number of cluster-fired chips
542 AliDebug(1,"Loading clusters and cluster-fired chips ...");
549 AliITSsegmentationSPD *seg = new AliITSsegmentationSPD();
551 TClonesArray* itsClusters = new TClonesArray("AliITSRecPoint");
552 TBranch* itsClusterBranch=itsClusterTree->GetBranch("ITSRecPoints");
554 itsClusterBranch->SetAddress(&itsClusters);
556 Int_t nItsSubs = (Int_t)itsClusterTree->GetEntries();
557 Float_t cluGlo[3]={0.,0.,0.};
561 // loop over the its subdetectors
562 for (Int_t iIts=0; iIts < nItsSubs; iIts++) {
563 if (!itsClusterTree->GetEvent(iIts))
566 Int_t nClusters = itsClusters->GetEntriesFast();
567 // loop over clusters
569 AliITSRecPoint* cluster = (AliITSRecPoint*)itsClusters->UncheckedAt(nClusters);
571 Int_t layer = cluster->GetLayer();
580 fClustersLay1 = new Float_t*[fNClustersLay1];
581 fDetectorIndexClustersLay1 = new Int_t[fNClustersLay1];
582 fOverlapFlagClustersLay1 = new Bool_t[fNClustersLay1];
584 fClustersLay2 = new Float_t*[fNClustersLay2];
585 fDetectorIndexClustersLay2 = new Int_t[fNClustersLay2];
586 fOverlapFlagClustersLay2 = new Bool_t[fNClustersLay2];
588 // no double association allowed
589 fTracklets = new Float_t*[TMath::Min(fNClustersLay1, fNClustersLay2)];
590 fSClusters = new Float_t*[fNClustersLay1];
592 for (Int_t i=0; i<fNClustersLay1; i++) {
593 fClustersLay1[i] = new Float_t[6];
594 fOverlapFlagClustersLay1[i] = kFALSE;
598 for (Int_t i=0; i<fNClustersLay2; i++) {
599 fClustersLay2[i] = new Float_t[6];
600 fOverlapFlagClustersLay2[i] = kFALSE;
603 for (Int_t i=0; i<TMath::Min(fNClustersLay1, fNClustersLay2); i++)
607 // loop over the its subdetectors
608 fNClustersLay1 = 0; // reset to 0
610 for (Int_t iIts=0; iIts < nItsSubs; iIts++) {
612 if (!itsClusterTree->GetEvent(iIts))
615 Int_t nClusters = itsClusters->GetEntriesFast();
617 // number of clusters in each chip of the current module
618 Int_t nClustersInChip[5] = {0,0,0,0,0};
621 // loop over clusters
623 AliITSRecPoint* cluster = (AliITSRecPoint*)itsClusters->UncheckedAt(nClusters);
625 layer = cluster->GetLayer();
626 if (layer>1) continue;
628 cluster->GetGlobalXYZ(cluGlo);
629 Float_t x = cluGlo[0];
630 Float_t y = cluGlo[1];
631 Float_t z = cluGlo[2];
633 // find the chip for the current cluster
634 Float_t locz = cluster->GetDetLocalZ();
635 Int_t iChip = seg->GetChipFromLocal(0,locz);
636 nClustersInChip[iChip]++;
639 fClustersLay1[fNClustersLay1][0] = x;
640 fClustersLay1[fNClustersLay1][1] = y;
641 fClustersLay1[fNClustersLay1][2] = z;
643 fDetectorIndexClustersLay1[fNClustersLay1]=iIts;
645 for (Int_t i=0; i<3; i++)
646 fClustersLay1[fNClustersLay1][3+i] = cluster->GetLabel(i);
650 fClustersLay2[fNClustersLay2][0] = x;
651 fClustersLay2[fNClustersLay2][1] = y;
652 fClustersLay2[fNClustersLay2][2] = z;
654 fDetectorIndexClustersLay2[fNClustersLay2]=iIts;
656 for (Int_t i=0; i<3; i++)
657 fClustersLay2[fNClustersLay2][3+i] = cluster->GetLabel(i);
661 }// end of cluster loop
663 // get number of fired chips in the current module
665 for(Int_t ifChip=0; ifChip<5; ifChip++) {
666 if(nClustersInChip[ifChip] >= 1) fNFiredChips[layer]++;
669 } // end of its "subdetector" loop
672 itsClusters->Delete();
677 AliDebug(1,Form("(clusters in layer 1 : %d, layer 2: %d)",fNClustersLay1,fNClustersLay2));
678 AliDebug(1,Form("(cluster-fired chips in layer 1 : %d, layer 2: %d)",fNFiredChips[0],fNFiredChips[1]));
680 //____________________________________________________________________
682 AliITSMultReconstructor::LoadClusterFiredChips(TTree* itsClusterTree) {
684 // - gets the clusters from the cluster tree
685 // - counts the number of (cluster)fired chips
687 AliDebug(1,"Loading cluster-fired chips ...");
692 AliITSsegmentationSPD *seg = new AliITSsegmentationSPD();
694 TClonesArray* itsClusters = new TClonesArray("AliITSRecPoint");
695 TBranch* itsClusterBranch=itsClusterTree->GetBranch("ITSRecPoints");
697 itsClusterBranch->SetAddress(&itsClusters);
699 Int_t nItsSubs = (Int_t)itsClusterTree->GetEntries();
701 // loop over the its subdetectors
702 for (Int_t iIts=0; iIts < nItsSubs; iIts++) {
704 if (!itsClusterTree->GetEvent(iIts))
707 Int_t nClusters = itsClusters->GetEntriesFast();
709 // number of clusters in each chip of the current module
710 Int_t nClustersInChip[5] = {0,0,0,0,0};
713 // loop over clusters
715 AliITSRecPoint* cluster = (AliITSRecPoint*)itsClusters->UncheckedAt(nClusters);
717 layer = cluster->GetLayer();
718 if (layer>1) continue;
720 // find the chip for the current cluster
721 Float_t locz = cluster->GetDetLocalZ();
722 Int_t iChip = seg->GetChipFromLocal(0,locz);
723 nClustersInChip[iChip]++;
725 }// end of cluster loop
727 // get number of fired chips in the current module
729 for(Int_t ifChip=0; ifChip<5; ifChip++) {
730 if(nClustersInChip[ifChip] >= 1) fNFiredChips[layer]++;
733 } // end of its "subdetector" loop
736 itsClusters->Delete();
741 AliDebug(1,Form("(cluster-fired chips in layer 1 : %d, layer 2: %d)",fNFiredChips[0],fNFiredChips[1]));
743 //____________________________________________________________________
745 AliITSMultReconstructor::SaveHists() {
746 // This method save the histograms on the output file
747 // (only if fHistOn is TRUE).
752 fhClustersDPhiAll->Write();
753 fhClustersDThetaAll->Write();
754 fhDPhiVsDThetaAll->Write();
756 fhClustersDPhiAcc->Write();
757 fhClustersDThetaAcc->Write();
758 fhDPhiVsDThetaAcc->Write();
760 fhetaTracklets->Write();
761 fhphiTracklets->Write();
762 fhetaClustersLay1->Write();
763 fhphiClustersLay1->Write();
766 //____________________________________________________________________
768 AliITSMultReconstructor::FlagClustersInOverlapRegions (Int_t iC1, Int_t iC2WithBestDist) {
770 Float_t distClSameMod=0.;
771 Float_t distClSameModMin=0.;
773 Float_t meanRadiusLay1 = 3.99335; // average radius inner layer
774 Float_t meanRadiusLay2 = 7.37935; // average radius outer layer;
780 // Loop on inner layer clusters
781 for (Int_t iiC1=0; iiC1<fNClustersLay1; iiC1++) {
782 if (!fOverlapFlagClustersLay1[iiC1]) {
783 // only for adjacent modules
784 if ((TMath::Abs(fDetectorIndexClustersLay1[iC1]-fDetectorIndexClustersLay1[iiC1])==4)||
785 (TMath::Abs(fDetectorIndexClustersLay1[iC1]-fDetectorIndexClustersLay1[iiC1])==76)) {
786 Float_t dePhi=TMath::Abs(fClustersLay1[iiC1][1]-fClustersLay1[iC1][1]);
787 if (dePhi>TMath::Pi()) dePhi=2.*TMath::Pi()-dePhi;
789 zproj1=meanRadiusLay1/TMath::Tan(fClustersLay1[iC1][0]);
790 zproj2=meanRadiusLay1/TMath::Tan(fClustersLay1[iiC1][0]);
792 deZproj=TMath::Abs(zproj1-zproj2);
794 distClSameMod = TMath::Sqrt(TMath::Power(deZproj/fZetaOverlapCut,2)+TMath::Power(dePhi/fPhiOverlapCut,2));
795 if (distClSameMod<=1.) fOverlapFlagClustersLay1[iiC1]=kTRUE;
797 // if (distClSameMod<=1.) {
798 // if (distClSameModMin==0. || distClSameMod<distClSameModMin) {
799 // distClSameModMin=distClSameMod;
805 } // end adjacent modules
807 } // end Loop on inner layer clusters
809 // if (distClSameModMin!=0.) fOverlapFlagClustersLay1[iClOverlap]=kTRUE;
814 // Loop on outer layer clusters
815 for (Int_t iiC2=0; iiC2<fNClustersLay2; iiC2++) {
816 if (!fOverlapFlagClustersLay2[iiC2]) {
817 // only for adjacent modules
818 if ((TMath::Abs(fDetectorIndexClustersLay2[iC2WithBestDist]-fDetectorIndexClustersLay2[iiC2])==4) ||
819 (TMath::Abs(fDetectorIndexClustersLay2[iC2WithBestDist]-fDetectorIndexClustersLay2[iiC2])==156)) {
820 Float_t dePhi=TMath::Abs(fClustersLay2[iiC2][1]-fClustersLay2[iC2WithBestDist][1]);
821 if (dePhi>TMath::Pi()) dePhi=2.*TMath::Pi()-dePhi;
823 zproj1=meanRadiusLay2/TMath::Tan(fClustersLay2[iC2WithBestDist][0]);
824 zproj2=meanRadiusLay2/TMath::Tan(fClustersLay2[iiC2][0]);
826 deZproj=TMath::Abs(zproj1-zproj2);
827 distClSameMod = TMath::Sqrt(TMath::Power(deZproj/fZetaOverlapCut,2)+TMath::Power(dePhi/fPhiOverlapCut,2));
828 if (distClSameMod<=1.) fOverlapFlagClustersLay2[iiC2]=kTRUE;
830 // if (distClSameMod<=1.) {
831 // if (distClSameModMin==0. || distClSameMod<distClSameModMin) {
832 // distClSameModMin=distClSameMod;
837 } // end adjacent modules
839 } // end Loop on outer layer clusters
841 // if (distClSameModMin!=0.) fOverlapFlagClustersLay2[iClOverlap]=kTRUE;