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