]>
Commit | Line | Data |
---|---|---|
6dc9348d | 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 | ||
762446e0 | 16 | /* |
7fffa85b | 17 | $Log: AliTOFcalib.cxx,v $ |
18 | Revision 1.21 2007/11/02 15:41:49 hristov | |
19 | Provide return value if the function is not void | |
20 | ||
52be7fb0 | 21 | Revision 1.20 2007/10/26 15:13:50 zampolli |
22 | Using a TChain instead of a TTree | |
23 | ||
296591ad | 24 | Revision 1.19 2007/10/23 15:27:38 zampolli |
25 | Rearrangement of Calibration objects for simulation | |
26 | ||
a7e9db2a | 27 | Revision 1.16 2007/10/08 10:13:26 zampolli |
28 | First Run and Last Run members added, infinite validity of calib obj implemented. | |
29 | ||
0cb9d099 | 30 | Revision 1.15 2007/10/04 13:23:28 zampolli |
31 | Updates to handle functionalities in TOF online/offline calibration according to the latest schema | |
32 | ||
0a749fa5 | 33 | Revision 1.14 2007/06/06 16:26:30 arcelli |
34 | remove fall-back call to local CDB storage | |
35 | ||
03705065 | 36 | Revision 1.13 2007/04/20 13:59:40 arcelli |
37 | make protections agains failed retrieval of the CDB object in a proper way | |
38 | ||
7a4f634e | 39 | Revision 1.12 2007/03/23 11:31:16 arcelli |
40 | CDB Entry for TOF Reconstruction Parameters | |
41 | ||
7037bd93 | 42 | Revision 1.11 2007/02/28 18:08:26 arcelli |
43 | Add protection against failed retrieval of the CDB cal object | |
44 | ||
1b20c168 | 45 | Revision 1.10 2006/08/22 13:30:49 arcelli |
46 | removal of effective c++ warnings (C.Zampolli) | |
47 | ||
655e379f | 48 | Revision 1.9 2006/04/20 22:30:50 hristov |
49 | Coding conventions (Annalisa) | |
50 | ||
0e46b9ae | 51 | Revision 1.8 2006/04/16 22:29:05 hristov |
52 | Coding conventions (Annalisa) | |
53 | ||
7aeeaf38 | 54 | Revision 1.7 2006/04/16 20:12:46 hristov |
55 | Removing memory leak in case of cached CDB entries | |
56 | ||
85fc78e3 | 57 | Revision 1.6 2006/04/11 15:28:32 hristov |
58 | Checks on cache status before deleting calibration objects (A.Colla) | |
59 | ||
5eaae242 | 60 | Revision 1.5 2006/04/05 08:35:38 hristov |
61 | Coding conventions (S.Arcelli, C.Zampolli) | |
62 | ||
340693af | 63 | Revision 1.4 2006/03/31 11:26:46 arcelli |
64 | changing CDB Ids according to standard convention | |
65 | ||
28dd10b6 | 66 | Revision 1.3 2006/03/28 14:57:02 arcelli |
67 | updates to handle new V5 geometry & some re-arrangements | |
68 | ||
d4ad0d6b | 69 | Revision 1.2 2006/02/13 17:22:26 arcelli |
70 | just Fixing Log info | |
71 | ||
762446e0 | 72 | Revision 1.1 2006/02/13 16:10:48 arcelli |
73 | Add classes for TOF Calibration (C.Zampolli) | |
74 | ||
6dc9348d | 75 | author: Chiara Zampolli, zampolli@bo.infn.it |
762446e0 | 76 | */ |
6dc9348d | 77 | |
78 | /////////////////////////////////////////////////////////////////////////////// | |
79 | // // | |
80 | // class for TOF calibration // | |
81 | // // | |
82 | /////////////////////////////////////////////////////////////////////////////// | |
83 | ||
6dc9348d | 84 | #include "TF1.h" |
0e46b9ae | 85 | #include "TFile.h" |
6dc9348d | 86 | #include "TH1F.h" |
87 | #include "TH2F.h" | |
5c7c93fa | 88 | //#include "TList.h" |
89 | //#include "TROOT.h" | |
90 | //#include "TStyle.h" | |
0a749fa5 | 91 | #include "TTree.h" |
296591ad | 92 | #include "TChain.h" |
0a749fa5 | 93 | #include "TProfile.h" |
94 | #include "TGrid.h" | |
5c7c93fa | 95 | #include "TMath.h" |
17149e6b | 96 | #include "TMap.h" |
0e46b9ae | 97 | |
98 | #include "AliCDBEntry.h" | |
0cb9d099 | 99 | #include "AliCDBRunRange.h" |
0e46b9ae | 100 | #include "AliCDBId.h" |
6dc9348d | 101 | #include "AliCDBManager.h" |
0a749fa5 | 102 | #include "AliCDBStorage.h" |
6dc9348d | 103 | #include "AliCDBMetaData.h" |
5c7c93fa | 104 | //#include "AliESDtrack.h" |
105 | //#include "AliESD.h" | |
0e46b9ae | 106 | #include "AliLog.h" |
107 | ||
0e46b9ae | 108 | #include "AliTOFcalib.h" |
17149e6b | 109 | #include "AliTOFChannelOnlineArray.h" |
0a749fa5 | 110 | #include "AliTOFChannelOnline.h" |
7fffa85b | 111 | #include "AliTOFChannelOnlineStatus.h" |
17149e6b | 112 | #include "AliTOFChannelOnlineStatusArray.h" |
0a749fa5 | 113 | #include "AliTOFChannelOffline.h" |
0e46b9ae | 114 | #include "AliTOFGeometry.h" |
7037bd93 | 115 | #include "AliTOFRecoParam.h" |
2bf4d9d6 | 116 | #include "AliTOFDeltaBCOffset.h" |
117 | #include "AliTOFCTPLatency.h" | |
118 | #include "AliTOFT0Fill.h" | |
119 | ||
6dc9348d | 120 | |
5c7c93fa | 121 | class TROOT; |
122 | class TStyle; | |
123 | ||
6dc9348d | 124 | extern TROOT *gROOT; |
125 | extern TStyle *gStyle; | |
126 | ||
127 | ClassImp(AliTOFcalib) | |
128 | ||
6dc9348d | 129 | //_______________________________________________________________________ |
655e379f | 130 | AliTOFcalib::AliTOFcalib(): |
131 | TTask("AliTOFcalib",""), | |
132 | fNChannels(-1), | |
0a749fa5 | 133 | fTOFCalOnline(0x0), |
7fffa85b | 134 | fTOFCalOnlinePulser(0x0), |
135 | fTOFCalOnlineNoise(0x0), | |
136 | fTOFCalOnlineHW(0x0), | |
0a749fa5 | 137 | fTOFCalOffline(0x0), |
17149e6b | 138 | fCal(0x0), |
139 | fStatus(0x0), | |
0a749fa5 | 140 | fTOFSimToT(0x0), |
141 | fkValidity(0x0), | |
142 | fTree(0x0), | |
296591ad | 143 | fChain(0x0), |
0cb9d099 | 144 | fNruns(0), |
145 | fFirstRun(0), | |
17149e6b | 146 | fLastRun(AliCDBRunRange::Infinity()), |
2bf4d9d6 | 147 | fConfigMap(new TMap), |
148 | fDeltaBCOffset(NULL), | |
149 | fCTPLatency(NULL), | |
150 | fT0Fill(NULL) | |
655e379f | 151 | { |
340693af | 152 | //TOF Calibration Class ctor |
0a749fa5 | 153 | fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX(); |
6dc9348d | 154 | } |
155 | //____________________________________________________________________________ | |
156 | ||
655e379f | 157 | AliTOFcalib::AliTOFcalib(const AliTOFcalib & calib): |
8a190ba2 | 158 | TTask(calib), |
0a749fa5 | 159 | fNChannels(calib.fNChannels), |
160 | fTOFCalOnline(0x0), | |
7fffa85b | 161 | fTOFCalOnlinePulser(0x0), |
162 | fTOFCalOnlineNoise(0x0), | |
163 | fTOFCalOnlineHW(0x0), | |
0a749fa5 | 164 | fTOFCalOffline(0x0), |
17149e6b | 165 | fCal(calib.fCal), |
166 | fStatus(calib.fStatus), | |
0a749fa5 | 167 | fTOFSimToT(calib.fTOFSimToT), |
168 | fkValidity(calib.fkValidity), | |
169 | fTree(calib.fTree), | |
296591ad | 170 | fChain(calib.fChain), |
0cb9d099 | 171 | fNruns(calib.fNruns), |
172 | fFirstRun(calib.fFirstRun), | |
17149e6b | 173 | fLastRun(calib.fLastRun), |
2bf4d9d6 | 174 | fConfigMap(calib.fConfigMap), |
175 | fDeltaBCOffset(NULL), | |
176 | fCTPLatency(NULL), | |
177 | fT0Fill(NULL) | |
6dc9348d | 178 | { |
340693af | 179 | //TOF Calibration Class copy ctor |
0a749fa5 | 180 | for (Int_t iarray = 0; iarray<fNChannels; iarray++){ |
181 | AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray); | |
7fffa85b | 182 | AliTOFChannelOnlineStatus * calChOnlineStPulser = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlinePulser->At(iarray); |
183 | AliTOFChannelOnlineStatus * calChOnlineStNoise = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineNoise->At(iarray); | |
184 | AliTOFChannelOnlineStatus * calChOnlineStHW = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineHW->At(iarray); | |
0a749fa5 | 185 | AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray); |
186 | fTOFCalOnline->AddAt(calChOnline,iarray); | |
7fffa85b | 187 | fTOFCalOnlinePulser->AddAt(calChOnlineStPulser,iarray); |
188 | fTOFCalOnlineNoise->AddAt(calChOnlineStNoise,iarray); | |
189 | fTOFCalOnlineHW->AddAt(calChOnlineStHW,iarray); | |
0a749fa5 | 190 | fTOFCalOffline->AddAt(calChOffline,iarray); |
0a749fa5 | 191 | } |
2bf4d9d6 | 192 | |
193 | if (calib.fDeltaBCOffset) fDeltaBCOffset = new AliTOFDeltaBCOffset(*calib.fDeltaBCOffset); | |
194 | if (calib.fCTPLatency) fCTPLatency = new AliTOFCTPLatency(*calib.fCTPLatency); | |
195 | if (calib.fT0Fill) fT0Fill = new AliTOFT0Fill(*calib.fT0Fill); | |
6dc9348d | 196 | } |
197 | ||
198 | //____________________________________________________________________________ | |
7aeeaf38 | 199 | |
200 | AliTOFcalib& AliTOFcalib::operator=(const AliTOFcalib &calib) | |
201 | { | |
202 | //TOF Calibration Class assignment operator | |
8a190ba2 | 203 | |
204 | if (this == &calib) | |
205 | return *this; | |
206 | ||
207 | TTask::operator=(calib); | |
208 | fNChannels = calib.fNChannels; | |
209 | fCal = calib.fCal; | |
210 | fStatus = calib.fStatus; | |
211 | fTOFSimToT = calib.fTOFSimToT; | |
212 | fkValidity = calib.fkValidity; | |
213 | fTree = calib.fTree; | |
214 | fChain = calib.fChain; | |
215 | fNruns = calib.fNruns; | |
216 | fFirstRun = calib.fFirstRun; | |
217 | fLastRun = calib.fLastRun; | |
0a749fa5 | 218 | for (Int_t iarray = 0; iarray<fNChannels; iarray++){ |
219 | AliTOFChannelOnline * calChOnline = (AliTOFChannelOnline*)calib.fTOFCalOnline->At(iarray); | |
220 | AliTOFChannelOffline * calChOffline = (AliTOFChannelOffline*)calib.fTOFCalOffline->At(iarray); | |
7fffa85b | 221 | AliTOFChannelOnlineStatus * calChOnlineStPulser = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlinePulser->At(iarray); |
222 | AliTOFChannelOnlineStatus * calChOnlineStNoise = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineNoise->At(iarray); | |
223 | AliTOFChannelOnlineStatus * calChOnlineStHW = (AliTOFChannelOnlineStatus*)calib.fTOFCalOnlineHW->At(iarray); | |
8a190ba2 | 224 | fTOFCalOnline->AddAt(calChOnline,iarray); |
225 | fTOFCalOnlinePulser->AddAt(calChOnlineStPulser,iarray); | |
226 | fTOFCalOnlineNoise->AddAt(calChOnlineStNoise,iarray); | |
227 | fTOFCalOnlineHW->AddAt(calChOnlineStHW,iarray); | |
228 | fTOFCalOffline->AddAt(calChOffline,iarray); | |
0a749fa5 | 229 | } |
2bf4d9d6 | 230 | |
231 | if (calib.fDeltaBCOffset) { | |
232 | if (fDeltaBCOffset) *fDeltaBCOffset = *calib.fDeltaBCOffset; | |
233 | else fDeltaBCOffset = new AliTOFDeltaBCOffset(*calib.fDeltaBCOffset); | |
234 | } | |
235 | ||
236 | if (calib.fCTPLatency) { | |
237 | if (fCTPLatency) *fCTPLatency = *calib.fCTPLatency; | |
238 | else fCTPLatency = new AliTOFCTPLatency(*calib.fCTPLatency); | |
239 | } | |
240 | ||
241 | if (calib.fT0Fill) { | |
242 | if (fT0Fill) *fT0Fill = *calib.fT0Fill; | |
243 | else fT0Fill = new AliTOFT0Fill(*calib.fT0Fill); | |
244 | } | |
245 | ||
7aeeaf38 | 246 | return *this; |
247 | } | |
248 | ||
249 | //____________________________________________________________________________ | |
6dc9348d | 250 | |
251 | AliTOFcalib::~AliTOFcalib() | |
252 | { | |
340693af | 253 | //TOF Calibration Class dtor |
5eaae242 | 254 | if(!(AliCDBManager::Instance()->GetCacheFlag())){ // CDB objects must NOT be deleted if cache is active! |
0a749fa5 | 255 | if (fTOFCalOnline){ |
0a749fa5 | 256 | delete fTOFCalOnline; |
6dc9348d | 257 | } |
7fffa85b | 258 | if (fTOFCalOnlinePulser){ |
259 | delete fTOFCalOnlinePulser; | |
260 | } | |
261 | if (fTOFCalOnlineNoise){ | |
262 | delete fTOFCalOnlineNoise; | |
263 | } | |
264 | if (fTOFCalOnlineHW){ | |
265 | delete fTOFCalOnlineHW; | |
266 | } | |
0a749fa5 | 267 | if (fTOFCalOffline){ |
0a749fa5 | 268 | delete fTOFCalOffline; |
6dc9348d | 269 | } |
17149e6b | 270 | if (fCal){ |
271 | delete fCal; | |
272 | } | |
273 | if (fStatus){ | |
274 | delete fStatus; | |
275 | } | |
276 | if (fConfigMap){ | |
277 | delete fConfigMap; | |
278 | } | |
2bf4d9d6 | 279 | if (fDeltaBCOffset) delete fDeltaBCOffset; |
280 | if (fCTPLatency) delete fCTPLatency; | |
281 | if (fT0Fill) delete fT0Fill; | |
6dc9348d | 282 | } |
0a749fa5 | 283 | if (fTree!=0x0) delete fTree; |
296591ad | 284 | if (fChain!=0x0) delete fChain; |
2bf4d9d6 | 285 | |
6dc9348d | 286 | } |
287 | //_____________________________________________________________________________ | |
0a749fa5 | 288 | void AliTOFcalib::CreateCalArrays(){ |
6dc9348d | 289 | |
0a749fa5 | 290 | // creating arrays for online/offline calibration objs |
6dc9348d | 291 | |
0a749fa5 | 292 | fTOFCalOnline = new TObjArray(fNChannels); |
7fffa85b | 293 | fTOFCalOnlinePulser = new TObjArray(fNChannels); |
294 | fTOFCalOnlineNoise = new TObjArray(fNChannels); | |
295 | fTOFCalOnlineHW = new TObjArray(fNChannels); | |
0a749fa5 | 296 | fTOFCalOffline = new TObjArray(fNChannels); |
297 | fTOFCalOnline->SetOwner(); | |
7fffa85b | 298 | fTOFCalOnlinePulser->SetOwner(); |
299 | fTOFCalOnlineNoise->SetOwner(); | |
300 | fTOFCalOnlineHW->SetOwner(); | |
0a749fa5 | 301 | fTOFCalOffline->SetOwner(); |
302 | for (Int_t iarray = 0; iarray<fNChannels; iarray++){ | |
303 | AliTOFChannelOnline * calChOnline = new AliTOFChannelOnline(); | |
7fffa85b | 304 | AliTOFChannelOnlineStatus * calChOnlineStPulser = new AliTOFChannelOnlineStatus(); |
305 | AliTOFChannelOnlineStatus * calChOnlineStNoise = new AliTOFChannelOnlineStatus(); | |
306 | AliTOFChannelOnlineStatus * calChOnlineStHW = new AliTOFChannelOnlineStatus(); | |
0a749fa5 | 307 | AliTOFChannelOffline * calChOffline = new AliTOFChannelOffline(); |
308 | fTOFCalOnline->AddAt(calChOnline,iarray); | |
7fffa85b | 309 | fTOFCalOnlinePulser->AddAt(calChOnlineStPulser,iarray); |
310 | fTOFCalOnlineNoise->AddAt(calChOnlineStNoise,iarray); | |
311 | fTOFCalOnlineHW->AddAt(calChOnlineStHW,iarray); | |
0a749fa5 | 312 | fTOFCalOffline->AddAt(calChOffline,iarray); |
6dc9348d | 313 | } |
17149e6b | 314 | fCal = new AliTOFChannelOnlineArray(fNChannels); |
315 | fStatus = new AliTOFChannelOnlineStatusArray(fNChannels); | |
316 | } | |
317 | //_____________________________________________________________________________ | |
24d1e16e | 318 | void AliTOFcalib::CreateCalObjects(){ |
319 | ||
320 | // creating arrays for online/offline calibration objs | |
321 | ||
322 | fTOFCalOffline = new TObjArray(fNChannels); | |
323 | fTOFCalOffline->SetOwner(); | |
324 | for (Int_t iarray = 0; iarray<fNChannels; iarray++){ | |
325 | AliTOFChannelOffline * calChOffline = new AliTOFChannelOffline(); | |
326 | fTOFCalOffline->AddAt(calChOffline,iarray); | |
327 | } | |
328 | fCal = new AliTOFChannelOnlineArray(fNChannels); | |
329 | fStatus = new AliTOFChannelOnlineStatusArray(fNChannels); | |
330 | } | |
331 | //_____________________________________________________________________________ | |
a6e0ebfe | 332 | void AliTOFcalib::WriteConfigMapOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun) |
17149e6b | 333 | { |
334 | //Write calibration parameters to the CDB | |
335 | SetFirstRun(minrun); | |
336 | SetLastRun(maxrun); | |
337 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 338 | const Char_t *sel1 = "Config" ; // to be consistent with TOFPreprocessor |
17149e6b | 339 | Char_t out[100]; |
340 | sprintf(out,"%s/%s",sel,sel1); | |
341 | AliDebug(2,Form("Writing TOF configuration map for online calib on CDB with run range [%i, %i] ",fFirstRun,fLastRun)); | |
342 | AliCDBId id(out,fFirstRun,fLastRun); | |
343 | AliCDBMetaData *md = new AliCDBMetaData(); | |
344 | md->SetResponsible("Chiara Zampolli"); | |
345 | if (!fConfigMap) { | |
346 | // deve uscire!! | |
347 | } | |
348 | man->Put(fConfigMap,id,md); | |
349 | delete md; | |
350 | } | |
351 | //_____________________________________________________________________________ | |
352 | ||
a6e0ebfe | 353 | void AliTOFcalib::WriteConfigMapOnCDB(const Char_t *sel) |
17149e6b | 354 | { |
355 | //Write calibration parameters to the CDB with infinite validity | |
356 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 357 | const Char_t *sel1 = "Config" ; // to be consistent with TOFPreprocessor |
17149e6b | 358 | Char_t out[100]; |
359 | sprintf(out,"%s/%s",sel,sel1); | |
360 | AliCDBRunRange runrange(fFirstRun,fLastRun); | |
361 | AliDebug(2,Form("Writing TOF config map for online calib on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun())); | |
362 | AliCDBId id(out,runrange); | |
363 | AliCDBMetaData *md = new AliCDBMetaData(); | |
364 | md->SetResponsible("Chiara Zampolli"); | |
365 | if (!fConfigMap) { | |
366 | // deve uscire!! | |
367 | } | |
368 | man->Put(fConfigMap,id,md); | |
369 | delete md; | |
370 | } | |
371 | //_____________________________________________________________________________ | |
a6e0ebfe | 372 | void AliTOFcalib::WriteParOnlineDelayOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun) |
17149e6b | 373 | { |
374 | //Write calibration parameters to the CDB -------> new calib objs!!!!! | |
375 | SetFirstRun(minrun); | |
376 | SetLastRun(maxrun); | |
377 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 378 | const Char_t *sel1 = "ParOnlineDelay" ; // to be consistent with TOFPreprocessor |
17149e6b | 379 | Char_t out[100]; |
380 | sprintf(out,"%s/%s",sel,sel1); | |
381 | AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun)); | |
382 | AliCDBId id(out,fFirstRun,fLastRun); | |
383 | AliCDBMetaData *md = new AliCDBMetaData(); | |
384 | md->SetResponsible("Chiara Zampolli"); | |
385 | if (!fCal) { | |
386 | // deve uscire!! | |
387 | } | |
388 | man->Put(fCal,id,md); | |
389 | delete md; | |
390 | } | |
391 | //_____________________________________________________________________________ | |
a6e0ebfe | 392 | void AliTOFcalib::WriteParOnlineStatusOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun) |
17149e6b | 393 | { |
394 | //Write calibration parameters to the CDB -------> new calib objs!!!!! | |
395 | SetFirstRun(minrun); | |
396 | SetLastRun(maxrun); | |
397 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 398 | const Char_t *sel1 = "Status" ; // to be consistent with TOFPreprocessor |
17149e6b | 399 | Char_t out[100]; |
400 | sprintf(out,"%s/%s",sel,sel1); | |
401 | AliDebug(2,Form("Writing TOF online status calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun)); | |
402 | AliCDBId id(out,fFirstRun,fLastRun); | |
403 | AliCDBMetaData *md = new AliCDBMetaData(); | |
404 | md->SetResponsible("Chiara Zampolli"); | |
405 | if (!fStatus) { | |
406 | // deve uscire!! | |
407 | } | |
408 | man->Put(fStatus,id,md); | |
409 | delete md; | |
410 | } | |
411 | //_____________________________________________________________________________ | |
412 | ||
a6e0ebfe | 413 | void AliTOFcalib::WriteParOnlineDelayOnCDB(const Char_t *sel) |
17149e6b | 414 | { |
415 | //Write calibration parameters to the CDB with infinite validity -------> new calib objs!!!!! | |
416 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 417 | const Char_t *sel1 = "ParOnlineDelay" ; // to be consistent with TOFPreprocessor |
17149e6b | 418 | Char_t out[100]; |
419 | sprintf(out,"%s/%s",sel,sel1); | |
420 | AliCDBRunRange runrange(fFirstRun,fLastRun); | |
421 | AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun())); | |
422 | AliCDBId id(out,runrange); | |
423 | AliCDBMetaData *md = new AliCDBMetaData(); | |
424 | md->SetResponsible("Chiara Zampolli"); | |
425 | if (!fCal) { | |
426 | // deve uscire!! | |
427 | } | |
428 | man->Put(fCal,id,md); | |
429 | delete md; | |
430 | } | |
431 | //_____________________________________________________________________________ | |
432 | ||
a6e0ebfe | 433 | void AliTOFcalib::WriteParOnlineStatusOnCDB(const Char_t *sel) |
17149e6b | 434 | { |
435 | //Write calibration parameters to the CDB with infinite validity -------> new calib objs!!!!! | |
436 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 437 | const Char_t *sel1 = "Status" ; // to be consistent with TOFPreprocessor |
17149e6b | 438 | Char_t out[100]; |
439 | sprintf(out,"%s/%s",sel,sel1); | |
440 | AliCDBRunRange runrange(fFirstRun,fLastRun); | |
441 | AliDebug(2,Form("Writing TOF online status calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun())); | |
442 | AliCDBId id(out,runrange); | |
443 | AliCDBMetaData *md = new AliCDBMetaData(); | |
444 | md->SetResponsible("Chiara Zampolli"); | |
445 | if (!fStatus) { | |
446 | // deve uscire!! | |
447 | } | |
448 | man->Put(fStatus,id,md); | |
449 | delete md; | |
6dc9348d | 450 | } |
451 | //_____________________________________________________________________________ | |
a6e0ebfe | 452 | void AliTOFcalib::WriteParOnlineOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun) |
340693af | 453 | { |
454 | //Write calibration parameters to the CDB | |
0cb9d099 | 455 | SetFirstRun(minrun); |
456 | SetLastRun(maxrun); | |
6dc9348d | 457 | AliCDBManager *man = AliCDBManager::Instance(); |
a6e0ebfe | 458 | const Char_t *sel1 = "ParOnline" ; // to be consistent with TOFPreprocessor |
d4ad0d6b | 459 | Char_t out[100]; |
460 | sprintf(out,"%s/%s",sel,sel1); | |
0cb9d099 | 461 | AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun)); |
462 | AliCDBId id(out,fFirstRun,fLastRun); | |
463 | AliCDBMetaData *md = new AliCDBMetaData(); | |
464 | md->SetResponsible("Chiara Zampolli"); | |
465 | if (!fTOFCalOnline) { | |
466 | // deve uscire!! | |
467 | } | |
468 | man->Put(fTOFCalOnline,id,md); | |
469 | delete md; | |
470 | } | |
471 | //_____________________________________________________________________________ | |
a6e0ebfe | 472 | void AliTOFcalib::WriteParOnlinePulserOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun) |
7fffa85b | 473 | { |
474 | //Write calibration parameters from pulser to the CDB | |
475 | SetFirstRun(minrun); | |
476 | SetLastRun(maxrun); | |
477 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 478 | const Char_t *sel1 = "Pulser" ; // to be consistent with TOFPreprocessor |
7fffa85b | 479 | Char_t out[100]; |
480 | sprintf(out,"%s/%s",sel,sel1); | |
481 | AliDebug(2,Form("Writing TOF online calib obj from pulser on CDB with run range [%i, %i] ",fFirstRun,fLastRun)); | |
482 | AliCDBId id(out,fFirstRun,fLastRun); | |
483 | AliCDBMetaData *md = new AliCDBMetaData(); | |
484 | md->SetResponsible("Chiara Zampolli"); | |
485 | if (!fTOFCalOnlinePulser) { | |
486 | // deve uscire!! | |
487 | } | |
488 | man->Put(fTOFCalOnlinePulser,id,md); | |
489 | delete md; | |
490 | } | |
491 | //_____________________________________________________________________________ | |
a6e0ebfe | 492 | void AliTOFcalib::WriteParOnlineNoiseOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun) |
7fffa85b | 493 | { |
494 | //Write calibration parameters from noise to the CDB | |
495 | SetFirstRun(minrun); | |
496 | SetLastRun(maxrun); | |
497 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 498 | const Char_t *sel1 = "Noise" ; // to be consistent with TOFPreprocessor |
7fffa85b | 499 | Char_t out[100]; |
500 | sprintf(out,"%s/%s",sel,sel1); | |
501 | AliDebug(2,Form("Writing TOF online calib obj from noise on CDB with run range [%i, %i] ",fFirstRun,fLastRun)); | |
502 | AliCDBId id(out,fFirstRun,fLastRun); | |
503 | AliCDBMetaData *md = new AliCDBMetaData(); | |
504 | md->SetResponsible("Chiara Zampolli"); | |
505 | if (!fTOFCalOnlineNoise) { | |
506 | // deve uscire!! | |
507 | } | |
508 | man->Put(fTOFCalOnlineNoise,id,md); | |
509 | delete md; | |
510 | } | |
511 | //_____________________________________________________________________________ | |
a6e0ebfe | 512 | void AliTOFcalib::WriteParOnlineHWOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun) |
7fffa85b | 513 | { |
514 | //Write calibration parameters from hardware to the CDB | |
515 | SetFirstRun(minrun); | |
516 | SetLastRun(maxrun); | |
517 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 518 | const Char_t *sel1 = "HW" ; // to be consistent with TOFPreprocessor |
7fffa85b | 519 | Char_t out[100]; |
520 | sprintf(out,"%s/%s",sel,sel1); | |
521 | AliDebug(2,Form("Writing TOF online calib obj from hardware on CDB with run range [%i, %i] ",fFirstRun,fLastRun)); | |
522 | AliCDBId id(out,fFirstRun,fLastRun); | |
523 | AliCDBMetaData *md = new AliCDBMetaData(); | |
524 | md->SetResponsible("Chiara Zampolli"); | |
525 | if (!fTOFCalOnlineHW) { | |
526 | // deve uscire!! | |
527 | } | |
528 | man->Put(fTOFCalOnlineHW,id,md); | |
529 | delete md; | |
530 | } | |
531 | //_____________________________________________________________________________ | |
0cb9d099 | 532 | |
a6e0ebfe | 533 | void AliTOFcalib::WriteParOnlineOnCDB(const Char_t *sel) |
0cb9d099 | 534 | { |
535 | //Write calibration parameters to the CDB with infinite validity | |
536 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 537 | const Char_t *sel1 = "ParOnline" ; // to be consistent with TOFPreprocessor |
0cb9d099 | 538 | Char_t out[100]; |
539 | sprintf(out,"%s/%s",sel,sel1); | |
540 | AliCDBRunRange runrange(fFirstRun,fLastRun); | |
541 | AliDebug(2,Form("Writing TOF online calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun())); | |
542 | AliCDBId id(out,runrange); | |
6dc9348d | 543 | AliCDBMetaData *md = new AliCDBMetaData(); |
d4ad0d6b | 544 | md->SetResponsible("Chiara Zampolli"); |
0a749fa5 | 545 | if (!fTOFCalOnline) { |
546 | // deve uscire!! | |
85fc78e3 | 547 | } |
0a749fa5 | 548 | man->Put(fTOFCalOnline,id,md); |
5eaae242 | 549 | delete md; |
6dc9348d | 550 | } |
551 | //_____________________________________________________________________________ | |
552 | ||
a6e0ebfe | 553 | void AliTOFcalib::WriteParOnlinePulserOnCDB(const Char_t *sel) |
7fffa85b | 554 | { |
555 | //Write calibration parameters from pulser to the CDB with infinite validity | |
556 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 557 | const Char_t *sel1 = "Pulser" ; // to be consistent with TOFPreprocessor |
7fffa85b | 558 | Char_t out[100]; |
559 | sprintf(out,"%s/%s",sel,sel1); | |
560 | AliCDBRunRange runrange(fFirstRun,fLastRun); | |
561 | AliDebug(2,Form("Writing TOF online calib obj from pulser on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun())); | |
562 | AliCDBId id(out,runrange); | |
563 | AliCDBMetaData *md = new AliCDBMetaData(); | |
564 | md->SetResponsible("Chiara Zampolli"); | |
565 | if (!fTOFCalOnlinePulser) { | |
566 | // deve uscire!! | |
567 | } | |
568 | man->Put(fTOFCalOnlinePulser,id,md); | |
569 | delete md; | |
570 | } | |
571 | //_____________________________________________________________________________ | |
572 | ||
a6e0ebfe | 573 | void AliTOFcalib::WriteParOnlineNoiseOnCDB(const Char_t *sel) |
7fffa85b | 574 | { |
575 | //Write calibration parameters from noise to the CDB with infinite validity | |
576 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 577 | const Char_t *sel1 = "Noise" ; // to be consistent with TOFPreprocessor |
7fffa85b | 578 | Char_t out[100]; |
579 | sprintf(out,"%s/%s",sel,sel1); | |
580 | AliCDBRunRange runrange(fFirstRun,fLastRun); | |
581 | AliDebug(2,Form("Writing TOF online calib obj from noise on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun())); | |
582 | AliCDBId id(out,runrange); | |
583 | AliCDBMetaData *md = new AliCDBMetaData(); | |
584 | md->SetResponsible("Chiara Zampolli"); | |
585 | if (!fTOFCalOnlineNoise) { | |
586 | // deve uscire!! | |
587 | } | |
588 | man->Put(fTOFCalOnlineNoise,id,md); | |
589 | delete md; | |
590 | } | |
591 | //_____________________________________________________________________________ | |
592 | ||
a6e0ebfe | 593 | void AliTOFcalib::WriteParOnlineHWOnCDB(const Char_t *sel) |
7fffa85b | 594 | { |
595 | //Write calibration parameters from hardware to the CDB with infinite validity | |
596 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 597 | const Char_t *sel1 = "HW" ; // to be consistent with TOFPreprocessor |
7fffa85b | 598 | Char_t out[100]; |
599 | sprintf(out,"%s/%s",sel,sel1); | |
600 | AliCDBRunRange runrange(fFirstRun,fLastRun); | |
601 | AliDebug(2,Form("Writing TOF online calib obj from harware on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun())); | |
602 | AliCDBId id(out,runrange); | |
603 | AliCDBMetaData *md = new AliCDBMetaData(); | |
604 | md->SetResponsible("Chiara Zampolli"); | |
605 | if (!fTOFCalOnlineHW) { | |
606 | // deve uscire!! | |
607 | } | |
608 | man->Put(fTOFCalOnlineHW,id,md); | |
609 | delete md; | |
610 | } | |
611 | //_____________________________________________________________________________ | |
612 | ||
a6e0ebfe | 613 | void AliTOFcalib::WriteParOfflineOnCDB(const Char_t *sel, const Char_t *validity, Int_t minrun, Int_t maxrun) |
0a749fa5 | 614 | { |
340693af | 615 | //Write calibration parameters to the CDB |
0cb9d099 | 616 | SetFirstRun(minrun); |
617 | SetLastRun(maxrun); | |
6dc9348d | 618 | AliCDBManager *man = AliCDBManager::Instance(); |
a6e0ebfe | 619 | const Char_t *sel1 = "ParOffline" ; |
d4ad0d6b | 620 | Char_t out[100]; |
621 | sprintf(out,"%s/%s",sel,sel1); | |
0cb9d099 | 622 | AliDebug(2,Form("Writing TOF offline calib obj on CDB with run range [%i, %i] ",fFirstRun,fLastRun)); |
623 | AliCDBId id(out,fFirstRun,fLastRun); | |
624 | AliCDBMetaData *md = new AliCDBMetaData(); | |
625 | md->SetResponsible("Chiara Zampolli"); | |
626 | md->SetComment(validity); | |
627 | man->Put(fTOFCalOffline,id,md); | |
628 | delete md; | |
629 | } | |
630 | //_____________________________________________________________________________ | |
631 | ||
a6e0ebfe | 632 | void AliTOFcalib::WriteParOfflineOnCDB(const Char_t *sel, const Char_t *validity) |
0cb9d099 | 633 | { |
634 | //Write calibration parameters to the CDB with infinite validity | |
635 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 636 | const Char_t *sel1 = "ParOffline" ; |
0cb9d099 | 637 | Char_t out[100]; |
638 | sprintf(out,"%s/%s",sel,sel1); | |
639 | AliCDBRunRange runrange(fFirstRun,fLastRun); | |
640 | AliDebug(2,Form("Writing TOF offline calib obj on CDB with run range [%i, %i] ",runrange.GetFirstRun(),runrange.GetLastRun())); | |
641 | AliCDBId id(out,runrange); | |
d4ad0d6b | 642 | AliCDBMetaData *md = new AliCDBMetaData(); |
643 | md->SetResponsible("Chiara Zampolli"); | |
0a749fa5 | 644 | md->SetComment(validity); |
645 | man->Put(fTOFCalOffline,id,md); | |
5eaae242 | 646 | delete md; |
d4ad0d6b | 647 | } |
648 | //_____________________________________________________________________________ | |
649 | ||
a6e0ebfe | 650 | Bool_t AliTOFcalib::ReadConfigMapFromCDB(const Char_t *sel, Int_t nrun) |
17149e6b | 651 | { |
652 | //Read calibration parameters from the CDB | |
653 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 654 | const Char_t *sel1 = "Config" ; |
17149e6b | 655 | Char_t out[100]; |
656 | sprintf(out,"%s/%s",sel,sel1); | |
657 | AliCDBEntry *entry = man->Get(out,nrun); | |
658 | if (!entry) { | |
659 | AliFatal("Exiting, no CDB object (ConfigMap) found!!!"); | |
660 | exit(0); | |
661 | } | |
662 | if(!entry->GetObject()){ | |
663 | AliFatal("Exiting, no CDB object (ConfigMap) found!!!"); | |
664 | exit(0); | |
665 | } | |
666 | ||
667 | fConfigMap =(TMap*)entry->GetObject(); | |
668 | ||
669 | return kTRUE; | |
670 | ||
671 | } | |
672 | //_____________________________________________________________________________ | |
673 | ||
a6e0ebfe | 674 | Bool_t AliTOFcalib::ReadParOnlineDelayFromCDB(const Char_t *sel, Int_t nrun) |
17149e6b | 675 | { |
676 | //Read calibration parameters from the CDB -------> new calib objs!!!!! | |
677 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 678 | const Char_t *sel1 = "ParOnlineDelay" ; |
17149e6b | 679 | Char_t out[100]; |
680 | sprintf(out,"%s/%s",sel,sel1); | |
681 | AliCDBEntry *entry = man->Get(out,nrun); | |
682 | if (!entry) { | |
683 | AliFatal("Exiting, no CDB object (ParOnlineDelay) found!!!"); | |
684 | exit(0); | |
685 | } | |
686 | if(!entry->GetObject()){ | |
687 | AliFatal("Exiting, no CDB object (ParOnlineDelay) found!!!"); | |
688 | exit(0); | |
689 | } | |
690 | ||
691 | fCal =(AliTOFChannelOnlineArray*)entry->GetObject(); | |
692 | ||
693 | return kTRUE; | |
694 | ||
695 | } | |
696 | //_____________________________________________________________________________ | |
697 | ||
a6e0ebfe | 698 | Bool_t AliTOFcalib::ReadParOnlineStatusFromCDB(const Char_t *sel, Int_t nrun) |
17149e6b | 699 | { |
700 | //Read calibration parameters from the CDB -------> new calib objs!!!!! | |
701 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 702 | const Char_t *sel1 = "Status" ; |
17149e6b | 703 | Char_t out[100]; |
704 | sprintf(out,"%s/%s",sel,sel1); | |
705 | AliCDBEntry *entry = man->Get(out,nrun); | |
706 | if (!entry) { | |
707 | AliFatal("Exiting, no CDB object (Status) found!!!"); | |
708 | exit(0); | |
709 | } | |
710 | if(!entry->GetObject()){ | |
711 | AliFatal("Exiting, no CDB object (Status) found!!!"); | |
712 | exit(0); | |
713 | } | |
714 | ||
715 | fStatus =(AliTOFChannelOnlineStatusArray*)entry->GetObject(); | |
716 | ||
717 | return kTRUE; | |
718 | ||
719 | } | |
720 | //_____________________________________________________________________________ | |
721 | ||
a6e0ebfe | 722 | Bool_t AliTOFcalib::ReadParOnlineFromCDB(const Char_t *sel, Int_t nrun) |
340693af | 723 | { |
724 | //Read calibration parameters from the CDB | |
d4ad0d6b | 725 | AliCDBManager *man = AliCDBManager::Instance(); |
a6e0ebfe | 726 | const Char_t *sel1 = "ParOnline" ; |
d4ad0d6b | 727 | Char_t out[100]; |
728 | sprintf(out,"%s/%s",sel,sel1); | |
7a4f634e | 729 | AliCDBEntry *entry = man->Get(out,nrun); |
c30c0a38 | 730 | if (!entry) { |
731 | AliFatal("Exiting, no CDB object (ParOnline) found!!!"); | |
732 | exit(0); | |
733 | } | |
7a4f634e | 734 | if(!entry->GetObject()){ |
c30c0a38 | 735 | AliFatal("Exiting, no CDB object (ParOnline) found!!!"); |
736 | exit(0); | |
7a4f634e | 737 | } |
738 | ||
0a749fa5 | 739 | fTOFCalOnline =(TObjArray*)entry->GetObject(); |
7fffa85b | 740 | |
741 | return kTRUE; | |
742 | ||
743 | } | |
744 | //_____________________________________________________________________________ | |
745 | ||
a6e0ebfe | 746 | Bool_t AliTOFcalib::ReadParOnlinePulserFromCDB(const Char_t *sel, Int_t nrun) |
7fffa85b | 747 | { |
748 | //Read calibration parameters from pulser from the CDB | |
749 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 750 | const Char_t *sel1 = "Pulser" ; |
7fffa85b | 751 | Char_t out[100]; |
752 | sprintf(out,"%s/%s",sel,sel1); | |
7fffa85b | 753 | AliCDBEntry *entry = man->Get(out,nrun); |
c30c0a38 | 754 | if (!entry) { |
755 | AliFatal("Exiting, no CDB object (Pulser) found!!!"); | |
756 | exit(0); | |
757 | } | |
7fffa85b | 758 | if(!entry->GetObject()){ |
c30c0a38 | 759 | AliFatal("Exiting, no CDB object (Pulser) found!!!"); |
760 | exit(0); | |
7fffa85b | 761 | } |
762 | ||
763 | fTOFCalOnlinePulser =(TObjArray*)entry->GetObject(); | |
764 | ||
765 | return kTRUE; | |
766 | ||
767 | } | |
768 | //_____________________________________________________________________________ | |
769 | ||
a6e0ebfe | 770 | Bool_t AliTOFcalib::ReadParOnlineNoiseFromCDB(const Char_t *sel, Int_t nrun) |
7fffa85b | 771 | { |
772 | //Read calibration parameters from noise from the CDB | |
773 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 774 | const Char_t *sel1 = "Noise" ; |
7fffa85b | 775 | Char_t out[100]; |
776 | sprintf(out,"%s/%s",sel,sel1); | |
7fffa85b | 777 | AliCDBEntry *entry = man->Get(out,nrun); |
c30c0a38 | 778 | if (!entry) { |
779 | AliFatal("Exiting, no CDB object (Noise) found!!!"); | |
780 | exit(0); | |
781 | } | |
7fffa85b | 782 | if(!entry->GetObject()){ |
c30c0a38 | 783 | AliFatal("Exiting, no CDB object (Noise) found!!!"); |
784 | exit(0); | |
7fffa85b | 785 | } |
786 | ||
787 | fTOFCalOnlineNoise =(TObjArray*)entry->GetObject(); | |
788 | ||
789 | return kTRUE; | |
790 | ||
791 | } | |
792 | //_____________________________________________________________________________ | |
793 | ||
a6e0ebfe | 794 | Bool_t AliTOFcalib::ReadParOnlineHWFromCDB(const Char_t *sel, Int_t nrun) |
7fffa85b | 795 | { |
796 | //Read calibration parameters from hardware from the CDB | |
797 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 798 | const Char_t *sel1 = "HW" ; |
7fffa85b | 799 | Char_t out[100]; |
800 | sprintf(out,"%s/%s",sel,sel1); | |
7fffa85b | 801 | AliCDBEntry *entry = man->Get(out,nrun); |
c30c0a38 | 802 | if (!entry) { |
803 | AliFatal("Exiting, no CDB object (HW map) found!!!"); | |
804 | exit(0); | |
805 | } | |
7fffa85b | 806 | if(!entry->GetObject()){ |
c30c0a38 | 807 | AliFatal("Exiting, no CDB object (HW map) found!!!"); |
808 | exit(0); | |
7fffa85b | 809 | } |
810 | ||
811 | fTOFCalOnlineHW =(TObjArray*)entry->GetObject(); | |
0a749fa5 | 812 | |
1b20c168 | 813 | return kTRUE; |
7a4f634e | 814 | |
6dc9348d | 815 | } |
816 | //_____________________________________________________________________________ | |
d4ad0d6b | 817 | |
a6e0ebfe | 818 | Bool_t AliTOFcalib::ReadParOfflineFromCDB(const Char_t *sel, Int_t nrun) |
0a749fa5 | 819 | { |
820 | //Read calibration parameters from the CDB | |
821 | AliCDBManager *man = AliCDBManager::Instance(); | |
a6e0ebfe | 822 | const Char_t *sel1 = "ParOffline" ; |
0a749fa5 | 823 | Char_t out[100]; |
824 | sprintf(out,"%s/%s",sel,sel1); | |
0a749fa5 | 825 | AliCDBEntry *entry = man->Get(out,nrun); |
c30c0a38 | 826 | if (!entry) { |
827 | AliFatal("Exiting, no CDB object (ParOffline) found!!!"); | |
828 | exit(0); | |
829 | } | |
0a749fa5 | 830 | if(!entry->GetObject()){ |
c30c0a38 | 831 | AliFatal("Exiting, no CDB object (ParOffline) found!!!"); |
832 | exit(0); | |
0a749fa5 | 833 | } |
834 | AliCDBMetaData * md = entry->GetMetaData(); | |
835 | fkValidity = md->GetComment(); | |
836 | fTOFCalOffline =(TObjArray*)entry->GetObject(); | |
d4ad0d6b | 837 | |
0a749fa5 | 838 | return kTRUE; |
839 | ||
840 | } | |
841 | //_____________________________________________________________________________ | |
a6e0ebfe | 842 | void AliTOFcalib::WriteSimHistoOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, TH1F *histo){ |
340693af | 843 | //Write Sim miscalibration parameters to the CDB |
d4ad0d6b | 844 | |
d4ad0d6b | 845 | fTOFSimToT=histo; |
d4ad0d6b | 846 | AliCDBManager *man = AliCDBManager::Instance(); |
a6e0ebfe | 847 | const Char_t *sel1 = "SimHisto" ; |
d4ad0d6b | 848 | Char_t out[100]; |
849 | sprintf(out,"%s/%s",sel,sel1); | |
0a749fa5 | 850 | AliCDBMetaData *mdhisto = new AliCDBMetaData(); |
851 | mdhisto->SetResponsible("Chiara Zampolli"); | |
40212801 | 852 | AliCDBId id(out,minrun,maxrun); |
853 | man->Put(fTOFSimToT,id,mdhisto); | |
0a749fa5 | 854 | delete mdhisto; |
855 | } | |
856 | //_____________________________________________________________________________ | |
a6e0ebfe | 857 | Bool_t AliTOFcalib::ReadSimHistoFromCDB(const Char_t *sel, Int_t nrun) |
0a749fa5 | 858 | { |
859 | //Read miscalibration parameters from the CDB | |
860 | AliCDBManager *man = AliCDBManager::Instance(); | |
861 | ||
40212801 | 862 | // The Tot Histo |
7a4f634e | 863 | |
a6e0ebfe | 864 | const Char_t *sel1 = "SimHisto" ; |
d4ad0d6b | 865 | Char_t out[100]; |
866 | sprintf(out,"%s/%s",sel,sel1); | |
c30c0a38 | 867 | AliCDBEntry *entry = man->Get(out,nrun); |
868 | if (!entry) { | |
7a4f634e | 869 | AliFatal("Exiting, no CDB object (SimHisto) found!!!"); |
870 | exit(0); | |
871 | } | |
40212801 | 872 | if(!entry->GetObject()){ |
7a4f634e | 873 | AliFatal("Exiting, no CDB object (SimHisto) found!!!"); |
874 | exit(0); | |
875 | } | |
40212801 | 876 | TH1F *histo =(TH1F*)entry->GetObject(); |
d4ad0d6b | 877 | fTOFSimToT=histo; |
52be7fb0 | 878 | return kTRUE; |
d4ad0d6b | 879 | } |
7037bd93 | 880 | //_____________________________________________________________________________ |
a6e0ebfe | 881 | void AliTOFcalib::WriteRecParOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, AliTOFRecoParam *param){ |
7037bd93 | 882 | //Write reconstruction parameters to the CDB |
883 | ||
884 | AliCDBManager *man = AliCDBManager::Instance(); | |
7037bd93 | 885 | AliCDBMetaData *md = new AliCDBMetaData(); |
886 | md->SetResponsible("Silvia Arcelli"); | |
641168d2 | 887 | const Char_t *sel1 = "RecoParam" ; |
7037bd93 | 888 | Char_t out[100]; |
889 | sprintf(out,"%s/%s",sel,sel1); | |
890 | AliCDBId id(out,minrun,maxrun); | |
891 | man->Put(param,id,md); | |
892 | delete md; | |
893 | } | |
894 | //_____________________________________________________________________________ | |
a6e0ebfe | 895 | AliTOFRecoParam * AliTOFcalib::ReadRecParFromCDB(const Char_t *sel, Int_t nrun) |
7037bd93 | 896 | { |
897 | //Read reconstruction parameters from the CDB | |
898 | AliCDBManager *man = AliCDBManager::Instance(); | |
641168d2 | 899 | const Char_t *sel1 = "RecoParam" ; |
7037bd93 | 900 | Char_t out[100]; |
901 | sprintf(out,"%s/%s",sel,sel1); | |
c30c0a38 | 902 | AliCDBEntry *entry = man->Get(out,nrun); |
903 | if (!entry) { | |
641168d2 | 904 | AliFatal("Exiting, no CDB object (RecoParam) found!!!"); |
7a4f634e | 905 | exit(0); |
906 | } | |
7a4f634e | 907 | if(!entry->GetObject()){ |
641168d2 | 908 | AliFatal("Exiting, no CDB object (RecoParam) found!!!"); |
7a4f634e | 909 | exit(0); |
910 | } | |
911 | ||
7037bd93 | 912 | AliTOFRecoParam *param=(AliTOFRecoParam*)entry->GetObject(); |
913 | return param; | |
914 | } | |
0a749fa5 | 915 | //----------------------------------------------------------------------------- |
916 | // Calibration methods | |
917 | //----------------------------------------------------------------------------- | |
918 | void AliTOFcalib::CreateTreeFromCDB(Int_t minrun, Int_t maxrun){ | |
919 | ||
920 | // creating the chain with the trees for calibration | |
921 | // collecting them from reference data | |
922 | // from minrun to maxrun | |
923 | ||
924 | Float_t p[CHENTRIESSMALL]; | |
925 | Int_t nentries; | |
926 | fTree = new TTree("TOFCalib","Tree for TOF Calibration"); | |
927 | fTree->Branch("nentries",&nentries,"nentries/I"); | |
928 | fTree->Branch("TOFentries",p,"TOFentries[nentries]/F"); | |
929 | AliCDBManager *man = AliCDBManager::Instance(); | |
162637e4 | 930 | AliCDBStorage *aStorage = man->GetStorage("local://$ALICE_ROOT/OCDB"); |
0a749fa5 | 931 | for (Int_t irun = minrun;irun<=maxrun;irun++){ |
932 | AliCDBEntry *entry = aStorage->Get("TOF/RefData/TreeForCalib",irun); | |
933 | if (!entry){ | |
934 | AliInfo(Form("No entry found for run %i",irun)); | |
935 | } | |
936 | else{ | |
937 | TTree *tree = new TTree(); | |
938 | tree = (TTree*)entry->GetObject(); | |
939 | tree->SetBranchAddress("nentries",&nentries); | |
940 | tree->SetBranchAddress("TOFentries",p); | |
941 | fTree->CopyEntries(tree); | |
942 | delete tree; | |
943 | fNruns++; | |
944 | } | |
945 | } | |
946 | AliInfo(Form("Number of runs being analyzed %i",fNruns)); | |
947 | } | |
948 | //----------------------------------------------------------------------------- | |
949 | void AliTOFcalib::CreateTreeFromGrid(Int_t minrun, Int_t maxrun){ | |
950 | ||
951 | // creating the chain with the trees for calibration | |
952 | // collecting them from the Grid | |
953 | // from minrun to maxrun | |
954 | ||
955 | Float_t p[CHENTRIESSMALL]; | |
956 | Int_t nentries; | |
957 | fTree = new TTree("TOFCalib","Tree for TOF Calibration"); | |
958 | fTree->SetDirectory(0); | |
959 | fTree->Branch("nentries",&nentries,"nentries/I"); | |
960 | fTree->Branch("TOFentries",p,"TOFentries[nentries]/F"); | |
961 | AliInfo("connected to alien"); | |
962 | TGrid::Connect("alien://"); | |
963 | ||
964 | Char_t filename[100]; | |
965 | for (Int_t irun = minrun;irun<=maxrun;irun++){ | |
966 | sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun); | |
967 | TFile *filegrid = TFile::Open(filename,"READ"); | |
968 | TTree *tree = (TTree*)filegrid->Get("T"); | |
969 | tree->SetBranchAddress("nentries",&nentries); | |
970 | tree->SetBranchAddress("TOFentries",p); | |
971 | fTree->CopyEntries(tree); | |
972 | delete tree; | |
973 | fNruns++; | |
974 | } | |
975 | ||
976 | AliInfo(Form("Number of runs being analyzed %i",fNruns)); | |
977 | } | |
978 | //----------------------------------------------------------------------------- | |
979 | void AliTOFcalib::CreateTreeFromFile(Int_t minrun, Int_t maxrun){ | |
980 | ||
981 | // creating the tree with the trees for calibration | |
982 | // collecting them from reference data (from file) | |
983 | // from minrun to maxrun | |
984 | ||
985 | Float_t p[CHENTRIESSMALL]; | |
986 | Int_t nentries; | |
987 | fTree = new TTree("TOFCalib","Tree for TOF Calibration"); | |
988 | fTree->SetDirectory(0); | |
989 | fTree->Branch("nentries",&nentries,"nentries/I"); | |
990 | fTree->Branch("TOFentries",p,"TOFentries[nentries]/F"); | |
991 | Char_t filename[100]; | |
992 | for (Int_t irun = minrun;irun<=maxrun;irun++){ | |
993 | sprintf(filename,"$ALICE_ROOT/TOF/RefData/TreeForCalib/fileout_%i.root",irun); | |
994 | TFile *file = new TFile(filename,"READ"); | |
995 | TTree *tree = (TTree*)file->Get("T"); | |
996 | tree->SetBranchAddress("nentries",&nentries); | |
997 | tree->SetBranchAddress("TOFentries",p); | |
998 | fTree->CopyEntries(tree); | |
999 | delete tree; | |
1000 | delete file; | |
1001 | file = 0x0; | |
1002 | fNruns++; | |
1003 | } | |
1004 | ||
1005 | AliInfo(Form("Number of runs being analyzed %i",fNruns)); | |
1006 | } | |
1007 | //----------------------------------------------------------------------------- | |
296591ad | 1008 | void AliTOFcalib::CreateChainFromGrid(Int_t minrun, Int_t maxrun){ |
1009 | ||
1010 | // creating the chain with the trees for calibration | |
1011 | // collecting them from the Grid | |
1012 | // from minrun to maxrun | |
1013 | ||
1014 | fChain = new TChain("T"); | |
1015 | AliInfo("connected to alien"); | |
1016 | TGrid::Connect("alien://"); | |
1017 | ||
1018 | Char_t filename[100]; | |
1019 | for (Int_t irun = minrun;irun<=maxrun;irun++){ | |
1020 | sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun); | |
1021 | fChain->Add(filename); | |
1022 | fNruns++; | |
1023 | } | |
1024 | ||
1025 | AliInfo(Form("Number of runs being analyzed %i",fNruns)); | |
1026 | } | |
1027 | //----------------------------------------------------------------------------- | |
0a749fa5 | 1028 | Int_t AliTOFcalib::Calibrate(Int_t ichmin, Int_t ichmax, Option_t *optionSave, Option_t *optionFit){ |
7037bd93 | 1029 | |
0a749fa5 | 1030 | // calibrating summing more than one channels |
1031 | // computing calibration parameters | |
1032 | // Returning codes: | |
1033 | // 0 -> everything was ok | |
1034 | // 1 -> no tree for calibration found | |
1035 | // 2 -> not enough statistics to perform calibration | |
1036 | // 3 -> problems with arrays | |
1037 | ||
1038 | TH1::AddDirectory(0); | |
1039 | ||
1040 | AliInfo(Form("*** Calibrating Histograms %s, summing more channels, from channel %i, to channel %i, storing Calib Pars in channel %i", GetName(),ichmin,ichmax,ichmin)) ; | |
1041 | AliInfo(Form("Option for Saving histos = %s",optionSave )) ; | |
1042 | AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ; | |
1043 | ||
1044 | Float_t p[CHENTRIESSMALL]; | |
1045 | Int_t nentries; | |
296591ad | 1046 | //fTree->SetBranchAddress("nentries",&nentries); |
1047 | //fTree->SetBranchAddress("TOFentries",p); | |
1048 | fChain->SetBranchAddress("nentries",&nentries); | |
1049 | fChain->SetBranchAddress("TOFentries",p); | |
0a749fa5 | 1050 | |
1051 | Float_t ntracksTotalmean =0; | |
1052 | for (Int_t i=ichmin; i<ichmax; i++){ | |
1053 | Int_t ientry = -1; | |
1054 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1055 | ientry = i+irun*fNChannels; | |
296591ad | 1056 | //fTree->GetEntry(ientry); |
1057 | fChain->GetEntry(ientry); | |
0a749fa5 | 1058 | Int_t ntracksRun=nentries/3; |
1059 | ntracksTotalmean+=ntracksRun; | |
1060 | } | |
1061 | } | |
1062 | ||
1063 | if (ntracksTotalmean < MEANENTRIES) { | |
1064 | AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean)); | |
1065 | return 2; | |
1066 | } | |
1067 | ||
1068 | //filling ToT and Time arrays | |
1069 | ||
1070 | Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps | |
1071 | Float_t minToT = 0; // ns | |
1072 | Float_t maxToT = 4.88; // ns | |
1073 | ||
1074 | TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT); | |
1075 | TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4); | |
1076 | Int_t ntracksTotal = 0; | |
1077 | Int_t ntracksRun = 0; | |
1078 | Double_t binsProfile[101]; // sized larger than necessary, the correct | |
1079 | // dim being set in the booking of the profile | |
1080 | Int_t nusefulbins=0; | |
1081 | Float_t meantime=0; | |
1082 | for (Int_t i = ichmin;i<ichmax;i++){ | |
1083 | Int_t ientry = -1; | |
1084 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1085 | ientry = i+irun*fNChannels; | |
296591ad | 1086 | //fTree->GetEntry(ientry); |
1087 | fChain->GetEntry(ientry); | |
0a749fa5 | 1088 | ntracksTotal+=nentries/3; |
1089 | ntracksRun=nentries/3; | |
1090 | AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracks = %i",irun,i,nentries, ntracksRun)); | |
1091 | for (Int_t j=0;j<ntracksRun;j++){ | |
1092 | Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT; | |
1093 | Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME; | |
1094 | Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID; | |
1095 | Float_t tot = p[idxexToT]; | |
1096 | hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]); | |
1097 | meantime+=p[idxexTime]-p[idxexExTime]; | |
1098 | hToT->Fill(tot); | |
1099 | } | |
1100 | } | |
1101 | } | |
1102 | nusefulbins = FindBins(hToT,&binsProfile[0]); | |
1103 | meantime/=ntracksTotal; | |
1104 | AliDebug(2, Form("meantime = %f",meantime)); | |
1105 | ||
1106 | for (Int_t j=1;j<=nusefulbins;j++) { | |
1107 | AliDebug(2,Form(" summing channels from %i to %i, nusefulbins = %i, bin %i = %f",ichmin,ichmax,nusefulbins,j,binsProfile[j])); | |
1108 | } | |
1109 | ||
1110 | TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!! | |
1111 | TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10); | |
1112 | ||
1113 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1114 | Int_t ientry = -1; | |
1115 | for (Int_t i=ichmin; i<ichmax; i++){ | |
1116 | ientry = i+irun*fNChannels; | |
296591ad | 1117 | //fTree->GetEntry(ientry); |
1118 | fChain->GetEntry(ientry); | |
0a749fa5 | 1119 | ntracksRun=nentries/3; |
1120 | for (Int_t j=0;j<ntracksRun;j++){ | |
1121 | Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT; | |
1122 | Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME; | |
1123 | Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID; | |
1124 | Float_t tot = p[idxexToT]; | |
1125 | Float_t time = p[idxexTime]-p[idxexExTime]; | |
1126 | AliDebug (2, Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime)); | |
1127 | hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above | |
1128 | htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above | |
1129 | } | |
1130 | } | |
1131 | } | |
1132 | ||
1133 | hSlewingProf->Fit("pol5",optionFit,"",0,4); | |
1134 | TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5"); | |
1135 | Float_t par[6]; | |
1136 | for(Int_t kk=0;kk<6;kk++){ | |
1137 | par[kk]=calibfunc->GetParameter(kk); | |
1138 | AliDebug(2,Form("parameter %i = %f",kk,par[kk])); | |
1139 | } | |
1140 | ||
1141 | if(strstr(optionSave,"save")){ | |
1142 | TFile * fileProf = new TFile("TOFCalibSave.root","recreate"); | |
1143 | fileProf->cd(); | |
1144 | TString profName=Form("Profile%06i_%06i",ichmin,ichmax); | |
1145 | TString timeTotName=Form("TimeTot%06i_%06i",ichmin,ichmax); | |
1146 | TString totName=Form("Tot%06i_%06i",ichmin,ichmax); | |
1147 | TString deltaName=Form("Delta%06i_%06i",ichmin,ichmax); | |
1148 | hSlewingProf->Write(profName); | |
1149 | htimetot->Write(timeTotName); | |
1150 | hToT->Write(totName); | |
1151 | hdeltaTime->Write(deltaName); | |
1152 | fileProf->Close(); | |
1153 | delete fileProf; | |
1154 | fileProf=0x0; | |
1155 | } | |
1156 | ||
1157 | delete hToT; | |
1158 | hToT=0x0; | |
1159 | delete hSlewingProf; | |
1160 | hSlewingProf=0x0; | |
1161 | delete htimetot; | |
1162 | htimetot=0x0; | |
1163 | delete hdeltaTime; | |
1164 | hdeltaTime=0x0; | |
1165 | ||
1166 | AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ichmin); | |
1167 | calChannel->SetSlewPar(par); | |
0cb9d099 | 1168 | WriteParOfflineOnCDB("TOF/Calib","valid"); |
0a749fa5 | 1169 | return 0; |
1170 | } | |
1171 | //---------------------------------------------------------------------------- | |
1172 | Int_t AliTOFcalib::Calibrate(Int_t i, Option_t *optionSave, Option_t *optionFit){ | |
1173 | ||
1174 | // computing calibration parameters for channel i | |
1175 | // Returning codes: | |
1176 | // 0 -> everything was ok | |
1177 | // 1 -> no tree for calibration found | |
1178 | // 2 -> not enough statistics to perform calibration | |
1179 | // 3 -> problems with arrays | |
1180 | ||
1181 | TH1::AddDirectory(0); | |
1182 | ||
1183 | AliInfo(Form("*** Calibrating Histograms (one channel) %s", GetName())) ; | |
1184 | AliInfo(Form("Option for Saving histos = %s",optionSave )) ; | |
1185 | AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ; | |
1186 | ||
1187 | Float_t p[MAXCHENTRIESSMALL]; | |
1188 | Int_t nentries; | |
296591ad | 1189 | //fTree->SetBranchAddress("nentries",&nentries); |
1190 | //fTree->SetBranchAddress("TOFentries",p); | |
1191 | fChain->SetBranchAddress("nentries",&nentries); | |
1192 | fChain->SetBranchAddress("TOFentries",p); | |
0a749fa5 | 1193 | |
1194 | Float_t ntracksTotal =0; | |
1195 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1196 | Int_t ientry = -1; | |
1197 | ientry = i+irun*fNChannels; | |
296591ad | 1198 | //fTree->GetEntry(ientry); |
1199 | fChain->GetEntry(ientry); | |
0a749fa5 | 1200 | ntracksTotal+=nentries/3; |
1201 | } | |
1202 | ||
1203 | if (ntracksTotal < MEANENTRIES) { | |
1204 | AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal)); | |
1205 | return 2; | |
1206 | } | |
1207 | ||
1208 | //filling ToT and Time arrays | |
1209 | ||
1210 | Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps | |
1211 | Float_t minToT = 0; // ns | |
1212 | Float_t maxToT = 4.88; // ns | |
1213 | ||
1214 | TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT); | |
1215 | TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4); | |
1216 | Int_t ntracksRun = 0; | |
1217 | Double_t binsProfile[101]; // sized larger than necessary, the correct | |
1218 | // dim being set in the booking of the profile | |
1219 | Int_t nusefulbins=0; | |
1220 | Float_t meantime=0; | |
1221 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1222 | Int_t ientry = -1; | |
1223 | ientry = i+irun*fNChannels; | |
296591ad | 1224 | //fTree->GetEntry(ientry); |
1225 | fChain->GetEntry(ientry); | |
0a749fa5 | 1226 | ntracksRun=nentries/3; |
1227 | AliDebug(2,Form("run %i, channel %i, nentries = %i, ntracksRun = %i",irun, i ,nentries, ntracksRun)); | |
1228 | for (Int_t j=0;j<ntracksRun;j++){ | |
1229 | Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT; | |
1230 | Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME; | |
1231 | Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID; | |
1232 | Float_t tot = p[idxexToT]; | |
1233 | meantime+=p[idxexTime]-p[idxexExTime]; | |
1234 | hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]); | |
1235 | hToT->Fill(tot); | |
1236 | } | |
1237 | } | |
1238 | ||
1239 | nusefulbins = FindBins(hToT,&binsProfile[0]); | |
1240 | meantime/=ntracksTotal; | |
1241 | AliDebug(2,Form("meantime = %f",meantime)); | |
1242 | ||
1243 | for (Int_t j=1;j<=nusefulbins;j++) { | |
1244 | AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j])); | |
1245 | } | |
1246 | ||
1247 | TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!! | |
1248 | TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10); | |
1249 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1250 | Int_t ientry = -1; | |
1251 | ientry = i+irun*fNChannels; | |
296591ad | 1252 | //fTree->GetEntry(ientry); |
1253 | fChain->GetEntry(ientry); | |
0a749fa5 | 1254 | ntracksRun=nentries/3; |
1255 | for (Int_t j=0;j<ntracksRun;j++){ | |
1256 | Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT; | |
1257 | Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME; | |
1258 | Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID; | |
1259 | Float_t tot = p[idxexToT]; | |
1260 | Float_t time = p[idxexTime]-p[idxexExTime]; | |
1261 | AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime)); | |
1262 | hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above | |
1263 | htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above | |
1264 | } | |
1265 | } | |
1266 | ||
1267 | hSlewingProf->Fit("pol5",optionFit,"",0,4); | |
1268 | TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5"); | |
1269 | Float_t par[6]; | |
1270 | for(Int_t kk=0;kk<6;kk++){ | |
1271 | par[kk]=calibfunc->GetParameter(kk); | |
1272 | AliDebug(2,Form("parameter %i = %f",kk,par[kk])); | |
1273 | } | |
1274 | ||
1275 | ||
1276 | if(strstr(optionSave,"save")){ | |
1277 | TFile * fileProf = new TFile("TOFCalibSave.root","recreate"); | |
1278 | fileProf->cd(); | |
1279 | TString profName=Form("Profile%06i",i); | |
1280 | TString timeTotName=Form("TimeTot%06i",i); | |
1281 | TString totName=Form("Tot%06i",i); | |
1282 | TString deltaName=Form("Delta%06i",i); | |
1283 | hSlewingProf->Write(profName); | |
1284 | htimetot->Write(timeTotName); | |
1285 | hToT->Write(totName); | |
1286 | hdeltaTime->Write(deltaName); | |
1287 | fileProf->Close(); | |
1288 | delete fileProf; | |
1289 | fileProf=0x0; | |
1290 | } | |
1291 | ||
1292 | delete hToT; | |
1293 | hToT=0x0; | |
1294 | delete hSlewingProf; | |
1295 | hSlewingProf=0x0; | |
1296 | delete htimetot; | |
1297 | htimetot=0x0; | |
1298 | delete hdeltaTime; | |
1299 | hdeltaTime=0x0; | |
1300 | ||
1301 | AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(i); | |
1302 | calChannel->SetSlewPar(par); | |
0cb9d099 | 1303 | WriteParOfflineOnCDB("TOF/Calib","valid"); |
0a749fa5 | 1304 | return 0; |
1305 | } | |
1306 | //---------------------------------------------------------------------------- | |
1307 | Int_t AliTOFcalib::Calibrate(Int_t nch, Int_t *ch, Option_t *optionSave, Option_t *optionFit){ | |
1308 | ||
1309 | // calibrating an array of channels | |
1310 | // computing calibration parameters | |
1311 | // Returning codes: | |
1312 | // 0 -> everything was ok | |
1313 | // 1 -> no tree for calibration found | |
1314 | // 2 -> not enough statistics to perform calibration | |
1315 | // 3 -> problems with arrays | |
1316 | ||
1317 | TH1::AddDirectory(0); | |
1318 | ||
1319 | AliInfo(Form("*** Calibrating Histograms %s, number of channels = %i", GetName(),nch)) ; | |
1320 | AliInfo(Form("Option for Saving histos = %s",optionSave )) ; | |
1321 | AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ; | |
1322 | for (Int_t ich=0; ich<nch; ich++){ | |
1323 | Int_t i = ch[ich]; | |
1324 | AliInfo(Form("Calibrating channel = %i",i )) ; | |
1325 | } | |
1326 | Float_t p[MAXCHENTRIESSMALL]; | |
1327 | Int_t nentries; | |
296591ad | 1328 | //fTree->SetBranchAddress("nentries",&nentries); |
1329 | //fTree->SetBranchAddress("TOFentries",p); | |
1330 | fChain->SetBranchAddress("nentries",&nentries); | |
1331 | fChain->SetBranchAddress("TOFentries",p); | |
0a749fa5 | 1332 | |
1333 | Float_t ntracksTotalmean =0; | |
1334 | for (Int_t ich=0; ich<nch; ich++){ | |
1335 | Int_t ientry = -1; | |
1336 | Int_t i = ch[ich]; | |
1337 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1338 | ientry = i+irun*fNChannels; | |
296591ad | 1339 | //fTree->GetEntry(ientry); |
1340 | fChain->GetEntry(ientry); | |
0a749fa5 | 1341 | ntracksTotalmean+=nentries/3; |
1342 | } | |
1343 | } | |
1344 | ||
1345 | ntracksTotalmean/=nch; | |
1346 | if (ntracksTotalmean < MEANENTRIES) { | |
1347 | AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean)); | |
1348 | return 2; | |
1349 | } | |
1350 | ||
1351 | //filling ToT and Time arrays | |
1352 | ||
1353 | Int_t nbinToT = 100; // ToT bin width in Profile = 48.8 ps | |
1354 | Float_t minToT = 0; // ns | |
1355 | Float_t maxToT = 4.88; // ns | |
1356 | TFile * fileProf=0x0; | |
1357 | if(strstr(optionSave,"save")){ | |
1358 | fileProf = new TFile("TOFCalibSave.root","recreate"); | |
1359 | } | |
1360 | for (Int_t ich=0; ich<nch; ich++) { | |
1361 | TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT); | |
1362 | TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4); | |
1363 | Double_t binsProfile[101]; // sized larger than necessary, the correct | |
1364 | // dim being set in the booking of the profile | |
1365 | TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10); | |
1366 | Int_t ntracksTotal = 0; | |
1367 | Int_t ntracksRun = 0; | |
1368 | Int_t nusefulbins=0; | |
1369 | Float_t meantime=0; | |
1370 | Int_t i=-1; | |
1371 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1372 | i = ch[ich]+irun*fNChannels; | |
1373 | AliDebug(2,Form("Calibrating channel %i",i)); | |
296591ad | 1374 | //fTree->GetEntry(i); |
1375 | fChain->GetEntry(i); | |
0a749fa5 | 1376 | ntracksTotal+=nentries/3; |
1377 | } | |
1378 | if (ntracksTotal < MEANENTRIES) { | |
1379 | AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",i,ntracksTotal)); | |
1380 | continue; | |
1381 | } | |
1382 | ||
1383 | for (Int_t irun=0;irun<fNruns;irun++){ | |
3c609b5c | 1384 | i = ch[ich]+irun*fNChannels; |
296591ad | 1385 | //fTree->GetEntry(i); |
1386 | fChain->GetEntry(i); | |
0a749fa5 | 1387 | ntracksRun=nentries/3; |
1388 | for (Int_t j=0;j<ntracksRun;j++){ | |
1389 | Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT; | |
1390 | Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME; | |
1391 | Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID; | |
1392 | Float_t tot = p[idxexToT]; | |
1393 | hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]); | |
1394 | meantime+=p[idxexTime]-p[idxexExTime]; | |
1395 | hToT->Fill(tot); | |
1396 | } | |
1397 | } | |
1398 | ||
1399 | nusefulbins = FindBins(hToT,&binsProfile[0]); | |
1400 | meantime/=ntracksTotal; | |
1401 | for (Int_t j=1;j<=nusefulbins;j++) { | |
1402 | AliDebug(2,Form(" channel %i, nusefulbins = %i, bin %i = %f",i,nusefulbins,j,binsProfile[j])); | |
1403 | } | |
1404 | ||
1405 | TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!! | |
1406 | for (Int_t irun=0;irun<fNruns;irun++){ | |
3c609b5c | 1407 | i = ch[ich]+irun*fNChannels; |
296591ad | 1408 | //fTree->GetEntry(i); |
1409 | fChain->GetEntry(i); | |
0a749fa5 | 1410 | ntracksRun=nentries/3; |
1411 | for (Int_t j=0;j<ntracksRun;j++){ | |
1412 | Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT; | |
1413 | Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME; | |
1414 | Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID; | |
1415 | Float_t tot = p[idxexToT]; | |
1416 | Float_t time = p[idxexTime]-p[idxexExTime]; | |
1417 | AliDebug(2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime)); | |
1418 | hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above | |
1419 | htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above | |
1420 | } | |
1421 | } | |
1422 | ||
1423 | hSlewingProf->Fit("pol5",optionFit,"",1,4); | |
1424 | TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5"); | |
1425 | Float_t par[6]; | |
1426 | for(Int_t kk=0;kk<6;kk++){ | |
1427 | par[kk]=calibfunc->GetParameter(kk); | |
1428 | AliDebug(2,Form("parameter %i = %f",kk,par[kk])); | |
1429 | } | |
1430 | ||
1431 | if(strstr(optionSave,"save") && fileProf){ | |
1432 | TString profName=Form("Profile%06i",i); | |
1433 | TString timeTotName=Form("TimeTot%06i",i); | |
1434 | TString totName=Form("Tot%06i",i); | |
1435 | TString deltaName=Form("Delta%06i",i); | |
1436 | fileProf->cd(); | |
1437 | hSlewingProf->Write(profName); | |
1438 | htimetot->Write(timeTotName); | |
1439 | hToT->Write(totName); | |
1440 | hdeltaTime->Write(deltaName); | |
1441 | } | |
1442 | ||
1443 | AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(i); | |
1444 | calChannel->SetSlewPar(par); | |
1445 | delete hToT; | |
1446 | hToT=0x0; | |
1447 | delete hSlewingProf; | |
1448 | hSlewingProf=0x0; | |
1449 | delete htimetot; | |
1450 | htimetot=0x0; | |
1451 | delete hdeltaTime; | |
1452 | hdeltaTime=0x0; | |
1453 | } | |
1454 | ||
1455 | if(strstr(optionSave,"save") && fileProf){ | |
1456 | fileProf->Close(); | |
1457 | delete fileProf; | |
1458 | fileProf=0x0; | |
1459 | } | |
0cb9d099 | 1460 | WriteParOfflineOnCDB("TOF/Calib","valid"); |
0a749fa5 | 1461 | |
1462 | return 0; | |
1463 | } | |
1464 | //---------------------------------------------------------------------------- | |
1465 | Int_t AliTOFcalib::CalibrateFromProfile(Int_t ich, Option_t *optionSave, Option_t *optionFit){ | |
1466 | ||
1467 | // computing calibration parameters using the old profiling algo | |
1468 | // Returning codes: | |
1469 | // 0 -> everything was ok | |
1470 | // 1 -> no tree for calibration found | |
1471 | // 2 -> not enough statistics to perform calibration | |
1472 | // 3 -> problems with arrays | |
1473 | ||
1474 | TH1::AddDirectory(0); | |
1475 | ||
1476 | AliInfo(Form("*** Calibrating Histograms From Profile %s", GetName())) ; | |
1477 | AliInfo(Form("Option for Saving histos = %s",optionSave )) ; | |
1478 | AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ; | |
1479 | Float_t p[MAXCHENTRIESSMALL]; | |
1480 | Int_t nentries; | |
1481 | Int_t ntracksTotal=0; | |
296591ad | 1482 | //fTree->SetBranchAddress("nentries",&nentries); |
1483 | //fTree->SetBranchAddress("TOFentries",p); | |
1484 | fChain->SetBranchAddress("nentries",&nentries); | |
1485 | fChain->SetBranchAddress("TOFentries",p); | |
0a749fa5 | 1486 | |
1487 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1488 | Int_t i = ich+irun*fNChannels; | |
296591ad | 1489 | //fTree->GetEntry(i); |
1490 | fChain->GetEntry(i); | |
0a749fa5 | 1491 | ntracksTotal+=nentries/3; |
1492 | } | |
1493 | ||
1494 | if (ntracksTotal < MEANENTRIES) { | |
1495 | AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotal)); | |
1496 | return 2; | |
1497 | } | |
1498 | ||
1499 | TH1F * hProf = new TH1F(); | |
1500 | hProf = Profile(ich); | |
1501 | hProf->Fit("pol5",optionFit,"",0,4); | |
1502 | TF1 * calibfunc = (TF1*)hProf->GetFunction("pol5"); | |
1503 | Float_t par[6]; | |
1504 | for(Int_t kk=0;kk<6;kk++){ | |
1505 | par[kk]=calibfunc->GetParameter(kk); | |
1506 | AliDebug(2,Form("parameter %i = %f",kk,par[kk])); | |
1507 | } | |
1508 | ||
1509 | if(strstr(optionSave,"save")){ | |
1510 | TFile * fileProf = new TFile("TOFCalibSave.root","recreate"); | |
1511 | fileProf->cd(); | |
1512 | TString profName=Form("Profile%06i",ich); | |
1513 | hProf->Write(profName); | |
1514 | fileProf->Close(); | |
1515 | delete fileProf; | |
1516 | fileProf=0x0; | |
1517 | } | |
1518 | ||
1519 | delete hProf; | |
1520 | hProf=0x0; | |
1521 | AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ich); | |
1522 | calChannel->SetSlewPar(par); | |
0cb9d099 | 1523 | WriteParOfflineOnCDB("TOF/Calib","valid"); |
0a749fa5 | 1524 | return 0; |
1525 | } | |
1526 | //---------------------------------------------------------------------------- | |
1527 | Int_t AliTOFcalib::Calibrate(Option_t *optionSave, Option_t *optionFit){ | |
1528 | ||
1529 | // calibrating the whole TOF | |
1530 | // computing calibration parameters | |
1531 | // Returning codes: | |
1532 | // 0 -> everything was ok | |
1533 | // 1 -> no tree for calibration found | |
1534 | // 2 -> not enough statistics to perform calibration | |
1535 | // 3 -> problems with arrays | |
1536 | ||
1537 | TH1::AddDirectory(0); | |
1538 | ||
1539 | AliInfo(Form("*** Calibrating Histograms %s, all channels", GetName())) ; | |
1540 | AliInfo(Form("Option for Saving histos = %s",optionSave )) ; | |
1541 | AliInfo(Form("Option for Fitting Profile histos = %s",optionFit )) ; | |
1542 | ||
1543 | TFile * fileProf=0x0; | |
1544 | if(strstr(optionSave,"save")){ | |
1545 | fileProf = new TFile("TOFCalibSave.root","recreate"); | |
1546 | } | |
1547 | ||
1548 | Float_t p[MAXCHENTRIESSMALL]; | |
1549 | Int_t nentries; | |
296591ad | 1550 | //fTree->SetBranchAddress("nentries",&nentries); |
1551 | //fTree->SetBranchAddress("TOFentries",p); | |
1552 | fChain->SetBranchAddress("nentries",&nentries); | |
1553 | fChain->SetBranchAddress("TOFentries",p); | |
0a749fa5 | 1554 | |
1555 | Float_t ntracksTotalmean =0; | |
1556 | for (Int_t ii=0; ii<fNChannels; ii++){ | |
1557 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1558 | Int_t i = ii+irun*fNChannels; | |
296591ad | 1559 | //fTree->GetEntry(i); |
1560 | fChain->GetEntry(i); | |
0a749fa5 | 1561 | ntracksTotalmean+=nentries/3; |
1562 | } | |
1563 | } | |
1564 | ||
1565 | ntracksTotalmean/=fNChannels; | |
1566 | if (ntracksTotalmean < MEANENTRIES) { | |
1567 | AliInfo(Form(" Too small mean number of entires per channel (mean number = %f) not calibrating and exiting.....",ntracksTotalmean)); | |
1568 | return 2; | |
1569 | } | |
1570 | ||
1571 | //filling ToT and Time arrays | |
1572 | ||
1573 | Int_t nbinToT = 100; // ToT bin width in Profile = 50.0 ps | |
1574 | Float_t minToT = 0; // ns | |
1575 | Float_t maxToT = 4.88;// ns | |
1576 | for (Int_t ii=0; ii<fNChannels; ii++) { | |
1577 | TH1F *hToT = new TH1F("htot","htot",nbinToT, minToT, maxToT); | |
1578 | TH1F *hdeltaTime = new TH1F("hdeltaTime","hdeltaTime",200,2,4); | |
1579 | TH2F * htimetot = new TH2F("htimetot","htimetot",nbinToT, minToT, maxToT,600,-5,10); | |
1580 | if (ii%1000 == 0) AliDebug(1,Form("Calibrating channel %i ",ii)); | |
1581 | //Int_t i = 3; | |
1582 | Int_t nusefulbins=0; | |
1583 | Double_t binsProfile[101]; // sized larger than necessary, the correct | |
1584 | // dim being set in the booking of the profile | |
1585 | Int_t ntracksRun = 0; | |
1586 | Int_t ntracksTotal = 0; | |
1587 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1588 | Int_t i = ii+irun*fNChannels; | |
296591ad | 1589 | //fTree->GetEntry(i); |
1590 | fChain->GetEntry(i); | |
0a749fa5 | 1591 | ntracksTotal+=nentries/3; |
1592 | } | |
1593 | if (ntracksTotal < MEANENTRIES) { | |
1594 | AliInfo(Form(" Too small mean number of entires in channel %i (number of tracks = %f), not calibrating channel and continuing.....",ii,ntracksTotal)); | |
1595 | continue; | |
1596 | } | |
1597 | Float_t meantime=0; | |
1598 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1599 | Int_t i = ii+irun*fNChannels; | |
296591ad | 1600 | //fTree->GetEntry(i); |
1601 | fChain->GetEntry(i); | |
0a749fa5 | 1602 | ntracksRun=nentries/3; |
1603 | for (Int_t j=0;j<ntracksRun;j++){ | |
1604 | Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT; | |
1605 | Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME; | |
1606 | Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID; | |
1607 | Float_t tot = p[idxexToT]; | |
1608 | hdeltaTime->Fill(p[idxexTime]-p[idxexExTime]); | |
1609 | meantime+=p[idxexTime]-p[idxexExTime]; | |
1610 | hToT->Fill(tot); | |
1611 | } | |
1612 | } | |
1613 | nusefulbins = FindBins(hToT,&binsProfile[0]); | |
1614 | meantime/=ntracksTotal; | |
1615 | for (Int_t j=0;j<nusefulbins;j++) { | |
1616 | AliDebug(2,Form(" channel %i, usefulbin = %i, low edge = %f",ii,j,binsProfile[j])); | |
1617 | } | |
1618 | TProfile* hSlewingProf = new TProfile("hSlewingProf", "hSlewingProf",nusefulbins, binsProfile, "G"); // CHECK THE BUILD OPTION, PLEASE!!!!!! | |
1619 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1620 | Int_t i = ii+irun*fNChannels; | |
296591ad | 1621 | //fTree->GetEntry(i); |
1622 | fChain->GetEntry(i); | |
0a749fa5 | 1623 | ntracksRun=nentries/3; |
1624 | for (Int_t j=0;j<ntracksRun;j++){ | |
1625 | Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT; | |
1626 | Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME; | |
1627 | Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID; | |
1628 | Float_t tot = p[idxexToT]; | |
1629 | Float_t time = p[idxexTime]-p[idxexExTime]; | |
1630 | AliDebug (2,Form("track = %i, time = %f, tot = %f, time-meantime = %f",j,time, tot, time-meantime)); | |
1631 | hSlewingProf->Fill(tot,time); // if meantime is not used, the fill may be moved in the loop above | |
1632 | htimetot->Fill(tot,time-meantime); // if meantime is not used, the fill may be moved in the loop above | |
1633 | } | |
1634 | } | |
1635 | hSlewingProf->Fit("pol5",optionFit,"",1,4); | |
1636 | TF1 * calibfunc = (TF1*)hSlewingProf->GetFunction("pol5"); | |
1637 | Float_t par[6]; | |
1638 | for(Int_t kk=0;kk<6;kk++){ | |
1639 | par[kk]=calibfunc->GetParameter(kk); | |
1640 | AliDebug(2,Form("parameter %i = %f",kk,par[kk])); | |
1641 | } | |
1642 | ||
1643 | if(strstr(optionSave,"save") && fileProf){ | |
1644 | TString profName=Form("Profile%06i",ii); | |
1645 | TString timeTotName=Form("TimeTot%06i",ii); | |
1646 | TString totName=Form("Tot%06i",ii); | |
1647 | TString deltaName=Form("Delta%06i",ii); | |
1648 | fileProf->cd(); | |
1649 | hSlewingProf->Write(profName); | |
1650 | htimetot->Write(timeTotName); | |
1651 | hToT->Write(totName); | |
1652 | hdeltaTime->Write(deltaName); | |
1653 | } | |
1654 | AliTOFChannelOffline * calChannel = (AliTOFChannelOffline*)fTOFCalOffline->At(ii); | |
1655 | calChannel->SetSlewPar(par); | |
1656 | ||
1657 | delete hToT; | |
1658 | hToT=0x0; | |
1659 | delete hSlewingProf; | |
1660 | hSlewingProf=0x0; | |
1661 | delete htimetot; | |
1662 | htimetot=0x0; | |
1663 | delete hdeltaTime; | |
1664 | hdeltaTime=0x0; | |
1665 | } | |
1666 | ||
1667 | if(strstr(optionSave,"save")){ | |
1668 | fileProf->Close(); | |
1669 | delete fileProf; | |
1670 | fileProf=0x0; | |
1671 | } | |
0cb9d099 | 1672 | WriteParOfflineOnCDB("TOF/Calib","valid"); |
0a749fa5 | 1673 | return 0; |
1674 | } | |
1675 | ||
1676 | //----------------------------------------------------------------------- | |
1677 | TH1F* AliTOFcalib::Profile(Int_t ich) | |
340693af | 1678 | { |
0a749fa5 | 1679 | // profiling algo |
1680 | ||
1681 | Float_t p[MAXCHENTRIESSMALL]; | |
1682 | Int_t nentries; | |
296591ad | 1683 | //fTree->SetBranchAddress("nentries",&nentries); |
1684 | //fTree->SetBranchAddress("TOFentries",p); | |
1685 | fChain->SetBranchAddress("nentries",&nentries); | |
1686 | fChain->SetBranchAddress("TOFentries",p); | |
0a749fa5 | 1687 | |
1688 | //Prepare histograms for Slewing Correction | |
1689 | const Int_t knbinToT = 100; | |
1690 | Int_t nbinTime = 200; | |
1691 | Float_t minTime = -5.5; //ns | |
1692 | Float_t maxTime = 5.5; //ns | |
1693 | Float_t minToT = 0; //ns | |
1694 | Float_t maxToT = 5.; //ns | |
1695 | Float_t deltaToT = (maxToT-minToT)/knbinToT; | |
1696 | Double_t mTime[knbinToT+1],mToT[knbinToT+1],meanTime[knbinToT+1], meanTime2[knbinToT+1],vToT[knbinToT+1], vToT2[knbinToT+1],meanToT[knbinToT+1],meanToT2[knbinToT+1],vTime[knbinToT+1],vTime2[knbinToT+1],xlow[knbinToT+1],sigmaTime[knbinToT+1]; | |
1697 | Int_t n[knbinToT+1], nentrx[knbinToT+1]; | |
1698 | Double_t sigmaToT[knbinToT+1]; | |
1699 | for (Int_t i = 0; i < knbinToT+1 ; i++){ | |
1700 | mTime[i]=0; | |
1701 | mToT[i]=0; | |
1702 | n[i]=0; | |
1703 | meanTime[i]=0; | |
1704 | meanTime2[i]=0; | |
1705 | vToT[i]=0; | |
1706 | vToT2[i]=0; | |
1707 | meanToT[i]=0; | |
1708 | meanToT2[i]=0; | |
1709 | vTime[i]=0; | |
1710 | vTime2[i]=0; | |
1711 | xlow[i]=0; | |
1712 | sigmaTime[i]=0; | |
1713 | sigmaToT[i]=0; | |
1714 | n[i]=0; | |
1715 | nentrx[i]=0; | |
1716 | } | |
1717 | TH2F* hSlewing = new TH2F("hSlewing", "hSlewing", knbinToT, minToT, maxToT, nbinTime, minTime, maxTime); | |
1718 | Int_t ntracksRun = 0; | |
1719 | TH1F *histo = new TH1F("histo", "1D Time vs ToT", knbinToT, minToT, maxToT); | |
1720 | for (Int_t irun=0;irun<fNruns;irun++){ | |
1721 | Int_t i = ich+irun*fNChannels; | |
296591ad | 1722 | //fTree->GetEntry(i); |
1723 | fChain->GetEntry(i); | |
0a749fa5 | 1724 | ntracksRun=nentries/3; |
1725 | for (Int_t j=0;j<ntracksRun;j++){ | |
1726 | Int_t idxexToT = (j* NIDXSMALL)+DELTAIDXTOT; | |
1727 | Int_t idxexTime = (j* NIDXSMALL)+DELTAIDXTIME; | |
1728 | Int_t idxexExTime = (j* NIDXSMALL)+DELTAIDXPID; | |
1729 | Float_t tot = p[idxexToT]; | |
1730 | Float_t time = p[idxexTime]-p[idxexExTime]; | |
1731 | Int_t nx = (Int_t)((tot-minToT)/deltaToT)+1; | |
1732 | if ((tot != 0) && ( time!= 0)){ | |
1733 | vTime[nx]+=time; | |
1734 | vTime2[nx]+=time*time; | |
1735 | vToT[nx]+=tot; | |
1736 | vToT2[nx]+=tot*tot; | |
1737 | nentrx[nx]++; | |
1738 | hSlewing->Fill(tot,time); | |
1739 | } | |
1740 | } | |
1741 | } | |
1742 | Int_t nbinsToT=hSlewing->GetNbinsX(); | |
1743 | if (nbinsToT != knbinToT) { | |
1744 | AliError("Profile :: incompatible numbers of bins"); | |
1745 | return 0x0; | |
1746 | } | |
1747 | ||
1748 | Int_t usefulBins=0; | |
1749 | for (Int_t i=1;i<=nbinsToT;i++){ | |
1750 | if (nentrx[i]!=0){ | |
1751 | n[usefulBins]+=nentrx[i]; | |
1752 | if (n[usefulBins]==0 && i == nbinsToT) { | |
1753 | break; | |
1754 | } | |
1755 | meanTime[usefulBins]+=vTime[i]; | |
1756 | meanTime2[usefulBins]+=vTime2[i]; | |
1757 | meanToT[usefulBins]+=vToT[i]; | |
1758 | meanToT2[usefulBins]+=vToT2[i]; | |
1759 | if (n[usefulBins]<10 && i!=nbinsToT) continue; | |
1760 | mTime[usefulBins]=meanTime[usefulBins]/n[usefulBins]; | |
1761 | mToT[usefulBins]=meanToT[usefulBins]/n[usefulBins]; | |
1762 | sigmaTime[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins] | |
1763 | *(meanTime2[usefulBins]-meanTime[usefulBins] | |
1764 | *meanTime[usefulBins]/n[usefulBins])); | |
1765 | if ((1./n[usefulBins]/n[usefulBins] | |
1766 | *(meanToT2[usefulBins]-meanToT[usefulBins] | |
1767 | *meanToT[usefulBins]/n[usefulBins]))< 0) { | |
1768 | AliError(" too small radical" ); | |
1769 | sigmaToT[usefulBins]=0; | |
1770 | } | |
1771 | else{ | |
1772 | sigmaToT[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins] | |
1773 | *(meanToT2[usefulBins]-meanToT[usefulBins] | |
1774 | *meanToT[usefulBins]/n[usefulBins])); | |
1775 | } | |
1776 | usefulBins++; | |
1777 | } | |
1778 | } | |
1779 | for (Int_t i=0;i<usefulBins;i++){ | |
1780 | Int_t binN = (Int_t)((mToT[i]-minToT)/deltaToT)+1; | |
1781 | histo->Fill(mToT[i],mTime[i]); | |
1782 | histo->SetBinError(binN,sigmaTime[i]); | |
1783 | } | |
1784 | delete hSlewing; | |
1785 | hSlewing=0x0; | |
1786 | ||
1787 | return histo; | |
6dc9348d | 1788 | } |
0a749fa5 | 1789 | //---------------------------------------------------------------------------- |
1790 | Int_t AliTOFcalib::FindBins(TH1F* h, Double_t *binsProfile) const{ | |
6dc9348d | 1791 | |
0a749fa5 | 1792 | // to determine the bins for ToT histo |
1793 | ||
1794 | Int_t cont = 0; | |
1795 | Int_t startBin = 1; | |
1796 | Int_t nbin = h->GetNbinsX(); | |
1797 | Int_t nentries = (Int_t)h->GetEntries(); | |
1798 | Float_t max = h->GetBinLowEdge(nbin); | |
1799 | Int_t nusefulbins=0; | |
1800 | Int_t maxcont=0; | |
1801 | // setting maxvalue of entries per bin | |
1802 | if (nentries <= 60) maxcont = 2; | |
1803 | else if (nentries <= 100) maxcont = 5; | |
1804 | else if (nentries <= 500) maxcont = 10; | |
1805 | else maxcont = 20; | |
1806 | for (Int_t j=1;j<=nbin;j++) { | |
1807 | cont += (Int_t)h->GetBinContent(j); | |
1808 | if (j<nbin){ | |
1809 | if (cont>=maxcont){ | |
1810 | nusefulbins++; | |
1811 | binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin); | |
1812 | cont=0; | |
1813 | startBin=j+1; | |
1814 | continue; | |
1815 | } | |
1816 | } | |
1817 | else{ | |
1818 | if (cont>=maxcont){ | |
1819 | nusefulbins++; | |
1820 | binsProfile[nusefulbins-1]=h->GetBinLowEdge(startBin); | |
1821 | binsProfile[nusefulbins]=max; | |
1822 | } | |
1823 | else { | |
1824 | binsProfile[nusefulbins]=h->GetBinLowEdge(startBin); | |
1825 | } | |
1826 | } | |
1827 | } | |
1828 | return nusefulbins; | |
1829 | } | |
2bf4d9d6 | 1830 | |
1831 | ||
1832 | //---------------------------------------------------------------------------- | |
1833 | ||
1834 | void | |
1835 | AliTOFcalib::CreateDeltaBCOffset() | |
1836 | { | |
1837 | /* | |
1838 | * create deltaBC offset | |
1839 | */ | |
1840 | ||
1841 | if (fDeltaBCOffset) { | |
1842 | AliWarning("DeltaBCOffset object already defined, cannot create a new one"); | |
1843 | return; | |
1844 | } | |
1845 | fDeltaBCOffset = new AliTOFDeltaBCOffset(); | |
1846 | } | |
1847 | ||
1848 | //---------------------------------------------------------------------------- | |
1849 | ||
1850 | void | |
1851 | AliTOFcalib::CreateCTPLatency() | |
1852 | { | |
1853 | /* | |
1854 | * create CTP latency | |
1855 | */ | |
1856 | ||
1857 | if (fCTPLatency) { | |
1858 | AliWarning("CTPLatency object already defined, cannot create a new one"); | |
1859 | return; | |
1860 | } | |
1861 | fCTPLatency = new AliTOFCTPLatency(); | |
1862 | } | |
1863 | ||
1864 | //---------------------------------------------------------------------------- | |
1865 | ||
1866 | void | |
1867 | AliTOFcalib::CreateT0Fill() | |
1868 | { | |
1869 | /* | |
1870 | * create event-time | |
1871 | */ | |
1872 | ||
1873 | if (fT0Fill) { | |
1874 | AliWarning("T0Fill object already defined, cannot create a new one"); | |
1875 | return; | |
1876 | } | |
1877 | fT0Fill = new AliTOFT0Fill(); | |
1878 | } | |
1879 | ||
1880 | //---------------------------------------------------------------------------- | |
1881 | ||
1882 | void | |
1883 | AliTOFcalib::WriteDeltaBCOffsetOnCDB(const Char_t *sel , Int_t minrun, Int_t maxrun) | |
1884 | { | |
1885 | /* | |
1886 | * deltaBC offset on CDB | |
1887 | */ | |
1888 | ||
1889 | if (!fDeltaBCOffset) return; | |
1890 | AliCDBId id(Form("%s/DeltaBCOffset", sel), minrun, maxrun); | |
1891 | AliCDBMetaData *md = new AliCDBMetaData(); | |
1892 | md->SetResponsible("Roberto Preghenella"); | |
1893 | AliCDBManager *man = AliCDBManager::Instance(); | |
1894 | man->Put(fDeltaBCOffset, id, md); | |
1895 | AliDebug(2,Form("DeltaBCOffset written on CDB with run range [%i, %i] ",minrun ,maxrun)); | |
1896 | delete md; | |
1897 | } | |
1898 | ||
1899 | //---------------------------------------------------------------------------- | |
1900 | ||
1901 | void | |
1902 | AliTOFcalib::WriteCTPLatencyOnCDB(const Char_t *sel , Int_t minrun, Int_t maxrun) | |
1903 | { | |
1904 | /* | |
1905 | * write CTP latency on CDB | |
1906 | */ | |
1907 | ||
1908 | if (!fCTPLatency) return; | |
1909 | AliCDBId id(Form("%s/CTPLatency", sel), minrun, maxrun); | |
1910 | AliCDBMetaData *md = new AliCDBMetaData(); | |
1911 | md->SetResponsible("Roberto Preghenella"); | |
1912 | AliCDBManager *man = AliCDBManager::Instance(); | |
1913 | man->Put(fCTPLatency, id, md); | |
1914 | AliDebug(2,Form("CTPLatency written on CDB with run range [%i, %i] ",minrun ,maxrun)); | |
1915 | delete md; | |
1916 | } | |
1917 | ||
1918 | //---------------------------------------------------------------------------- | |
1919 | ||
1920 | void | |
1921 | AliTOFcalib::WriteT0FillOnCDB(const Char_t *sel , Int_t minrun, Int_t maxrun) | |
1922 | { | |
1923 | /* | |
1924 | * write event-time on CDB | |
1925 | */ | |
1926 | ||
1927 | if (!fT0Fill) return; | |
1928 | AliCDBId id(Form("%s/T0Fill", sel), minrun, maxrun); | |
1929 | AliCDBMetaData *md = new AliCDBMetaData(); | |
1930 | md->SetResponsible("Roberto Preghenella"); | |
1931 | AliCDBManager *man = AliCDBManager::Instance(); | |
1932 | man->Put(fT0Fill, id, md); | |
1933 | AliDebug(2,Form("T0Fill written on CDB with run range [%i, %i] ",minrun ,maxrun)); | |
1934 | delete md; | |
1935 | } | |
1936 | ||
1937 | //---------------------------------------------------------------------------- | |
1938 | ||
1939 | Bool_t | |
1940 | AliTOFcalib::ReadDeltaBCOffsetFromCDB(const Char_t *sel , Int_t nrun) | |
1941 | { | |
1942 | /* | |
1943 | * read deltaBC offset from CDB | |
1944 | */ | |
1945 | ||
1946 | AliCDBManager *man = AliCDBManager::Instance(); | |
1947 | AliCDBEntry *entry = man->Get(Form("%s/DeltaBCOffset", sel),nrun); | |
1948 | if (!entry) { | |
1949 | AliFatal("No DeltaBCOffset entry found in CDB"); | |
1950 | exit(0); | |
1951 | } | |
1952 | fDeltaBCOffset =(AliTOFDeltaBCOffset *)entry->GetObject(); | |
1953 | if(!fDeltaBCOffset){ | |
1954 | AliFatal("No DeltaBCOffset object found in CDB entry"); | |
1955 | exit(0); | |
1956 | } | |
1957 | return kTRUE; | |
1958 | } | |
1959 | ||
1960 | //---------------------------------------------------------------------------- | |
1961 | ||
1962 | Bool_t | |
1963 | AliTOFcalib::ReadCTPLatencyFromCDB(const Char_t *sel , Int_t nrun) | |
1964 | { | |
1965 | /* | |
1966 | * read CTP latency from CDB | |
1967 | */ | |
1968 | ||
1969 | AliCDBManager *man = AliCDBManager::Instance(); | |
1970 | AliCDBEntry *entry = man->Get(Form("%s/CTPLatency", sel),nrun); | |
1971 | if (!entry) { | |
1972 | AliFatal("No CTPLatency entry found in CDB"); | |
1973 | exit(0); | |
1974 | } | |
1975 | fCTPLatency =(AliTOFCTPLatency *)entry->GetObject(); | |
1976 | if(!fCTPLatency){ | |
1977 | AliFatal("No CTPLatency object found in CDB entry"); | |
1978 | exit(0); | |
1979 | } | |
1980 | return kTRUE; | |
1981 | } | |
1982 | ||
1983 | //---------------------------------------------------------------------------- | |
1984 | ||
1985 | Bool_t | |
1986 | AliTOFcalib::ReadT0FillFromCDB(const Char_t *sel , Int_t nrun) | |
1987 | { | |
1988 | /* | |
1989 | * read event-time from CDB | |
1990 | */ | |
1991 | ||
1992 | AliCDBManager *man = AliCDBManager::Instance(); | |
1993 | AliCDBEntry *entry = man->Get(Form("%s/T0Fill", sel),nrun); | |
1994 | if (!entry) { | |
1995 | AliFatal("No T0Fill entry found in CDB"); | |
1996 | exit(0); | |
1997 | } | |
1998 | fT0Fill =(AliTOFT0Fill *)entry->GetObject(); | |
1999 | if(!fT0Fill){ | |
2000 | AliFatal("No T0Fill object found in CDB entry"); | |
2001 | exit(0); | |
2002 | } | |
2003 | return kTRUE; | |
2004 | } | |
2005 |