Add run number and timestamp to ntuple
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 12 Nov 2009 18:43:01 +0000 (18:43 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 12 Nov 2009 18:43:01 +0000 (18:43 +0000)
PWG1/global/AliAnalysisTaskVertexESD.cxx
PWG1/global/AliAnalysisTaskVertexESD.h
PWG1/macros/PlotVertexESD.C

index 660c273..e4f4743 100644 (file)
@@ -123,7 +123,7 @@ void AliAnalysisTaskVertexESD::CreateOutputObjects()
   fOutput = new TList;
   fOutput->SetOwner();
 
-  fNtupleVertexESD = new TNtuple("fNtupleVertexESD","vertices","xtrue:ytrue:ztrue:xSPD:xdiffSPD:xerrSPD:ySPD:ydiffSPD:yerrSPD:zSPD:zdiffSPD:zerrSPD:ntrksSPD:xTPC:xdiffTPC:xerrTPC:yTPC:ydiffTPC:yerrTPC:zTPC:zdiffTPC:zerrTPC:ntrksTPC:xTRK:xdiffTRK:xerrTRK:yTRK:ydiffTRK:yerrTRK:zTRK:zdiffTRK:zerrTRK:ntrksTRK:ntrklets:nESDtracks:nITSrefit5or6:nTPCin:nTPCinEta09:dndygen:triggered:SPD3D:SPD0cls:constrTRK");
+  fNtupleVertexESD = new TNtuple("fNtupleVertexESD","vertices","run:tstamp:xtrue:ytrue:ztrue:xSPD:xerrSPD:ySPD:yerrSPD:zSPD:zerrSPD:ntrksSPD:xTPC:xerrTPC:yTPC:yerrTPC:zTPC:zerrTPC:ntrksTPC:xTRK:xerrTRK:yTRK:yerrTRK:zTRK:zerrTRK:ntrksTRK:ntrklets:nESDtracks:nITSrefit5or6:nTPCin:nTPCinEta09:dndygen:triggered:SPD3D:SPD0cls:constrTRK:constrTPC");
 
   fOutput->Add(fNtupleVertexESD);
 
@@ -240,6 +240,7 @@ void AliAnalysisTaskVertexESD::Exec(Option_t *)
   const AliESDVertex *trkv=fESD->GetPrimaryVertex();
 
   //Float_t tpccontrorig=tpcv->GetNContributors();
+
   //tpcv = 0;
   //tpcv = ReconstructPrimaryVertexTPC();
 
@@ -254,66 +255,66 @@ void AliAnalysisTaskVertexESD::Exec(Option_t *)
   }
 
 
-  Float_t xnt[43];
+  Int_t isize=36;
+  Float_t xnt[36];
   
-  xnt[0]=mcVertex[0];
-  xnt[1]=mcVertex[1];
-  xnt[2]=mcVertex[2];
+  Int_t index=0;
+
+  xnt[index++]=(Float_t)fESD->GetRunNumber();
+  xnt[index++]=(Float_t)fESD->GetTimeStamp();
+
+  xnt[index++]=mcVertex[0];
+  xnt[index++]=mcVertex[1];
+  xnt[index++]=mcVertex[2];
   
-  xnt[3]=spdv->GetXv();
-  xnt[4]=(spdv->GetXv()-mcVertex[0])*10000.;
-  xnt[5]=spdv->GetXRes();
-  xnt[6]=spdv->GetYv();
-  xnt[7]=(spdv->GetYv()-mcVertex[1])*10000.;
-  xnt[8]=spdv->GetYRes();
-  xnt[9]=spdv->GetZv();
-  xnt[10]=(spdv->GetZv()-mcVertex[2])*10000.;
-  xnt[11]=spdv->GetZRes();
-  xnt[12]=spdv->GetNContributors();
+  xnt[index++]=spdv->GetXv();
+  xnt[index++]=spdv->GetXRes();
+  xnt[index++]=spdv->GetYv();
+  xnt[index++]=spdv->GetYRes();
+  xnt[index++]=spdv->GetZv();
+  xnt[index++]=spdv->GetZRes();
+  xnt[index++]=spdv->GetNContributors();
   
