]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterReconstructor.cxx
New segmentation with switch between old and new (Ch. Finck)
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterReconstructor.cxx
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 ////////////////////////////////////
19 //
20 // MUON cluster reconstructor for MUON
21 //
22 // Should implement a virtual class ClusterFinder to chose between VS and AZ method
23 ////////////////////////////////////
24
25 #include "AliMUONClusterReconstructor.h"
26 #include "AliRun.h" // for gAlice
27 #include "AliRunLoader.h"
28 #include "AliLoader.h"
29
30 #include "AliMUON.h"
31 #include "AliMUONDigit.h"
32 #include "AliMUONConstants.h"
33 #include "AliMUONData.h"
34 #include "AliMUONClusterFinderVS.h"
35 #include "AliMUONClusterInput.h"
36 #include "AliMUONRawCluster.h"
37 #include "AliRawReader.h" // for raw data
38 #include "AliLog.h"
39
40
41 const Int_t AliMUONClusterReconstructor::fgkDefaultPrintLevel = 0;
42
43 ClassImp(AliMUONClusterReconstructor) // Class implementation in ROOT context
44
45 //__________________________________________________________________________
46 AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliLoader* loader)
47   : TObject(),
48     fMUONData(0),
49     fPrintLevel(fgkDefaultPrintLevel),
50     fDebug(0)
51 {
52   // Standard Constructor
53
54   // initialize loader's
55   fLoader = loader;
56
57   // initialize container
58   fMUONData  = new AliMUONData(fLoader,"MUON","MUON");
59
60   // reconstruction model
61   fRecModel = new AliMUONClusterFinderVS();
62   //fRecModel = new AliMUONClusterFinderAZ();
63
64 }
65
66 //__________________________________________________________________________
67 AliMUONClusterReconstructor::AliMUONClusterReconstructor()
68   : TObject(),
69     fMUONData(0),
70     fPrintLevel(fgkDefaultPrintLevel),
71     fDebug(0),
72     fLoader(0)
73 {
74   // Default Constructor
75 }
76
77 //_______________________________________________________________________
78 AliMUONClusterReconstructor::AliMUONClusterReconstructor (const AliMUONClusterReconstructor& rhs)
79   : TObject(rhs)
80 {
81 // Protected copy constructor
82
83   AliFatal("Not implemented.");
84 }
85
86 //_______________________________________________________________________
87 AliMUONClusterReconstructor & 
88 AliMUONClusterReconstructor::operator=(const AliMUONClusterReconstructor& rhs)
89 {
90 // Protected assignement operator
91
92   if (this == &rhs) return *this;
93
94   AliFatal("Not implemented.");
95     
96   return *this;  
97 }
98
99 //__________________________________________________________________________
100 AliMUONClusterReconstructor::~AliMUONClusterReconstructor(void)
101 {
102
103   if (fMUONData)
104     delete fMUONData;
105
106   return;
107 }
108 //____________________________________________________________________
109 void AliMUONClusterReconstructor::Digits2Clusters()
110 {
111 //
112 //  Perform cluster finding
113 //
114
115     AliMUON* pMUON = (AliMUON*) gAlice->GetModule("MUON");
116     if (pMUON->WhichSegmentation() == 1)
117       Digits2ClustersOld();
118     else
119       Digits2ClustersNew();
120
121 }
122 //____________________________________________________________________
123 void AliMUONClusterReconstructor::Digits2ClustersOld()
124 {
125
126 //
127 //  Perform cluster finding
128 //
129     TClonesArray *dig1, *dig2;
130     Int_t ndig, k;
131     dig1 = new TClonesArray("AliMUONDigit",1000);
132     dig2 = new TClonesArray("AliMUONDigit",1000);
133     AliMUONDigit *digit;
134
135 // Loop on chambers and on cathode planes     
136     TClonesArray * muonDigits;
137
138     for (Int_t ich = 0; ich < 10; ich++) {
139
140         fMUONData->ResetDigits();
141         fMUONData->GetCathode(0);
142         //TClonesArray *
143         muonDigits = fMUONData->Digits(ich); 
144         ndig=muonDigits->GetEntriesFast();
145         AliDebug(1,Form("1 Found %d digits in %p chamber %d", ndig, (void*)muonDigits,ich));
146         TClonesArray &lhits1 = *dig1;
147         Int_t n = 0;
148         for (k = 0; k < ndig; k++) {
149             digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
150             new(lhits1[n++]) AliMUONDigit(*digit);
151         }
152         fMUONData->ResetDigits();
153         fMUONData->GetCathode(1);
154         muonDigits =  fMUONData->Digits(ich);  
155         ndig=muonDigits->GetEntriesFast();
156         AliDebug(1,Form("2 Found %d digits in %p %d", ndig, (void*)muonDigits, ich));
157         TClonesArray &lhits2 = *dig2;
158         n=0;
159         
160         for (k=0; k<ndig; k++) {
161             digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
162             new(lhits2[n++]) AliMUONDigit(*digit);
163         }
164
165         if (fRecModel) {         
166             AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
167             fRecModel->FindRawClusters();
168         }
169         // copy into the container
170         TClonesArray* tmp = fRecModel->GetRawClusters();
171         for (Int_t id = 0; id < tmp->GetEntriesFast(); id++) {
172           AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id);
173           fMUONData->AddRawCluster(ich, *pClus);
174         }
175         dig1->Delete();
176         dig2->Delete();
177     } // for ich
178     delete dig1;
179     delete dig2;
180 }
181 //____________________________________________________________________
182 void AliMUONClusterReconstructor::Digits2ClustersNew()
183 {
184
185     TClonesArray *dig1, *dig2, *digAll;
186     Int_t ndig, k, idDE, idDE_prev;
187     dig1 = new TClonesArray("AliMUONDigit",1000);
188     dig2 = new TClonesArray("AliMUONDigit",1000);
189     digAll = new TClonesArray("AliMUONDigit",2000);
190
191     AliMUONDigit* digit;
192
193     TArrayI id(100); // contains the different IdDE
194     id.Reset();
195   
196 // Loop on chambers and on cathode planes     
197     TClonesArray* muonDigits;
198     Int_t n2;
199     Int_t n1;
200     Int_t flag = 0;
201
202     for (Int_t ich = 0; ich < AliMUONConstants::NTrackingCh(); ich++) {
203       n1 = 0;
204       n2 = 0;
205       //cathode 0
206       fMUONData->ResetDigits();
207       fMUONData->GetCathode(0);
208       muonDigits = fMUONData->Digits(ich); 
209       ndig = muonDigits->GetEntriesFast();
210       TClonesArray &lDigit = *digAll;
211
212       idDE_prev = 0;
213
214       for (k = 0; k < ndig; k++) {
215
216         digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
217         new(lDigit[n1++]) AliMUONDigit(*digit);
218         idDE = digit->DetElemId();
219         if (idDE != idDE_prev)
220           id.AddAt(idDE,n2++);
221         idDE_prev = idDE;
222       }
223
224       //cathode 1
225       fMUONData->ResetDigits();
226       fMUONData->GetCathode(1);
227       muonDigits =  fMUONData->Digits(ich);  
228       ndig = muonDigits->GetEntriesFast();
229
230       for (k = 0; k < ndig; k++) {
231
232         digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
233         new(lDigit[n1++]) AliMUONDigit(*digit);
234         idDE = digit->DetElemId();
235         flag = 0;
236
237         for (Int_t n = 0; n < id.GetSize(); n++) {
238           if (id[n] == idDE) {
239             flag = 1;
240             break;
241           }
242           if (flag) continue;
243           id[id.GetSize()+1] = idDE;
244         }
245       }
246
247       // loop over id DE
248       for (idDE = 0; idDE < id.GetSize(); idDE++) {
249
250         TClonesArray &lhits1 = *dig1;
251         TClonesArray &lhits2 = *dig2;
252         n1 = n2 = 0;
253
254         for (k = 0; k < digAll->GetEntriesFast(); k++) {
255           digit = (AliMUONDigit*) digAll->UncheckedAt(k);
256           if (id[idDE] == digit->DetElemId())
257             if (digit->Cathode() == 1)
258               new(lhits1[n1++]) AliMUONDigit(*digit);
259             else 
260               new(lhits2[n2++]) AliMUONDigit(*digit);
261
262         }
263
264         // cluster finder
265         if (fRecModel) {
266           AliMUONClusterInput::Instance()->SetDigits(ich, id[idDE], dig1, dig2);
267           fRecModel->FindRawClusters();
268         }
269         // copy into the container
270         TClonesArray* tmp = fRecModel->GetRawClusters();
271         for (Int_t id = 0; id < tmp->GetEntriesFast(); id++) {
272           AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id);
273           fMUONData->AddRawCluster(ich, *pClus);
274         }
275         dig1->Delete();
276         dig2->Delete();
277         digAll->Delete();
278
279       }
280     } // for ich
281     delete dig1;
282     delete dig2;
283     delete digAll;
284 }
285
286 //____________________________________________________________________
287 void AliMUONClusterReconstructor::Digits2Clusters(AliRawReader* /*rawReader*/)
288 {
289
290 //  Perform cluster finding form raw data
291
292    AliFatal("clusterization not implemented for raw data input");
293 }
294 //_______________________________________________________________________
295 void AliMUONClusterReconstructor::Trigger2Trigger() 
296 {
297 // copy trigger from TreeD to TreeR
298
299   fMUONData->SetTreeAddress("GLT");
300   fMUONData->GetTriggerD();
301 }
302 //_______________________________________________________________________
303 void AliMUONClusterReconstructor::Trigger2Trigger(AliRawReader* /*rawReader*/) 
304 {
305 // call the Trigger Algorithm from raw data and fill TreeR 
306
307    AliFatal("Trigger not implemented for raw data input");
308
309 }