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