]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/DoVerticesSPD.C
Updated geometry
[u/mrichter/AliRoot.git] / ITS / DoVerticesSPD.C
CommitLineData
f5826889 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include "TFile.h"
3#include "TGeoManager.h"
4#include "TInterpreter.h"
5#include "TClassTable.h"
6#include "TNtuple.h"
7#include "TTree.h"
8#include "TArrayF.h"
9#include "TParticle.h"
10#include "AliESD.h"
11#include "AliGenPythiaEventHeader.h"
12#include "AliTracker.h"
13#include "AliHeader.h"
14#include "AliITSLoader.h"
15#include "AliVertexerTracks.h"
16#include "AliCDBManager.h"
17#include "AliGeomManager.h"
18#include "AliITSVertexer3D.h"
19#include "AliITSVertexerZ.h"
20#include "AliESDVertex.h"
21#include "AliRun.h"
22#include "AliRunLoader.h"
23#include "AliGenEventHeader.h"
24#include "AliStack.h"
25#endif
26
27/* $Id$ */
28
29Bool_t DoVerticesSPD(Int_t optdebug=1){
30 TFile *fint = new TFile("VertexSPD.root","recreate");
31 TNtuple *nt = new TNtuple("ntvert","vertices","xtrue:ytrue:ztrue:zZ:zdiffZ:zerrZ:ntrksZ:x3D:xdiff3D:xerr3D:y3D:ydiff3D:yerr3D:z3D:zdiff3D:zerr3D:ntrks3D:dndy:ntrklets:nrp1:ptyp");
32
33 if (gClassTable->GetID("AliRun") < 0) {
34 gInterpreter->ExecuteMacro("loadlibs.C");
35 }
36 // Set OCDB if needed
37 AliCDBManager* man = AliCDBManager::Instance();
38 if (!man->IsDefaultStorageSet()) {
39 printf("Setting a local default storage and run number 0\n");
40 man->SetDefaultStorage("local://$ALICE_ROOT");
41 man->SetRun(0);
42 }
43 else {
44 printf("Using deafult storage \n");
45 }
46
47 // retrives geometry
48 if(!gGeoManager){
49 AliGeomManager::LoadGeometry("geometry.root");
50 }
51
52 AliRunLoader* runLoader = AliRunLoader::Open("galice.root");
53 if (!runLoader) {
54 Error("DoVertices", "getting run loader from file %s failed",
55 "galice.root");
56 return kFALSE;
57 }
58 runLoader->LoadgAlice();
59 gAlice = runLoader->GetAliRun();
60 if (!gAlice) {
61 Error("DoVertices", "no galice object found");
62 return kFALSE;
63 }
64 runLoader->LoadKinematics();
65 runLoader->LoadHeader();
66 AliITSLoader* ITSloader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
67 ITSloader->LoadRecPoints("read");
68
69 AliMagF * magf = gAlice->Field();
70 AliTracker::SetFieldMap(magf,kTRUE);
71 if(optdebug) printf("MagneticField=%f\n",AliTracker::GetBz());
72
73 Int_t totev=runLoader->GetNumberOfEvents();
74 if(optdebug) printf("Number of events= %d\n",totev);
75
76
f5826889 77 Double_t xnom=0.,ynom=0.;
ecce5370 78
308c2f7c 79 AliITSVertexerZ *vertz = new AliITSVertexerZ(xnom,ynom);
80 vertz->Init("default");
81 AliITSVertexer3D *vert3d = new AliITSVertexer3D();
82 vert3d->Init("default");
ecce5370 83
84 /* uncomment these lines to use diamond constrain */
85// Double_t posdiam[3]={0.03,0.1,0.};
86// Double_t sigdiam[3]={0.01,0.01,10.0};
87// AliESDVertex* diam=new AliESDVertex(posdiam,sigdiam);
88// vertz->SetVtxStart(diam);
89// vert3d->SetVtxStart(diam);
90 /* end lines to be uncommented to use diamond constrain */
f5826889 91
92 Int_t goodz=0,good3d=0;
93
94 for (Int_t iEvent = 0; iEvent < totev; iEvent++) {
95 TArrayF mcVertex(3);
96 runLoader->GetEvent(iEvent);
97 runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
98 AliGenPythiaEventHeader *evh=(AliGenPythiaEventHeader*)runLoader->GetHeader()->GenEventHeader();
99 Int_t ptype = evh->ProcessType();
100 if(optdebug){
101 printf("==============================================================\n");
102 printf("\nEvent: %d ---- Process Type = %d \n",iEvent,ptype);
103 }
104
105 AliStack* stack = runLoader->Stack();
106 TTree *treek=(TTree*)runLoader->TreeK();
107 Int_t npart = (Int_t)treek->GetEntries();
108 if(optdebug) printf("particles %d\n",npart);
109
110 Double_t dNchdy = 0.;
111
ecce5370 112 // loop on particles to get generated dN/dy
113 for(Int_t iPart=0; iPart<npart; iPart++) {
114 if(!stack->IsPhysicalPrimary(iPart)) continue;
115 TParticle* part = (TParticle*)stack->Particle(iPart);
116 if(part->GetPDG()->Charge() == 0) continue;
117 Double_t eta=part->Eta();
f5826889 118
ecce5370 119 if(TMath::Abs(eta)<1.5) dNchdy+=1.;
f5826889 120 }
121 if(optdebug) printf(" dNch/dy = %f\n",dNchdy);
122
308c2f7c 123 TTree* cltree = ITSloader->TreeR();
124
125 AliESDVertex* vtxz = vertz->FindVertexForCurrentEvent(cltree);
ecce5370 126 AliESDVertex* vtx3d = vert3d->FindVertexForCurrentEvent(cltree);
127
128 AliMultiplicity *alimult = vert3d->GetMultiplicity();
f5826889 129 Int_t ntrklets=0,nrecp1=0;
130 if(alimult) {
131 nrecp1=alimult->GetNumberOfTracklets() ;
132 ntrklets = alimult->GetNumberOfTracklets();
133 for(Int_t l=0;l<alimult->GetNumberOfTracklets();l++){
134 if(alimult->GetDeltaPhi(l)<-9998.) ntrklets--;
135 }
136 }
137
ecce5370 138
139
f5826889 140
141 TDirectory *current = gDirectory;
142 fint->cd();
143 Float_t xnt[21];
144
145 Double_t zz = 0.;
146 Double_t zresz = 0.;
147 Double_t zdiffz = 0.;
148
149 Int_t ntrkz = 0;
150 if(vtxz){
151
152 ntrkz = vtxz->GetNContributors();
153 if(ntrkz>0)goodz++;
154 zz=vtxz->GetZv();
155 zresz =vtxz->GetZRes(); // microns
156 zdiffz = 10000.*(zz-mcVertex[2]); // microns
157 }
158
159 Double_t x3d = 0.;
160 Double_t xerr3d = 0.;
161 Double_t xdiff3d = 0.;
162
163 Double_t y3d = 0.;
164 Double_t yerr3d = 0.;
165 Double_t ydiff3d = 0.;
166
167 Double_t z3d = 0.;
168 Double_t zerr3d = 0.;
169 Double_t zdiff3d = 0.;
170
171 Int_t ntrk3d = 0;
172 if(vtx3d){
173
174 ntrk3d = vtx3d->GetNContributors();
175 if(ntrk3d>0)good3d++;
176 x3d = vtx3d->GetXv();
177 xerr3d=vtx3d->GetXRes();
178 xdiff3d = 10000.*(x3d-mcVertex[0]); // microns
179
180 y3d = vtx3d->GetYv();
181 yerr3d=vtx3d->GetYRes();
182 ydiff3d = 10000.*(y3d-mcVertex[1]); // microns
183
184 z3d = vtx3d->GetZv();
185 zerr3d=vtx3d->GetZRes();
186 zdiff3d = 10000.*(z3d-mcVertex[2]); // microns
187
188 }
189
190 xnt[0]=mcVertex[0];//x
191 xnt[1]=mcVertex[1];//y
192 xnt[2]=mcVertex[2];//z
193
194 xnt[3]=zz;
195 xnt[4]=zdiffz;
196 xnt[5]=zresz;
197 xnt[6]=ntrkz;
198
199 xnt[7]=x3d;
200 xnt[8]=xdiff3d;
201 xnt[9]=xerr3d;
202 xnt[11]=y3d;
203 xnt[11]=ydiff3d;
204 xnt[12]=yerr3d;
205 xnt[13]=z3d;
206 xnt[14]=zdiff3d;
207 xnt[15]=zerr3d;
208 xnt[16]=ntrk3d;
209
210 xnt[17]=dNchdy;
211 xnt[18]=float(ntrklets);
212 xnt[19]=float(nrecp1);
213 xnt[20]=float(ptype);
214 nt->Fill(xnt);
215 current->cd();
216
217 if(optdebug){
218 printf("\nVertexerZ: \tz(cm)=%9.5f \tTracklets=%d \tztrue(cm)=%9.5f \tzdiff(um)=%8.2f\n",zz,ntrkz,mcVertex[2],zdiffz);
219 printf("Vertexer3D: \tz(cm)=%9.5f \tTracklets=%d \tztrue(cm)=%9.5f \tzdiff(um)=%8.2f\n",z3d,ntrk3d,mcVertex[2],zdiff3d);
220 }
221
222 }
223 fint->cd();
224 nt->Write();
225 fint->Close();
226 delete fint;
227 if(optdebug){
228 printf("***********************************************\n");
229 printf("Number of Z vertices found= %d\n",goodz);
230 printf("efficiency=%f\n",float(goodz)/float(totev));
231 printf("Number of 3D vertices found= %d\n",good3d);
232 printf("efficiency=%f\n",float(good3d)/float(totev));
233 }
234 return kTRUE;
235}