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