]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSVertexer.cxx
A new bunch of Global QA histogramms
[u/mrichter/AliRoot.git] / ITS / AliITSVertexer.cxx
1 #include <AliESDVertex.h>
2 #include "AliITSgeomTGeo.h"
3 #include "AliITSVertexer.h"
4 #include "AliRunLoader.h"
5 #include "AliITSLoader.h"
6 #include "AliMultiplicity.h"
7 #include "AliITSMultReconstructor.h"
8
9 const Float_t AliITSVertexer::fgkPipeRadius = 3.0;
10
11 ClassImp(AliITSVertexer)
12
13 //////////////////////////////////////////////////////////////////////
14 // Base class for primary vertex reconstruction                     //
15 // AliESDVertexer is a class for full 3D primary vertex finding     //
16 // derived classes: AliITSVertexerIons AliITSvertexer3D             //
17 //                  AliITSVertexerCosmics                           //
18 //////////////////////////////////////////////////////////////////////
19
20 //______________________________________________________________________
21 AliITSVertexer::AliITSVertexer():AliVertexer(),
22 fLadders(), 
23 fLadOnLay2(0)    {
24   // Default Constructor
25   SetLaddersOnLayer2();
26 }
27
28 AliITSVertexer::AliITSVertexer(TString filename):AliVertexer(),
29 fLadders(), 
30 fLadOnLay2(0)
31 {
32   // Standard constructor
33   AliRunLoader *rl = AliRunLoader::GetRunLoader();
34   if(!rl){
35     Fatal("AliITSVertexer","Run Loader not found");
36   }
37   /*
38   if(rl->LoadgAlice()){
39     Fatal("AliITSVertexer","The AliRun object is not available - nothing done");
40   }
41   */
42   fCurrentVertex  = 0;   
43   SetFirstEvent(0);
44   SetLastEvent(0);
45   //  rl->LoadHeader();
46   AliITSLoader* itsLoader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
47   if(!filename.Contains("default"))itsLoader->SetVerticesFileName(filename);
48   if(!filename.Contains("null"))itsLoader->LoadVertices("recreate");
49
50   //  Int_t lst;
51   SetLastEvent(rl->GetNumberOfEvents()-1);
52   /*
53   if(rl->TreeE()){
54     lst = static_cast<Int_t>(rl->TreeE()->GetEntries());
55     SetLastEvent(lst-1);
56   }
57   */
58   SetLaddersOnLayer2();
59 }
60
61 //______________________________________________________________________
62 AliITSVertexer::AliITSVertexer(const AliITSVertexer &vtxr) : AliVertexer(vtxr),
63 fLadders(), 
64 fLadOnLay2(0) 
65 {
66   // Copy constructor
67   // Copies are not allowed. The method is protected to avoid misuse.
68   Error("AliITSVertexer","Copy constructor not allowed\n");
69 }
70
71 //______________________________________________________________________
72 AliITSVertexer& AliITSVertexer::operator=(const AliITSVertexer& /* vtxr */){
73   // Assignment operator
74   // Assignment is not allowed. The method is protected to avoid misuse.
75   Error("= operator","Assignment operator not allowed\n");
76   return *this;
77 }
78
79 //______________________________________________________________________
80 AliITSVertexer::~AliITSVertexer() {
81   // Destructor
82  if(fLadders) delete [] fLadders;
83 }
84
85 //______________________________________________________________________
86 void AliITSVertexer::FindMultiplicity(Int_t evnumber){
87   // Invokes AliITSMultReconstructor to determine the
88   // charged multiplicity in the pixel layers
89   if(fMult){delete fMult; fMult = 0;}
90   Bool_t success=kTRUE;
91   if(!fCurrentVertex)success=kFALSE;
92   if(fCurrentVertex && fCurrentVertex->GetNContributors()<1)success=kFALSE;
93   if(!success){
94     AliWarning("Tracklets multiplicity not determined because the primary vertex was not found");
95     return;
96   }
97   AliITSMultReconstructor* multReco = new AliITSMultReconstructor();
98   AliRunLoader *rl =AliRunLoader::GetRunLoader();
99   AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader");
100   itsLoader->LoadRecPoints();
101   rl->GetEvent(evnumber);
102   TTree* itsClusterTree = itsLoader->TreeR();
103   if (!itsClusterTree) {
104     AliError(" Can't get the ITS cluster tree !\n");
105     return;
106   }
107   Double_t vtx[3];
108   fCurrentVertex->GetXYZ(vtx);
109   Float_t vtxf[3];
110   for(Int_t i=0;i<3;i++)vtxf[i]=vtx[i];
111   multReco->SetHistOn(kFALSE);
112   multReco->Reconstruct(itsClusterTree,vtxf,vtxf);
113   Int_t notracks=multReco->GetNTracklets();
114   Float_t *tht = new Float_t [notracks];
115   Float_t *phi = new Float_t [notracks];
116   Float_t *dphi = new Float_t [notracks];
117   Int_t *labels = new Int_t[notracks];
118   for(Int_t i=0;i<multReco->GetNTracklets();i++){
119     tht[i] = multReco->GetTracklet(i)[0];
120     phi[i] =  multReco->GetTracklet(i)[1];
121     dphi[i] = multReco->GetTracklet(i)[2];
122     labels[i] = static_cast<Int_t>(multReco->GetTracklet(i)[3]);
123   }
124   Int_t nosingleclus=multReco->GetNSingleClusters();
125   Float_t *ths = new Float_t [nosingleclus];
126   Float_t *phs = new Float_t [nosingleclus];
127   for(Int_t i=0;i<nosingleclus;i++){
128     ths[i] = multReco->GetCluster(i)[0];
129     phs[i] =  multReco->GetCluster(i)[1];
130   }
131   fMult = new AliMultiplicity(notracks,tht,phi,dphi,labels,nosingleclus,ths,phs);
132   delete [] tht;
133   delete [] phi;
134   delete [] dphi;
135   delete [] ths;
136   delete [] phs;
137   delete [] labels;
138   itsLoader->UnloadRecPoints();
139   delete multReco;
140   return;
141 }
142
143 //______________________________________________________________________
144 void AliITSVertexer::SetLaddersOnLayer2(Int_t ladwid){
145   // Calculates the array of ladders on layer 2 to be used with a 
146   // given ladder on layer 1
147   fLadOnLay2=ladwid;
148   //  AliRunLoader *rl =AliRunLoader::GetRunLoader();
149   //  AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader");
150   //  AliITSgeom* geom = itsLoader->GetITSgeom();
151   Int_t ladtot1=AliITSgeomTGeo::GetNLadders(1);
152   if(fLadders) delete [] fLadders;
153   fLadders=new UShort_t[ladtot1];
154
155
156   Double_t pos1[3],pos2[3];
157   Int_t mod1=AliITSgeomTGeo::GetModuleIndex(2,1,1);
158   AliITSgeomTGeo::GetTranslation(mod1,pos1);  // position of the module in the MRS 
159   Double_t phi0=TMath::ATan2(pos1[1],pos1[0]);
160   if(phi0<0) phi0+=2*TMath::Pi();
161   Int_t mod2=AliITSgeomTGeo::GetModuleIndex(2,2,1);
162   AliITSgeomTGeo::GetTranslation(mod2,pos2);
163   Double_t phi2=TMath::ATan2(pos2[1],pos2[0]); 
164   if(phi2<0) phi2+=2*TMath::Pi();
165   Double_t deltaPhi= phi0-phi2; // phi width of a layer2 module
166
167   for(Int_t i= 0; i<ladtot1;i++){
168     Int_t modlad= AliITSgeomTGeo::GetModuleIndex(1,i+1,1);
169     Double_t posmod[3];
170     AliITSgeomTGeo::GetTranslation(modlad,posmod);
171     Double_t phimod=TMath::ATan2(posmod[1],posmod[0]); 
172     if(phimod<0) phimod+=2*TMath::Pi();
173     Double_t phi1= phimod+deltaPhi*double(fLadOnLay2);
174     if(phi1<0) phi1+=2*TMath::Pi();
175     if(phi1>2*TMath::Pi()) phi1-=2*TMath::Pi();
176     Double_t philad1=phi0-phi1;
177     UShort_t lad1;
178     Double_t ladder1=(philad1)/(deltaPhi) +1.; 
179     if(ladder1<1){ladder1=40+ladder1;}
180     lad1=int(ladder1+0.5);
181     fLadders[i]=lad1;
182   }
183 }
184
185
186 //______________________________________________________________________
187 void AliITSVertexer::WriteCurrentVertex(){
188   // Write the current AliVertex object to file fOutFile
189   AliRunLoader *rl = AliRunLoader::GetRunLoader();
190   AliITSLoader* itsLoader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
191   fCurrentVertex->SetName("Vertex");
192   //  const char * name = fCurrentVertex->GetName();
193   //  itsLoader->SetVerticesContName(name);
194   Int_t rc = itsLoader->PostVertex(fCurrentVertex);
195   rc = itsLoader->WriteVertices();
196 }
197