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