]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCclusterKr.cxx
o fix for coverity bug 19907
[u/mrichter/AliRoot.git] / TPC / AliTPCclusterKr.cxx
1 /**************************************************************************
2
3
4  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5
6
7  *                                                                        *
8
9
10  * Author: The ALICE Off-line Project.                                    *
11
12
13  * Contributors are mentioned in the code where appropriate.              *
14
15
16  *                                                                        *
17
18
19  * Permission to use, copy, modify and distribute this software and its   *
20
21
22  * documentation strictly for non-commercial purposes is hereby granted   *
23
24
25  * without fee, provided that the above copyright notice appears in all   *
26
27
28  * copies and that both the copyright notice and this permission notice   *
29
30
31  * appear in the supporting documentation. The authors make no claims     *
32
33
34  * about the suitability of this software for any purpose. It is          *
35
36
37  * provided "as is" without express or implied warranty.                  *
38
39
40  **************************************************************************/
41
42
43
44
45
46 /* $Id: AliTPCclusterKr.cxx,v 1.7 2008/01/22 17:24:53 matyja Exp $ */
47
48
49
50
51
52 //-----------------------------------------------------------------
53
54
55 //           Implementation of the TPC Kr cluster class
56
57
58 //
59
60
61 // Origin: Adam Matyja, INP PAN, adam.matyja@ifj.edu.pl
62
63
64 //-----------------------------------------------------------------
65
66
67
68
69
70 #include "AliTPCclusterKr.h"
71
72
73 #include "AliCluster.h"
74
75
76 #include "AliTPCvtpr.h"
77
78
79 #include "TObjArray.h"
80
81
82 //#include "TH1F.h"
83
84
85 #include "TMath.h"
86
87
88 #include "TArrayI.h"
89
90
91
92
93
94 ClassImp(AliTPCclusterKr)
95
96
97
98
99
100
101
102
103 AliTPCclusterKr::AliTPCclusterKr()
104
105
106 :AliCluster(),
107
108
109  fMax(),
110
111
112  fADCcluster(0),
113
114
115  fSec(0),
116
117
118  fNPads(0),
119
120
121  fNRows(0),
122
123
124  fTimebins1D(0),
125
126
127  fPads1D(0),
128
129
130  fPadRMS(0),
131
132
133  fRowRMS(0),
134
135
136  fTimebinRMS(0),
137
138
139  fSize(0),
140
141
142  fCenterX(0),
143
144
145  fCenterY(0),
146
147
148  fCenterT(0),
149
150
151  fCluster(0),
152
153
154  fTimeStamp(0),
155  fRun(0)
156
157
158 {
159
160
161 //
162
163
164 // default constructor
165
166
167 //
168
169
170   fCluster=new TObjArray();
171
172
173 }
174
175
176
177
178
179 AliTPCclusterKr::AliTPCclusterKr(const AliTPCclusterKr &param)
180
181
182 :AliCluster(param),
183
184
185  fMax(),
186
187
188  fADCcluster(0),
189
190
191  fSec(0),
192
193
194  fNPads(0),
195
196
197  fNRows(0),
198
199
200  fTimebins1D(0),
201
202
203  fPads1D(0),
204
205
206  fPadRMS(0),
207
208
209  fRowRMS(0),
210
211
212  fTimebinRMS(0),
213
214
215  fSize(0),
216
217
218  fCenterX(0),
219
220
221  fCenterY(0),
222
223
224  fCenterT(0),
225
226
227  fCluster(0),
228
229
230  fTimeStamp(0),
231  fRun(0)
232
233
234 {
235
236
237 //
238
239
240 // copy constructor
241
242
243 //
244
245
246   fADCcluster = param.fADCcluster;
247
248
249   fSec  = param.fSec ;
250
251
252   fNPads = param.fNPads;
253
254
255   fNRows = param.fNRows;
256
257
258   fMax = param.fMax;
259
260
261   //  fCluster = param.fCluster;
262
263
264   fCenterX = param.fCenterX;
265
266
267   fCenterY = param.fCenterY;
268
269
270   fCenterT = param.fCenterT;
271
272
273   fCluster=new TObjArray(*(param.fCluster));
274
275
276   fSize = param.fSize;
277
278
279   fTimebins1D = param.fTimebins1D;
280
281
282   fPads1D = param.fPads1D;
283
284
285   fPadRMS = param.fPadRMS;
286
287
288   fRowRMS = param.fRowRMS;
289
290
291   fTimebinRMS = param.fTimebinRMS;
292
293
294   fTimeStamp = param.fTimeStamp;
295   fRun = param.fRun;
296
297
298
299
300
301
302
303
304 AliTPCclusterKr &AliTPCclusterKr::operator = (const AliTPCclusterKr & param)
305
306
307 {
308
309
310   //
311
312
313   // assignment operator
314
315
316   // 
317   if (this == &param) return (*this);
318
319   (AliCluster&)(*this) = (AliCluster&)param;
320
321
322   fADCcluster = param.fADCcluster;
323
324
325   fSec  = param.fSec ;
326
327
328   fNPads = param.fNPads;
329
330
331   fNRows = param.fNRows;
332
333
334   fMax = param.fMax;
335
336
337   //  fCluster=param.fCluster;
338
339
340   fCenterX = param.fCenterX;
341
342
343   fCenterY = param.fCenterY;
344
345
346   fCenterT = param.fCenterT;
347
348
349   delete fCluster;
350
351
352   fCluster=new TObjArray(*(param.fCluster));
353
354
355   fSize=param.fSize;
356
357
358   fTimebins1D = param.fTimebins1D;
359
360
361   fPads1D = param.fPads1D;
362
363
364   fPadRMS = param.fPadRMS;
365
366
367   fRowRMS = param.fRowRMS;
368
369
370   fTimebinRMS = param.fTimebinRMS;
371
372
373   fTimeStamp = param.fTimeStamp;
374   fRun = param.fRun;
375
376
377   return (*this);
378
379
380 }
381
382
383
384
385
386 AliTPCclusterKr::~AliTPCclusterKr()
387
388
389 {
390
391
392   //
393
394
395   // destructor
396
397
398   //
399
400
401   if(fCluster) {
402
403
404     fCluster->SetOwner(kTRUE);
405
406
407     fCluster->Delete();
408
409
410     delete fCluster;
411
412
413   }
414
415
416   fCluster=0;
417
418
419 }
420
421
422
423
424
425 ////____________________________________________________________________________
426
427
428 void AliTPCclusterKr::SetCenter(){
429
430
431   //
432
433
434   // calculate geometrical center of the cluster
435
436
437   //
438
439
440   Double_t rX=0;
441
442
443   Double_t rY=0;
444
445
446   Double_t rT=0;
447
448
449
450
451
452   Short_t adc;
453
454
455   fADCcluster=0;
456
457
458   for(Int_t iter = 0; iter < fCluster->GetEntriesFast(); ++iter) {
459
460
461     AliTPCvtpr *iclus=(AliTPCvtpr *)fCluster->At(iter);
462
463
464
465
466
467     //for( std::vector<AliTPCvtpr*>::iterator iclus  = fCluster.begin();
468
469
470     //iclus != fCluster.end(); ++iclus ) {
471
472
473     adc = (iclus)->GetAdc();
474
475
476     fADCcluster+=adc;
477
478
479     rX += ((iclus)->GetX() * adc);
480
481
482     rY += ((iclus)->GetY() * adc);
483
484
485     rT += ((iclus)->GetT() * adc);
486
487
488   }
489   if(fADCcluster){ 
490
491     fCenterX=rX/fADCcluster;
492
493
494     fCenterY=rY/fADCcluster;
495
496
497     fCenterT=rT/fADCcluster;
498   }
499
500
501
502
503
504   return;
505
506
507 }
508
509
510
511
512
513 void AliTPCclusterKr::SetPadRMS(){
514
515
516   //
517
518
519   // calculate RMS in pad direction
520
521
522   //
523
524
525   //  TH1F *histo= new TH1F("","",200,0,200);
526
527
528   TArrayI *array= new TArrayI(fCluster->GetEntriesFast());
529
530
531   for(Int_t i=0;i<fCluster->GetEntriesFast();i++)
532
533
534     {
535
536
537       array->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetPad(),i);
538
539
540       //histo->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetPad() );
541
542
543     }
544
545
546   //  fPadRMS=histo->GetRMS();
547
548
549   fPadRMS=TMath::RMS(array->GetSize(),array->GetArray());
550
551
552   //  delete histo;
553
554
555   delete array;
556
557
558   return;
559
560
561 }
562
563
564
565
566
567 void AliTPCclusterKr::SetRowRMS(){
568
569
570   //
571
572
573   // calculate RMS in row direction
574
575
576   //
577
578
579   TArrayI *array= new TArrayI(fCluster->GetEntriesFast());
580
581
582   //  TH1F *histo= new TH1F("","",120,0,120);
583
584
585   for(Int_t i=0;i<fCluster->GetEntriesFast();i++)
586
587
588     {
589
590
591       array->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetRow(),i);
592
593
594       //      histo->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetRow() );
595
596
597     }
598
599
600   //  fRowRMS=histo->GetRMS();
601
602
603   fRowRMS=TMath::RMS(array->GetSize(),array->GetArray());
604
605
606   //  delete histo;
607
608
609   delete array;
610
611
612   return;
613
614
615 }
616
617
618
619
620
621 void AliTPCclusterKr::SetTimebinRMS(){
622
623
624   //
625
626
627   // calculate RMS in timebin direction
628
629
630   //
631
632
633   TArrayI *array= new TArrayI(fCluster->GetEntriesFast());
634
635
636   //  TH1F *histo= new TH1F("","",1000,0,1000);
637
638
639   for(Int_t i=0;i<fCluster->GetEntriesFast();i++)
640
641
642     {
643
644
645       array->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetTime(),i);
646
647
648       //      histo->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetTime() );
649
650
651     }
652
653
654   fTimebinRMS=TMath::RMS(array->GetSize(),array->GetArray());
655
656
657   //histo->GetRMS();
658
659
660   //  delete histo;
661
662
663   delete array;
664
665
666   return;
667
668
669 }
670
671
672
673
674
675 void AliTPCclusterKr::SetRMS(){
676
677
678   //
679
680
681   // calculate RMS in pad,row,timebin direction
682
683
684   //
685
686
687   TArrayI *arrayPad = new TArrayI(fCluster->GetEntriesFast());
688
689
690   TArrayI *arrayRow = new TArrayI(fCluster->GetEntriesFast());
691
692
693   TArrayI *arrayTime= new TArrayI(fCluster->GetEntriesFast());
694
695
696   //  TH1F *histoPad= new TH1F("p","p",200,0,200);
697
698
699   //  TH1F *histoRow= new TH1F("r","r",120,0,120);
700
701
702   //  TH1F *histoTime= new TH1F("t","t",1000,0,1000);
703
704
705   for(Int_t i=0;i<fCluster->GetEntriesFast();i++)
706
707
708     {
709
710
711       arrayPad->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetPad(),i);
712
713
714       arrayRow->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetRow(),i);
715
716
717       arrayTime->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetTime(),i);
718
719
720
721
722
723       //histoPad->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetPad() );
724
725
726       //histoRow->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetRow() );
727
728
729       //histoTime->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetTime() );
730
731
732     }
733
734
735   //  fPadRMS=histoPad->GetRMS();
736
737
738   fPadRMS=TMath::RMS(arrayPad->GetSize(),arrayPad->GetArray());
739
740
741   fRowRMS=TMath::RMS(arrayRow->GetSize(),arrayRow->GetArray());
742
743
744     //histoRow->GetRMS();
745
746
747   fTimebinRMS=TMath::RMS(arrayTime->GetSize(),arrayTime->GetArray());
748
749
750     //histoTime->GetRMS();
751
752
753
754
755
756   delete arrayPad;
757
758
759   delete arrayRow;
760
761
762   delete arrayTime;
763
764
765   //  delete histoPad;
766
767
768   //  delete histoRow;
769
770
771   //  delete histoTime;
772
773
774
775
776
777   return;
778
779
780 }
781
782
783
784
785
786
787
788
789 void AliTPCclusterKr::Set1D(){
790
791
792   //
793
794
795   //
796
797
798   //
799
800
801   Short_t maxTime=0;
802
803
804   Short_t minTime=1000;
805
806
807   Short_t maxPad=0;
808
809
810   Short_t minPad=1000;
811
812
813  
814
815
816   for(Int_t i=0;i<fCluster->GetEntriesFast();i++)
817
818
819     {
820
821
822       if(((AliTPCvtpr *)(fCluster->At(i)))->GetPad()>maxPad)maxPad   =((AliTPCvtpr *)(fCluster->At(i)))->GetPad();
823
824
825       if(((AliTPCvtpr *)(fCluster->At(i)))->GetPad()<minPad)minPad   =((AliTPCvtpr *)(fCluster->At(i)))->GetPad();
826
827
828       if(((AliTPCvtpr *)(fCluster->At(i)))->GetTime()>maxTime)maxTime=((AliTPCvtpr *)(fCluster->At(i)))->GetTime();
829
830
831       if(((AliTPCvtpr *)(fCluster->At(i)))->GetTime()<minTime)minTime=((AliTPCvtpr *)(fCluster->At(i)))->GetTime();
832
833
834     }
835
836
837   fPads1D=maxPad-minPad+1;
838
839
840   fTimebins1D=maxTime-minTime+1;
841
842
843   return;
844
845
846 }
847
848