]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMDClusterFinder.cxx
change Ds selection
[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"
5f55af10 43#include "AliPMDRawStream.h"
09a06455 44#include "AliPMDCalibData.h"
35535af7 45#include "AliPMDPedestal.h"
df42ab21 46#include "AliPMDddldata.h"
7adbd8e9 47#include "AliPMDHotData.h"
963fe679 48#include "AliPMDNoiseCut.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()),
963fe679 66 fNoiseCut(GetNoiseCut()),
b9e2f33c 67 fRecoParam(0x0),
7e9508a7 68 fTreeD(0),
69 fTreeR(0),
70 fDigits(new TClonesArray("AliPMDdigit", 1000)),
71 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
5c5cadd5 72 fRechits(new TClonesArray("AliPMDrechit", 1000)),
7e9508a7 73 fNpoint(0),
5c5cadd5 74 fNhit(0),
963fe679 75 fDetNo(0)
7e9508a7 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()),
963fe679 88 fNoiseCut(GetNoiseCut()),
b9e2f33c 89 fRecoParam(0x0),
1758e4fe 90 fTreeD(0),
91 fTreeR(0),
ebd83c56 92 fDigits(new TClonesArray("AliPMDdigit", 1000)),
1758e4fe 93 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
5c5cadd5 94 fRechits(new TClonesArray("AliPMDrechit", 1000)),
1758e4fe 95 fNpoint(0),
5c5cadd5 96 fNhit(0),
963fe679 97 fDetNo(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()),
963fe679 111 fNoiseCut(GetNoiseCut()),
b9e2f33c 112 fRecoParam(0x0),
2332574a 113 fTreeD(0),
114 fTreeR(0),
115 fDigits(NULL),
116 fRecpoints(NULL),
117 fRechits(NULL),
118 fNpoint(0),
119 fNhit(0),
963fe679 120 fDetNo(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
8fbad6d3 152void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
153 TTree *clustersTree)
154{
155 // Converts digits to recpoints after running clustering
156 // algorithm on CPV plane and PREshower plane
2c1131dd 157 //
f0290c15 158 // This algorithm is called during the reconstruction from digits
8fbad6d3 159
160 Int_t det = 0,smn = 0;
161 Int_t xpos,ypos;
162 Float_t adc;
163 Int_t ismn;
164 Int_t idet;
165 Float_t clusdata[6];
166
5254fcca 167 AliPMDcluster *pmdcl = 0x0;
168
8fbad6d3 169 TObjArray *pmdcont = new TObjArray();
27a78deb 170
8fbad6d3 171 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
172
b9e2f33c 173 // Fetch the reco param object
174
175 fRecoParam = AliPMDReconstructor::GetRecoParam();
176 if(fRecoParam == 0x0)
177 {
178 AliFatal("No Reco Param found for PMD!!!");
179 }
180
8fbad6d3 181
8fbad6d3 182 AliPMDdigit *pmddigit;
183 TBranch *branch = digitsTree->GetBranch("PMDDigit");
184 branch->SetAddress(&fDigits);
185
186 ResetRecpoint();
187
8fbad6d3 188 Int_t bufsize = 16000;
189 TBranch * branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
190 TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize);
191
192 Int_t nmodules = (Int_t) digitsTree->GetEntries();
193
194 for (Int_t imodule = 0; imodule < nmodules; imodule++)
195 {
5254fcca 196
197 Int_t totADCMod = 0;
8fbad6d3 198 ResetCellADC();
199 digitsTree->GetEntry(imodule);
200 Int_t nentries = fDigits->GetLast();
201 for (Int_t ient = 0; ient < nentries+1; ient++)
202 {
203 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
204
205 det = pmddigit->GetDetector();
206 smn = pmddigit->GetSMNumber();
207 xpos = pmddigit->GetRow();
208 ypos = pmddigit->GetColumn();
209 adc = pmddigit->GetADC();
8a523d22 210
211 if(det < 0 || det > 1)
212 {
213 AliError(Form("*CPV/PRE NUMBER WRONG %d *",det));
214 continue;
215 }
72f10132 216 if(smn == -1 || smn > 23)
8a523d22 217 {
218 AliError(Form("*MODULE NUMBER WRONG %d *",smn));
219 continue;
220 }
221
72f10132 222 if(xpos < 0 || xpos > 47 || ypos < 0 || ypos > 95)
f0290c15 223 {
224 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
225 xpos, ypos));
226 continue;
227 }
228
35535af7 229 // Pedestal Subtraction
230 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,xpos,ypos);
37edc588 231 Int_t pedrms1 = (Int_t) pedmeanrms%100;
35535af7 232 Float_t pedrms = (Float_t)pedrms1/10.;
233 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
234 //printf("%f %f\n",pedmean, pedrms);
235
236 Float_t adc1 = adc - (pedmean + 3.0*pedrms);
237
7adbd8e9 238 // Hot cell - set the cell adc = 0
239 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,xpos,ypos);
8a523d22 240 if (hotflag == 1.) adc1 = 0;
7adbd8e9 241
8fbad6d3 242 // CALIBRATION
35535af7 243 Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
8fbad6d3 244 // printf("adc = %d gain = %f\n",adc,gain);
35535af7 245
246 adc = adc1*gain;
8fbad6d3 247
920e13db 248 fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
249 fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
8fbad6d3 250 fCellADC[xpos][ypos] = (Double_t) adc;
5254fcca 251
5fbd2db1 252 totADCMod += (Int_t) adc;
5254fcca 253
8fbad6d3 254 }
255
256 idet = det;
257 ismn = smn;
5254fcca 258
259 if (totADCMod <= 0) continue;
260
b9e2f33c 261 // Set the minimum noise cut per module before clustering
262
963fe679 263 // Int_t imod = idet*24 + ismn;
264
265
266 // Int_t cluspar = fRecoParam->GetPbPbParam()->GetClusteringParam();
267 //Int_t cluspar = fRecoParam->GetPPParam()->GetClusteringParam();
268 // Int_t cluspar = fRecoParam->GetCosmicParam()->GetClusteringParam();
b9e2f33c 269
270
963fe679 271 Float_t encut = 0.;
272 pmdclust->SetEdepCut(encut);
27a78deb 273 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,pmdcont);
8fbad6d3 274
275 Int_t nentries1 = pmdcont->GetEntries();
276
277 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
278
279 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
280 {
920e13db 281 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
8fbad6d3 282 idet = pmdcl->GetDetector();
283 ismn = pmdcl->GetSMN();
284 clusdata[0] = pmdcl->GetClusX();
285 clusdata[1] = pmdcl->GetClusY();
286 clusdata[2] = pmdcl->GetClusADC();
287 clusdata[3] = pmdcl->GetClusCells();
288 clusdata[4] = pmdcl->GetClusSigmaX();
289 clusdata[5] = pmdcl->GetClusSigmaY();
290
291 AddRecPoint(idet,ismn,clusdata);
292
293 Int_t ncell = (Int_t) clusdata[3];
27a78deb 294 if (ncell > 19) ncell = 19;
8fbad6d3 295 for(Int_t ihit = 0; ihit < ncell; ihit++)
296 {
297 Int_t celldataX = pmdcl->GetClusCellX(ihit);
298 Int_t celldataY = pmdcl->GetClusCellY(ihit);
920e13db 299 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
300 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
b0e4d1e1 301 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
302 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
8fbad6d3 303 }
304 branch2->Fill();
305 ResetRechit();
306 }
26e08752 307 pmdcont->Delete();
920e13db 308
8fbad6d3 309 branch1->Fill();
310 ResetRecpoint();
311
312 } // modules
313
920e13db 314
8fbad6d3 315 ResetCellADC();
8fbad6d3 316
317 // delete the pointers
318 delete pmdclust;
319 delete pmdcont;
8fbad6d3 320}
321// ------------------------------------------------------------------------- //
322
7e9508a7 323void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
324 TTree *clustersTree)
325{
326 // Converts RAW data to recpoints after running clustering
327 // algorithm on CPV and PREshower plane
328 //
2c1131dd 329 // This method is called at the time of reconstruction from RAW data
2332574a 330
7e9508a7 331
920e13db 332 AliPMDddldata *pmdddl = 0x0;
333 AliPMDcluster *pmdcl = 0x0;
5254fcca 334
5c5cadd5 335 Float_t clusdata[6];
df42ab21 336 TObjArray pmdddlcont;
7e9508a7 337
338 TObjArray *pmdcont = new TObjArray();
5254fcca 339
5c5cadd5 340 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
7e9508a7 341
08cf9354 342 // open the ddl file info to know the module
343 TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
344 ddlinfofileName += "/PMD/PMD_ddl_info.dat";
345
346 ifstream infileddl;
347 infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
348 if(!infileddl) AliError("Could not read the ddl info file");
349
350 Int_t ddlno;
351 Int_t modno;
352 Int_t modulePerDDL;
353 Int_t moduleddl[6];
354
355 for(Int_t jddl = 0; jddl < 6; jddl++)
356 {
357 if (infileddl.eof()) break;
358 infileddl >> ddlno >> modulePerDDL;
359 moduleddl[jddl] = modulePerDDL;
360
361 if (modulePerDDL == 0) continue;
362 for (Int_t im = 0; im < modulePerDDL; im++)
363 {
364 infileddl >> modno;
365 }
366 }
367
368 infileddl.close();
369
b9e2f33c 370 // Set the minimum noise cut per module before clustering
371
372 fRecoParam = AliPMDReconstructor::GetRecoParam();
373
374 if(fRecoParam == 0x0)
375 {
376 AliFatal("No Reco Param found for PMD!!!");
377 }
378
7e9508a7 379 ResetRecpoint();
380
381 Int_t bufsize = 16000;
5c5cadd5 382 TBranch *branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
383
384 TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize);
7e9508a7 385
7e9508a7 386 const Int_t kRow = 48;
387 const Int_t kCol = 96;
388
389 Int_t idet = 0;
390 Int_t iSMN = 0;
2332574a 391
722ccc67 392 Int_t indexDDL = -1;
393 AliPMDRawStream pmdinput(rawReader);
8fbad6d3 394
722ccc67 395 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
08cf9354 396 {
397 iSMN = moduleddl[indexDDL];
398
7e9508a7 399 Int_t ***precpvADC;
400 precpvADC = new int **[iSMN];
401 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
402 for (Int_t i=0; i<iSMN;i++)
403 {
404 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
405 }
406 for (Int_t i = 0; i < iSMN; i++)
407 {
408 for (Int_t j = 0; j < kRow; j++)
409 {
410 for (Int_t k = 0; k < kCol; k++)
411 {
412 precpvADC[i][j][k] = 0;
413 }
414 }
415 }
416 ResetCellADC();
2332574a 417
df42ab21 418 Int_t indexsmn = 0;
419 Int_t ientries = pmdddlcont.GetEntries();
420 for (Int_t ient = 0; ient < ientries; ient++)
7e9508a7 421 {
920e13db 422 pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
7e9508a7 423
df42ab21 424 Int_t det = pmdddl->GetDetector();
425 Int_t smn = pmdddl->GetSMN();
426 //Int_t mcm = pmdddl->GetMCM();
427 //Int_t chno = pmdddl->GetChannel();
428 Int_t row = pmdddl->GetRow();
429 Int_t col = pmdddl->GetColumn();
430 Int_t sig = pmdddl->GetSignal();
2c1131dd 431
72f10132 432
8a523d22 433 if(det < 0 || det > 1)
434 {
435 AliError(Form("*CPV/PRE NUMBER WRONG %d *",det));
436 continue;
437 }
72f10132 438 if(smn < 0 || smn > 23)
2c1131dd 439 {
440 AliError(Form("*MODULE NUMBER WRONG %d *",smn));
441 continue;
442 }
72f10132 443 if(row < 0 || row > 47 || col < 0 || col > 95)
f0290c15 444 {
445 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
446 row, col));
08cf9354 447
f0290c15 448 continue;
449 }
2c1131dd 450
72f10132 451
35535af7 452 // Pedestal Subtraction
453 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
37edc588 454 Int_t pedrms1 = (Int_t) pedmeanrms%100;
35535af7 455 Float_t pedrms = (Float_t)pedrms1/10.;
456 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
457
458 //printf("%f %f\n",pedmean, pedrms);
459
460 // Float_t sig1 = (Float_t) sig;
461 Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
462
8a523d22 463
7adbd8e9 464 // Hot cell - set the cell adc = 0
465 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
8a523d22 466 if (hotflag == 1.) sig1 = 0;
7adbd8e9 467
09a06455 468 // CALIBRATION
35535af7 469 Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
df42ab21 470 //printf("sig = %d gain = %f\n",sig,gain);
09a06455 471 sig = (Int_t) (sig1*gain);
7e9508a7 472
08cf9354 473 if (indexDDL == 0)
474 {
475 if (det != 0)
476 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
477 indexDDL, det));
478 if (iSMN == 6)
479 {
480 indexsmn = smn;
481 }
482 else if (iSMN == 12)
483 {
484 if (smn < 6)
485 indexsmn = smn;
486 else if (smn >= 18 && smn < 24)
487 indexsmn = smn-12;
488 }
489 }
490 else if (indexDDL >= 1 && indexDDL < 4)
7e9508a7 491 {
492 if (det != 0)
493 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
494 indexDDL, det));
495 indexsmn = smn - indexDDL * 6;
496 }
497 else if (indexDDL == 4)
498 {
499 if (det != 1)
500 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
501 indexDDL, det));
502 if (smn < 6)
503 {
504 indexsmn = smn;
505 }
df42ab21 506 else if (smn >= 18 && smn < 24)
7e9508a7 507 {
df42ab21 508 indexsmn = smn - 12;
7e9508a7 509 }
510 }
511 else if (indexDDL == 5)
512 {
513 if (det != 1)
514 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
515 indexDDL, det));
08cf9354 516 if (smn >= 6 && smn < 18)
7e9508a7 517 {
df42ab21 518 indexsmn = smn - 6;
7e9508a7 519 }
520 }
08cf9354 521
7e9508a7 522 precpvADC[indexsmn][row][col] = sig;
df42ab21 523 }
524
26e08752 525 pmdddlcont.Delete();
7e9508a7 526
5254fcca 527 Int_t totAdcMod = 0;
528
7e9508a7 529 Int_t ismn = 0;
78fc1b96 530 for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
7e9508a7 531 {
532 ResetCellADC();
5254fcca 533 totAdcMod = 0;
7e9508a7 534 for (Int_t irow = 0; irow < kRow; irow++)
535 {
536 for (Int_t icol = 0; icol < kCol; icol++)
537 {
920e13db 538 fCellTrack[irow][icol] = -1;
539 fCellPid[irow][icol] = -1;
540
7e9508a7 541 fCellADC[irow][icol] =
542 (Double_t) precpvADC[indexsmn][irow][icol];
5254fcca 543 totAdcMod += precpvADC[indexsmn][irow][icol];
7e9508a7 544 } // row
545 } // col
df42ab21 546
08cf9354 547 if (indexDDL == 0)
548 {
549 if (iSMN == 6)
550 {
551 ismn = indexsmn;
552 }
553 else if (iSMN == 12)
554 {
555
556 if (indexsmn < 6)
557 ismn = indexsmn;
558 else if (indexsmn >= 6 && indexsmn < 12)
559 ismn = indexsmn + 12;
560 }
561 idet = 0;
562 }
563 else if (indexDDL >= 1 && indexDDL < 4)
7e9508a7 564 {
565 ismn = indexsmn + indexDDL * 6;
566 idet = 0;
567 }
568 else if (indexDDL == 4)
569 {
570 if (indexsmn < 6)
571 {
572 ismn = indexsmn;
573 }
574 else if (indexsmn >= 6 && indexsmn < 12)
575 {
df42ab21 576 ismn = indexsmn + 12;
7e9508a7 577 }
578 idet = 1;
579 }
580 else if (indexDDL == 5)
581 {
08cf9354 582 ismn = indexsmn + 6;
7e9508a7 583 idet = 1;
584 }
585
5254fcca 586 if (totAdcMod <= 0) continue;
920e13db 587
b9e2f33c 588 Int_t imod = idet*24 + ismn;
589
963fe679 590 // Int_t cluspar = fRecoParam->GetPbPbParam()->GetClusteringParam();
591 // Int_t cluspar = fRecoParam->GetPPParam()->GetClusteringParam();
592 // Int_t cluspar = fRecoParam->GetCosmicParam()->GetClusteringParam();
593
594 Float_t encut = fNoiseCut->GetNoiseCut(imod);
b9e2f33c 595
963fe679 596 pmdclust->SetEdepCut(encut);
27a78deb 597 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,pmdcont);
920e13db 598
7e9508a7 599 Int_t nentries1 = pmdcont->GetEntries();
600
601 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
602
603 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
604 {
920e13db 605 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
7e9508a7 606 idet = pmdcl->GetDetector();
607 ismn = pmdcl->GetSMN();
608 clusdata[0] = pmdcl->GetClusX();
609 clusdata[1] = pmdcl->GetClusY();
610 clusdata[2] = pmdcl->GetClusADC();
611 clusdata[3] = pmdcl->GetClusCells();
5c5cadd5 612 clusdata[4] = pmdcl->GetClusSigmaX();
613 clusdata[5] = pmdcl->GetClusSigmaY();
7e9508a7 614
615 AddRecPoint(idet,ismn,clusdata);
09a06455 616
5c5cadd5 617 Int_t ncell = (Int_t) clusdata[3];
27a78deb 618 if (ncell > 19) ncell = 19;
5c5cadd5 619 for(Int_t ihit = 0; ihit < ncell; ihit++)
620 {
621 Int_t celldataX = pmdcl->GetClusCellX(ihit);
622 Int_t celldataY = pmdcl->GetClusCellY(ihit);
920e13db 623 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
624 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
b0e4d1e1 625 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
626 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
5c5cadd5 627 }
628 branch2->Fill();
629 ResetRechit();
630
7e9508a7 631 }
26e08752 632 pmdcont->Delete();
920e13db 633
5c5cadd5 634 branch1->Fill();
7e9508a7 635 ResetRecpoint();
636
637
638 } // smn
639
640 for (Int_t i=0; i<iSMN; i++)
641 {
642 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
643 }
644 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
c9e0bd24 645 delete [] precpvADC;
722ccc67 646
7e9508a7 647 } // DDL Loop
920e13db 648
7e9508a7 649
650 ResetCellADC();
651
652 // delete the pointers
653 delete pmdclust;
654 delete pmdcont;
01709453 655}
1758e4fe 656// ------------------------------------------------------------------------- //
1758e4fe 657void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
01709453 658{
b208c6a3 659 // Add Reconstructed points
660 //
01709453 661 TClonesArray &lrecpoints = *fRecpoints;
ed228cbc 662 AliPMDrecpoint1 *newrecpoint;
1758e4fe 663 newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
ed228cbc 664 new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
01709453 665 delete newrecpoint;
666}
1758e4fe 667// ------------------------------------------------------------------------- //
920e13db 668void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY,
b0e4d1e1 669 Int_t celldataTr, Int_t celldataPid,
670 Float_t celldataAdc)
5c5cadd5 671{
672 // Add associated cell hits to the Reconstructed points
673 //
674 TClonesArray &lrechits = *fRechits;
675 AliPMDrechit *newrechit;
b0e4d1e1 676 newrechit = new AliPMDrechit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
5c5cadd5 677 new(lrechits[fNhit++]) AliPMDrechit(newrechit);
678 delete newrechit;
679}
680// ------------------------------------------------------------------------- //
01709453 681void AliPMDClusterFinder::ResetCellADC()
682{
b208c6a3 683 // Reset the individual cell ADC value to zero
684 //
5e6a9312 685 for(Int_t irow = 0; irow < fgkRow; irow++)
01709453 686 {
5e6a9312 687 for(Int_t icol = 0; icol < fgkCol; icol++)
01709453 688 {
920e13db 689 fCellTrack[irow][icol] = -1;
690 fCellPid[irow][icol] = -1;
691 fCellADC[irow][icol] = 0.;
01709453 692 }
693 }
694}
1758e4fe 695// ------------------------------------------------------------------------- //
01709453 696void AliPMDClusterFinder::ResetRecpoint()
697{
b208c6a3 698 // Clear the list of reconstructed points
01709453 699 fNpoint = 0;
700 if (fRecpoints) fRecpoints->Clear();
701}
1758e4fe 702// ------------------------------------------------------------------------- //
5c5cadd5 703void AliPMDClusterFinder::ResetRechit()
704{
705 // Clear the list of reconstructed points
706 fNhit = 0;
707 if (fRechits) fRechits->Clear();
708}
709// ------------------------------------------------------------------------- //
55601d47 710void AliPMDClusterFinder::Load()
711{
ebd83c56 712 // Load all the *.root files
55601d47 713 //
714 fPMDLoader->LoadDigits("READ");
715 fPMDLoader->LoadRecPoints("recreate");
716}
717// ------------------------------------------------------------------------- //
01b56f5c 718void AliPMDClusterFinder::LoadClusters()
719{
720 // Load all the *.root files
721 //
722 fPMDLoader->LoadRecPoints("recreate");
723}
724// ------------------------------------------------------------------------- //
ebd83c56 725void AliPMDClusterFinder::UnLoad()
01709453 726{
b208c6a3 727 // Unload all the *.root files
728 //
ebd83c56 729 fPMDLoader->UnloadDigits();
730 fPMDLoader->UnloadRecPoints();
01709453 731}
1758e4fe 732// ------------------------------------------------------------------------- //
01b56f5c 733void AliPMDClusterFinder::UnLoadClusters()
734{
735 // Unload all the *.root files
736 //
737 fPMDLoader->UnloadRecPoints();
738}
739// ------------------------------------------------------------------------- //
35535af7 740AliPMDCalibData* AliPMDClusterFinder::GetCalibGain() const
09a06455 741{
742 // The run number will be centralized in AliCDBManager,
743 // you don't need to set it here!
744 // Added by ZA
35535af7 745 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Gain");
09a06455 746
0dd3d6f9 747 if(!entry) AliFatal("Calibration object retrieval failed! ");
09a06455 748
749 AliPMDCalibData *calibdata=0;
750 if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
751
0dd3d6f9 752 if (!calibdata) AliFatal("No calibration data from calibration database !");
09a06455 753
754 return calibdata;
755}
35535af7 756// ------------------------------------------------------------------------- //
35535af7 757AliPMDPedestal* AliPMDClusterFinder::GetCalibPed() const
758{
759 // The run number will be centralized in AliCDBManager,
760 // you don't need to set it here!
761 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ped");
762
763 if(!entry) AliFatal("Pedestal object retrieval failed!");
764
765 AliPMDPedestal *pedestal = 0;
766 if (entry) pedestal = (AliPMDPedestal*) entry->GetObject();
767
768 if (!pedestal) AliFatal("No pedestal data from pedestal database !");
769
770 return pedestal;
771}
7adbd8e9 772//--------------------------------------------------------------------//
773AliPMDHotData* AliPMDClusterFinder::GetCalibHot() const
774{
775 // The run number will be centralized in AliCDBManager,
776 // you don't need to set it here!
777 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Hot");
778
779 if(!entry) AliFatal("HotData object retrieval failed!");
780
781 AliPMDHotData *hot = 0;
782 if (entry) hot = (AliPMDHotData*) entry->GetObject();
783
784 if (!hot) AliFatal("No hot data from database !");
785
786 return hot;
787}
963fe679 788//--------------------------------------------------------------------//
789AliPMDNoiseCut* AliPMDClusterFinder::GetNoiseCut() const
790{
791 // The run number will be centralized in AliCDBManager,
792 // you don't need to set it here!
793 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/NoiseCut");
794
795 if(!entry) AliFatal("Noisecut object retrieval failed!");
796
797 AliPMDNoiseCut *ncut = 0;
798 if (entry) ncut = (AliPMDNoiseCut*) entry->GetObject();
799
800 if (!ncut) AliFatal("No noise cut data from database !");
801
802 return ncut;
803}
7adbd8e9 804