1 #include <AliESDVertex.h>
2 #include "AliITSgeom.h"
3 #include "AliITSVertexer.h"
4 #include "AliRunLoader.h"
5 #include "AliITSLoader.h"
6 #include "AliMultiplicity.h"
7 #include "AliITSMultReconstructor.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 AliITSvertexerPPZ //
17 // AliITSVertexer3D //
18 //////////////////////////////////////////////////////////////////////
20 //______________________________________________________________________
21 AliITSVertexer::AliITSVertexer():AliVertexer(),
24 // Default Constructor
28 AliITSVertexer::AliITSVertexer(TString filename):AliVertexer(),
32 // Standard constructor
33 AliRunLoader *rl = AliRunLoader::GetRunLoader();
35 Fatal("AliITSVertexer","Run Loader not found");
39 Fatal("AliITSVertexer","The AliRun object is not available - nothing done");
46 AliITSLoader* itsLoader = (AliITSLoader*) rl->GetLoader("ITSLoader");
47 if(!filename.Contains("default"))itsLoader->SetVerticesFileName(filename);
48 if(!filename.Contains("null"))itsLoader->LoadVertices("recreate");
49 itsLoader->LoadRecPoints();
51 SetLastEvent(rl->GetNumberOfEvents()-1);
54 lst = static_cast<Int_t>(rl->TreeE()->GetEntries());
61 //______________________________________________________________________
62 AliITSVertexer::AliITSVertexer(const AliITSVertexer &vtxr) : AliVertexer(vtxr) {
64 // Copies are not allowed. The method is protected to avoid misuse.
65 Error("AliITSVertexer","Copy constructor not allowed\n");
68 //______________________________________________________________________
69 AliITSVertexer& AliITSVertexer::operator=(const AliITSVertexer& /* vtxr */){
70 // Assignment operator
71 // Assignment is not allowed. The method is protected to avoid misuse.
72 Error("= operator","Assignment operator not allowed\n");
76 //______________________________________________________________________
77 AliITSVertexer::~AliITSVertexer() {
79 if(fLadders) delete [] fLadders;
82 //______________________________________________________________________
83 void AliITSVertexer::FindMultiplicity(Int_t evnumber){
84 // Invokes AliITSMultReconstructor to determine the
85 // charged multiplicity in the pixel layers
86 if(fMult){delete fMult; fMult = 0;}
88 if(!fCurrentVertex)success=kFALSE;
89 if(fCurrentVertex && fCurrentVertex->GetNContributors()<1)success=kFALSE;
91 AliWarning("Tracklets multiplicity not determined because the primary vertex was not found");
94 AliITSMultReconstructor* multReco = new AliITSMultReconstructor();
95 AliRunLoader *rl =AliRunLoader::GetRunLoader();
96 AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader");
97 multReco->SetGeometry(itsLoader->GetITSgeom());
98 itsLoader->LoadRecPoints();
99 rl->GetEvent(evnumber);
100 TTree* itsClusterTree = itsLoader->TreeR();
101 if (!itsClusterTree) {
102 AliError(" Can't get the ITS cluster tree !\n");
106 fCurrentVertex->GetXYZ(vtx);
108 for(Int_t i=0;i<3;i++)vtxf[i]=vtx[i];
109 multReco->SetHistOn(kFALSE);
110 multReco->Reconstruct(itsClusterTree,vtxf,vtxf);
111 Int_t notracks=multReco->GetNTracklets();
112 Float_t *tht = new Float_t [notracks];
113 Float_t *phi = new Float_t [notracks];
114 Float_t *dphi = new Float_t [notracks];
115 for(Int_t i=0;i<multReco->GetNTracklets();i++){
116 tht[i] = multReco->GetTracklet(i)[0];
117 phi[i] = multReco->GetTracklet(i)[1];
118 dphi[i] = multReco->GetTracklet(i)[2];
120 Int_t nosingleclus=multReco->GetNSingleClusters();
121 Float_t *ths = new Float_t [nosingleclus];
122 Float_t *phs = new Float_t [nosingleclus];
123 for(Int_t i=0;i<nosingleclus;i++){
124 ths[i] = multReco->GetCluster(i)[0];
125 phs[i] = multReco->GetCluster(i)[1];
127 fMult = new AliMultiplicity(notracks,tht,phi,dphi,nosingleclus,ths,phs);
133 itsLoader->UnloadRecPoints();
138 //______________________________________________________________________
139 void AliITSVertexer::SetLaddersOnLayer2(Int_t ladwid){
140 // Calculates the array of ladders on layer 2 to be used with a
141 // given ladder on layer 1
143 AliRunLoader *rl =AliRunLoader::GetRunLoader();
144 AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader");
145 AliITSgeom* geom = itsLoader->GetITSgeom();
146 Int_t ladtot1=geom->GetNladders(1);
147 if(fLadders) delete [] fLadders;
148 fLadders=new UShort_t[ladtot1];
151 Double_t pos1[3],pos2[3];
152 Int_t mod1=geom->GetModuleIndex(2,1,1);
153 geom->GetTrans(mod1,pos1); // position of the module in the MRS
154 Double_t phi0=TMath::ATan2(pos1[1],pos1[0]);
155 if(phi0<0) phi0+=2*TMath::Pi();
156 Int_t mod2=geom->GetModuleIndex(2,2,1);
157 geom->GetTrans(mod2,pos2);
158 Double_t phi2=TMath::ATan2(pos2[1],pos2[0]);
159 if(phi2<0) phi2+=2*TMath::Pi();
160 Double_t deltaPhi= phi0-phi2; // phi width of a layer2 module
162 for(Int_t i= 0; i<ladtot1;i++){
163 Int_t modlad= geom->GetModuleIndex(1,i+1,1);
165 geom->GetTrans(modlad,posmod);
166 Double_t phimod=TMath::ATan2(posmod[1],posmod[0]);
167 if(phimod<0) phimod+=2*TMath::Pi();
168 Double_t phi1= phimod+deltaPhi*double(fLadOnLay2);
169 if(phi1<0) phi1+=2*TMath::Pi();
170 if(phi1>2*TMath::Pi()) phi1-=2*TMath::Pi();
171 Double_t philad1=phi0-phi1;
173 Double_t ladder1=(philad1)/(deltaPhi) +1.;
174 if(ladder1<1){ladder1=40+ladder1;}
175 lad1=int(ladder1+0.5);
181 //______________________________________________________________________
182 void AliITSVertexer::WriteCurrentVertex(){
183 // Write the current AliVertex object to file fOutFile
184 AliRunLoader *rl = AliRunLoader::GetRunLoader();
185 AliITSLoader* itsLoader = (AliITSLoader*) rl->GetLoader("ITSLoader");
186 fCurrentVertex->SetName("Vertex");
187 // const char * name = fCurrentVertex->GetName();
188 // itsLoader->SetVerticesContName(name);
189 Int_t rc = itsLoader->PostVertex(fCurrentVertex);
190 rc = itsLoader->WriteVertices();