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