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