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