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