]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMDClusterFinder.cxx
prtection against detector number not to crash for database access
[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>
01709453 26#include <TTree.h>
01709453 27#include <TObjArray.h>
28#include <TClonesArray.h>
08cf9354 29#include <TSystem.h>
01709453 30
7e9508a7 31#include "AliLog.h"
01709453 32#include "AliRunLoader.h"
33#include "AliLoader.h"
5f55af10 34#include "AliRawReader.h"
01709453 35
36#include "AliPMDdigit.h"
37#include "AliPMDClusterFinder.h"
38#include "AliPMDClustering.h"
5c5cadd5 39#include "AliPMDClusteringV1.h"
01709453 40#include "AliPMDcluster.h"
96377d57 41#include "AliPMDrecpoint1.h"
5c5cadd5 42#include "AliPMDrechit.h"
920e13db 43#include "AliPMDisocell.h"
5f55af10 44#include "AliPMDRawStream.h"
09a06455 45#include "AliPMDCalibData.h"
35535af7 46#include "AliPMDPedestal.h"
df42ab21 47#include "AliPMDddldata.h"
7adbd8e9 48#include "AliPMDHotData.h"
b9e2f33c 49#include "AliPMDRecoParam.h"
50#include "AliPMDReconstructor.h"
09a06455 51
2332574a 52#include "AliDAQ.h"
09a06455 53#include "AliCDBManager.h"
54#include "AliCDBEntry.h"
01709453 55
7e9508a7 56
57
01709453 58ClassImp(AliPMDClusterFinder)
b208c6a3 59
7e9508a7 60AliPMDClusterFinder::AliPMDClusterFinder():
61 fRunLoader(0),
62 fPMDLoader(0),
35535af7 63 fCalibGain(GetCalibGain()),
64 fCalibPed(GetCalibPed()),
7adbd8e9 65 fCalibHot(GetCalibHot()),
b9e2f33c 66 fRecoParam(0x0),
7e9508a7 67 fTreeD(0),
68 fTreeR(0),
69 fDigits(new TClonesArray("AliPMDdigit", 1000)),
70 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
5c5cadd5 71 fRechits(new TClonesArray("AliPMDrechit", 1000)),
7e9508a7 72 fNpoint(0),
5c5cadd5 73 fNhit(0),
a48edddd 74 fDetNo(0),
7e9508a7 75 fEcut(0.)
76{
77//
78// Constructor
79//
80}
81// ------------------------------------------------------------------------- //
dfaeee5f 82AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
83 fRunLoader(runLoader),
84 fPMDLoader(runLoader->GetLoader("PMDLoader")),
35535af7 85 fCalibGain(GetCalibGain()),
86 fCalibPed(GetCalibPed()),
7adbd8e9 87 fCalibHot(GetCalibHot()),
b9e2f33c 88 fRecoParam(0x0),
1758e4fe 89 fTreeD(0),
90 fTreeR(0),
ebd83c56 91 fDigits(new TClonesArray("AliPMDdigit", 1000)),
1758e4fe 92 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
5c5cadd5 93 fRechits(new TClonesArray("AliPMDrechit", 1000)),
1758e4fe 94 fNpoint(0),
5c5cadd5 95 fNhit(0),
a48edddd 96 fDetNo(0),
1758e4fe 97 fEcut(0.)
01709453 98{
b208c6a3 99//
dfaeee5f 100// Constructor
b208c6a3 101//
a48edddd 102}
103// ------------------------------------------------------------------------- //
2332574a 104AliPMDClusterFinder::AliPMDClusterFinder(const AliPMDClusterFinder & finder):
105 TObject(finder),
106 fRunLoader(0),
107 fPMDLoader(0),
35535af7 108 fCalibGain(GetCalibGain()),
109 fCalibPed(GetCalibPed()),
7adbd8e9 110 fCalibHot(GetCalibHot()),
b9e2f33c 111 fRecoParam(0x0),
2332574a 112 fTreeD(0),
113 fTreeR(0),
114 fDigits(NULL),
115 fRecpoints(NULL),
116 fRechits(NULL),
117 fNpoint(0),
118 fNhit(0),
119 fDetNo(0),
120 fEcut(0.)
a48edddd 121{
122 // copy constructor
123 AliError("Copy constructor not allowed");
124}
125// ------------------------------------------------------------------------- //
126AliPMDClusterFinder &AliPMDClusterFinder::operator=(const AliPMDClusterFinder & /*finder*/)
127{
128 // assignment op
129 AliError("Assignment Operator not allowed");
130 return *this;
01709453 131}
1758e4fe 132// ------------------------------------------------------------------------- //
01709453 133AliPMDClusterFinder::~AliPMDClusterFinder()
134{
b208c6a3 135 // Destructor
ebd83c56 136 if (fDigits)
137 {
b9e2f33c 138 fDigits->Clear();
ebd83c56 139 }
1758e4fe 140 if (fRecpoints)
141 {
722ccc67 142 fRecpoints->Clear();
1758e4fe 143 }
5c5cadd5 144 if (fRechits)
145 {
722ccc67 146 fRechits->Clear();
5c5cadd5 147 }
5254fcca 148
01709453 149}
1758e4fe 150// ------------------------------------------------------------------------- //
b208c6a3 151
01709453 152void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
153{
b208c6a3 154 // Converts digits to recpoints after running clustering
155 // algorithm on CPV plane and PREshower plane
156 //
2332574a 157
ed228cbc 158 Int_t det = 0,smn = 0;
01709453 159 Int_t xpos,ypos;
160 Float_t adc;
1758e4fe 161 Int_t ismn;
01709453 162 Int_t idet;
5c5cadd5 163 Float_t clusdata[6];
ed228cbc 164
920e13db 165 AliPMDisocell *pmdiso = 0x0;
166
ed228cbc 167 TObjArray *pmdcont = new TObjArray();
920e13db 168 TObjArray *pmdisocell = new TObjArray();
169
5c5cadd5 170 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
7e9508a7 171
b9e2f33c 172 // fetch the recoparam object from database
173 fRecoParam = AliPMDReconstructor::GetRecoParam();
174
175 if(fRecoParam == 0x0)
176 {
177 AliFatal("No Reco Param found for PMD!!!");
178 }
179
01709453 180
181 fRunLoader->GetEvent(ievt);
7e9508a7 182
01b56f5c 183
b208c6a3 184 fTreeD = fPMDLoader->TreeD();
185 if (fTreeD == 0x0)
01709453 186 {
7e9508a7 187 AliFatal("AliPMDClusterFinder: Can not get TreeD");
188
01709453 189 }
190 AliPMDdigit *pmddigit;
b208c6a3 191 TBranch *branch = fTreeD->GetBranch("PMDDigit");
01709453 192 branch->SetAddress(&fDigits);
193
194 ResetRecpoint();
01b56f5c 195
b208c6a3 196 fTreeR = fPMDLoader->TreeR();
197 if (fTreeR == 0x0)
01709453 198 {
b208c6a3 199 fPMDLoader->MakeTree("R");
200 fTreeR = fPMDLoader->TreeR();
01709453 201 }
202
203 Int_t bufsize = 16000;
5c5cadd5 204 TBranch * branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
205 TBranch * branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize);
01709453 206
b208c6a3 207 Int_t nmodules = (Int_t) fTreeD->GetEntries();
01b56f5c 208
01709453 209 for (Int_t imodule = 0; imodule < nmodules; imodule++)
210 {
ed228cbc 211 ResetCellADC();
b208c6a3 212 fTreeD->GetEntry(imodule);
01709453 213 Int_t nentries = fDigits->GetLast();
214 for (Int_t ient = 0; ient < nentries+1; ient++)
215 {
216 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
217
218 det = pmddigit->GetDetector();
219 smn = pmddigit->GetSMNumber();
5e6a9312 220 xpos = pmddigit->GetRow();
221 ypos = pmddigit->GetColumn();
01709453 222 adc = pmddigit->GetADC();
f0290c15 223 if(xpos < 0 || xpos > 48 || ypos < 0 || ypos > 96)
224 {
225 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
226 xpos, ypos));
227 continue;
228 }
7adbd8e9 229
230 // Hot cell - set the cell adc = 0
231 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,xpos,ypos);
232 if (hotflag == 1) adc = 0;
09a06455 233 // CALIBRATION
35535af7 234 Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
2332574a 235 // printf("adc = %d gain = %f\n",adc,gain);
09a06455 236
237 adc = adc*gain;
238
ed228cbc 239 //Int_t trno = pmddigit->GetTrackNumber();
920e13db 240 fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
241 fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
242 fCellADC[xpos][ypos] = (Double_t) adc;
01709453 243 }
01709453 244
ed228cbc 245 idet = det;
1758e4fe 246 ismn = smn;
b9e2f33c 247
248 // Set the minimum noise cut per module before clustering
249
250 Int_t imod = idet*24 + ismn;
251 fEcut = fRecoParam->GetNoiseCut(imod); // default
252 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
253 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
254 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
255
256 pmdclust->SetEdepCut(fEcut);
257
258
920e13db 259 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
260 pmdisocell,pmdcont);
261
ed228cbc 262 Int_t nentries1 = pmdcont->GetEntries();
7e9508a7 263
264 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
265
ed228cbc 266 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
01709453 267 {
ebd83c56 268 AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
1758e4fe 269 idet = pmdcl->GetDetector();
270 ismn = pmdcl->GetSMN();
271 clusdata[0] = pmdcl->GetClusX();
272 clusdata[1] = pmdcl->GetClusY();
273 clusdata[2] = pmdcl->GetClusADC();
274 clusdata[3] = pmdcl->GetClusCells();
5c5cadd5 275 clusdata[4] = pmdcl->GetClusSigmaX();
276 clusdata[5] = pmdcl->GetClusSigmaY();
01b56f5c 277
1758e4fe 278 AddRecPoint(idet,ismn,clusdata);
5c5cadd5 279
5c5cadd5 280 Int_t ncell = (Int_t) clusdata[3];
281 for(Int_t ihit = 0; ihit < ncell; ihit++)
282 {
283 Int_t celldataX = pmdcl->GetClusCellX(ihit);
284 Int_t celldataY = pmdcl->GetClusCellY(ihit);
920e13db 285 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
286 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
b0e4d1e1 287 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
288 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
5c5cadd5 289 }
290 branch2->Fill();
291 ResetRechit();
ed228cbc 292 }
26e08752 293 pmdcont->Delete();
920e13db 294
295 // Added single isolated cell for offline gain calibration
296 nentries1 = pmdisocell->GetEntries();
297 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
298
299 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
300 {
301 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
302 idet = pmdiso->GetDetector();
303 ismn = pmdiso->GetSmn();
304 clusdata[0] = (Float_t) pmdiso->GetRow();
305 clusdata[1] = (Float_t) pmdiso->GetCol();
306 clusdata[2] = pmdiso->GetADC();
307 clusdata[3] = 1.;
308 clusdata[4] = -99.;
309 clusdata[5] = -99.;
310
311 AddRecPoint(idet,ismn,clusdata);
312 }
313 pmdisocell->Delete();
ed228cbc 314
5c5cadd5 315 branch1->Fill();
ed228cbc 316 ResetRecpoint();
317
318 } // modules
319
01709453 320 ResetCellADC();
e1287360 321 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
b208c6a3 322 fPMDLoader->WriteRecPoints("OVERWRITE");
01709453 323
324 // delete the pointers
325 delete pmdclust;
326 delete pmdcont;
920e13db 327 delete pmdisocell;
01709453 328
7e9508a7 329}
330// ------------------------------------------------------------------------- //
331
8fbad6d3 332void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
333 TTree *clustersTree)
334{
335 // Converts digits to recpoints after running clustering
336 // algorithm on CPV plane and PREshower plane
2c1131dd 337 //
f0290c15 338 // This algorithm is called during the reconstruction from digits
8fbad6d3 339
340 Int_t det = 0,smn = 0;
341 Int_t xpos,ypos;
342 Float_t adc;
343 Int_t ismn;
344 Int_t idet;
345 Float_t clusdata[6];
346
5254fcca 347 AliPMDcluster *pmdcl = 0x0;
920e13db 348 AliPMDisocell *pmdiso = 0x0;
5254fcca 349
8fbad6d3 350 TObjArray *pmdcont = new TObjArray();
920e13db 351 TObjArray *pmdisocell = new TObjArray();
8fbad6d3 352 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
353
b9e2f33c 354 // Fetch the reco param object
355
356 fRecoParam = AliPMDReconstructor::GetRecoParam();
357 if(fRecoParam == 0x0)
358 {
359 AliFatal("No Reco Param found for PMD!!!");
360 }
361
8fbad6d3 362
8fbad6d3 363 AliPMDdigit *pmddigit;
364 TBranch *branch = digitsTree->GetBranch("PMDDigit");
365 branch->SetAddress(&fDigits);
366
367 ResetRecpoint();
368
8fbad6d3 369 Int_t bufsize = 16000;
370 TBranch * branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
371 TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize);
372
373 Int_t nmodules = (Int_t) digitsTree->GetEntries();
374
375 for (Int_t imodule = 0; imodule < nmodules; imodule++)
376 {
5254fcca 377
378 Int_t totADCMod = 0;
8fbad6d3 379 ResetCellADC();
380 digitsTree->GetEntry(imodule);
381 Int_t nentries = fDigits->GetLast();
382 for (Int_t ient = 0; ient < nentries+1; ient++)
383 {
384 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
385
386 det = pmddigit->GetDetector();
387 smn = pmddigit->GetSMNumber();
388 xpos = pmddigit->GetRow();
389 ypos = pmddigit->GetColumn();
390 adc = pmddigit->GetADC();
8a523d22 391
392 if(det < 0 || det > 1)
393 {
394 AliError(Form("*CPV/PRE NUMBER WRONG %d *",det));
395 continue;
396 }
397 if(smn == -1)
398 {
399 AliError(Form("*MODULE NUMBER WRONG %d *",smn));
400 continue;
401 }
402
f0290c15 403 if(xpos < 0 || xpos > 48 || ypos < 0 || ypos > 96)
404 {
405 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
406 xpos, ypos));
407 continue;
408 }
409
35535af7 410 // Pedestal Subtraction
411 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,xpos,ypos);
37edc588 412 Int_t pedrms1 = (Int_t) pedmeanrms%100;
35535af7 413 Float_t pedrms = (Float_t)pedrms1/10.;
414 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
415 //printf("%f %f\n",pedmean, pedrms);
416
417 Float_t adc1 = adc - (pedmean + 3.0*pedrms);
418
7adbd8e9 419 // Hot cell - set the cell adc = 0
420 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,xpos,ypos);
8a523d22 421 if (hotflag == 1.) adc1 = 0;
7adbd8e9 422
8fbad6d3 423 // CALIBRATION
35535af7 424 Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
8fbad6d3 425 // printf("adc = %d gain = %f\n",adc,gain);
35535af7 426
427 adc = adc1*gain;
8fbad6d3 428
920e13db 429 fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
430 fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
8fbad6d3 431 fCellADC[xpos][ypos] = (Double_t) adc;
5254fcca 432
5fbd2db1 433 totADCMod += (Int_t) adc;
5254fcca 434
8fbad6d3 435 }
436
437 idet = det;
438 ismn = smn;
5254fcca 439
440 if (totADCMod <= 0) continue;
441
b9e2f33c 442 // Set the minimum noise cut per module before clustering
443
444 Int_t imod = idet*24 + ismn;
445 fEcut = fRecoParam->GetNoiseCut(imod); // default
446 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
447 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
448 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
449
450
451 pmdclust->SetEdepCut(fEcut);
452
920e13db 453 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
454 pmdisocell,pmdcont);
8fbad6d3 455
456 Int_t nentries1 = pmdcont->GetEntries();
457
458 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
459
460 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
461 {
920e13db 462 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
8fbad6d3 463 idet = pmdcl->GetDetector();
464 ismn = pmdcl->GetSMN();
465 clusdata[0] = pmdcl->GetClusX();
466 clusdata[1] = pmdcl->GetClusY();
467 clusdata[2] = pmdcl->GetClusADC();
468 clusdata[3] = pmdcl->GetClusCells();
469 clusdata[4] = pmdcl->GetClusSigmaX();
470 clusdata[5] = pmdcl->GetClusSigmaY();
471
472 AddRecPoint(idet,ismn,clusdata);
473
474 Int_t ncell = (Int_t) clusdata[3];
475 for(Int_t ihit = 0; ihit < ncell; ihit++)
476 {
477 Int_t celldataX = pmdcl->GetClusCellX(ihit);
478 Int_t celldataY = pmdcl->GetClusCellY(ihit);
920e13db 479 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
480 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
b0e4d1e1 481 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
482 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
8fbad6d3 483 }
484 branch2->Fill();
485 ResetRechit();
486 }
26e08752 487 pmdcont->Delete();
920e13db 488
489 // Added single isolated cell for offline gain calibration
490 nentries1 = pmdisocell->GetEntries();
491 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
492
493 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
494 {
495 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
496 idet = pmdiso->GetDetector();
497 ismn = pmdiso->GetSmn();
498 clusdata[0] = (Float_t) pmdiso->GetRow();
499 clusdata[1] = (Float_t) pmdiso->GetCol();
500 clusdata[2] = pmdiso->GetADC();
501 clusdata[3] = 1.;
502 clusdata[4] = -99.;
503 clusdata[5] = -99.;
504
505 AddRecPoint(idet,ismn,clusdata);
506 }
507 pmdisocell->Delete();
8fbad6d3 508
509 branch1->Fill();
510 ResetRecpoint();
511
512 } // modules
513
920e13db 514
8fbad6d3 515 ResetCellADC();
8fbad6d3 516
517 // delete the pointers
518 delete pmdclust;
519 delete pmdcont;
920e13db 520 delete pmdisocell;
8fbad6d3 521}
522// ------------------------------------------------------------------------- //
523
7e9508a7 524void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
525 TTree *clustersTree)
526{
527 // Converts RAW data to recpoints after running clustering
528 // algorithm on CPV and PREshower plane
529 //
2c1131dd 530 // This method is called at the time of reconstruction from RAW data
2332574a 531
7e9508a7 532
920e13db 533 AliPMDddldata *pmdddl = 0x0;
534 AliPMDcluster *pmdcl = 0x0;
535 AliPMDisocell *pmdiso = 0x0;
5254fcca 536
537
5c5cadd5 538 Float_t clusdata[6];
df42ab21 539 TObjArray pmdddlcont;
7e9508a7 540
541 TObjArray *pmdcont = new TObjArray();
920e13db 542 TObjArray *pmdisocell = new TObjArray();
5254fcca 543
5c5cadd5 544 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
7e9508a7 545
08cf9354 546 // open the ddl file info to know the module
547 TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
548 ddlinfofileName += "/PMD/PMD_ddl_info.dat";
549
550 ifstream infileddl;
551 infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
552 if(!infileddl) AliError("Could not read the ddl info file");
553
554 Int_t ddlno;
555 Int_t modno;
556 Int_t modulePerDDL;
557 Int_t moduleddl[6];
558
559 for(Int_t jddl = 0; jddl < 6; jddl++)
560 {
561 if (infileddl.eof()) break;
562 infileddl >> ddlno >> modulePerDDL;
563 moduleddl[jddl] = modulePerDDL;
564
565 if (modulePerDDL == 0) continue;
566 for (Int_t im = 0; im < modulePerDDL; im++)
567 {
568 infileddl >> modno;
569 }
570 }
571
572 infileddl.close();
573
b9e2f33c 574 // Set the minimum noise cut per module before clustering
575
576 fRecoParam = AliPMDReconstructor::GetRecoParam();
577
578 if(fRecoParam == 0x0)
579 {
580 AliFatal("No Reco Param found for PMD!!!");
581 }
582
7e9508a7 583 ResetRecpoint();
584
585 Int_t bufsize = 16000;
5c5cadd5 586 TBranch *branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
587
588 TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize);
7e9508a7 589
7e9508a7 590 const Int_t kRow = 48;
591 const Int_t kCol = 96;
592
593 Int_t idet = 0;
594 Int_t iSMN = 0;
2332574a 595
722ccc67 596 Int_t indexDDL = -1;
597 AliPMDRawStream pmdinput(rawReader);
8fbad6d3 598
722ccc67 599 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
08cf9354 600 {
601 iSMN = moduleddl[indexDDL];
602
7e9508a7 603 Int_t ***precpvADC;
604 precpvADC = new int **[iSMN];
605 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
606 for (Int_t i=0; i<iSMN;i++)
607 {
608 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
609 }
610 for (Int_t i = 0; i < iSMN; i++)
611 {
612 for (Int_t j = 0; j < kRow; j++)
613 {
614 for (Int_t k = 0; k < kCol; k++)
615 {
616 precpvADC[i][j][k] = 0;
617 }
618 }
619 }
620 ResetCellADC();
2332574a 621
df42ab21 622 Int_t indexsmn = 0;
623 Int_t ientries = pmdddlcont.GetEntries();
624 for (Int_t ient = 0; ient < ientries; ient++)
7e9508a7 625 {
920e13db 626 pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
7e9508a7 627
df42ab21 628 Int_t det = pmdddl->GetDetector();
629 Int_t smn = pmdddl->GetSMN();
630 //Int_t mcm = pmdddl->GetMCM();
631 //Int_t chno = pmdddl->GetChannel();
632 Int_t row = pmdddl->GetRow();
633 Int_t col = pmdddl->GetColumn();
634 Int_t sig = pmdddl->GetSignal();
2c1131dd 635
8a523d22 636 if(det < 0 || det > 1)
637 {
638 AliError(Form("*CPV/PRE NUMBER WRONG %d *",det));
639 continue;
640 }
2c1131dd 641 if(smn == -1)
642 {
643 AliError(Form("*MODULE NUMBER WRONG %d *",smn));
644 continue;
645 }
f0290c15 646 if(row < 0 || row > 48 || col < 0 || col > 96)
647 {
648 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
649 row, col));
08cf9354 650
f0290c15 651 continue;
652 }
2c1131dd 653
35535af7 654 // Pedestal Subtraction
655 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
37edc588 656 Int_t pedrms1 = (Int_t) pedmeanrms%100;
35535af7 657 Float_t pedrms = (Float_t)pedrms1/10.;
658 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
659
660 //printf("%f %f\n",pedmean, pedrms);
661
662 // Float_t sig1 = (Float_t) sig;
663 Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
664
8a523d22 665
7adbd8e9 666 // Hot cell - set the cell adc = 0
667 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
8a523d22 668 if (hotflag == 1.) sig1 = 0;
7adbd8e9 669
09a06455 670 // CALIBRATION
35535af7 671 Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
df42ab21 672 //printf("sig = %d gain = %f\n",sig,gain);
09a06455 673 sig = (Int_t) (sig1*gain);
7e9508a7 674
08cf9354 675 if (indexDDL == 0)
676 {
677 if (det != 0)
678 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
679 indexDDL, det));
680 if (iSMN == 6)
681 {
682 indexsmn = smn;
683 }
684 else if (iSMN == 12)
685 {
686 if (smn < 6)
687 indexsmn = smn;
688 else if (smn >= 18 && smn < 24)
689 indexsmn = smn-12;
690 }
691 }
692 else if (indexDDL >= 1 && indexDDL < 4)
7e9508a7 693 {
694 if (det != 0)
695 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
696 indexDDL, det));
697 indexsmn = smn - indexDDL * 6;
698 }
699 else if (indexDDL == 4)
700 {
701 if (det != 1)
702 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
703 indexDDL, det));
704 if (smn < 6)
705 {
706 indexsmn = smn;
707 }
df42ab21 708 else if (smn >= 18 && smn < 24)
7e9508a7 709 {
df42ab21 710 indexsmn = smn - 12;
7e9508a7 711 }
712 }
713 else if (indexDDL == 5)
714 {
715 if (det != 1)
716 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
717 indexDDL, det));
08cf9354 718 if (smn >= 6 && smn < 18)
7e9508a7 719 {
df42ab21 720 indexsmn = smn - 6;
7e9508a7 721 }
722 }
08cf9354 723
7e9508a7 724 precpvADC[indexsmn][row][col] = sig;
df42ab21 725 }
726
26e08752 727 pmdddlcont.Delete();
7e9508a7 728
5254fcca 729 Int_t totAdcMod = 0;
730
7e9508a7 731 Int_t ismn = 0;
78fc1b96 732 for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
7e9508a7 733 {
734 ResetCellADC();
5254fcca 735 totAdcMod = 0;
7e9508a7 736 for (Int_t irow = 0; irow < kRow; irow++)
737 {
738 for (Int_t icol = 0; icol < kCol; icol++)
739 {
920e13db 740 fCellTrack[irow][icol] = -1;
741 fCellPid[irow][icol] = -1;
742
7e9508a7 743 fCellADC[irow][icol] =
744 (Double_t) precpvADC[indexsmn][irow][icol];
5254fcca 745 totAdcMod += precpvADC[indexsmn][irow][icol];
7e9508a7 746 } // row
747 } // col
df42ab21 748
08cf9354 749 if (indexDDL == 0)
750 {
751 if (iSMN == 6)
752 {
753 ismn = indexsmn;
754 }
755 else if (iSMN == 12)
756 {
757
758 if (indexsmn < 6)
759 ismn = indexsmn;
760 else if (indexsmn >= 6 && indexsmn < 12)
761 ismn = indexsmn + 12;
762 }
763 idet = 0;
764 }
765 else if (indexDDL >= 1 && indexDDL < 4)
7e9508a7 766 {
767 ismn = indexsmn + indexDDL * 6;
768 idet = 0;
769 }
770 else if (indexDDL == 4)
771 {
772 if (indexsmn < 6)
773 {
774 ismn = indexsmn;
775 }
776 else if (indexsmn >= 6 && indexsmn < 12)
777 {
df42ab21 778 ismn = indexsmn + 12;
7e9508a7 779 }
780 idet = 1;
781 }
782 else if (indexDDL == 5)
783 {
08cf9354 784 ismn = indexsmn + 6;
7e9508a7 785 idet = 1;
786 }
787
5254fcca 788 if (totAdcMod <= 0) continue;
920e13db 789
b9e2f33c 790 Int_t imod = idet*24 + ismn;
791
792 fEcut = fRecoParam->GetNoiseCut(imod); // default
793 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
794 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
795 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
796
797
798 pmdclust->SetEdepCut(fEcut);
920e13db 799
920e13db 800 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
801 pmdisocell,pmdcont);
802
7e9508a7 803 Int_t nentries1 = pmdcont->GetEntries();
804
805 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
806
807 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
808 {
920e13db 809 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
7e9508a7 810 idet = pmdcl->GetDetector();
811 ismn = pmdcl->GetSMN();
812 clusdata[0] = pmdcl->GetClusX();
813 clusdata[1] = pmdcl->GetClusY();
814 clusdata[2] = pmdcl->GetClusADC();
815 clusdata[3] = pmdcl->GetClusCells();
5c5cadd5 816 clusdata[4] = pmdcl->GetClusSigmaX();
817 clusdata[5] = pmdcl->GetClusSigmaY();
7e9508a7 818
819 AddRecPoint(idet,ismn,clusdata);
09a06455 820
5c5cadd5 821 Int_t ncell = (Int_t) clusdata[3];
822 for(Int_t ihit = 0; ihit < ncell; ihit++)
823 {
824 Int_t celldataX = pmdcl->GetClusCellX(ihit);
825 Int_t celldataY = pmdcl->GetClusCellY(ihit);
920e13db 826 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
827 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
b0e4d1e1 828 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
829 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
5c5cadd5 830 }
831 branch2->Fill();
832 ResetRechit();
833
7e9508a7 834 }
26e08752 835 pmdcont->Delete();
920e13db 836
837
838 // Added single isolated cell for offline gain calibration
839 nentries1 = pmdisocell->GetEntries();
840 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
841
842 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
843 {
844 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
845 idet = pmdiso->GetDetector();
846 ismn = pmdiso->GetSmn();
847 clusdata[0] = (Float_t) pmdiso->GetRow();
848 clusdata[1] = (Float_t) pmdiso->GetCol();
849 clusdata[2] = pmdiso->GetADC();
850 clusdata[3] = 1.;
851 clusdata[4] = -99.;
852 clusdata[5] = -99.;
853
854 AddRecPoint(idet,ismn,clusdata);
855 }
856 pmdisocell->Delete();
7e9508a7 857
5c5cadd5 858 branch1->Fill();
7e9508a7 859 ResetRecpoint();
860
861
862 } // smn
863
864 for (Int_t i=0; i<iSMN; i++)
865 {
866 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
867 }
868 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
c9e0bd24 869 delete [] precpvADC;
722ccc67 870
7e9508a7 871 } // DDL Loop
920e13db 872
7e9508a7 873
874 ResetCellADC();
875
876 // delete the pointers
877 delete pmdclust;
878 delete pmdcont;
920e13db 879 delete pmdisocell;
7e9508a7 880
01709453 881}
1758e4fe 882// ------------------------------------------------------------------------- //
5f55af10 883
884void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
885{
01b56f5c 886 // Converts RAW data to recpoints after running clustering
887 // algorithm on CPV and PREshower plane
5f55af10 888 //
889
5c5cadd5 890 Float_t clusdata[6];
920e13db 891
df42ab21 892 TObjArray pmdddlcont;
920e13db 893
b0e4d1e1 894 AliPMDcluster *pmdcl = 0x0;
920e13db 895 AliPMDisocell *pmdiso = 0x0;
896
897
5f55af10 898 TObjArray *pmdcont = new TObjArray();
920e13db 899 TObjArray *pmdisocell = new TObjArray();
5c5cadd5 900
901 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
7e9508a7 902
08cf9354 903 // open the ddl file info to know the module
904 TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
905 ddlinfofileName += "/PMD/PMD_ddl_info.dat";
906
907 ifstream infileddl;
908 infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
909 if(!infileddl) AliError("Could not read the ddl info file");
910
911 Int_t ddlno;
912 Int_t modno;
913 Int_t modulePerDDL;
914 Int_t moduleddl[6];
915
916 for(Int_t jddl = 0; jddl < 6; jddl++)
917 {
918 if (infileddl.eof()) break;
919 infileddl >> ddlno >> modulePerDDL;
920 moduleddl[jddl] = modulePerDDL;
921
922 if (modulePerDDL == 0) continue;
923 for (Int_t im = 0; im < modulePerDDL; im++)
924 {
925 infileddl >> modno;
926 }
927 }
928
929 infileddl.close();
930
b9e2f33c 931 // Set the minimum noise cut per module before clustering
932
933 fRecoParam = AliPMDReconstructor::GetRecoParam();
934
935 if(fRecoParam == 0x0)
936 {
937 AliFatal("No Reco Param found for PMD!!!");
938 }
939
5f55af10 940
941 fRunLoader->GetEvent(ievt);
942
943 ResetRecpoint();
01b56f5c 944
5f55af10 945 fTreeR = fPMDLoader->TreeR();
946 if (fTreeR == 0x0)
947 {
948 fPMDLoader->MakeTree("R");
949 fTreeR = fPMDLoader->TreeR();
950 }
5f55af10 951 Int_t bufsize = 16000;
5c5cadd5 952 TBranch *branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
953 TBranch *branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize);
01b56f5c 954
5f55af10 955 const Int_t kRow = 48;
956 const Int_t kCol = 96;
5f55af10 957
01b56f5c 958 Int_t idet = 0;
959 Int_t iSMN = 0;
722ccc67 960
961 AliPMDRawStream pmdinput(rawReader);
962 Int_t indexDDL = -1;
963
08cf9354 964 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
965 {
966
967 iSMN = moduleddl[indexDDL];
722ccc67 968
01b56f5c 969 Int_t ***precpvADC;
970 precpvADC = new int **[iSMN];
971 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
972 for (Int_t i=0; i<iSMN;i++)
5f55af10 973 {
01b56f5c 974 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
5f55af10 975 }
01b56f5c 976 for (Int_t i = 0; i < iSMN; i++)
977 {
978 for (Int_t j = 0; j < kRow; j++)
979 {
980 for (Int_t k = 0; k < kCol; k++)
981 {
982 precpvADC[i][j][k] = 0;
983 }
984 }
985 }
986 ResetCellADC();
2332574a 987
df42ab21 988
989 Int_t indexsmn = 0;
990 Int_t ientries = pmdddlcont.GetEntries();
991 for (Int_t ient = 0; ient < ientries; ient++)
01b56f5c 992 {
df42ab21 993 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
994
995 Int_t det = pmdddl->GetDetector();
996 Int_t smn = pmdddl->GetSMN();
997 //Int_t mcm = pmdddl->GetMCM();
998 //Int_t chno = pmdddl->GetChannel();
999 Int_t row = pmdddl->GetRow();
1000 Int_t col = pmdddl->GetColumn();
1001 Int_t sig = pmdddl->GetSignal();
f0290c15 1002 if(row < 0 || row > 48 || col < 0 || col > 96)
1003 {
1004 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
1005 row, col));
1006 continue;
1007 }
35535af7 1008 // Pedestal Subtraction
1009 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
37edc588 1010 Int_t pedrms1 = (Int_t) pedmeanrms%100;
35535af7 1011 Float_t pedrms = (Float_t)pedrms1/10.;
1012 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
35535af7 1013 //printf("%f %f\n",pedmean, pedrms);
35535af7 1014 Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
7adbd8e9 1015
1016 // Hot cell - set the cell adc = 0
1017 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
1018 if (hotflag == 1) sig1 = 0;
1019
09a06455 1020 // CALIBRATION
35535af7 1021 Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
2332574a 1022
df42ab21 1023 //printf("sig = %d gain = %f\n",sig,gain);
09a06455 1024 sig = (Int_t) (sig1*gain);
df42ab21 1025
08cf9354 1026 if (indexDDL == 0)
1027 {
1028 if (det != 0)
1029 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1030 indexDDL, det));
1031 if (iSMN == 6)
1032 {
1033 indexsmn = smn;
1034 }
1035 else if (iSMN == 12)
1036 {
1037 if (smn < 6)
1038 indexsmn = smn;
1039 else if (smn >= 18 && smn < 24)
1040 indexsmn = smn-12;
1041 }
1042 }
1043 else if (indexDDL >= 1 && indexDDL < 4)
01b56f5c 1044 {
1045 if (det != 0)
7e9508a7 1046 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1047 indexDDL, det));
01b56f5c 1048 indexsmn = smn - indexDDL * 6;
1049 }
1050 else if (indexDDL == 4)
1051 {
1052 if (det != 1)
7e9508a7 1053 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1054 indexDDL, det));
01b56f5c 1055 if (smn < 6)
1056 {
1057 indexsmn = smn;
1058 }
df42ab21 1059 else if (smn >= 18 && smn < 24)
01b56f5c 1060 {
df42ab21 1061 indexsmn = smn - 12;
01b56f5c 1062 }
1063 }
1064 else if (indexDDL == 5)
1065 {
1066 if (det != 1)
7e9508a7 1067 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1068 indexDDL, det));
08cf9354 1069 if (smn >= 6 && smn < 18)
01b56f5c 1070 {
df42ab21 1071 indexsmn = smn - 6;
01b56f5c 1072 }
1073 }
08cf9354 1074
01b56f5c 1075 precpvADC[indexsmn][row][col] = sig;
df42ab21 1076
1077 }
1078
26e08752 1079 pmdddlcont.Delete();
01b56f5c 1080
1081 Int_t ismn = 0;
78fc1b96 1082 for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
5f55af10 1083 {
01b56f5c 1084 ResetCellADC();
5f55af10 1085 for (Int_t irow = 0; irow < kRow; irow++)
1086 {
1087 for (Int_t icol = 0; icol < kCol; icol++)
1088 {
920e13db 1089 fCellTrack[irow][icol] = -1;
1090 fCellPid[irow][icol] = -1;
01b56f5c 1091 fCellADC[irow][icol] =
1092 (Double_t) precpvADC[indexsmn][irow][icol];
5f55af10 1093 } // row
1094 } // col
df42ab21 1095
08cf9354 1096
1097 if (indexDDL == 0)
1098 {
1099 if (iSMN == 6)
1100 {
1101 ismn = indexsmn;
1102 }
1103 else if (iSMN == 12)
1104 {
1105
1106 if (indexsmn < 6)
1107 ismn = indexsmn;
1108 else if (indexsmn >= 6 && indexsmn < 12)
1109 ismn = indexsmn + 12;
1110 }
1111 idet = 0;
1112 }
1113 else if (indexDDL >= 1 && indexDDL < 4)
01b56f5c 1114 {
1115 ismn = indexsmn + indexDDL * 6;
1116 idet = 0;
1117 }
1118 else if (indexDDL == 4)
1119 {
1120 if (indexsmn < 6)
1121 {
1122 ismn = indexsmn;
1123 }
1124 else if (indexsmn >= 6 && indexsmn < 12)
1125 {
df42ab21 1126 ismn = indexsmn + 12;
01b56f5c 1127 }
1128 idet = 1;
1129 }
1130 else if (indexDDL == 5)
1131 {
08cf9354 1132 ismn = indexsmn + 6;
01b56f5c 1133 idet = 1;
1134 }
1135
b9e2f33c 1136 Int_t imod = idet*24 + ismn;
1137 fEcut = fRecoParam->GetNoiseCut(imod); // default
1138 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
1139 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
1140 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
1141
1142 pmdclust->SetEdepCut(fEcut);
1143
920e13db 1144 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
1145 pmdisocell,pmdcont);
1146
5f55af10 1147 Int_t nentries1 = pmdcont->GetEntries();
7e9508a7 1148
1149 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
1150
5f55af10 1151 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
1152 {
b0e4d1e1 1153 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
5f55af10 1154 idet = pmdcl->GetDetector();
1155 ismn = pmdcl->GetSMN();
1156 clusdata[0] = pmdcl->GetClusX();
1157 clusdata[1] = pmdcl->GetClusY();
1158 clusdata[2] = pmdcl->GetClusADC();
1159 clusdata[3] = pmdcl->GetClusCells();
5c5cadd5 1160 clusdata[4] = pmdcl->GetClusSigmaX();
1161 clusdata[5] = pmdcl->GetClusSigmaY();
01b56f5c 1162
5f55af10 1163 AddRecPoint(idet,ismn,clusdata);
5c5cadd5 1164
5c5cadd5 1165 Int_t ncell = (Int_t) clusdata[3];
1166 for(Int_t ihit = 0; ihit < ncell; ihit++)
1167 {
1168 Int_t celldataX = pmdcl->GetClusCellX(ihit);
1169 Int_t celldataY = pmdcl->GetClusCellY(ihit);
920e13db 1170 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
1171 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
b0e4d1e1 1172 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
1173 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
5c5cadd5 1174 }
1175 branch2->Fill();
1176 ResetRechit();
1177
5f55af10 1178 }
26e08752 1179 pmdcont->Delete();
920e13db 1180
1181 // Added single isolated cell for offline gain calibration
1182 nentries1 = pmdisocell->GetEntries();
1183 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
1184
1185 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
1186 {
1187 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
1188 idet = pmdiso->GetDetector();
1189 ismn = pmdiso->GetSmn();
1190 clusdata[0] = (Float_t) pmdiso->GetRow();
1191 clusdata[1] = (Float_t) pmdiso->GetCol();
1192 clusdata[2] = pmdiso->GetADC();
1193 clusdata[3] = 1.;
1194 clusdata[4] = -99.;
1195 clusdata[5] = -99.;
1196
1197 AddRecPoint(idet,ismn,clusdata);
1198 }
1199 pmdisocell->Delete();
5f55af10 1200
5c5cadd5 1201 branch1->Fill();
5f55af10 1202 ResetRecpoint();
01b56f5c 1203
1204
5f55af10 1205 } // smn
5f55af10 1206
01b56f5c 1207 for (Int_t i=0; i<iSMN; i++)
1208 {
1209 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
1210 }
1211 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
1212 delete precpvADC;
1213 } // DDL Loop
920e13db 1214
1215
5f55af10 1216 ResetCellADC();
01b56f5c 1217
5f55af10 1218 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
1219 fPMDLoader->WriteRecPoints("OVERWRITE");
1220
1221 // delete the pointers
1222 delete pmdclust;
1223 delete pmdcont;
920e13db 1224 delete pmdisocell;
5f55af10 1225}
1226// ------------------------------------------------------------------------- //
ed228cbc 1227void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
1228{
1229 fEcut = ecut;
1230}
1758e4fe 1231// ------------------------------------------------------------------------- //
1758e4fe 1232void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
01709453 1233{
b208c6a3 1234 // Add Reconstructed points
1235 //
01709453 1236 TClonesArray &lrecpoints = *fRecpoints;
ed228cbc 1237 AliPMDrecpoint1 *newrecpoint;
1758e4fe 1238 newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
ed228cbc 1239 new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
01709453 1240 delete newrecpoint;
1241}
1758e4fe 1242// ------------------------------------------------------------------------- //
920e13db 1243void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY,
b0e4d1e1 1244 Int_t celldataTr, Int_t celldataPid,
1245 Float_t celldataAdc)
5c5cadd5 1246{
1247 // Add associated cell hits to the Reconstructed points
1248 //
1249 TClonesArray &lrechits = *fRechits;
1250 AliPMDrechit *newrechit;
b0e4d1e1 1251 newrechit = new AliPMDrechit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
5c5cadd5 1252 new(lrechits[fNhit++]) AliPMDrechit(newrechit);
1253 delete newrechit;
1254}
1255// ------------------------------------------------------------------------- //
01709453 1256void AliPMDClusterFinder::ResetCellADC()
1257{
b208c6a3 1258 // Reset the individual cell ADC value to zero
1259 //
5e6a9312 1260 for(Int_t irow = 0; irow < fgkRow; irow++)
01709453 1261 {
5e6a9312 1262 for(Int_t icol = 0; icol < fgkCol; icol++)
01709453 1263 {
920e13db 1264 fCellTrack[irow][icol] = -1;
1265 fCellPid[irow][icol] = -1;
1266 fCellADC[irow][icol] = 0.;
01709453 1267 }
1268 }
1269}
1758e4fe 1270// ------------------------------------------------------------------------- //
01709453 1271void AliPMDClusterFinder::ResetRecpoint()
1272{
b208c6a3 1273 // Clear the list of reconstructed points
01709453 1274 fNpoint = 0;
1275 if (fRecpoints) fRecpoints->Clear();
1276}
1758e4fe 1277// ------------------------------------------------------------------------- //
5c5cadd5 1278void AliPMDClusterFinder::ResetRechit()
1279{
1280 // Clear the list of reconstructed points
1281 fNhit = 0;
1282 if (fRechits) fRechits->Clear();
1283}
1284// ------------------------------------------------------------------------- //
55601d47 1285void AliPMDClusterFinder::Load()
1286{
ebd83c56 1287 // Load all the *.root files
55601d47 1288 //
1289 fPMDLoader->LoadDigits("READ");
1290 fPMDLoader->LoadRecPoints("recreate");
1291}
1292// ------------------------------------------------------------------------- //
01b56f5c 1293void AliPMDClusterFinder::LoadClusters()
1294{
1295 // Load all the *.root files
1296 //
1297 fPMDLoader->LoadRecPoints("recreate");
1298}
1299// ------------------------------------------------------------------------- //
ebd83c56 1300void AliPMDClusterFinder::UnLoad()
01709453 1301{
b208c6a3 1302 // Unload all the *.root files
1303 //
ebd83c56 1304 fPMDLoader->UnloadDigits();
1305 fPMDLoader->UnloadRecPoints();
01709453 1306}
1758e4fe 1307// ------------------------------------------------------------------------- //
01b56f5c 1308void AliPMDClusterFinder::UnLoadClusters()
1309{
1310 // Unload all the *.root files
1311 //
1312 fPMDLoader->UnloadRecPoints();
1313}
1314// ------------------------------------------------------------------------- //
35535af7 1315AliPMDCalibData* AliPMDClusterFinder::GetCalibGain() const
09a06455 1316{
1317 // The run number will be centralized in AliCDBManager,
1318 // you don't need to set it here!
1319 // Added by ZA
35535af7 1320 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Gain");
09a06455 1321
0dd3d6f9 1322 if(!entry) AliFatal("Calibration object retrieval failed! ");
09a06455 1323
1324 AliPMDCalibData *calibdata=0;
1325 if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
1326
0dd3d6f9 1327 if (!calibdata) AliFatal("No calibration data from calibration database !");
09a06455 1328
1329 return calibdata;
1330}
35535af7 1331// ------------------------------------------------------------------------- //
35535af7 1332AliPMDPedestal* AliPMDClusterFinder::GetCalibPed() const
1333{
1334 // The run number will be centralized in AliCDBManager,
1335 // you don't need to set it here!
1336 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ped");
1337
1338 if(!entry) AliFatal("Pedestal object retrieval failed!");
1339
1340 AliPMDPedestal *pedestal = 0;
1341 if (entry) pedestal = (AliPMDPedestal*) entry->GetObject();
1342
1343 if (!pedestal) AliFatal("No pedestal data from pedestal database !");
1344
1345 return pedestal;
1346}
7adbd8e9 1347//--------------------------------------------------------------------//
1348AliPMDHotData* AliPMDClusterFinder::GetCalibHot() const
1349{
1350 // The run number will be centralized in AliCDBManager,
1351 // you don't need to set it here!
1352 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Hot");
1353
1354 if(!entry) AliFatal("HotData object retrieval failed!");
1355
1356 AliPMDHotData *hot = 0;
1357 if (entry) hot = (AliPMDHotData*) entry->GetObject();
1358
1359 if (!hot) AliFatal("No hot data from database !");
1360
1361 return hot;
1362}
1363