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), |
58 | fDigits(0), |
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 |
1758e4fe |
72 | if (fRecpoints) |
73 | { |
74 | fRecpoints->Delete(); |
75 | delete fRecpoints; |
76 | fRecpoints=0; |
77 | } |
01709453 |
78 | } |
1758e4fe |
79 | // ------------------------------------------------------------------------- // |
b208c6a3 |
80 | |
01709453 |
81 | void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt) |
82 | { |
b208c6a3 |
83 | // Converts digits to recpoints after running clustering |
84 | // algorithm on CPV plane and PREshower plane |
85 | // |
ed228cbc |
86 | Int_t det = 0,smn = 0; |
01709453 |
87 | Int_t xpos,ypos; |
88 | Float_t adc; |
1758e4fe |
89 | Int_t ismn; |
01709453 |
90 | Int_t idet; |
1758e4fe |
91 | Float_t clusdata[5]; |
ed228cbc |
92 | |
93 | TObjArray *pmdcont = new TObjArray(); |
94 | AliPMDcluster *pmdcl = new AliPMDcluster; |
95 | AliPMDClustering *pmdclust = new AliPMDClustering(); |
96 | pmdclust->SetDebug(fDebug); |
97 | pmdclust->SetEdepCut(fEcut); |
01709453 |
98 | |
dfaeee5f |
99 | fPMDLoader->LoadDigits("READ"); |
100 | fPMDLoader->LoadRecPoints("recreate"); |
01709453 |
101 | fRunLoader->GetEvent(ievt); |
102 | //cout << " ***** Beginning::Digits2RecPoints *****" << endl; |
b208c6a3 |
103 | fTreeD = fPMDLoader->TreeD(); |
104 | if (fTreeD == 0x0) |
01709453 |
105 | { |
106 | cout << " Can not get TreeD" << endl; |
107 | } |
108 | AliPMDdigit *pmddigit; |
b208c6a3 |
109 | TBranch *branch = fTreeD->GetBranch("PMDDigit"); |
01709453 |
110 | branch->SetAddress(&fDigits); |
111 | |
112 | ResetRecpoint(); |
b208c6a3 |
113 | fTreeR = fPMDLoader->TreeR(); |
114 | if (fTreeR == 0x0) |
01709453 |
115 | { |
b208c6a3 |
116 | fPMDLoader->MakeTree("R"); |
117 | fTreeR = fPMDLoader->TreeR(); |
01709453 |
118 | } |
119 | |
120 | Int_t bufsize = 16000; |
b208c6a3 |
121 | fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); |
01709453 |
122 | |
b208c6a3 |
123 | Int_t nmodules = (Int_t) fTreeD->GetEntries(); |
01709453 |
124 | |
125 | for (Int_t imodule = 0; imodule < nmodules; imodule++) |
126 | { |
ed228cbc |
127 | ResetCellADC(); |
b208c6a3 |
128 | fTreeD->GetEntry(imodule); |
01709453 |
129 | Int_t nentries = fDigits->GetLast(); |
130 | for (Int_t ient = 0; ient < nentries+1; ient++) |
131 | { |
132 | pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient); |
133 | |
134 | det = pmddigit->GetDetector(); |
135 | smn = pmddigit->GetSMNumber(); |
5e6a9312 |
136 | xpos = pmddigit->GetRow(); |
137 | ypos = pmddigit->GetColumn(); |
01709453 |
138 | adc = pmddigit->GetADC(); |
ed228cbc |
139 | //Int_t trno = pmddigit->GetTrackNumber(); |
01709453 |
140 | |
ed228cbc |
141 | fCellADC[xpos][ypos] = (Double_t) adc; |
01709453 |
142 | } |
01709453 |
143 | |
ed228cbc |
144 | idet = det; |
1758e4fe |
145 | ismn = smn; |
146 | pmdclust->DoClust(idet,ismn,fCellADC,pmdcont); |
ed228cbc |
147 | |
148 | Int_t nentries1 = pmdcont->GetEntries(); |
dfaeee5f |
149 | // cout << " nentries1 = " << nentries1 << endl; |
ed228cbc |
150 | for (Int_t ient1 = 0; ient1 < nentries1; ient1++) |
01709453 |
151 | { |
ed228cbc |
152 | pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1); |
1758e4fe |
153 | idet = pmdcl->GetDetector(); |
154 | ismn = pmdcl->GetSMN(); |
155 | clusdata[0] = pmdcl->GetClusX(); |
156 | clusdata[1] = pmdcl->GetClusY(); |
157 | clusdata[2] = pmdcl->GetClusADC(); |
158 | clusdata[3] = pmdcl->GetClusCells(); |
159 | clusdata[4] = pmdcl->GetClusRadius(); |
01709453 |
160 | |
1758e4fe |
161 | AddRecPoint(idet,ismn,clusdata); |
ed228cbc |
162 | } |
163 | pmdcont->Clear(); |
164 | |
b208c6a3 |
165 | fTreeR->Fill(); |
ed228cbc |
166 | ResetRecpoint(); |
167 | |
168 | } // modules |
169 | |
01709453 |
170 | ResetCellADC(); |
e1287360 |
171 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); |
b208c6a3 |
172 | fPMDLoader->WriteRecPoints("OVERWRITE"); |
dfaeee5f |
173 | fPMDLoader->UnloadRecPoints(); |
174 | fPMDLoader->UnloadDigits(); |
01709453 |
175 | |
176 | // delete the pointers |
177 | delete pmdclust; |
178 | delete pmdcont; |
179 | |
180 | // cout << " ***** End::Digits2RecPoints *****" << endl; |
181 | } |
1758e4fe |
182 | // ------------------------------------------------------------------------- // |
ed228cbc |
183 | void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut) |
184 | { |
185 | fEcut = ecut; |
186 | } |
1758e4fe |
187 | // ------------------------------------------------------------------------- // |
ed228cbc |
188 | void AliPMDClusterFinder::SetDebug(Int_t idebug) |
189 | { |
190 | fDebug = idebug; |
191 | } |
1758e4fe |
192 | // ------------------------------------------------------------------------- // |
193 | void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata) |
01709453 |
194 | { |
b208c6a3 |
195 | // Add Reconstructed points |
196 | // |
01709453 |
197 | TClonesArray &lrecpoints = *fRecpoints; |
ed228cbc |
198 | AliPMDrecpoint1 *newrecpoint; |
1758e4fe |
199 | newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata); |
ed228cbc |
200 | new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint); |
01709453 |
201 | delete newrecpoint; |
202 | } |
1758e4fe |
203 | // ------------------------------------------------------------------------- // |
01709453 |
204 | void AliPMDClusterFinder::ResetCellADC() |
205 | { |
b208c6a3 |
206 | // Reset the individual cell ADC value to zero |
207 | // |
5e6a9312 |
208 | for(Int_t irow = 0; irow < fgkRow; irow++) |
01709453 |
209 | { |
5e6a9312 |
210 | for(Int_t icol = 0; icol < fgkCol; icol++) |
01709453 |
211 | { |
ed228cbc |
212 | fCellADC[irow][icol] = 0.; |
01709453 |
213 | } |
214 | } |
215 | } |
1758e4fe |
216 | // ------------------------------------------------------------------------- // |
01709453 |
217 | |
218 | void AliPMDClusterFinder::ResetRecpoint() |
219 | { |
b208c6a3 |
220 | // Clear the list of reconstructed points |
01709453 |
221 | fNpoint = 0; |
222 | if (fRecpoints) fRecpoints->Clear(); |
223 | } |
1758e4fe |
224 | // ------------------------------------------------------------------------- // |
01709453 |
225 | void AliPMDClusterFinder::UnLoad(Option_t *option) |
226 | { |
b208c6a3 |
227 | // Unload all the *.root files |
228 | // |
01709453 |
229 | const char *cR = strstr(option,"R"); |
230 | |
231 | fRunLoader->UnloadgAlice(); |
01709453 |
232 | |
233 | if (cR) |
234 | { |
b208c6a3 |
235 | fPMDLoader->UnloadDigits(); |
e1287360 |
236 | fPMDLoader->UnloadRecPoints(); |
01709453 |
237 | } |
238 | } |
1758e4fe |
239 | // ------------------------------------------------------------------------- // |