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