]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSVertexerFast.cxx
Update of SSD calibration default DB. Update of SSD calibration classes. Ad hoc inter...
[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;
60b9526b 43 AliRunLoader *rl =AliRunLoader::GetRunLoader();
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];
2257f27e 56 Info("AliITSVertexerFast","Gaussian smaring of the generated vertex. Parameters %f12.5 , %f12.5 , %f12.5 \n",fSmear[0],fSmear[1],fSmear[2]);
60b9526b 57 AliRunLoader *rl =AliRunLoader::GetRunLoader();
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//______________________________________________________________________
d681bb2d 73AliESDVertex* AliITSVertexerFast::FindVertexForCurrentEvent(Int_t evnumb){
92e7a7bb 74 // Defines the AliITSVertex for the current event
75 fCurrentVertex = 0;
76 AliRunLoader *rl =AliRunLoader::GetRunLoader();
77 rl->GetEvent(evnumb);
78 TArrayF primaryVertex(3); // true vertex
60b9526b 79 AliHeader* header = rl->GetAliRun()->GetHeader();
92e7a7bb 80 AliGenEventHeader* genEventHeader = header->GenEventHeader();
81 genEventHeader->PrimaryVertex(primaryVertex);
60b9526b 82
92e7a7bb 83 // Smearing
84 Double_t vrttrue[3],vrtx[3];
85 for(Int_t k=0; k<3;k++){
86 vrttrue[k] = static_cast<Double_t>(primaryVertex[k]);
87 vrtx[k] = gRandom->Gaus(vrttrue[k],fSmear[k]);
88 }
89 char name[30];
90 sprintf(name,"Vertex_%d",evnumb);
d681bb2d 91 fCurrentVertex = new AliESDVertex(vrtx,fSmear,name);
92e7a7bb 92 fCurrentVertex->SetTruePos(vrttrue);
93 return fCurrentVertex;
60b9526b 94
92e7a7bb 95}
96
97//______________________________________________________________________
98void AliITSVertexerFast::FindVertices(){
99 // computes the vertices of the events in the range FirstEvent - LastEvent
100
101 AliRunLoader *rl = AliRunLoader::GetRunLoader();
102 AliITSLoader* iTSloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
103 iTSloader->ReloadRecPoints();
104 for(Int_t i=fFirstEvent;i<=fLastEvent;i++){
105 rl->GetEvent(i);
106 FindVertexForCurrentEvent(i);
107 if(fCurrentVertex) WriteCurrentVertex();
108 else {
109 cout<<"Vertex not found for event "<<i<<endl;
110
111 }
112
113 }
114
115}
116
117//________________________________________________________
118void AliITSVertexerFast::PrintStatus() const {
119 // Print current status
120 cout <<"=======================================================\n";
121
122 cout<<"First event to be processed "<<fFirstEvent;
123 cout<<"\n Last event to be processed "<<fLastEvent<<endl;
124 cout<<"RMS for gaussian smearing: ";
125 for(Int_t k=0;k<3;k++)cout<<" "<<fSmear[k];
126 cout<<endl;
127}
128
129//______________________________________________________________________
130AliITSVertexerFast::AliITSVertexerFast(const AliITSVertexerFast &vtxr) :
131 AliITSVertexer(vtxr) {
132 // Copy constructor
133 // Copies are not allowed. The method is protected to avoid misuse.
134 Error("AliITSVertexerFast","Copy constructor not allowed\n");
135}
136
137//______________________________________________________________________
138AliITSVertexerFast& AliITSVertexerFast::operator=(const
139 AliITSVertexerFast& /* vtxr */){
140 // Assignment operator
141 // Assignment is not allowed. The method is protected to avoid misuse.
142 Error("= operator","Assignment operator not allowed\n");
143 return *this;
144}