]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterInput.cxx
Cleaning the task in the destructor if it was posted
[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 AliMUONClusterInput::AliMUONClusterInput(const AliMUONClusterInput& clusterInput):TObject(clusterInput)
63 {
64   
65 }
66
67 void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig1, TClonesArray* dig2)
68 {
69 // Set pointer to digits with corresponding segmentations and responses (two cathode planes)
70     fChamber=chamber;
71     fDigits[0]=dig1;
72     fDigits[1]=dig2; 
73     fNDigits[0]=dig1->GetEntriesFast();
74     fNDigits[1]=dig2->GetEntriesFast();
75     
76     AliMUON *pMUON;
77     AliMUONChamber* iChamber;
78
79     pMUON = (AliMUON*) gAlice->GetModule("MUON");
80     iChamber =  &(pMUON->Chamber(chamber));
81
82     fSegmentation[0]=iChamber->SegmentationModel(1);
83     fSegmentation[1]=iChamber->SegmentationModel(2);
84     fResponse=iChamber->ResponseModel();
85     fNseg = 2;
86 }
87
88 void AliMUONClusterInput::SetDigits(Int_t chamber, TClonesArray* dig)
89 {
90 // Set pointer to digits with corresponding segmentations and responses (one cathode plane)
91     fDigits[0]=dig;
92     AliMUON *pMUON;
93     AliMUONChamber* iChamber;
94
95     pMUON = (AliMUON*) gAlice->GetModule("MUON");
96     iChamber =  &(pMUON->Chamber(chamber));
97
98     fSegmentation[0]=iChamber->SegmentationModel(1);
99     fResponse=iChamber->ResponseModel();
100     fNseg=1;
101 }
102
103 void  AliMUONClusterInput::SetCluster(AliMUONRawCluster* cluster)
104 {
105 // Set the current cluster
106     printf("\n %p \n", cluster);
107     fCluster=cluster;
108     Float_t qtot;
109     Int_t   i, cath, ix, iy;
110     AliMUONDigit* digit;
111     fNmul[0]=cluster->fMultiplicity[0];
112     fNmul[1]=cluster->fMultiplicity[1];
113     printf("\n %p %p ", fDigits[0], fDigits[1]);
114     
115     for (cath=0; cath<2; cath++) {
116         qtot=0;
117         for (i=0; i<fNmul[cath]; i++) {
118             // pointer to digit
119             digit =(AliMUONDigit*)
120                 (fDigits[cath]->UncheckedAt(cluster->fIndexMap[i][cath]));
121             // pad coordinates
122             ix = digit->PadX();
123             iy = digit->PadY();
124             // pad charge
125             fCharge[i][cath] = digit->Signal();
126             // pad centre coordinates
127 //          fSegmentation[cath]->GetPadCxy(ix, iy, x, y);
128             // globals kUsed in fitting functions
129             fix[i][cath]=ix;
130             fiy[i][cath]=iy;
131             // total charge per cluster
132             qtot+=fCharge[i][cath];
133             // Current z
134             Float_t xc, yc;
135             fSegmentation[cath]->GetPadC(ix,iy,xc,yc,fZ);
136         } // loop over cluster digits
137         fQtot[cath]=qtot;
138         fChargeTot[cath]=Int_t(qtot);  
139     }  // loop over cathodes
140 }
141
142
143
144 Float_t AliMUONClusterInput::DiscrChargeS1(Int_t i,Double_t *par) 
145 {
146 // Compute the charge on first cathod only.
147 return DiscrChargeCombiS1(i,par,0);
148 }
149
150 Float_t AliMUONClusterInput::DiscrChargeCombiS1(Int_t i,Double_t *par, Int_t cath) 
151 {
152 // par[0]    x-position of cluster
153 // par[1]    y-position of cluster
154
155    fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
156 //  First Cluster
157    fSegmentation[cath]->SetHit(par[0],par[1],fZ);
158    Float_t q1=fResponse->IntXY(fSegmentation[cath]);
159     
160    Float_t value = fQtot[cath]*q1;
161    return value;
162 }
163
164
165 Float_t AliMUONClusterInput::DiscrChargeS2(Int_t i,Double_t *par) 
166 {
167 // par[0]    x-position of first  cluster
168 // par[1]    y-position of first  cluster
169 // par[2]    x-position of second cluster
170 // par[3]    y-position of second cluster
171 // par[4]    charge fraction of first  cluster
172 // 1-par[4]  charge fraction of second cluster
173
174    fSegmentation[0]->SetPad(fix[i][0], fiy[i][0]);
175 //  First Cluster
176    fSegmentation[0]->SetHit(par[0],par[1],fZ);
177    Float_t q1=fResponse->IntXY(fSegmentation[0]);
178     
179 //  Second Cluster
180    fSegmentation[0]->SetHit(par[2],par[3],fZ);
181    Float_t q2=fResponse->IntXY(fSegmentation[0]);
182     
183    Float_t value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
184    return value;
185 }
186
187 Float_t AliMUONClusterInput::DiscrChargeCombiS2(Int_t i,Double_t *par, Int_t cath) 
188 {
189 // par[0]    x-position of first  cluster
190 // par[1]    y-position of first  cluster
191 // par[2]    x-position of second cluster
192 // par[3]    y-position of second cluster
193 // par[4]    charge fraction of first  cluster - first cathode
194 // 1-par[4]  charge fraction of second cluster 
195 // par[5]    charge fraction of first  cluster - second cathode
196
197    fSegmentation[cath]->SetPad(fix[i][cath], fiy[i][cath]);
198 //  First Cluster
199    fSegmentation[cath]->SetHit(par[0],par[1],fZ);
200    Float_t q1=fResponse->IntXY(fSegmentation[cath]);
201     
202 //  Second Cluster
203    fSegmentation[cath]->SetHit(par[2],par[3],fZ);
204    Float_t q2=fResponse->IntXY(fSegmentation[cath]);
205    Float_t value;
206    if (cath==0) {
207        value = fQtot[0]*(par[4]*q1+(1.-par[4])*q2);
208    } else {
209        value = fQtot[1]*(par[5]*q1+(1.-par[5])*q2);
210    }
211    return value;
212 }
213
214 AliMUONClusterInput& AliMUONClusterInput
215 ::operator = (const AliMUONClusterInput& /*rhs*/)
216 {
217 // Dummy assignment operator
218     return *this;
219 }