]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterInput.cxx
60bbf5c16480e53b88954fad2f9d13d456813bd3
[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 #include "AliLog.h"
29
30 ClassImp(AliMUONClusterInput)
31
32 AliMUONClusterInput* AliMUONClusterInput::fgClusterInput = 0; 
33 TMinuit* AliMUONClusterInput::fgMinuit = 0; 
34
35 AliMUONClusterInput::AliMUONClusterInput()
36   : TObject()
37 {
38   fgClusterInput = 0; 
39   fgMinuit = 0; 
40   fDigits[0]=0;
41   fDigits[1]=0;
42   fSegmentation[0]=0;
43   fSegmentation[1]=0;
44   fResponse=0;
45   fCluster=0;
46 }
47
48 AliMUONClusterInput* AliMUONClusterInput::Instance()
49 {
50 // return pointer to the singleton instance
51     if (fgClusterInput == 0) {
52         fgClusterInput = new AliMUONClusterInput();
53         fgMinuit = new TMinuit(8);
54     }
55     
56     return fgClusterInput;
57 }
58
59 AliMUONClusterInput::~AliMUONClusterInput()
60 {
61 // Destructor
62     delete fgMinuit;
63 }
64
65 AliMUONClusterInput::AliMUONClusterInput(const AliMUONClusterInput& clusterInput):TObject(clusterInput)
66 {
67 // Protected copy constructor
68
69   AliFatal("Not implemented.");
70 }
71
72 void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig1, TClonesArray* dig2)
73 {
74 // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
75     fChamber=chamber;
76     fDigits[0]=dig1;
77     fDigits[1]=dig2; 
78     fNDigits[0]=dig1->GetEntriesFast();
79     fNDigits[1]=dig2->GetEntriesFast();
80     
81     AliMUON *pMUON;
82     AliMUONChamber* iChamber;
83
84     pMUON = (AliMUON*) gAlice->GetModule("MUON");
85     iChamber =  &(pMUON->Chamber(chamber));
86
87     fSegmentation[0]=iChamber->SegmentationModel(1);
88     fSegmentation[1]=iChamber->SegmentationModel(2);
89     fResponse=iChamber->ResponseModel();
90     fNseg = 2;
91 }
92
93 void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig)
94 {
95 // Set pointer to digits with corresponding segmentations and responses (one cathode plane)
96     fDigits[0]=dig;
97     AliMUON *pMUON;
98     AliMUONChamber* iChamber;
99
100     pMUON = (AliMUON*) gAlice->GetModule("MUON");
101     iChamber =  &(pMUON->Chamber(chamber));
102
103     fSegmentation[0]=iChamber->SegmentationModel(1);
104     fResponse=iChamber->ResponseModel();
105     fNseg=1;
106 }
107
108 void  AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
109 {
110 // Set the current cluster
111     //PH printf("\n %p \n", cluster);
112     fCluster=cluster;
113     Float_t qtot;
114     Int_t   i, cath, ix, iy;
115     AliMUONDigit* digit;
116     fNmul[0]=cluster->GetMultiplicity(0);
117     fNmul[1]=cluster->GetMultiplicity(1);
118     //PH printf("\n %p %p ", fDigits[0], fDigits[1]);
119     
120     for (cath=0; cath<2; cath++) {
121         qtot=0;
122         for (i=0; i<fNmul[cath]; i++) {
123             // pointer to digit
124             digit =(AliMUONDigit*)
125                 (fDigits[cath]->UncheckedAt(cluster->GetIndex(i,cath)));
126             // pad coordinates
127             ix = digit->PadX();
128             iy = digit->PadY();
129             // pad charge
130             fCharge[i][cath] = digit->Signal();
131             // pad centre coordinates
132 //          fSegmentation[cath]->GetPadCxy(ix, iy, x, y);
133             // globals kUsed in fitting functions
134             fix[i][cath]=ix;
135             fiy[i][cath]=iy;
136             // total charge per cluster
137             qtot+=fCharge[i][cath];
138             // Current z
139             Float_t xc, yc;
140             fSegmentation[cath]->GetPadC(ix,iy,xc,yc,fZ);
141         } // loop over cluster digits
142         fQtot[cath]=qtot;
143         fChargeTot[cath]=Int_t(qtot);  
144     }  // loop over cathodes
145 }
146
147
148
149 Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par) 
150 {
151 // Compute the charge on first cathod only.
152 return DiscrChargeCombiS1(i,par,0);
153 }
154
155 Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath) 
156 {
157 // par[0]    x-position of cluster
158 // par[1]    y-position of cluster
159
160    fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
161 //  First Cluster
162    fSegmentation[cath]->SetHit(par[0],par[1],fZ);
163    Float_t q1=fResponse->IntXY(fSegmentation[cath]);
164     
165    Float_t value = fQtot[cath]*q1;
166    return value;
167 }
168
169
170 Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par) 
171 {
172 // par[0]    x-position of first  cluster
173 // par[1]    y-position of first  cluster
174 // par[2]    x-position of second cluster
175 // par[3]    y-position of second cluster
176 // par[4]    charge fraction of first  cluster
177 // 1-par[4]  charge fraction of second cluster
178
179    fSegmentation[0]->SetPad(fix[i][0], fiy[i][0]);
180 //  First Cluster
181    fSegmentation[0]->SetHit(par[0],par[1],fZ);
182    Float_t q1=fResponse->IntXY(fSegmentation[0]);
183     
184 //  Second Cluster
185    fSegmentation[0]->SetHit(par[2],par[3],fZ);
186    Float_t q2=fResponse->IntXY(fSegmentation[0]);
187     
188    Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
189    return value;
190 }
191
192 Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath) 
193 {
194 // par[0]    x-position of first  cluster
195 // par[1]    y-position of first  cluster
196 // par[2]    x-position of second cluster
197 // par[3]    y-position of second cluster
198 // par[4]    charge fraction of first  cluster - first cathode
199 // 1-par[4]  charge fraction of second cluster 
200 // par[5]    charge fraction of first  cluster - second cathode
201
202    fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
203 //  First Cluster
204    fSegmentation[cath]->SetHit(par[0],par[1],fZ);
205    Float_t q1=fResponse->IntXY(fSegmentation[cath]);
206     
207 //  Second Cluster
208    fSegmentation[cath]->SetHit(par[2],par[3],fZ);
209    Float_t q2=fResponse->IntXY(fSegmentation[cath]);
210    Float_t value;
211    if (cath==0) {
212        value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
213    } else {
214        value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
215    }
216    return value;
217 }
218
219 AliMUONClusterInput& AliMUONClusterInput
220 ::operator = (const AliMUONClusterInput& rhs)
221 {
222 // Protected assignement operator
223
224   if (this == &rhs) return *this;
225
226   AliFatal("Not implemented.");
227     
228   return *this;  
229 }