1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ////////////////////////////////////
20 // MUON cluster reconstructor for MUON
22 // Should implement a virtual class ClusterFinder to chose between VS and AZ method
23 ////////////////////////////////////
25 #include "AliMUONClusterReconstructor.h"
26 #include "AliRun.h" // for gAlice
27 #include "AliRunLoader.h"
28 #include "AliLoader.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
41 const Int_t AliMUONClusterReconstructor::fgkDefaultPrintLevel = 0;
43 ClassImp(AliMUONClusterReconstructor) // Class implementation in ROOT context
45 //__________________________________________________________________________
46 AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliLoader* loader)
49 fPrintLevel(fgkDefaultPrintLevel),
52 // Standard Constructor
54 // initialize loader's
57 // initialize container
58 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
60 // reconstruction model
61 fRecModel = new AliMUONClusterFinderVS();
62 //fRecModel = new AliMUONClusterFinderAZ();
66 //__________________________________________________________________________
67 AliMUONClusterReconstructor::AliMUONClusterReconstructor()
70 fPrintLevel(fgkDefaultPrintLevel),
74 // Default Constructor
77 //_______________________________________________________________________
78 AliMUONClusterReconstructor::AliMUONClusterReconstructor (const AliMUONClusterReconstructor& rhs)
81 // Protected copy constructor
83 AliFatal("Not implemented.");
86 //_______________________________________________________________________
87 AliMUONClusterReconstructor &
88 AliMUONClusterReconstructor::operator=(const AliMUONClusterReconstructor& rhs)
90 // Protected assignement operator
92 if (this == &rhs) return *this;
94 AliFatal("Not implemented.");
99 //__________________________________________________________________________
100 AliMUONClusterReconstructor::~AliMUONClusterReconstructor(void)
108 //____________________________________________________________________
109 void AliMUONClusterReconstructor::Digits2Clusters()
112 // Perform cluster finding
115 AliMUON* pMUON = (AliMUON*) gAlice->GetModule("MUON");
116 if (pMUON->WhichSegmentation() == 1)
117 Digits2ClustersOld();
119 Digits2ClustersNew();
122 //____________________________________________________________________
123 void AliMUONClusterReconstructor::Digits2ClustersOld()
127 // Perform cluster finding
129 TClonesArray *dig1, *dig2;
131 dig1 = new TClonesArray("AliMUONDigit",1000);
132 dig2 = new TClonesArray("AliMUONDigit",1000);
135 // Loop on chambers and on cathode planes
136 TClonesArray * muonDigits;
138 for (Int_t ich = 0; ich < 10; ich++) {
140 fMUONData->ResetDigits();
141 fMUONData->GetCathode(0);
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;
148 for (k = 0; k < ndig; k++) {
149 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
150 new(lhits1[n++]) AliMUONDigit(*digit);
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;
160 for (k=0; k<ndig; k++) {
161 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
162 new(lhits2[n++]) AliMUONDigit(*digit);
166 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
167 fRecModel->FindRawClusters();
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);
181 //____________________________________________________________________
182 void AliMUONClusterReconstructor::Digits2ClustersNew()
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);
193 TArrayI id(200); // contains the different IdDE
196 // Loop on chambers and on cathode planes
197 TClonesArray* muonDigits;
202 for (Int_t ich = 0; ich < AliMUONConstants::NTrackingCh(); ich++) {
208 fMUONData->ResetDigits();
209 fMUONData->GetCathode(0);
210 muonDigits = fMUONData->Digits(ich);
211 ndig = muonDigits->GetEntriesFast();
212 TClonesArray &lDigit = *digAll;
216 for (k = 0; k < ndig; k++) {
218 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
219 new(lDigit[n1++]) AliMUONDigit(*digit);
220 idDE = digit->DetElemId();
221 if (idDE != idDE_prev) {
228 fMUONData->ResetDigits();
229 fMUONData->GetCathode(1);
230 muonDigits = fMUONData->Digits(ich);
231 ndig = muonDigits->GetEntriesFast();
235 for (k = 0; k < ndig; k++) {
237 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
238 new(lDigit[n1++]) AliMUONDigit(*digit);
239 idDE = digit->DetElemId();
242 // looking for new idDE in cathode 1 (method to be checked CF)
243 for (Int_t n = 0; n < idSize; n++) {
256 for (idDE = 0; idDE < idSize; idDE++) {
257 TClonesArray &lhits1 = *dig1;
258 TClonesArray &lhits2 = *dig2;
260 // printf("idDE %d\n", id[idDE]);
262 for (k = 0; k < digAll->GetEntriesFast(); k++) {
263 digit = (AliMUONDigit*) digAll->UncheckedAt(k);
264 // printf("digit idDE %d\n", digit->DetElemId());
265 if (id[idDE] == digit->DetElemId()) {
266 if (digit->Cathode() == 1)
267 new(lhits1[n1++]) AliMUONDigit(*digit);
269 new(lhits2[n2++]) AliMUONDigit(*digit);
275 AliMUONClusterInput::Instance()->SetDigits(ich, id[idDE], dig1, dig2);
276 fRecModel->FindRawClusters();
278 // copy into the container
279 TClonesArray* tmp = fRecModel->GetRawClusters();
280 for (Int_t id = 0; id < tmp->GetEntriesFast(); id++) {
281 AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id);
282 fMUONData->AddRawCluster(ich, *pClus);
295 //____________________________________________________________________
296 void AliMUONClusterReconstructor::Digits2Clusters(AliRawReader* /*rawReader*/)
299 // Perform cluster finding form raw data
301 AliFatal("clusterization not implemented for raw data input");
303 //_______________________________________________________________________
304 void AliMUONClusterReconstructor::Trigger2Trigger()
306 // copy trigger from TreeD to TreeR
308 fMUONData->SetTreeAddress("GLT");
309 fMUONData->GetTriggerD();
311 //_______________________________________________________________________
312 void AliMUONClusterReconstructor::Trigger2Trigger(AliRawReader* /*rawReader*/)
314 // call the Trigger Algorithm from raw data and fill TreeR
316 AliFatal("Trigger not implemented for raw data input");