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