ROOT logo
/**************************************************************************
 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
#include <Riostream.h>
#include <TArrayF.h>
#include <TRandom.h>
#include "AliESDVertex.h"
#include <AliITSVertexerFast.h>
#include "AliHeader.h"
#include "AliGenEventHeader.h"
#include "AliRun.h"
#include "AliITSLoader.h"
#include "AliRunLoader.h"

/////////////////////////////////////////////////////////////////////////
//                                                                     //
// Fast vertexer - True (i.e. generated) vertex coordinates            //
// are smeared with gaussians of given width                           //
// Origin: masera@to.infn.it     25/09/2003                            //
//                                                                     //
/////////////////////////////////////////////////////////////////////////

using std::endl;
using std::cout;
ClassImp(AliITSVertexerFast)



//______________________________________________________________________
AliITSVertexerFast::AliITSVertexerFast():AliITSVertexer(),
fSmear(0) 
{
  // Default Constructor
  fSmear = 0;
  AliRunLoader *rl =AliRunLoader::Instance();
  TTree *trK=(TTree*)rl->TreeK();
  if(!trK)AliFatal("This class should be used only with simulated events!!");
  rl->LoadHeader(); 
}

//______________________________________________________________________
AliITSVertexerFast::AliITSVertexerFast(Double_t *smear):AliITSVertexer(),
fSmear(0)
{
  // Standard constructor
  fSmear = new Double_t[3];
  for(Int_t i=0;i<3;i++)fSmear[i]=smear[i];
  AliInfo(Form("Gaussian smaring of the generated vertex. Sigmas (x,y,z) = %12.5f , %12.5f , %12.5f cm",fSmear[0],fSmear[1],fSmear[2]));
  AliRunLoader *rl =AliRunLoader::Instance();
  TTree *trK=(TTree*)rl->TreeK();
  if(!trK)AliFatal("This class should be used only with simulated events!!");
  rl->LoadHeader(); 

}


//______________________________________________________________________
AliITSVertexerFast::~AliITSVertexerFast(){
  // Destructor
  delete [] fSmear;
}

//______________________________________________________________________
AliESDVertex* AliITSVertexerFast::FindVertexForCurrentEvent(TTree *itsClusterTree){
  // Defines the AliITSVertex for the current event
  AliWarning(Form("This class should be used only with simulated events!! Input cluster tree (%p) will not be used!!",itsClusterTree));

  fCurrentVertex = 0;
  AliRunLoader *rl =AliRunLoader::Instance();
  TArrayF primaryVertex(3);  // true vertex
  AliHeader* header = rl->GetHeader();
  AliGenEventHeader* genEventHeader = header->GenEventHeader();   
  genEventHeader->PrimaryVertex(primaryVertex); 
  
  // Smearing
  Double_t vrttrue[3],vrtx[3];
  for(Int_t k=0; k<3;k++){
    vrttrue[k] = static_cast<Double_t>(primaryVertex[k]);
    vrtx[k] = gRandom->Gaus(vrttrue[k],fSmear[k]);
  }
  fCurrentVertex = new AliESDVertex(vrtx,fSmear,"Smeared Generated Vertex");
  fCurrentVertex->SetTitle("vertexer: smearMC");
  return fCurrentVertex;
  
}

//________________________________________________________
void AliITSVertexerFast::PrintStatus() const {
  // Print current status
  cout <<"=======================================================\n";

  cout<<"RMS for gaussian smearing: ";
  for(Int_t k=0;k<3;k++)cout<<" "<<fSmear[k];
  cout<<endl;
}

 AliITSVertexerFast.cxx:1
 AliITSVertexerFast.cxx:2
 AliITSVertexerFast.cxx:3
 AliITSVertexerFast.cxx:4
 AliITSVertexerFast.cxx:5
 AliITSVertexerFast.cxx:6
 AliITSVertexerFast.cxx:7
 AliITSVertexerFast.cxx:8
 AliITSVertexerFast.cxx:9
 AliITSVertexerFast.cxx:10
 AliITSVertexerFast.cxx:11
 AliITSVertexerFast.cxx:12
 AliITSVertexerFast.cxx:13
 AliITSVertexerFast.cxx:14
 AliITSVertexerFast.cxx:15
 AliITSVertexerFast.cxx:16
 AliITSVertexerFast.cxx:17
 AliITSVertexerFast.cxx:18
 AliITSVertexerFast.cxx:19
 AliITSVertexerFast.cxx:20
 AliITSVertexerFast.cxx:21
 AliITSVertexerFast.cxx:22
 AliITSVertexerFast.cxx:23
 AliITSVertexerFast.cxx:24
 AliITSVertexerFast.cxx:25
 AliITSVertexerFast.cxx:26
 AliITSVertexerFast.cxx:27
 AliITSVertexerFast.cxx:28
 AliITSVertexerFast.cxx:29
 AliITSVertexerFast.cxx:30
 AliITSVertexerFast.cxx:31
 AliITSVertexerFast.cxx:32
 AliITSVertexerFast.cxx:33
 AliITSVertexerFast.cxx:34
 AliITSVertexerFast.cxx:35
 AliITSVertexerFast.cxx:36
 AliITSVertexerFast.cxx:37
 AliITSVertexerFast.cxx:38
 AliITSVertexerFast.cxx:39
 AliITSVertexerFast.cxx:40
 AliITSVertexerFast.cxx:41
 AliITSVertexerFast.cxx:42
 AliITSVertexerFast.cxx:43
 AliITSVertexerFast.cxx:44
 AliITSVertexerFast.cxx:45
 AliITSVertexerFast.cxx:46
 AliITSVertexerFast.cxx:47
 AliITSVertexerFast.cxx:48
 AliITSVertexerFast.cxx:49
 AliITSVertexerFast.cxx:50
 AliITSVertexerFast.cxx:51
 AliITSVertexerFast.cxx:52
 AliITSVertexerFast.cxx:53
 AliITSVertexerFast.cxx:54
 AliITSVertexerFast.cxx:55
 AliITSVertexerFast.cxx:56
 AliITSVertexerFast.cxx:57
 AliITSVertexerFast.cxx:58
 AliITSVertexerFast.cxx:59
 AliITSVertexerFast.cxx:60
 AliITSVertexerFast.cxx:61
 AliITSVertexerFast.cxx:62
 AliITSVertexerFast.cxx:63
 AliITSVertexerFast.cxx:64
 AliITSVertexerFast.cxx:65
 AliITSVertexerFast.cxx:66
 AliITSVertexerFast.cxx:67
 AliITSVertexerFast.cxx:68
 AliITSVertexerFast.cxx:69
 AliITSVertexerFast.cxx:70
 AliITSVertexerFast.cxx:71
 AliITSVertexerFast.cxx:72
 AliITSVertexerFast.cxx:73
 AliITSVertexerFast.cxx:74
 AliITSVertexerFast.cxx:75
 AliITSVertexerFast.cxx:76
 AliITSVertexerFast.cxx:77
 AliITSVertexerFast.cxx:78
 AliITSVertexerFast.cxx:79
 AliITSVertexerFast.cxx:80
 AliITSVertexerFast.cxx:81
 AliITSVertexerFast.cxx:82
 AliITSVertexerFast.cxx:83
 AliITSVertexerFast.cxx:84
 AliITSVertexerFast.cxx:85
 AliITSVertexerFast.cxx:86
 AliITSVertexerFast.cxx:87
 AliITSVertexerFast.cxx:88
 AliITSVertexerFast.cxx:89
 AliITSVertexerFast.cxx:90
 AliITSVertexerFast.cxx:91
 AliITSVertexerFast.cxx:92
 AliITSVertexerFast.cxx:93
 AliITSVertexerFast.cxx:94
 AliITSVertexerFast.cxx:95
 AliITSVertexerFast.cxx:96
 AliITSVertexerFast.cxx:97
 AliITSVertexerFast.cxx:98
 AliITSVertexerFast.cxx:99
 AliITSVertexerFast.cxx:100
 AliITSVertexerFast.cxx:101
 AliITSVertexerFast.cxx:102
 AliITSVertexerFast.cxx:103
 AliITSVertexerFast.cxx:104
 AliITSVertexerFast.cxx:105
 AliITSVertexerFast.cxx:106
 AliITSVertexerFast.cxx:107