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