1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ////////////////////////////////////
20 // MUON cluster reconstructor for MUON
22 // Should implement a virtual class ClusterFinder to chose between VS and AZ method
23 ////////////////////////////////////
25 #include "AliMUONClusterReconstructor.h"
26 #include "AliRun.h" // for gAlice
27 #include "AliRunLoader.h"
28 #include "AliLoader.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"
39 ClassImp(AliMUONClusterReconstructor) // Class implementation in ROOT context
41 //__________________________________________________________________________
42 AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliMUONData* data)
45 fRecModel(new AliMUONClusterFinderVS()),
46 fDigitsCath0(new TClonesArray("AliMUONDigit",1000)),
47 fDigitsCath1(new TClonesArray("AliMUONDigit",1000))
49 // Standard Constructor
51 fDigitsCath0->SetOwner(kTRUE);
52 fDigitsCath1->SetOwner(kTRUE);
55 //_______________________________________________________________________
56 AliMUONClusterReconstructor::AliMUONClusterReconstructor (const AliMUONClusterReconstructor& rhs)
59 // Protected copy constructor
61 AliFatal("Not implemented.");
64 //_______________________________________________________________________
65 AliMUONClusterReconstructor &
66 AliMUONClusterReconstructor::operator=(const AliMUONClusterReconstructor& rhs)
68 // Protected assignement operator
70 if (this == &rhs) return *this;
72 AliFatal("Not implemented.");
77 //__________________________________________________________________________
78 AliMUONClusterReconstructor::~AliMUONClusterReconstructor(void)
85 //______________________________________________________________________________
87 AliMUONClusterReconstructor::CheckSize(TClonesArray& a)
90 // Check if one can adds a new element, or if a is already full.
91 // If full, it is resized.
93 if ( a.GetLast()+1 >= a.GetSize() )
95 AliInfo(Form("Increasing array size from %d to %d",
96 a.GetSize(),a.GetSize()*2));
97 a.Expand(a.GetSize()*2);
101 //______________________________________________________________________________
103 AliMUONClusterReconstructor::ClusterizeOneDE(Int_t detElemId)
106 // Clusterize one detection element, and let fMUONData know about
110 if ( fDigitsCath0->GetEntriesFast() || fDigitsCath1->GetEntriesFast() )
112 Int_t iChamber = detElemId/100 - 1;
113 AliMUONClusterInput::Instance()->SetDigits(iChamber, detElemId,
114 fDigitsCath0,fDigitsCath1);
115 AliDebug(3,Form("ClusterizeOneDE iChamber=%d DE=%d",iChamber,detElemId));
116 StdoutToAliDebug(3,cout << "DigitsCath0=" << endl;
117 fDigitsCath0->Print();
118 cout << "DigitsCath1=" << endl;
119 fDigitsCath1->Print(););
120 fRecModel->FindRawClusters();
122 // copy results into the output container
123 TClonesArray* tmp = fRecModel->GetRawClusters();
124 for (Int_t id = 0; id < tmp->GetEntriesFast(); ++id)
126 AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id);
127 fMUONData->AddRawCluster(iChamber, *pClus);
131 fDigitsCath0->Clear("C");
132 fDigitsCath1->Clear("C");
136 //____________________________________________________________________
137 void AliMUONClusterReconstructor::Digits2Clusters(Int_t chBeg)
140 // Clusterize all the tracking chamber digits.
142 // For each chamber, we loop *once* on that chamber digits, and store them
143 // in 2 temporary arrays (one pair of arrays per detection element,
144 // one array per cathode). Once a pair of arrays is full (i.e. all the digits
145 // of that detection element have been stored), we clusterize this DE, and
146 // move to the next one.
151 AliWarning("No reco model defined. Nothing to do...");
159 for ( iChamber = chBeg; iChamber < AliMUONConstants::NTrackingCh(); ++iChamber )
161 TClonesArray* muonDigits = fMUONData->Digits(iChamber);
163 Int_t ndig = muonDigits->GetEntriesFast();
166 muonDigits->Sort(); // the sort *must* be per DE (at least), otherwise
167 // the following logic with currentDE will fail.
169 currentDE = -1; // initialize the DE counter (that is used to track
170 // when we change of DE in the following loop over
171 // all digits) to an invalid value.
173 for ( Int_t k = 0; k < ndig; ++k )
175 AliMUONDigit* digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
176 if ( ! digit->Signal() > 0 ) continue; // skip void digits.
178 if ( digit->DetElemId() != currentDE )
180 AliDebug(3,Form("Switching DE from %d to %d",currentDE,digit->DetElemId()));
181 // we get to a new DE, so clusterize the previous one before
183 ClusterizeOneDE(currentDE);
184 currentDE = digit->DetElemId();
187 // Add the digit to the array with the right cathode number.
188 if (digit->Cathode() == 0)
190 CheckSize(*fDigitsCath0);
191 new((*fDigitsCath0)[fDigitsCath0->GetLast()+1]) AliMUONDigit(*digit);
195 CheckSize(*fDigitsCath1);
196 new((*fDigitsCath1)[fDigitsCath1->GetLast()+1]) AliMUONDigit(*digit);
198 } // end of loop on chamber digits
200 // As the above logic is based on detecting a change in DE number,
201 // the last DE of each chamber has not been clusterized, so we do
203 ClusterizeOneDE(currentDE);
204 } // end of loop over chambers
207 //_______________________________________________________________________
209 AliMUONClusterReconstructor::SetRecoModel(AliMUONClusterFinderVS* rec)
215 //_______________________________________________________________________
216 void AliMUONClusterReconstructor::Trigger2Trigger()
218 // copy trigger from TreeD to TreeR
220 fMUONData->SetTreeAddress("GLT");
221 fMUONData->GetTriggerD();