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