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