//
// Author : Tiziano Virgili
//
-//
+// Recent updates (D. Elia, INFN Bari):
+// - multiple association forbidden (fOnlyOneTrackletPerC2 = kTRUE)
+// - phi definition changed to ALICE convention (0,2*TMath::pi())
+// - cluster coordinates taken with GetGlobalXYZ()
+// - fGeometry removed
+// - number of fired chips on the two layers
+// - option to avoid duplicates in the overlaps (fRemoveClustersFromOverlaps)
+// - options and fiducial cuts via AliITSRecoParam
//
//____________________________________________________________________
#include <TTree.h>
#include "AliITSMultReconstructor.h"
+#include "AliITSReconstructor.h"
+#include "AliITSsegmentationSPD.h"
#include "AliITSRecPoint.h"
#include "AliITSgeom.h"
#include "AliLog.h"
//____________________________________________________________________
AliITSMultReconstructor::AliITSMultReconstructor():
-fGeometry(0),
+TObject(),
fClustersLay1(0),
fClustersLay2(0),
+fDetectorIndexClustersLay1(0),
+fDetectorIndexClustersLay2(0),
+fOverlapFlagClustersLay1(0),
+fOverlapFlagClustersLay2(0),
fTracklets(0),
fSClusters(0),
fAssociationFlag(0),
fNClustersLay2(0),
fNTracklets(0),
fNSingleCluster(0),
+fOnlyOneTrackletPerC2(0),
fPhiWindow(0),
fZetaWindow(0),
-fOnlyOneTrackletPerC2(0),
+fRemoveClustersFromOverlaps(0),
+fPhiOverlapCut(0),
+fZetaOverlapCut(0),
fHistOn(0),
fhClustersDPhiAcc(0),
fhClustersDThetaAcc(0),
fhphiTracklets(0),
fhetaClustersLay1(0),
fhphiClustersLay1(0){
+
+ fNFiredChips[0] = 0;
+ fNFiredChips[1] = 0;
+
// Method to reconstruct the charged particles multiplicity with the
// SPD (tracklets).
- fGeometry =0;
SetHistOn();
- SetPhiWindow();
- SetZetaWindow();
- SetOnlyOneTrackletPerC2();
- fClustersLay1 = new Float_t*[300000];
- fClustersLay2 = new Float_t*[300000];
- fTracklets = new Float_t*[300000];
- fSClusters = new Float_t*[300000];
- fAssociationFlag = new Bool_t[300000];
+ if(AliITSReconstructor::GetRecoParam()) {
+ SetOnlyOneTrackletPerC2(AliITSReconstructor::GetRecoParam()->GetTrackleterOnlyOneTrackletPerC2());
+ SetPhiWindow(AliITSReconstructor::GetRecoParam()->GetTrackleterPhiWindow());
+ SetZetaWindow(AliITSReconstructor::GetRecoParam()->GetTrackleterZetaWindow());
+ SetRemoveClustersFromOverlaps(AliITSReconstructor::GetRecoParam()->GetTrackleterRemoveClustersFromOverlaps());
+ SetPhiOverlapCut(AliITSReconstructor::GetRecoParam()->GetTrackleterPhiOverlapCut());
+ SetZetaOverlapCut(AliITSReconstructor::GetRecoParam()->GetTrackleterZetaOverlapCut());
+ } else {
+ SetOnlyOneTrackletPerC2();
+ SetPhiWindow();
+ SetZetaWindow();
+ SetRemoveClustersFromOverlaps();
+ SetPhiOverlapCut();
+ SetZetaOverlapCut();
+ }
+
+
+ fClustersLay1 = new Float_t*[300000];
+ fClustersLay2 = new Float_t*[300000];
+ fDetectorIndexClustersLay1 = new Int_t[300000];
+ fDetectorIndexClustersLay2 = new Int_t[300000];
+ fOverlapFlagClustersLay1 = new Bool_t[300000];
+ fOverlapFlagClustersLay2 = new Bool_t[300000];
+ fTracklets = new Float_t*[300000];
+ fSClusters = new Float_t*[300000];
+ fAssociationFlag = new Bool_t[300000];
for(Int_t i=0; i<300000; i++) {
fClustersLay1[i] = new Float_t[6];
fClustersLay2[i] = new Float_t[6];
- fTracklets[i] = new Float_t[4];
+ fTracklets[i] = new Float_t[5];
fSClusters[i] = new Float_t[2];
+ fOverlapFlagClustersLay1[i] = kFALSE;
+ fOverlapFlagClustersLay2[i] = kFALSE;
fAssociationFlag[i] = kFALSE;
}
fhDPhiVsDThetaAll->SetDirectory(0);
fhetaTracklets = new TH1F("etaTracklets", "eta", 100,-2.,2.);
- fhphiTracklets = new TH1F("phiTracklets", "phi", 100,-3.14159,3.14159);
+ fhetaTracklets->SetDirectory(0);
+ fhphiTracklets = new TH1F("phiTracklets", "phi", 100, 0., 2*TMath::Pi());
+ fhphiTracklets->SetDirectory(0);
fhetaClustersLay1 = new TH1F("etaClustersLay1", "etaCl1", 100,-2.,2.);
- fhphiClustersLay1 = new TH1F("phiClustersLay1", "phiCl1", 100,-3.141,3.141);
-
+ fhetaClustersLay1->SetDirectory(0);
+ fhphiClustersLay1 = new TH1F("phiClustersLay1", "phiCl1", 100, 0., 2*TMath::Pi());
+ fhphiClustersLay1->SetDirectory(0);
}
//______________________________________________________________________
AliITSMultReconstructor::AliITSMultReconstructor(const AliITSMultReconstructor &mr) : TObject(mr),
-fGeometry(mr.fGeometry),
fClustersLay1(mr.fClustersLay1),
fClustersLay2(mr.fClustersLay2),
+fDetectorIndexClustersLay1(mr.fDetectorIndexClustersLay1),
+fDetectorIndexClustersLay2(mr.fDetectorIndexClustersLay2),
+fOverlapFlagClustersLay1(mr.fOverlapFlagClustersLay1),
+fOverlapFlagClustersLay2(mr.fOverlapFlagClustersLay2),
fTracklets(mr.fTracklets),
fSClusters(mr.fSClusters),
fAssociationFlag(mr.fAssociationFlag),
fNClustersLay2(mr.fNClustersLay2),
fNTracklets(mr.fNTracklets),
fNSingleCluster(mr.fNSingleCluster),
+fOnlyOneTrackletPerC2(mr.fOnlyOneTrackletPerC2),
fPhiWindow(mr.fPhiWindow),
fZetaWindow(mr.fZetaWindow),
-fOnlyOneTrackletPerC2(mr.fOnlyOneTrackletPerC2),
+fRemoveClustersFromOverlaps(mr.fRemoveClustersFromOverlaps),
+fPhiOverlapCut(mr.fPhiOverlapCut),
+fZetaOverlapCut(mr.fZetaOverlapCut),
fHistOn(mr.fHistOn),
fhClustersDPhiAcc(mr.fhClustersDPhiAcc),
fhClustersDThetaAcc(mr.fhClustersDThetaAcc),
}
delete [] fClustersLay1;
delete [] fClustersLay2;
+ delete [] fDetectorIndexClustersLay1;
+ delete [] fDetectorIndexClustersLay2;
+ delete [] fOverlapFlagClustersLay1;
+ delete [] fOverlapFlagClustersLay2;
delete [] fTracklets;
delete [] fSClusters;
fhetaClustersLay1->Fill(eta);
fhphiClustersLay1->Fill(fClustersLay1[iC1][1]);
}
-}
+ }
// Loop on layer 2 : finding theta, phi and r
for (Int_t iC2=0; iC2<fNClustersLay2; iC2++) {
Float_t dPhimin = 0.; // Used for histograms only!
Float_t dThetamin = 0.; // Used for histograms only!
Float_t dZetamin = 0.; // Used for histograms only!
-
+
+ if (fOverlapFlagClustersLay1[iC1]) continue;
+
// Loop on layer 2
for (Int_t iC2=0; iC2<fNClustersLay2; iC2++) {
-
+ if (fOverlapFlagClustersLay2[iC2]) continue;
// The following excludes double associations
if (!fAssociationFlag[iC2]) {
fTracklets[fNTracklets][0] = fClustersLay1[iC1][0];
// use the phi from the clusters in the first layer
fTracklets[fNTracklets][1] = fClustersLay1[iC1][1];
- // Store the difference between phi1 and phi2
+ // store the difference between phi1 and phi2
fTracklets[fNTracklets][2] = fClustersLay1[iC1][1] - fClustersLay2[iC2WithBestDist][1];
+ // define dphi in the range [0,pi] with proper sign (track charge correlated)
+ if (fTracklets[fNTracklets][2] > TMath::Pi())
+ fTracklets[fNTracklets][2] = fTracklets[fNTracklets][2]-2.*TMath::Pi();
+ if (fTracklets[fNTracklets][2] < -TMath::Pi())
+ fTracklets[fNTracklets][2] = fTracklets[fNTracklets][2]+2.*TMath::Pi();
+
// find label
+ // if equal label in both clusters found this label is assigned
+ // if no equal label can be found the first labels of the L1 AND L2 cluster are assigned
Int_t label1 = 0;
Int_t label2 = 0;
while (label2 < 3)
{
if ((Int_t) fClustersLay1[iC1][3+label1] != -2 && (Int_t) fClustersLay1[iC1][3+label1] == (Int_t) fClustersLay2[iC2WithBestDist][3+label2])
break;
-
label1++;
if (label1 == 3)
{
{
AliDebug(AliLog::kDebug, Form("Found label %d == %d for tracklet candidate %d\n", (Int_t) fClustersLay1[iC1][3+label1], (Int_t) fClustersLay2[iC2WithBestDist][3+label2], fNTracklets));
fTracklets[fNTracklets][3] = fClustersLay1[iC1][3+label1];
+ fTracklets[fNTracklets][4] = fClustersLay2[iC2WithBestDist][3+label2];
}
else
{
AliDebug(AliLog::kDebug, Form("Did not find label %d %d %d %d %d %d for tracklet candidate %d\n", (Int_t) fClustersLay1[iC1][3], (Int_t) fClustersLay1[iC1][4], (Int_t) fClustersLay1[iC1][5], (Int_t) fClustersLay2[iC2WithBestDist][3], (Int_t) fClustersLay2[iC2WithBestDist][4], (Int_t) fClustersLay2[iC2WithBestDist][5], fNTracklets));
- fTracklets[fNTracklets][3] = -2;
+ fTracklets[fNTracklets][3] = fClustersLay1[iC1][3];
+ fTracklets[fNTracklets][4] = fClustersLay2[iC2WithBestDist][3];
}
if (fHistOn) {
AliDebug(1,Form(" Cl. %d of Layer 1 and %d of Layer 2", iC1,
iC2WithBestDist));
fNTracklets++;
+
+ if (fRemoveClustersFromOverlaps) FlagClustersInOverlapRegions (iC1,iC2WithBestDist);
+
}
// Delete the following else if you do not want to save Clusters!
// - gets the clusters from the cluster tree
// - convert them into global coordinates
// - store them in the internal arrays
+ // - count the number of cluster-fired chips
- AliDebug(1,"Loading clusters ...");
+ AliDebug(1,"Loading clusters and cluster-fired chips ...");
fNClustersLay1 = 0;
fNClustersLay2 = 0;
+ fNFiredChips[0] = 0;
+ fNFiredChips[1] = 0;
+ AliITSsegmentationSPD *seg = new AliITSsegmentationSPD();
+
TClonesArray* itsClusters = new TClonesArray("AliITSRecPoint");
TBranch* itsClusterBranch=itsClusterTree->GetBranch("ITSRecPoints");
itsClusterBranch->SetAddress(&itsClusters);
Int_t nItsSubs = (Int_t)itsClusterTree->GetEntries();
+ Float_t cluGlo[3]={0.,0.,0.};
// loop over the its subdetectors
for (Int_t iIts=0; iIts < nItsSubs; iIts++) {
continue;
Int_t nClusters = itsClusters->GetEntriesFast();
-
- // stuff needed to get the global coordinates
- Double_t rot[9]; fGeometry->GetRotMatrix(iIts,rot);
- Int_t lay,lad,det; fGeometry->GetModuleId(iIts,lay,lad,det);
- Float_t tx,ty,tz; fGeometry->GetTrans(lay,lad,det,tx,ty,tz);
-
- // Below:
- // "alpha" is the angle from the global X-axis to the
- // local GEANT X'-axis ( rot[0]=cos(alpha) and rot[1]=sin(alpha) )
- // "phi" is the angle from the global X-axis to the
- // local cluster X"-axis
-
- Double_t alpha = TMath::ATan2(rot[1],rot[0])+TMath::Pi();
- Double_t itsPhi = TMath::Pi()/2+alpha;
-
- if (lay==1) itsPhi+=TMath::Pi();
- Double_t cp=TMath::Cos(itsPhi), sp=TMath::Sin(itsPhi);
- Double_t r=tx*cp+ty*sp;
+
+ // number of clusters in each chip of the current module
+ Int_t nClustersInChip[5] = {0,0,0,0,0};
+ Int_t layer = 0;
// loop over clusters
while(nClusters--) {
AliITSRecPoint* cluster = (AliITSRecPoint*)itsClusters->UncheckedAt(nClusters);
- if (cluster->GetLayer()>1)
- continue;
+ layer = cluster->GetLayer();
+ if (layer>1) continue;
- Float_t x = r*cp - cluster->GetY()*sp;
- Float_t y = r*sp + cluster->GetY()*cp;
- Float_t z = cluster->GetZ();
+ cluster->GetGlobalXYZ(cluGlo);
+ Float_t x = cluGlo[0];
+ Float_t y = cluGlo[1];
+ Float_t z = cluGlo[2];
+
+ // find the chip for the current cluster
+ Float_t locz = cluster->GetDetLocalZ();
+ Int_t iChip = seg->GetChipFromLocal(0,locz);
+ nClustersInChip[iChip]++;
- if (cluster->GetLayer()==0) {
+ if (layer==0) {
fClustersLay1[fNClustersLay1][0] = x;
fClustersLay1[fNClustersLay1][1] = y;
fClustersLay1[fNClustersLay1][2] = z;
+
+ fDetectorIndexClustersLay1[fNClustersLay1]=iIts;
+
for (Int_t i=0; i<3; i++)
fClustersLay1[fNClustersLay1][3+i] = cluster->GetLabel(i);
fNClustersLay1++;
}
- if (cluster->GetLayer()==1) {
+ if (layer==1) {
fClustersLay2[fNClustersLay2][0] = x;
fClustersLay2[fNClustersLay2][1] = y;
fClustersLay2[fNClustersLay2][2] = z;
+
+ fDetectorIndexClustersLay2[fNClustersLay2]=iIts;
+
for (Int_t i=0; i<3; i++)
fClustersLay2[fNClustersLay2][3+i] = cluster->GetLabel(i);
fNClustersLay2++;
}
}// end of cluster loop
+
+ // get number of fired chips in the current module
+ if(layer<2)
+ for(Int_t ifChip=0; ifChip<5; ifChip++) {
+ if(nClustersInChip[ifChip] >= 1) fNFiredChips[layer]++;
+ }
+
} // end of its "subdetector" loop
-
+
if (itsClusters) {
itsClusters->Delete();
delete itsClusters;
+ delete seg;
itsClusters = 0;
}
AliDebug(1,Form("(clusters in layer 1 : %d, layer 2: %d)",fNClustersLay1,fNClustersLay2));
+ AliDebug(1,Form("(cluster-fired chips in layer 1 : %d, layer 2: %d)",fNFiredChips[0],fNFiredChips[1]));
+}
+//____________________________________________________________________
+void
+AliITSMultReconstructor::LoadClusterFiredChips(TTree* itsClusterTree) {
+ // This method
+ // - gets the clusters from the cluster tree
+ // - counts the number of (cluster)fired chips
+
+ AliDebug(1,"Loading cluster-fired chips ...");
+
+ fNFiredChips[0] = 0;
+ fNFiredChips[1] = 0;
+
+ AliITSsegmentationSPD *seg = new AliITSsegmentationSPD();
+
+ TClonesArray* itsClusters = new TClonesArray("AliITSRecPoint");
+ TBranch* itsClusterBranch=itsClusterTree->GetBranch("ITSRecPoints");
+
+ itsClusterBranch->SetAddress(&itsClusters);
+
+ Int_t nItsSubs = (Int_t)itsClusterTree->GetEntries();
+
+ // loop over the its subdetectors
+ for (Int_t iIts=0; iIts < nItsSubs; iIts++) {
+
+ if (!itsClusterTree->GetEvent(iIts))
+ continue;
+
+ Int_t nClusters = itsClusters->GetEntriesFast();
+
+ // number of clusters in each chip of the current module
+ Int_t nClustersInChip[5] = {0,0,0,0,0};
+ Int_t layer = 0;
+
+ // loop over clusters
+ while(nClusters--) {
+ AliITSRecPoint* cluster = (AliITSRecPoint*)itsClusters->UncheckedAt(nClusters);
+
+ layer = cluster->GetLayer();
+ if (layer>1) continue;
+
+ // find the chip for the current cluster
+ Float_t locz = cluster->GetDetLocalZ();
+ Int_t iChip = seg->GetChipFromLocal(0,locz);
+ nClustersInChip[iChip]++;
+
+ }// end of cluster loop
+
+ // get number of fired chips in the current module
+ if(layer<2)
+ for(Int_t ifChip=0; ifChip<5; ifChip++) {
+ if(nClustersInChip[ifChip] >= 1) fNFiredChips[layer]++;
+ }
+
+ } // end of its "subdetector" loop
+
+ if (itsClusters) {
+ itsClusters->Delete();
+ delete itsClusters;
+ delete seg;
+ itsClusters = 0;
+ }
+ AliDebug(1,Form("(cluster-fired chips in layer 1 : %d, layer 2: %d)",fNFiredChips[0],fNFiredChips[1]));
}
//____________________________________________________________________
void
fhphiClustersLay1->Write();
}
+//____________________________________________________________________
+void
+AliITSMultReconstructor::FlagClustersInOverlapRegions (Int_t iC1, Int_t iC2WithBestDist) {
+
+ Float_t distClSameMod=0.;
+ Float_t distClSameModMin=0.;
+ Int_t iClOverlap =0;
+ Float_t meanRadiusLay1 = 3.99335; // average radius inner layer
+ Float_t meanRadiusLay2 = 7.37935; // average radius outer layer;
+
+ Float_t zproj1=0.;
+ Float_t zproj2=0.;
+ Float_t deZproj=0.;
+
+ // Loop on inner layer clusters
+ for (Int_t iiC1=0; iiC1<fNClustersLay1; iiC1++) {
+ if (!fOverlapFlagClustersLay1[iiC1]) {
+ // only for adjacent modules
+ if ((TMath::Abs(fDetectorIndexClustersLay1[iC1]-fDetectorIndexClustersLay1[iiC1])==4)||
+ (TMath::Abs(fDetectorIndexClustersLay1[iC1]-fDetectorIndexClustersLay1[iiC1])==76)) {
+ Float_t dePhi=TMath::Abs(fClustersLay1[iiC1][1]-fClustersLay1[iC1][1]);
+ if (dePhi>TMath::Pi()) dePhi=2.*TMath::Pi()-dePhi;
+
+ zproj1=meanRadiusLay1/TMath::Tan(fClustersLay1[iC1][0]);
+ zproj2=meanRadiusLay1/TMath::Tan(fClustersLay1[iiC1][0]);
+
+ deZproj=TMath::Abs(zproj1-zproj2);
+
+ distClSameMod = TMath::Sqrt(TMath::Power(deZproj/fZetaOverlapCut,2)+TMath::Power(dePhi/fPhiOverlapCut,2));
+ if (distClSameMod<=1.) fOverlapFlagClustersLay1[iiC1]=kTRUE;
+
+// if (distClSameMod<=1.) {
+// if (distClSameModMin==0. || distClSameMod<distClSameModMin) {
+// distClSameModMin=distClSameMod;
+// iClOverlap=iiC1;
+// }
+// }
+
+
+ } // end adjacent modules
+ }
+ } // end Loop on inner layer clusters
+
+// if (distClSameModMin!=0.) fOverlapFlagClustersLay1[iClOverlap]=kTRUE;
+
+ distClSameMod=0.;
+ distClSameModMin=0.;
+ iClOverlap =0;
+ // Loop on outer layer clusters
+ for (Int_t iiC2=0; iiC2<fNClustersLay2; iiC2++) {
+ if (!fOverlapFlagClustersLay2[iiC2]) {
+ // only for adjacent modules
+ if ((TMath::Abs(fDetectorIndexClustersLay2[iC2WithBestDist]-fDetectorIndexClustersLay2[iiC2])==4) ||
+ (TMath::Abs(fDetectorIndexClustersLay2[iC2WithBestDist]-fDetectorIndexClustersLay2[iiC2])==156)) {
+ Float_t dePhi=TMath::Abs(fClustersLay2[iiC2][1]-fClustersLay2[iC2WithBestDist][1]);
+ if (dePhi>TMath::Pi()) dePhi=2.*TMath::Pi()-dePhi;
+
+ zproj1=meanRadiusLay2/TMath::Tan(fClustersLay2[iC2WithBestDist][0]);
+ zproj2=meanRadiusLay2/TMath::Tan(fClustersLay2[iiC2][0]);
+
+ deZproj=TMath::Abs(zproj1-zproj2);
+ distClSameMod = TMath::Sqrt(TMath::Power(deZproj/fZetaOverlapCut,2)+TMath::Power(dePhi/fPhiOverlapCut,2));
+ if (distClSameMod<=1.) fOverlapFlagClustersLay2[iiC2]=kTRUE;
+
+// if (distClSameMod<=1.) {
+// if (distClSameModMin==0. || distClSameMod<distClSameModMin) {
+// distClSameModMin=distClSameMod;
+// iClOverlap=iiC2;
+// }
+// }
+
+ } // end adjacent modules
+ }
+ } // end Loop on outer layer clusters
+// if (distClSameModMin!=0.) fOverlapFlagClustersLay2[iClOverlap]=kTRUE;
+
+}