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()
40 fChargeCorrel(1.) // in case not defined
49 AliMUONClusterInput* AliMUONClusterInput::Instance()
51 // return pointer to the singleton instance
52 if (fgClusterInput == 0) {
53 fgClusterInput = new AliMUONClusterInput();
54 fgMinuit = new TMinuit(8);
57 return fgClusterInput;
60 AliMUONClusterInput::~AliMUONClusterInput()
67 AliMUONClusterInput::AliMUONClusterInput(const AliMUONClusterInput& clusterInput):TObject(clusterInput)
69 // Protected copy constructor
71 AliFatal("Not implemented.");
74 void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig1, TClonesArray* dig2)
76 // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
80 fNDigits[0]=dig1->GetEntriesFast();
81 fNDigits[1]=dig2->GetEntriesFast();
84 AliMUONChamber* iChamber;
86 pMUON = (AliMUON*) gAlice->GetModule("MUON");
87 if ((fSegmentationType = pMUON->WhichSegmentation()) != 1)
88 AliFatal("Wrong segmentation type");
90 iChamber = &(pMUON->Chamber(chamber));
91 fgMathieson = new AliMUONMathieson();
93 fSegmentation[0]=iChamber->SegmentationModel(1);
94 fSegmentation[1]=iChamber->SegmentationModel(2);
97 if (chamber < AliMUONConstants::NTrackingCh()) {
99 fgMathieson->SetPitch(AliMUONConstants::Pitch());
100 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3());
101 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3());
102 fChargeCorrel = AliMUONConstants::ChargeCorrel();
104 fgMathieson->SetPitch(AliMUONConstants::PitchSt1());
105 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3St1());
106 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3St1());
107 fChargeCorrel = AliMUONConstants::ChargeCorrelSt1();
112 void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig)
114 // Set pointer to digits with corresponding segmentations and responses (one cathode plane)
117 AliMUONChamber* iChamber;
119 pMUON = (AliMUON*) gAlice->GetModule("MUON");
120 if ((fSegmentationType = pMUON->WhichSegmentation()) != 1)
121 AliFatal("Wrong segmentation type");
123 iChamber = &(pMUON->Chamber(chamber));
124 fSegmentation[0]=iChamber->SegmentationModel(1);
128 void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig1, TClonesArray* dig2)
130 // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
135 fNDigits[0] = dig1->GetEntriesFast();
136 fNDigits[1] = dig2->GetEntriesFast();
139 AliMUONChamber* iChamber;
141 pMUON = (AliMUON*) gAlice->GetModule("MUON");
142 iChamber = &(pMUON->Chamber(chamber));
144 fgMathieson = new AliMUONMathieson();
145 if ((fSegmentationType = pMUON->WhichSegmentation()) != 2)
146 AliFatal("Wrong segmentation type");
148 fSegmentation2[0]=iChamber->SegmentationModel2(1);
149 fSegmentation2[1]=iChamber->SegmentationModel2(2);
152 if (chamber < AliMUONConstants::NTrackingCh()) {
154 fgMathieson->SetPitch(AliMUONConstants::Pitch());
155 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3());
156 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3());
157 fChargeCorrel = AliMUONConstants::ChargeCorrel();
159 fgMathieson->SetPitch(AliMUONConstants::PitchSt1());
160 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3St1());
161 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3St1());
162 fChargeCorrel = AliMUONConstants::ChargeCorrelSt1();
167 void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig)
169 // Set pointer to digits with corresponding segmentations and responses (one cathode plane)
176 AliMUONChamber* iChamber;
178 pMUON = (AliMUON*) gAlice->GetModule("MUON");
179 iChamber = &(pMUON->Chamber(chamber));
180 if ((fSegmentationType = pMUON->WhichSegmentation()) != 2)
181 AliFatal("Wrong segmentation type");
183 fSegmentation2[0]=iChamber->SegmentationModel2(1);
188 void AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
190 // Set the current cluster
191 //PH printf("\n %p \n", cluster);
194 Int_t i, cath, ix, iy;
196 fNmul[0]=cluster->GetMultiplicity(0);
197 fNmul[1]=cluster->GetMultiplicity(1);
198 //PH printf("\n %p %p ", fDigits[0], fDigits[1]);
200 for (cath=0; cath<2; cath++) {
202 for (i=0; i<fNmul[cath]; i++) {
204 digit =(AliMUONDigit*)
205 (fDigits[cath]->UncheckedAt(cluster->GetIndex(i,cath)));
210 fCharge[i][cath] = digit->Signal();
211 // pad centre coordinates
212 // fSegmentation[cath]->GetPadCxy(ix, iy, x, y);
213 // globals kUsed in fitting functions
216 // total charge per cluster
217 qtot+=fCharge[i][cath];
220 if (fSegmentationType == 1)
221 fSegmentation[cath]->GetPadC(ix,iy,xc,yc,fZ);
223 fSegmentation2[cath]->GetPadC(fDetElemId,ix,iy,xc,yc,fZ);
225 } // loop over cluster digits
227 fChargeTot[cath]=Int_t(qtot);
228 } // loop over cathodes
233 Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par)
235 // Compute the charge on first cathod only.
236 return DiscrChargeCombiS1(i,par,0);
239 Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath)
241 // par[0] x-position of cluster
242 // par[1] y-position of cluster
245 if (fSegmentationType == 1) {
247 fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
249 fSegmentation[cath]->SetHit(par[0],par[1],fZ);
250 q1 = fgMathieson->IntXY(fSegmentation[cath]);
254 fSegmentation2[cath]->SetPad(fDetElemId, fix[i][cath], fiy[i][cath]);
256 fSegmentation2[cath]->SetHit(fDetElemId, par[0],par[1],fZ);
257 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
260 Float_t value = fQtot[cath]*q1;
265 Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par)
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
276 if (fSegmentationType == 1) {
278 fSegmentation[0]->SetPad(fix[i][0], fiy[i][0]);
280 fSegmentation[0]->SetHit(par[0],par[1],fZ);
281 q1 = fgMathieson->IntXY(fSegmentation[0]);
284 fSegmentation[0]->SetHit(par[2],par[3],fZ);
285 q2 = fgMathieson->IntXY(fSegmentation[0]);
289 fSegmentation2[0]->SetPad(fDetElemId, fix[i][0], fiy[i][0]);
291 fSegmentation2[0]->SetHit(fDetElemId, par[0],par[1],fZ);
292 q1 = fgMathieson->IntXY(fSegmentation[0]);
295 fSegmentation2[0]->SetHit(fDetElemId,par[2],par[3],fZ);
296 q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[0]);
299 Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
303 Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath)
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
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
315 if (fSegmentationType == 1) {
317 fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
319 fSegmentation[cath]->SetHit(par[0],par[1],fZ);
320 q1 = fgMathieson->IntXY(fSegmentation[cath]);
323 fSegmentation[cath]->SetHit(par[2],par[3],fZ);
324 q2 = fgMathieson->IntXY(fSegmentation[cath]);
327 fSegmentation2[cath]->SetPad(fDetElemId,fix[i][cath], fiy[i][cath]);
329 fSegmentation2[cath]->SetHit(fDetElemId,par[0],par[1],fZ);
330 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
333 fSegmentation2[cath]->SetHit(fDetElemId,par[2],par[3],fZ);
334 q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
338 value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
340 value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
345 AliMUONClusterInput& AliMUONClusterInput
346 ::operator = (const AliMUONClusterInput& rhs)
348 // Protected assignement operator
350 if (this == &rhs) return *this;
352 AliFatal("Not implemented.");