]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMDClusterFinder.cxx
439ed43580f991f5da1a6af547324d55558456ea
[u/mrichter/AliRoot.git] / PMD / AliPMDClusterFinder.cxx
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
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>
26 #include <TTree.h>
27 #include <TObjArray.h>
28 #include <TClonesArray.h>
29
30 #include "AliLog.h"
31 #include "AliRunLoader.h"
32 #include "AliLoader.h"
33 #include "AliRawReader.h"
34
35 #include "AliPMDdigit.h"
36 #include "AliPMDClusterFinder.h"
37 #include "AliPMDClustering.h"
38 #include "AliPMDClusteringV1.h"
39 #include "AliPMDcluster.h"
40 #include "AliPMDrecpoint1.h"
41 #include "AliPMDrechit.h"
42 #include "AliPMDRawStream.h"
43 #include "AliPMDCalibData.h"
44 #include "AliPMDddldata.h"
45
46 #include "AliCDBManager.h"
47 #include "AliCDBEntry.h"
48
49
50
51 ClassImp(AliPMDClusterFinder)
52
53 AliPMDClusterFinder::AliPMDClusterFinder():
54   fRunLoader(0),
55   fPMDLoader(0),
56   fCalibData(GetCalibData()),
57   fTreeD(0),
58   fTreeR(0),
59   fDigits(new TClonesArray("AliPMDdigit", 1000)),
60   fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
61   fRechits(new TClonesArray("AliPMDrechit", 1000)),
62   fNpoint(0),
63   fNhit(0),
64   fDetNo(0),
65   fEcut(0.)
66 {
67 //
68 // Constructor
69 //
70 }
71 // ------------------------------------------------------------------------- //
72 AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
73   fRunLoader(runLoader),
74   fPMDLoader(runLoader->GetLoader("PMDLoader")),
75   fCalibData(GetCalibData()),
76   fTreeD(0),
77   fTreeR(0),
78   fDigits(new TClonesArray("AliPMDdigit", 1000)),
79   fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
80   fRechits(new TClonesArray("AliPMDrechit", 1000)),
81   fNpoint(0),
82   fNhit(0),
83   fDetNo(0),
84   fEcut(0.)
85 {
86 //
87 // Constructor
88 //
89 }
90 // ------------------------------------------------------------------------- //
91 AliPMDClusterFinder::AliPMDClusterFinder(const AliPMDClusterFinder & /*finder*/):
92   TObject(/*finder*/)
93 {
94   // copy constructor
95   AliError("Copy constructor not allowed");
96 }
97 // ------------------------------------------------------------------------- //
98 AliPMDClusterFinder &AliPMDClusterFinder::operator=(const AliPMDClusterFinder & /*finder*/)
99 {
100  // assignment op
101   AliError("Assignment Operator not allowed");
102   return *this;
103 }
104 // ------------------------------------------------------------------------- //
105 AliPMDClusterFinder::~AliPMDClusterFinder()
106 {
107   // Destructor
108   if (fDigits)
109     {
110       fDigits->Delete();
111       delete fDigits;
112       fDigits=0;
113     }
114   if (fRecpoints)
115     {
116       fRecpoints->Delete();
117       delete fRecpoints;
118       fRecpoints=0;
119     }
120   if (fRechits)
121     {
122       fRechits->Delete();
123       delete fRechits;
124       fRechits=0;
125     }
126 }
127 // ------------------------------------------------------------------------- //
128
129 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
130 {
131   // Converts digits to recpoints after running clustering
132   // algorithm on CPV plane and PREshower plane
133   //
134   Int_t    det = 0,smn = 0;
135   Int_t    xpos,ypos;
136   Float_t  adc;
137   Int_t    ismn;
138   Int_t    idet;
139   Float_t  clusdata[6];
140
141   TObjArray *pmdcont = new TObjArray();
142   AliPMDClustering *pmdclust = new AliPMDClusteringV1();
143
144   pmdclust->SetEdepCut(fEcut);
145
146   fRunLoader->GetEvent(ievt);
147
148
149   fTreeD = fPMDLoader->TreeD();
150   if (fTreeD == 0x0)
151     {
152       AliFatal("AliPMDClusterFinder: Can not get TreeD");
153
154     }
155   AliPMDdigit  *pmddigit;
156   TBranch *branch = fTreeD->GetBranch("PMDDigit");
157   branch->SetAddress(&fDigits);
158
159   ResetRecpoint();
160
161   fTreeR = fPMDLoader->TreeR();
162   if (fTreeR == 0x0)
163     {
164       fPMDLoader->MakeTree("R");
165       fTreeR = fPMDLoader->TreeR();
166     }
167
168   Int_t bufsize = 16000;
169   TBranch * branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); 
170   TBranch * branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize); 
171
172   Int_t nmodules = (Int_t) fTreeD->GetEntries();
173
174   for (Int_t imodule = 0; imodule < nmodules; imodule++)
175     {
176       ResetCellADC();
177       fTreeD->GetEntry(imodule); 
178       Int_t nentries = fDigits->GetLast();
179       for (Int_t ient = 0; ient < nentries+1; ient++)
180         {
181           pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
182           
183           det    = pmddigit->GetDetector();
184           smn    = pmddigit->GetSMNumber();
185           xpos   = pmddigit->GetRow();
186           ypos   = pmddigit->GetColumn();
187           adc    = pmddigit->GetADC();
188           
189           // CALIBRATION
190           Float_t gain = fCalibData->GetGainFact(det,smn,xpos,ypos);
191          // printf("adc = %d gain = %f\n",adc,gain);
192           
193           adc = adc*gain;
194
195
196           //Int_t trno   = pmddigit->GetTrackNumber();
197           fCellADC[xpos][ypos] = (Double_t) adc;
198         }
199
200       idet = det;
201       ismn = smn;
202       pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
203       
204       Int_t nentries1 = pmdcont->GetEntries();
205
206       AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
207
208       for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
209         {
210           AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
211           idet        = pmdcl->GetDetector();
212           ismn        = pmdcl->GetSMN();
213           clusdata[0] = pmdcl->GetClusX();
214           clusdata[1] = pmdcl->GetClusY();
215           clusdata[2] = pmdcl->GetClusADC();
216           clusdata[3] = pmdcl->GetClusCells();
217           clusdata[4] = pmdcl->GetClusSigmaX();
218           clusdata[5] = pmdcl->GetClusSigmaY();
219
220           AddRecPoint(idet,ismn,clusdata);
221
222           Int_t ncell = (Int_t) clusdata[3];
223           for(Int_t ihit = 0; ihit < ncell; ihit++)
224             {
225               Int_t celldataX = pmdcl->GetClusCellX(ihit);
226               Int_t celldataY = pmdcl->GetClusCellY(ihit);
227               AddRecHit(celldataX, celldataY);
228             }
229           branch2->Fill();
230           ResetRechit();
231         }
232       pmdcont->Clear();
233       
234       branch1->Fill();
235       ResetRecpoint();
236
237     } // modules
238
239   ResetCellADC();
240   fPMDLoader = fRunLoader->GetLoader("PMDLoader");  
241   fPMDLoader->WriteRecPoints("OVERWRITE");
242
243   //   delete the pointers
244   delete pmdclust;
245   delete pmdcont;
246     
247 }
248 // ------------------------------------------------------------------------- //
249
250 void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
251                                            TTree *clustersTree)
252 {
253   // Converts RAW data to recpoints after running clustering
254   // algorithm on CPV and PREshower plane
255   //
256
257   Float_t  clusdata[6];
258   TObjArray pmdddlcont;
259
260   TObjArray *pmdcont = new TObjArray();
261   AliPMDClustering *pmdclust = new AliPMDClusteringV1();
262
263   pmdclust->SetEdepCut(fEcut);
264
265   ResetRecpoint();
266
267   Int_t bufsize = 16000;
268   TBranch *branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize); 
269
270   TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize); 
271
272   const Int_t kDDL = 6;
273   const Int_t kRow = 48;
274   const Int_t kCol = 96;
275
276   Int_t idet = 0;
277   Int_t iSMN = 0;
278   
279   for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
280     {
281       if (indexDDL < 4)
282         {
283           iSMN = 6;
284         }
285       else if (indexDDL >= 4)
286         {
287           iSMN = 12;
288         }
289       Int_t ***precpvADC;
290       precpvADC = new int **[iSMN];
291       for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
292       for (Int_t i=0; i<iSMN;i++)
293         {
294           for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
295         }
296       for (Int_t i = 0; i < iSMN; i++)
297         {
298           for (Int_t j = 0; j < kRow; j++)
299             {
300               for (Int_t k = 0; k < kCol; k++)
301                 {
302                   precpvADC[i][j][k] = 0;
303                 }
304             }
305         }
306       ResetCellADC();
307       rawReader->Reset();
308       AliPMDRawStream pmdinput(rawReader);
309       rawReader->Select("PMD", indexDDL, indexDDL);
310       pmdinput.DdlData(&pmdddlcont);
311       Int_t indexsmn = 0;
312       Int_t ientries = pmdddlcont.GetEntries();
313       for (Int_t ient = 0; ient < ientries; ient++)
314         {
315           AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
316           
317           Int_t det = pmdddl->GetDetector();
318           Int_t smn = pmdddl->GetSMN();
319           //Int_t mcm = pmdddl->GetMCM();
320           //Int_t chno = pmdddl->GetChannel();
321           Int_t row = pmdddl->GetRow();
322           Int_t col = pmdddl->GetColumn();
323           Int_t sig = pmdddl->GetSignal();
324
325           Float_t sig1 = (Float_t) sig;
326           // CALIBRATION
327           Float_t gain = fCalibData->GetGainFact(det,smn,row,col);
328           //printf("sig = %d gain = %f\n",sig,gain);
329           sig = (Int_t) (sig1*gain);
330
331           if (indexDDL < 4)
332             {
333               if (det != 0)
334                 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
335                               indexDDL, det));
336               indexsmn = smn - indexDDL * 6;
337             }
338           else if (indexDDL == 4)
339             {
340               if (det != 1)
341                 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
342                               indexDDL, det));
343               if (smn < 6)
344                 {
345                   indexsmn = smn;
346                 }
347               else if (smn >= 18 && smn < 24)
348                 {
349                   indexsmn = smn - 12;
350                 }
351             }
352           else if (indexDDL == 5)
353             {
354               if (det != 1)
355                 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
356                               indexDDL, det));
357               if (smn >= 6 && smn < 12)
358                 {
359                   indexsmn = smn - 6;
360                 }
361               else if (smn >= 12 && smn < 18)
362                 {
363                   indexsmn = smn - 6;
364                 }
365             }         
366           precpvADC[indexsmn][row][col] = sig;
367         }
368       
369       pmdddlcont.Clear();
370
371       Int_t ismn = 0;
372       for (Int_t indexsmn = 0; indexsmn < iSMN; indexsmn++)
373         {
374           ResetCellADC();
375           for (Int_t irow = 0; irow < kRow; irow++)
376             {
377               for (Int_t icol = 0; icol < kCol; icol++)
378                 {
379                   fCellADC[irow][icol] = 
380                     (Double_t) precpvADC[indexsmn][irow][icol];
381                 } // row
382             }     // col
383           
384           if (indexDDL < 4)
385             {
386               ismn = indexsmn + indexDDL * 6;
387               idet = 0;
388             }
389           else if (indexDDL == 4)
390             {
391               if (indexsmn < 6)
392                 {
393                   ismn = indexsmn;
394                 }
395               else if (indexsmn >= 6 && indexsmn < 12)
396                 {
397                   ismn = indexsmn + 12;
398                 }
399               idet = 1;
400             }
401           else if (indexDDL == 5)
402             {
403               if (indexsmn < 6)
404                 {
405                   ismn = indexsmn + 6;
406                 }
407               else if (indexsmn >= 6 && indexsmn < 12)
408                 {
409                   ismn = indexsmn + 6;
410                 }
411               idet = 1;
412             }
413
414           pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
415           Int_t nentries1 = pmdcont->GetEntries();
416
417           AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
418
419           for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
420             {
421               AliPMDcluster *pmdcl = 
422                 (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
423               idet        = pmdcl->GetDetector();
424               ismn        = pmdcl->GetSMN();
425               clusdata[0] = pmdcl->GetClusX();
426               clusdata[1] = pmdcl->GetClusY();
427               clusdata[2] = pmdcl->GetClusADC();
428               clusdata[3] = pmdcl->GetClusCells();
429               clusdata[4] = pmdcl->GetClusSigmaX();
430               clusdata[5] = pmdcl->GetClusSigmaY();
431
432               AddRecPoint(idet,ismn,clusdata);
433
434               Int_t ncell = (Int_t) clusdata[3];
435               for(Int_t ihit = 0; ihit < ncell; ihit++)
436                 {
437                   Int_t celldataX = pmdcl->GetClusCellX(ihit);
438                   Int_t celldataY = pmdcl->GetClusCellY(ihit);
439                   AddRecHit(celldataX, celldataY);
440                 }
441               branch2->Fill();
442               ResetRechit();
443
444             }
445           pmdcont->Clear();
446           
447           branch1->Fill();
448           ResetRecpoint();
449
450
451         } // smn
452
453       for (Int_t i=0; i<iSMN; i++)
454         {
455           for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
456         }
457       for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
458       delete precpvADC;
459     } // DDL Loop
460   
461   ResetCellADC();
462   
463   //   delete the pointers
464   delete pmdclust;
465   delete pmdcont;
466
467 }
468 // ------------------------------------------------------------------------- //
469
470 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
471 {
472   // Converts RAW data to recpoints after running clustering
473   // algorithm on CPV and PREshower plane
474   //
475
476   Float_t  clusdata[6];
477   TObjArray pmdddlcont;
478   TObjArray *pmdcont = new TObjArray();
479
480   AliPMDClustering *pmdclust = new AliPMDClusteringV1();
481
482   pmdclust->SetEdepCut(fEcut);
483
484   fRunLoader->GetEvent(ievt);
485
486   ResetRecpoint();
487
488   fTreeR = fPMDLoader->TreeR();
489   if (fTreeR == 0x0)
490     {
491       fPMDLoader->MakeTree("R");
492       fTreeR = fPMDLoader->TreeR();
493     }
494   Int_t bufsize = 16000;
495   TBranch *branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); 
496   TBranch *branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize); 
497
498   const Int_t kDDL = 6;
499   const Int_t kRow = 48;
500   const Int_t kCol = 96;
501
502   Int_t idet = 0;
503   Int_t iSMN = 0;
504   
505   for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
506     {
507       if (indexDDL < 4)
508         {
509           iSMN = 6;
510         }
511       else if (indexDDL >= 4)
512         {
513           iSMN = 12;
514         }
515       Int_t ***precpvADC;
516       precpvADC = new int **[iSMN];
517       for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
518       for (Int_t i=0; i<iSMN;i++)
519         {
520           for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
521         }
522       for (Int_t i = 0; i < iSMN; i++)
523         {
524           for (Int_t j = 0; j < kRow; j++)
525             {
526               for (Int_t k = 0; k < kCol; k++)
527                 {
528                   precpvADC[i][j][k] = 0;
529                 }
530             }
531         }
532       ResetCellADC();
533       rawReader->Reset();
534       AliPMDRawStream pmdinput(rawReader);
535       rawReader->Select("PMD", indexDDL, indexDDL);
536       
537       pmdinput.DdlData(&pmdddlcont);
538     
539       Int_t indexsmn = 0;
540       Int_t ientries = pmdddlcont.GetEntries();
541       for (Int_t ient = 0; ient < ientries; ient++)
542         {
543           AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
544           
545           Int_t det = pmdddl->GetDetector();
546           Int_t smn = pmdddl->GetSMN();
547           //Int_t mcm = pmdddl->GetMCM();
548           //Int_t chno = pmdddl->GetChannel();
549           Int_t row = pmdddl->GetRow();
550           Int_t col = pmdddl->GetColumn();
551           Int_t sig = pmdddl->GetSignal();
552
553           Float_t sig1 = (Float_t) sig;
554           // CALIBRATION
555           Float_t gain = fCalibData->GetGainFact(det,smn,row,col);
556           //printf("sig = %d gain = %f\n",sig,gain);
557           sig = (Int_t) (sig1*gain);
558
559
560           if (indexDDL < 4)
561             {
562               if (det != 0)
563                 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
564                               indexDDL, det));
565               indexsmn = smn - indexDDL * 6;
566             }
567           else if (indexDDL == 4)
568             {
569               if (det != 1)
570                 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
571                               indexDDL, det));
572               if (smn < 6)
573                 {
574                   indexsmn = smn;
575                 }
576               else if (smn >= 18 && smn < 24)
577                 {
578                   indexsmn = smn - 12;
579                 }
580             }
581           else if (indexDDL == 5)
582             {
583               if (det != 1)
584                 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
585                               indexDDL, det));
586               if (smn >= 6 && smn < 12)
587                 {
588                   indexsmn = smn - 6;
589                 }
590               else if (smn >= 12 && smn < 18)
591                 {
592                   indexsmn = smn - 6;
593                 }
594             }         
595           precpvADC[indexsmn][row][col] = sig;
596
597         }
598       
599       pmdddlcont.Clear();
600
601       Int_t ismn = 0;
602       for (Int_t indexsmn = 0; indexsmn < iSMN; indexsmn++)
603         {
604           ResetCellADC();
605           for (Int_t irow = 0; irow < kRow; irow++)
606             {
607               for (Int_t icol = 0; icol < kCol; icol++)
608                 {
609                   fCellADC[irow][icol] = 
610                     (Double_t) precpvADC[indexsmn][irow][icol];
611                 } // row
612             }     // col
613
614           
615           if (indexDDL < 4)
616             {
617               ismn = indexsmn + indexDDL * 6;
618               idet = 0;
619             }
620           else if (indexDDL == 4)
621             {
622               if (indexsmn < 6)
623                 {
624                   ismn = indexsmn;
625                 }
626               else if (indexsmn >= 6 && indexsmn < 12)
627                 {
628                   ismn = indexsmn + 12;
629                 }
630               idet = 1;
631             }
632           else if (indexDDL == 5)
633             {
634               if (indexsmn < 6)
635                 {
636                   ismn = indexsmn + 6;
637                 }
638               else if (indexsmn >= 6 && indexsmn < 12)
639                 {
640                   ismn = indexsmn + 6;
641                 }
642               idet = 1;
643             }
644
645           pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
646           Int_t nentries1 = pmdcont->GetEntries();
647
648           AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
649
650           for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
651             {
652               AliPMDcluster *pmdcl = 
653                 (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
654               idet        = pmdcl->GetDetector();
655               ismn        = pmdcl->GetSMN();
656               clusdata[0] = pmdcl->GetClusX();
657               clusdata[1] = pmdcl->GetClusY();
658               clusdata[2] = pmdcl->GetClusADC();
659               clusdata[3] = pmdcl->GetClusCells();
660               clusdata[4] = pmdcl->GetClusSigmaX();
661               clusdata[5] = pmdcl->GetClusSigmaY();
662
663               AddRecPoint(idet,ismn,clusdata);
664
665               Int_t ncell = (Int_t) clusdata[3];
666               for(Int_t ihit = 0; ihit < ncell; ihit++)
667                 {
668                   Int_t celldataX = pmdcl->GetClusCellX(ihit);
669                   Int_t celldataY = pmdcl->GetClusCellY(ihit);
670                   AddRecHit(celldataX, celldataY);
671                 }
672               branch2->Fill();
673               ResetRechit();
674
675             }
676           pmdcont->Clear();
677           
678           branch1->Fill();
679           ResetRecpoint();
680
681
682         } // smn
683
684       for (Int_t i=0; i<iSMN; i++)
685         {
686           for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
687         }
688       for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
689       delete precpvADC;
690     } // DDL Loop
691   
692   ResetCellADC();
693   
694   fPMDLoader = fRunLoader->GetLoader("PMDLoader");  
695   fPMDLoader->WriteRecPoints("OVERWRITE");
696
697   //   delete the pointers
698   delete pmdclust;
699   delete pmdcont;
700
701 }
702 // ------------------------------------------------------------------------- //
703 void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
704 {
705   fEcut = ecut;
706 }
707 // ------------------------------------------------------------------------- //
708 void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
709 {
710   // Add Reconstructed points
711   //
712   TClonesArray &lrecpoints = *fRecpoints;
713   AliPMDrecpoint1 *newrecpoint;
714   newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
715   new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
716   delete newrecpoint;
717 }
718 // ------------------------------------------------------------------------- //
719 void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY)
720 {
721   // Add associated cell hits to the Reconstructed points
722   //
723   TClonesArray &lrechits = *fRechits;
724   AliPMDrechit *newrechit;
725   newrechit = new AliPMDrechit(celldataX, celldataY);
726   new(lrechits[fNhit++]) AliPMDrechit(newrechit);
727   delete newrechit;
728 }
729 // ------------------------------------------------------------------------- //
730 void AliPMDClusterFinder::ResetCellADC()
731 {
732   // Reset the individual cell ADC value to zero
733   //
734   for(Int_t irow = 0; irow < fgkRow; irow++)
735     {
736       for(Int_t icol = 0; icol < fgkCol; icol++)
737         {
738           fCellADC[irow][icol] = 0.;
739         }
740     }
741 }
742 // ------------------------------------------------------------------------- //
743
744 void AliPMDClusterFinder::ResetRecpoint()
745 {
746   // Clear the list of reconstructed points
747   fNpoint = 0;
748   if (fRecpoints) fRecpoints->Clear();
749 }
750 // ------------------------------------------------------------------------- //
751 void AliPMDClusterFinder::ResetRechit()
752 {
753   // Clear the list of reconstructed points
754   fNhit = 0;
755   if (fRechits) fRechits->Clear();
756 }
757 // ------------------------------------------------------------------------- //
758 void AliPMDClusterFinder::Load()
759 {
760   // Load all the *.root files
761   //
762   fPMDLoader->LoadDigits("READ");
763   fPMDLoader->LoadRecPoints("recreate");
764 }
765 // ------------------------------------------------------------------------- //
766 void AliPMDClusterFinder::LoadClusters()
767 {
768   // Load all the *.root files
769   //
770   fPMDLoader->LoadRecPoints("recreate");
771 }
772 // ------------------------------------------------------------------------- //
773 void AliPMDClusterFinder::UnLoad()
774 {
775   // Unload all the *.root files
776   //
777   fPMDLoader->UnloadDigits();
778   fPMDLoader->UnloadRecPoints();
779 }
780 // ------------------------------------------------------------------------- //
781 void AliPMDClusterFinder::UnLoadClusters()
782 {
783   // Unload all the *.root files
784   //
785   fPMDLoader->UnloadRecPoints();
786 }
787 // ------------------------------------------------------------------------- //
788
789 AliPMDCalibData* AliPMDClusterFinder::GetCalibData() const
790 {
791   // The run number will be centralized in AliCDBManager,
792   // you don't need to set it here!
793   // Added by ZA
794   AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
795   
796   if(!entry){
797     AliWarning("Calibration object retrieval failed! Dummy calibration will be used.");
798     
799     // this just remembers the actual default storage. No problem if it is null.
800     AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage();
801     AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
802     
803     entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
804     
805     // now reset the original default storage to AliCDBManager...
806     AliCDBManager::Instance()->SetDefaultStorage(origStorage);  
807   }
808   
809   AliPMDCalibData *calibdata=0;
810   if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
811   
812   if (!calibdata)  AliError("No calibration data from calibration database !");
813   
814   return calibdata;
815 }