]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONClusterInput.cxx
Cache the InversePitch instead of computing it each time.
[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"
b7ef3c96 23#include "AliMUONSegmentation.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),
fed772f3 40 fChargeCorrel(1.),
fed772f3 41 fDetElemId(0)
b137f8b9 42
30178c30 43{
3f5cf0b3 44 fDigits[0]=0;
45 fDigits[1]=0;
fed772f3 46 fSegmentation2[0]=0;
47 fSegmentation2[1]=0;
3f5cf0b3 48}
49
9825400f 50AliMUONClusterInput* AliMUONClusterInput::Instance()
51{
52// return pointer to the singleton instance
53 if (fgClusterInput == 0) {
54 fgClusterInput = new AliMUONClusterInput();
e357fc46 55 fgMinuit = new TMinuit(8);
9825400f 56 }
57
58 return fgClusterInput;
59}
60
d4fa40b7 61AliMUONClusterInput::~AliMUONClusterInput()
62{
63// Destructor
64 delete fgMinuit;
7e4a628d 65 delete fgMathieson;
d4fa40b7 66}
30178c30 67
7b4177a6 68AliMUONClusterInput::AliMUONClusterInput(const AliMUONClusterInput& clusterInput):TObject(clusterInput)
69{
30178c30 70// Protected copy constructor
71
8c343c7c 72 AliFatal("Not implemented.");
7b4177a6 73}
d4fa40b7 74
a713db22 75void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig1, TClonesArray* dig2)
76{
77 // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
78 fChamber = chamber;
79 fDetElemId = idDE;
80 fDigits[0] = dig1;
81 fDigits[1] = dig2;
82 fNDigits[0] = dig1->GetEntriesFast();
83 fNDigits[1] = dig2->GetEntriesFast();
84
b7ef3c96 85 fgMathieson = new AliMUONMathieson();
86
a713db22 87 AliMUON *pMUON;
b7ef3c96 88 AliMUONSegmentation* pSegmentation;
a713db22 89
90 pMUON = (AliMUON*) gAlice->GetModule("MUON");
b7ef3c96 91 pSegmentation = pMUON->GetSegmentation();
92 fSegmentation2[0]= pSegmentation->GetModuleSegmentation(chamber, 0);
93 fSegmentation2[1]= pSegmentation->GetModuleSegmentation(chamber, 1);
a713db22 94
95 fNseg = 2;
96 if (chamber < AliMUONConstants::NTrackingCh()) {
97 if (chamber > 1 ) {
98 fgMathieson->SetPitch(AliMUONConstants::Pitch());
99 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3());
100 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3());
101 fChargeCorrel = AliMUONConstants::ChargeCorrel();
102 } else {
103 fgMathieson->SetPitch(AliMUONConstants::PitchSt1());
104 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3St1());
105 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3St1());
106 fChargeCorrel = AliMUONConstants::ChargeCorrelSt1();
107 }
108 }
109}
110
111void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig)
112{
113// Set pointer to digits with corresponding segmentations and responses (one cathode plane)
114
115 fChamber = chamber;
116 fDetElemId = idDE;
117 fDigits[0] = dig;
118
119 AliMUON *pMUON;
b7ef3c96 120 AliMUONSegmentation* pSegmentation;
a713db22 121
122 pMUON = (AliMUON*) gAlice->GetModule("MUON");
b7ef3c96 123 pSegmentation = pMUON->GetSegmentation();
124 fSegmentation2[0]= pSegmentation->GetModuleSegmentation(chamber, 0);
a713db22 125
9825400f 126 fNseg=1;
127}
128
129void AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
130{
131// Set the current cluster
b137f8b9 132 //PH printf("\n %p \n", cluster);
133 fCluster=cluster;
134 Float_t qtot;
135 Int_t i, cath, ix, iy;
136 AliMUONDigit* digit;
137 fNmul[0]=cluster->GetMultiplicity(0);
138 fNmul[1]=cluster->GetMultiplicity(1);
139 //PH printf("\n %p %p ", fDigits[0], fDigits[1]);
140
141 for (cath=0; cath<2; cath++) {
142 qtot=0;
143 for (i=0; i<fNmul[cath]; i++) {
144 // pointer to digit
145 digit =(AliMUONDigit*)
0164904a 146 (fDigits[cath]->UncheckedAt(cluster->GetIndex(i,cath)));
9825400f 147 // pad coordinates
08a636a8 148 ix = digit->PadX();
149 iy = digit->PadY();
9825400f 150 // pad charge
08a636a8 151 fCharge[i][cath] = digit->Signal();
9825400f 152 // pad centre coordinates
153// fSegmentation[cath]->GetPadCxy(ix, iy, x, y);
154 // globals kUsed in fitting functions
155 fix[i][cath]=ix;
156 fiy[i][cath]=iy;
157 // total charge per cluster
158 qtot+=fCharge[i][cath];
e357fc46 159 // Current z
160 Float_t xc, yc;
002920d1 161 fSegmentation2[cath]->GetPadC(fDetElemId,ix,iy,xc,yc,fZ);
9825400f 162 } // loop over cluster digits
163 fQtot[cath]=qtot;
164 fChargeTot[cath]=Int_t(qtot);
165 } // loop over cathodes
166}
167
168
169
170Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par)
171{
a1b02be9 172// Compute the charge on first cathod only.
173return DiscrChargeCombiS1(i,par,0);
9825400f 174}
175
176Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath)
177{
178// par[0] x-position of cluster
179// par[1] y-position of cluster
180
a713db22 181 Float_t q1;
002920d1 182 fSegmentation2[cath]->SetPad(fDetElemId, fix[i][cath], fiy[i][cath]);
183 // First Cluster
184 fSegmentation2[cath]->SetHit(fDetElemId, par[0],par[1],fZ);
185 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
186
9825400f 187 Float_t value = fQtot[cath]*q1;
188 return value;
189}
190
191
192Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par)
193{
194// par[0] x-position of first cluster
195// par[1] y-position of first cluster
196// par[2] x-position of second cluster
197// par[3] y-position of second cluster
198// par[4] charge fraction of first cluster
199// 1-par[4] charge fraction of second cluster
200
a713db22 201 Float_t q1, q2;
202
002920d1 203 fSegmentation2[0]->SetPad(fDetElemId, fix[i][0], fiy[i][0]);
204 // First Cluster
205 fSegmentation2[0]->SetHit(fDetElemId, par[0],par[1],fZ);
206 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[0]);
207
208 // Second Cluster
209 fSegmentation2[0]->SetHit(fDetElemId,par[2],par[3],fZ);
210 q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[0]);
211
a713db22 212 Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
213 return value;
9825400f 214}
215
216Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath)
217{
218// par[0] x-position of first cluster
219// par[1] y-position of first cluster
220// par[2] x-position of second cluster
221// par[3] y-position of second cluster
a1b02be9 222// par[4] charge fraction of first cluster - first cathode
223// 1-par[4] charge fraction of second cluster
224// par[5] charge fraction of first cluster - second cathode
9825400f 225
a713db22 226 Float_t q1, q2;
227
002920d1 228 fSegmentation2[cath]->SetPad(fDetElemId,fix[i][cath], fiy[i][cath]);
229 // First Cluster
230 fSegmentation2[cath]->SetHit(fDetElemId,par[0],par[1],fZ);
231 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
232
233 // Second Cluster
234 fSegmentation2[cath]->SetHit(fDetElemId,par[2],par[3],fZ);
235 q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
236
a713db22 237 Float_t value;
238 if (cath==0) {
239 value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
240 } else {
241 value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
242 }
243 return value;
9825400f 244}
245
6a9bc541 246AliMUONClusterInput& AliMUONClusterInput
30178c30 247::operator = (const AliMUONClusterInput& rhs)
6a9bc541 248{
30178c30 249// Protected assignement operator
250
251 if (this == &rhs) return *this;
252
8c343c7c 253 AliFatal("Not implemented.");
30178c30 254
255 return *this;
6a9bc541 256}