Avoid global variables in AliMUONClusterFinderVS by seperating the input data for...
[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
16/*
17$Log$
18*/
19#include "AliRun.h"
20#include "AliMUON.h"
21#include "AliMUONChamber.h"
22#include "AliMUONClusterInput.h"
23#include "AliMUONSegmentation.h"
24#include "AliMUONResponse.h"
25#include "AliMUONRawCluster.h"
26#include "AliMUONDigit.h"
27
28#include <TClonesArray.h>
29#include <TMinuit.h>
30
31ClassImp(AliMUONClusterInput)
32
33AliMUONClusterInput* AliMUONClusterInput::fgClusterInput = 0;
34TMinuit* AliMUONClusterInput::fgMinuit = 0;
35
36AliMUONClusterInput* AliMUONClusterInput::Instance()
37{
38// return pointer to the singleton instance
39 if (fgClusterInput == 0) {
40 fgClusterInput = new AliMUONClusterInput();
41 fgMinuit = new TMinuit(5);
42 }
43
44 return fgClusterInput;
45}
46
47void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig1, TClonesArray* dig2)
48{
49// Set pointer to digits with corresponding segmentations and responses (two cathode planes)
50 fDigits[0]=dig1;
51 fDigits[1]=dig2;
52 AliMUON *pMUON;
53 AliMUONChamber* iChamber;
54
55 pMUON = (AliMUON*) gAlice->GetModule("MUON");
56 iChamber = &(pMUON->Chamber(chamber));
57
58 fSegmentation[0]=iChamber->SegmentationModel(1);
59 fSegmentation[1]=iChamber->SegmentationModel(2);
60 fResponse=iChamber->ResponseModel();
61 fNseg = 2;
62}
63
64void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig)
65{
66// Set pointer to digits with corresponding segmentations and responses (one cathode plane)
67 fDigits[0]=dig;
68 AliMUON *pMUON;
69 AliMUONChamber* iChamber;
70
71 pMUON = (AliMUON*) gAlice->GetModule("MUON");
72 iChamber = &(pMUON->Chamber(chamber));
73
74 fSegmentation[0]=iChamber->SegmentationModel(1);
75 fResponse=iChamber->ResponseModel();
76 fNseg=1;
77}
78
79void AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
80{
81// Set the current cluster
82 fCluster=cluster;
83 Float_t qtot;
84 Int_t i, cath, ix, iy;
85 AliMUONDigit* digit;
86 fNmul[0]=cluster->fMultiplicity[0];
87 fNmul[1]=cluster->fMultiplicity[1];
88 printf("\n %p %p ", fDigits[0], fDigits[1]);
89
90 for (cath=0; cath<2; cath++) {
91 qtot=0;
92 for (i=0; i<fNmul[cath]; i++) {
93 // pointer to digit
94 digit =(AliMUONDigit*)
95 (fDigits[cath]->UncheckedAt(cluster->fIndexMap[i][cath]));
96 // pad coordinates
97 ix = digit->fPadX;
98 iy = digit->fPadY;
99 // pad charge
100 fCharge[i][cath] = digit->fSignal;
101 // pad centre coordinates
102// fSegmentation[cath]->GetPadCxy(ix, iy, x, y);
103 // globals kUsed in fitting functions
104 fix[i][cath]=ix;
105 fiy[i][cath]=iy;
106 // total charge per cluster
107 qtot+=fCharge[i][cath];
108 } // loop over cluster digits
109 fQtot[cath]=qtot;
110 fChargeTot[cath]=Int_t(qtot);
111 } // loop over cathodes
112}
113
114
115
116Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par)
117{
118// par[0] x-position of cluster
119// par[1] y-position of cluster
120
121 fSegmentation[0]->SetPad(fix[i][0], fiy[i][0]);
122// First Cluster
123 fSegmentation[0]->SetHit(par[0],par[1]);
124 Float_t q1=fResponse->IntXY(fSegmentation[0]);
125
126 Float_t value = fQtot[0]*q1;
127 return value;
128}
129
130Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath)
131{
132// par[0] x-position of cluster
133// par[1] y-position of cluster
134
135 fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
136// First Cluster
137 fSegmentation[cath]->SetHit(par[0],par[1]);
138 Float_t q1=fResponse->IntXY(fSegmentation[cath]);
139
140 Float_t value = fQtot[cath]*q1;
141 return value;
142}
143
144
145Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par)
146{
147// par[0] x-position of first cluster
148// par[1] y-position of first cluster
149// par[2] x-position of second cluster
150// par[3] y-position of second cluster
151// par[4] charge fraction of first cluster
152// 1-par[4] charge fraction of second cluster
153
154 fSegmentation[0]->SetPad(fix[i][0], fiy[i][0]);
155// First Cluster
156 fSegmentation[0]->SetHit(par[0],par[1]);
157 Float_t q1=fResponse->IntXY(fSegmentation[0]);
158
159// Second Cluster
160 fSegmentation[0]->SetHit(par[2],par[3]);
161 Float_t q2=fResponse->IntXY(fSegmentation[0]);
162
163 Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
164 return value;
165}
166
167Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath)
168{
169// par[0] x-position of first cluster
170// par[1] y-position of first cluster
171// par[2] x-position of second cluster
172// par[3] y-position of second cluster
173// par[4] charge fraction of first cluster
174// 1-par[4] charge fraction of second cluster
175
176 fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
177// First Cluster
178 fSegmentation[cath]->SetHit(par[0],par[1]);
179 Float_t q1=fResponse->IntXY(fSegmentation[cath]);
180
181// Second Cluster
182 fSegmentation[cath]->SetHit(par[2],par[3]);
183 Float_t q2=fResponse->IntXY(fSegmentation[cath]);
184 Float_t value;
185 if (cath==0) {
186 value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
187 } else {
188 value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
189 }
190 return value;
191}
192
193
194
195