]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSVertexer.cxx
Protection involving the existance of gMC added. Usefull when the ITS is used
[u/mrichter/AliRoot.git] / ITS / AliITSVertexer.cxx
index 39dc270722ab86178a34393af8f429fc88fa642c..f66b6f56af75830b9268fd1cbb7a9befc2c3645b 100644 (file)
-#include <AliITSVertex.h>
+#include <AliESDVertex.h>
 #include <AliITSVertexer.h>
+#include <AliRunLoader.h>
+#include <AliITSLoader.h>
+#include <AliITSRecPoint.h>
+#include <AliITSclusterV2.h>
 
 ClassImp(AliITSVertexer)
 
 //////////////////////////////////////////////////////////////////////
 // Base class for primary vertex reconstruction                     //
-// AliITSVertex is a class for full 3D primary vertex finding       //
+// AliESDVertexer is a class for full 3D primary vertex finding     //
+// derived classes: AliITSVertexerIons AliITSvertexerPPZ            //
+//                  AliITSVertexerTracks                            //
 //////////////////////////////////////////////////////////////////////
 
 //______________________________________________________________________
-AliITSVertexer::AliITSVertexer() {
+AliITSVertexer::AliITSVertexer():AliVertexer() {
   // Default Constructor
-
-    fCurrentVertex  = 0;
-    fInFile         = 0;
-    fOutFile        = 0;
-    SetDebug();
-    SetFirstEvent(0);
-    SetLastEvent(0);
+  SetUseV2Clusters(kTRUE);
 }
 
-AliITSVertexer::AliITSVertexer(TFile *infile, TFile *outfile) {
+AliITSVertexer::AliITSVertexer(TString filename) {
   // Standard constructor
+  AliRunLoader *rl = AliRunLoader::GetRunLoader();
+  if(!rl){
+    Fatal("AliITSVertexer","Run Loader not found");
+  }
+  if(rl->LoadgAlice()){
+    Fatal("AliITSVertexer","The AliRun object is not available - nothing done");
+  }
   fCurrentVertex  = 0;   
-  SetInputFile(infile);
-  SetOutputFile(outfile);
   SetDebug();
   SetFirstEvent(0);
   SetLastEvent(0);
-  if(gAlice){
-    Int_t lst;
-    if(gAlice->TreeE()){
-      lst = static_cast<Int_t>(gAlice->TreeE()->GetEntries());
-      SetLastEvent(lst-1);
-    }
+  rl->LoadHeader();
+  AliITSLoader* itsLoader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
+  if(!filename.Contains("default"))itsLoader->SetVerticesFileName(filename);
+  if(!filename.Contains("null"))itsLoader->LoadVertices("recreate");
+  itsLoader->LoadRecPoints();
+  Int_t lst;
+  if(rl->TreeE()){
+    lst = static_cast<Int_t>(rl->TreeE()->GetEntries());
+    SetLastEvent(lst-1);
   }
+  SetUseV2Clusters(kTRUE);
+}
+
+//______________________________________________________________________
+AliITSVertexer::AliITSVertexer(const AliITSVertexer &vtxr) : AliVertexer(vtxr) {
+  // Copy constructor
+  // Copies are not allowed. The method is protected to avoid misuse.
+  Error("AliITSVertexer","Copy constructor not allowed\n");
 }
 
 //______________________________________________________________________
-AliITSVertexer::~AliITSVertexer() {
-  // Default Destructor
-  // The objects poited by the following pointers are not owned
-  // by this class and are not deleted
-
-    fCurrentVertex  = 0;
-    fInFile         = 0;
-    fOutFile        = 0;
+AliITSVertexer& AliITSVertexer::operator=(const AliITSVertexer& /* vtxr */){
+  // Assignment operator
+  // Assignment is not allowed. The method is protected to avoid misuse.
+  Error("= operator","Assignment operator not allowed\n");
+  return *this;
 }
 
+
 //______________________________________________________________________
 void AliITSVertexer::WriteCurrentVertex(){
   // Write the current AliVertex object to file fOutFile
-  if(!fOutFile){
-    Error("WriteCurrentEvent","The output file is not defined");
-    return;
+  AliRunLoader *rl = AliRunLoader::GetRunLoader();
+  AliITSLoader* itsLoader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
+  fCurrentVertex->SetName("Vertex");
+  //  const char * name = fCurrentVertex->GetName();
+  //  itsLoader->SetVerticesContName(name);
+  Int_t rc = itsLoader->PostVertex(fCurrentVertex);
+  rc = itsLoader->WriteVertices();
+}
+
+//______________________________________________________________________
+void AliITSVertexer::Clusters2RecPoints
+(const TClonesArray *clusters, Int_t idx, TClonesArray *points) {
+  //------------------------------------------------------------
+  // Conversion AliITSclusterV2 -> AliITSRecPoints for the ITS
+  // module "idx" (entry in the tree with the clusters).
+  // Simplified version, supposed to work with the pixels only !
+  //------------------------------------------------------------
+  const Int_t lastSPD1=79; //let's hope the number of the SPDs will not change
+  const Int_t lastSPD2=239;//let's hope the number of the SPDs will not change
+
+  Float_t yshift = 0; //see AliITSclustererV2.cxx about these shifts
+  Float_t zshift[4] = {-10.708000, -3.536000, 3.536000, 10.708000}; //let's hope the positioning of the SPDs will not change
+
+  if (idx<=lastSPD1) {
+    yshift=0.248499;  //let's hope the positioning of the SPDs will not change
+  } else if (idx<=lastSPD2) {
+    yshift=3.096207;  //let's hope the positioning of the SPDs will not change
+  } else {
+    Fatal("Clusters2RecPoints","This is not an SPD module ! %d",idx);
   }
-  TDirectory *curdir = gDirectory;
-  fOutFile->cd();
-  fCurrentVertex->Write();
-  curdir->cd();
-  fCurrentVertex = 0;
+
+  TClonesArray &pn=*points;
+  Int_t ncl=clusters->GetEntriesFast();
+  for (Int_t i=0; i<ncl; i++) {
+    AliITSRecPoint p;
+    AliITSclusterV2 *c = (AliITSclusterV2 *)clusters->UncheckedAt(i);
+
+    Float_t x=c->GetY();  if (idx<=lastSPD1) x=-x;
+    x+=yshift;
+
+    Float_t z=c->GetZ();
+    z=-z; z+=zshift[idx%4];
+
+    p.SetX(x);
+    p.SetZ(z);
+    p.SetQ(c->GetQ());
+    p.SetSigmaX2(c->GetSigmaY2());
+    p.SetSigmaZ2(c->GetSigmaZ2());
+    p.SetLabel(0,c->GetLabel(0));
+    p.SetLabel(1,c->GetLabel(1));
+    p.SetLabel(2,c->GetLabel(2));
+
+    new (pn[i]) AliITSRecPoint(p);
+  }
+
 }