Updated SSD raw streamer which fixes the swapping between the 18th and 19th modules...
[u/mrichter/AliRoot.git] / STEER / AliRecoParam.cxx
CommitLineData
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 34ClassImp(AliRecoParam)
35
6769d914 36AliRecoParam::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 51AliRecoParam::AliRecoParam(const AliRecoParam& par) :
52 TObject(),
53 fEventSpecie(par.fEventSpecie)
54{
55 // copy constructor
56 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
57 // fDetRecoParams[iDet] = new TObjArray;
58 // for(Int_t i = 0; i < par.fDetRecoParams[iDet]->GetEntriesFast(); i++) {
59 // if (!par.fDetRecoParams[iDet]->UncheckedAt(i)) {
60 // fDetRecoParams[iDet]->AddAt(NULL,i);
61 // continue;
62 // }
63 // fDetRecoParams[iDet]->AddAt(par.fDetRecoParams[iDet]->UncheckedAt(i)->Clone(),i);
64 // }
65 // }
66// fDetRecoParams[iDet] = par.fDetRecoParams[iDet];
67// }
68 if (par.fDetRecoParams[iDet])
69 fDetRecoParams[iDet] = (TObjArray*)(par.fDetRecoParams[iDet]->Clone());
70 else
71 fDetRecoParams[iDet] = NULL;
72 }
73 for(Int_t iSpecie = 0; iSpecie < kNSpecies; iSpecie++) {
74 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
75 fDetRecoParamsIndex[iSpecie][iDet] = par.fDetRecoParamsIndex[iSpecie][iDet];
76 }
77 }
78}
79
242b332c 80AliRecoParam::~AliRecoParam(){
6769d914 81 // Destructor
82 // ...
83 // Delete the array with the reco-param objects
7e88424f 84 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
85 if (fDetRecoParams[iDet]){
86 fDetRecoParams[iDet]->Delete();
87 delete fDetRecoParams[iDet];
88 }
242b332c 89 }
90}
91
6769d914 92void AliRecoParam::Print(Option_t *option) const {
242b332c 93 //
94 // Print reconstruction setup
95 //
7e88424f 96 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
97 if (fDetRecoParams[iDet]){
ac232c75 98 printf("AliDetectorRecoParam objects for detector %d:\n",iDet);
7e88424f 99 Int_t nparam = fDetRecoParams[iDet]->GetEntriesFast();
100 for (Int_t iparam=0; iparam<nparam; iparam++){
101 AliDetectorRecoParam * param = (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(iparam);
102 if (!param) continue;
103 param->Print(option);
104 }
105 }
106 else {
107 printf("No AliDetectorRecoParam objects specified for detector %d\n",iDet);
108 }
242b332c 109 }
110}
111
7e88424f 112void AliRecoParam::SetEventSpecie(const AliRunInfo */*runInfo*/, const AliEventInfo &/*evInfo*/)
113{
114 // To be implemented
115 // Here we return always kDefault!!
116 fEventSpecie = kDefault;
117}
118
119const AliDetectorRecoParam *AliRecoParam::GetDetRecoParam(Int_t iDet) const
120{
121 // Return AliDetectorRecoParam object for a given detector
122 // according to the event specie provided as an argument
123 if (!fDetRecoParams[iDet]) return NULL;
124 if (fDetRecoParams[iDet]->GetEntries() == 0) return NULL;
125
126 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
127 if (fEventSpecie & (1 << iBit)) {
128 if (fDetRecoParamsIndex[iBit][iDet] >= 0)
129 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[iBit][iDet]);
130 else
131 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
132 }
133 }
6bcbb25b 134
7e88424f 135 // Default one
136 AliError(Form("Invalid event specie: %d!",fEventSpecie));
137 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
6bcbb25b 138}
139
7e88424f 140void AliRecoParam::AddDetRecoParam(Int_t iDet, AliDetectorRecoParam* param)
141{
6769d914 142 // Add an instance of reco params object into
7e88424f 143 // the fDetRecoParams for detector iDet
144 // Updates the fDetRecoParams index
145 if (!fDetRecoParams[iDet]) fDetRecoParams[iDet] = new TObjArray;
146 fDetRecoParams[iDet]->AddLast(param);
147 Int_t index = fDetRecoParams[iDet]->GetLast();
148
149 // Index
150 Int_t specie = param->GetEventSpecie();
151 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
152 if (specie & (1 << iBit)) {
153 fDetRecoParamsIndex[iBit][iDet] = index;
154 }
155 }
156}
157
158Bool_t AliRecoParam::AddDetRecoParamArray(Int_t iDet, TObjArray* parArray)
159{
160 // Add an array of reconstruction parameter objects
161 // for a given detector
162 // Basic check on the consistency of the array
163 Bool_t defaultFound = kFALSE;
164 for(Int_t i = 0; i < parArray->GetEntriesFast(); i++) {
165 AliDetectorRecoParam *par = (AliDetectorRecoParam*)parArray->At(i);
166 if (!par) continue;
167 if (par->IsDefault()) defaultFound = kTRUE;
3d0847a7 168
169 Int_t specie = par->GetEventSpecie();
170 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
171 if (specie & (1 << iBit)) {
172 fDetRecoParamsIndex[iBit][iDet] = i;
173 }
174 }
175 }
7e88424f 176
177 fDetRecoParams[iDet] = parArray;
178
179 return defaultFound;
242b332c 180}