]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterInput.cxx
renamed CorrectionMatrix class
[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 // ----------------------------
19 // Class AliMUONClusterInput
20 // ----------------------------
21 // Global data service for hit reconstruction
22 // Author: to be added
23
24 #include "AliMUONClusterInput.h"
25
26 #include "AliMUONGeometryTransformer.h"
27 #include "AliMUONGeometrySegmentation.h"
28 #include "AliMUONSegFactory.h"
29 #include "AliMUONSegmentation.h"
30 #include "AliMUONConstants.h"
31 #include "AliMUONMathieson.h"
32 #include "AliMUONRawCluster.h"
33 #include "AliMUONDigit.h"
34
35 #include "AliLog.h"
36
37 #include <TClonesArray.h>
38 #include <TMinuit.h>
39 #include <TGeoManager.h>
40
41 AliMUONClusterInput*        AliMUONClusterInput::fgClusterInput = 0; 
42 TMinuit*                    AliMUONClusterInput::fgMinuit = 0; 
43 AliMUONMathieson*           AliMUONClusterInput::fgMathieson = 0; 
44 AliMUONGeometryTransformer* AliMUONClusterInput::fgTransformer = 0; 
45 AliMUONSegmentation*        AliMUONClusterInput::fgSegmentation = 0; 
46
47 ClassImp(AliMUONClusterInput)
48
49 AliMUONClusterInput::AliMUONClusterInput()
50   : TObject(),
51     fCluster(0),
52     fChargeCorrel(1.),
53     fDetElemId(0)
54   
55 {
56 // Default constructor
57
58   fDigits[0]=0;
59   fDigits[1]=0;
60   fSegmentation2[0]=0;
61   fSegmentation2[1]=0;
62 }
63
64 AliMUONClusterInput* AliMUONClusterInput::Instance()
65 {
66 // return pointer to the singleton instance
67     if (fgClusterInput == 0) {
68         fgClusterInput = new AliMUONClusterInput();
69         fgMinuit = new TMinuit(8);
70         
71         // Create segmentation with activated Root geometry  
72         if ( ! gGeoManager ) {
73           AliFatalClass("Geometry not loaded.");
74           return fgClusterInput;
75         }  
76         fgTransformer = new AliMUONGeometryTransformer(true);
77         fgTransformer->ReadGeometryData("volpath.dat", gGeoManager);
78         AliMUONSegFactory factory(fgTransformer);
79         fgSegmentation = factory.CreateSegmentation(); 
80     }
81     
82     return fgClusterInput;
83 }
84
85 AliMUONClusterInput::~AliMUONClusterInput()
86 {
87 // Destructor
88     delete fgMinuit;
89     delete fgMathieson;
90     delete fgTransformer;
91     delete fgSegmentation;
92     fgMinuit = 0;
93     fgMathieson = 0;
94 }
95
96 AliMUONClusterInput::AliMUONClusterInput(const AliMUONClusterInput& clusterInput):TObject(clusterInput)
97 {
98 // Protected copy constructor
99
100   AliFatal("Not implemented.");
101 }
102
103 void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig1, TClonesArray* dig2)
104 {
105   // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
106     fChamber = chamber;
107     fDetElemId = idDE;
108     fDigits[0]  = dig1;
109     fDigits[1]  = dig2; 
110     fNDigits[0] = dig1->GetEntriesFast();
111     fNDigits[1] = dig2->GetEntriesFast();
112     
113     delete fgMathieson;
114     fgMathieson = new AliMUONMathieson();
115
116     fSegmentation2[0]= fgSegmentation->GetModuleSegmentation(chamber, 0);
117     fSegmentation2[1]= fgSegmentation->GetModuleSegmentation(chamber, 1);
118
119     fNseg = 2;
120     if (chamber < AliMUONConstants::NTrackingCh()) {
121       if (chamber > 1 ) {
122         fgMathieson->SetPitch(AliMUONConstants::Pitch());
123         fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3());
124         fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3());
125         fChargeCorrel = AliMUONConstants::ChargeCorrel();
126       } else {
127         fgMathieson->SetPitch(AliMUONConstants::PitchSt1());
128         fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3St1());
129         fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3St1());
130         fChargeCorrel = AliMUONConstants::ChargeCorrelSt1();
131       }
132     }
133 }
134
135 void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig)
136 {
137 // Set pointer to digits with corresponding segmentations and responses (one cathode plane)
138
139     fChamber = chamber;
140     fDetElemId = idDE;
141     fDigits[0] = dig;
142
143     fSegmentation2[0]= fgSegmentation->GetModuleSegmentation(chamber, 0);
144     fNseg=1;
145 }
146
147 void  AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
148 {
149 // Set the current cluster
150   //PH printf("\n %p \n", cluster);
151   fCluster=cluster;
152   Float_t qtot;
153   Int_t   i, cath, ix, iy;
154   AliMUONDigit* digit;
155   fNmul[0]=cluster->GetMultiplicity(0);
156   fNmul[1]=cluster->GetMultiplicity(1);
157   //PH printf("\n %p %p ", fDigits[0], fDigits[1]);
158   
159   for (cath=0; cath<2; cath++) {
160     qtot=0;
161     for (i=0; i<fNmul[cath]; i++) {
162       // pointer to digit
163       digit =(AliMUONDigit*)
164                 (fDigits[cath]->UncheckedAt(cluster->GetIndex(i,cath)));
165             // pad coordinates
166             ix = digit->PadX();
167             iy = digit->PadY();
168             // pad charge
169             fCharge[i][cath] = digit->Signal();
170             // pad centre coordinates
171 //          fSegmentation[cath]->GetPadCxy(ix, iy, x, y);
172             // globals kUsed in fitting functions
173             fix[i][cath]=ix;
174             fiy[i][cath]=iy;
175             // total charge per cluster
176             qtot+=fCharge[i][cath];
177             // Current z
178             Float_t xc, yc;
179             fSegmentation2[cath]->GetPadC(fDetElemId,ix,iy,xc,yc,fZ);
180         } // loop over cluster digits
181         fQtot[cath]=qtot;
182         fChargeTot[cath]=Int_t(qtot);  
183     }  // loop over cathodes
184 }
185
186
187
188 Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par) 
189 {
190 // Compute the charge on first cathod only.
191 return DiscrChargeCombiS1(i,par,0);
192 }
193
194 Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath) 
195 {
196 // par[0]    x-position of cluster
197 // par[1]    y-position of cluster
198
199     Float_t q1;
200     fSegmentation2[cath]->SetPad(fDetElemId, fix[i][cath], fiy[i][cath]);
201     //  First Cluster
202     fSegmentation2[cath]->SetHit(fDetElemId, par[0],par[1],fZ);
203     q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
204        
205    Float_t value = fQtot[cath]*q1;
206    return value;
207 }
208
209
210 Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par) 
211 {
212 // par[0]    x-position of first  cluster
213 // par[1]    y-position of first  cluster
214 // par[2]    x-position of second cluster
215 // par[3]    y-position of second cluster
216 // par[4]    charge fraction of first  cluster
217 // 1-par[4]  charge fraction of second cluster
218
219   Float_t q1, q2;
220   
221   fSegmentation2[0]->SetPad(fDetElemId, fix[i][0], fiy[i][0]);
222   //  First Cluster
223   fSegmentation2[0]->SetHit(fDetElemId, par[0],par[1],fZ);
224   q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[0]);
225
226   //  Second Cluster
227   fSegmentation2[0]->SetHit(fDetElemId,par[2],par[3],fZ);
228   q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[0]);
229   
230   Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
231   return value;
232 }
233
234 Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath) 
235 {
236 // par[0]    x-position of first  cluster
237 // par[1]    y-position of first  cluster
238 // par[2]    x-position of second cluster
239 // par[3]    y-position of second cluster
240 // par[4]    charge fraction of first  cluster - first cathode
241 // 1-par[4]  charge fraction of second cluster 
242 // par[5]    charge fraction of first  cluster - second cathode
243
244   Float_t q1, q2;
245
246   fSegmentation2[cath]->SetPad(fDetElemId,fix[i][cath], fiy[i][cath]);
247   //  First Cluster
248   fSegmentation2[cath]->SetHit(fDetElemId,par[0],par[1],fZ);
249   q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
250   
251   //  Second Cluster
252   fSegmentation2[cath]->SetHit(fDetElemId,par[2],par[3],fZ);
253   q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
254   
255   Float_t value;
256   if (cath==0) {
257     value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
258   } else {
259     value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
260   }
261   return value;
262 }
263
264 AliMUONClusterInput& AliMUONClusterInput
265 ::operator = (const AliMUONClusterInput& rhs)
266 {
267 // Protected assignement operator
268
269   if (this == &rhs) return *this;
270
271   AliFatal("Not implemented.");
272     
273   return *this;  
274 }