]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSVertexer.cxx
moving class
[u/mrichter/AliRoot.git] / ITS / AliITSVertexer.cxx
CommitLineData
308c2f7c 1#include "AliLog.h"
2#include "AliMultiplicity.h"
32e63e47 3#include "AliITSgeomTGeo.h"
27167524 4#include "AliITSVertexer.h"
27167524 5#include "AliITSLoader.h"
27167524 6#include "AliITSMultReconstructor.h"
7
8const Float_t AliITSVertexer::fgkPipeRadius = 3.0;
c5f0f3c1 9
10ClassImp(AliITSVertexer)
11
12//////////////////////////////////////////////////////////////////////
13// Base class for primary vertex reconstruction //
d681bb2d 14// AliESDVertexer is a class for full 3D primary vertex finding //
3acc14d5 15// derived classes: AliITSVertexerIons AliITSvertexer3D //
16// AliITSVertexerCosmics //
c5f0f3c1 17//////////////////////////////////////////////////////////////////////
18
19//______________________________________________________________________
27167524 20AliITSVertexer::AliITSVertexer():AliVertexer(),
21fLadders(),
308c2f7c 22fLadOnLay2(0),
23fFirstEvent(0),
24fLastEvent(-1)
27167524 25{
308c2f7c 26 // Default Constructor
27167524 27 SetLaddersOnLayer2();
c5f0f3c1 28}
29
27167524 30//______________________________________________________________________
31AliITSVertexer::~AliITSVertexer() {
32 // Destructor
33 if(fLadders) delete [] fLadders;
34}
35
32e449be 36//______________________________________________________________________
308c2f7c 37void AliITSVertexer::FindMultiplicity(TTree *itsClusterTree){
32e449be 38 // Invokes AliITSMultReconstructor to determine the
39 // charged multiplicity in the pixel layers
40 if(fMult){delete fMult; fMult = 0;}
41 Bool_t success=kTRUE;
42 if(!fCurrentVertex)success=kFALSE;
43 if(fCurrentVertex && fCurrentVertex->GetNContributors()<1)success=kFALSE;
44 if(!success){
45 AliWarning("Tracklets multiplicity not determined because the primary vertex was not found");
46 return;
47 }
48 AliITSMultReconstructor* multReco = new AliITSMultReconstructor();
308c2f7c 49
32e449be 50 if (!itsClusterTree) {
308c2f7c 51 AliError(" Invalid ITS cluster tree !\n");
32e449be 52 return;
53 }
54 Double_t vtx[3];
55 fCurrentVertex->GetXYZ(vtx);
56 Float_t vtxf[3];
57 for(Int_t i=0;i<3;i++)vtxf[i]=vtx[i];
58 multReco->SetHistOn(kFALSE);
59 multReco->Reconstruct(itsClusterTree,vtxf,vtxf);
32e449be 60 Int_t notracks=multReco->GetNTracklets();
968e8539 61 Float_t *tht = new Float_t [notracks];
32e449be 62 Float_t *phi = new Float_t [notracks];
63 Float_t *dphi = new Float_t [notracks];
de4c520e 64 Int_t *labels = new Int_t[notracks];
0939e22a 65 Int_t *labelsL2 = new Int_t[notracks];
32e449be 66 for(Int_t i=0;i<multReco->GetNTracklets();i++){
968e8539 67 tht[i] = multReco->GetTracklet(i)[0];
32e449be 68 phi[i] = multReco->GetTracklet(i)[1];
69 dphi[i] = multReco->GetTracklet(i)[2];
1b9fef1c 70 labels[i] = static_cast<Int_t>(multReco->GetTracklet(i)[3]);
0939e22a 71 labelsL2[i] = static_cast<Int_t>(multReco->GetTracklet(i)[4]);
32e449be 72 }
968e8539 73 Int_t nosingleclus=multReco->GetNSingleClusters();
74 Float_t *ths = new Float_t [nosingleclus];
75 Float_t *phs = new Float_t [nosingleclus];
76 for(Int_t i=0;i<nosingleclus;i++){
77 ths[i] = multReco->GetCluster(i)[0];
78 phs[i] = multReco->GetCluster(i)[1];
79 }
0939e22a 80 fMult = new AliMultiplicity(notracks,tht,phi,dphi,labels,labelsL2,nosingleclus,ths,phs);
968e8539 81 delete [] tht;
32e449be 82 delete [] phi;
83 delete [] dphi;
968e8539 84 delete [] ths;
85 delete [] phs;
d6fc37c1 86 delete [] labels;
0939e22a 87 delete [] labelsL2;
308c2f7c 88
32e449be 89 delete multReco;
90 return;
91}
c5f0f3c1 92
27167524 93//______________________________________________________________________
94void AliITSVertexer::SetLaddersOnLayer2(Int_t ladwid){
95 // Calculates the array of ladders on layer 2 to be used with a
96 // given ladder on layer 1
97 fLadOnLay2=ladwid;
32e63e47 98 Int_t ladtot1=AliITSgeomTGeo::GetNLadders(1);
27167524 99 if(fLadders) delete [] fLadders;
100 fLadders=new UShort_t[ladtot1];
101
102
103 Double_t pos1[3],pos2[3];
32e63e47 104 Int_t mod1=AliITSgeomTGeo::GetModuleIndex(2,1,1);
105 AliITSgeomTGeo::GetTranslation(mod1,pos1); // position of the module in the MRS
27167524 106 Double_t phi0=TMath::ATan2(pos1[1],pos1[0]);
107 if(phi0<0) phi0+=2*TMath::Pi();
32e63e47 108 Int_t mod2=AliITSgeomTGeo::GetModuleIndex(2,2,1);
109 AliITSgeomTGeo::GetTranslation(mod2,pos2);
27167524 110 Double_t phi2=TMath::ATan2(pos2[1],pos2[0]);
111 if(phi2<0) phi2+=2*TMath::Pi();
112 Double_t deltaPhi= phi0-phi2; // phi width of a layer2 module
113
114 for(Int_t i= 0; i<ladtot1;i++){
32e63e47 115 Int_t modlad= AliITSgeomTGeo::GetModuleIndex(1,i+1,1);
27167524 116 Double_t posmod[3];
32e63e47 117 AliITSgeomTGeo::GetTranslation(modlad,posmod);
27167524 118 Double_t phimod=TMath::ATan2(posmod[1],posmod[0]);
119 if(phimod<0) phimod+=2*TMath::Pi();
120 Double_t phi1= phimod+deltaPhi*double(fLadOnLay2);
121 if(phi1<0) phi1+=2*TMath::Pi();
122 if(phi1>2*TMath::Pi()) phi1-=2*TMath::Pi();
123 Double_t philad1=phi0-phi1;
124 UShort_t lad1;
125 Double_t ladder1=(philad1)/(deltaPhi) +1.;
126 if(ladder1<1){ladder1=40+ladder1;}
127 lad1=int(ladder1+0.5);
128 fLadders[i]=lad1;
129 }
130}
131
308c2f7c 132#include "AliRunLoader.h"
133
134//______________________________________________________________________
135void AliITSVertexer::Init(TString filename){
136 // Initialize the vertexer in case of
137 // analysis of an entire file
138 AliRunLoader *rl = AliRunLoader::GetRunLoader();
139 if(!rl){
140 Fatal("AliITSVertexer","Run Loader not found");
141 }
142 if (fLastEvent < 0) SetLastEvent(rl->GetNumberOfEvents()-1);
143
144 AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
145 if(!filename.Contains("default"))itsloader->SetVerticesFileName(filename);
146 if(!filename.Contains("null"))itsloader->LoadVertices("recreate");
147}
27167524 148
c5f0f3c1 149//______________________________________________________________________
150void AliITSVertexer::WriteCurrentVertex(){
151 // Write the current AliVertex object to file fOutFile
88cb7938 152 AliRunLoader *rl = AliRunLoader::GetRunLoader();
41b19549 153 AliITSLoader* itsLoader = (AliITSLoader*) rl->GetLoader("ITSLoader");
88cb7938 154 fCurrentVertex->SetName("Vertex");
155 // const char * name = fCurrentVertex->GetName();
41b19549 156 // itsLoader->SetVerticesContName(name);
157 Int_t rc = itsLoader->PostVertex(fCurrentVertex);
158 rc = itsLoader->WriteVertices();
c5f0f3c1 159}
de4c520e 160
308c2f7c 161//______________________________________________________________________
162void AliITSVertexer::FindVertices(){
163 // computes the vertices of the events in the range FirstEvent - LastEvent
164
165 AliRunLoader *rl = AliRunLoader::GetRunLoader();
166 AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
167 itsloader->LoadRecPoints("read");
168 for(Int_t i=fFirstEvent;i<=fLastEvent;i++){
169 rl->GetEvent(i);
170 TTree* cltree = itsloader->TreeR();
171 FindVertexForCurrentEvent(cltree);
172 if(fCurrentVertex){
173 WriteCurrentVertex();
174 }
175 else {
176 AliDebug(1,Form("Vertex not found for event %d",i));
177 }
178 }
179}