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