1 #if !defined(__CINT__) || defined(__MAKECINT__)
3 #include "TGeoManager.h"
4 #include "TInterpreter.h"
5 #include "TClassTable.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"
22 #include "AliRunLoader.h"
23 #include "AliGenEventHeader.h"
29 Bool_t DoVerticesSPD(Int_t optdebug=1){
31 TFile *fint = new TFile("VertexSPD.root","recreate");
32 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:is3D");
34 if (gClassTable->GetID("AliRun") < 0) {
35 gInterpreter->ExecuteMacro("loadlibs.C");
38 AliCDBManager* man = AliCDBManager::Instance();
39 if (!man->IsDefaultStorageSet()) {
40 printf("Setting a local default storage and run number 0\n");
41 man->SetDefaultStorage("local://$ALICE_ROOT");
45 printf("Using deafult storage \n");
50 AliGeomManager::LoadGeometry("geometry.root");
53 AliRunLoader* runLoader = AliRunLoader::Open("galice.root");
55 Error("DoVertices", "getting run loader from file %s failed",
59 runLoader->LoadgAlice();
60 gAlice = runLoader->GetAliRun();
62 Error("DoVertices", "no galice object found");
65 runLoader->LoadKinematics();
66 runLoader->LoadHeader();
67 AliITSLoader* ITSloader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
68 ITSloader->LoadRecPoints("read");
70 AliMagF * magf = gAlice->Field();
71 AliTracker::SetFieldMap(magf,kTRUE);
72 if(optdebug) printf("MagneticField=%f\n",AliTracker::GetBz());
74 Int_t totev=runLoader->GetNumberOfEvents();
75 if(optdebug) printf("Number of events= %d\n",totev);
78 Double_t xnom=0.,ynom=0.;
80 AliITSVertexerZ *vertz = new AliITSVertexerZ(xnom,ynom);
81 vertz->Init("default");
82 AliITSVertexer3D *vert3d = new AliITSVertexer3D();
83 vert3d->Init("default");
84 vert3d->SetWideFiducialRegion(40.,1.);
85 vert3d->PrintStatus();
87 /* uncomment these lines to use diamond constrain */
88 // Double_t posdiam[3]={0.03,0.1,0.};
89 // Double_t sigdiam[3]={0.01,0.01,10.0};
90 // AliESDVertex* diam=new AliESDVertex(posdiam,sigdiam);
91 // vertz->SetVtxStart(diam);
92 // vert3d->SetVtxStart(diam);
93 /* end lines to be uncommented to use diamond constrain */
95 Int_t goodz=0,good3d=0;
97 for (Int_t iEvent = 0; iEvent < totev; iEvent++) {
99 runLoader->GetEvent(iEvent);
100 runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
101 AliGenPythiaEventHeader *evh=(AliGenPythiaEventHeader*)runLoader->GetHeader()->GenEventHeader();
102 Int_t ptype = evh->ProcessType();
104 printf("==============================================================\n");
105 printf("\nEvent: %d ---- Process Type = %d \n",iEvent,ptype);
108 AliStack* stack = runLoader->Stack();
109 TTree *treek=(TTree*)runLoader->TreeK();
110 Int_t npart = (Int_t)treek->GetEntries();
111 if(optdebug) printf("particles %d\n",npart);
113 Double_t dNchdy = 0.;
115 // loop on particles to get generated dN/dy
116 for(Int_t iPart=0; iPart<npart; iPart++) {
117 if(!stack->IsPhysicalPrimary(iPart)) continue;
118 TParticle* part = (TParticle*)stack->Particle(iPart);
119 if(part->GetPDG()->Charge() == 0) continue;
120 Double_t eta=part->Eta();
122 if(TMath::Abs(eta)<1.5) dNchdy+=1.;
124 if(optdebug) printf(" dNch/dy = %f\n",dNchdy);
126 TTree* cltree = ITSloader->TreeR();
128 AliESDVertex* vtxz = vertz->FindVertexForCurrentEvent(cltree);
129 AliESDVertex* vtx3d = vert3d->FindVertexForCurrentEvent(cltree);
130 AliMultiplicity *alimult = vert3d->GetMultiplicity();
134 ntrklets=alimult->GetNumberOfTracklets() ;
135 nrecp1=ntrklets+alimult->GetNumberOfSingleClusters();
137 TString tit=vtx3d->GetTitle();
139 if(tit.Contains("3D")) is3d=kTRUE;
143 TDirectory *current = gDirectory;
149 Double_t zdiffz = 0.;
154 ntrkz = vtxz->GetNContributors();
157 zresz =vtxz->GetZRes(); // microns
158 zdiffz = 10000.*(zz-mcVertex[2]); // microns
162 Double_t xerr3d = 0.;
163 Double_t xdiff3d = 0.;
166 Double_t yerr3d = 0.;
167 Double_t ydiff3d = 0.;
170 Double_t zerr3d = 0.;
171 Double_t zdiff3d = 0.;
176 ntrk3d = vtx3d->GetNContributors();
177 if(is3d && ntrk3d>0)good3d++;
178 x3d = vtx3d->GetXv();
179 xerr3d=vtx3d->GetXRes();
180 xdiff3d = 10000.*(x3d-mcVertex[0]); // microns
182 y3d = vtx3d->GetYv();
183 yerr3d=vtx3d->GetYRes();
184 ydiff3d = 10000.*(y3d-mcVertex[1]); // microns
186 z3d = vtx3d->GetZv();
187 zerr3d=vtx3d->GetZRes();
188 zdiff3d = 10000.*(z3d-mcVertex[2]); // microns
192 xnt[0]=mcVertex[0];//x
193 xnt[1]=mcVertex[1];//y
194 xnt[2]=mcVertex[2];//z
213 xnt[18]=float(ntrklets);
214 xnt[19]=float(nrecp1);
215 xnt[20]=float(ptype);
221 printf("\nVertexerZ: \tz(cm)=%9.5f \tTracklets=%d \tztrue(cm)=%9.5f \tzdiff(um)=%8.2f\n",zz,ntrkz,mcVertex[2],zdiffz);
222 printf("Vertexer3D: \tz(cm)=%9.5f \tTracklets=%d \tztrue(cm)=%9.5f \tzdiff(um)=%8.2f\n",z3d,ntrk3d,mcVertex[2],zdiff3d);
231 printf("***********************************************\n");
232 printf("Number of Z vertices found= %d\n",goodz);
233 printf("efficiency=%f\n",float(goodz)/float(totev));
234 printf("Number of 3D vertices found= %d\n",good3d);
235 printf("efficiency=%f\n",float(good3d)/float(totev));