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