]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterInput.cxx
Updated for changes in AliMUONSegmentation
[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 // ----------------------------
19 // Class AliMUONClusterInput
20 // ----------------------------
21 // Global data service for hit reconstruction
22 // Author: to be added
23
24 #include "AliMUONClusterInput.h"
25
26 #include "AliMUONGeometryTransformer.h"
27 #include "AliMUONGeometrySegmentation.h"
28 #include "AliMUONSegFactory.h"
29 #include "AliMUONSegmentation.h"
30 #include "AliMUONConstants.h"
31 #include "AliMUONMathieson.h"
32 #include "AliMUONRawCluster.h"
33 #include "AliMUONDigit.h"
34
35 #include "AliLog.h"
36
37 #include <TClonesArray.h>
38 #include <TMinuit.h>
39 #include <TGeoManager.h>
40
41 AliMUONClusterInput*        AliMUONClusterInput::fgClusterInput = 0; 
42 TMinuit*                    AliMUONClusterInput::fgMinuit = 0; 
43 AliMUONMathieson*           AliMUONClusterInput::fgMathieson = 0; 
44 AliMUONGeometryTransformer* AliMUONClusterInput::fgTransformer = 0; 
45 AliMUONSegmentation*        AliMUONClusterInput::fgSegmentation = 0; 
46
47 ClassImp(AliMUONClusterInput)
48
49 AliMUONClusterInput::AliMUONClusterInput()
50   : TObject(),
51     fNseg(0),
52     fChamber(0),
53     fCluster(0),
54     fZ(0.),
55     fChargeCorrel(1.),
56     fDetElemId(0)
57   
58 {
59 // Default constructor
60
61   fDigits[0]=0;
62   fDigits[1]=0;
63   fSegmentation2[0]=0;
64   fSegmentation2[1]=0;
65 }
66
67 AliMUONClusterInput* AliMUONClusterInput::Instance()
68 {
69 // return pointer to the singleton instance
70     if (fgClusterInput == 0) {
71         fgClusterInput = new AliMUONClusterInput();
72         fgMinuit = new TMinuit(8);
73         
74         // Create segmentation with activated Root geometry  
75         if ( ! gGeoManager ) {
76           AliFatalClass("Geometry not loaded.");
77           return fgClusterInput;
78         }  
79         fgTransformer = new AliMUONGeometryTransformer(true);
80         fgTransformer->ReadGeometryData("volpath.dat", gGeoManager);
81         AliMUONSegFactory factory(fgTransformer);
82         fgSegmentation = factory.CreateSegmentation(); 
83     }
84     
85     return fgClusterInput;
86 }
87
88 AliMUONClusterInput::~AliMUONClusterInput()
89 {
90 // Destructor
91     delete fgMinuit;
92     delete fgMathieson;
93     delete fgTransformer;
94     delete fgSegmentation;
95     fgMinuit = 0;
96     fgMathieson = 0;
97 }
98
99 void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig1, TClonesArray* dig2)
100 {
101   // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
102     fChamber = chamber;
103     fDetElemId = idDE;
104     fDigits[0]  = dig1;
105     fDigits[1]  = dig2; 
106     fNDigits[0] = dig1->GetEntriesFast();
107     fNDigits[1] = dig2->GetEntriesFast();
108     
109     delete fgMathieson;
110     fgMathieson = new AliMUONMathieson();
111
112     fSegmentation2[0]= fgSegmentation->GetModuleSegmentationByDEId(fDetElemId, 0);
113     fSegmentation2[1]= fgSegmentation->GetModuleSegmentationByDEId(fDetElemId, 1);
114
115     fNseg = 2;
116     if (chamber < AliMUONConstants::NTrackingCh()) {
117       if (chamber > 1 ) {
118         fgMathieson->SetPitch(AliMUONConstants::Pitch());
119         fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3());
120         fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3());
121         fChargeCorrel = AliMUONConstants::ChargeCorrel();
122       } else {
123         fgMathieson->SetPitch(AliMUONConstants::PitchSt1());
124         fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3St1());
125         fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3St1());
126         fChargeCorrel = AliMUONConstants::ChargeCorrelSt1();
127       }
128     }
129 }
130
131 void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig)
132 {
133 // Set pointer to digits with corresponding segmentations and responses (one cathode plane)
134
135     fChamber = chamber;
136     fDetElemId = idDE;
137     fDigits[0] = dig;
138
139     fSegmentation2[0]= fgSegmentation->GetModuleSegmentationByDEId(fDetElemId, 0);
140     fNseg=1;
141 }
142
143 void  AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
144 {
145 // Set the current cluster
146   //PH printf("\n %p \n", cluster);
147   fCluster=cluster;
148   Float_t qtot;
149   Int_t   i, cath, ix, iy;
150   AliMUONDigit* digit;
151   fNmul[0]=cluster->GetMultiplicity(0);
152   fNmul[1]=cluster->GetMultiplicity(1);
153   //PH printf("\n %p %p ", fDigits[0], fDigits[1]);
154   
155   for (cath=0; cath<2; cath++) {
156     qtot=0;
157     for (i=0; i<fNmul[cath]; i++) {
158       // pointer to digit
159       digit =(AliMUONDigit*)
160                 (fDigits[cath]->UncheckedAt(cluster->GetIndex(i,cath)));
161             // pad coordinates
162             ix = digit->PadX();
163             iy = digit->PadY();
164             // pad charge
165             fCharge[i][cath] = digit->Signal();
166             // pad centre coordinates
167 //          fSegmentation[cath]->GetPadCxy(ix, iy, x, y);
168             // globals kUsed in fitting functions
169             fix[i][cath]=ix;
170             fiy[i][cath]=iy;
171             // total charge per cluster
172             qtot+=fCharge[i][cath];
173             // Current z
174             Float_t xc, yc;
175             fSegmentation2[cath]->GetPadC(fDetElemId,ix,iy,xc,yc,fZ);
176         } // loop over cluster digits
177         fQtot[cath]=qtot;
178         fChargeTot[cath]=Int_t(qtot);  
179     }  // loop over cathodes
180 }
181
182
183
184 Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par) 
185 {
186 // Compute the charge on first cathod only.
187 return DiscrChargeCombiS1(i,par,0);
188 }
189
190 Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath) 
191 {
192 // par[0]    x-position of cluster
193 // par[1]    y-position of cluster
194
195    Float_t q1;
196    fSegmentation2[cath]-> SetPad(fDetElemId, fix[i][cath], fiy[i][cath]);
197    //  First Cluster
198    fSegmentation2[cath]-> SetHit(fDetElemId, par[0],par[1],fZ);
199    q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
200        
201    Float_t value = fQtot[cath]*q1;
202    return value;
203 }
204
205
206 Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par) 
207 {
208 // par[0]    x-position of first  cluster
209 // par[1]    y-position of first  cluster
210 // par[2]    x-position of second cluster
211 // par[3]    y-position of second cluster
212 // par[4]    charge fraction of first  cluster
213 // 1-par[4]  charge fraction of second cluster
214
215   Float_t q1, q2;
216   
217   fSegmentation2[0]->SetPad(fDetElemId, fix[i][0], fiy[i][0]);
218   //  First Cluster
219   fSegmentation2[0]->SetHit(fDetElemId, par[0],par[1],fZ);
220   q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[0]);
221
222   //  Second Cluster
223   fSegmentation2[0]->SetHit(fDetElemId,par[2],par[3],fZ);
224   q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[0]);
225   
226   Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
227   return value;
228 }
229
230 Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath) 
231 {
232 // par[0]    x-position of first  cluster
233 // par[1]    y-position of first  cluster
234 // par[2]    x-position of second cluster
235 // par[3]    y-position of second cluster
236 // par[4]    charge fraction of first  cluster - first cathode
237 // 1-par[4]  charge fraction of second cluster 
238 // par[5]    charge fraction of first  cluster - second cathode
239
240   Float_t q1, q2;
241
242   fSegmentation2[cath]->SetPad(fDetElemId,fix[i][cath], fiy[i][cath]);
243   //  First Cluster
244   fSegmentation2[cath]->SetHit(fDetElemId,par[0],par[1],fZ);
245   q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
246   
247   //  Second Cluster
248   fSegmentation2[cath]->SetHit(fDetElemId,par[2],par[3],fZ);
249   q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
250   
251   Float_t value;
252   if (cath==0) {
253     value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
254   } else {
255     value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
256   }
257   return value;
258 }
259
260 AliMUONClusterInput& AliMUONClusterInput
261 ::operator = (const AliMUONClusterInput& rhs)
262 {
263 // Protected assignement operator
264
265   if (this == &rhs) return *this;
266
267   AliFatal("Not implemented.");
268     
269   return *this;  
270 }