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