**************************************************************************/
#include <TClonesArray.h>
+#include <TTree.h>
#include "AliLog.h"
#include "AliESDVertex.h"
-#include "AliRunLoader.h"
-#include "AliITSLoader.h"
#include "AliITSgeomTGeo.h"
#include "AliITSRecPoint.h"
#include "AliITSReconstructor.h"
SetFirstLastModules(3,324,499);
SetFirstLastModules(4,500,1247);
SetFirstLastModules(5,1248,2197);
+ /*
SetMaxVtxRadius(0,3.5);
SetMaxVtxRadius(1,6.5);
SetMaxVtxRadius(2,14.5);
SetMaxVtxRadius(3,23.5);
SetMaxVtxRadius(4,37.5);
SetMaxVtxRadius(5,42.5);
- /*
+ */
SetMaxVtxRadius(0,5.5);
SetMaxVtxRadius(1,8.5);
SetMaxVtxRadius(2,18.5);
SetMaxVtxRadius(3,28.5);
SetMaxVtxRadius(4,39.5);
SetMaxVtxRadius(5,48.5);
- */
+
SetMaxDistOnOuterLayer();
SetMinDist2Vtxs();
}
//--------------------------------------------------------------------------
-AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(Int_t evnumber)
+AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(TTree *itsClusterTree)
{
// Defines the AliESDVertex for the current event
fCurrentVertex = 0;
- AliRunLoader *rl =AliRunLoader::GetRunLoader();
- AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader");
- itsLoader->LoadRecPoints();
- rl->GetEvent(evnumber);
-
- TTree *rpTree = itsLoader->TreeR();
TClonesArray *recpoints=new TClonesArray("AliITSRecPoint",10000);
- rpTree->SetBranchAddress("ITSRecPoints",&recpoints);
+ itsClusterTree->SetBranchAddress("ITSRecPoints",&recpoints);
Int_t lay,lad,det;
// Search for innermost layer with at least two clusters
// on two different modules
Int_t ilayer=0,ilayer2=0;
- while(ilayer<6) {
+ Int_t nHitModulesSPDinner=0;
+ while(ilayer<AliITSgeomTGeo::GetNLayers()) {
if(AliITSReconstructor::GetRecoParam()->GetLayersToSkip(ilayer)) {
ilayer++;
continue;
}
Int_t nHitModules=0;
for(Int_t imodule=fFirst[ilayer]; imodule<=fLast[ilayer]; imodule++) {
- rpTree->GetEvent(imodule);
+ itsClusterTree->GetEvent(imodule);
AliITSgeomTGeo::GetModuleId(imodule,lay,lad,det);
lay -= 1; // AliITSgeomTGeo gives layer from 1 to 6, we want 0 to 5
if(lay!=ilayer) AliFatal("Layer mismatch!");
if(recpoints->GetEntriesFast()>0) nHitModules++;
}
+ if(ilayer==0) nHitModulesSPDinner=nHitModules;
if(nHitModules>=2) break;
ilayer++;
}
ilayer2++;
}
- //if(ilayer==1 && ilayer2>5 && !AliITSReconstructor::GetRecoParam()->GetLayersToSkip(0)) {ilayer=0; ilayer2=1;}
+ // try tracklet on SPD2 and point on SPD1
+ if(ilayer==1 && !AliITSReconstructor::GetRecoParam()->GetLayersToSkip(0) &&
+ nHitModulesSPDinner>0) { ilayer=0; ilayer2=1; }
if(ilayer>4 || ilayer2>5) {
AliWarning("Not enough clusters");
delete recpoints;
- itsLoader->UnloadRecPoints();
fCurrentVertex = new AliESDVertex(pos,err,"cosmics");
fCurrentVertex->SetTitle("cosmics fake vertex (failed)");
fCurrentVertex->SetNContributors(ncontributors);
Int_t nclOutLayStored=0;
Int_t nRecPoints,nRecPointsInnLay=0;
- Float_t gc[3],gcov[5];
+ Float_t gc[3],gcov[6];
Float_t matchOutLayValue;
Float_t distxyInnLay,distxyInnLayBest=0.;
// Collect clusters in the selected layer and the outer one
for(Int_t imodule=fFirst[ilayer]; imodule<=fLast[ilayer2]; imodule++) {
- rpTree->GetEvent(imodule);
+ itsClusterTree->GetEvent(imodule);
AliITSgeomTGeo::GetModuleId(imodule,lay,lad,det);
lay -= 1; // AliITSgeomTGeo gives layer from 1 to 6, we want 0 to 5
nRecPoints=recpoints->GetEntriesFast();
//AliFatal("More than arrSize clusters per layer");
AliWarning("Too many clusters per layer");
delete recpoints;
- itsLoader->UnloadRecPoints();
fCurrentVertex = new AliESDVertex(pos,err,"cosmics");
fCurrentVertex->SetTitle("cosmics fake vertex (failed)");
fCurrentVertex->SetNContributors(ncontributors);
Int_t i1InnLay,i2InnLay,iOutLay;
// build fake vertices
- printf("Building tracklets on layer %d\n",ilayer);
+ //printf("Building tracklets on layer %d\n",ilayer);
// InnLay - first cluster
for(i1InnLay=0; i1InnLay<nclInnLayStored; i1InnLay++) {
p3[0]=xclOutLay[iOutLay];
p3[1]=yclOutLay[iOutLay];
p3[2]=zclOutLay[iOutLay];
- //printf(" %f\n",innLayline.GetDistFromPoint(p3));
+ //printf("(%f,%f) (%f,%f) (%f,%f) %f\n",p1[0],p1[1],p2[0],p2[1],p3[0],p3[1],innLayline.GetDistFromPoint(p3));
matchOutLayValue=innLayline.GetDistFromPoint(p3);
distxyInnLay = (p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1]);
if(matchOutLayValue<fMaxDistOnOuterLayer &&
distxyInnLay>distxyInnLayBest) {
+ //printf("found\n");
distxyInnLayBest=distxyInnLay;
i1InnLayBest=i1InnLay;
i2InnLayBest=i2InnLay;
err[1]=TMath::Sqrt(0.25*(e2yclInnLay[i1InnLayBest]+e2yclInnLay[i2InnLayBest]));
err[2]=TMath::Sqrt(0.25*(e2zclInnLay[i1InnLayBest]+e2zclInnLay[i2InnLayBest]));
}
- /*
- fCurrentVertex = new AliESDVertex(pos,err,"cosmics");
- fCurrentVertex->SetTitle("cosmics fake vertex");
- fCurrentVertex->SetNContributors(ncontributors);
- delete recpoints;
- itsLoader->UnloadRecPoints();
- return fCurrentVertex;
- */
- }
- /*
- if(i1InnLayBest==-1 && i2InnLayBest==-1) {
- // give a try exchanging InnLay and OutLay
+ } else { // give it a try exchanging InnLay and OutLay
+
// OutLay - first cluster
for(i1InnLay=0; i1InnLay<nclOutLayStored; i1InnLay++) {
p1[0]=xclOutLay[i1InnLay];
}
} // OutLay - second cluster
} // OutLay - first cluster
- }
- if(i1InnLayBest>-1 && i2InnLayBest>-1) {
- xvtx = 0.5*(xclOutLay[i1InnLayBest]+xclOutLay[i2InnLayBest]);
- yvtx = 0.5*(yclOutLay[i1InnLayBest]+yclOutLay[i2InnLayBest]);
- zvtx = 0.5*(zclOutLay[i1InnLayBest]+zclOutLay[i2InnLayBest]);
- rvtx = TMath::Sqrt(xvtx*xvtx+yvtx*yvtx);
- if(rvtx<fMaxVtxRadius[ilayer]) {
- ncontributors = ilayer2;
- pos[0] = xvtx;
- pos[1] = yvtx;
- pos[2] = zvtx;
- err[0]=TMath::Sqrt(0.25*(e2xclOutLay[i1InnLayBest]+e2xclOutLay[i2InnLayBest]));
- err[1]=TMath::Sqrt(0.25*(e2yclOutLay[i1InnLayBest]+e2yclOutLay[i2InnLayBest]));
- err[2]=TMath::Sqrt(0.25*(e2zclOutLay[i1InnLayBest]+e2zclOutLay[i2InnLayBest]));
+ if(i1InnLayBest>-1 && i2InnLayBest>-1) {
+ xvtx = 0.5*(xclOutLay[i1InnLayBest]+xclOutLay[i2InnLayBest]);
+ yvtx = 0.5*(yclOutLay[i1InnLayBest]+yclOutLay[i2InnLayBest]);
+ zvtx = 0.5*(zclOutLay[i1InnLayBest]+zclOutLay[i2InnLayBest]);
+ rvtx = TMath::Sqrt(xvtx*xvtx+yvtx*yvtx);
+ if(rvtx<fMaxVtxRadius[ilayer]) {
+ ncontributors = ilayer2;
+ pos[0] = xvtx;
+ pos[1] = yvtx;
+ pos[2] = zvtx;
+ err[0]=TMath::Sqrt(0.25*(e2xclOutLay[i1InnLayBest]+e2xclOutLay[i2InnLayBest]));
+ err[1]=TMath::Sqrt(0.25*(e2yclOutLay[i1InnLayBest]+e2yclOutLay[i2InnLayBest]));
+ err[2]=TMath::Sqrt(0.25*(e2zclOutLay[i1InnLayBest]+e2zclOutLay[i2InnLayBest]));
+ }
}
- }
- */
+ } // give it a try exchanging InnLay and OutLay
fCurrentVertex = new AliESDVertex(pos,err,"cosmics");
fCurrentVertex->SetTitle("cosmics fake vertex");
fCurrentVertex->SetNContributors(ncontributors);
//fCurrentVertex->Print();
+ if(fComputeMultiplicity) FindMultiplicity(itsClusterTree);
delete recpoints;
- itsLoader->UnloadRecPoints();
return fCurrentVertex;
}
-//-------------------------------------------------------------------------
-void AliITSVertexerCosmics::FindVertices()
-{
- // computes the vertices of the events in the range FirstEvent - LastEvent
- AliRunLoader *rl = AliRunLoader::GetRunLoader();
- AliITSLoader* itsLoader = (AliITSLoader*) rl->GetLoader("ITSLoader");
- itsLoader->ReloadRecPoints();
- for(Int_t i=fFirstEvent;i<=fLastEvent;i++){
- // printf("Processing event %d\n",i);
- rl->GetEvent(i);
- FindVertexForCurrentEvent(i);
- if(fCurrentVertex){
- WriteCurrentVertex();
- }
- }
-}
+
//-------------------------------------------------------------------------
void AliITSVertexerCosmics::PrintStatus() const
{