Test macros for primary vertex finding
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 21 Feb 2003 16:24:41 +0000 (16:24 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 21 Feb 2003 16:24:41 +0000 (16:24 +0000)
ITS/AliITSDumpVertices.C [new file with mode: 0644]
ITS/AliITSVertexerTracksTest.C [new file with mode: 0644]
ITS/AliITSVertexerTracksTest2.C [new file with mode: 0644]
ITS/AliITSVertexerZTest.C [new file with mode: 0644]

diff --git a/ITS/AliITSDumpVertices.C b/ITS/AliITSDumpVertices.C
new file mode 100644 (file)
index 0000000..9e757ac
--- /dev/null
@@ -0,0 +1,20 @@
+void AliITSDumpVertices(Int_t firstEv=0, Int_t noev=1,
+       TString fileimp="AliITSVertices.root",
+       TString objbasename="VertexTracks_"){
+  // This is a simple example on how to access the vertex objects
+  // The default object base name is VertexTracks_  for AliITSVertexerTracks
+  //                                 Vertex_        for AliITSVertexerPPZ
+  //                                 Vertex_        for AliITSVertexerIons
+  Int_t evmax = firstEv+noev;
+  TFile *file = new TFile(fileimp);
+  for(Int_t i=firstEv; i<evmax; i++){
+    TString name = objbasename;
+    name += i;
+    vert = (AliITSVertex*)file->Get(name.Data());
+    if(vert){
+      cout <<"===============================================\n";
+      cout <<" Event n. "<<i<<endl;
+      vert->PrintStatus();
+    }
+  }
+}
diff --git a/ITS/AliITSVertexerTracksTest.C b/ITS/AliITSVertexerTracksTest.C
new file mode 100644 (file)
index 0000000..5ca857e
--- /dev/null
@@ -0,0 +1,79 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+//-- --- standard headers------------- 
+#include <Riostream.h>
+//--------Root headers ---------------
+#include <TSystem.h>
+#include <TFile.h>
+#include <TStopwatch.h>
+#include <TObject.h>
+#include <TTree.h>
+//----- AliRoot headers ---------------
+#include "alles.h"
+#include "AliRun.h"
+#include "AliMagF.h"
+#include "AliKalmanTrack.h"
+#include "AliITSVertex.h"
+#include "AliITSVertexer.h"
+#include "AliITSVertexerTracks.h"
+//-------------------------------------
+#endif
+void AliITSVertexerTracksTest(Int_t evFirst=0,Int_t evLast=0,
+                             const Char_t *galiceName="galice.root",
+                             const Char_t *trksName="AliITStracksV2.root",
+                             const Char_t *vtxName="AliITSVertices.root") {
+  /*******************************************************************
+   *                                                                 *
+   * Test macro for vertexing in pp using tracks.                    *
+   * Input file must contain trees with AliITStrackV2 objects.       *
+   * Output file can be the same file with the tracks                *
+   * or another file.                                                *
+   * If the file galice.root is available, B is taken from there,    *
+   * otherwise is can be set here "by hand".                         *
+   *                                                                 *
+   * Origin: A.Dainese, Padova  andrea.dainese@pd.infn.it            *
+   *******************************************************************/     
+
+  // Look for field value in galice.root
+  Double_t field = 0.4;
+  if(!gSystem->AccessPathName(galiceName,kFileExists)) {
+    TFile *galice = new TFile(galiceName);
+    gAlice = (AliRun*)galice->Get("gAlice");
+    AliMagF *fiel = (AliMagF*)gAlice->Field();
+    field=(Double_t)fiel->SolenoidField()/10.;
+    AliKalmanTrack::SetConvConst(100/0.299792458/field);
+    printf(" B = %3.1f read from gAlice and set\n",field);
+    delete gAlice;
+    gAlice = 0;
+    galice->Close();
+    delete galice;
+  } else {
+    printf(" File galice.root not found: default 0.4 T being used!\n");
+  }
+
+  // Open input and output files
+  TFile *inFile = TFile::Open(trksName);
+  TFile *outFile = TFile::Open(vtxName,"recreate");
+
+  // Create vertexer
+  AliITSVertexerTracks *vertexer = 
+    new AliITSVertexerTracks(inFile,outFile,field);
+  vertexer->SetFirstEvent(evFirst);
+  vertexer->SetLastEvent(evLast);
+  vertexer->SetDebug(0);
+  vertexer->SetUseThrustFrame(0);
+  vertexer->PrintStatus();
+  // Find vertices
+  vertexer->FindVertices();
+
+
+  delete vertexer;
+
+
+
+  inFile->Close();
+  outFile->Close();
+  delete inFile;
+  delete outFile;
+
+  return;
+}
diff --git a/ITS/AliITSVertexerTracksTest2.C b/ITS/AliITSVertexerTracksTest2.C
new file mode 100644 (file)
index 0000000..470909e
--- /dev/null
@@ -0,0 +1,108 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+//-- --- standard headers------------- 
+#include <Riostream.h>
+//--------Root headers ---------------
+#include <TSystem.h>
+#include <TFile.h>
+#include <TStopwatch.h>
+#include <TObject.h>
+#include <TTree.h>
+//----- AliRoot headers ---------------
+#include "alles.h"
+#include "AliRun.h"
+#include "AliMagF.h"
+#include "AliKalmanTrack.h"
+#include "AliITSVertex.h"
+#include "AliITSVertexer.h"
+#include "AliITSVertexerTracks.h"
+#include <AliHeader.h>
+#include <AliGenEventHeader.h>
+//-------------------------------------
+#endif
+void AliITSVertexerTracksTest2(Int_t evFirst=0,Int_t evLast=0,
+                             const Char_t *galiceName="galice.root",
+                             const Char_t *trksName="AliITStracksV2.root",
+                             const Char_t *vtxName="AliITSVertices.root") {
+  /*******************************************************************
+   *                                                                 *
+   * Test macro for vertexing in pp using tracks.                    *
+   * Input file must contain trees with AliITStrackV2 objects.       *
+   * Output file can be the same file with the tracks                *
+   * or another file.                                                *
+   * If the file galice.root is available, B is taken from there,    *
+   * otherwise is can be set here "by hand".                         *
+   *                                                                 *
+   * Origin: A.Dainese, Padova  andrea.dainese@pd.infn.it            *
+   *******************************************************************/     
+
+  // Look for field value in galice.root
+  Double_t field = 0.4;
+  Int_t kDebug = 0;
+  TFile *galice = 0;
+  if(!gSystem->AccessPathName(galiceName,kFileExists)) {
+    galice = new TFile(galiceName);
+    gAlice = (AliRun*)galice->Get("gAlice");
+    AliMagF *fiel = (AliMagF*)gAlice->Field();
+    field=(Double_t)fiel->SolenoidField()/10.;
+    AliKalmanTrack::SetConvConst(100/0.299792458/field);
+    printf(" B = %3.1f read from gAlice and set\n",field);
+  } else {
+    printf(" File galice.root not found: default 0.4 T being used!\n");
+  }
+
+  // Open input and output files
+  TFile *inFile = TFile::Open(trksName);
+  TFile *outFile = TFile::Open(vtxName,"recreate");
+
+  // Create vertexer
+  AliITSVertexerTracks *vertexer = 
+    new AliITSVertexerTracks(inFile,outFile,field,0.,0.);
+  vertexer->SetDebug(0);
+  vertexer->SetUseThrustFrame(0);
+  vertexer->PrintStatus();
+
+  AliITSVertex *vert = 0;
+  // Find vertices
+
+  for(Int_t i=evFirst; i<=evLast; i++){
+    if(i%100==0)cout<<"processing event "<<i<<endl;
+    gAlice->GetEvent(i);
+    // The true Z coord. is fetched for comparison
+    AliHeader *header = gAlice->GetHeader();
+    AliGenEventHeader* genEventHeader = header->GenEventHeader();
+    TArrayF primaryVertex(3);
+    genEventHeader->PrimaryVertex(primaryVertex);
+    vert = vertexer->FindVertexForCurrentEvent(i);
+    if(kDebug>0){
+      // Prints the results
+      cout <<"========================================================\n";
+      cout << "Event number: "<<i<<")  Z Vertex:"<<endl;
+      if(vert){
+       cout<<"FOUND: "<<vert->GetZv()<<"; "<<vert->GetZRes()<<endl;
+       cout <<" True Z position "<<primaryVertex[2]<<endl;
+       cout<<", diff= "<<(primaryVertex[2]-vert->GetZv())*10000.<<endl;
+      }
+      else {
+       cout<<"NOT FOUND "<<endl;
+      }
+    }
+    if(vert){
+      Double_t pos[3];
+      for(Int_t kk=0;kk<3;kk++)pos[kk]=(Double_t)primaryVertex[kk];
+      vert->SetTruePos(pos);
+      vertexer->WriteCurrentVertex();
+    }
+  }
+
+  delete vertexer;
+
+
+
+  inFile->Close();
+  outFile->Close();
+  delete inFile;
+  delete outFile;
+  galice->Close();
+  delete galice;
+  return;
+}
diff --git a/ITS/AliITSVertexerZTest.C b/ITS/AliITSVertexerZTest.C
new file mode 100644 (file)
index 0000000..fabd4e2
--- /dev/null
@@ -0,0 +1,89 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <TFile.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include <TTree.h>
+#include <Riostream.h>
+#include <AliRun.h>
+#include <AliHeader.h>
+#include <AliGenEventHeader.h>
+#include <AliITSVertexerPPZ.h>
+
+#endif
+
+void AliITSVertexerZTest(Float_t delphi=0.05,Float_t window=3.,Float_t initx=0., Float_t inity=0.,TString FileWithKine="galice.root", TString FileWithRecP="galice.root"){
+  // delphi ---> azimuthal range to accept tracklets
+  // window ---> window in Z around the peak of tracklets proj. in mm
+  Int_t kDebug = 0;
+  TH2F *diff2 = new TH2F("diff2","Zfound vs Ztrue",100,-6,6,100,-6,6); 
+  TH1F *diff1 = new TH1F("diff1","Zfound - Ztrue(#mu m)",100,-500,500);
+  delete gAlice;
+  gAlice = 0;
+  TFile *in = new TFile("galice.root");
+  gAlice = (AliRun*)in->Get("gAlice");
+  if(FileWithKine != FileWithRecP)gAlice->SetTreeRFileName(FileWithRecP);
+  TFile *fo = new TFile("vertici.root","recreate");
+  AliITSVertexerPPZ *dovert = new AliITSVertexerPPZ(in,fo,initx,inity);
+  dovert->SetDebug(0);
+  dovert->SetDiffPhiMax(delphi);
+  dovert->SetWindow(window);
+  dovert->PrintStatus();
+  Int_t meno100=0;
+  Int_t meno200=0;
+  Int_t meno110=0;
+  Int_t sigmazero=0;
+  AliITSVertex *vert = 0;
+  for(Int_t i=0; i<gAlice->TreeE()->GetEntries(); i++){
+    gAlice->GetEvent(i);
+    // The true Z coord. is fetched for comparison
+    AliHeader *header = gAlice->GetHeader();
+    AliGenEventHeader* genEventHeader = header->GenEventHeader();
+    TArrayF primaryVertex(3);
+    genEventHeader->PrimaryVertex(primaryVertex);
+    vert = dovert->FindVertexForCurrentEvent(i);
+    if(kDebug>0){
+      // Prints the results
+      cout <<"========================================================\n";
+      cout << "Event number: "<<i<<")  Z Vertex:"<<endl;
+      if(vert){
+       cout<<"FOUND: "<<vert->GetZv()<<"; ";
+       cout<<vert->GetZRes()<<"; "<<vert->GetNContributors()<<endl;
+      }
+      else {
+       cout<<"NOT FOUND - fZFound= "<<dovert->GetZFound();
+       cout<<" fZsig= "<<dovert->GetZsig()<<endl;
+       if(dovert->GetZFound() == -100) meno100++;
+       if(dovert->GetZFound() == -200) meno200++;
+       if(dovert->GetZFound() == -110) meno110++;
+      }
+      cout <<" True Z position "<<primaryVertex[2]<<", diff= ";
+      cout<<(primaryVertex[2]-dovert->GetZFound())*10000.<<endl;
+    }
+    if(vert){
+      Double_t pos[3];
+      for(Int_t kk=0;kk<3;kk++)pos[kk]=(Double_t)primaryVertex[kk];
+      vert->SetTruePos(pos);
+      Float_t found = vert->GetZv();
+      diff2->Fill(primaryVertex[2],found);
+      found = 10000.*(found-primaryVertex[2]);
+      if(vert->GetZRes()!=0){
+       diff1->Fill(found);
+      }
+      else {
+       sigmazero++;
+      }
+      dovert->WriteCurrentVertex();
+    }
+  }
+  in->Close();
+  fo->Close();
+  delete in;
+  delete fo;
+  if(kDebug>0){
+    cout<<"Number of bad vertices with code  -100: "<<meno100<<endl;
+    cout<<"Number of bad vertices with code  -110: "<<meno110<<endl;
+    cout<<"Number of bad vertices with code  -200: "<<meno200<<endl;
+    cout<<"Only one tracklet (sigma = 0) "<<sigmazero<<endl;
+  }
+
+}