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