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>
27 #include <TObjArray.h>
28 #include <TClonesArray.h>
31 #include "AliRunLoader.h"
32 #include "AliLoader.h"
33 #include "AliRawReader.h"
35 #include "AliPMDdigit.h"
36 #include "AliPMDClusterFinder.h"
37 #include "AliPMDClustering.h"
38 #include "AliPMDcluster.h"
39 #include "AliPMDrecpoint1.h"
40 #include "AliPMDRawStream.h"
44 ClassImp(AliPMDClusterFinder)
46 AliPMDClusterFinder::AliPMDClusterFinder():
51 fDigits(new TClonesArray("AliPMDdigit", 1000)),
52 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
60 // ------------------------------------------------------------------------- //
61 AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
62 fRunLoader(runLoader),
63 fPMDLoader(runLoader->GetLoader("PMDLoader")),
66 fDigits(new TClonesArray("AliPMDdigit", 1000)),
67 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
75 // ------------------------------------------------------------------------- //
76 AliPMDClusterFinder::~AliPMDClusterFinder()
92 // ------------------------------------------------------------------------- //
94 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
96 // Converts digits to recpoints after running clustering
97 // algorithm on CPV plane and PREshower plane
99 Int_t det = 0,smn = 0;
106 TObjArray *pmdcont = new TObjArray();
107 AliPMDClustering *pmdclust = new AliPMDClustering();
109 pmdclust->SetEdepCut(fEcut);
111 fRunLoader->GetEvent(ievt);
114 fTreeD = fPMDLoader->TreeD();
117 AliFatal("AliPMDClusterFinder: Can not get TreeD");
120 AliPMDdigit *pmddigit;
121 TBranch *branch = fTreeD->GetBranch("PMDDigit");
122 branch->SetAddress(&fDigits);
126 fTreeR = fPMDLoader->TreeR();
129 fPMDLoader->MakeTree("R");
130 fTreeR = fPMDLoader->TreeR();
133 Int_t bufsize = 16000;
134 fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
136 Int_t nmodules = (Int_t) fTreeD->GetEntries();
138 for (Int_t imodule = 0; imodule < nmodules; imodule++)
141 fTreeD->GetEntry(imodule);
142 Int_t nentries = fDigits->GetLast();
143 for (Int_t ient = 0; ient < nentries+1; ient++)
145 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
147 det = pmddigit->GetDetector();
148 smn = pmddigit->GetSMNumber();
149 xpos = pmddigit->GetRow();
150 ypos = pmddigit->GetColumn();
151 adc = pmddigit->GetADC();
152 //Int_t trno = pmddigit->GetTrackNumber();
153 fCellADC[xpos][ypos] = (Double_t) adc;
158 pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
160 Int_t nentries1 = pmdcont->GetEntries();
162 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
164 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
166 AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
167 idet = pmdcl->GetDetector();
168 ismn = pmdcl->GetSMN();
169 clusdata[0] = pmdcl->GetClusX();
170 clusdata[1] = pmdcl->GetClusY();
171 clusdata[2] = pmdcl->GetClusADC();
172 clusdata[3] = pmdcl->GetClusCells();
173 clusdata[4] = pmdcl->GetClusRadius();
175 AddRecPoint(idet,ismn,clusdata);
185 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
186 fPMDLoader->WriteRecPoints("OVERWRITE");
188 // delete the pointers
193 // ------------------------------------------------------------------------- //
195 void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
198 // Converts RAW data to recpoints after running clustering
199 // algorithm on CPV and PREshower plane
204 TObjArray *pmdcont = new TObjArray();
205 AliPMDClustering *pmdclust = new AliPMDClustering();
207 pmdclust->SetEdepCut(fEcut);
211 Int_t bufsize = 16000;
212 clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
214 const Int_t kDDL = 6;
215 const Int_t kRow = 48;
216 const Int_t kCol = 96;
221 for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
227 else if (indexDDL >= 4)
232 precpvADC = new int **[iSMN];
233 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
234 for (Int_t i=0; i<iSMN;i++)
236 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
238 for (Int_t i = 0; i < iSMN; i++)
240 for (Int_t j = 0; j < kRow; j++)
242 for (Int_t k = 0; k < kCol; k++)
244 precpvADC[i][j][k] = 0;
250 AliPMDRawStream pmdinput(rawReader);
251 rawReader->Select(12, indexDDL, indexDDL);
252 while(pmdinput.Next())
254 Int_t det = pmdinput.GetDetector();
255 Int_t smn = pmdinput.GetSMN();
256 //Int_t mcm = pmdinput.GetMCM();
257 //Int_t chno = pmdinput.GetChannel();
258 Int_t row = pmdinput.GetRow();
259 Int_t col = pmdinput.GetColumn();
260 Int_t sig = pmdinput.GetSignal();
267 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
269 indexsmn = smn - indexDDL * 6;
271 else if (indexDDL == 4)
274 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
280 else if (smn >= 12 && smn < 18)
285 else if (indexDDL == 5)
288 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
290 if (smn >= 6 && smn < 12)
294 else if (smn >= 18 && smn < 24)
299 precpvADC[indexsmn][row][col] = sig;
303 for (Int_t indexsmn = 0; indexsmn < iSMN; indexsmn++)
306 for (Int_t irow = 0; irow < kRow; irow++)
308 for (Int_t icol = 0; icol < kCol; icol++)
310 fCellADC[irow][icol] =
311 (Double_t) precpvADC[indexsmn][irow][icol];
316 ismn = indexsmn + indexDDL * 6;
319 else if (indexDDL == 4)
325 else if (indexsmn >= 6 && indexsmn < 12)
331 else if (indexDDL == 5)
337 else if (indexsmn >= 6 && indexsmn < 12)
339 ismn = indexsmn + 12;
345 pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
346 Int_t nentries1 = pmdcont->GetEntries();
348 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
350 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
352 AliPMDcluster *pmdcl =
353 (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
354 idet = pmdcl->GetDetector();
355 ismn = pmdcl->GetSMN();
356 clusdata[0] = pmdcl->GetClusX();
357 clusdata[1] = pmdcl->GetClusY();
358 clusdata[2] = pmdcl->GetClusADC();
359 clusdata[3] = pmdcl->GetClusCells();
360 clusdata[4] = pmdcl->GetClusRadius();
362 AddRecPoint(idet,ismn,clusdata);
367 clustersTree->Fill();
373 for (Int_t i=0; i<iSMN; i++)
375 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
377 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
383 // delete the pointers
388 // ------------------------------------------------------------------------- //
390 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
392 // Converts RAW data to recpoints after running clustering
393 // algorithm on CPV and PREshower plane
398 TObjArray *pmdcont = new TObjArray();
399 AliPMDClustering *pmdclust = new AliPMDClustering();
401 pmdclust->SetEdepCut(fEcut);
403 fRunLoader->GetEvent(ievt);
407 fTreeR = fPMDLoader->TreeR();
410 fPMDLoader->MakeTree("R");
411 fTreeR = fPMDLoader->TreeR();
413 Int_t bufsize = 16000;
414 fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
416 const Int_t kDDL = 6;
417 const Int_t kRow = 48;
418 const Int_t kCol = 96;
423 for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
429 else if (indexDDL >= 4)
434 precpvADC = new int **[iSMN];
435 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
436 for (Int_t i=0; i<iSMN;i++)
438 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
440 for (Int_t i = 0; i < iSMN; i++)
442 for (Int_t j = 0; j < kRow; j++)
444 for (Int_t k = 0; k < kCol; k++)
446 precpvADC[i][j][k] = 0;
452 AliPMDRawStream pmdinput(rawReader);
453 rawReader->Select(12, indexDDL, indexDDL);
454 while(pmdinput.Next())
456 Int_t det = pmdinput.GetDetector();
457 Int_t smn = pmdinput.GetSMN();
458 //Int_t mcm = pmdinput.GetMCM();
459 //Int_t chno = pmdinput.GetChannel();
460 Int_t row = pmdinput.GetRow();
461 Int_t col = pmdinput.GetColumn();
462 Int_t sig = pmdinput.GetSignal();
469 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
471 indexsmn = smn - indexDDL * 6;
473 else if (indexDDL == 4)
476 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
482 else if (smn >= 12 && smn < 18)
487 else if (indexDDL == 5)
490 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
492 if (smn >= 6 && smn < 12)
496 else if (smn >= 18 && smn < 24)
501 precpvADC[indexsmn][row][col] = sig;
505 for (Int_t indexsmn = 0; indexsmn < iSMN; indexsmn++)
508 for (Int_t irow = 0; irow < kRow; irow++)
510 for (Int_t icol = 0; icol < kCol; icol++)
512 fCellADC[irow][icol] =
513 (Double_t) precpvADC[indexsmn][irow][icol];
518 ismn = indexsmn + indexDDL * 6;
521 else if (indexDDL == 4)
527 else if (indexsmn >= 6 && indexsmn < 12)
533 else if (indexDDL == 5)
539 else if (indexsmn >= 6 && indexsmn < 12)
541 ismn = indexsmn + 12;
547 pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
548 Int_t nentries1 = pmdcont->GetEntries();
550 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
552 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
554 AliPMDcluster *pmdcl =
555 (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
556 idet = pmdcl->GetDetector();
557 ismn = pmdcl->GetSMN();
558 clusdata[0] = pmdcl->GetClusX();
559 clusdata[1] = pmdcl->GetClusY();
560 clusdata[2] = pmdcl->GetClusADC();
561 clusdata[3] = pmdcl->GetClusCells();
562 clusdata[4] = pmdcl->GetClusRadius();
564 AddRecPoint(idet,ismn,clusdata);
574 for (Int_t i=0; i<iSMN; i++)
576 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
578 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
584 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
585 fPMDLoader->WriteRecPoints("OVERWRITE");
587 // delete the pointers
592 // ------------------------------------------------------------------------- //
593 void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
597 // ------------------------------------------------------------------------- //
598 void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
600 // Add Reconstructed points
602 TClonesArray &lrecpoints = *fRecpoints;
603 AliPMDrecpoint1 *newrecpoint;
604 newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
605 new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
608 // ------------------------------------------------------------------------- //
609 void AliPMDClusterFinder::ResetCellADC()
611 // Reset the individual cell ADC value to zero
613 for(Int_t irow = 0; irow < fgkRow; irow++)
615 for(Int_t icol = 0; icol < fgkCol; icol++)
617 fCellADC[irow][icol] = 0.;
621 // ------------------------------------------------------------------------- //
623 void AliPMDClusterFinder::ResetRecpoint()
625 // Clear the list of reconstructed points
627 if (fRecpoints) fRecpoints->Clear();
629 // ------------------------------------------------------------------------- //
630 void AliPMDClusterFinder::Load()
632 // Load all the *.root files
634 fPMDLoader->LoadDigits("READ");
635 fPMDLoader->LoadRecPoints("recreate");
637 // ------------------------------------------------------------------------- //
638 void AliPMDClusterFinder::LoadClusters()
640 // Load all the *.root files
642 fPMDLoader->LoadRecPoints("recreate");
644 // ------------------------------------------------------------------------- //
645 void AliPMDClusterFinder::UnLoad()
647 // Unload all the *.root files
649 fPMDLoader->UnloadDigits();
650 fPMDLoader->UnloadRecPoints();
652 // ------------------------------------------------------------------------- //
653 void AliPMDClusterFinder::UnLoadClusters()
655 // Unload all the *.root files
657 fPMDLoader->UnloadRecPoints();
659 // ------------------------------------------------------------------------- //