]>
Commit | Line | Data |
---|---|---|
52c9bc11 | 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 | ||
d19b6003 | 18 | // ----------------------------------- |
19 | // Class AliMUONClusterReconstructor | |
20 | // ---------------------------------- | |
cf464691 | 21 | // MUON cluster reconstructor for MUON |
d19b6003 | 22 | // Should implement a virtual class ClusterFinder to choose between VS and AZ method |
52c9bc11 | 23 | |
52c9bc11 | 24 | #include "AliMUONClusterReconstructor.h" |
cf464691 | 25 | #include "AliRun.h" // for gAlice |
26 | #include "AliRunLoader.h" | |
27 | #include "AliLoader.h" | |
28 | ||
a713db22 | 29 | #include "AliMUON.h" |
52c9bc11 | 30 | #include "AliMUONDigit.h" |
31 | #include "AliMUONConstants.h" | |
32 | #include "AliMUONData.h" | |
33 | #include "AliMUONClusterFinderVS.h" | |
52c9bc11 | 34 | #include "AliMUONClusterInput.h" |
35 | #include "AliMUONRawCluster.h" | |
f9247068 | 36 | #include "AliMUONVClusterFinder.h" |
37 | #include "AliMUONCluster.h" | |
66f4c572 | 38 | #include "AliMpDEManager.h" |
f9247068 | 39 | #include "AliMpSegmentation.h" |
40 | #include "AliMUONGeometryTransformer.h" | |
8c343c7c | 41 | #include "AliLog.h" |
cf464691 | 42 | |
7945aae7 | 43 | /// \cond CLASSIMP |
52c9bc11 | 44 | ClassImp(AliMUONClusterReconstructor) // Class implementation in ROOT context |
7945aae7 | 45 | /// \endcond |
dd20215d | 46 | |
52c9bc11 | 47 | //__________________________________________________________________________ |
f9247068 | 48 | AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliMUONData* data, |
49 | AliMUONVClusterFinder* clusterFinder, | |
50 | const AliMUONGeometryTransformer* transformer) | |
dd20215d | 51 | : TObject(), |
f9247068 | 52 | fClusterFinder(clusterFinder), |
dd20215d | 53 | fMUONData(data), |
54 | fRecModel(new AliMUONClusterFinderVS()), | |
55 | fDigitsCath0(new TClonesArray("AliMUONDigit",1000)), | |
f9247068 | 56 | fDigitsCath1(new TClonesArray("AliMUONDigit",1000)), |
57 | fTransformer(transformer) | |
52c9bc11 | 58 | { |
d19b6003 | 59 | /// Standard Constructor |
52c9bc11 | 60 | |
dd20215d | 61 | fDigitsCath0->SetOwner(kTRUE); |
62 | fDigitsCath1->SetOwner(kTRUE); | |
f9247068 | 63 | if (!transformer && clusterFinder) |
64 | { | |
65 | AliFatal("I require a geometry transformer, otherwise I cannot compute " | |
66 | "global coordinates of the clusters !"); | |
67 | } | |
52c9bc11 | 68 | } |
30178c30 | 69 | |
52c9bc11 | 70 | //__________________________________________________________________________ |
71 | AliMUONClusterReconstructor::~AliMUONClusterReconstructor(void) | |
72 | { | |
d19b6003 | 73 | /// Destructor |
74 | ||
dd20215d | 75 | delete fRecModel; |
76 | delete fDigitsCath0; | |
77 | delete fDigitsCath1; | |
78 | } | |
7e4a628d | 79 | |
f9247068 | 80 | //______________________________________________________________________________ |
81 | void | |
82 | AliMUONClusterReconstructor::ClusterizeOneDEV2(Int_t detElemId) | |
83 | { | |
84 | AliDebug(1,Form("DE %d",detElemId)); | |
85 | const AliMpVSegmentation* seg[2] = | |
86 | { AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,0), | |
87 | AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,1) | |
88 | }; | |
89 | ||
90 | ||
91 | TClonesArray* digits[2] = { fDigitsCath0, fDigitsCath1 }; | |
92 | ||
93 | Bool_t ok = fClusterFinder->Prepare(seg,digits); | |
94 | if ( !ok ) | |
95 | { | |
96 | AliWarning(Form("No hit pad for DE %d ?",detElemId)); | |
97 | } | |
98 | ||
99 | AliMUONCluster* cluster; | |
100 | ||
101 | Int_t chamber = detElemId/100 - 1; | |
102 | ||
103 | while ( ( cluster = fClusterFinder->NextCluster() ) ) | |
104 | { | |
105 | StdoutToAliDebug(1,cout << "From AliMUONClusterReconstructor::ClusterizeOneDEV2 : cluster->Print():" << endl; | |
106 | cluster->Print();); | |
107 | ||
108 | // Converts cluster objects into ones suitable for output | |
109 | // | |
110 | AliMUONRawCluster rawCluster; | |
111 | ||
112 | rawCluster.SetDetElemId(detElemId); | |
113 | ||
114 | for ( Int_t cathode = 0; cathode < 2; ++cathode ) | |
115 | { | |
116 | rawCluster.SetMultiplicity(cathode,cluster->Multiplicity(cathode)); | |
117 | rawCluster.SetCharge(cathode,cluster->Charge()); // both cathode get the total cluster charge | |
118 | Double_t xg, yg, zg; | |
119 | ||
120 | fTransformer->Local2Global(detElemId, | |
121 | cluster->Position().X(), cluster->Position().Y(), | |
122 | 0, xg, yg, zg); | |
123 | ||
124 | if ( cathode == 0 ) | |
125 | { | |
126 | AliDebug(1,Form("Adding RawCluster detElemId %4d mult %2d charge %e (xl,yl,zl)=(%e,%e,%e) (xg,yg,zg)=(%e,%e,%e)", | |
127 | detElemId,cluster->Multiplicity(),cluster->Charge(), | |
128 | cluster->Position().X(),cluster->Position().Y(),0.0, | |
129 | xg,yg,zg)); | |
130 | } | |
131 | rawCluster.SetX(cathode,xg); | |
132 | rawCluster.SetY(cathode,yg); | |
133 | rawCluster.SetZ(cathode,zg); | |
134 | } | |
135 | fMUONData->AddRawCluster(chamber,rawCluster); | |
136 | delete cluster; | |
137 | } | |
138 | } | |
139 | ||
dd20215d | 140 | //______________________________________________________________________________ |
141 | void | |
142 | AliMUONClusterReconstructor::ClusterizeOneDE(Int_t detElemId) | |
143 | { | |
d19b6003 | 144 | /// Clusterize one detection element, and let fMUONData know about |
145 | /// the results. | |
dd20215d | 146 | |
147 | if ( fDigitsCath0->GetEntriesFast() || fDigitsCath1->GetEntriesFast() ) | |
148 | { | |
f9247068 | 149 | if ( fClusterFinder ) |
dd20215d | 150 | { |
f9247068 | 151 | ClusterizeOneDEV2(detElemId); |
152 | } | |
153 | else | |
154 | { | |
155 | Int_t iChamber = AliMpDEManager::GetChamberId(detElemId); | |
156 | AliMUONClusterInput::Instance()->SetDigits(iChamber, detElemId, | |
157 | fDigitsCath0,fDigitsCath1); | |
158 | AliDebug(3,Form("ClusterizeOneDE iChamber=%d DE=%d",iChamber,detElemId)); | |
159 | StdoutToAliDebug(3,cout << "DigitsCath0=" << endl; | |
160 | fDigitsCath0->Print(); | |
161 | cout << "DigitsCath1=" << endl; | |
162 | fDigitsCath1->Print();); | |
163 | fRecModel->FindRawClusters(); | |
164 | ||
165 | // copy results into the output container | |
166 | TClonesArray* tmp = fRecModel->GetRawClusters(); | |
167 | for (Int_t id = 0; id < tmp->GetEntriesFast(); ++id) | |
168 | { | |
169 | AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id); | |
170 | fMUONData->AddRawCluster(iChamber, *pClus); | |
171 | } | |
172 | } | |
dd20215d | 173 | // Reset the arrays |
174 | fDigitsCath0->Clear("C"); | |
175 | fDigitsCath1->Clear("C"); | |
176 | } | |
52c9bc11 | 177 | } |
dd20215d | 178 | |
52c9bc11 | 179 | //____________________________________________________________________ |
cc87ebcd | 180 | void AliMUONClusterReconstructor::Digits2Clusters(Int_t chBeg) |
a713db22 | 181 | { |
d19b6003 | 182 | /// Clusterize all the tracking chamber digits. |
183 | /// | |
184 | /// For each chamber, we loop *once* on that chamber digits, and store them | |
185 | /// in 2 temporary arrays (one pair of arrays per detection element, | |
186 | /// one array per cathode). Once a pair of arrays is full (i.e. all the digits | |
187 | /// of that detection element have been stored), we clusterize this DE, and | |
188 | /// move to the next one. | |
a713db22 | 189 | |
f9247068 | 190 | if (!fRecModel && !fClusterFinder) |
dd20215d | 191 | { |
192 | AliWarning("No reco model defined. Nothing to do..."); | |
193 | return; | |
194 | } | |
195 | ||
196 | Int_t iChamber(-1); | |
197 | Int_t currentDE(-1); | |
198 | ||
199 | // Loop on chambers | |
200 | for ( iChamber = chBeg; iChamber < AliMUONConstants::NTrackingCh(); ++iChamber ) | |
201 | { | |
202 | TClonesArray* muonDigits = fMUONData->Digits(iChamber); | |
203 | ||
204 | Int_t ndig = muonDigits->GetEntriesFast(); | |
205 | if (!ndig) continue; | |
206 | ||
207 | muonDigits->Sort(); // the sort *must* be per DE (at least), otherwise | |
208 | // the following logic with currentDE will fail. | |
209 | ||
210 | currentDE = -1; // initialize the DE counter (that is used to track | |
211 | // when we change of DE in the following loop over | |
212 | // all digits) to an invalid value. | |
213 | ||
214 | for ( Int_t k = 0; k < ndig; ++k ) | |
215 | { | |
216 | AliMUONDigit* digit = (AliMUONDigit*) muonDigits->UncheckedAt(k); | |
217 | if ( ! digit->Signal() > 0 ) continue; // skip void digits. | |
218 | ||
219 | if ( digit->DetElemId() != currentDE ) | |
220 | { | |
221 | AliDebug(3,Form("Switching DE from %d to %d",currentDE,digit->DetElemId())); | |
222 | // we get to a new DE, so clusterize the previous one before | |
223 | // moving on. | |
224 | ClusterizeOneDE(currentDE); | |
225 | currentDE = digit->DetElemId(); | |
a713db22 | 226 | } |
dd20215d | 227 | |
228 | // Add the digit to the array with the right cathode number. | |
229 | if (digit->Cathode() == 0) | |
230 | { | |
dd20215d | 231 | new((*fDigitsCath0)[fDigitsCath0->GetLast()+1]) AliMUONDigit(*digit); |
232 | } | |
233 | else | |
234 | { | |
dd20215d | 235 | new((*fDigitsCath1)[fDigitsCath1->GetLast()+1]) AliMUONDigit(*digit); |
236 | } | |
237 | } // end of loop on chamber digits | |
238 | ||
239 | // As the above logic is based on detecting a change in DE number, | |
240 | // the last DE of each chamber has not been clusterized, so we do | |
241 | // it here. | |
242 | ClusterizeOneDE(currentDE); | |
243 | } // end of loop over chambers | |
52c9bc11 | 244 | } |
cf464691 | 245 | |
dd20215d | 246 | //_______________________________________________________________________ |
247 | void | |
248 | AliMUONClusterReconstructor::SetRecoModel(AliMUONClusterFinderVS* rec) | |
249 | { | |
d19b6003 | 250 | /// Set reconstruction model |
251 | ||
dd20215d | 252 | delete fRecModel; |
253 | fRecModel = rec; | |
254 | } | |
255 | ||
7e4a628d | 256 | //_______________________________________________________________________ |
257 | void AliMUONClusterReconstructor::Trigger2Trigger() | |
258 | { | |
d19b6003 | 259 | /// Copy trigger from TreeD to TreeR |
cc87ebcd | 260 | |
261 | fMUONData->SetTreeAddress("GLT"); | |
7e4a628d | 262 | fMUONData->GetTriggerD(); |
263 | } |