-  xnt[13]=tpcv->GetXv();
-  xnt[14]=(tpcv->GetXv()-mcVertex[0])*10000.;
-  xnt[15]=tpcv->GetXRes();
-  xnt[16]=tpcv->GetYv();
-  xnt[17]=(tpcv->GetYv()-mcVertex[1])*10000.;
-  xnt[18]=tpcv->GetYRes();
-  xnt[19]=tpcv->GetZv();
-  xnt[20]=(tpcv->GetZv()-mcVertex[2])*10000.;
-  xnt[21]=tpcv->GetZRes();
-  xnt[22]=tpcv->GetNContributors();
+  xnt[index++]=tpcv->GetXv();
+  xnt[index++]=tpcv->GetXRes();
+  xnt[index++]=tpcv->GetYv();
+  xnt[index++]=tpcv->GetYRes();
+  xnt[index++]=tpcv->GetZv();
+  xnt[index++]=tpcv->GetZRes();
+  xnt[index++]=tpcv->GetNContributors();
   
-  xnt[23]=trkv->GetXv();
-  xnt[24]=(trkv->GetXv()-mcVertex[0])*10000.;
-  xnt[25]=trkv->GetXRes();
-  xnt[26]=trkv->GetYv();
-  xnt[27]=(trkv->GetYv()-mcVertex[1])*10000.;
-  xnt[28]=trkv->GetYRes();
-  xnt[29]=trkv->GetZv();
-  xnt[30]=(trkv->GetZv()-mcVertex[2])*10000.;
-  xnt[31]=trkv->GetZRes();
-  xnt[32]=trkv->GetNContributors();// tpccontrorig;
+  xnt[index++]=trkv->GetXv();
+  xnt[index++]=trkv->GetXRes();
+  xnt[index++]=trkv->GetYv();
+  xnt[index++]=trkv->GetYRes();
+  xnt[index++]=trkv->GetZv();
+  xnt[index++]=trkv->GetZRes();
+  xnt[index++]=trkv->GetNContributors();// tpccontrorig;
   
 
-  xnt[33]=float(ntrklets);
-  xnt[34]=float(ntracks);
-  xnt[35]=float(nITS5or6);
-  xnt[36]=float(nTPCin);
-  xnt[37]=float(nTPCinEta09);
+  xnt[index++]=float(ntrklets);
+  xnt[index++]=float(ntracks);
+  xnt[index++]=float(nITS5or6);
+  xnt[index++]=float(nTPCin);
+  xnt[index++]=float(nTPCinEta09);
 
-  xnt[38]=float(dNchdy);
+  xnt[index++]=float(dNchdy);
 
-  xnt[39]=0.; 
-  if(eventTriggered) xnt[39]=1.;
+  xnt[index++]=(eventTriggered ? 1. : 0.);
 
-  xnt[40]=0.; 
   TString spdtitle = spdv->GetTitle();
-  if(spdtitle.Contains("vertexer: 3D")) xnt[40]=1.;
+  xnt[index++]=(spdtitle.Contains("vertexer: 3D") ? 1. : 0.);
+
+  xnt[index++]=spd0cls;
 
-  xnt[42]=0.; 
   TString trktitle = trkv->GetTitle();
-  if(trktitle.Contains("WithConstraint")) xnt[42]=1.;
+  xnt[index++]=(trktitle.Contains("WithConstraint") ? 1. : 0.);
+
+  TString tpctitle = tpcv->GetTitle();
+  xnt[index++]=(tpctitle.Contains("WithConstraint") ? 1. : 0.);
+
 
-  xnt[41]=spd0cls;
+  if(index!=isize) printf("AliAnalysisTaskVertexESD: ERROR, index!=isize\n");
 
   fNtupleVertexESD->Fill(xnt);
     
@@ -340,18 +341,18 @@ void AliAnalysisTaskVertexESD::Terminate(Option_t *)
 }
 
 //_________________________________________________________________________
