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