]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDdEdxCalibHistArray.cxx
Change THnSparseS to THnSparseF (Xianguo)
[u/mrichter/AliRoot.git] / TRD / AliTRDdEdxCalibHistArray.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 // xx
18 // xx
19 // xx
20 // xx
21 // xx
22 //
23 //  Xianguo Lu 
24 //  lu@physi.uni-heidelberg.de
25 //  Xianguo.Lu@cern.ch
26 //  
27 //
28 #include "THnBase.h"
29 #include "THnSparse.h"
30 #include "TCollection.h"
31
32 #include "AliTRDdEdxBaseUtils.h"
33 #include "AliTRDdEdxCalibHistArray.h"
34
35 ClassImp(AliTRDdEdxCalibHistArray);
36
37 AliTRDdEdxCalibHistArray::AliTRDdEdxCalibHistArray(const Bool_t kNoInv): 
38   TObjArray(kNoInv ? 4: 8)
39 {
40   //
41   //constructor
42   //
43   SetName(GetArrayName());
44   SetOwner(kTRUE);
45
46   const Int_t    nbin[2]={AliTRDdEdxBaseUtils::NTRDtimebin(), 11250};
47   const Double_t xmin[2]={0,       0};
48   const Double_t xmax[2]={nbin[0], 20};
49
50   for(Int_t iter=0; iter<GetSize(); iter++){
51     THnBase *hi = new THnSparseF(GetNameAt(iter), "", 2, nbin, xmin, xmax);
52     AddAt(hi, iter);
53   }
54 }
55
56 AliTRDdEdxCalibHistArray::AliTRDdEdxCalibHistArray(const AliTRDdEdxCalibHistArray &obj): 
57   TObjArray(obj)
58 {
59   //
60   //copy constructor
61   //
62 }
63
64 AliTRDdEdxCalibHistArray & AliTRDdEdxCalibHistArray::operator=(const AliTRDdEdxCalibHistArray &obj)
65 {
66   //
67   //assignment operator
68   //
69
70   if(&obj == this) return *this;
71
72   TObjArray::operator=(obj);
73
74   return *this;
75 }
76
77 Long64_t AliTRDdEdxCalibHistArray::Merge(const TCollection* list) 
78 {
79   //
80   // Merge list of objects (needed by PROOF)
81   //
82
83   if(!list)
84     return 0;
85   
86   if(list->IsEmpty())
87     return 1;
88   
89   TIterator* iter = list->MakeIterator();
90   TObject* obj = 0;
91   
92   Int_t count=0;
93   while((obj = iter->Next()) != 0) 
94     {
95       AliTRDdEdxCalibHistArray * entry = dynamic_cast<AliTRDdEdxCalibHistArray*>(obj);
96       if (entry == 0) continue; 
97       
98       if(GetSize()!= entry->GetSize()){
99         printf("AliTRDdEdxCalibHistArray::Merge GetSize()!= entry->GetSize() %d %d\n", GetSize(), entry->GetSize()); exit(1);
100       }
101
102       for(Int_t ii=0; ii<GetSize(); ii++){
103         THnBase *h0 = (THnBase*) At(ii);
104         THnBase *h1 = (THnBase*) entry->At(ii);
105         h0->Add(h1);
106       }
107       
108       count++;
109     }
110   
111   return count;
112
113 }