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