]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliRecoParam.cxx
1dc9e3f2b53ecbed2e68fb643dbe7301ea124642
[u/mrichter/AliRoot.git] / STEER / AliRecoParam.cxx
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 //                                                                           //
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.      //
25 //                                                                           //
26 ///////////////////////////////////////////////////////////////////////////////
27
28 #include "TObjArray.h"
29 #include "AliDetectorRecoParam.h"
30
31 #include "AliLog.h"
32 #include "AliRecoParam.h"
33
34 ClassImp(AliRecoParam)
35
36 AliRecoParam::AliRecoParam(): 
37   TObject(),
38   fEventSpecie(kDefault)
39 {
40   // Default constructor
41   // ...
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   }
49 }
50
51 AliRecoParam::~AliRecoParam(){
52   // Destructor
53   // ...
54   // Delete the array with the reco-param objects
55   for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
56     if (fDetRecoParams[iDet]){
57       fDetRecoParams[iDet]->Delete();
58       delete fDetRecoParams[iDet];
59     }
60   }
61 }
62
63 void  AliRecoParam::Print(Option_t *option) const {
64   //
65   // Print reconstruction setup
66   //
67   for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
68     if (fDetRecoParams[iDet]){
69       printf("AliDetectorRecoParam objects for detector %d\n",iDet); 
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     }
80   }
81 }
82
83 void AliRecoParam::SetEventSpecie(const AliRunInfo */*runInfo*/, const AliEventInfo &/*evInfo*/)
84 {
85   // To be implemented
86   // Here we return always kDefault!!
87   fEventSpecie = kDefault;
88 }
89
90 const 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   }
105
106   // Default one
107   AliError(Form("Invalid event specie: %d!",fEventSpecie));
108   return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
109 }
110
111 void  AliRecoParam::AddDetRecoParam(Int_t iDet, AliDetectorRecoParam* param)
112 {
113   // Add an instance of reco params object into
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
129 Bool_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;
139   }
140    
141   fDetRecoParams[iDet] = parArray;
142
143   return defaultFound;
144 }