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 **************************************************************************/
16 //-----------------------------------------------------//
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) //
23 //-----------------------------------------------------//
25 #include <Riostream.h>
30 #include <TGeometry.h>
31 #include <TObjArray.h>
32 #include <TClonesArray.h>
35 #include <TParticle.h>
39 #include "AliDetector.h"
40 #include "AliRunLoader.h"
41 #include "AliLoader.h"
42 #include "AliHeader.h"
43 #include "AliRawReader.h"
45 #include "AliPMDdigit.h"
46 #include "AliPMDClusterFinder.h"
47 #include "AliPMDClustering.h"
48 #include "AliPMDcluster.h"
49 #include "AliPMDrecpoint1.h"
50 #include "AliPMDRawStream.h"
52 ClassImp(AliPMDClusterFinder)
54 AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
55 fRunLoader(runLoader),
56 fPMDLoader(runLoader->GetLoader("PMDLoader")),
59 fDigits(new TClonesArray("AliPMDdigit", 1000)),
60 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
69 // ------------------------------------------------------------------------- //
70 AliPMDClusterFinder::~AliPMDClusterFinder()
86 // ------------------------------------------------------------------------- //
88 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
90 // Converts digits to recpoints after running clustering
91 // algorithm on CPV plane and PREshower plane
93 Int_t det = 0,smn = 0;
100 TObjArray *pmdcont = new TObjArray();
101 AliPMDClustering *pmdclust = new AliPMDClustering();
102 pmdclust->SetDebug(fDebug);
103 pmdclust->SetEdepCut(fEcut);
105 fRunLoader->GetEvent(ievt);
106 //cout << " ***** Beginning::Digits2RecPoints *****" << endl;
108 fTreeD = fPMDLoader->TreeD();
111 cout << " Can not get TreeD" << endl;
113 AliPMDdigit *pmddigit;
114 TBranch *branch = fTreeD->GetBranch("PMDDigit");
115 branch->SetAddress(&fDigits);
119 fTreeR = fPMDLoader->TreeR();
122 fPMDLoader->MakeTree("R");
123 fTreeR = fPMDLoader->TreeR();
126 Int_t bufsize = 16000;
127 fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
129 Int_t nmodules = (Int_t) fTreeD->GetEntries();
131 for (Int_t imodule = 0; imodule < nmodules; imodule++)
134 fTreeD->GetEntry(imodule);
135 Int_t nentries = fDigits->GetLast();
136 for (Int_t ient = 0; ient < nentries+1; ient++)
138 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
140 det = pmddigit->GetDetector();
141 smn = pmddigit->GetSMNumber();
142 xpos = pmddigit->GetRow();
143 ypos = pmddigit->GetColumn();
144 adc = pmddigit->GetADC();
145 //Int_t trno = pmddigit->GetTrackNumber();
146 fCellADC[xpos][ypos] = (Double_t) adc;
151 pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
153 Int_t nentries1 = pmdcont->GetEntries();
154 // cout << " nentries1 = " << nentries1 << endl;
155 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
157 AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
158 idet = pmdcl->GetDetector();
159 ismn = pmdcl->GetSMN();
160 clusdata[0] = pmdcl->GetClusX();
161 clusdata[1] = pmdcl->GetClusY();
162 clusdata[2] = pmdcl->GetClusADC();
163 clusdata[3] = pmdcl->GetClusCells();
164 clusdata[4] = pmdcl->GetClusRadius();
166 AddRecPoint(idet,ismn,clusdata);
176 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
177 fPMDLoader->WriteRecPoints("OVERWRITE");
179 // delete the pointers
183 // cout << " ***** End::Digits2RecPoints *****" << endl;
185 // ------------------------------------------------------------------------- //
187 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
189 // Converts RAW data to recpoints after running clustering
190 // algorithm on CPV and PREshower plane
195 TObjArray *pmdcont = new TObjArray();
196 AliPMDClustering *pmdclust = new AliPMDClustering();
197 pmdclust->SetDebug(fDebug);
198 pmdclust->SetEdepCut(fEcut);
200 fRunLoader->GetEvent(ievt);
204 fTreeR = fPMDLoader->TreeR();
207 fPMDLoader->MakeTree("R");
208 fTreeR = fPMDLoader->TreeR();
210 Int_t bufsize = 16000;
211 fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
213 const Int_t kDDL = 6;
214 const Int_t kRow = 48;
215 const Int_t kCol = 96;
220 for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
226 else if (indexDDL >= 4)
231 precpvADC = new int **[iSMN];
232 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
233 for (Int_t i=0; i<iSMN;i++)
235 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
237 for (Int_t i = 0; i < iSMN; i++)
239 for (Int_t j = 0; j < kRow; j++)
241 for (Int_t k = 0; k < kCol; k++)
243 precpvADC[i][j][k] = 0;
249 AliPMDRawStream pmdinput(rawReader);
250 rawReader->Select(12, indexDDL, indexDDL);
251 while(pmdinput.Next())
253 Int_t det = pmdinput.GetDetector();
254 Int_t smn = pmdinput.GetSMN();
255 //Int_t mcm = pmdinput.GetMCM();
256 //Int_t chno = pmdinput.GetChannel();
257 Int_t row = pmdinput.GetRow();
258 Int_t col = pmdinput.GetColumn();
259 Int_t sig = pmdinput.GetSignal();
266 printf(" *** DDL %d and Detector NUMBER %d NOT MATCHING *** ",
268 indexsmn = smn - indexDDL * 6;
270 else if (indexDDL == 4)
273 printf(" *** DDL %d and Detector NUMBER %d NOT MATCHING *** ",
279 else if (smn >= 12 && smn < 18)
284 else if (indexDDL == 5)
287 printf(" *** DDL %d and Detector NUMBER %d NOT MATCHING *** ",
289 if (smn >= 6 && smn < 12)
293 else if (smn >= 18 && smn < 24)
298 precpvADC[indexsmn][row][col] = sig;
302 for (Int_t indexsmn = 0; indexsmn < iSMN; indexsmn++)
305 for (Int_t irow = 0; irow < kRow; irow++)
307 for (Int_t icol = 0; icol < kCol; icol++)
309 fCellADC[irow][icol] =
310 (Double_t) precpvADC[indexsmn][irow][icol];
315 ismn = indexsmn + indexDDL * 6;
318 else if (indexDDL == 4)
324 else if (indexsmn >= 6 && indexsmn < 12)
330 else if (indexDDL == 5)
336 else if (indexsmn >= 6 && indexsmn < 12)
338 ismn = indexsmn + 12;
344 pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
345 Int_t nentries1 = pmdcont->GetEntries();
346 // cout << " nentries1 = " << nentries1 << endl;
347 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
349 AliPMDcluster *pmdcl =
350 (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
351 idet = pmdcl->GetDetector();
352 ismn = pmdcl->GetSMN();
353 clusdata[0] = pmdcl->GetClusX();
354 clusdata[1] = pmdcl->GetClusY();
355 clusdata[2] = pmdcl->GetClusADC();
356 clusdata[3] = pmdcl->GetClusCells();
357 clusdata[4] = pmdcl->GetClusRadius();
359 AddRecPoint(idet,ismn,clusdata);
369 for (Int_t i=0; i<iSMN; i++)
371 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
373 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
379 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
380 fPMDLoader->WriteRecPoints("OVERWRITE");
382 // delete the pointers
386 // cout << " ***** End::Digits2RecPoints :: Raw *****" << endl;
388 // ------------------------------------------------------------------------- //
389 void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
393 // ------------------------------------------------------------------------- //
394 void AliPMDClusterFinder::SetDebug(Int_t idebug)
398 // ------------------------------------------------------------------------- //
399 void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
401 // Add Reconstructed points
403 TClonesArray &lrecpoints = *fRecpoints;
404 AliPMDrecpoint1 *newrecpoint;
405 newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
406 new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
409 // ------------------------------------------------------------------------- //
410 void AliPMDClusterFinder::ResetCellADC()
412 // Reset the individual cell ADC value to zero
414 for(Int_t irow = 0; irow < fgkRow; irow++)
416 for(Int_t icol = 0; icol < fgkCol; icol++)
418 fCellADC[irow][icol] = 0.;
422 // ------------------------------------------------------------------------- //
424 void AliPMDClusterFinder::ResetRecpoint()
426 // Clear the list of reconstructed points
428 if (fRecpoints) fRecpoints->Clear();
430 // ------------------------------------------------------------------------- //
431 void AliPMDClusterFinder::Load()
433 // Load all the *.root files
435 fPMDLoader->LoadDigits("READ");
436 fPMDLoader->LoadRecPoints("recreate");
438 // ------------------------------------------------------------------------- //
439 void AliPMDClusterFinder::LoadClusters()
441 // Load all the *.root files
443 fPMDLoader->LoadRecPoints("recreate");
445 // ------------------------------------------------------------------------- //
446 void AliPMDClusterFinder::UnLoad()
448 // Unload all the *.root files
450 fPMDLoader->UnloadDigits();
451 fPMDLoader->UnloadRecPoints();
453 // ------------------------------------------------------------------------- //
454 void AliPMDClusterFinder::UnLoadClusters()
456 // Unload all the *.root files
458 fPMDLoader->UnloadRecPoints();
460 // ------------------------------------------------------------------------- //