]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterInput.cxx
README
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterInput.cxx
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 /* $Id$ */
17
18 #include "AliRun.h"
19 #include "AliMUON.h"
20 #include "AliMUONChamber.h"
21 #include "AliMUONClusterInput.h"
22 #include "AliSegmentation.h"
23 #include "AliMUONResponse.h"
24 #include "AliMUONRawCluster.h"
25 #include "AliMUONDigit.h"
26
27 #include <TClonesArray.h>
28 #include <TMinuit.h>
29
30 ClassImp(AliMUONClusterInput)
31
32 AliMUONClusterInput* AliMUONClusterInput::fgClusterInput = 0; 
33 TMinuit* AliMUONClusterInput::fgMinuit = 0; 
34
35 AliMUONClusterInput::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
46 AliMUONClusterInput* AliMUONClusterInput::Instance()
47 {
48 // return pointer to the singleton instance
49     if (fgClusterInput == 0) {
50         fgClusterInput = new AliMUONClusterInput();
51         fgMinuit = new TMinuit(8);
52     }
53     
54     return fgClusterInput;
55 }
56
57 AliMUONClusterInput::~AliMUONClusterInput()
58 {
59 // Destructor
60     delete fgMinuit;
61 }
62
63
64 void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig1, TClonesArray* dig2)
65 {
66 // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
67     fChamber=chamber;
68     fDigits[0]=dig1;
69     fDigits[1]=dig2; 
70     fNDigits[0]=dig1->GetEntriesFast();
71     fNDigits[1]=dig2->GetEntriesFast();
72     
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
85 void 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
100 void  AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
101 {
102 // Set the current cluster
103     printf("\n %p \n", cluster);
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
119             ix = digit->PadX();
120             iy = digit->PadY();
121             // pad charge
122             fCharge[i][cath] = digit->Signal();
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];
130             // Current z
131             Float_t xc, yc;
132             fSegmentation[cath]->GetPadC(ix,iy,xc,yc,fZ);
133         } // loop over cluster digits
134         fQtot[cath]=qtot;
135         fChargeTot[cath]=Int_t(qtot);  
136     }  // loop over cathodes
137 }
138
139
140
141 Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par) 
142 {
143 // Compute the charge on first cathod only.
144 return DiscrChargeCombiS1(i,par,0);
145 }
146
147 Float_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
154    fSegmentation[cath]->SetHit(par[0],par[1],fZ);
155    Float_t q1=fResponse->IntXY(fSegmentation[cath]);
156     
157    Float_t value = fQtot[cath]*q1;
158    return value;
159 }
160
161
162 Float_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
173    fSegmentation[0]->SetHit(par[0],par[1],fZ);
174    Float_t q1=fResponse->IntXY(fSegmentation[0]);
175     
176 //  Second Cluster
177    fSegmentation[0]->SetHit(par[2],par[3],fZ);
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
184 Float_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
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
193
194    fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
195 //  First Cluster
196    fSegmentation[cath]->SetHit(par[0],par[1],fZ);
197    Float_t q1=fResponse->IntXY(fSegmentation[cath]);
198     
199 //  Second Cluster
200    fSegmentation[cath]->SetHit(par[2],par[3],fZ);
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
211 AliMUONClusterInput& AliMUONClusterInput
212 ::operator = (const AliMUONClusterInput& rhs)
213 {
214 // Dummy assignment operator
215     return *this;
216 }