]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONClusterInput.cxx
New segmentation with switch between old and new (Ch. Finck)
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterInput.cxx
CommitLineData
9825400f 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
88cb7938 16/* $Id$ */
d4fa40b7 17
30178c30 18#include <TClonesArray.h>
19#include <TMinuit.h>
20
9825400f 21#include "AliRun.h"
22#include "AliMUON.h"
23#include "AliMUONChamber.h"
7e4a628d 24#include "AliMUONConstants.h"
9825400f 25#include "AliMUONClusterInput.h"
7e4a628d 26#include "AliMUONMathieson.h"
9825400f 27#include "AliMUONRawCluster.h"
28#include "AliMUONDigit.h"
8c343c7c 29#include "AliLog.h"
9825400f 30
9825400f 31ClassImp(AliMUONClusterInput)
32
33AliMUONClusterInput* AliMUONClusterInput::fgClusterInput = 0;
34TMinuit* AliMUONClusterInput::fgMinuit = 0;
7e4a628d 35AliMUONMathieson* AliMUONClusterInput::fgMathieson = 0;
9825400f 36
30178c30 37AliMUONClusterInput::AliMUONClusterInput()
7e4a628d 38 : TObject(),
39 fCluster(0),
40 fChargeCorrel(1.) // in case not defined
41
30178c30 42{
3f5cf0b3 43 fDigits[0]=0;
44 fDigits[1]=0;
45 fSegmentation[0]=0;
46 fSegmentation[1]=0;
3f5cf0b3 47}
48
9825400f 49AliMUONClusterInput* AliMUONClusterInput::Instance()
50{
51// return pointer to the singleton instance
52 if (fgClusterInput == 0) {
53 fgClusterInput = new AliMUONClusterInput();
e357fc46 54 fgMinuit = new TMinuit(8);
9825400f 55 }
56
57 return fgClusterInput;
58}
59
d4fa40b7 60AliMUONClusterInput::~AliMUONClusterInput()
61{
62// Destructor
63 delete fgMinuit;
7e4a628d 64 delete fgMathieson;
d4fa40b7 65}
30178c30 66
7b4177a6 67AliMUONClusterInput::AliMUONClusterInput(const AliMUONClusterInput& clusterInput):TObject(clusterInput)
68{
30178c30 69// Protected copy constructor
70
8c343c7c 71 AliFatal("Not implemented.");
7b4177a6 72}
d4fa40b7 73
9825400f 74void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig1, TClonesArray* dig2)
75{
76// Set pointer to digits with corresponding segmentations and responses (two cathode planes)
30aaba74 77 fChamber=chamber;
9825400f 78 fDigits[0]=dig1;
79 fDigits[1]=dig2;
30aaba74 80 fNDigits[0]=dig1->GetEntriesFast();
81 fNDigits[1]=dig2->GetEntriesFast();
82
9825400f 83 AliMUON *pMUON;
84 AliMUONChamber* iChamber;
85
86 pMUON = (AliMUON*) gAlice->GetModule("MUON");
a713db22 87 if ((fSegmentationType = pMUON->WhichSegmentation()) != 1)
88 AliFatal("Wrong segmentation type");
9825400f 89
a713db22 90 iChamber = &(pMUON->Chamber(chamber));
7e4a628d 91 fgMathieson = new AliMUONMathieson();
a713db22 92
9825400f 93 fSegmentation[0]=iChamber->SegmentationModel(1);
94 fSegmentation[1]=iChamber->SegmentationModel(2);
a713db22 95
9825400f 96 fNseg = 2;
7e4a628d 97 if (chamber < AliMUONConstants::NTrackingCh()) {
1c334adf 98 if (chamber > 1 ) {
99 fgMathieson->SetPitch(AliMUONConstants::Pitch());
100 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3());
101 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3());
102 fChargeCorrel = AliMUONConstants::ChargeCorrel();
7e4a628d 103 } else {
1c334adf 104 fgMathieson->SetPitch(AliMUONConstants::PitchSt1());
105 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3St1());
106 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3St1());
107 fChargeCorrel = AliMUONConstants::ChargeCorrelSt1();
7e4a628d 108 }
109 }
9825400f 110}
111
112void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig)
113{
114// Set pointer to digits with corresponding segmentations and responses (one cathode plane)
115 fDigits[0]=dig;
116 AliMUON *pMUON;
117 AliMUONChamber* iChamber;
118
119 pMUON = (AliMUON*) gAlice->GetModule("MUON");
a713db22 120 if ((fSegmentationType = pMUON->WhichSegmentation()) != 1)
121 AliFatal("Wrong segmentation type");
9825400f 122
a713db22 123 iChamber = &(pMUON->Chamber(chamber));
9825400f 124 fSegmentation[0]=iChamber->SegmentationModel(1);
a713db22 125
126 fNseg=1;
127}
128void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig1, TClonesArray* dig2)
129{
130 // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
131 fChamber = chamber;
132 fDetElemId = idDE;
133 fDigits[0] = dig1;
134 fDigits[1] = dig2;
135 fNDigits[0] = dig1->GetEntriesFast();
136 fNDigits[1] = dig2->GetEntriesFast();
137
138 AliMUON *pMUON;
139 AliMUONChamber* iChamber;
140
141 pMUON = (AliMUON*) gAlice->GetModule("MUON");
142 iChamber = &(pMUON->Chamber(chamber));
143
144 fgMathieson = new AliMUONMathieson();
145 if ((fSegmentationType = pMUON->WhichSegmentation()) != 2)
146 AliFatal("Wrong segmentation type");
147
148 fSegmentation2[0]=iChamber->SegmentationModel2(1);
149 fSegmentation2[1]=iChamber->SegmentationModel2(2);
150
151 fNseg = 2;
152 if (chamber < AliMUONConstants::NTrackingCh()) {
153 if (chamber > 1 ) {
154 fgMathieson->SetPitch(AliMUONConstants::Pitch());
155 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3());
156 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3());
157 fChargeCorrel = AliMUONConstants::ChargeCorrel();
158 } else {
159 fgMathieson->SetPitch(AliMUONConstants::PitchSt1());
160 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3St1());
161 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3St1());
162 fChargeCorrel = AliMUONConstants::ChargeCorrelSt1();
163 }
164 }
165}
166
167void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig)
168{
169// Set pointer to digits with corresponding segmentations and responses (one cathode plane)
170
171 fChamber = chamber;
172 fDetElemId = idDE;
173 fDigits[0] = dig;
174
175 AliMUON *pMUON;
176 AliMUONChamber* iChamber;
177
178 pMUON = (AliMUON*) gAlice->GetModule("MUON");
179 iChamber = &(pMUON->Chamber(chamber));
180 if ((fSegmentationType = pMUON->WhichSegmentation()) != 2)
181 AliFatal("Wrong segmentation type");
182
183 fSegmentation2[0]=iChamber->SegmentationModel2(1);
184
9825400f 185 fNseg=1;
186}
187
188void AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
189{
190// Set the current cluster
19dd5b2f 191 //PH printf("\n %p \n", cluster);
9825400f 192 fCluster=cluster;
193 Float_t qtot;
194 Int_t i, cath, ix, iy;
195 AliMUONDigit* digit;
9e993f2a 196 fNmul[0]=cluster->GetMultiplicity(0);
197 fNmul[1]=cluster->GetMultiplicity(1);
19dd5b2f 198 //PH printf("\n %p %p ", fDigits[0], fDigits[1]);
9825400f 199
200 for (cath=0; cath<2; cath++) {
201 qtot=0;
202 for (i=0; i<fNmul[cath]; i++) {
203 // pointer to digit
204 digit =(AliMUONDigit*)
0164904a 205 (fDigits[cath]->UncheckedAt(cluster->GetIndex(i,cath)));
9825400f 206 // pad coordinates
08a636a8 207 ix = digit->PadX();
208 iy = digit->PadY();
9825400f 209 // pad charge
08a636a8 210 fCharge[i][cath] = digit->Signal();
9825400f 211 // pad centre coordinates
212// fSegmentation[cath]->GetPadCxy(ix, iy, x, y);
213 // globals kUsed in fitting functions
214 fix[i][cath]=ix;
215 fiy[i][cath]=iy;
216 // total charge per cluster
217 qtot+=fCharge[i][cath];
e357fc46 218 // Current z
219 Float_t xc, yc;
a713db22 220 if (fSegmentationType == 1)
221 fSegmentation[cath]->GetPadC(ix,iy,xc,yc,fZ);
222 else
223 fSegmentation2[cath]->GetPadC(fDetElemId,ix,iy,xc,yc,fZ);
224
9825400f 225 } // loop over cluster digits
226 fQtot[cath]=qtot;
227 fChargeTot[cath]=Int_t(qtot);
228 } // loop over cathodes
229}
230
231
232
233Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par)
234{
a1b02be9 235// Compute the charge on first cathod only.
236return DiscrChargeCombiS1(i,par,0);
9825400f 237}
238
239Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath)
240{
241// par[0] x-position of cluster
242// par[1] y-position of cluster
243
a713db22 244 Float_t q1;
245 if (fSegmentationType == 1) {
246
247 fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
248 // First Cluster
249 fSegmentation[cath]->SetHit(par[0],par[1],fZ);
250 q1 = fgMathieson->IntXY(fSegmentation[cath]);
251
252 } else {
253
254 fSegmentation2[cath]->SetPad(fDetElemId, fix[i][cath], fiy[i][cath]);
255 // First Cluster
256 fSegmentation2[cath]->SetHit(fDetElemId, par[0],par[1],fZ);
257 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
258 }
9825400f 259
260 Float_t value = fQtot[cath]*q1;
261 return value;
262}
263
264
265Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par)
266{
267// par[0] x-position of first cluster
268// par[1] y-position of first cluster
269// par[2] x-position of second cluster
270// par[3] y-position of second cluster
271// par[4] charge fraction of first cluster
272// 1-par[4] charge fraction of second cluster
273
a713db22 274 Float_t q1, q2;
275
276 if (fSegmentationType == 1) {
277
278 fSegmentation[0]->SetPad(fix[i][0], fiy[i][0]);
279 // First Cluster
280 fSegmentation[0]->SetHit(par[0],par[1],fZ);
281 q1 = fgMathieson->IntXY(fSegmentation[0]);
9825400f 282
a713db22 283 // Second Cluster
284 fSegmentation[0]->SetHit(par[2],par[3],fZ);
285 q2 = fgMathieson->IntXY(fSegmentation[0]);
286
287 } else {
288
289 fSegmentation2[0]->SetPad(fDetElemId, fix[i][0], fiy[i][0]);
290 // First Cluster
291 fSegmentation2[0]->SetHit(fDetElemId, par[0],par[1],fZ);
292 q1 = fgMathieson->IntXY(fSegmentation[0]);
9825400f 293
a713db22 294 // Second Cluster
295 fSegmentation2[0]->SetHit(fDetElemId,par[2],par[3],fZ);
296 q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[0]);
297 }
298
299 Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
300 return value;
9825400f 301}
302
303Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath)
304{
305// par[0] x-position of first cluster
306// par[1] y-position of first cluster
307// par[2] x-position of second cluster
308// par[3] y-position of second cluster
a1b02be9 309// par[4] charge fraction of first cluster - first cathode
310// 1-par[4] charge fraction of second cluster
311// par[5] charge fraction of first cluster - second cathode
9825400f 312
a713db22 313 Float_t q1, q2;
314
315 if (fSegmentationType == 1) {
316
317 fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
318 // First Cluster
319 fSegmentation[cath]->SetHit(par[0],par[1],fZ);
320 q1 = fgMathieson->IntXY(fSegmentation[cath]);
9825400f 321
a713db22 322 // Second Cluster
323 fSegmentation[cath]->SetHit(par[2],par[3],fZ);
324 q2 = fgMathieson->IntXY(fSegmentation[cath]);
325
326 } else {
327 fSegmentation2[cath]->SetPad(fDetElemId,fix[i][cath], fiy[i][cath]);
328 // First Cluster
329 fSegmentation2[cath]->SetHit(fDetElemId,par[0],par[1],fZ);
330 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
331
332 // Second Cluster
333 fSegmentation2[cath]->SetHit(fDetElemId,par[2],par[3],fZ);
334 q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
335 }
336 Float_t value;
337 if (cath==0) {
338 value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
339 } else {
340 value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
341 }
342 return value;
9825400f 343}
344
6a9bc541 345AliMUONClusterInput& AliMUONClusterInput
30178c30 346::operator = (const AliMUONClusterInput& rhs)
6a9bc541 347{
30178c30 348// Protected assignement operator
349
350 if (this == &rhs) return *this;
351
8c343c7c 352 AliFatal("Not implemented.");
30178c30 353
354 return *this;
6a9bc541 355}