1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include <TClonesArray.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"
31 ClassImp(AliMUONClusterInput)
33 AliMUONClusterInput* AliMUONClusterInput::fgClusterInput = 0;
34 TMinuit* AliMUONClusterInput::fgMinuit = 0;
35 AliMUONMathieson* AliMUONClusterInput::fgMathieson = 0;
37 AliMUONClusterInput::AliMUONClusterInput()
53 AliMUONClusterInput* AliMUONClusterInput::Instance()
55 // return pointer to the singleton instance
56 if (fgClusterInput == 0) {
57 fgClusterInput = new AliMUONClusterInput();
58 fgMinuit = new TMinuit(8);
61 return fgClusterInput;
64 AliMUONClusterInput::~AliMUONClusterInput()
71 AliMUONClusterInput::AliMUONClusterInput(const AliMUONClusterInput& clusterInput):TObject(clusterInput)
73 // Protected copy constructor
75 AliFatal("Not implemented.");
78 void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig1, TClonesArray* dig2)
80 // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
84 fNDigits[0]=dig1->GetEntriesFast();
85 fNDigits[1]=dig2->GetEntriesFast();
88 AliMUONChamber* iChamber;
90 pMUON = (AliMUON*) gAlice->GetModule("MUON");
91 if ((fSegmentationType = pMUON->WhichSegmentation()) != 1)
92 AliFatal("Wrong segmentation type");
94 iChamber = &(pMUON->Chamber(chamber));
95 fgMathieson = new AliMUONMathieson();
97 fSegmentation[0]=iChamber->SegmentationModel(1);
98 fSegmentation[1]=iChamber->SegmentationModel(2);
101 if (chamber < AliMUONConstants::NTrackingCh()) {
103 fgMathieson->SetPitch(AliMUONConstants::Pitch());
104 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3());
105 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3());
106 fChargeCorrel = AliMUONConstants::ChargeCorrel();
108 fgMathieson->SetPitch(AliMUONConstants::PitchSt1());
109 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3St1());
110 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3St1());
111 fChargeCorrel = AliMUONConstants::ChargeCorrelSt1();
116 void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig)
118 // Set pointer to digits with corresponding segmentations and responses (one cathode plane)
121 AliMUONChamber* iChamber;
123 pMUON = (AliMUON*) gAlice->GetModule("MUON");
124 if ((fSegmentationType = pMUON->WhichSegmentation()) != 1)
125 AliFatal("Wrong segmentation type");
127 iChamber = &(pMUON->Chamber(chamber));
128 fSegmentation[0]=iChamber->SegmentationModel(1);
132 void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig1, TClonesArray* dig2)
134 // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
139 fNDigits[0] = dig1->GetEntriesFast();
140 fNDigits[1] = dig2->GetEntriesFast();
143 AliMUONChamber* iChamber;
145 pMUON = (AliMUON*) gAlice->GetModule("MUON");
146 iChamber = &(pMUON->Chamber(chamber));
148 fgMathieson = new AliMUONMathieson();
149 if ((fSegmentationType = pMUON->WhichSegmentation()) != 2)
150 AliFatal("Wrong segmentation type");
152 fSegmentation2[0]=iChamber->SegmentationModel2(1);
153 fSegmentation2[1]=iChamber->SegmentationModel2(2);
156 if (chamber < AliMUONConstants::NTrackingCh()) {
158 fgMathieson->SetPitch(AliMUONConstants::Pitch());
159 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3());
160 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3());
161 fChargeCorrel = AliMUONConstants::ChargeCorrel();
163 fgMathieson->SetPitch(AliMUONConstants::PitchSt1());
164 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3St1());
165 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3St1());
166 fChargeCorrel = AliMUONConstants::ChargeCorrelSt1();
171 void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig)
173 // Set pointer to digits with corresponding segmentations and responses (one cathode plane)
180 AliMUONChamber* iChamber;
182 pMUON = (AliMUON*) gAlice->GetModule("MUON");
183 iChamber = &(pMUON->Chamber(chamber));
184 if ((fSegmentationType = pMUON->WhichSegmentation()) != 2)
185 AliFatal("Wrong segmentation type");
187 fSegmentation2[0]=iChamber->SegmentationModel2(1);
192 void AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
194 // Set the current cluster
195 //PH printf("\n %p \n", cluster);
198 Int_t i, cath, ix, iy;
200 fNmul[0]=cluster->GetMultiplicity(0);
201 fNmul[1]=cluster->GetMultiplicity(1);
202 //PH printf("\n %p %p ", fDigits[0], fDigits[1]);
204 for (cath=0; cath<2; cath++) {
206 for (i=0; i<fNmul[cath]; i++) {
208 digit =(AliMUONDigit*)
209 (fDigits[cath]->UncheckedAt(cluster->GetIndex(i,cath)));
214 fCharge[i][cath] = digit->Signal();
215 // pad centre coordinates
216 // fSegmentation[cath]->GetPadCxy(ix, iy, x, y);
217 // globals kUsed in fitting functions
220 // total charge per cluster
221 qtot+=fCharge[i][cath];
224 if (fSegmentationType == 1)
225 fSegmentation[cath]->GetPadC(ix,iy,xc,yc,fZ);
227 fSegmentation2[cath]->GetPadC(fDetElemId,ix,iy,xc,yc,fZ);
229 } // loop over cluster digits
231 fChargeTot[cath]=Int_t(qtot);
232 } // loop over cathodes
237 Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par)
239 // Compute the charge on first cathod only.
240 return DiscrChargeCombiS1(i,par,0);
243 Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath)
245 // par[0] x-position of cluster
246 // par[1] y-position of cluster
249 if (fSegmentationType == 1) {
251 fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
253 fSegmentation[cath]->SetHit(par[0],par[1],fZ);
254 q1 = fgMathieson->IntXY(fSegmentation[cath]);
258 fSegmentation2[cath]->SetPad(fDetElemId, fix[i][cath], fiy[i][cath]);
260 fSegmentation2[cath]->SetHit(fDetElemId, par[0],par[1],fZ);
261 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
264 Float_t value = fQtot[cath]*q1;
269 Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par)
271 // par[0] x-position of first cluster
272 // par[1] y-position of first cluster
273 // par[2] x-position of second cluster
274 // par[3] y-position of second cluster
275 // par[4] charge fraction of first cluster
276 // 1-par[4] charge fraction of second cluster
280 if (fSegmentationType == 1) {
282 fSegmentation[0]->SetPad(fix[i][0], fiy[i][0]);
284 fSegmentation[0]->SetHit(par[0],par[1],fZ);
285 q1 = fgMathieson->IntXY(fSegmentation[0]);
288 fSegmentation[0]->SetHit(par[2],par[3],fZ);
289 q2 = fgMathieson->IntXY(fSegmentation[0]);
293 fSegmentation2[0]->SetPad(fDetElemId, fix[i][0], fiy[i][0]);
295 fSegmentation2[0]->SetHit(fDetElemId, par[0],par[1],fZ);
296 q1 = fgMathieson->IntXY(fSegmentation[0]);
299 fSegmentation2[0]->SetHit(fDetElemId,par[2],par[3],fZ);
300 q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[0]);
303 Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
307 Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath)
309 // par[0] x-position of first cluster
310 // par[1] y-position of first cluster
311 // par[2] x-position of second cluster
312 // par[3] y-position of second cluster
313 // par[4] charge fraction of first cluster - first cathode
314 // 1-par[4] charge fraction of second cluster
315 // par[5] charge fraction of first cluster - second cathode
319 if (fSegmentationType == 1) {
321 fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
323 fSegmentation[cath]->SetHit(par[0],par[1],fZ);
324 q1 = fgMathieson->IntXY(fSegmentation[cath]);
327 fSegmentation[cath]->SetHit(par[2],par[3],fZ);
328 q2 = fgMathieson->IntXY(fSegmentation[cath]);
331 fSegmentation2[cath]->SetPad(fDetElemId,fix[i][cath], fiy[i][cath]);
333 fSegmentation2[cath]->SetHit(fDetElemId,par[0],par[1],fZ);
334 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
337 fSegmentation2[cath]->SetHit(fDetElemId,par[2],par[3],fZ);
338 q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
342 value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
344 value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
349 AliMUONClusterInput& AliMUONClusterInput
350 ::operator = (const AliMUONClusterInput& rhs)
352 // Protected assignement operator
354 if (this == &rhs) return *this;
356 AliFatal("Not implemented.");