]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMDClusterFinder.cxx
DDL word unpacking correction (Christian)
[u/mrichter/AliRoot.git] / PMD / AliPMDClusterFinder.cxx
CommitLineData
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"
5f55af10 43#include "AliRawReader.h"
01709453 44
45#include "AliPMDdigit.h"
46#include "AliPMDClusterFinder.h"
47#include "AliPMDClustering.h"
01709453 48#include "AliPMDcluster.h"
96377d57 49#include "AliPMDrecpoint1.h"
5f55af10 50#include "AliPMDRawStream.h"
01709453 51
52ClassImp(AliPMDClusterFinder)
b208c6a3 53
dfaeee5f 54AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
55 fRunLoader(runLoader),
56 fPMDLoader(runLoader->GetLoader("PMDLoader")),
1758e4fe 57 fTreeD(0),
58 fTreeR(0),
ebd83c56 59 fDigits(new TClonesArray("AliPMDdigit", 1000)),
1758e4fe 60 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
61 fNpoint(0),
62 fDebug(0),
63 fEcut(0.)
01709453 64{
b208c6a3 65//
dfaeee5f 66// Constructor
b208c6a3 67//
01709453 68}
1758e4fe 69// ------------------------------------------------------------------------- //
01709453 70AliPMDClusterFinder::~AliPMDClusterFinder()
71{
b208c6a3 72 // Destructor
ebd83c56 73 if (fDigits)
74 {
75 fDigits->Delete();
76 delete fDigits;
77 fDigits=0;
78 }
1758e4fe 79 if (fRecpoints)
80 {
81 fRecpoints->Delete();
82 delete fRecpoints;
83 fRecpoints=0;
84 }
01709453 85}
1758e4fe 86// ------------------------------------------------------------------------- //
b208c6a3 87
01709453 88void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
89{
b208c6a3 90 // Converts digits to recpoints after running clustering
91 // algorithm on CPV plane and PREshower plane
92 //
ed228cbc 93 Int_t det = 0,smn = 0;
01709453 94 Int_t xpos,ypos;
95 Float_t adc;
1758e4fe 96 Int_t ismn;
01709453 97 Int_t idet;
1758e4fe 98 Float_t clusdata[5];
ed228cbc 99
100 TObjArray *pmdcont = new TObjArray();
ed228cbc 101 AliPMDClustering *pmdclust = new AliPMDClustering();
102 pmdclust->SetDebug(fDebug);
103 pmdclust->SetEdepCut(fEcut);
01709453 104
105 fRunLoader->GetEvent(ievt);
106 //cout << " ***** Beginning::Digits2RecPoints *****" << endl;
b208c6a3 107 fTreeD = fPMDLoader->TreeD();
108 if (fTreeD == 0x0)
01709453 109 {
110 cout << " Can not get TreeD" << endl;
111 }
112 AliPMDdigit *pmddigit;
b208c6a3 113 TBranch *branch = fTreeD->GetBranch("PMDDigit");
01709453 114 branch->SetAddress(&fDigits);
115
116 ResetRecpoint();
b208c6a3 117 fTreeR = fPMDLoader->TreeR();
118 if (fTreeR == 0x0)
01709453 119 {
b208c6a3 120 fPMDLoader->MakeTree("R");
121 fTreeR = fPMDLoader->TreeR();
01709453 122 }
123
124 Int_t bufsize = 16000;
b208c6a3 125 fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
01709453 126
b208c6a3 127 Int_t nmodules = (Int_t) fTreeD->GetEntries();
01709453 128
129 for (Int_t imodule = 0; imodule < nmodules; imodule++)
130 {
ed228cbc 131 ResetCellADC();
b208c6a3 132 fTreeD->GetEntry(imodule);
01709453 133 Int_t nentries = fDigits->GetLast();
134 for (Int_t ient = 0; ient < nentries+1; ient++)
135 {
136 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
137
138 det = pmddigit->GetDetector();
139 smn = pmddigit->GetSMNumber();
5e6a9312 140 xpos = pmddigit->GetRow();
141 ypos = pmddigit->GetColumn();
01709453 142 adc = pmddigit->GetADC();
ed228cbc 143 //Int_t trno = pmddigit->GetTrackNumber();
ed228cbc 144 fCellADC[xpos][ypos] = (Double_t) adc;
01709453 145 }
01709453 146
ed228cbc 147 idet = det;
1758e4fe 148 ismn = smn;
8616b098 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// ------------------------------------------------------------------------- //
5f55af10 184
185void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
186{
187 // Converts digits to recpoints after running clustering
188 // algorithm on CPV plane and PREshower plane
189 //
190
191 Float_t clusdata[5];
192
193
194 rawReader->Reset();
195 AliPMDRawStream pmdinput(rawReader);
196
197 TObjArray *pmdcont = new TObjArray();
198 AliPMDClustering *pmdclust = new AliPMDClustering();
199 pmdclust->SetDebug(fDebug);
200 pmdclust->SetEdepCut(fEcut);
201
202 fRunLoader->GetEvent(ievt);
203
204 ResetRecpoint();
205 fTreeR = fPMDLoader->TreeR();
206 if (fTreeR == 0x0)
207 {
208 fPMDLoader->MakeTree("R");
209 fTreeR = fPMDLoader->TreeR();
210 }
211
212 Int_t bufsize = 16000;
213 fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
5f55af10 214 const Int_t kDet = 2;
215 const Int_t kSMN = 24;
216 const Int_t kRow = 48;
217 const Int_t kCol = 96;
218 Int_t preADC[kSMN][kRow][kCol];
219 Int_t cpvADC[kSMN][kRow][kCol];
220
221 for (Int_t i = 0; i < kSMN; i++)
222 {
223 for (Int_t j = 0; j < kRow; j++)
224 {
225 for (Int_t k = 0; k < kCol; k++)
226 {
227 preADC[i][j][k] = 0;
228 cpvADC[i][j][k] = 0;
229 }
230 }
231 }
232 ResetCellADC();
233
234 while(pmdinput.Next())
235 {
236 Int_t det = pmdinput.GetDetector();
237 Int_t smn = pmdinput.GetSMN();
238 //Int_t mcm = pmdinput.GetMCM();
239 //Int_t chno = pmdinput.GetChannel();
240 Int_t row = pmdinput.GetRow();
241 Int_t col = pmdinput.GetColumn();
242 Int_t sig = pmdinput.GetSignal();
243
244 //cout << " det = " << det << " smn = " << smn
245 // << " row = " << row << " col = " << col
246 // << " sig = " << sig << endl;
247
5f55af10 248 if (det == 0)
249 {
e54787da 250 preADC[smn][row][col] = sig;
5f55af10 251 }
252 else if (det == 1)
253 {
e54787da 254 cpvADC[smn][row][col] = sig;
5f55af10 255 }
256
257 } // while loop
258
259 for (Int_t idet = 0; idet < kDet; idet++)
260 {
261 for (Int_t ismn = 0; ismn < kSMN; ismn++)
262 {
263 for (Int_t irow = 0; irow < kRow; irow++)
264 {
265 for (Int_t icol = 0; icol < kCol; icol++)
266 {
267 if (idet == 0)
268 {
269 fCellADC[irow][icol] =
270 (Double_t) preADC[ismn][irow][icol];
271 }
272 else if (idet == 1)
273 {
274 fCellADC[irow][icol] =
275 (Double_t) cpvADC[ismn][irow][icol];
276 }
277 } // row
278 } // col
279 pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
280 Int_t nentries1 = pmdcont->GetEntries();
281 // cout << " nentries1 = " << nentries1 << endl;
282 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
283 {
284 AliPMDcluster *pmdcl =
285 (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
286 idet = pmdcl->GetDetector();
287 ismn = pmdcl->GetSMN();
288 clusdata[0] = pmdcl->GetClusX();
289 clusdata[1] = pmdcl->GetClusY();
290 clusdata[2] = pmdcl->GetClusADC();
291 clusdata[3] = pmdcl->GetClusCells();
292 clusdata[4] = pmdcl->GetClusRadius();
293
294 AddRecPoint(idet,ismn,clusdata);
295 }
296 pmdcont->Clear();
297
298 fTreeR->Fill();
299 ResetRecpoint();
300
301 } // smn
302 } // det (pre, cpv)
303
304 ResetCellADC();
305 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
306 fPMDLoader->WriteRecPoints("OVERWRITE");
307
308 // delete the pointers
309 delete pmdclust;
310 delete pmdcont;
311
312 // cout << " ***** End::Digits2RecPoints :: Raw *****" << endl;
313}
314// ------------------------------------------------------------------------- //
ed228cbc 315void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
316{
317 fEcut = ecut;
318}
1758e4fe 319// ------------------------------------------------------------------------- //
ed228cbc 320void AliPMDClusterFinder::SetDebug(Int_t idebug)
321{
322 fDebug = idebug;
323}
1758e4fe 324// ------------------------------------------------------------------------- //
325void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
01709453 326{
b208c6a3 327 // Add Reconstructed points
328 //
01709453 329 TClonesArray &lrecpoints = *fRecpoints;
ed228cbc 330 AliPMDrecpoint1 *newrecpoint;
1758e4fe 331 newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
ed228cbc 332 new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
01709453 333 delete newrecpoint;
334}
1758e4fe 335// ------------------------------------------------------------------------- //
01709453 336void AliPMDClusterFinder::ResetCellADC()
337{
b208c6a3 338 // Reset the individual cell ADC value to zero
339 //
5e6a9312 340 for(Int_t irow = 0; irow < fgkRow; irow++)
01709453 341 {
5e6a9312 342 for(Int_t icol = 0; icol < fgkCol; icol++)
01709453 343 {
ed228cbc 344 fCellADC[irow][icol] = 0.;
01709453 345 }
346 }
347}
1758e4fe 348// ------------------------------------------------------------------------- //
01709453 349
350void AliPMDClusterFinder::ResetRecpoint()
351{
b208c6a3 352 // Clear the list of reconstructed points
01709453 353 fNpoint = 0;
354 if (fRecpoints) fRecpoints->Clear();
355}
1758e4fe 356// ------------------------------------------------------------------------- //
55601d47 357void AliPMDClusterFinder::Load()
358{
ebd83c56 359 // Load all the *.root files
55601d47 360 //
361 fPMDLoader->LoadDigits("READ");
362 fPMDLoader->LoadRecPoints("recreate");
363}
364// ------------------------------------------------------------------------- //
ebd83c56 365void AliPMDClusterFinder::UnLoad()
01709453 366{
b208c6a3 367 // Unload all the *.root files
368 //
ebd83c56 369 fPMDLoader->UnloadDigits();
370 fPMDLoader->UnloadRecPoints();
01709453 371}
1758e4fe 372// ------------------------------------------------------------------------- //