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