]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSVertexerTracksTest.C
Print removed
[u/mrichter/AliRoot.git] / ITS / AliITSVertexerTracksTest.C
index 5ca857e8b82456b317ccbbde20d81ee523970ffa..e70ac0f494b8b0468e054eb53baea628b913dcc2 100644 (file)
@@ -7,69 +7,76 @@
 #include <TStopwatch.h>
 #include <TObject.h>
 #include <TTree.h>
+#include <TStopwatch.h>
+#include <TKey.h>
 //----- AliRoot headers ---------------
 #include "alles.h"
 #include "AliRun.h"
+#include "AliRunLoader.h"
 #include "AliMagF.h"
 #include "AliKalmanTrack.h"
-#include "AliITSVertex.h"
+#include "AliESDVertex.h"
 #include "AliITSVertexer.h"
 #include "AliITSVertexerTracks.h"
 //-------------------------------------
 #endif
-void AliITSVertexerTracksTest(Int_t evFirst=0,Int_t evLast=0,
+void AliITSVertexerTracksTest(Int_t evFirst=0,Int_t evLast=0,Bool_t esd=kTRUE,
                              const Char_t *galiceName="galice.root",
-                             const Char_t *trksName="AliITStracksV2.root",
-                             const Char_t *vtxName="AliITSVertices.root") {
+                             const Char_t *inName="AliESDs.root",
+                              const Char_t *outName="AliESDs.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".                         *
+   * If(esd) {                                                       *
+   *   Input file must contain ESD events with tracks reco in ITS    *
+   *   if output file = input file, vertices will be stored in the   *
+   *   ESD events and these rewritten to the same file; otherwise    *
+   *   they will be written to a new file                            *
+   * } else {                                                        *
+   *   input file must contain a tree with AliITStracksV2 and        *
+   *   can be written to the same file (output file = input file)    *
+   *   or to a new one                                               *
+   * }                                                               *
+   * If file galice.root is present field will be read from it       *
+   * otherwise it can be set here "by hand".                         *
    *                                                                 *
    * Origin: A.Dainese, Padova  andrea.dainese@pd.infn.it            *
    *******************************************************************/     
 
+  TStopwatch timer;
+  timer.Start();
+
   // 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");
+    AliRunLoader *rl = AliRunLoader::Open(galiceName);
+    rl->LoadgAlice();
     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");
+  TFile *inFile  = TFile::Open(inName);
+  TFile *outFile = TFile::Open(outName,"update");
 
   // Create vertexer
   AliITSVertexerTracks *vertexer = 
-    new AliITSVertexerTracks(inFile,outFile,field);
-  vertexer->SetFirstEvent(evFirst);
-  vertexer->SetLastEvent(evLast);
-  vertexer->SetDebug(0);
-  vertexer->SetUseThrustFrame(0);
-  vertexer->PrintStatus();
+    new AliITSVertexerTracks(inFile,outFile,field,evFirst,evLast);
   // Find vertices
-  vertexer->FindVertices();
+  if(esd) {
+    vertexer->FindVerticesESD();
+  } else {
+    vertexer->FindVertices();
+  }
 
+  timer.Stop(); timer.Print();
 
   delete vertexer;
 
-
-
   inFile->Close();
   outFile->Close();
   delete inFile;
@@ -77,3 +84,63 @@ void AliITSVertexerTracksTest(Int_t evFirst=0,Int_t evLast=0,
 
   return;
 }
+//----------------------------------------------------------------------------
+void VertexRecoInESDChain() {
+
+  TStopwatch timer;
+  timer.Start();
+
+  // Look for field value in galice.root
+  Double_t field = 0.4;
+  if(!gSystem->AccessPathName("galice.root",kFileExists)) {
+    AliRunLoader *rl = AliRunLoader::Open("galice.root");
+    rl->LoadgAlice();
+    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 file with ESD events (this would not be necessary in the chain...)
+  if(gSystem->AccessPathName("AliESDs.root",kFileExists))
+    { printf(" ESD file not found!\n"); return; }
+  TFile *esdFile = new TFile("AliESDs.root","update");
+  AliITSVertexerTracks *vertexer = new AliITSVertexerTracks();
+  vertexer->SetField(field);
+
+  Int_t n=0;
+  TKey *key=0;
+  TIter next(esdFile->GetListOfKeys());
+
+  //******* The loop over events
+  while ((key=(TKey*)next())!=0) {
+    printf("--- Processing event number : %d",n++);
+
+    AliESD *event=(AliESD*)key->ReadObj();
+
+    // find vertex and store it in the ESD (only pos and cov matrix)
+    vertexer->FindVertexForCurrentEvent(event);
+
+    // write event on file
+    event->Write();
+
+  }
+
+  timer.Stop(); timer.Print();
+
+  delete vertexer;
+  esdFile->Close();
+  delete esdFile;
+
+  return;
+}
+
+
+
+
+
+
+