]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterReconstructor.cxx
4bbc81e57baccfe11727451c0b4b10c715a649f2
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterReconstructor.cxx
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
18 ////////////////////////////////////
19 //
20 // MUON event reconstructor in ALICE
21 //
22 // This class contains as data:
23 // * the parameters for the event reconstruction
24 // * a pointer to the array of hits to be reconstructed (the event)
25 // * a pointer to the array of segments made with these hits inside each station
26 // * a pointer to the array of reconstructed tracks
27 //
28 // It contains as methods, among others:
29 // * MakeEventToBeReconstructed to build the array of hits to be reconstructed
30 // * MakeSegments to build the segments
31 // * MakeTracks to build the tracks
32 //
33 ////////////////////////////////////
34
35 #include "AliMUONClusterReconstructor.h"
36 #include "AliMUON.h"
37 #include "AliMUONDigit.h"
38 #include "AliMUONConstants.h"
39 #include "AliMUONData.h"
40 #include "AliMUONClusterFinderVS.h"
41 #include "AliMUONClusterInput.h"
42 #include "AliMUONRawCluster.h"
43 #include "AliRun.h" // for gAlice
44 #include "AliRunLoader.h"
45 #include "AliLoader.h"
46
47 const Int_t AliMUONClusterReconstructor::fgkDefaultPrintLevel = 0;
48
49 ClassImp(AliMUONClusterReconstructor) // Class implementation in ROOT context
50
51 //__________________________________________________________________________
52 AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliLoader* loader)
53   : TObject()
54 {
55   // Standard Constructor
56  
57   fDebug           = 0;
58   fNCh             = 0;
59   fNTrackingCh     = 0;
60   fChambers        = 0;
61   fMUONData        = 0;
62   fChambers = new TObjArray(AliMUONConstants::NCh());
63
64   fPrintLevel = fgkDefaultPrintLevel;
65
66   // initialize loader's
67   fLoader = loader;
68
69   // initialize container
70   fMUONData  = new AliMUONData(fLoader,"MUON","MUON");
71
72   // Loading AliRun master
73   AliRunLoader* runloader = fLoader->GetRunLoader();
74   if (runloader->GetAliRun() == 0x0) runloader->LoadgAlice();
75   gAlice = runloader->GetAliRun();
76
77   // getting MUON
78   fMUON = (AliMUON*) gAlice->GetDetector("MUON");
79 }
80
81 //__________________________________________________________________________
82 AliMUONClusterReconstructor::AliMUONClusterReconstructor()
83   : TObject(),
84     fNCh(0),
85     fNTrackingCh(0),
86     fMUONData(0),
87     fMUON(0),
88     fChambers(0),
89     fPrintLevel(fgkDefaultPrintLevel),
90     fDebug(0),
91     fLoader(0)
92 {
93   // Default Constructor
94 }
95
96 //____________________________________________________________________
97 void AliMUONClusterReconstructor::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
98 {
99   // take infos chambers from AliMUON
100   AliMUONChamber* pCh = 0;
101   pCh = &(fMUON->Chamber(id));
102
103   fChambers->AddAt(pCh, id);
104
105   // Set ClusterFinder for chamber id
106   ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
107 }
108 //_______________________________________________________________________
109 AliMUONClusterReconstructor::AliMUONClusterReconstructor (const AliMUONClusterReconstructor& rhs)
110   : TObject(rhs)
111 {
112 // Protected copy constructor
113
114   Fatal("AliMUONClusterReconstructor", "Not implemented.");
115 }
116
117 //_______________________________________________________________________
118 AliMUONClusterReconstructor & 
119 AliMUONClusterReconstructor::operator=(const AliMUONClusterReconstructor& rhs)
120 {
121 // Protected assignement operator
122
123   if (this == &rhs) return *this;
124
125   Fatal("operator=", "Not implemented.");
126     
127   return *this;  
128 }
129
130 //__________________________________________________________________________
131 AliMUONClusterReconstructor::~AliMUONClusterReconstructor(void)
132 {
133   if (fChambers){
134     fChambers->Clear(); // Sets pointers to 0 sinche it is not the owner
135     delete fChambers;
136   } 
137   if (fMUONData)
138     delete fMUONData;
139
140   return;
141 }
142 //____________________________________________________________________
143 void AliMUONClusterReconstructor::Digits2Clusters()
144 {
145 //
146 //  Perform cluster finding
147 //
148     TClonesArray *dig1, *dig2;
149     Int_t ndig, k;
150     dig1 = new TClonesArray("AliMUONDigit",1000);
151     dig2 = new TClonesArray("AliMUONDigit",1000);
152     AliMUONDigit *digit;
153 // Loop on chambers and on cathode planes
154 //
155 //    fMUONData->ResetRawClusters();        
156     TClonesArray * muonDigits;
157
158     for (Int_t ich = 0; ich < 10; ich++) {
159         AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
160         AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
161         //AliMUONClusterFinderAZ* rec = (AliMUONClusterFinderAZ*)iChamber->ReconstructionModel();
162
163         fMUONData->ResetDigits();
164         fMUONData->GetCathode(0);
165         //TClonesArray *
166         muonDigits = fMUONData->Digits(ich); 
167         ndig=muonDigits->GetEntriesFast();
168         if(fDebug)
169           printf("1 Found %d digits in %p chamber %d\n", ndig, (void*)muonDigits,ich);
170         TClonesArray &lhits1 = *dig1;
171         Int_t n = 0;
172         for (k = 0; k < ndig; k++) {
173             digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
174             if (rec->TestTrack(digit->Track(0)))
175               new(lhits1[n++]) AliMUONDigit(*digit);
176         }
177         fMUONData->ResetDigits();
178         fMUONData->GetCathode(1);
179         muonDigits =  fMUONData->Digits(ich);  
180         ndig=muonDigits->GetEntriesFast();
181         if(fDebug)
182           printf("\n 2 Found %d digits in %p %d", ndig, (void*)muonDigits, ich);
183         TClonesArray &lhits2 = *dig2;
184         n=0;
185         
186         for (k=0; k<ndig; k++) {
187             digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
188             if (rec->TestTrack(digit->Track(0)))
189               new(lhits2[n++]) AliMUONDigit(*digit);
190         }
191
192         if (rec) {       
193             AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
194             rec->FindRawClusters();
195         }
196         // copy into the container
197         TClonesArray* tmp = rec->GetRawClusters();
198         for (Int_t id = 0; id < tmp->GetEntriesFast(); id++) {
199           AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id);
200           fMUONData->AddRawCluster(ich, *pClus);
201         }
202         dig1->Delete();
203         dig2->Delete();
204     } // for ich
205     delete dig1;
206     delete dig2;
207 }