]>
Commit | Line | Data |
---|---|---|
8449e3e0 | 1 | // |
2 | // Manager (singleton) of corrections | |
3 | // | |
4 | #include "AliCentralCorrectionManager.h" | |
5 | #include "AliCentralCorrSecondaryMap.h" | |
6 | #include "AliCentralCorrAcceptance.h" | |
7 | #include "AliForwardUtil.h" | |
8 | #include "AliOADBForward.h" | |
9 | #include <TString.h> | |
10 | #include <AliLog.h> | |
11 | #include <TFile.h> | |
12 | #include <TSystem.h> | |
13 | #include <TBrowser.h> | |
14 | #include <TROOT.h> | |
15 | #include <TClass.h> | |
16 | #include <iostream> | |
17 | #include <iomanip> | |
18 | ||
19 | //____________________________________________________________________ | |
20 | AliCentralCorrectionManager* AliCentralCorrectionManager::fgInstance= 0; | |
21 | const char* AliCentralCorrectionManager::fgkSecondaryMapSkel = "secondary"; | |
22 | const char* AliCentralCorrectionManager::fgkAcceptanceSkel = "acceptance"; | |
23 | ||
24 | #define PREFIX "$(ALICE_ROOT)/OADB/PWGLF/FORWARD/CORRECTIONS/data/" | |
25 | #define DB_NAME "spd_corrections.root" | |
26 | ||
27 | //____________________________________________________________________ | |
28 | AliCentralCorrectionManager& AliCentralCorrectionManager::Instance() | |
29 | { | |
30 | // | |
31 | // Access to the singleton object | |
32 | // | |
33 | // Return: | |
34 | // Reference to the singleton object | |
35 | // | |
36 | if (!fgInstance) fgInstance= new AliCentralCorrectionManager(false); | |
37 | return *fgInstance; | |
38 | } | |
39 | ||
40 | //____________________________________________________________________ | |
41 | AliCentralCorrectionManager::AliCentralCorrectionManager() | |
42 | { | |
43 | // | |
44 | // Default constructor | |
45 | // | |
46 | } | |
47 | //____________________________________________________________________ | |
48 | AliCentralCorrectionManager::AliCentralCorrectionManager(Bool_t d) | |
49 | : AliCorrectionManagerBase(d) | |
50 | { | |
51 | // | |
52 | // Non-default constructor | |
53 | // | |
54 | // Parameters: | |
55 | // Not used | |
56 | // | |
57 | RegisterCorrection(kIdSecondaryMap, fgkSecondaryMapSkel, | |
58 | PREFIX DB_NAME, AliCentralCorrSecondaryMap::Class(), | |
59 | kStandard|kSatellite); | |
60 | RegisterCorrection(kIdAcceptance, fgkAcceptanceSkel, | |
61 | PREFIX DB_NAME, AliCentralCorrAcceptance::Class(), | |
62 | kStandard|kSatellite); | |
63 | } | |
64 | //____________________________________________________________________ | |
65 | Bool_t | |
66 | AliCentralCorrectionManager::Init(ULong_t runNo, | |
67 | const char* sys, | |
68 | Float_t sNN, | |
69 | Float_t field, | |
70 | Bool_t mc, | |
71 | Bool_t sat, | |
72 | UInt_t what, | |
73 | Bool_t force) | |
74 | { | |
75 | // | |
76 | // Read in correction based on passed parameters | |
77 | // | |
78 | // Parameters: | |
79 | // collisionSystem Collision system string | |
80 | // cmsNN Center of mass energy per nucleon pair [GeV] | |
81 | // field Magnetic field [kG] | |
82 | // mc Monte-carlo switch | |
83 | // what What to read in | |
84 | // force Force (re-)reading of specified things | |
85 | // | |
86 | // Return: | |
87 | // true on success | |
88 | // | |
89 | UShort_t col = AliForwardUtil::ParseCollisionSystem(sys); | |
90 | // AliInfo(Form("Initialising with cms='%s', sNN=%fGeV field=%fkG", | |
91 | // cms, sNN, field)); | |
92 | return Init(runNo, col, | |
93 | AliForwardUtil::ParseCenterOfMassEnergy(col, sNN), | |
94 | AliForwardUtil::ParseMagneticField(field), | |
95 | mc, sat, what, force); | |
96 | } | |
97 | ||
98 | //____________________________________________________________________ | |
99 | Bool_t | |
100 | AliCentralCorrectionManager::Init(ULong_t runNo, | |
101 | UShort_t sys, | |
102 | UShort_t sNN, | |
103 | Short_t field, | |
104 | Bool_t mc, | |
105 | Bool_t sat, | |
106 | UInt_t what, | |
107 | Bool_t force) | |
108 | { | |
109 | // | |
110 | // Read in corrections based on the parameters given | |
111 | // | |
112 | // Parameters: | |
113 | // collisionSystem Collision system | |
114 | // cmsNN Center of mass energy per nuclean pair [GeV] | |
115 | // field Magnetic field setting [kG] | |
116 | // mc Monte-carlo switch | |
117 | // what What to read in. | |
118 | // force Force (re-)reading of specified things | |
119 | // | |
120 | // Return: | |
121 | // | |
122 | // | |
123 | EnableCorrection(kIdSecondaryMap, what & kSecondaryMap); | |
124 | EnableCorrection(kIdAcceptance, what & kAcceptance); | |
125 | ||
126 | return InitCorrections(runNo, sys, sNN, field, mc, sat, force); | |
127 | } | |
128 | ||
129 | //____________________________________________________________________ | |
130 | Bool_t | |
131 | AliCentralCorrectionManager::Append(const TString& addition, | |
132 | const TString& destination) const | |
133 | { | |
134 | TString dest(destination); | |
135 | if (dest.IsNull()) | |
136 | dest = PREFIX DB_NAME; | |
2a50d35b | 137 | return AliCorrectionManagerBase::Append(addition, dest); |
8449e3e0 | 138 | } |
139 | ||
140 | //____________________________________________________________________ | |
141 | const AliCentralCorrSecondaryMap* | |
142 | AliCentralCorrectionManager::GetSecondaryMap() const | |
143 | { | |
144 | /** | |
145 | * Get the secondary correction map | |
146 | * | |
147 | * @return Get the secondary correction map object or null | |
148 | */ | |
149 | return static_cast<const AliCentralCorrSecondaryMap*>(Get(kIdSecondaryMap)); | |
150 | } | |
151 | //____________________________________________________________________ | |
152 | const AliCentralCorrAcceptance* | |
153 | AliCentralCorrectionManager::GetAcceptance() const | |
154 | { | |
155 | /** | |
156 | * Get the acceptance correction due to dead channels | |
157 | * | |
158 | * | |
159 | * @return Acceptance correction due to dead channels | |
160 | */ | |
161 | return static_cast<const AliCentralCorrAcceptance*>(Get(kIdAcceptance)); | |
162 | } | |
163 | ||
164 | //____________________________________________________________________ | |
165 | const TAxis* | |
166 | AliCentralCorrectionManager::GetVertexAxis() const | |
167 | { | |
168 | const AliCentralCorrSecondaryMap* map = GetSecondaryMap(); | |
169 | if (!map) return 0; | |
170 | return &(map->GetVertexAxis()); | |
171 | } | |
172 | ||
173 | ||
174 | #ifndef DOXY_INPUT | |
175 | //______________________________________________________________________________ | |
176 | void AliCentralCorrectionManager::Streamer(TBuffer &R__b) | |
177 | { | |
178 | // | |
179 | // Stream an object of class AliCentralCorrectionManager. | |
180 | // | |
181 | if (R__b.IsReading()) { | |
182 | R__b.ReadClassBuffer(AliCentralCorrectionManager::Class(),this); | |
183 | if (fgInstance) { | |
184 | AliWarning(Form("Singleton instance already set (%p) when reading " | |
185 | "singleton object (%p). Read object will be new " | |
186 | "singleton object", fgInstance, this)); | |
187 | // delete fgInstance; | |
188 | } | |
189 | fgInstance = this; | |
190 | } else { | |
191 | R__b.WriteClassBuffer(AliCentralCorrectionManager::Class(),this); | |
192 | } | |
193 | } | |
194 | #endif | |
195 | ||
196 | //____________________________________________________________________ | |
197 | // | |
198 | // EOF | |
199 | // |