]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterInput.cxx
Destructor added.
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterInput.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 /*
17 $Log$
18 Revision 1.10  2001/03/20 13:33:23  egangler
19 Small cleanup
20
21 Revision 1.9  2001/01/26 21:38:49  morsch
22 Use access functions to AliMUONDigit member data.
23
24 Revision 1.8  2001/01/23 18:58:19  hristov
25 Initialisation of some pointers
26
27 Revision 1.7  2000/12/21 22:14:38  morsch
28 Clean-up of coding rule violations.
29
30 Revision 1.6  2000/10/06 09:04:50  morsch
31
32 - Dummy z-arguments in GetPadI, SetHit, FirstPad replaced by real z-coordinate
33         to make code work with slat chambers.
34
35 Revision 1.5  2000/10/02 16:58:29  egangler
36 Cleaning of the code :
37 -> coding conventions
38 -> void Streamers
39 -> some useless includes removed or replaced by "class" statement
40
41 Revision 1.4  2000/07/03 11:54:57  morsch
42 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
43 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
44
45 Revision 1.3  2000/06/28 15:16:35  morsch
46 (1) Client code adapted to new method signatures in AliMUONSegmentation (see comments there)
47 to allow development of slat-muon chamber simulation and reconstruction code in the MUON
48 framework. The changes should have no side effects (mostly dummy arguments).
49 (2) Hit disintegration uses 3-dim hit coordinates to allow simulation
50 of chambers with overlapping modules (MakePadHits, Disintegration).
51
52 Revision 1.2  2000/06/28 12:19:18  morsch
53 More consequent seperation of global input data services (AliMUONClusterInput singleton) and the
54 cluster and hit reconstruction algorithms in AliMUONClusterFinderVS.
55 AliMUONClusterFinderVS becomes the base class for clustering and hit reconstruction.
56 It requires two cathode planes. Small modifications in the code will make it usable for
57 one cathode plane and, hence, more general (for test beam data).
58 AliMUONClusterFinder is now obsolete.
59
60 Revision 1.1  2000/06/28 08:06:10  morsch
61 Avoid global variables in AliMUONClusterFinderVS by seperating the input data for the fit from the
62 algorithmic part of the class. Input data resides inside the AliMUONClusterInput singleton.
63 It also naturally takes care of the TMinuit instance.
64
65 */
66 #include "AliRun.h"
67 #include "AliMUON.h"
68 #include "AliMUONChamber.h"
69 #include "AliMUONClusterInput.h"
70 #include "AliSegmentation.h"
71 #include "AliMUONResponse.h"
72 #include "AliMUONRawCluster.h"
73 #include "AliMUONDigit.h"
74
75 #include <TClonesArray.h>
76 #include <TMinuit.h>
77
78 ClassImp(AliMUONClusterInput)
79
80 AliMUONClusterInput* AliMUONClusterInput::fgClusterInput = 0; 
81 TMinuit* AliMUONClusterInput::fgMinuit = 0; 
82
83 AliMUONClusterInput::AliMUONClusterInput(){
84   fgClusterInput = 0; 
85   fgMinuit = 0; 
86   fDigits[0]=0;
87   fDigits[1]=0;
88   fSegmentation[0]=0;
89   fSegmentation[1]=0;
90   fResponse=0;
91   fCluster=0;
92 }
93
94 AliMUONClusterInput* AliMUONClusterInput::Instance()
95 {
96 // return pointer to the singleton instance
97     if (fgClusterInput == 0) {
98         fgClusterInput = new AliMUONClusterInput();
99         fgMinuit = new TMinuit(8);
100     }
101     
102     return fgClusterInput;
103 }
104
105 AliMUONClusterInput::~AliMUONClusterInput()
106 {
107 // Destructor
108     delete fgMinuit;
109 }
110
111
112 void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig1, TClonesArray* dig2)
113 {
114 // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
115     fChamber=chamber;
116     fDigits[0]=dig1;
117     fDigits[1]=dig2; 
118     fNDigits[0]=dig1->GetEntriesFast();
119     fNDigits[1]=dig2->GetEntriesFast();
120     
121     AliMUON *pMUON;
122     AliMUONChamber* iChamber;
123
124     pMUON = (AliMUON*) gAlice->GetModule("MUON");
125     iChamber =  &(pMUON->Chamber(chamber));
126
127     fSegmentation[0]=iChamber->SegmentationModel(1);
128     fSegmentation[1]=iChamber->SegmentationModel(2);
129     fResponse=iChamber->ResponseModel();
130     fNseg = 2;
131 }
132
133 void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig)
134 {
135 // Set pointer to digits with corresponding segmentations and responses (one cathode plane)
136     fDigits[0]=dig;
137     AliMUON *pMUON;
138     AliMUONChamber* iChamber;
139
140     pMUON = (AliMUON*) gAlice->GetModule("MUON");
141     iChamber =  &(pMUON->Chamber(chamber));
142
143     fSegmentation[0]=iChamber->SegmentationModel(1);
144     fResponse=iChamber->ResponseModel();
145     fNseg=1;
146 }
147
148 void  AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
149 {
150 // Set the current cluster
151     printf("\n %p \n", cluster);
152     fCluster=cluster;
153     Float_t qtot;
154     Int_t   i, cath, ix, iy;
155     AliMUONDigit* digit;
156     fNmul[0]=cluster->fMultiplicity[0];
157     fNmul[1]=cluster->fMultiplicity[1];
158     printf("\n %p %p ", fDigits[0], fDigits[1]);
159     
160     for (cath=0; cath<2; cath++) {
161         qtot=0;
162         for (i=0; i<fNmul[cath]; i++) {
163             // pointer to digit
164             digit =(AliMUONDigit*)
165                 (fDigits[cath]->UncheckedAt(cluster->fIndexMap[i][cath]));
166             // pad coordinates
167             ix = digit->PadX();
168             iy = digit->PadY();
169             // pad charge
170             fCharge[i][cath] = digit->Signal();
171             // pad centre coordinates
172 //          fSegmentation[cath]->GetPadCxy(ix, iy, x, y);
173             // globals kUsed in fitting functions
174             fix[i][cath]=ix;
175             fiy[i][cath]=iy;
176             // total charge per cluster
177             qtot+=fCharge[i][cath];
178             // Current z
179             Float_t xc, yc;
180             fSegmentation[cath]->GetPadC(ix,iy,xc,yc,fZ);
181         } // loop over cluster digits
182         fQtot[cath]=qtot;
183         fChargeTot[cath]=Int_t(qtot);  
184     }  // loop over cathodes
185 }
186
187
188
189 Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par) 
190 {
191 // Compute the charge on first cathod only.
192 return DiscrChargeCombiS1(i,par,0);
193 }
194
195 Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath) 
196 {
197 // par[0]    x-position of cluster
198 // par[1]    y-position of cluster
199
200    fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
201 //  First Cluster
202    fSegmentation[cath]->SetHit(par[0],par[1],fZ);
203    Float_t q1=fResponse->IntXY(fSegmentation[cath]);
204     
205    Float_t value = fQtot[cath]*q1;
206    return value;
207 }
208
209
210 Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par) 
211 {
212 // par[0]    x-position of first  cluster
213 // par[1]    y-position of first  cluster
214 // par[2]    x-position of second cluster
215 // par[3]    y-position of second cluster
216 // par[4]    charge fraction of first  cluster
217 // 1-par[4]  charge fraction of second cluster
218
219    fSegmentation[0]->SetPad(fix[i][0], fiy[i][0]);
220 //  First Cluster
221    fSegmentation[0]->SetHit(par[0],par[1],fZ);
222    Float_t q1=fResponse->IntXY(fSegmentation[0]);
223     
224 //  Second Cluster
225    fSegmentation[0]->SetHit(par[2],par[3],fZ);
226    Float_t q2=fResponse->IntXY(fSegmentation[0]);
227     
228    Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
229    return value;
230 }
231
232 Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath) 
233 {
234 // par[0]    x-position of first  cluster
235 // par[1]    y-position of first  cluster
236 // par[2]    x-position of second cluster
237 // par[3]    y-position of second cluster
238 // par[4]    charge fraction of first  cluster - first cathode
239 // 1-par[4]  charge fraction of second cluster 
240 // par[5]    charge fraction of first  cluster - second cathode
241
242    fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
243 //  First Cluster
244    fSegmentation[cath]->SetHit(par[0],par[1],fZ);
245    Float_t q1=fResponse->IntXY(fSegmentation[cath]);
246     
247 //  Second Cluster
248    fSegmentation[cath]->SetHit(par[2],par[3],fZ);
249    Float_t q2=fResponse->IntXY(fSegmentation[cath]);
250    Float_t value;
251    if (cath==0) {
252        value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
253    } else {
254        value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
255    }
256    return value;
257 }
258
259 AliMUONClusterInput& AliMUONClusterInput
260 ::operator = (const AliMUONClusterInput& rhs)
261 {
262 // Dummy assignment operator
263     return *this;
264 }