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