]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterReconstructor.cxx
Corrected index (aplhacxx6)
[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     TClonesArray *dig1, *dig2, *digAll;
113     Int_t ndig, k, idDE, idDE_prev;
114     dig1 = new TClonesArray("AliMUONDigit",1000);
115     dig2 = new TClonesArray("AliMUONDigit",1000);
116     digAll = new TClonesArray("AliMUONDigit",2000);
117
118     AliMUONDigit* digit;
119
120     TArrayI id(200); // contains the different IdDE
121    
122   
123 // Loop on chambers and on cathode planes     
124     TClonesArray* muonDigits;
125     Int_t n2;
126     Int_t n1;
127   
128     for (Int_t ich = 0; ich < AliMUONConstants::NTrackingCh(); ich++) {
129  
130       id.Reset();
131       n1 = 0;
132       n2 = 0;
133       //cathode 0 & 1
134       fMUONData->ResetDigits();
135       fMUONData->GetDigits();
136       muonDigits = fMUONData->Digits(ich); 
137       ndig = muonDigits->GetEntriesFast();
138       TClonesArray &lDigit = *digAll;
139
140       idDE_prev = 0;
141       muonDigits->Sort();
142       for (k = 0; k < ndig; k++) {
143
144         digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
145         new(lDigit[n1++]) AliMUONDigit(*digit);
146         idDE = digit->DetElemId();
147         if (idDE != idDE_prev) {
148           id.AddAt(idDE,n2++);
149         }
150         idDE_prev = idDE;
151       }
152
153
154       Int_t idSize = n2;
155
156       // loop over id DE
157       for (idDE = 0; idDE < idSize; idDE++) {
158         TClonesArray &lhits1 = *dig1;
159         TClonesArray &lhits2 = *dig2;
160         dig1->Clear();
161         dig2->Clear();
162         n1 = n2 = 0;
163
164         for (k = 0; k < digAll->GetEntriesFast(); k++) {
165           digit = (AliMUONDigit*) digAll->UncheckedAt(k);
166           //      printf("digit idDE %d\n", digit->DetElemId());
167           if (id[idDE] == digit->DetElemId()) {
168             if (digit->Cathode() == 0)
169               new(lhits1[n1++]) AliMUONDigit(*digit);
170             else 
171               new(lhits2[n2++]) AliMUONDigit(*digit);
172           }
173         }
174
175         //      if (id[idDE] < 500 && id[idDE] > 299) continue; // temporary patch til St2 geometry is not yet ok (CF)
176
177         // cluster finder
178         if (fRecModel) {
179           AliMUONClusterInput::Instance()->SetDigits(ich, id[idDE], dig1, dig2);
180           fRecModel->FindRawClusters();
181         }
182         // copy into the container
183         TClonesArray* tmp = fRecModel->GetRawClusters();
184         for (Int_t id = 0; id < tmp->GetEntriesFast(); id++) {
185           AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id);
186           fMUONData->AddRawCluster(ich, *pClus);
187         }
188         dig1->Delete();
189         dig2->Delete();
190       } // idDE
191       digAll->Delete();
192     } // for ich
193     delete dig1;
194     delete dig2;
195     delete digAll;
196 }
197
198 //____________________________________________________________________
199 void AliMUONClusterReconstructor::Digits2Clusters(AliRawReader* /*rawReader*/)
200 {
201
202 //  Perform cluster finding form raw data
203
204    AliFatal("clusterization not implemented for raw data input");
205 }
206 //_______________________________________________________________________
207 void AliMUONClusterReconstructor::Trigger2Trigger() 
208 {
209 // copy trigger from TreeD to TreeR
210
211   fMUONData->SetTreeAddress("GLT");
212   fMUONData->GetTriggerD();
213 }
214 //_______________________________________________________________________
215 void AliMUONClusterReconstructor::Trigger2Trigger(AliRawReader* /*rawReader*/) 
216 {
217 // call the Trigger Algorithm from raw data and fill TreeR 
218
219    AliFatal("Trigger not implemented for raw data input");
220
221 }