]>
Commit | Line | Data |
---|---|---|
cc87ebcd | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | ||
843092b4 | 18 | // ------------------------------------- |
19 | // Class AliMUONEventRecoCombi | |
20 | // ------------------------------------- | |
21 | // Steering class for the combined cluster / track reconstructor | |
22 | // Author: Alexander Zinchenko, JINR Dubna | |
23 | ||
cc87ebcd | 24 | #include "AliMUONEventRecoCombi.h" |
63ed9c6b | 25 | |
cc87ebcd | 26 | #include "AliMUONData.h" |
27 | #include "AliMUONDetElement.h" | |
28 | #include "AliMUONDigit.h" | |
29 | #include "AliMUONHitForRec.h" | |
30 | #include "AliMUONRawCluster.h" | |
31 | #include "AliMUONTrackK.h" | |
2457f726 | 32 | #include "AliMUONTrackReconstructorK.h" |
cc87ebcd | 33 | #include "AliMUONConstants.h" |
63ed9c6b | 34 | |
cc87ebcd | 35 | #include "AliLoader.h" |
b4508f33 | 36 | #include "AliLog.h" |
cc87ebcd | 37 | |
63ed9c6b | 38 | #include <Riostream.h> |
39 | #include <TClonesArray.h> | |
40 | #include <TArrayS.h> | |
41 | #include <TArrayD.h> | |
cc87ebcd | 42 | |
7945aae7 | 43 | /// \cond CLASSIMP |
63ed9c6b | 44 | ClassImp(AliMUONEventRecoCombi) |
7945aae7 | 45 | /// \endcond |
46 | ||
47 | AliMUONEventRecoCombi* AliMUONEventRecoCombi::fgRecoCombi = 0; | |
63ed9c6b | 48 | |
cc87ebcd | 49 | //_________________________________________________________________________ |
b4508f33 | 50 | AliMUONEventRecoCombi::AliMUONEventRecoCombi() |
51 | : TObject(), | |
52 | fDetElems(0x0), | |
53 | fZ(new TArrayD(20)), | |
54 | fNZ(0), | |
55 | fDEvsZ(0x0) | |
cc87ebcd | 56 | { |
7945aae7 | 57 | /// Ctor |
cc87ebcd | 58 | |
59 | fDetElems = new TClonesArray("AliMUONDetElement", 20); | |
cc87ebcd | 60 | } |
61 | ||
62 | //_________________________________________________________________________ | |
63 | AliMUONEventRecoCombi* AliMUONEventRecoCombi::Instance() | |
64 | { | |
b4508f33 | 65 | /// Return pointer to the singleton instance |
cc87ebcd | 66 | |
67 | if (fgRecoCombi == 0) { | |
68 | fgRecoCombi = new AliMUONEventRecoCombi(); | |
69 | } | |
cc87ebcd | 70 | return fgRecoCombi; |
71 | } | |
72 | ||
73 | //_________________________________________________________________________ | |
74 | AliMUONEventRecoCombi::~AliMUONEventRecoCombi() | |
75 | { | |
7945aae7 | 76 | /// Destructor |
cc87ebcd | 77 | delete fDetElems; |
78 | delete fZ; | |
79 | delete [] fDEvsZ; | |
80 | } | |
81 | ||
82 | //_________________________________________________________________________ | |
3bc8b580 | 83 | void AliMUONEventRecoCombi::FillEvent(AliMUONData *data, AliMUONClusterFinderAZ *recModel) |
cc87ebcd | 84 | { |
7945aae7 | 85 | /// Fill event information |
cc87ebcd | 86 | |
87 | // Clear previous event | |
88 | fDetElems->Delete(); | |
89 | for (Int_t i = 0; i < fNZ; i++) delete [] fDEvsZ[i]; | |
90 | delete [] fDEvsZ; fDEvsZ = NULL; | |
91 | fNZ = -1; | |
92 | ||
93 | Int_t nDetElem = 0; | |
94 | for (Int_t ich = 0; ich < 6; ich++) { | |
95 | // loop over chambers 0-5 | |
3bc8b580 | 96 | TClonesArray *digs = data->Digits(ich); |
b4508f33 | 97 | digs->Sort(); //AZ |
cc87ebcd | 98 | //cout << ich << " " << digs << " " << digs->GetEntriesFast() << endl; |
99 | Int_t idDE = -1; | |
100 | for (Int_t i = 0; i < digs->GetEntriesFast(); i++) { | |
101 | AliMUONDigit *dig = (AliMUONDigit*) digs->UncheckedAt(i); | |
102 | if (dig->DetElemId() != idDE) { | |
103 | idDE = dig->DetElemId(); | |
104 | new ((*fDetElems)[nDetElem++]) AliMUONDetElement(idDE, dig, recModel); | |
105 | } | |
106 | else ((AliMUONDetElement*)fDetElems->UncheckedAt(nDetElem-1))->AddDigit(dig); | |
107 | } | |
108 | } | |
109 | ||
b4508f33 | 110 | // Compute average Z-position |
111 | for (Int_t i = 0; i < nDetElem; i++) { | |
112 | AliMUONDetElement *detElem = (AliMUONDetElement*) fDetElems->UncheckedAt(i); | |
113 | Int_t nDigs = detElem->Digits(0)->GetEntriesFast() + | |
114 | detElem->Digits(1)->GetEntriesFast(); | |
115 | detElem->SetZ(detElem->Z() / nDigs); | |
116 | } | |
117 | ||
cc87ebcd | 118 | // Sort according to Z |
119 | fDetElems->Sort(); | |
120 | //cout << nDetElem << endl; | |
121 | // Fill det. elems. position index in the container | |
122 | for (Int_t i = 0; i < nDetElem; i++) | |
123 | ((AliMUONDetElement*)fDetElems->UncheckedAt(i))->SetIndex(i); | |
124 | ||
125 | // Find groups of det. elements with the same Z | |
126 | Double_t z0 = -99999; | |
127 | TArrayS *nPerZ = new TArrayS(20); | |
128 | for (Int_t i = 0; i < nDetElem; i++) { | |
129 | AliMUONDetElement *detElem = (AliMUONDetElement*) fDetElems->UncheckedAt(i); | |
3bc8b580 | 130 | detElem->Fill(data); |
b4508f33 | 131 | //cout << i << " " << detElem->IdDE() << " " << detElem->Z() << endl; |
132 | if (detElem->Z() - z0 < 0.05) { | |
cc87ebcd | 133 | // the same Z |
134 | (*nPerZ)[fNZ]++; | |
135 | } else { | |
b4508f33 | 136 | if (fZ->GetSize() <= fNZ+1) fZ->Set(fZ->GetSize()+10); |
137 | if (nPerZ->GetSize() <= fNZ+1) nPerZ->Set(nPerZ->GetSize()+10); | |
cc87ebcd | 138 | (*fZ)[++fNZ] = detElem->Z(); |
139 | z0 = detElem->Z(); | |
140 | (*nPerZ)[fNZ]++; | |
141 | } | |
142 | } | |
143 | fNZ++; | |
144 | /* | |
145 | cout << fNZ << endl; | |
146 | for (Int_t i = 0; i < 7; i++) { | |
3bc8b580 | 147 | cout << i << " " << data->RawClusters(i)->GetEntriesFast() << endl; |
cc87ebcd | 148 | } |
149 | */ | |
150 | ||
151 | // Build list of DE locations vs Z | |
152 | fDEvsZ = new Int_t* [fNZ]; | |
153 | Int_t iPos = 0; | |
154 | for (Int_t i = 0; i < fNZ; i++) { | |
155 | Int_t *idPerZ = new Int_t[(*nPerZ)[i]+1]; | |
156 | for (Int_t j = 1; j < (*nPerZ)[i]+1; j++) idPerZ[j] = iPos++; | |
157 | idPerZ[0] = (*nPerZ)[i]; // number of DE's as first element of array | |
158 | fDEvsZ[i] = idPerZ; | |
159 | //cout << (*nPerZ)[i] << " "; | |
160 | } | |
161 | //cout << endl; | |
162 | delete nPerZ; | |
163 | ||
164 | // Fill rec. point container for stations 4 and 5 | |
3bc8b580 | 165 | //cout << data->TreeR() << endl; |
166 | //data->MakeBranch("RC"); | |
b4508f33 | 167 | /* |
3bc8b580 | 168 | data->SetTreeAddress("RCC"); |
cc87ebcd | 169 | for (Int_t ch = 6; ch < 10; ch++) { |
3bc8b580 | 170 | TClonesArray *raw = data->RawClusters(ch); |
b4508f33 | 171 | cout << ch << " " << raw->GetEntriesFast() << " " << data->RawClusters(ch) << endl; |
172 | //for (Int_t i = 0; i < raw->GetEntriesFast(); i++) { | |
173 | for (Int_t i = 0; i < TMath::Min(raw->GetEntriesFast(),1000); i++) { | |
cc87ebcd | 174 | AliMUONRawCluster *clus = (AliMUONRawCluster*) raw->UncheckedAt(i); |
3bc8b580 | 175 | data->AddRawCluster(ch, *clus); |
b4508f33 | 176 | cout << i << " " << raw->GetEntriesFast() << endl; |
cc87ebcd | 177 | } |
178 | } | |
b4508f33 | 179 | */ |
3bc8b580 | 180 | //data->SetTreeAddress("RC"); |
cc87ebcd | 181 | } |
182 | ||
183 | //_________________________________________________________________________ | |
2457f726 | 184 | void AliMUONEventRecoCombi::FillRecP(AliMUONData *dataCluster, AliMUONTrackReconstructorK *recoTrack) const |
cc87ebcd | 185 | { |
7945aae7 | 186 | /// Fill rec. points used for tracking from det. elems |
cc87ebcd | 187 | |
188 | TClonesArray *tracks = recoTrack->GetRecTracksPtr(); | |
189 | for (Int_t i = 0; i < recoTrack->GetNRecTracks(); i++) { | |
190 | AliMUONTrackK *track = (AliMUONTrackK*) tracks->UncheckedAt(i); | |
843092b4 | 191 | TObjArray *hits = track->GetTrackHits(); |
cc87ebcd | 192 | for (Int_t j = 0; j < track->GetNTrackHits(); j++) { |
193 | AliMUONHitForRec *hit = (AliMUONHitForRec*) hits->UncheckedAt(j); | |
194 | if (hit->GetHitNumber() >= 0) continue; | |
195 | // Combined cluster / track finder | |
196 | Int_t index = -hit->GetHitNumber() / 100000; | |
197 | Int_t iPos = -hit->GetHitNumber() - index * 100000; | |
198 | AliMUONRawCluster *clus = (AliMUONRawCluster*) DetElem(index-1)->RawClusters()->UncheckedAt(iPos); | |
199 | //cout << j << " " << iPos << " " << clus << " " << index << " " << DetElem(index-1)->Chamber() << endl; | |
200 | dataCluster->AddRawCluster(DetElem(index-1)->Chamber(), *clus); | |
201 | } | |
202 | } | |
203 | /* | |
204 | for (Int_t ch = 0; ch < 10; ch++) { | |
205 | TClonesArray *raw = dataCluster->RawClusters(ch); | |
206 | cout << ch << " " << raw->GetEntriesFast() << endl; | |
207 | } | |
208 | */ | |
209 | // Reset raw cluster tree | |
210 | /* | |
211 | char branchname[30]; | |
212 | TBranch * branch = 0x0; | |
213 | if ( dataCluster->TreeR()) { | |
214 | if ( dataCluster->IsTriggerBranchesInTree() ) { | |
215 | // Branch per branch filling | |
216 | for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) { | |
217 | sprintf(branchname,"%sRawClusters%d",dataCluster->GetName(),i+1); | |
218 | branch = dataCluster->TreeR()->GetBranch(branchname); | |
219 | //branch->Fill(); | |
220 | //branch->Reset(); | |
221 | //branch->Clear(); | |
222 | branch->Delete(); | |
223 | } | |
224 | } | |
225 | //else TreeR()->Fill(); | |
226 | else dataCluster->TreeR()->Reset(); | |
227 | } | |
228 | */ | |
229 | } | |
230 | ||
231 | //_________________________________________________________________________ | |
232 | Int_t AliMUONEventRecoCombi::IZfromHit(AliMUONHitForRec *hit) const | |
233 | { | |
7945aae7 | 234 | /// Get Iz of det. elem. from the hit |
cc87ebcd | 235 | |
236 | Int_t index = -hit->GetHitNumber() / 100000 - 1, iz0 = -1; | |
237 | for (Int_t iz = 0; iz < fNZ; iz++) { | |
238 | Int_t *pDEatZ = DEatZ(iz); | |
239 | Int_t nDetElem = pDEatZ[-1]; | |
240 | for (Int_t j = 0; j < nDetElem; j++) { | |
241 | if (pDEatZ[j] != index) continue; | |
242 | iz0 = iz; | |
243 | break; | |
244 | } | |
245 | if (iz0 >= 0) break; | |
246 | } | |
247 | return iz0; | |
248 | } |