]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterInput.cxx
0b0b54ff322cd0cd7de5e89931419527d0106a0a
[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 /* $Id$ */
17
18 #include <TClonesArray.h>
19 #include <TMinuit.h>
20
21 #include "AliRun.h"
22 #include "AliMUON.h"
23 #include "AliMUONChamber.h"
24 #include "AliMUONClusterInput.h"
25 #include "AliMUONResponse.h"
26 #include "AliMUONRawCluster.h"
27 #include "AliMUONDigit.h"
28
29 ClassImp(AliMUONClusterInput)
30
31 AliMUONClusterInput* AliMUONClusterInput::fgClusterInput = 0; 
32 TMinuit* AliMUONClusterInput::fgMinuit = 0; 
33
34 AliMUONClusterInput::AliMUONClusterInput()
35   : TObject()
36 {
37   fgClusterInput = 0; 
38   fgMinuit = 0; 
39   fDigits[0]=0;
40   fDigits[1]=0;
41   fSegmentation[0]=0;
42   fSegmentation[1]=0;
43   fResponse=0;
44   fCluster=0;
45 }
46
47 AliMUONClusterInput* AliMUONClusterInput::Instance()
48 {
49 // return pointer to the singleton instance
50     if (fgClusterInput == 0) {
51         fgClusterInput = new AliMUONClusterInput();
52         fgMinuit = new TMinuit(8);
53     }
54     
55     return fgClusterInput;
56 }
57
58 AliMUONClusterInput::~AliMUONClusterInput()
59 {
60 // Destructor
61     delete fgMinuit;
62 }
63
64 AliMUONClusterInput::AliMUONClusterInput(const AliMUONClusterInput& clusterInput):TObject(clusterInput)
65 {
66 // Protected copy constructor
67
68   Fatal("AliMUONClusterInput", "Not implemented.");
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     //PH 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->GetMultiplicity(0);
116     fNmul[1]=cluster->GetMultiplicity(1);
117     //PH 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->GetIndex(i,cath)));
125             // pad coordinates
126             ix = digit->PadX();
127             iy = digit->PadY();
128             // pad charge
129             fCharge[i][cath] = digit->Signal();
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             // Current z
138             Float_t xc, yc;
139             fSegmentation[cath]->GetPadC(ix,iy,xc,yc,fZ);
140         } // loop over cluster digits
141         fQtot[cath]=qtot;
142         fChargeTot[cath]=Int_t(qtot);  
143     }  // loop over cathodes
144 }
145
146
147
148 Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par) 
149 {
150 // Compute the charge on first cathod only.
151 return DiscrChargeCombiS1(i,par,0);
152 }
153
154 Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath) 
155 {
156 // par[0]    x-position of cluster
157 // par[1]    y-position of cluster
158
159    fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
160 //  First Cluster
161    fSegmentation[cath]->SetHit(par[0],par[1],fZ);
162    Float_t q1=fResponse->IntXY(fSegmentation[cath]);
163     
164    Float_t value = fQtot[cath]*q1;
165    return value;
166 }
167
168
169 Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par) 
170 {
171 // par[0]    x-position of first  cluster
172 // par[1]    y-position of first  cluster
173 // par[2]    x-position of second cluster
174 // par[3]    y-position of second cluster
175 // par[4]    charge fraction of first  cluster
176 // 1-par[4]  charge fraction of second 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 //  Second Cluster
184    fSegmentation[0]->SetHit(par[2],par[3],fZ);
185    Float_t q2=fResponse->IntXY(fSegmentation[0]);
186     
187    Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
188    return value;
189 }
190
191 Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath) 
192 {
193 // par[0]    x-position of first  cluster
194 // par[1]    y-position of first  cluster
195 // par[2]    x-position of second cluster
196 // par[3]    y-position of second cluster
197 // par[4]    charge fraction of first  cluster - first cathode
198 // 1-par[4]  charge fraction of second cluster 
199 // par[5]    charge fraction of first  cluster - second cathode
200
201    fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
202 //  First Cluster
203    fSegmentation[cath]->SetHit(par[0],par[1],fZ);
204    Float_t q1=fResponse->IntXY(fSegmentation[cath]);
205     
206 //  Second Cluster
207    fSegmentation[cath]->SetHit(par[2],par[3],fZ);
208    Float_t q2=fResponse->IntXY(fSegmentation[cath]);
209    Float_t value;
210    if (cath==0) {
211        value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
212    } else {
213        value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
214    }
215    return value;
216 }
217
218 AliMUONClusterInput& AliMUONClusterInput
219 ::operator = (const AliMUONClusterInput& rhs)
220 {
221 // Protected assignement operator
222
223   if (this == &rhs) return *this;
224
225   Fatal("operator=", "Not implemented.");
226     
227   return *this;  
228 }