2 #include "AliMultiplicity.h"
3 #include "AliITSgeomTGeo.h"
4 #include "AliITSVertexer.h"
5 #include "AliITSLoader.h"
6 #include "AliITSMultReconstructor.h"
7 #include "AliITSRecPointContainer.h"
9 const Float_t AliITSVertexer::fgkPipeRadius = 3.0;
11 ClassImp(AliITSVertexer)
13 //////////////////////////////////////////////////////////////////////
14 // Base class for primary vertex reconstruction //
15 // AliESDVertexer is a class for full 3D primary vertex finding //
16 // derived classes: AliITSVertexerIons AliITSvertexer3D //
17 // AliITSVertexerCosmics //
18 //////////////////////////////////////////////////////////////////////
22 //______________________________________________________________________
23 AliITSVertexer::AliITSVertexer():AliVertexer(),
27 fMinTrackletsForPilup(0),
36 // Default Constructor
38 SetMinTrackletsForPilup();
39 for(Int_t i=0; i<kNSPDMod;i++) fUseModule[i]=kTRUE;
42 //______________________________________________________________________
43 AliITSVertexer::~AliITSVertexer() {
45 if(fLadders) delete [] fLadders;
53 //______________________________________________________________________
54 void AliITSVertexer::ResetVertex(){
55 // Resets vertex related data members
57 if(fVertArray) delete []fVertArray;
66 //______________________________________________________________________
67 void AliITSVertexer::FindMultiplicity(TTree *itsClusterTree){
68 // Invokes AliITSMultReconstructor to determine the
69 // charged multiplicity in the pixel layers
70 if(fMult){delete fMult; fMult = 0;}
72 Bool_t cosmics=kFALSE;
73 if(!fCurrentVertex)success=kFALSE;
74 if(fCurrentVertex && fCurrentVertex->GetNContributors()<1)success=kFALSE;
75 if(fCurrentVertex && strstr(fCurrentVertex->GetTitle(),"cosmics")) {
80 // get the FastOr bit mask
81 TBits fastOrFiredMap = fDetTypeRec->GetFastOrFiredMap();
83 AliITSMultReconstructor multReco;
87 AliWarning("Tracklets multiplicity not determined because the primary vertex was not found");
88 AliWarning("Just counting the number of cluster-fired chips on the SPD layers");
90 if (!itsClusterTree) {
91 AliError(" Invalid ITS cluster tree !\n");
94 multReco.LoadClusterFiredChips(itsClusterTree);
95 Short_t nfcL1 = multReco.GetNFiredChips(0);
96 Short_t nfcL2 = multReco.GetNFiredChips(1);
97 fMult = new AliMultiplicity(0,0,0,0,0,0,0,0,0,0,nfcL1,nfcL2,fastOrFiredMap);
98 AliITSRecPointContainer* rcont = AliITSRecPointContainer::Instance();
99 fMult->SetITSClusters(0,rcont->GetNClustersInLayer(1,itsClusterTree));
100 for(Int_t kk=2;kk<=6;kk++){
101 fMult->SetITSClusters(kk-1,rcont->GetNClustersInLayerFast(kk));
106 if (!itsClusterTree) {
107 AliError(" Invalid ITS cluster tree !\n");
111 fCurrentVertex->GetXYZ(vtx);
113 for(Int_t i=0;i<3;i++)vtxf[i]=vtx[i];
114 multReco.SetHistOn(kFALSE);
115 multReco.Reconstruct(itsClusterTree,vtxf,vtxf);
116 Int_t notracks=multReco.GetNTracklets();
117 Float_t *tht = new Float_t [notracks];
118 Float_t *phi = new Float_t [notracks];
119 Float_t *dtht = new Float_t [notracks];
120 Float_t *dphi = new Float_t [notracks];
121 Int_t *labels = new Int_t[notracks];
122 Int_t *labelsL2 = new Int_t[notracks];
123 for(Int_t i=0;i<multReco.GetNTracklets();i++){
124 tht[i] = multReco.GetTracklet(i)[0];
125 phi[i] = multReco.GetTracklet(i)[1];
126 dtht[i] = multReco.GetTracklet(i)[3];
127 dphi[i] = multReco.GetTracklet(i)[2];
128 labels[i] = static_cast<Int_t>(multReco.GetTracklet(i)[4]);
129 labelsL2[i] = static_cast<Int_t>(multReco.GetTracklet(i)[5]);
131 Int_t nosingleclus=multReco.GetNSingleClusters();
132 Float_t *ths = new Float_t [nosingleclus];
133 Float_t *phs = new Float_t [nosingleclus];
134 for(Int_t i=0;i<nosingleclus;i++){
135 ths[i] = multReco.GetCluster(i)[0];
136 phs[i] = multReco.GetCluster(i)[1];
138 Short_t nfcL1 = multReco.GetNFiredChips(0);
139 Short_t nfcL2 = multReco.GetNFiredChips(1);
140 fMult = new AliMultiplicity(notracks,tht,phi,dtht,dphi,labels,labelsL2,nosingleclus,ths,phs,nfcL1,nfcL2,fastOrFiredMap);
141 AliITSRecPointContainer* rcont = AliITSRecPointContainer::Instance();
142 fMult->SetITSClusters(0,rcont->GetNClustersInLayer(1,itsClusterTree));
143 for(Int_t kk=2;kk<=6;kk++){
144 fMult->SetITSClusters(kk-1,rcont->GetNClustersInLayerFast(kk));
158 //______________________________________________________________________
159 void AliITSVertexer::SetLaddersOnLayer2(Int_t ladwid){
160 // Calculates the array of ladders on layer 2 to be used with a
161 // given ladder on layer 1
163 Int_t ladtot1=AliITSgeomTGeo::GetNLadders(1);
164 if(fLadders) delete [] fLadders;
165 fLadders=new UShort_t[ladtot1];
168 Double_t pos1[3],pos2[3];
169 Int_t mod1=AliITSgeomTGeo::GetModuleIndex(2,1,1);
170 AliITSgeomTGeo::GetTranslation(mod1,pos1); // position of the module in the MRS
171 Double_t phi0=TMath::ATan2(pos1[1],pos1[0]);
172 if(phi0<0) phi0+=2*TMath::Pi();
173 Int_t mod2=AliITSgeomTGeo::GetModuleIndex(2,2,1);
174 AliITSgeomTGeo::GetTranslation(mod2,pos2);
175 Double_t phi2=TMath::ATan2(pos2[1],pos2[0]);
176 if(phi2<0) phi2+=2*TMath::Pi();
177 Double_t deltaPhi= phi0-phi2; // phi width of a layer2 module
179 for(Int_t i= 0; i<ladtot1;i++){
180 Int_t modlad= AliITSgeomTGeo::GetModuleIndex(1,i+1,1);
182 AliITSgeomTGeo::GetTranslation(modlad,posmod);
183 Double_t phimod=TMath::ATan2(posmod[1],posmod[0]);
184 if(phimod<0) phimod+=2*TMath::Pi();
185 Double_t phi1= phimod+deltaPhi*double(fLadOnLay2);
186 if(phi1<0) phi1+=2*TMath::Pi();
187 if(phi1>2*TMath::Pi()) phi1-=2*TMath::Pi();
188 Double_t philad1=phi0-phi1;
190 Double_t ladder1=(philad1)/(deltaPhi) +1.;
191 if(ladder1<1){ladder1=40+ladder1;}
192 lad1=int(ladder1+0.5);
197 #include "AliRunLoader.h"
199 //______________________________________________________________________
200 void AliITSVertexer::Init(TString filename){
201 // Initialize the vertexer in case of
202 // analysis of an entire file
203 AliRunLoader *rl = AliRunLoader::Instance();
205 Fatal("AliITSVertexer","Run Loader not found");
207 if (fLastEvent < 0) SetLastEvent(rl->GetNumberOfEvents()-1);
209 AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
210 if(!filename.Contains("default"))itsloader->SetVerticesFileName(filename);
211 if(!filename.Contains("null"))itsloader->LoadVertices("recreate");
214 //______________________________________________________________________
215 void AliITSVertexer::WriteCurrentVertex(){
216 // Write the current AliVertex object to file fOutFile
217 AliRunLoader *rl = AliRunLoader::Instance();
218 AliITSLoader* itsLoader = (AliITSLoader*) rl->GetLoader("ITSLoader");
219 fCurrentVertex->SetName("Vertex");
220 // const char * name = fCurrentVertex->GetName();
221 // itsLoader->SetVerticesContName(name);
222 Int_t rc = itsLoader->PostVertex(fCurrentVertex);
223 rc = itsLoader->WriteVertices();
226 //______________________________________________________________________
227 void AliITSVertexer::FindVertices(){
228 // computes the vertices of the events in the range FirstEvent - LastEvent
230 AliRunLoader *rl = AliRunLoader::Instance();
231 AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
232 itsloader->LoadRecPoints("read");
233 for(Int_t i=fFirstEvent;i<=fLastEvent;i++){
235 TTree* cltree = itsloader->TreeR();
236 FindVertexForCurrentEvent(cltree);
238 WriteCurrentVertex();
241 AliDebug(1,Form("Vertex not found for event %d",i));