ed228cbc |
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 | |
01709453 |
16 | //-----------------------------------------------------// |
17 | // // |
18 | // Date : August 05 2003 // |
19 | // This reads the file PMD.digits.root(TreeD), // |
20 | // calls the Clustering algorithm and stores the // |
21 | // clustering output in PMD.RecPoints.root(TreeR) // |
22 | // // |
23 | //-----------------------------------------------------// |
24 | |
25 | #include <Riostream.h> |
b208c6a3 |
26 | #include <TMath.h> |
01709453 |
27 | #include <TBRIK.h> |
28 | #include <TNode.h> |
29 | #include <TTree.h> |
30 | #include <TGeometry.h> |
31 | #include <TObjArray.h> |
32 | #include <TClonesArray.h> |
33 | #include <TFile.h> |
34 | #include <TNtuple.h> |
35 | #include <TParticle.h> |
36 | |
37 | #include "AliRun.h" |
38 | #include "AliPMD.h" |
39 | #include "AliDetector.h" |
40 | #include "AliRunLoader.h" |
41 | #include "AliLoader.h" |
42 | #include "AliHeader.h" |
43 | |
44 | #include "AliPMDdigit.h" |
45 | #include "AliPMDClusterFinder.h" |
46 | #include "AliPMDClustering.h" |
01709453 |
47 | #include "AliPMDcluster.h" |
96377d57 |
48 | #include "AliPMDrecpoint1.h" |
01709453 |
49 | |
50 | |
51 | ClassImp(AliPMDClusterFinder) |
b208c6a3 |
52 | |
dfaeee5f |
53 | AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader): |
54 | fRunLoader(runLoader), |
55 | fPMDLoader(runLoader->GetLoader("PMDLoader")), |
1758e4fe |
56 | fTreeD(0), |
57 | fTreeR(0), |
ebd83c56 |
58 | fDigits(new TClonesArray("AliPMDdigit", 1000)), |
1758e4fe |
59 | fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)), |
60 | fNpoint(0), |
61 | fDebug(0), |
62 | fEcut(0.) |
01709453 |
63 | { |
b208c6a3 |
64 | // |
dfaeee5f |
65 | // Constructor |
b208c6a3 |
66 | // |
01709453 |
67 | } |
1758e4fe |
68 | // ------------------------------------------------------------------------- // |
01709453 |
69 | AliPMDClusterFinder::~AliPMDClusterFinder() |
70 | { |
b208c6a3 |
71 | // Destructor |
ebd83c56 |
72 | if (fDigits) |
73 | { |
74 | fDigits->Delete(); |
75 | delete fDigits; |
76 | fDigits=0; |
77 | } |
1758e4fe |
78 | if (fRecpoints) |
79 | { |
80 | fRecpoints->Delete(); |
81 | delete fRecpoints; |
82 | fRecpoints=0; |
83 | } |
01709453 |
84 | } |
1758e4fe |
85 | // ------------------------------------------------------------------------- // |
b208c6a3 |
86 | |
01709453 |
87 | void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt) |
88 | { |
b208c6a3 |
89 | // Converts digits to recpoints after running clustering |
90 | // algorithm on CPV plane and PREshower plane |
91 | // |
ed228cbc |
92 | Int_t det = 0,smn = 0; |
01709453 |
93 | Int_t xpos,ypos; |
94 | Float_t adc; |
1758e4fe |
95 | Int_t ismn; |
01709453 |
96 | Int_t idet; |
1758e4fe |
97 | Float_t clusdata[5]; |
ed228cbc |
98 | |
99 | TObjArray *pmdcont = new TObjArray(); |
ed228cbc |
100 | AliPMDClustering *pmdclust = new AliPMDClustering(); |
101 | pmdclust->SetDebug(fDebug); |
102 | pmdclust->SetEdepCut(fEcut); |
01709453 |
103 | |
104 | fRunLoader->GetEvent(ievt); |
105 | //cout << " ***** Beginning::Digits2RecPoints *****" << endl; |
b208c6a3 |
106 | fTreeD = fPMDLoader->TreeD(); |
107 | if (fTreeD == 0x0) |
01709453 |
108 | { |
109 | cout << " Can not get TreeD" << endl; |
110 | } |
111 | AliPMDdigit *pmddigit; |
b208c6a3 |
112 | TBranch *branch = fTreeD->GetBranch("PMDDigit"); |
01709453 |
113 | branch->SetAddress(&fDigits); |
114 | |
115 | ResetRecpoint(); |
b208c6a3 |
116 | fTreeR = fPMDLoader->TreeR(); |
117 | if (fTreeR == 0x0) |
01709453 |
118 | { |
b208c6a3 |
119 | fPMDLoader->MakeTree("R"); |
120 | fTreeR = fPMDLoader->TreeR(); |
01709453 |
121 | } |
122 | |
123 | Int_t bufsize = 16000; |
b208c6a3 |
124 | fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); |
01709453 |
125 | |
b208c6a3 |
126 | Int_t nmodules = (Int_t) fTreeD->GetEntries(); |
01709453 |
127 | |
128 | for (Int_t imodule = 0; imodule < nmodules; imodule++) |
129 | { |
ed228cbc |
130 | ResetCellADC(); |
b208c6a3 |
131 | fTreeD->GetEntry(imodule); |
01709453 |
132 | Int_t nentries = fDigits->GetLast(); |
133 | for (Int_t ient = 0; ient < nentries+1; ient++) |
134 | { |
135 | pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient); |
136 | |
137 | det = pmddigit->GetDetector(); |
138 | smn = pmddigit->GetSMNumber(); |
5e6a9312 |
139 | xpos = pmddigit->GetRow(); |
140 | ypos = pmddigit->GetColumn(); |
01709453 |
141 | adc = pmddigit->GetADC(); |
ed228cbc |
142 | //Int_t trno = pmddigit->GetTrackNumber(); |
01709453 |
143 | |
ed228cbc |
144 | fCellADC[xpos][ypos] = (Double_t) adc; |
01709453 |
145 | } |
01709453 |
146 | |
ed228cbc |
147 | idet = det; |
1758e4fe |
148 | ismn = smn; |
149 | pmdclust->DoClust(idet,ismn,fCellADC,pmdcont); |
ed228cbc |
150 | |
151 | Int_t nentries1 = pmdcont->GetEntries(); |
dfaeee5f |
152 | // cout << " nentries1 = " << nentries1 << endl; |
ed228cbc |
153 | for (Int_t ient1 = 0; ient1 < nentries1; ient1++) |
01709453 |
154 | { |
ebd83c56 |
155 | AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1); |
1758e4fe |
156 | idet = pmdcl->GetDetector(); |
157 | ismn = pmdcl->GetSMN(); |
158 | clusdata[0] = pmdcl->GetClusX(); |
159 | clusdata[1] = pmdcl->GetClusY(); |
160 | clusdata[2] = pmdcl->GetClusADC(); |
161 | clusdata[3] = pmdcl->GetClusCells(); |
162 | clusdata[4] = pmdcl->GetClusRadius(); |
01709453 |
163 | |
1758e4fe |
164 | AddRecPoint(idet,ismn,clusdata); |
ed228cbc |
165 | } |
166 | pmdcont->Clear(); |
167 | |
b208c6a3 |
168 | fTreeR->Fill(); |
ed228cbc |
169 | ResetRecpoint(); |
170 | |
171 | } // modules |
172 | |
01709453 |
173 | ResetCellADC(); |
e1287360 |
174 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); |
b208c6a3 |
175 | fPMDLoader->WriteRecPoints("OVERWRITE"); |
01709453 |
176 | |
177 | // delete the pointers |
178 | delete pmdclust; |
179 | delete pmdcont; |
180 | |
181 | // cout << " ***** End::Digits2RecPoints *****" << endl; |
182 | } |
1758e4fe |
183 | // ------------------------------------------------------------------------- // |
ed228cbc |
184 | void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut) |
185 | { |
186 | fEcut = ecut; |
187 | } |
1758e4fe |
188 | // ------------------------------------------------------------------------- // |
ed228cbc |
189 | void AliPMDClusterFinder::SetDebug(Int_t idebug) |
190 | { |
191 | fDebug = idebug; |
192 | } |
1758e4fe |
193 | // ------------------------------------------------------------------------- // |
194 | void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata) |
01709453 |
195 | { |
b208c6a3 |
196 | // Add Reconstructed points |
197 | // |
01709453 |
198 | TClonesArray &lrecpoints = *fRecpoints; |
ed228cbc |
199 | AliPMDrecpoint1 *newrecpoint; |
1758e4fe |
200 | newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata); |
ed228cbc |
201 | new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint); |
01709453 |
202 | delete newrecpoint; |
203 | } |
1758e4fe |
204 | // ------------------------------------------------------------------------- // |
01709453 |
205 | void AliPMDClusterFinder::ResetCellADC() |
206 | { |
b208c6a3 |
207 | // Reset the individual cell ADC value to zero |
208 | // |
5e6a9312 |
209 | for(Int_t irow = 0; irow < fgkRow; irow++) |
01709453 |
210 | { |
5e6a9312 |
211 | for(Int_t icol = 0; icol < fgkCol; icol++) |
01709453 |
212 | { |
ed228cbc |
213 | fCellADC[irow][icol] = 0.; |
01709453 |
214 | } |
215 | } |
216 | } |
1758e4fe |
217 | // ------------------------------------------------------------------------- // |
01709453 |
218 | |
219 | void AliPMDClusterFinder::ResetRecpoint() |
220 | { |
b208c6a3 |
221 | // Clear the list of reconstructed points |
01709453 |
222 | fNpoint = 0; |
223 | if (fRecpoints) fRecpoints->Clear(); |
224 | } |
1758e4fe |
225 | // ------------------------------------------------------------------------- // |
55601d47 |
226 | void AliPMDClusterFinder::Load() |
227 | { |
ebd83c56 |
228 | // Load all the *.root files |
55601d47 |
229 | // |
230 | fPMDLoader->LoadDigits("READ"); |
231 | fPMDLoader->LoadRecPoints("recreate"); |
232 | } |
233 | // ------------------------------------------------------------------------- // |
ebd83c56 |
234 | void AliPMDClusterFinder::UnLoad() |
01709453 |
235 | { |
b208c6a3 |
236 | // Unload all the *.root files |
237 | // |
ebd83c56 |
238 | fPMDLoader->UnloadDigits(); |
239 | fPMDLoader->UnloadRecPoints(); |
01709453 |
240 | } |
1758e4fe |
241 | // ------------------------------------------------------------------------- // |