-AliESDVertex* AliAnalysisTaskVertexESD::ReconstructPrimaryVertexTPC() {
+AliESDVertex* AliAnalysisTaskVertexESD::ReconstructPrimaryVertexTPC() const {
   // On the fly reco of TPC vertex from ESD
 
   AliVertexerTracks vertexer(fESD->GetMagneticField());
-  vertexer.SetTPCMode(0.1,1.0,5.,0,1,3.,0.1,1.5); // defaults
-  //vertexer.SetTPCMode(0.1,1.0,5.,0,1,3.,0.1,1.5); // defaults
+  vertexer.SetTPCMode(); // defaults
+  //vertexer.SetTPCMode(0.1,1.0,5.,0,1,3.,0.1,1.5);
   Double_t pos[3]={+0.0220,-0.0340,+0.270}; 
   Double_t err[3]={0.0200,0.0200,7.5};
   AliESDVertex *initVertex = new AliESDVertex(pos,err);
   vertexer.SetVtxStart(initVertex);
   delete initVertex;
-  //vertexer.SetConstraintOff();
+  vertexer.SetConstraintOff();
 
   return vertexer.FindPrimaryVertex(fESD);
 }
index 3b5ed69..57d4310 100644 (file)
@@ -48,7 +48,7 @@ class AliAnalysisTaskVertexESD : public AliAnalysisTask
 
   AliAnalysisTaskVertexESD(const AliAnalysisTaskVertexESD&); // not implemented
   AliAnalysisTaskVertexESD& operator=(const AliAnalysisTaskVertexESD&); // not implemented
-  AliESDVertex* ReconstructPrimaryVertexTPC();
+  AliESDVertex* ReconstructPrimaryVertexTPC() const;
   
   ClassDef(AliAnalysisTaskVertexESD,1); // primary vertex analysis
 };
