1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // ALICE Reconstruction parameterization: //
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. //
26 ///////////////////////////////////////////////////////////////////////////////
28 #include "TObjArray.h"
29 #include "AliDetectorRecoParam.h"
32 #include "AliRecoParam.h"
34 ClassImp(AliRecoParam)
36 AliRecoParam::AliRecoParam():
38 fEventSpecie(kDefault)
40 // Default constructor
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;
51 AliRecoParam::AliRecoParam(const AliRecoParam& par) :
53 fEventSpecie(par.fEventSpecie)
56 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
57 if (par.fDetRecoParams[iDet])
58 fDetRecoParams[iDet] = (TObjArray*)(par.fDetRecoParams[iDet]->Clone());
60 fDetRecoParams[iDet] = NULL;
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];
69 //_____________________________________________________________________________
70 AliRecoParam& AliRecoParam::operator = (const AliRecoParam& par)
72 // assignment operator
74 if(&par == this) return *this;
76 this->~AliRecoParam();
77 new(this) AliRecoParam(par);
81 AliRecoParam::~AliRecoParam(){
84 // Delete the array with the reco-param objects
85 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
86 if (fDetRecoParams[iDet]){
87 fDetRecoParams[iDet]->Delete();
88 delete fDetRecoParams[iDet];
93 void AliRecoParam::Print(Option_t *option) const {
95 // Print reconstruction setup
97 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
98 if (fDetRecoParams[iDet]){
99 printf("AliDetectorRecoParam objects for detector %d:\n",iDet);
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);
108 printf("No AliDetectorRecoParam objects specified for detector %d\n",iDet);
113 void AliRecoParam::SetEventSpecie(const AliRunInfo */*runInfo*/, const AliEventInfo &/*evInfo*/)
116 // Here we return always kDefault!!
117 fEventSpecie = kDefault;
120 const AliDetectorRecoParam *AliRecoParam::GetDetRecoParam(Int_t iDet) const
122 // Return AliDetectorRecoParam object for a given detector
123 // according to the event specie provided as an argument
124 if (!fDetRecoParams[iDet]) return NULL;
125 if (fDetRecoParams[iDet]->GetEntries() == 0) return NULL;
127 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
128 if (fEventSpecie & (1 << iBit)) {
129 if (fDetRecoParamsIndex[iBit][iDet] >= 0)
130 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[iBit][iDet]);
132 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
137 AliError(Form("Invalid event specie: %d!",fEventSpecie));
138 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
141 void AliRecoParam::AddDetRecoParam(Int_t iDet, AliDetectorRecoParam* param)
143 // Add an instance of reco params object into
144 // the fDetRecoParams for detector iDet
145 // Updates the fDetRecoParams index
146 if (!fDetRecoParams[iDet]) fDetRecoParams[iDet] = new TObjArray;
147 fDetRecoParams[iDet]->AddLast(param);
148 Int_t index = fDetRecoParams[iDet]->GetLast();
151 Int_t specie = param->GetEventSpecie();
152 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
153 if (specie & (1 << iBit)) {
154 fDetRecoParamsIndex[iBit][iDet] = index;
159 Bool_t AliRecoParam::AddDetRecoParamArray(Int_t iDet, TObjArray* parArray)
161 // Add an array of reconstruction parameter objects
162 // for a given detector
163 // Basic check on the consistency of the array
164 Bool_t defaultFound = kFALSE;
165 for(Int_t i = 0; i < parArray->GetEntriesFast(); i++) {
166 AliDetectorRecoParam *par = (AliDetectorRecoParam*)parArray->At(i);
168 if (par->IsDefault()) defaultFound = kTRUE;
170 Int_t specie = par->GetEventSpecie();
171 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
172 if (specie & (1 << iBit)) {
173 fDetRecoParamsIndex[iBit][iDet] = i;
178 fDetRecoParams[iDet] = parArray;