]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterReconstructor.cxx
71e749fa170125ae5f6623b4349d8783ca5e444f
[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 <Riostream.h> // for cout
36 #include <stdlib.h> // for exit()
37
38 #include <TTree.h>
39
40 #include "AliMUON.h"
41 #include "AliMUONClusterReconstructor.h"
42 #include "AliMUONDigit.h"
43 #include "AliMUONConstants.h"
44 #include "AliMUONData.h"
45 #include "AliMUONClusterFinderVS.h"
46 #include "AliMUONClusterFinderAZ.h"
47 #include "AliMUONClusterInput.h"
48 #include "AliMUONRawCluster.h"
49 #include "AliRun.h" // for gAlice
50 #include "AliConfig.h"
51 #include "AliRunLoader.h"
52 #include "AliLoader.h"
53
54 static const Int_t kDefaultPrintLevel = 0;
55
56 ClassImp(AliMUONClusterReconstructor) // Class implementation in ROOT context
57
58 //__________________________________________________________________________
59 AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliLoader* loader)
60 {
61   // Default Constructor
62  
63   fDebug           = 0;
64   fNCh             = 0;
65   fNTrackingCh     = 0;
66   fChambers        = 0;
67   fMUONData        = 0;
68   fChambers = new TObjArray(AliMUONConstants::NCh());
69
70   fPrintLevel = kDefaultPrintLevel;
71
72   // initialize loader's
73   fLoader = loader;
74
75   // initialize container
76   fMUONData  = new AliMUONData(fLoader,"MUON","MUON");
77
78   // Loading AliRun master
79   AliRunLoader* runloader = fLoader->GetRunLoader();
80   if (runloader->GetAliRun() == 0x0) runloader->LoadgAlice();
81   gAlice = runloader->GetAliRun();
82
83   // getting MUON
84   fMUON = (AliMUON*) gAlice->GetDetector("MUON");
85
86   return; 
87 }
88 //____________________________________________________________________
89 void AliMUONClusterReconstructor::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
90 {
91   // take infos chambers from AliMUON
92   AliMUONChamber* pCh = 0;
93   pCh = &(fMUON->Chamber(id));
94
95   fChambers->AddAt(pCh, id);
96
97   // Set ClusterFinder for chamber id
98   ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
99 }
100 //_______________________________________________________________________
101 AliMUONClusterReconstructor::AliMUONClusterReconstructor (const AliMUONClusterReconstructor& Reconstructor):TObject(Reconstructor)
102 {
103   // Dummy copy constructor
104 }
105
106 AliMUONClusterReconstructor & AliMUONClusterReconstructor::operator=(const AliMUONClusterReconstructor& /*Reconstructor*/)
107 {
108   // Dummy assignment operator
109     return *this;
110 }
111
112 //__________________________________________________________________________
113 AliMUONClusterReconstructor::~AliMUONClusterReconstructor(void)
114 {
115   if (fChambers){
116     fChambers->Clear(); // Sets pointers to 0 sinche it is not the owner
117     delete fChambers;
118   } 
119   if (fMUONData)
120     delete fMUONData;
121
122   return;
123 }
124 //____________________________________________________________________
125 void AliMUONClusterReconstructor::Digits2Clusters()
126 {
127 //
128 //  Perform cluster finding
129 //
130     TClonesArray *dig1, *dig2;
131     Int_t ndig, k;
132     dig1 = new TClonesArray("AliMUONDigit",1000);
133     dig2 = new TClonesArray("AliMUONDigit",1000);
134     AliMUONDigit *digit;
135 // Loop on chambers and on cathode planes
136 //
137 //    fMUONData->ResetRawClusters();        
138     TClonesArray * muonDigits;
139
140     for (Int_t ich = 0; ich < 10; ich++) {
141         AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
142         AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
143         //AliMUONClusterFinderAZ* rec = (AliMUONClusterFinderAZ*)iChamber->ReconstructionModel();
144
145         fMUONData->ResetDigits();
146         fMUONData->GetCathode(0);
147         //TClonesArray *
148         muonDigits = fMUONData->Digits(ich); 
149         ndig=muonDigits->GetEntriesFast();
150         if(fDebug)
151           printf("1 Found %d digits in %p chamber %d\n", ndig, (void*)muonDigits,ich);
152         TClonesArray &lhits1 = *dig1;
153         Int_t n = 0;
154         for (k = 0; k < ndig; k++) {
155             digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
156             if (rec->TestTrack(digit->Track(0)))
157               new(lhits1[n++]) AliMUONDigit(*digit);
158         }
159         fMUONData->ResetDigits();
160         fMUONData->GetCathode(1);
161         muonDigits =  fMUONData->Digits(ich);  
162         ndig=muonDigits->GetEntriesFast();
163         if(fDebug)
164           printf("\n 2 Found %d digits in %p %d", ndig, (void*)muonDigits, ich);
165         TClonesArray &lhits2 = *dig2;
166         n=0;
167         
168         for (k=0; k<ndig; k++) {
169             digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
170             if (rec->TestTrack(digit->Track(0)))
171               new(lhits2[n++]) AliMUONDigit(*digit);
172         }
173
174         if (rec) {       
175             AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
176             rec->FindRawClusters();
177         }
178         // copy into the container
179         TClonesArray* tmp = rec->GetRawClusters();
180         for (Int_t id = 0; id < tmp->GetEntriesFast(); id++) {
181           AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id);
182           fMUONData->AddRawCluster(ich, *pClus);
183         }
184         dig1->Delete();
185         dig2->Delete();
186     } // for ich
187     delete dig1;
188     delete dig2;
189 }