Coding conventions (Laurent)
[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
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"
8c343c7c 36#include "AliLog.h"
cf464691 37
52c9bc11 38ClassImp(AliMUONClusterReconstructor) // Class implementation in ROOT context
dd20215d 39
52c9bc11 40//__________________________________________________________________________
dd20215d 41AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliMUONData* data)
42: TObject(),
43 fMUONData(data),
44 fRecModel(new AliMUONClusterFinderVS()),
45 fDigitsCath0(new TClonesArray("AliMUONDigit",1000)),
46 fDigitsCath1(new TClonesArray("AliMUONDigit",1000))
52c9bc11 47{
d19b6003 48/// Standard Constructor
52c9bc11 49
dd20215d 50 fDigitsCath0->SetOwner(kTRUE);
51 fDigitsCath1->SetOwner(kTRUE);
52c9bc11 52}
30178c30 53
52c9bc11 54//_______________________________________________________________________
30178c30 55AliMUONClusterReconstructor::AliMUONClusterReconstructor (const AliMUONClusterReconstructor& rhs)
56 : TObject(rhs)
52c9bc11 57{
d19b6003 58/// Protected copy constructor
30178c30 59
8c343c7c 60 AliFatal("Not implemented.");
52c9bc11 61}
62
30178c30 63//_______________________________________________________________________
64AliMUONClusterReconstructor &
65AliMUONClusterReconstructor::operator=(const AliMUONClusterReconstructor& rhs)
52c9bc11 66{
d19b6003 67/// Protected assignement operator
30178c30 68
69 if (this == &rhs) return *this;
70
8c343c7c 71 AliFatal("Not implemented.");
30178c30 72
73 return *this;
52c9bc11 74}
75
76//__________________________________________________________________________
77AliMUONClusterReconstructor::~AliMUONClusterReconstructor(void)
78{
d19b6003 79/// Destructor
80
dd20215d 81 delete fRecModel;
82 delete fDigitsCath0;
83 delete fDigitsCath1;
84}
7e4a628d 85
dd20215d 86//______________________________________________________________________________
87void
dd20215d 88AliMUONClusterReconstructor::ClusterizeOneDE(Int_t detElemId)
89{
d19b6003 90/// Clusterize one detection element, and let fMUONData know about
91/// the results.
dd20215d 92
93 if ( fDigitsCath0->GetEntriesFast() || fDigitsCath1->GetEntriesFast() )
94 {
95 Int_t iChamber = detElemId/100 - 1;
96 AliMUONClusterInput::Instance()->SetDigits(iChamber, detElemId,
97 fDigitsCath0,fDigitsCath1);
98 AliDebug(3,Form("ClusterizeOneDE iChamber=%d DE=%d",iChamber,detElemId));
99 StdoutToAliDebug(3,cout << "DigitsCath0=" << endl;
100 fDigitsCath0->Print();
101 cout << "DigitsCath1=" << endl;
102 fDigitsCath1->Print(););
103 fRecModel->FindRawClusters();
104
105 // copy results into the output container
106 TClonesArray* tmp = fRecModel->GetRawClusters();
107 for (Int_t id = 0; id < tmp->GetEntriesFast(); ++id)
108 {
109 AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id);
110 fMUONData->AddRawCluster(iChamber, *pClus);
111 }
112
113 // Reset the arrays
114 fDigitsCath0->Clear("C");
115 fDigitsCath1->Clear("C");
116 }
52c9bc11 117}
dd20215d 118
52c9bc11 119//____________________________________________________________________
cc87ebcd 120void AliMUONClusterReconstructor::Digits2Clusters(Int_t chBeg)
52c9bc11 121{
d19b6003 122/// Clusterize all the tracking chamber digits.
123///
124/// For each chamber, we loop *once* on that chamber digits, and store them
125/// in 2 temporary arrays (one pair of arrays per detection element,
126/// one array per cathode). Once a pair of arrays is full (i.e. all the digits
127/// of that detection element have been stored), we clusterize this DE, and
128/// move to the next one.
a713db22 129
dd20215d 130 if (!fRecModel)
131 {
132 AliWarning("No reco model defined. Nothing to do...");
133 return;
134 }
135
136 Int_t iChamber(-1);
137 Int_t currentDE(-1);
138
139 // Loop on chambers
140 for ( iChamber = chBeg; iChamber < AliMUONConstants::NTrackingCh(); ++iChamber )
141 {
142 TClonesArray* muonDigits = fMUONData->Digits(iChamber);
143
144 Int_t ndig = muonDigits->GetEntriesFast();
145 if (!ndig) continue;
146
147 muonDigits->Sort(); // the sort *must* be per DE (at least), otherwise
148 // the following logic with currentDE will fail.
149
150 currentDE = -1; // initialize the DE counter (that is used to track
151 // when we change of DE in the following loop over
152 // all digits) to an invalid value.
153
154 for ( Int_t k = 0; k < ndig; ++k )
155 {
156 AliMUONDigit* digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
157 if ( ! digit->Signal() > 0 ) continue; // skip void digits.
158
159 if ( digit->DetElemId() != currentDE )
160 {
161 AliDebug(3,Form("Switching DE from %d to %d",currentDE,digit->DetElemId()));
162 // we get to a new DE, so clusterize the previous one before
163 // moving on.
164 ClusterizeOneDE(currentDE);
165 currentDE = digit->DetElemId();
a713db22 166 }
dd20215d 167
168 // Add the digit to the array with the right cathode number.
169 if (digit->Cathode() == 0)
170 {
dd20215d 171 new((*fDigitsCath0)[fDigitsCath0->GetLast()+1]) AliMUONDigit(*digit);
172 }
173 else
174 {
dd20215d 175 new((*fDigitsCath1)[fDigitsCath1->GetLast()+1]) AliMUONDigit(*digit);
176 }
177 } // end of loop on chamber digits
178
179 // As the above logic is based on detecting a change in DE number,
180 // the last DE of each chamber has not been clusterized, so we do
181 // it here.
182 ClusterizeOneDE(currentDE);
183 } // end of loop over chambers
52c9bc11 184}
cf464691 185
7e4a628d 186//_______________________________________________________________________
dd20215d 187void
188AliMUONClusterReconstructor::SetRecoModel(AliMUONClusterFinderVS* rec)
189{
d19b6003 190/// Set reconstruction model
191
dd20215d 192 delete fRecModel;
193 fRecModel = rec;
194}
195
196//_______________________________________________________________________
7e4a628d 197void AliMUONClusterReconstructor::Trigger2Trigger()
198{
d19b6003 199/// Copy trigger from TreeD to TreeR
cc87ebcd 200
201 fMUONData->SetTreeAddress("GLT");
7e4a628d 202 fMUONData->GetTriggerD();
203}