]>
Commit | Line | Data |
---|---|---|
308c2f7c | 1 | #include "AliLog.h" |
2 | #include "AliMultiplicity.h" | |
32e63e47 | 3 | #include "AliITSgeomTGeo.h" |
f510fd70 | 4 | #include "AliITSDetTypeRec.h" |
27167524 | 5 | #include "AliITSVertexer.h" |
27167524 | 6 | #include "AliITSLoader.h" |
27167524 | 7 | #include "AliITSMultReconstructor.h" |
d325d83f | 8 | #include "AliITSRecPointContainer.h" |
a65111f1 | 9 | #include "AliRunLoader.h" |
27167524 | 10 | |
11 | const Float_t AliITSVertexer::fgkPipeRadius = 3.0; | |
c5f0f3c1 | 12 | |
13 | ClassImp(AliITSVertexer) | |
14 | ||
15 | ////////////////////////////////////////////////////////////////////// | |
16 | // Base class for primary vertex reconstruction // | |
d681bb2d | 17 | // AliESDVertexer is a class for full 3D primary vertex finding // |
0c1383c1 | 18 | // derived classes: AliITSvertexer3D, AliITSVertexerZ. // |
3acc14d5 | 19 | // AliITSVertexerCosmics // |
c5f0f3c1 | 20 | ////////////////////////////////////////////////////////////////////// |
21 | ||
8c42830a | 22 | /* $Id$ */ |
23 | ||
c5f0f3c1 | 24 | //______________________________________________________________________ |
27167524 | 25 | AliITSVertexer::AliITSVertexer():AliVertexer(), |
a65111f1 | 26 | fLadders(NULL), |
308c2f7c | 27 | fLadOnLay2(0), |
1ff24d0a | 28 | fComputeMultiplicity(kFALSE), |
06a7cbee | 29 | fDetTypeRec(NULL), |
8c32ba44 | 30 | fMinTrackletsForPilup(0), |
31 | fIsPileup(0), | |
32 | fNTrpuv(-2), | |
33 | fZpuv(-9999999.), | |
6b4d9537 | 34 | fNoVertices(0), |
35 | fVertArray(NULL), | |
308c2f7c | 36 | fFirstEvent(0), |
06a7cbee | 37 | fLastEvent(-1) |
27167524 | 38 | { |
308c2f7c | 39 | // Default Constructor |
27167524 | 40 | SetLaddersOnLayer2(); |
8c32ba44 | 41 | SetMinTrackletsForPilup(); |
8c42830a | 42 | for(Int_t i=0; i<kNSPDMod;i++) fUseModule[i]=kTRUE; |
c5f0f3c1 | 43 | } |
44 | ||
27167524 | 45 | //______________________________________________________________________ |
46 | AliITSVertexer::~AliITSVertexer() { | |
47 | // Destructor | |
f510fd70 | 48 | delete [] fLadders; |
49 | delete []fVertArray; | |
27167524 | 50 | } |
51 | ||
6b4d9537 | 52 | //______________________________________________________________________ |
53 | void AliITSVertexer::ResetVertex(){ | |
54 | // Resets vertex related data members | |
55 | if(fNoVertices > 0){ | |
56 | if(fVertArray) delete []fVertArray; | |
57 | fVertArray = NULL; | |
58 | fNoVertices = 0; | |
59 | } | |
60 | fIsPileup=kFALSE; | |
61 | fNTrpuv=-2; | |
62 | fZpuv=-99999.; | |
63 | ||
64 | } | |
32e449be | 65 | //______________________________________________________________________ |
308c2f7c | 66 | void AliITSVertexer::FindMultiplicity(TTree *itsClusterTree){ |
32e449be | 67 | // Invokes AliITSMultReconstructor to determine the |
68 | // charged multiplicity in the pixel layers | |
69 | if(fMult){delete fMult; fMult = 0;} | |
6873ed43 | 70 | |
32e449be | 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); | |
d7c5c1e4 | 98 | fMult = new AliMultiplicity(0,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]; | |
d7c5c1e4 | 136 | Int_t *labelss = new Int_t [nosingleclus]; |
968e8539 | 137 | for(Int_t i=0;i<nosingleclus;i++){ |
9b373e9a | 138 | ths[i] = multReco.GetCluster(i)[0]; |
139 | phs[i] = multReco.GetCluster(i)[1]; | |
b7bd9ab6 | 140 | labelss[i] = (Int_t)multReco.GetCluster(i)[2]; |
968e8539 | 141 | } |
9b373e9a | 142 | Short_t nfcL1 = multReco.GetNFiredChips(0); |
143 | Short_t nfcL2 = multReco.GetNFiredChips(1); | |
d7c5c1e4 | 144 | fMult = new AliMultiplicity(notracks,tht,phi,dtht,dphi,labels,labelsL2,nosingleclus,ths,phs,labelss,nfcL1,nfcL2,fastOrFiredMap); |
adc4b00f | 145 | fMult->SetFiredChipMap(firedChipMap); |
d325d83f | 146 | AliITSRecPointContainer* rcont = AliITSRecPointContainer::Instance(); |
147 | fMult->SetITSClusters(0,rcont->GetNClustersInLayer(1,itsClusterTree)); | |
148 | for(Int_t kk=2;kk<=6;kk++){ | |
149 | fMult->SetITSClusters(kk-1,rcont->GetNClustersInLayerFast(kk)); | |
150 | } | |
968e8539 | 151 | delete [] tht; |
32e449be | 152 | delete [] phi; |
fa9ed8e9 | 153 | delete [] dtht; |
32e449be | 154 | delete [] dphi; |
968e8539 | 155 | delete [] ths; |
156 | delete [] phs; | |
d6fc37c1 | 157 | delete [] labels; |
0939e22a | 158 | delete [] labelsL2; |
d7c5c1e4 | 159 | delete [] labelss; |
308c2f7c | 160 | |
32e449be | 161 | return; |
162 | } | |
c5f0f3c1 | 163 | |
27167524 | 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 | |
a65111f1 | 168 | if(ladwid == fLadOnLay2 && fLadders)return; |
27167524 | 169 | fLadOnLay2=ladwid; |
32e63e47 | 170 | Int_t ladtot1=AliITSgeomTGeo::GetNLadders(1); |
27167524 | 171 | if(fLadders) delete [] fLadders; |
172 | fLadders=new UShort_t[ladtot1]; | |
173 | ||
174 | ||
175 | Double_t pos1[3],pos2[3]; | |
32e63e47 | 176 | Int_t mod1=AliITSgeomTGeo::GetModuleIndex(2,1,1); |
177 | AliITSgeomTGeo::GetTranslation(mod1,pos1); // position of the module in the MRS | |
27167524 | 178 | Double_t phi0=TMath::ATan2(pos1[1],pos1[0]); |
179 | if(phi0<0) phi0+=2*TMath::Pi(); | |
32e63e47 | 180 | Int_t mod2=AliITSgeomTGeo::GetModuleIndex(2,2,1); |
181 | AliITSgeomTGeo::GetTranslation(mod2,pos2); | |
27167524 | 182 | Double_t phi2=TMath::ATan2(pos2[1],pos2[0]); |
183 | if(phi2<0) phi2+=2*TMath::Pi(); | |
184 | Double_t deltaPhi= phi0-phi2; // phi width of a layer2 module | |
185 | ||
186 | for(Int_t i= 0; i<ladtot1;i++){ | |
32e63e47 | 187 | Int_t modlad= AliITSgeomTGeo::GetModuleIndex(1,i+1,1); |
27167524 | 188 | Double_t posmod[3]; |
32e63e47 | 189 | AliITSgeomTGeo::GetTranslation(modlad,posmod); |
27167524 | 190 | Double_t phimod=TMath::ATan2(posmod[1],posmod[0]); |
191 | if(phimod<0) phimod+=2*TMath::Pi(); | |
192 | Double_t phi1= phimod+deltaPhi*double(fLadOnLay2); | |
193 | if(phi1<0) phi1+=2*TMath::Pi(); | |
194 | if(phi1>2*TMath::Pi()) phi1-=2*TMath::Pi(); | |
195 | Double_t philad1=phi0-phi1; | |
196 | UShort_t lad1; | |
197 | Double_t ladder1=(philad1)/(deltaPhi) +1.; | |
198 | if(ladder1<1){ladder1=40+ladder1;} | |
199 | lad1=int(ladder1+0.5); | |
200 | fLadders[i]=lad1; | |
201 | } | |
202 | } | |
203 | ||
308c2f7c | 204 | |
205 | //______________________________________________________________________ | |
206 | void AliITSVertexer::Init(TString filename){ | |
207 | // Initialize the vertexer in case of | |
208 | // analysis of an entire file | |
33c3c91a | 209 | AliRunLoader *rl = AliRunLoader::Instance(); |
308c2f7c | 210 | if(!rl){ |
3457dd2d | 211 | AliFatal("Run Loader not found"); |
212 | return; | |
308c2f7c | 213 | } |
214 | if (fLastEvent < 0) SetLastEvent(rl->GetNumberOfEvents()-1); | |
215 | ||
216 | AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader"); | |
217 | if(!filename.Contains("default"))itsloader->SetVerticesFileName(filename); | |
218 | if(!filename.Contains("null"))itsloader->LoadVertices("recreate"); | |
219 | } | |
27167524 | 220 | |
c5f0f3c1 | 221 | //______________________________________________________________________ |
222 | void AliITSVertexer::WriteCurrentVertex(){ | |
223 | // Write the current AliVertex object to file fOutFile | |
33c3c91a | 224 | AliRunLoader *rl = AliRunLoader::Instance(); |
41b19549 | 225 | AliITSLoader* itsLoader = (AliITSLoader*) rl->GetLoader("ITSLoader"); |
88cb7938 | 226 | fCurrentVertex->SetName("Vertex"); |
227 | // const char * name = fCurrentVertex->GetName(); | |
41b19549 | 228 | // itsLoader->SetVerticesContName(name); |
229 | Int_t rc = itsLoader->PostVertex(fCurrentVertex); | |
230 | rc = itsLoader->WriteVertices(); | |
c5f0f3c1 | 231 | } |
de4c520e | 232 | |
308c2f7c | 233 | //______________________________________________________________________ |
234 | void AliITSVertexer::FindVertices(){ | |
235 | // computes the vertices of the events in the range FirstEvent - LastEvent | |
236 | ||
33c3c91a | 237 | AliRunLoader *rl = AliRunLoader::Instance(); |
308c2f7c | 238 | AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader"); |
239 | itsloader->LoadRecPoints("read"); | |
240 | for(Int_t i=fFirstEvent;i<=fLastEvent;i++){ | |
241 | rl->GetEvent(i); | |
242 | TTree* cltree = itsloader->TreeR(); | |
243 | FindVertexForCurrentEvent(cltree); | |
244 | if(fCurrentVertex){ | |
245 | WriteCurrentVertex(); | |
246 | } | |
247 | else { | |
248 | AliDebug(1,Form("Vertex not found for event %d",i)); | |
249 | } | |
250 | } | |
251 | } |