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"
44 #include "AliPMDdigit.h"
45 #include "AliPMDClusterFinder.h"
46 #include "AliPMDClustering.h"
47 #include "AliPMDcluster.h"
48 #include "AliPMDrecpoint1.h"
51 ClassImp(AliPMDClusterFinder)
53 AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
54 fRunLoader(runLoader),
55 fPMDLoader(runLoader->GetLoader("PMDLoader")),
59 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
68 // ------------------------------------------------------------------------- //
69 AliPMDClusterFinder::~AliPMDClusterFinder()
79 // ------------------------------------------------------------------------- //
81 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
83 // Converts digits to recpoints after running clustering
84 // algorithm on CPV plane and PREshower plane
86 Int_t det = 0,smn = 0;
93 TObjArray *pmdcont = new TObjArray();
94 AliPMDcluster *pmdcl = new AliPMDcluster;
95 AliPMDClustering *pmdclust = new AliPMDClustering();
96 pmdclust->SetDebug(fDebug);
97 pmdclust->SetEdepCut(fEcut);
99 fRunLoader->GetEvent(ievt);
100 //cout << " ***** Beginning::Digits2RecPoints *****" << endl;
101 fTreeD = fPMDLoader->TreeD();
104 cout << " Can not get TreeD" << endl;
106 AliPMDdigit *pmddigit;
107 TBranch *branch = fTreeD->GetBranch("PMDDigit");
108 branch->SetAddress(&fDigits);
111 fTreeR = fPMDLoader->TreeR();
114 fPMDLoader->MakeTree("R");
115 fTreeR = fPMDLoader->TreeR();
118 Int_t bufsize = 16000;
119 fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
121 Int_t nmodules = (Int_t) fTreeD->GetEntries();
123 for (Int_t imodule = 0; imodule < nmodules; imodule++)
126 fTreeD->GetEntry(imodule);
127 Int_t nentries = fDigits->GetLast();
128 for (Int_t ient = 0; ient < nentries+1; ient++)
130 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
132 det = pmddigit->GetDetector();
133 smn = pmddigit->GetSMNumber();
134 xpos = pmddigit->GetRow();
135 ypos = pmddigit->GetColumn();
136 adc = pmddigit->GetADC();
137 //Int_t trno = pmddigit->GetTrackNumber();
139 fCellADC[xpos][ypos] = (Double_t) adc;
144 pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
146 Int_t nentries1 = pmdcont->GetEntries();
147 // cout << " nentries1 = " << nentries1 << endl;
148 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
150 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
151 idet = pmdcl->GetDetector();
152 ismn = pmdcl->GetSMN();
153 clusdata[0] = pmdcl->GetClusX();
154 clusdata[1] = pmdcl->GetClusY();
155 clusdata[2] = pmdcl->GetClusADC();
156 clusdata[3] = pmdcl->GetClusCells();
157 clusdata[4] = pmdcl->GetClusRadius();
159 AddRecPoint(idet,ismn,clusdata);
169 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
170 fPMDLoader->WriteRecPoints("OVERWRITE");
172 // delete the pointers
176 // cout << " ***** End::Digits2RecPoints *****" << endl;
178 // ------------------------------------------------------------------------- //
179 void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
183 // ------------------------------------------------------------------------- //
184 void AliPMDClusterFinder::SetDebug(Int_t idebug)
188 // ------------------------------------------------------------------------- //
189 void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
191 // Add Reconstructed points
193 TClonesArray &lrecpoints = *fRecpoints;
194 AliPMDrecpoint1 *newrecpoint;
195 newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
196 new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
199 // ------------------------------------------------------------------------- //
200 void AliPMDClusterFinder::ResetCellADC()
202 // Reset the individual cell ADC value to zero
204 for(Int_t irow = 0; irow < fgkRow; irow++)
206 for(Int_t icol = 0; icol < fgkCol; icol++)
208 fCellADC[irow][icol] = 0.;
212 // ------------------------------------------------------------------------- //
214 void AliPMDClusterFinder::ResetRecpoint()
216 // Clear the list of reconstructed points
218 if (fRecpoints) fRecpoints->Clear();
220 // ------------------------------------------------------------------------- //
221 void AliPMDClusterFinder::Load()
223 // Unload all the *.root files
225 fPMDLoader->LoadDigits("READ");
226 fPMDLoader->LoadRecPoints("recreate");
228 // ------------------------------------------------------------------------- //
229 void AliPMDClusterFinder::UnLoad(Option_t *option)
231 // Unload all the *.root files
233 const char *cR = strstr(option,"R");
235 fRunLoader->UnloadgAlice();
239 fPMDLoader->UnloadDigits();
240 fPMDLoader->UnloadRecPoints();
243 // ------------------------------------------------------------------------- //