1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 // ----------------------------
19 // Class AliMUONClusterInput
20 // ----------------------------
21 // Global data service for hit reconstruction
22 // Author: to be added
24 #include "AliMUONClusterInput.h"
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"
37 #include <TClonesArray.h>
39 #include <TGeoManager.h>
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;
47 ClassImp(AliMUONClusterInput)
49 AliMUONClusterInput::AliMUONClusterInput()
59 // Default constructor
67 AliMUONClusterInput* AliMUONClusterInput::Instance()
69 // return pointer to the singleton instance
70 if (fgClusterInput == 0) {
71 fgClusterInput = new AliMUONClusterInput();
72 fgMinuit = new TMinuit(8);
74 // Create segmentation with activated Root geometry
75 if ( ! gGeoManager ) {
76 AliFatalClass("Geometry not loaded.");
77 return fgClusterInput;
79 fgTransformer = new AliMUONGeometryTransformer(true);
80 fgTransformer->ReadGeometryData("volpath.dat", gGeoManager);
81 AliMUONSegFactory factory(fgTransformer);
82 fgSegmentation = factory.CreateSegmentation();
85 return fgClusterInput;
88 AliMUONClusterInput::~AliMUONClusterInput()
94 delete fgSegmentation;
99 void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig1, TClonesArray* dig2)
101 // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
106 fNDigits[0] = dig1->GetEntriesFast();
107 fNDigits[1] = dig2->GetEntriesFast();
110 fgMathieson = new AliMUONMathieson();
112 fSegmentation2[0]= fgSegmentation->GetModuleSegmentationByDEId(fDetElemId, 0);
113 fSegmentation2[1]= fgSegmentation->GetModuleSegmentationByDEId(fDetElemId, 1);
116 if (chamber < AliMUONConstants::NTrackingCh()) {
118 fgMathieson->SetPitch(AliMUONConstants::Pitch());
119 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3());
120 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3());
121 fChargeCorrel = AliMUONConstants::ChargeCorrel();
123 fgMathieson->SetPitch(AliMUONConstants::PitchSt1());
124 fgMathieson->SetSqrtKx3AndDeriveKx2Kx4(AliMUONConstants::SqrtKx3St1());
125 fgMathieson->SetSqrtKy3AndDeriveKy2Ky4(AliMUONConstants::SqrtKy3St1());
126 fChargeCorrel = AliMUONConstants::ChargeCorrelSt1();
131 void AliMUONClusterInput::SetDigits(Int_t chamber, Int_t idDE, TClonesArray* dig)
133 // Set pointer to digits with corresponding segmentations and responses (one cathode plane)
139 fSegmentation2[0]= fgSegmentation->GetModuleSegmentationByDEId(fDetElemId, 0);
143 void AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
145 // Set the current cluster
146 //PH printf("\n %p \n", cluster);
149 Int_t i, cath, ix, iy;
151 fNmul[0]=cluster->GetMultiplicity(0);
152 fNmul[1]=cluster->GetMultiplicity(1);
153 //PH printf("\n %p %p ", fDigits[0], fDigits[1]);
155 for (cath=0; cath<2; cath++) {
157 for (i=0; i<fNmul[cath]; i++) {
159 digit =(AliMUONDigit*)
160 (fDigits[cath]->UncheckedAt(cluster->GetIndex(i,cath)));
165 fCharge[i][cath] = digit->Signal();
166 // pad centre coordinates
167 // fSegmentation[cath]->GetPadCxy(ix, iy, x, y);
168 // globals kUsed in fitting functions
171 // total charge per cluster
172 qtot+=fCharge[i][cath];
175 fSegmentation2[cath]->GetPadC(fDetElemId,ix,iy,xc,yc,fZ);
176 } // loop over cluster digits
178 fChargeTot[cath]=Int_t(qtot);
179 } // loop over cathodes
184 Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par)
186 // Compute the charge on first cathod only.
187 return DiscrChargeCombiS1(i,par,0);
190 Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath)
192 // par[0] x-position of cluster
193 // par[1] y-position of cluster
196 fSegmentation2[cath]-> SetPad(fDetElemId, fix[i][cath], fiy[i][cath]);
198 fSegmentation2[cath]-> SetHit(fDetElemId, par[0],par[1],fZ);
199 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
201 Float_t value = fQtot[cath]*q1;
206 Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par)
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
217 fSegmentation2[0]->SetPad(fDetElemId, fix[i][0], fiy[i][0]);
219 fSegmentation2[0]->SetHit(fDetElemId, par[0],par[1],fZ);
220 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[0]);
223 fSegmentation2[0]->SetHit(fDetElemId,par[2],par[3],fZ);
224 q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[0]);
226 Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
230 Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath)
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
242 fSegmentation2[cath]->SetPad(fDetElemId,fix[i][cath], fiy[i][cath]);
244 fSegmentation2[cath]->SetHit(fDetElemId,par[0],par[1],fZ);
245 q1 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
248 fSegmentation2[cath]->SetHit(fDetElemId,par[2],par[3],fZ);
249 q2 = fgMathieson->IntXY(fDetElemId, fSegmentation2[cath]);
253 value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
255 value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
260 AliMUONClusterInput& AliMUONClusterInput
261 ::operator = (const AliMUONClusterInput& rhs)
263 // Protected assignement operator
265 if (this == &rhs) return *this;
267 AliFatal("Not implemented.");