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 ( iDet >= kNDetectors) return NULL;
125 if (!fDetRecoParams[iDet]) return NULL;
126 if (fDetRecoParams[iDet]->GetEntries() == 0) return NULL;
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]);
133 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
138 AliError(Form("Invalid event specie: %d!",fEventSpecie));
139 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
142 void AliRecoParam::AddDetRecoParam(Int_t iDet, AliDetectorRecoParam* param)
144 // Add an instance of reco params object into
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();
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;
160 Bool_t AliRecoParam::AddDetRecoParamArray(Int_t iDet, TObjArray* parArray)
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);
169 if (par->IsDefault()) defaultFound = kTRUE;
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;
179 fDetRecoParams[iDet] = parArray;