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 "AliITSDetTypeRec.h"
19 #include "AliITSVertexer3D.h"
20 #include "AliITSVertexerZ.h"
21 #include "AliESDVertex.h"
23 #include "AliRunLoader.h"
24 #include "AliGenEventHeader.h"
30 Bool_t DoVerticesSPD(Int_t optdebug=1){
32 TFile *fint = new TFile("VertexSPD.root","recreate");
33 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");
35 if (gClassTable->GetID("AliRun") < 0) {
36 gInterpreter->ExecuteMacro("loadlibs.C");
39 AliCDBManager* man = AliCDBManager::Instance();
40 if (!man->IsDefaultStorageSet()) {
41 printf("Setting a local default storage and run number 0\n");
42 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
46 printf("Using deafult storage \n");
51 AliGeomManager::LoadGeometry("geometry.root");
54 AliRunLoader* runLoader = AliRunLoader::Open("galice.root");
56 Error("DoVertices", "getting run loader from file %s failed",
60 runLoader->LoadgAlice();
61 gAlice = runLoader->GetAliRun();
63 Error("DoVertices", "no galice object found");
66 runLoader->LoadKinematics();
67 runLoader->LoadHeader();
68 AliITSLoader* ITSloader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
69 ITSloader->LoadRecPoints("read");
71 AliMagF * magf = gAlice->Field();
72 AliTracker::SetFieldMap(magf,kTRUE);
73 if(optdebug) printf("MagneticField=%f\n",AliTracker::GetBz());
75 Int_t totev=runLoader->GetNumberOfEvents();
76 if(optdebug) printf("Number of events= %d\n",totev);
78 AliITSDetTypeRec* detTypeRec = new AliITSDetTypeRec();
80 Double_t xnom=0.,ynom=0.;
81 AliITSVertexerZ *vertz = new AliITSVertexerZ(xnom,ynom);
82 vertz->Init("default");
83 AliITSVertexer3D *vert3d = new AliITSVertexer3D();
84 vert3d->Init("default");
85 vert3d->SetWideFiducialRegion(40.,1.);
86 vert3d->PrintStatus();
87 vertz->SetDetTypeRec(detTypeRec);
88 vert3d->SetDetTypeRec(detTypeRec);
90 /* uncomment these lines to use diamond constrain */
91 // Double_t posdiam[3]={0.03,0.1,0.};
92 // Double_t sigdiam[3]={0.01,0.01,10.0};
93 // AliESDVertex* diam=new AliESDVertex(posdiam,sigdiam);
94 // vertz->SetVtxStart(diam);
95 // vert3d->SetVtxStart(diam);
96 /* end lines to be uncommented to use diamond constrain */
98 Int_t goodz=0,good3d=0;
100 for (Int_t iEvent = 0; iEvent < totev; iEvent++) {
102 runLoader->GetEvent(iEvent);
103 runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
104 AliGenPythiaEventHeader *evh=(AliGenPythiaEventHeader*)runLoader->GetHeader()->GenEventHeader();
105 Int_t ptype = evh->ProcessType();
107 printf("==============================================================\n");
108 printf("\nEvent: %d ---- Process Type = %d \n",iEvent,ptype);
111 AliStack* stack = runLoader->Stack();
112 TTree *treek=(TTree*)runLoader->TreeK();
113 Int_t npart = (Int_t)treek->GetEntries();
114 if(optdebug) printf("particles %d\n",npart);
116 Double_t dNchdy = 0.;
118 // loop on particles to get generated dN/dy
119 for(Int_t iPart=0; iPart<npart; iPart++) {
120 if(!stack->IsPhysicalPrimary(iPart)) continue;
121 TParticle* part = (TParticle*)stack->Particle(iPart);
122 if(part->GetPDG()->Charge() == 0) continue;
123 Double_t eta=part->Eta();
125 if(TMath::Abs(eta)<1.5) dNchdy+=1.;
127 if(optdebug) printf(" dNch/dy = %f\n",dNchdy);
129 TTree* cltree = ITSloader->TreeR();
131 AliESDVertex* vtxz = vertz->FindVertexForCurrentEvent(cltree);
132 AliESDVertex* vtx3d = vert3d->FindVertexForCurrentEvent(cltree);
133 AliMultiplicity *alimult = vert3d->GetMultiplicity();
137 ntrklets=alimult->GetNumberOfTracklets() ;
138 nrecp1=ntrklets+alimult->GetNumberOfSingleClusters();
140 TString tit=vtx3d->GetTitle();
142 if(tit.Contains("3D")) is3d=kTRUE;
146 TDirectory *current = gDirectory;
152 Double_t zdiffz = 0.;
157 ntrkz = vtxz->GetNContributors();
160 zresz =vtxz->GetZRes(); // microns
161 zdiffz = 10000.*(zz-mcVertex[2]); // microns
165 Double_t xerr3d = 0.;
166 Double_t xdiff3d = 0.;
169 Double_t yerr3d = 0.;
170 Double_t ydiff3d = 0.;
173 Double_t zerr3d = 0.;
174 Double_t zdiff3d = 0.;
179 ntrk3d = vtx3d->GetNContributors();
180 if(is3d && ntrk3d>0)good3d++;
181 x3d = vtx3d->GetXv();
182 xerr3d=vtx3d->GetXRes();
183 xdiff3d = 10000.*(x3d-mcVertex[0]); // microns
185 y3d = vtx3d->GetYv();
186 yerr3d=vtx3d->GetYRes();
187 ydiff3d = 10000.*(y3d-mcVertex[1]); // microns
189 z3d = vtx3d->GetZv();
190 zerr3d=vtx3d->GetZRes();
191 zdiff3d = 10000.*(z3d-mcVertex[2]); // microns
195 xnt[0]=mcVertex[0];//x
196 xnt[1]=mcVertex[1];//y
197 xnt[2]=mcVertex[2];//z
216 xnt[18]=float(ntrklets);
217 xnt[19]=float(nrecp1);
218 xnt[20]=float(ptype);
224 printf("\nVertexerZ: \tz(cm)=%9.5f \tTracklets=%d \tztrue(cm)=%9.5f \tzdiff(um)=%8.2f\n",zz,ntrkz,mcVertex[2],zdiffz);
225 printf("Vertexer3D: \tz(cm)=%9.5f \tTracklets=%d \tztrue(cm)=%9.5f \tzdiff(um)=%8.2f\n",z3d,ntrk3d,mcVertex[2],zdiff3d);
234 printf("***********************************************\n");
235 printf("Number of Z vertices found= %d\n",goodz);
236 printf("efficiency=%f\n",float(goodz)/float(totev));
237 printf("Number of 3D vertices found= %d\n",good3d);
238 printf("efficiency=%f\n",float(good3d)/float(totev));