index a7e9772..7c149c0 100644 (file)
@@ -259,13 +259,13 @@ void PlotVertexESD(TString vtxtype="SPD",
   TFile *f=new TFile(fname.Data());
   TList *cOutput = (TList*)f->Get("cOutput");
   TNtuple *nt=(TNtuple*)cOutput->FindObject(ntname.Data());
-  Int_t NNNev=nt->GetEntries();
-  printf("Events = %d\n",NNNev);
+  Int_t nnnev=nt->GetEntries();
+  printf("Events = %d\n",nnnev);
   Float_t xVtx,xdiffVtx,xerrVtx;
   Float_t yVtx,ydiffVtx,yerrVtx;
   Float_t zVtx,zdiffVtx,zerrVtx;
   Float_t ntrklets,ncontrVtx,dndy,triggered,vtx3D;
-  Float_t ztrue,zref;
+  Float_t xtrue,ytrue,ztrue,zref;
   
   TString sxx="x"; sxx.Append(vtxtype.Data());
   nt->SetBranchAddress(sxx.Data(),&xVtx);
@@ -274,13 +274,6 @@ void PlotVertexESD(TString vtxtype="SPD",
   TString szz="z"; szz.Append(vtxtype.Data());
   nt->SetBranchAddress(szz.Data(),&zVtx);
   
-  TString xdiff="xdiff"; xdiff.Append(vtxtype.Data());
-  nt->SetBranchAddress(xdiff.Data(),&xdiffVtx);
-  TString ydiff="ydiff"; ydiff.Append(vtxtype.Data());
-  nt->SetBranchAddress(ydiff.Data(),&ydiffVtx);
-  TString zdiff="zdiff"; zdiff.Append(vtxtype.Data());
-  nt->SetBranchAddress(zdiff.Data(),&zdiffVtx);
-    
   TString xerr="xerr"; xerr.Append(vtxtype.Data());
   nt->SetBranchAddress(xerr.Data(),&xerrVtx);
   TString yerr="yerr"; yerr.Append(vtxtype.Data());
@@ -300,6 +293,8 @@ void PlotVertexESD(TString vtxtype="SPD",
   nt->SetBranchAddress(ntrks.Data(),&ncontrVtx);
   nt->SetBranchAddress("dndygen",&dndy);
   
+  nt->SetBranchAddress("xtrue",&xtrue);
+  nt->SetBranchAddress("ytrue",&ytrue);
   nt->SetBranchAddress("ztrue",&ztrue);
 
   nt->SetBranchAddress("triggered",&triggered);
@@ -308,8 +303,14 @@ void PlotVertexESD(TString vtxtype="SPD",
 
 
   // loop on events
-  for(Int_t iev=0;iev<NNNev;iev++){
+  for(Int_t iev=0;iev<nnnev;iev++){
     nt->GetEvent(iev);
+
+    xdiffVtx=10000.*(xVtx-xtrue);
+    ydiffVtx=10000.*(yVtx-ytrue);
+    zdiffVtx=10000.*(zVtx-ztrue);
+
+
     zref = (useztrue ? ztrue : zVtx);
     if(!vtxtype.Contains("SPD")) vtx3D=1.;
     if(triggered<0.5) continue; // not triggered
@@ -383,7 +384,7 @@ void PlotVertexESD(TString vtxtype="SPD",
       }
     }
   }
-  totev+=NNNev;
+  totev+=nnnev;
 
   if(totev==0){
     printf("Total number of events = 0\n");
@@ -1019,11 +1020,11 @@ void PlotVertexESD(TString vtxtype="SPD",
   return;
 }
 //----------------------------------------------------------------------------
-void ComputeVtxMean(TString vtxtype="TPC",
-                   TString fname="VertexESDwithMC.root",
+void ComputeVtxMean(TString vtxtype="TRK",
+                   TString fname="Vertex.Performance.root",
                    TString ntname="fNtupleVertexESD",
                    Int_t nEventsToUse=10000,
-                   Int_t mincontr=10) {
+                   Int_t mincontr=1) {
   //-----------------------------------------------------------------------
   // Compute weighted mean and cov. matrix from the ntuple
   //-----------------------------------------------------------------------
@@ -1053,10 +1054,10 @@ void ComputeVtxMean(TString vtxtype="TPC",
   Double_t covyz=0.;
   Double_t eavx,eavy,eavz,ewgtavx,ewgtavy,ewgtavz;
 
-  TH1F* hx = new TH1F("hx","",200,-1,1);
+  TH1F* hx = new TH1F("hx","",200,-0.1,0.1);
   hx->SetXTitle("vertex x [#mu m]");
   hx->SetYTitle("events");
-  TH1F* hy = new TH1F("hy","",200,-1,1);
+  TH1F* hy = new TH1F("hy","",200,-0.1,0.1);
   hy->SetXTitle("vertex y [#mu m]");
   hy->SetYTitle("events");
   TH1F* hz = new TH1F("hz","",200,-20,20);
@@ -1067,8 +1068,8 @@ void ComputeVtxMean(TString vtxtype="TPC",
   TFile *f=new TFile(fname.Data());
   TList *cOutput = (TList*)f->Get("cOutput");
   TNtuple *nt=(TNtuple*)cOutput->FindObject(ntname.Data());
-  Int_t NNNev=nt->GetEntries();
-  printf("Events = %d\n",NNNev);
+  Int_t nnnev=nt->GetEntries();
+  printf("Events = %d\n",nnnev);
   Float_t xVtx,xdiffVtx,xerrVtx;
   Float_t yVtx,ydiffVtx,yerrVtx;
   Float_t zVtx,zdiffVtx,zerrVtx;
@@ -1082,13 +1083,6 @@ void ComputeVtxMean(TString vtxtype="TPC",
   TString szz="z"; szz.Append(vtxtype.Data());
   nt->SetBranchAddress(szz.Data(),&zVtx);
   
-  TString xdiff="xdiff"; xdiff.Append(vtxtype.Data());
-  nt->SetBranchAddress(xdiff.Data(),&xdiffVtx);
-  TString ydiff="ydiff"; ydiff.Append(vtxtype.Data());
-  nt->SetBranchAddress(ydiff.Data(),&ydiffVtx);
-  TString zdiff="zdiff"; zdiff.Append(vtxtype.Data());
-  nt->SetBranchAddress(zdiff.Data(),&zdiffVtx);
-    
   TString xerr="xerr"; xerr.Append(vtxtype.Data());
   nt->SetBranchAddress(xerr.Data(),&xerrVtx);
   TString yerr="yerr"; yerr.Append(vtxtype.Data());
@@ -1116,14 +1110,14 @@ void ComputeVtxMean(TString vtxtype="TPC",
 
   Int_t total=0;
 
-  Int_t divider=(Int_t)(NNNev/nEventsToUse);
+  Int_t divider=(Int_t)(nnnev/nEventsToUse);
   // first loop on events
-  for(Int_t iev=0;iev<NNNev;iev++) {
+  for(Int_t iev=0;iev<nnnev;iev++) {
     if(iev%divider!=0) continue;
     total++;
     nt->GetEvent(iev);
     if(!vtxtype.Contains("SPD")) vtx3D=1.;
-    if(vtx3D<0.5) continue;
+    //if(vtx3D<0.5) continue;
     if(triggered<0.5) continue; // not triggered
     if(ncontrVtx<=0) continue; // no vertex
 
@@ -1157,7 +1151,7 @@ void ComputeVtxMean(TString vtxtype="TPC",
   
 
   // second loop on events
-  for(Int_t iev=0;iev<NNNev;iev++){
+  for(Int_t iev=0;iev<nnnev;iev++){
     if(iev%divider!=0) continue;
     nt->GetEvent(iev);
     if(!vtxtype.Contains("SPD")) vtx3D=1.;