Remove useless Dump
[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;
9b373e9a 44
45 AliITSMultReconstructor multReco;
46
32e449be 47 if(!success){
48 AliWarning("Tracklets multiplicity not determined because the primary vertex was not found");
9b373e9a 49 AliWarning("Just counting the number of cluster-fired chips on the SPD layers");
50 if (!itsClusterTree) {
51 AliError(" Invalid ITS cluster tree !\n");
52 return;
53 }
54 multReco.LoadClusterFiredChips(itsClusterTree);
55 Short_t nfcL1 = multReco.GetNFiredChips(0);
56 Short_t nfcL2 = multReco.GetNFiredChips(1);
57 fMult = new AliMultiplicity(0,0,0,0,0,0,0,0,0,nfcL1,nfcL2);
32e449be 58 return;
59 }
308c2f7c 60
32e449be 61 if (!itsClusterTree) {
308c2f7c 62 AliError(" Invalid ITS cluster tree !\n");
32e449be 63 return;
64 }
65 Double_t vtx[3];
66 fCurrentVertex->GetXYZ(vtx);
67 Float_t vtxf[3];
68 for(Int_t i=0;i<3;i++)vtxf[i]=vtx[i];
9b373e9a 69 multReco.SetHistOn(kFALSE);
70 multReco.Reconstruct(itsClusterTree,vtxf,vtxf);
71 Int_t notracks=multReco.GetNTracklets();
968e8539 72 Float_t *tht = new Float_t [notracks];
32e449be 73 Float_t *phi = new Float_t [notracks];
74 Float_t *dphi = new Float_t [notracks];
de4c520e 75 Int_t *labels = new Int_t[notracks];
0939e22a 76 Int_t *labelsL2 = new Int_t[notracks];
9b373e9a 77 for(Int_t i=0;i<multReco.GetNTracklets();i++){
78 tht[i] = multReco.GetTracklet(i)[0];
79 phi[i] = multReco.GetTracklet(i)[1];
80 dphi[i] = multReco.GetTracklet(i)[2];
81 labels[i] = static_cast<Int_t>(multReco.GetTracklet(i)[3]);
82 labelsL2[i] = static_cast<Int_t>(multReco.GetTracklet(i)[4]);
32e449be 83 }
9b373e9a 84 Int_t nosingleclus=multReco.GetNSingleClusters();
968e8539 85 Float_t *ths = new Float_t [nosingleclus];
86 Float_t *phs = new Float_t [nosingleclus];
87 for(Int_t i=0;i<nosingleclus;i++){
9b373e9a 88 ths[i] = multReco.GetCluster(i)[0];
89 phs[i] = multReco.GetCluster(i)[1];
968e8539 90 }
9b373e9a 91 Short_t nfcL1 = multReco.GetNFiredChips(0);
92 Short_t nfcL2 = multReco.GetNFiredChips(1);
9b373e9a 93 fMult = new AliMultiplicity(notracks,tht,phi,dphi,labels,labelsL2,nosingleclus,ths,phs,nfcL1,nfcL2);
94
968e8539 95 delete [] tht;
32e449be 96 delete [] phi;
97 delete [] dphi;
968e8539 98 delete [] ths;
99 delete [] phs;
d6fc37c1 100 delete [] labels;
0939e22a 101 delete [] labelsL2;
308c2f7c 102
32e449be 103 return;
104}
c5f0f3c1 105
27167524 106//______________________________________________________________________
107void AliITSVertexer::SetLaddersOnLayer2(Int_t ladwid){
108 // Calculates the array of ladders on layer 2 to be used with a
109 // given ladder on layer 1
110 fLadOnLay2=ladwid;
32e63e47 111 Int_t ladtot1=AliITSgeomTGeo::GetNLadders(1);
27167524 112 if(fLadders) delete [] fLadders;
113 fLadders=new UShort_t[ladtot1];
114
115
116 Double_t pos1[3],pos2[3];
32e63e47 117 Int_t mod1=AliITSgeomTGeo::GetModuleIndex(2,1,1);
118 AliITSgeomTGeo::GetTranslation(mod1,pos1); // position of the module in the MRS
27167524 119 Double_t phi0=TMath::ATan2(pos1[1],pos1[0]);
120 if(phi0<0) phi0+=2*TMath::Pi();
32e63e47 121 Int_t mod2=AliITSgeomTGeo::GetModuleIndex(2,2,1);
122 AliITSgeomTGeo::GetTranslation(mod2,pos2);
27167524 123 Double_t phi2=TMath::ATan2(pos2[1],pos2[0]);
124 if(phi2<0) phi2+=2*TMath::Pi();
125 Double_t deltaPhi= phi0-phi2; // phi width of a layer2 module
126
127 for(Int_t i= 0; i<ladtot1;i++){
32e63e47 128 Int_t modlad= AliITSgeomTGeo::GetModuleIndex(1,i+1,1);
27167524 129 Double_t posmod[3];
32e63e47 130 AliITSgeomTGeo::GetTranslation(modlad,posmod);
27167524 131 Double_t phimod=TMath::ATan2(posmod[1],posmod[0]);
132 if(phimod<0) phimod+=2*TMath::Pi();
133 Double_t phi1= phimod+deltaPhi*double(fLadOnLay2);
134 if(phi1<0) phi1+=2*TMath::Pi();
135 if(phi1>2*TMath::Pi()) phi1-=2*TMath::Pi();
136 Double_t philad1=phi0-phi1;
137 UShort_t lad1;
138 Double_t ladder1=(philad1)/(deltaPhi) +1.;
139 if(ladder1<1){ladder1=40+ladder1;}
140 lad1=int(ladder1+0.5);
141 fLadders[i]=lad1;
142 }
143}
144
308c2f7c 145#include "AliRunLoader.h"
146
147//______________________________________________________________________
148void AliITSVertexer::Init(TString filename){
149 // Initialize the vertexer in case of
150 // analysis of an entire file
151 AliRunLoader *rl = AliRunLoader::GetRunLoader();
152 if(!rl){
153 Fatal("AliITSVertexer","Run Loader not found");
154 }
155 if (fLastEvent < 0) SetLastEvent(rl->GetNumberOfEvents()-1);
156
157 AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
158 if(!filename.Contains("default"))itsloader->SetVerticesFileName(filename);
159 if(!filename.Contains("null"))itsloader->LoadVertices("recreate");
160}
27167524 161
c5f0f3c1 162//______________________________________________________________________
163void AliITSVertexer::WriteCurrentVertex(){
164 // Write the current AliVertex object to file fOutFile
88cb7938 165 AliRunLoader *rl = AliRunLoader::GetRunLoader();
41b19549 166 AliITSLoader* itsLoader = (AliITSLoader*) rl->GetLoader("ITSLoader");
88cb7938 167 fCurrentVertex->SetName("Vertex");
168 // const char * name = fCurrentVertex->GetName();
41b19549 169 // itsLoader->SetVerticesContName(name);
170 Int_t rc = itsLoader->PostVertex(fCurrentVertex);
171 rc = itsLoader->WriteVertices();
c5f0f3c1 172}
de4c520e 173
308c2f7c 174//______________________________________________________________________
175void AliITSVertexer::FindVertices(){
176 // computes the vertices of the events in the range FirstEvent - LastEvent
177
178 AliRunLoader *rl = AliRunLoader::GetRunLoader();
179 AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
180 itsloader->LoadRecPoints("read");
181 for(Int_t i=fFirstEvent;i<=fLastEvent;i++){
182 rl->GetEvent(i);
183 TTree* cltree = itsloader->TreeR();
184 FindVertexForCurrentEvent(cltree);
185 if(fCurrentVertex){
186 WriteCurrentVertex();
187 }
188 else {
189 AliDebug(1,Form("Vertex not found for event %d",i));
190 }
191 }
192}