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