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():
59 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
65 // Default Constructor
68 // ------------------------------------------------------------------------- //
69 AliPMDClusterFinder::~AliPMDClusterFinder()
79 // ------------------------------------------------------------------------- //
81 void AliPMDClusterFinder::OpengAliceFile(const Char_t *file, Option_t *option)
83 // Loads galice.root file and corresponding header, kinematics
84 // hits and sdigits or digits depending on the option
86 fRunLoader = AliRunLoader::Open(file,AliConfig::GetDefaultEventFolderName(),
91 Error("Open","Can not open session for file %s.",file);
94 fRunLoader->LoadgAlice();
95 gAlice = fRunLoader->GetAliRun();
99 printf("<AliPMDdigitizer::Open> ");
100 printf("AliRun object found on file.\n");
104 printf("<AliPMDdigitizer::Open> ");
105 printf("Could not find AliRun object.\n");
107 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
108 if (fPMDLoader == 0x0)
110 cerr<<"OpengAlice : Can not find PMD or PMDLoader\n";
113 const char *cDR = strstr(option,"DR");
117 fPMDLoader->LoadDigits("READ");
118 fPMDLoader->LoadRecPoints("recreate");
121 // ------------------------------------------------------------------------- //
123 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
125 // Converts digits to recpoints after running clustering
126 // algorithm on CPV plane and PREshower plane
128 Int_t det = 0,smn = 0;
135 TObjArray *pmdcont = new TObjArray();
136 AliPMDcluster *pmdcl = new AliPMDcluster;
137 AliPMDClustering *pmdclust = new AliPMDClustering();
138 pmdclust->SetDebug(fDebug);
139 pmdclust->SetEdepCut(fEcut);
141 fRunLoader->GetEvent(ievt);
142 //cout << " ***** Beginning::Digits2RecPoints *****" << endl;
143 fTreeD = fPMDLoader->TreeD();
146 cout << " Can not get TreeD" << endl;
148 AliPMDdigit *pmddigit;
149 TBranch *branch = fTreeD->GetBranch("PMDDigit");
150 branch->SetAddress(&fDigits);
153 fTreeR = fPMDLoader->TreeR();
156 fPMDLoader->MakeTree("R");
157 fTreeR = fPMDLoader->TreeR();
160 Int_t bufsize = 16000;
161 fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
163 Int_t nmodules = (Int_t) fTreeD->GetEntries();
165 for (Int_t imodule = 0; imodule < nmodules; imodule++)
168 fTreeD->GetEntry(imodule);
169 Int_t nentries = fDigits->GetLast();
170 for (Int_t ient = 0; ient < nentries+1; ient++)
172 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
174 det = pmddigit->GetDetector();
175 smn = pmddigit->GetSMNumber();
176 xpos = pmddigit->GetRow();
177 ypos = pmddigit->GetColumn();
178 adc = pmddigit->GetADC();
179 //Int_t trno = pmddigit->GetTrackNumber();
181 fCellADC[xpos][ypos] = (Double_t) adc;
186 pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
188 Int_t nentries1 = pmdcont->GetEntries();
189 cout << " nentries1 = " << nentries1 << endl;
190 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
192 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
193 idet = pmdcl->GetDetector();
194 ismn = pmdcl->GetSMN();
195 clusdata[0] = pmdcl->GetClusX();
196 clusdata[1] = pmdcl->GetClusY();
197 clusdata[2] = pmdcl->GetClusADC();
198 clusdata[3] = pmdcl->GetClusCells();
199 clusdata[4] = pmdcl->GetClusRadius();
201 AddRecPoint(idet,ismn,clusdata);
211 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
212 fPMDLoader->WriteRecPoints("OVERWRITE");
214 // delete the pointers
218 // cout << " ***** End::Digits2RecPoints *****" << endl;
220 // ------------------------------------------------------------------------- //
221 void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
225 // ------------------------------------------------------------------------- //
226 void AliPMDClusterFinder::SetDebug(Int_t idebug)
230 // ------------------------------------------------------------------------- //
231 void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
233 // Add Reconstructed points
235 TClonesArray &lrecpoints = *fRecpoints;
236 AliPMDrecpoint1 *newrecpoint;
237 newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
238 new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
241 // ------------------------------------------------------------------------- //
242 void AliPMDClusterFinder::ResetCellADC()
244 // Reset the individual cell ADC value to zero
246 for(Int_t irow = 0; irow < fgkRow; irow++)
248 for(Int_t icol = 0; icol < fgkCol; icol++)
250 fCellADC[irow][icol] = 0.;
254 // ------------------------------------------------------------------------- //
256 void AliPMDClusterFinder::ResetRecpoint()
258 // Clear the list of reconstructed points
260 if (fRecpoints) fRecpoints->Clear();
262 // ------------------------------------------------------------------------- //
263 void AliPMDClusterFinder::UnLoad(Option_t *option)
265 // Unload all the *.root files
267 const char *cR = strstr(option,"R");
269 fRunLoader->UnloadgAlice();
273 fPMDLoader->UnloadDigits();
274 fPMDLoader->UnloadRecPoints();
277 // ------------------------------------------------------------------------- //