Update for Ds
[u/mrichter/AliRoot.git] / ITS / AliITSVertexerFast.cxx
CommitLineData
92e7a7bb 1/**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15#include <Riostream.h>
16#include <TArrayF.h>
17#include <TRandom.h>
d681bb2d 18#include "AliESDVertex.h"
92e7a7bb 19#include <AliITSVertexerFast.h>
20#include "AliHeader.h"
21#include "AliGenEventHeader.h"
22#include "AliRun.h"
23#include "AliITSLoader.h"
24#include "AliRunLoader.h"
25
26/////////////////////////////////////////////////////////////////////////
27// //
28// Fast vertexer - True (i.e. generated) vertex coordinates //
29// are smeared with gaussians of given width //
30// Origin: masera@to.infn.it 25/09/2003 //
31// //
32/////////////////////////////////////////////////////////////////////////
33ClassImp(AliITSVertexerFast)
34
35
36
37//______________________________________________________________________
8221b41b 38AliITSVertexerFast::AliITSVertexerFast():AliITSVertexer(),
39fSmear(0)
40{
92e7a7bb 41 // Default Constructor
42 fSmear = 0;
33c3c91a 43 AliRunLoader *rl =AliRunLoader::Instance();
60b9526b 44 TTree *trK=(TTree*)rl->TreeK();
45 if(!trK)AliFatal("This class should be used only with simulated events!!");
46 rl->LoadHeader();
92e7a7bb 47}
48
49//______________________________________________________________________
8221b41b 50AliITSVertexerFast::AliITSVertexerFast(Double_t *smear):AliITSVertexer(),
51fSmear(0)
52{
92e7a7bb 53 // Standard constructor
54 fSmear = new Double_t[3];
55 for(Int_t i=0;i<3;i++)fSmear[i]=smear[i];
9364069b 56 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]));
33c3c91a 57 AliRunLoader *rl =AliRunLoader::Instance();
60b9526b 58 TTree *trK=(TTree*)rl->TreeK();
59 if(!trK)AliFatal("This class should be used only with simulated events!!");
60 rl->LoadHeader();
61
92e7a7bb 62}
63
60b9526b 64
92e7a7bb 65//______________________________________________________________________
66AliITSVertexerFast::~AliITSVertexerFast(){
67 // Destructor
68 if(fSmear)delete [] fSmear;
69 fSmear = 0;
70}
71
72//______________________________________________________________________
308c2f7c 73AliESDVertex* AliITSVertexerFast::FindVertexForCurrentEvent(TTree *itsClusterTree){
92e7a7bb 74 // Defines the AliITSVertex for the current event
308c2f7c 75 AliWarning(Form("This class should be used only with simulated events!! Input cluster tree (%p) will not be used!!",itsClusterTree));
76
92e7a7bb 77 fCurrentVertex = 0;
33c3c91a 78 AliRunLoader *rl =AliRunLoader::Instance();
92e7a7bb 79 TArrayF primaryVertex(3); // true vertex
d3b3a3b2 80 AliHeader* header = rl->GetHeader();
92e7a7bb 81 AliGenEventHeader* genEventHeader = header->GenEventHeader();
82 genEventHeader->PrimaryVertex(primaryVertex);
60b9526b 83
92e7a7bb 84 // Smearing
85 Double_t vrttrue[3],vrtx[3];
86 for(Int_t k=0; k<3;k++){
87 vrttrue[k] = static_cast<Double_t>(primaryVertex[k]);
88 vrtx[k] = gRandom->Gaus(vrttrue[k],fSmear[k]);
89 }
308c2f7c 90 fCurrentVertex = new AliESDVertex(vrtx,fSmear,"Smeared Generated Vertex");
db2eccce 91 fCurrentVertex->SetTitle("vertexer: smearMC");
92e7a7bb 92 return fCurrentVertex;
60b9526b 93
92e7a7bb 94}
95
92e7a7bb 96//________________________________________________________
97void AliITSVertexerFast::PrintStatus() const {
98 // Print current status
99 cout <<"=======================================================\n";
100
92e7a7bb 101 cout<<"RMS for gaussian smearing: ";
102 for(Int_t k=0;k<3;k++)cout<<" "<<fSmear[k];
103 cout<<endl;
104}
105