]>
Commit | Line | Data |
---|---|---|
7eb061fb | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | ||
19 | //------------------------------------------------------------------------- | |
20 | // Class AliMixedEvent | |
21 | // VEvent which is the container of several VEvents | |
22 | // Use Case: Event Mixing | |
23 | // Origin: Andreas Morsch, CERN, Andreas.Morsch@cern.ch | |
24 | //------------------------------------------------------------------------- | |
25 | ||
26 | ||
27 | #include "AliMixedEvent.h" | |
bbeb9cae | 28 | #include "AliESDVertex.h" |
29 | #include "AliExternalTrackParam.h" | |
30 | #include "AliESDtrack.h" | |
31 | #include "TVector3.h" | |
32 | #include "AliAODVertex.h" | |
7eb061fb | 33 | #include <TMath.h> |
bbeb9cae | 34 | #include <TMatrix.h> |
35 | #include <TMatrixD.h> | |
7eb061fb | 36 | |
37 | ClassImp(AliMixedEvent) | |
38 | ||
39 | ||
40 | AliMixedEvent::AliMixedEvent() : | |
41 | AliVEvent(), | |
bbeb9cae | 42 | fEventList(), |
7eb061fb | 43 | fNEvents(0), |
44 | fNumberOfTracks(0), | |
8c755c03 | 45 | fNTracksCumul(0), |
46 | fMeanVertex(0) | |
7eb061fb | 47 | { |
48 | // Default constructor | |
49 | } | |
50 | ||
7eb061fb | 51 | AliMixedEvent::AliMixedEvent(const AliMixedEvent& Evnt) : |
a2813d8b | 52 | AliVEvent(Evnt), |
bbeb9cae | 53 | fEventList(), |
54 | fNEvents(0), | |
a2813d8b | 55 | fNumberOfTracks(0), |
8c755c03 | 56 | fNTracksCumul(0), |
57 | fMeanVertex(0) | |
a2813d8b | 58 | { } // Copy constructor |
7eb061fb | 59 | |
60 | AliMixedEvent& AliMixedEvent::operator=(const AliMixedEvent& vEvnt) | |
61 | { if (this!=&vEvnt) { | |
62 | AliVEvent::operator=(vEvnt); | |
63 | } | |
64 | ||
65 | return *this; | |
66 | } | |
67 | ||
68 | ||
69 | void AliMixedEvent::AddEvent(AliVEvent* evt) | |
70 | { | |
71 | // Add a new event to the list | |
bbeb9cae | 72 | fEventList.AddLast(evt); |
7eb061fb | 73 | } |
74 | ||
75 | ||
76 | void AliMixedEvent::Init() | |
77 | { | |
78 | // Initialize meta information | |
79 | fNEvents = fEventList.GetEntries(); | |
80 | fNTracksCumul = new Int_t[fNEvents]; | |
81 | fNumberOfTracks = 0; | |
82 | TIter next(&fEventList); | |
83 | AliVEvent* event; | |
84 | Int_t iev = 0; | |
85 | ||
86 | while((event = (AliVEvent*)next())) { | |
87 | fNTracksCumul[iev++] = fNumberOfTracks; | |
88 | fNumberOfTracks += (event->GetNumberOfTracks()); | |
89 | } | |
90 | } | |
91 | ||
92 | ||
93 | AliVParticle* AliMixedEvent::GetTrack(Int_t i) const | |
94 | { | |
95 | // Return track # i | |
96 | Int_t iEv = TMath::BinarySearch(fNEvents, fNTracksCumul, i); | |
18476ce9 | 97 | while((iEv < (fNEvents - 1)) && (fNTracksCumul[iEv] == fNTracksCumul[iEv+1])) {iEv++;} |
bbeb9cae | 98 | |
7eb061fb | 99 | Int_t irel = i - fNTracksCumul[iEv]; |
100 | AliVEvent* evt = (AliVEvent*) (fEventList.At(iEv)); | |
101 | return (evt->GetTrack(irel)); | |
102 | } | |
103 | ||
bbeb9cae | 104 | const AliVVertex* AliMixedEvent::GetEventVertex(Int_t i) const |
105 | { | |
106 | // Return track # i | |
107 | Int_t iEv = TMath::BinarySearch(fNEvents, fNTracksCumul, i); | |
108 | while((iEv < (fNEvents - 1)) && (fNTracksCumul[iEv] == fNTracksCumul[iEv+1])) {iEv++;} | |
109 | AliVEvent* evt = (AliVEvent*) (fEventList.At(iEv)); | |
110 | return (evt->GetPrimaryVertex()); | |
111 | } | |
7eb061fb | 112 | |
113 | void AliMixedEvent::Reset() | |
114 | { | |
115 | // Reset the event | |
116 | fEventList.Clear(); | |
117 | fNEvents = 0; | |
118 | fNumberOfTracks = 0; | |
119 | if (fNTracksCumul) { | |
120 | delete[] fNTracksCumul; | |
121 | fNTracksCumul = 0; | |
122 | } | |
123 | } | |
124 | ||
125 | Int_t AliMixedEvent::EventIndex(Int_t itrack) | |
126 | { | |
127 | // Return the event index for track #itrack | |
128 | return TMath::BinarySearch(fNEvents, fNTracksCumul, itrack); | |
129 | } | |
bbeb9cae | 130 | |
131 | void AliMixedEvent::ComputeVtx(TObjArray *vertices, Double_t *pos,Double_t *sig){ | |
132 | // | |
133 | // Calculate the mean vertex psoitions from events in the buffer | |
134 | ||
135 | Int_t nentries = vertices->GetEntriesFast(); | |
136 | Double_t sum[3]={0.,0.,0.}; | |
137 | Double_t sumsigma[6]={0.,0.,0.,0.,0.,0.}; | |
138 | ||
139 | for(Int_t ivtx = 0; ivtx < nentries; ivtx++){ | |
140 | AliAODVertex *vtx=(AliAODVertex*)vertices->UncheckedAt(ivtx); | |
141 | if(!vtx) return; | |
142 | Double_t covariance[6]; | |
143 | vtx->GetCovMatrix(covariance); | |
144 | ||
145 | Double_t vtxPos[3]; | |
146 | vtx->GetXYZ(vtxPos); | |
147 | if(covariance[0]==0) continue; | |
148 | sum[0]+=vtxPos[0]*(1./covariance[0]); | |
149 | sumsigma[0]+=(1./covariance[0]); | |
150 | if(covariance[2]==0) continue; | |
151 | sum[1]+=vtxPos[1]*(1./covariance[2]); | |
152 | sumsigma[2]+=(1./covariance[2]); | |
153 | if(covariance[5]==0) continue; | |
154 | sum[2]+=vtxPos[2]*(1./covariance[5]); | |
155 | sumsigma[5]+=(1./covariance[5]); | |
156 | if(covariance[1]==0) continue; | |
157 | sumsigma[1]+=(1./covariance[1]); | |
158 | if(covariance[3]==0) continue; | |
159 | sumsigma[3]+=(1./covariance[3]); | |
160 | if(covariance[4]==0) continue; | |
161 | sumsigma[4]+=(1./covariance[4]); | |
162 | } | |
163 | ||
164 | for(Int_t i=0;i<3;i++){ | |
165 | if(sumsigma[i]==0) continue; | |
166 | pos[i]=sum[i]/sumsigma[i]; | |
167 | } | |
168 | for(Int_t i2=0;i2<6;i2++){ | |
169 | if(sumsigma[i2]==0) {sig[i2]=0.; continue;} | |
170 | sig[i2]=1./sumsigma[i2]; | |
171 | } | |
172 | return; | |
173 | } | |
174 |