Line data Source code
1 : #include "AliLog.h"
2 : #include "AliMultiplicity.h"
3 : #include "AliITSgeomTGeo.h"
4 : #include "AliITSDetTypeRec.h"
5 : #include "AliITSVertexer.h"
6 : #include "AliITSLoader.h"
7 : #include "AliITSMultReconstructor.h"
8 : #include "AliITSRecPointContainer.h"
9 : #include "AliRunLoader.h"
10 :
11 : const Float_t AliITSVertexer::fgkPipeRadius = 3.0;
12 :
13 118 : ClassImp(AliITSVertexer)
14 :
15 : //////////////////////////////////////////////////////////////////////
16 : // Base class for primary vertex reconstruction //
17 : // AliESDVertexer is a class for full 3D primary vertex finding //
18 : // derived classes: AliITSvertexer3D, AliITSVertexerZ. //
19 : // AliITSVertexerCosmics //
20 : //////////////////////////////////////////////////////////////////////
21 :
22 : /* $Id$ */
23 :
24 : //______________________________________________________________________
25 8 : AliITSVertexer::AliITSVertexer():AliVertexer(),
26 8 : fLadders(NULL),
27 8 : fLadOnLay2(0),
28 8 : fComputeMultiplicity(kFALSE),
29 8 : fDetTypeRec(NULL),
30 8 : fMinTrackletsForPilup(0),
31 8 : fIsPileup(0),
32 8 : fNTrpuv(-2),
33 8 : fZpuv(-9999999.),
34 8 : fNoVertices(0),
35 8 : fVertArray(NULL),
36 8 : fFirstEvent(0),
37 8 : fLastEvent(-1)
38 24 : {
39 : // Default Constructor
40 8 : SetLaddersOnLayer2();
41 8 : SetMinTrackletsForPilup();
42 3856 : for(Int_t i=0; i<kNSPDMod;i++) fUseModule[i]=kTRUE;
43 8 : }
44 :
45 : //______________________________________________________________________
46 16 : AliITSVertexer::~AliITSVertexer() {
47 : // Destructor
48 16 : delete [] fLadders;
49 32 : delete []fVertArray;
50 8 : }
51 :
52 : //______________________________________________________________________
53 : void AliITSVertexer::ResetVertex(){
54 : // Resets vertex related data members
55 16 : if(fNoVertices > 0){
56 0 : if(fVertArray) delete []fVertArray;
57 0 : fVertArray = NULL;
58 0 : fNoVertices = 0;
59 0 : }
60 8 : fIsPileup=kFALSE;
61 8 : fNTrpuv=-2;
62 8 : fZpuv=-99999.;
63 :
64 8 : }
65 : //______________________________________________________________________
66 : void AliITSVertexer::FindMultiplicity(TTree *itsClusterTree){
67 : // Invokes AliITSMultReconstructor to determine the
68 : // charged multiplicity in the pixel layers
69 0 : if(fMult){delete fMult; fMult = 0;}
70 :
71 : Bool_t success=kTRUE;
72 : Bool_t cosmics=kFALSE;
73 0 : if(!fCurrentVertex)success=kFALSE;
74 0 : if(fCurrentVertex && fCurrentVertex->GetNContributors()<1)success=kFALSE;
75 0 : if(fCurrentVertex && strstr(fCurrentVertex->GetTitle(),"cosmics")) {
76 : success=kFALSE;
77 : cosmics=kTRUE;
78 0 : }
79 :
80 : // get the FastOr bit mask
81 0 : TBits fastOrFiredMap = fDetTypeRec->GetFastOrFiredMap();
82 0 : TBits firedChipMap = fDetTypeRec->GetFiredChipMap(itsClusterTree);
83 :
84 0 : AliITSMultReconstructor multReco;
85 :
86 0 : if(!success){
87 0 : if(!cosmics) {
88 0 : AliDebug(1,"Tracklets multiplicity not determined because the primary vertex was not found");
89 0 : AliDebug(1,"Just counting the number of cluster-fired chips on the SPD layers");
90 : }
91 0 : if (!itsClusterTree) {
92 0 : AliError(" Invalid ITS cluster tree !\n");
93 0 : return;
94 : }
95 0 : multReco.LoadClusterFiredChips(itsClusterTree);
96 0 : Short_t nfcL1 = multReco.GetNFiredChips(0);
97 0 : Short_t nfcL2 = multReco.GetNFiredChips(1);
98 0 : fMult = new AliMultiplicity(0,0,0,0,0,0,0,0,0,0,0,nfcL1,nfcL2,fastOrFiredMap);
99 0 : fMult->SetFiredChipMap(firedChipMap);
100 0 : AliITSRecPointContainer* rcont = AliITSRecPointContainer::Instance();
101 0 : fMult->SetITSClusters(0,rcont->GetNClustersInLayer(1,itsClusterTree));
102 0 : for(Int_t kk=2;kk<=6;kk++){
103 0 : fMult->SetITSClusters(kk-1,rcont->GetNClustersInLayerFast(kk));
104 : }
105 : return;
106 : }
107 :
108 0 : if (!itsClusterTree) {
109 0 : AliError(" Invalid ITS cluster tree !\n");
110 0 : return;
111 : }
112 0 : Double_t vtx[3];
113 0 : fCurrentVertex->GetXYZ(vtx);
114 0 : Float_t vtxf[3];
115 0 : for(Int_t i=0;i<3;i++)vtxf[i]=vtx[i];
116 0 : multReco.SetHistOn(kFALSE);
117 0 : multReco.Reconstruct(itsClusterTree,vtxf,vtxf);
118 0 : Int_t notracks=multReco.GetNTracklets();
119 0 : Float_t *tht = new Float_t [notracks];
120 0 : Float_t *phi = new Float_t [notracks];
121 0 : Float_t *dtht = new Float_t [notracks];
122 0 : Float_t *dphi = new Float_t [notracks];
123 0 : Int_t *labels = new Int_t[notracks];
124 0 : Int_t *labelsL2 = new Int_t[notracks];
125 0 : for(Int_t i=0;i<multReco.GetNTracklets();i++){
126 0 : tht[i] = multReco.GetTracklet(i)[0];
127 0 : phi[i] = multReco.GetTracklet(i)[1];
128 0 : dtht[i] = multReco.GetTracklet(i)[3];
129 0 : dphi[i] = multReco.GetTracklet(i)[2];
130 0 : labels[i] = static_cast<Int_t>(multReco.GetTracklet(i)[4]);
131 0 : labelsL2[i] = static_cast<Int_t>(multReco.GetTracklet(i)[5]);
132 : }
133 0 : Int_t nosingleclus=multReco.GetNSingleClusters();
134 0 : Float_t *ths = new Float_t [nosingleclus];
135 0 : Float_t *phs = new Float_t [nosingleclus];
136 0 : Int_t *labelss = new Int_t [nosingleclus];
137 0 : for(Int_t i=0;i<nosingleclus;i++){
138 0 : ths[i] = multReco.GetCluster(i)[0];
139 0 : phs[i] = multReco.GetCluster(i)[1];
140 0 : labelss[i] = (Int_t)multReco.GetCluster(i)[2];
141 : }
142 0 : Short_t nfcL1 = multReco.GetNFiredChips(0);
143 0 : Short_t nfcL2 = multReco.GetNFiredChips(1);
144 0 : fMult = new AliMultiplicity(notracks,tht,phi,dtht,dphi,labels,labelsL2,nosingleclus,ths,phs,labelss,nfcL1,nfcL2,fastOrFiredMap);
145 0 : fMult->SetFiredChipMap(firedChipMap);
146 0 : AliITSRecPointContainer* rcont = AliITSRecPointContainer::Instance();
147 0 : fMult->SetITSClusters(0,rcont->GetNClustersInLayer(1,itsClusterTree));
148 0 : for(Int_t kk=2;kk<=6;kk++){
149 0 : fMult->SetITSClusters(kk-1,rcont->GetNClustersInLayerFast(kk));
150 : }
151 0 : delete [] tht;
152 0 : delete [] phi;
153 0 : delete [] dtht;
154 0 : delete [] dphi;
155 0 : delete [] ths;
156 0 : delete [] phs;
157 0 : delete [] labels;
158 0 : delete [] labelsL2;
159 0 : delete [] labelss;
160 :
161 : return;
162 0 : }
163 :
164 : //______________________________________________________________________
165 : void AliITSVertexer::SetLaddersOnLayer2(Int_t ladwid){
166 : // Calculates the array of ladders on layer 2 to be used with a
167 : // given ladder on layer 1
168 304 : if(ladwid == fLadOnLay2 && fLadders)return;
169 8 : fLadOnLay2=ladwid;
170 8 : Int_t ladtot1=AliITSgeomTGeo::GetNLadders(1);
171 8 : if(fLadders) delete [] fLadders;
172 8 : fLadders=new UShort_t[ladtot1];
173 :
174 :
175 8 : Double_t pos1[3],pos2[3];
176 8 : Int_t mod1=AliITSgeomTGeo::GetModuleIndex(2,1,1);
177 8 : AliITSgeomTGeo::GetTranslation(mod1,pos1); // position of the module in the MRS
178 8 : Double_t phi0=TMath::ATan2(pos1[1],pos1[0]);
179 8 : if(phi0<0) phi0+=2*TMath::Pi();
180 8 : Int_t mod2=AliITSgeomTGeo::GetModuleIndex(2,2,1);
181 8 : AliITSgeomTGeo::GetTranslation(mod2,pos2);
182 8 : Double_t phi2=TMath::ATan2(pos2[1],pos2[0]);
183 8 : if(phi2<0) phi2+=2*TMath::Pi();
184 8 : Double_t deltaPhi= phi0-phi2; // phi width of a layer2 module
185 :
186 336 : for(Int_t i= 0; i<ladtot1;i++){
187 160 : Int_t modlad= AliITSgeomTGeo::GetModuleIndex(1,i+1,1);
188 160 : Double_t posmod[3];
189 160 : AliITSgeomTGeo::GetTranslation(modlad,posmod);
190 160 : Double_t phimod=TMath::ATan2(posmod[1],posmod[0]);
191 240 : if(phimod<0) phimod+=2*TMath::Pi();
192 160 : Double_t phi1= phimod+deltaPhi*double(fLadOnLay2);
193 176 : if(phi1<0) phi1+=2*TMath::Pi();
194 160 : if(phi1>2*TMath::Pi()) phi1-=2*TMath::Pi();
195 160 : Double_t philad1=phi0-phi1;
196 : UShort_t lad1;
197 160 : Double_t ladder1=(philad1)/(deltaPhi) +1.;
198 160 : if(ladder1<1){ladder1=40+ladder1;}
199 160 : lad1=int(ladder1+0.5);
200 160 : fLadders[i]=lad1;
201 160 : }
202 112 : }
203 :
204 :
205 : //______________________________________________________________________
206 : void AliITSVertexer::Init(TString filename){
207 : // Initialize the vertexer in case of
208 : // analysis of an entire file
209 0 : AliRunLoader *rl = AliRunLoader::Instance();
210 0 : if(!rl){
211 0 : AliFatal("Run Loader not found");
212 0 : return;
213 : }
214 0 : if (fLastEvent < 0) SetLastEvent(rl->GetNumberOfEvents()-1);
215 :
216 0 : AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
217 0 : if(!filename.Contains("default"))itsloader->SetVerticesFileName(filename);
218 0 : if(!filename.Contains("null"))itsloader->LoadVertices("recreate");
219 0 : }
220 :
221 : //______________________________________________________________________
222 : void AliITSVertexer::WriteCurrentVertex(){
223 : // Write the current AliVertex object to file fOutFile
224 0 : AliRunLoader *rl = AliRunLoader::Instance();
225 0 : AliITSLoader* itsLoader = (AliITSLoader*) rl->GetLoader("ITSLoader");
226 0 : fCurrentVertex->SetName("Vertex");
227 : // const char * name = fCurrentVertex->GetName();
228 : // itsLoader->SetVerticesContName(name);
229 0 : itsLoader->PostVertex(fCurrentVertex);
230 0 : itsLoader->WriteVertices();
231 0 : }
232 :
233 : //______________________________________________________________________
234 : void AliITSVertexer::FindVertices(){
235 : // computes the vertices of the events in the range FirstEvent - LastEvent
236 :
237 0 : AliRunLoader *rl = AliRunLoader::Instance();
238 0 : AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
239 0 : itsloader->LoadRecPoints("read");
240 0 : for(Int_t i=fFirstEvent;i<=fLastEvent;i++){
241 0 : rl->GetEvent(i);
242 0 : TTree* cltree = itsloader->TreeR();
243 0 : FindVertexForCurrentEvent(cltree);
244 0 : if(fCurrentVertex){
245 0 : WriteCurrentVertex();
246 0 : }
247 : else {
248 0 : AliDebug(1,Form("Vertex not found for event %d",i));
249 : }
250 : }
251 0 : }
|