242b332c |
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 | // // |
6769d914 |
19 | // ALICE Reconstruction parameterization: // |
20 | // // |
21 | // // |
22 | // Base Class for Detector reconstruction parameters // |
23 | // Revision: cvetan.cheshkov@cern.ch 12/06/2008 // |
24 | // Its structure has been revised and it is interfaced to AliEventInfo. // |
242b332c |
25 | // // |
26 | /////////////////////////////////////////////////////////////////////////////// |
27 | |
28 | #include "TObjArray.h" |
29 | #include "AliDetectorRecoParam.h" |
30 | |
6bcbb25b |
31 | #include "AliLog.h" |
242b332c |
32 | #include "AliRecoParam.h" |
33 | |
242b332c |
34 | ClassImp(AliRecoParam) |
35 | |
6769d914 |
36 | AliRecoParam::AliRecoParam(): |
7e88424f |
37 | TObject(), |
38 | fEventSpecie(kDefault) |
242b332c |
39 | { |
6769d914 |
40 | // Default constructor |
41 | // ... |
7e88424f |
42 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) |
43 | fDetRecoParams[iDet] = NULL; |
44 | for(Int_t iSpecie = 0; iSpecie < kNSpecies; iSpecie++) { |
45 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { |
46 | fDetRecoParamsIndex[iSpecie][iDet] = -1; |
47 | } |
48 | } |
242b332c |
49 | } |
50 | |
54e51010 |
51 | AliRecoParam::AliRecoParam(const AliRecoParam& par) : |
52 | TObject(), |
53 | fEventSpecie(par.fEventSpecie) |
54 | { |
55 | // copy constructor |
56 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { |
54e51010 |
57 | if (par.fDetRecoParams[iDet]) |
58 | fDetRecoParams[iDet] = (TObjArray*)(par.fDetRecoParams[iDet]->Clone()); |
59 | else |
60 | fDetRecoParams[iDet] = NULL; |
61 | } |
62 | for(Int_t iSpecie = 0; iSpecie < kNSpecies; iSpecie++) { |
63 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { |
64 | fDetRecoParamsIndex[iSpecie][iDet] = par.fDetRecoParamsIndex[iSpecie][iDet]; |
65 | } |
66 | } |
67 | } |
68 | |
49ad11d0 |
69 | //_____________________________________________________________________________ |
70 | AliRecoParam& AliRecoParam::operator = (const AliRecoParam& par) |
71 | { |
72 | // assignment operator |
73 | |
74 | if(&par == this) return *this; |
75 | |
76 | this->~AliRecoParam(); |
77 | new(this) AliRecoParam(par); |
78 | return *this; |
79 | } |
80 | |
242b332c |
81 | AliRecoParam::~AliRecoParam(){ |
6769d914 |
82 | // Destructor |
83 | // ... |
84 | // Delete the array with the reco-param objects |
7e88424f |
85 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { |
86 | if (fDetRecoParams[iDet]){ |
87 | fDetRecoParams[iDet]->Delete(); |
88 | delete fDetRecoParams[iDet]; |
89 | } |
242b332c |
90 | } |
91 | } |
92 | |
6769d914 |
93 | void AliRecoParam::Print(Option_t *option) const { |
242b332c |
94 | // |
95 | // Print reconstruction setup |
96 | // |
7e88424f |
97 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { |
98 | if (fDetRecoParams[iDet]){ |
ac232c75 |
99 | printf("AliDetectorRecoParam objects for detector %d:\n",iDet); |
7e88424f |
100 | Int_t nparam = fDetRecoParams[iDet]->GetEntriesFast(); |
101 | for (Int_t iparam=0; iparam<nparam; iparam++){ |
102 | AliDetectorRecoParam * param = (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(iparam); |
103 | if (!param) continue; |
104 | param->Print(option); |
105 | } |
106 | } |
107 | else { |
108 | printf("No AliDetectorRecoParam objects specified for detector %d\n",iDet); |
109 | } |
242b332c |
110 | } |
111 | } |
112 | |
7e88424f |
113 | void AliRecoParam::SetEventSpecie(const AliRunInfo */*runInfo*/, const AliEventInfo &/*evInfo*/) |
114 | { |
115 | // To be implemented |
116 | // Here we return always kDefault!! |
117 | fEventSpecie = kDefault; |
118 | } |
119 | |
120 | const AliDetectorRecoParam *AliRecoParam::GetDetRecoParam(Int_t iDet) const |
121 | { |
122 | // Return AliDetectorRecoParam object for a given detector |
123 | // according to the event specie provided as an argument |
a00021a7 |
124 | if ( iDet >= kNDetectors) return NULL; |
7e88424f |
125 | if (!fDetRecoParams[iDet]) return NULL; |
126 | if (fDetRecoParams[iDet]->GetEntries() == 0) return NULL; |
127 | |
128 | for(Int_t iBit = 0; iBit < kNSpecies; iBit++) { |
129 | if (fEventSpecie & (1 << iBit)) { |
130 | if (fDetRecoParamsIndex[iBit][iDet] >= 0) |
131 | return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[iBit][iDet]); |
132 | else |
133 | return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]); |
134 | } |
135 | } |
6bcbb25b |
136 | |
7e88424f |
137 | // Default one |
138 | AliError(Form("Invalid event specie: %d!",fEventSpecie)); |
139 | return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]); |
6bcbb25b |
140 | } |
141 | |
7e88424f |
142 | void AliRecoParam::AddDetRecoParam(Int_t iDet, AliDetectorRecoParam* param) |
143 | { |
6769d914 |
144 | // Add an instance of reco params object into |
7e88424f |
145 | // the fDetRecoParams for detector iDet |
146 | // Updates the fDetRecoParams index |
147 | if (!fDetRecoParams[iDet]) fDetRecoParams[iDet] = new TObjArray; |
148 | fDetRecoParams[iDet]->AddLast(param); |
149 | Int_t index = fDetRecoParams[iDet]->GetLast(); |
150 | |
151 | // Index |
152 | Int_t specie = param->GetEventSpecie(); |
153 | for(Int_t iBit = 0; iBit < kNSpecies; iBit++) { |
154 | if (specie & (1 << iBit)) { |
155 | fDetRecoParamsIndex[iBit][iDet] = index; |
156 | } |
157 | } |
158 | } |
159 | |
160 | Bool_t AliRecoParam::AddDetRecoParamArray(Int_t iDet, TObjArray* parArray) |
161 | { |
162 | // Add an array of reconstruction parameter objects |
163 | // for a given detector |
164 | // Basic check on the consistency of the array |
165 | Bool_t defaultFound = kFALSE; |
166 | for(Int_t i = 0; i < parArray->GetEntriesFast(); i++) { |
167 | AliDetectorRecoParam *par = (AliDetectorRecoParam*)parArray->At(i); |
168 | if (!par) continue; |
169 | if (par->IsDefault()) defaultFound = kTRUE; |
3d0847a7 |
170 | |
171 | Int_t specie = par->GetEventSpecie(); |
172 | for(Int_t iBit = 0; iBit < kNSpecies; iBit++) { |
173 | if (specie & (1 << iBit)) { |
174 | fDetRecoParamsIndex[iBit][iDet] = i; |
175 | } |
176 | } |
177 | } |
7e88424f |
178 | |
179 | fDetRecoParams[iDet] = parArray; |
180 | |
181 | return defaultFound; |
242b332c |
182 | } |