]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCcalibDB.cxx
loop over the friend tracks instead of esd tracks to avoid "out of bounds" messages...
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibDB.cxx
CommitLineData
c5bbaa2c 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17///////////////////////////////////////////////////////////////////////////////
18// //
19// Class providing the calibration parameters by accessing the CDB //
20// //
21// Request an instance with AliTPCcalibDB::Instance() //
22// If a new event is processed set the event number with SetRun //
1ac191a6 23// Then request the calibration data ////
f5344549 24//
25//
1ac191a6 26// Calibration data:
8cd9634d 27// 0.) Altro mapping
28// Simulation - not yet
29// Reconstruction - AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
30//
1ac191a6 31// 1.) pad by pad calibration - AliTPCCalPad
f5344549 32//
1ac191a6 33// a.) fPadGainFactor
34// Simulation: AliTPCDigitizer::ExecFast - Multiply by gain
35// Reconstruction : AliTPCclustererMI::Digits2Clusters - Divide by gain
f5344549 36//
1ac191a6 37// b.) fPadNoise -
38// Simulation: AliTPCDigitizer::ExecFast
39// Reconstruction: AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC)
8cd9634d 40// Noise depending cut on clusters charge (n sigma)
f5344549 41// c.) fPedestal:
42// Simulation: Not used yet - To be impleneted - Rounding to the nearest integer
43// Reconstruction: Used in AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
44// if data taken without zero suppression
45// Currently switch in fRecoParam->GetCalcPedestal();
46//
47// d.) fPadTime0
48// Simulation: applied in the AliTPC::MakeSector - adding offset
49// Reconstruction: AliTPCTransform::Transform() - remove offset
50// AliTPCTransform::Transform() - to be called
5cf28d9b 51// in AliTPCtrackerMI::Transform()
8cd9634d 52//
53//
54// 2.) Space points transformation:
55//
56// a.) General coordinate tranformation - AliTPCtransform (see $ALICE_ROOT/TPC/AliTPCtransform.cxx)
57// Created on fly - use the other calibration components
58// Unisochronity - (substract time0 - pad by pad)
59// Drift velocity - Currently common drift velocity - functionality of AliTPCParam
60// ExB effect
61// Simulation - Not used directly (the effects are applied one by one (see AliTPC::MakeSector)
62// Reconstruction -
63// AliTPCclustererMI::AddCluster
64// AliTPCtrackerMI::Transform
65// b.) ExB effect calibration -
66// classes (base class AliTPCExB, implementation- AliTPCExBExact.h AliTPCExBFirst.h)
67// a.a) Simulation: applied in the AliTPC::MakeSector -
68// calib->GetExB()->CorrectInverse(dxyz0,dxyz1);
69// a.b) Reconstruction -
70//
71// in AliTPCtransform::Correct() - called calib->GetExB()->Correct(dxyz0,dxyz1)
72//
96305e49 73// 3.) cluster error, shape and Q parameterization
74//
75//
8cd9634d 76//
c5bbaa2c 77///////////////////////////////////////////////////////////////////////////////
78
418bbcaf 79#include <iostream>
80#include <fstream>
81
c5bbaa2c 82
83#include <AliCDBManager.h>
c5bbaa2c 84#include <AliCDBEntry.h>
949d8707 85#include <AliCDBId.h>
c5bbaa2c 86#include <AliLog.h>
3ac615eb 87#include <AliMagF.h>
7fff7612 88#include <AliSplineFit.h>
f14d21a1 89#include <AliCTPTimeParams.h>
c5bbaa2c 90
91#include "AliTPCcalibDB.h"
949d8707 92#include "AliTPCdataQA.h"
817766d5 93#include "AliTPCcalibDButil.h"
d6834f5f 94#include "AliTPCAltroMapping.h"
418bbcaf 95#include "AliTPCExB.h"
c5bbaa2c 96
97#include "AliTPCCalROC.h"
98#include "AliTPCCalPad.h"
54472e4f 99#include "AliTPCSensorTempArray.h"
bf85fe4d 100#include "AliGRPObject.h"
418bbcaf 101#include "AliTPCTransform.h"
f6b5fa33 102#include "AliTPCmapper.h"
d6834f5f 103
418bbcaf 104class AliCDBStorage;
105class AliTPCCalDet;
86df2b3a 106//
107//
108
86df2b3a 109#include "TFile.h"
110#include "TKey.h"
43a74775 111#include "TGraphErrors.h"
86df2b3a 112
113#include "TObjArray.h"
114#include "TObjString.h"
115#include "TString.h"
7390f655 116#include "TDirectory.h"
f6b5fa33 117#include "TArrayI.h"
86df2b3a 118#include "AliTPCCalPad.h"
0fe7645c 119#include "AliTPCCalibPulser.h"
86df2b3a 120#include "AliTPCCalibPedestal.h"
121#include "AliTPCCalibCE.h"
3ac615eb 122#include "AliTPCExBFirst.h"
bf85fe4d 123#include "AliTPCTempMap.h"
da6c0bc9 124#include "AliTPCCalibVdrift.h"
6e7d7dc4 125#include "AliTPCCalibRaw.h"
43a74775 126#include "AliTPCParam.h"
cf5b0aa0 127#include "AliTPCCorrection.h"
3f3549a3 128#include "AliTPCComposedCorrection.h"
5312f439 129#include "AliTPCPreprocessorOnline.h"
86df2b3a 130
c5bbaa2c 131
132ClassImp(AliTPCcalibDB)
133
134AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0;
135Bool_t AliTPCcalibDB::fgTerminated = kFALSE;
3ac615eb 136TObjArray AliTPCcalibDB::fgExBArray; // array of ExB corrections
c5bbaa2c 137
138
139//_ singleton implementation __________________________________________________
140AliTPCcalibDB* AliTPCcalibDB::Instance()
141{
142 //
143 // Singleton implementation
8de4c8a6 144 // Returns an instance of this class, it is created if necessary
c5bbaa2c 145 //
146
147 if (fgTerminated != kFALSE)
148 return 0;
149
150 if (fgInstance == 0)
151 fgInstance = new AliTPCcalibDB();
152
153 return fgInstance;
154}
155
156void AliTPCcalibDB::Terminate()
157{
158 //
159 // Singleton implementation
160 // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
161 // This function can be called several times.
162 //
163
164 fgTerminated = kTRUE;
165
166 if (fgInstance != 0)
167 {
168 delete fgInstance;
169 fgInstance = 0;
170 }
171}
172
173//_____________________________________________________________________________
e4dce695 174AliTPCcalibDB::AliTPCcalibDB():
9389f9a4 175 TObject(),
e4dce695 176 fRun(-1),
f5344549 177 fTransform(0),
481f877b 178 fExB(0),
e4dce695 179 fPadGainFactor(0),
8de4c8a6 180 fActiveChannelMap(0),
9f6e9f81 181 fDedxGainFactor(0),
e4dce695 182 fPadTime0(0),
2293155b 183 fDistortionMap(0),
cf5b0aa0 184 fComposedCorrection(0),
0b736a46 185 fComposedCorrectionArray(0),
e4dce695 186 fPadNoise(0),
187 fPedestals(0),
6e7d7dc4 188 fCalibRaw(0),
949d8707 189 fDataQA(0),
5312f439 190 fALTROConfigData(0),
191 fPulserData(0),
192 fCEData(0),
e4dce695 193 fTemperature(0),
d6834f5f 194 fMapping(0),
96305e49 195 fParam(0),
a2c3785e 196 fClusterParam(0),
197 fTimeGainSplines(0),
6b5e0bab 198 fTimeGainSplinesArray(1),
199 fGRPArray(1), //! array of GRPs - per run - JUST for calibration studies
200 fGRPMaps(1), //! array of GRPs - per run - JUST for calibration studies
201 fGoofieArray(1), //! array of GOOFIE values -per run - Just for calibration studies
202 fVoltageArray(1),
203 fTemperatureArray(1), //! array of temperature sensors - per run - Just for calibration studies
204 fVdriftArray(1), //! array of v drift interfaces
205 fDriftCorrectionArray(1), //! array of drift correction
206 fRunList(1), //! run list - indicates try to get the run param
3f3549a3 207 fBHasAlignmentOCDB(kFALSE), // Flag - has the alignment on the composed correction ?
f14d21a1 208 fDButil(0),
88a69e6f 209 fCTPTimeParams(0),
210 fMode(-1)
c5bbaa2c 211{
212 //
213 // constructor
214 //
54472e4f 215 //
534fd34a 216 fgInstance=this;
c5bbaa2c 217 Update(); // temporary
2b4c6ff5 218 fTimeGainSplinesArray.SetOwner(); //own the keys
219 fGRPArray.SetOwner(); //own the keys
220 fGRPMaps.SetOwner(); //own the keys
221 fGoofieArray.SetOwner(); //own the keys
222 fVoltageArray.SetOwner(); //own the keys
223 fTemperatureArray.SetOwner(); //own the keys
224 fVdriftArray.SetOwner(); //own the keys
225 fDriftCorrectionArray.SetOwner(); //own the keys
c5bbaa2c 226}
227
9389f9a4 228AliTPCcalibDB::AliTPCcalibDB(const AliTPCcalibDB& ):
229 TObject(),
230 fRun(-1),
231 fTransform(0),
232 fExB(0),
233 fPadGainFactor(0),
8de4c8a6 234 fActiveChannelMap(0),
9f6e9f81 235 fDedxGainFactor(0),
9389f9a4 236 fPadTime0(0),
2293155b 237 fDistortionMap(0),
cf5b0aa0 238 fComposedCorrection(0),
0b736a46 239 fComposedCorrectionArray(0),
9389f9a4 240 fPadNoise(0),
241 fPedestals(0),
6e7d7dc4 242 fCalibRaw(0),
949d8707 243 fDataQA(0),
5312f439 244 fALTROConfigData(0),
245 fPulserData(0),
246 fCEData(0),
9389f9a4 247 fTemperature(0),
248 fMapping(0),
9389f9a4 249 fParam(0),
bf85fe4d 250 fClusterParam(0),
a2c3785e 251 fTimeGainSplines(0),
6b5e0bab 252 fTimeGainSplinesArray(1),
bf85fe4d 253 fGRPArray(0), //! array of GRPs - per run - JUST for calibration studies
0231c65f 254 fGRPMaps(0), //! array of GRPs - per run - JUST for calibration studies
bf85fe4d 255 fGoofieArray(0), //! array of GOOFIE values -per run - Just for calibration studies
e2914767 256 fVoltageArray(0),
bf85fe4d 257 fTemperatureArray(0), //! array of temperature sensors - per run - Just for calibration studies
da6c0bc9 258 fVdriftArray(0), //! array of v drift interfaces
5647625c 259 fDriftCorrectionArray(0), //! array of v drift corrections
1e722a63 260 fRunList(0), //! run list - indicates try to get the run param
3f3549a3 261 fBHasAlignmentOCDB(kFALSE), // Flag - has the alignment on the composed correction ?
f14d21a1 262 fDButil(0),
88a69e6f 263 fCTPTimeParams(0),
264 fMode(-1)
9389f9a4 265{
266 //
267 // Copy constructor invalid -- singleton implementation
268 //
269 Error("copy constructor","invalid -- singleton implementation");
2b4c6ff5 270 fTimeGainSplinesArray.SetOwner(); //own the keys
271 fGRPArray.SetOwner(); //own the keys
272 fGRPMaps.SetOwner(); //own the keys
273 fGoofieArray.SetOwner(); //own the keys
274 fVoltageArray.SetOwner(); //own the keys
275 fTemperatureArray.SetOwner(); //own the keys
276 fVdriftArray.SetOwner(); //own the keys
277 fDriftCorrectionArray.SetOwner(); //own the keys
9389f9a4 278}
279
280AliTPCcalibDB& AliTPCcalibDB::operator= (const AliTPCcalibDB& )
281{
282//
283// Singleton implementation - no assignment operator
284//
285 Error("operator =", "assignment operator not implemented");
286 return *this;
287}
288
289
290
c5bbaa2c 291//_____________________________________________________________________________
292AliTPCcalibDB::~AliTPCcalibDB()
293{
294 //
295 // destructor
296 //
68751c2c 297
8de4c8a6 298 delete fActiveChannelMap;
c5bbaa2c 299}
8b63d99c 300AliTPCCalPad* AliTPCcalibDB::GetDistortionMap(Int_t i) const {
301 //
302 // get distortion map - due E field distortions
303 //
304 return (fDistortionMap) ? (AliTPCCalPad*)fDistortionMap->At(i):0;
305}
c5bbaa2c 306
307//_____________________________________________________________________________
308AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
309{
310 //
311 // Retrieves an entry with path <cdbPath> from the CDB.
312 //
313 char chinfo[1000];
314
68751c2c 315 AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
c5bbaa2c 316 if (!entry)
317 {
4aa37f93 318 snprintf(chinfo,1000,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
c5bbaa2c 319 AliError(chinfo);
320 return 0;
321 }
322 return entry;
323}
324
325
326//_____________________________________________________________________________
327void AliTPCcalibDB::SetRun(Long64_t run)
328{
329 //
330 // Sets current run number. Calibration data is read from the corresponding file.
331 //
332 if (fRun == run)
333 return;
a2c3785e 334 fRun = run;
c5bbaa2c 335 Update();
336}
337
338
339
340void AliTPCcalibDB::Update(){
92fb7d95 341 //
342 // cache the OCDB entries for simulation, reconstruction, calibration
343 //
344 //
a8f8b6a1 345 AliCDBEntry * entry=0;
68751c2c 346 Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
347 AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
1e722a63 348 fDButil = new AliTPCcalibDButil;
c5bbaa2c 349 //
5647625c 350
c5bbaa2c 351 entry = GetCDBEntry("TPC/Calib/PadGainFactor");
352 if (entry){
68751c2c 353 //if (fPadGainFactor) delete fPadGainFactor;
c5bbaa2c 354 entry->SetOwner(kTRUE);
355 fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
2293155b 356 }else{
13242232 357 AliFatal("TPC - Missing calibration entry TPC/Calib/PadGainFactor");
c5bbaa2c 358 }
359 //
3af3fbc4 360 entry = GetCDBEntry("TPC/Calib/TimeGain");
361 if (entry){
362 //if (fTimeGainSplines) delete fTimeGainSplines;
363 entry->SetOwner(kTRUE);
364 fTimeGainSplines = (TObjArray*)entry->GetObject();
2293155b 365 }else{
13242232 366 AliFatal("TPC - Missing calibration entry TPC/Calib/Timegain");
3af3fbc4 367 }
368 //
9f6e9f81 369 entry = GetCDBEntry("TPC/Calib/GainFactorDedx");
370 if (entry){
371 entry->SetOwner(kTRUE);
372 fDedxGainFactor = (AliTPCCalPad*)entry->GetObject();
2293155b 373 }else{
13242232 374 AliFatal("TPC - Missing calibration entry TPC/Calib/gainFactordEdx");
9f6e9f81 375 }
376 //
c5bbaa2c 377 entry = GetCDBEntry("TPC/Calib/PadTime0");
378 if (entry){
68751c2c 379 //if (fPadTime0) delete fPadTime0;
c5bbaa2c 380 entry->SetOwner(kTRUE);
381 fPadTime0 = (AliTPCCalPad*)entry->GetObject();
2293155b 382 }else{
13242232 383 AliFatal("TPC - Missing calibration entry");
c5bbaa2c 384 }
2293155b 385
8b63d99c 386 entry = GetCDBEntry("TPC/Calib/Distortion");
2293155b 387 if (entry){
388 //if (fPadTime0) delete fPadTime0;
389 entry->SetOwner(kTRUE);
8b63d99c 390 fDistortionMap =dynamic_cast<TObjArray*>(entry->GetObject());
2293155b 391 }else{
392 //AliFatal("TPC - Missing calibration entry")
393 }
394
395
c5bbaa2c 396 //
c5bbaa2c 397 //
398 entry = GetCDBEntry("TPC/Calib/PadNoise");
399 if (entry){
68751c2c 400 //if (fPadNoise) delete fPadNoise;
c5bbaa2c 401 entry->SetOwner(kTRUE);
402 fPadNoise = (AliTPCCalPad*)entry->GetObject();
2293155b 403 }else{
13242232 404 AliFatal("TPC - Missing calibration entry");
c5bbaa2c 405 }
8477f500 406
407 entry = GetCDBEntry("TPC/Calib/Pedestals");
408 if (entry){
409 //if (fPedestals) delete fPedestals;
410 entry->SetOwner(kTRUE);
411 fPedestals = (AliTPCCalPad*)entry->GetObject();
412 }
413
54472e4f 414 entry = GetCDBEntry("TPC/Calib/Temperature");
415 if (entry){
416 //if (fTemperature) delete fTemperature;
417 entry->SetOwner(kTRUE);
418 fTemperature = (AliTPCSensorTempArray*)entry->GetObject();
419 }
420
8477f500 421 entry = GetCDBEntry("TPC/Calib/Parameters");
422 if (entry){
54472e4f 423 //if (fPadNoise) delete fPadNoise;
8477f500 424 entry->SetOwner(kTRUE);
2baa7fb5 425 fParam = (AliTPCParam*)(entry->GetObject());
2293155b 426 }else{
13242232 427 AliFatal("TPC - Missing calibration entry TPC/Calib/Parameters");
8477f500 428 }
429
96305e49 430 entry = GetCDBEntry("TPC/Calib/ClusterParam");
431 if (entry){
96305e49 432 entry->SetOwner(kTRUE);
2baa7fb5 433 fClusterParam = (AliTPCClusterParam*)(entry->GetObject());
2293155b 434 }else{
13242232 435 AliFatal("TPC - Missing calibration entry");
96305e49 436 }
437
5312f439 438 //ALTRO configuration data
439 entry = GetCDBEntry("TPC/Calib/AltroConfig");
440 if (entry){
441 entry->SetOwner(kTRUE);
442 fALTROConfigData=(TObjArray*)(entry->GetObject());
2293155b 443 }else{
13242232 444 AliFatal("TPC - Missing calibration entry");
5312f439 445 }
446
447 //Calibration Pulser data
448 entry = GetCDBEntry("TPC/Calib/Pulser");
449 if (entry){
450 entry->SetOwner(kTRUE);
451 fPulserData=(TObjArray*)(entry->GetObject());
452 }
453
454 //CE data
455 entry = GetCDBEntry("TPC/Calib/CE");
456 if (entry){
457 entry->SetOwner(kTRUE);
458 fCEData=(TObjArray*)(entry->GetObject());
459 }
6e7d7dc4 460 //RAW calibration data
56ce896d 461 // entry = GetCDBEntry("TPC/Calib/Raw");
8de4c8a6 462
d6834f5f 463 entry = GetCDBEntry("TPC/Calib/Mapping");
464 if (entry){
465 //if (fPadNoise) delete fPadNoise;
466 entry->SetOwner(kTRUE);
467 TObjArray * array = dynamic_cast<TObjArray*>(entry->GetObject());
468 if (array && array->GetEntriesFast()==6){
469 fMapping = new AliTPCAltroMapping*[6];
470 for (Int_t i=0; i<6; i++){
5312f439 471 fMapping[i] = dynamic_cast<AliTPCAltroMapping*>(array->At(i));
d6834f5f 472 }
473 }
474 }
475
2293155b 476 //CTP calibration data
f14d21a1 477 entry = GetCDBEntry("GRP/CTP/CTPtiming");
478 if (entry){
4a880881 479 //entry->SetOwner(kTRUE);
f14d21a1 480 fCTPTimeParams=dynamic_cast<AliCTPTimeParams*>(entry->GetObject());
2293155b 481 }else{
13242232 482 AliError("TPC - Missing calibration entry");
2293155b 483 }
be67055b 484 //TPC space point correction data
485 entry = GetCDBEntry("TPC/Calib/Correction");
486 if (entry){
487 //entry->SetOwner(kTRUE);
488 fComposedCorrection=dynamic_cast<AliTPCCorrection*>(entry->GetObject());
0b736a46 489 if (fComposedCorrection) fComposedCorrection->Init();
490 fComposedCorrectionArray=dynamic_cast<TObjArray*>(entry->GetObject());
491 if (fComposedCorrectionArray){
492 for (Int_t i=0; i<fComposedCorrectionArray->GetEntries(); i++){
3f3549a3 493 AliTPCComposedCorrection* composedCorrection= dynamic_cast<AliTPCComposedCorrection*>(fComposedCorrectionArray->At(i));
494 if (composedCorrection) {
495 composedCorrection->Init();
496 if (composedCorrection->GetCorrections()){
497 if (composedCorrection->GetCorrections()->FindObject("FitAlignTPC")){
498 fBHasAlignmentOCDB=kTRUE;
499 }
500 }
501 }
0b736a46 502 }
3f3549a3 503 }
be67055b 504 }else{
13242232 505 AliError("TPC - Missing calibration entry- TPC/Calib/Correction");
88a69e6f 506 }
507 //RCU trigger config mode
508 fMode=GetRCUTriggerConfig();
3ac615eb 509 //
f5344549 510 if (!fTransform) {
511 fTransform=new AliTPCTransform();
bfec3eeb 512 fTransform->SetCurrentRun(AliCDBManager::Instance()->GetRun());
f5344549 513 }
8477f500 514
ba63ff39 515 // Create Dead Channel Map
516 InitDeadMap();
517
c5bbaa2c 518 //
68751c2c 519 AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
c5bbaa2c 520}
e4dce695 521
56ce896d 522void AliTPCcalibDB::UpdateNonRec(){
523 //
524 // Update/Load the parameters which are important for QA studies
525 // and not used yet for the reconstruction
526 //
527 //RAW calibration data
528 AliCDBEntry * entry=0;
529 entry = GetCDBEntry("TPC/Calib/Raw");
530 if (entry){
531 entry->SetOwner(kTRUE);
532 TObjArray *arr=(TObjArray*)(entry->GetObject());
533 if (arr) fCalibRaw=(AliTPCCalibRaw*)arr->At(0);
534 }
535 //QA calibration data
536 entry = GetCDBEntry("TPC/Calib/QA");
537 if (entry){
538 entry->SetOwner(kTRUE);
539 fDataQA=dynamic_cast<AliTPCdataQA*>(entry->GetObject());
540 }
2293155b 541 // High voltage
2b4c6ff5 542 if (fRun>=0 && !fVoltageArray.GetValue(Form("%i",fRun))){
14301155 543 entry = AliCDBManager::Instance()->Get("TPC/Calib/HighVoltage",fRun);
544 if (entry) {
2b4c6ff5 545 fVoltageArray.Add(new TObjString(Form("%i",fRun)),entry->GetObject());
14301155 546 }
2293155b 547 }
548
56ce896d 549}
550
86df2b3a 551
552
553void AliTPCcalibDB::CreateObjectList(const Char_t *filename, TObjArray *calibObjects)
554{
418bbcaf 555//
556// Create calibration objects and read contents from OCDB
557//
86df2b3a 558 if ( calibObjects == 0x0 ) return;
559 ifstream in;
560 in.open(filename);
561 if ( !in.is_open() ){
562 fprintf(stderr,"Error: cannot open list file '%s'", filename);
563 return;
564 }
565
566 AliTPCCalPad *calPad=0x0;
567
568 TString sFile;
569 sFile.ReadFile(in);
570 in.close();
571
572 TObjArray *arrFileLine = sFile.Tokenize("\n");
573
574 TIter nextLine(arrFileLine);
575
576 TObjString *sObjLine=0x0;
2c632057 577 while ( (sObjLine = (TObjString*)nextLine()) ){
86df2b3a 578 TString sLine(sObjLine->GetString());
579
580 TObjArray *arrNextCol = sLine.Tokenize("\t");
581
582 TObjString *sObjType = (TObjString*)(arrNextCol->At(0));
583 TObjString *sObjFileName = (TObjString*)(arrNextCol->At(1));
584
585 if ( !sObjType || ! sObjFileName ) continue;
586 TString sType(sObjType->GetString());
587 TString sFileName(sObjFileName->GetString());
588 printf("%s\t%s\n",sType.Data(),sFileName.Data());
589
590 TFile *fIn = TFile::Open(sFileName);
591 if ( !fIn ){
592 fprintf(stderr,"File not found: '%s'", sFileName.Data());
593 continue;
594 }
595
596 if ( sType == "CE" ){
597 AliTPCCalibCE *ce = (AliTPCCalibCE*)fIn->Get("AliTPCCalibCE");
598
599 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadT0());
600 calPad->SetNameTitle("CETmean","CETmean");
601 calibObjects->Add(calPad);
602
603 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadQ());
604 calPad->SetNameTitle("CEQmean","CEQmean");
605 calibObjects->Add(calPad);
606
607 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadRMS());
608 calPad->SetNameTitle("CETrms","CETrms");
609 calibObjects->Add(calPad);
610
611 } else if ( sType == "Pulser") {
0fe7645c 612 AliTPCCalibPulser *sig = (AliTPCCalibPulser*)fIn->Get("AliTPCCalibPulser");
86df2b3a 613
614 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadT0());
615 calPad->SetNameTitle("PulserTmean","PulserTmean");
616 calibObjects->Add(calPad);
617
618 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadQ());
619 calPad->SetNameTitle("PulserQmean","PulserQmean");
620 calibObjects->Add(calPad);
621
622 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadRMS());
623 calPad->SetNameTitle("PulserTrms","PulserTrms");
624 calibObjects->Add(calPad);
625
626 } else if ( sType == "Pedestals") {
627 AliTPCCalibPedestal *ped = (AliTPCCalibPedestal*)fIn->Get("AliTPCCalibPedestal");
628
629 calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadPedestal());
630 calPad->SetNameTitle("Pedestals","Pedestals");
631 calibObjects->Add(calPad);
632
633 calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadRMS());
634 calPad->SetNameTitle("Noise","Noise");
635 calibObjects->Add(calPad);
636
637 } else {
638 fprintf(stderr,"Undefined Type: '%s'",sType.Data());
639
640 }
641 delete fIn;
642 }
643}
644
ba63ff39 645Int_t AliTPCcalibDB::InitDeadMap() {
646 // Initialize DeadChannel Map
647 // Source of information:
648 // - HV < HVnominal -delta
649 // - Altro disabled channels. Noisy channels.
650 // - DDL list
86df2b3a 651
8de4c8a6 652 // check necessary information
653 Int_t run=AliCDBManager::Instance()->GetRun();
654 if (run<0){
655 AliError("run not set in CDB manager. Cannot create active channel map");
656 return 0;
657 }
658 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
659 AliTPCCalPad* altroMap = GetALTROMasked();
660 TMap* mapddl = GetDDLMap();
661
662 if (!voltageArray && !altroMap && !mapddl) {
663 AliError("All necessary information to create the activate channel are map missing.");
664 return 0;
665 }
666
667 if (!fActiveChannelMap) fActiveChannelMap=new AliTPCCalPad("ActiveChannelMap","ActiveChannelMap");
668
669 //=============================================================
670 //get map of bad ROCs from VOLTAGE deviations
671 //
672 Bool_t badVoltage[AliTPCCalPad::kNsec]={kFALSE};
673 Double_t maxVdiff=100.;
674
675 if (voltageArray){
676 //1. get median of median of all chambers
677 Double_t chamberMedian[AliTPCCalPad::kNsec]={0.};
678 for (Int_t iROC=0;iROC<AliTPCCalPad::kNsec;++iROC){
679 TString sensorName="";
680 Char_t sideName='A';
681 if ((iROC/18)%2==1) sideName='C';
682 if (iROC<36) sensorName=Form("TPC_ANODE_I_%c%02d_VMEAS",sideName,iROC%18);
683 else sensorName=Form("TPC_ANODE_O_%c%02d_0_VMEAS",sideName,iROC%18);
684
685 AliDCSSensor *sensor = voltageArray->GetSensor(sensorName);
686 if (!sensor) continue;
687
688 chamberMedian[iROC]=0;
689 TGraph *gr=sensor->GetGraph();
690 AliSplineFit *fit=sensor->GetFit();
691 if ( gr && gr->GetN()>0 ){
692 chamberMedian[iROC]=TMath::Median(gr->GetN(),gr->GetY());
693 } else if (fit && fit->GetKnots()>0) {
694 chamberMedian[iROC]=TMath::Median(fit->GetKnots(), fit->GetY0());
695 }
696 }
697 Double_t medianIROC=TMath::Median( 36, chamberMedian );
698 Double_t medianOROC=TMath::Median( 36, chamberMedian+36 );
699
700 //2. check if 90% of the knots (points) are out of a given threshold
701 for (Int_t iROC=0;iROC<AliTPCCalPad::kNsec;++iROC){
702 badVoltage[iROC]=kFALSE;
703 TString sensorName="";
704 Char_t sideName='A';
705 Double_t median=medianIROC;
706 if ((iROC/18)%2==1) sideName='C';
707 if (iROC<36) sensorName=Form("TPC_ANODE_I_%c%02d_VMEAS",sideName,iROC%18);
708 else {sensorName=Form("TPC_ANODE_O_%c%02d_0_VMEAS",sideName,iROC%18); median=medianOROC; }
709
710 AliDCSSensor *sensor = voltageArray->GetSensor(sensorName);
711 if (!sensor) continue;
712
713 chamberMedian[iROC]=0;
714 TGraph *gr=sensor->GetGraph();
715 AliSplineFit *fit=sensor->GetFit();
83c2331b 716 Int_t nmax=1;
8de4c8a6 717 Int_t nout=0;
718 if ( gr && gr->GetN()>0 ){
719 nmax=gr->GetN();
720 for (Int_t i=0; i<gr->GetN(); ++i)
721 if ( TMath::Abs( gr->GetY()[i]-median ) > maxVdiff ) ++nout;
722 } else if (fit && fit->GetKnots()>0) {
723 nmax=fit->GetKnots();
724 for (Int_t i=0; i<fit->GetKnots(); ++i)
725 if ( TMath::Abs( fit->GetY0()[i]-median ) > maxVdiff ) ++nout;
726 }
727 if ( (Double_t)nout/(Double_t)nmax > 0.9 ) badVoltage[iROC]=kTRUE;
728 // printf("%d, %d, %d, %f\n",iROC, nout, nmax, median);
729 }
730
731 } else {
732 AliError("Voltage Array missing. ActiveChannelMap can only be created with parts of the information.");
733 }
734 // Voltage map is done
735 //=============================================================
736
737 //=============================================================
738 // Setup DDL map
739
740 Bool_t ddlMap[216]={0};
741 for (Int_t iddl=0; iddl<216; ++iddl) ddlMap[iddl]=1;
742 if (mapddl){
743 TObjString *s = (TObjString*)mapddl->GetValue("DDLArray");
744 if (s){
745 for (Int_t iddl=0; iddl<216; ++iddl) ddlMap[iddl]=TString(s->GetString()(iddl))!="0";
746 }
747 } else {
748 AliError("DDL map missing. ActiveChannelMap can only be created with parts of the information.");
749 }
750 // Setup DDL map done
751 // ============================================================
752
753 //=============================================================
754 // Setup active chnnel map
755 //
756
757 AliTPCmapper map(gSystem->ExpandPathName("$ALICE_ROOT/TPC/mapping/"));
758
759 if (!altroMap) AliError("ALTRO dead channel map missing. ActiveChannelMap can only be created with parts of the information.");
760
761 for (Int_t iROC=0;iROC<AliTPCCalPad::kNsec;++iROC){
762 AliTPCCalROC *roc=fActiveChannelMap->GetCalROC(iROC);
763 if (!roc){
764 AliError(Form("No ROC %d in active channel map",iROC));
765 continue;
766 }
767
768 // check for bad voltage
769 if (badVoltage[iROC]){
770 roc->Multiply(0.);
771 continue;
772 }
773
774 AliTPCCalROC *masked=0x0;
775 if (altroMap) masked=altroMap->GetCalROC(iROC);
776
777 for (UInt_t irow=0; irow<roc->GetNrows(); ++irow){
778 for (UInt_t ipad=0; ipad<roc->GetNPads(irow); ++ipad){
779 //per default the channel is on
780 roc->SetValue(irow,ipad,1);
781 // apply altro dead channel mask (inverse logik, it is not active, but inactive channles)
782 if (masked && masked->GetValue(irow, ipad)) roc->SetValue(irow, ipad ,0);
783 // mask channels if a DDL is inactive
784 Int_t ddlId=map.GetEquipmentID(iROC, irow, ipad)-768;
785 if (ddlId>=0 && !ddlMap[ddlId]) roc->SetValue(irow, ipad ,0);
786 }
787 }
788 }
789
790 return 1;
ba63ff39 791}
86df2b3a 792
793void AliTPCcalibDB::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad* outlierPad, Float_t ltmFraction) {
794 //
795 // Write a tree with all available information
418bbcaf 796 // if mapFileName is specified, the Map information are also written to the tree
86df2b3a 797 // pads specified in outlierPad are not used for calculating statistics
798 // - the same function as AliTPCCalPad::MakeTree -
799 //
800 AliTPCROC* tpcROCinstance = AliTPCROC::Instance();
801
802 TObjArray* mapIROCs = 0;
803 TObjArray* mapOROCs = 0;
804 TVectorF *mapIROCArray = 0;
805 TVectorF *mapOROCArray = 0;
806 Int_t mapEntries = 0;
807 TString* mapNames = 0;
808
809 if (mapFileName) {
810 TFile mapFile(mapFileName, "read");
811
812 TList* listOfROCs = mapFile.GetListOfKeys();
813 mapEntries = listOfROCs->GetEntries()/2;
814 mapIROCs = new TObjArray(mapEntries*2);
815 mapOROCs = new TObjArray(mapEntries*2);
816 mapIROCArray = new TVectorF[mapEntries];
817 mapOROCArray = new TVectorF[mapEntries];
818
819 mapNames = new TString[mapEntries];
820 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
418bbcaf 821 TString nameROC(((TKey*)(listOfROCs->At(ivalue*2)))->GetName());
822 nameROC.Remove(nameROC.Length()-4, 4);
823 mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "IROC").Data()), ivalue);
824 mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "OROC").Data()), ivalue);
825 mapNames[ivalue].Append(nameROC);
86df2b3a 826 }
827
828 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
829 mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0));
830 mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36));
831
832 for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++)
833 (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel);
834 for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++)
835 (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel);
836 }
837
838 } // if (mapFileName)
839
840 TTreeSRedirector cstream(fileName);
841 Int_t arrayEntries = array->GetEntries();
842
843 TString* names = new TString[arrayEntries];
844 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
845 names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName());
846
847 for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) {
848 //
849 // get statistic for given sector
850 //
851 TVectorF median(arrayEntries);
852 TVectorF mean(arrayEntries);
853 TVectorF rms(arrayEntries);
854 TVectorF ltm(arrayEntries);
855 TVectorF ltmrms(arrayEntries);
856 TVectorF medianWithOut(arrayEntries);
857 TVectorF meanWithOut(arrayEntries);
858 TVectorF rmsWithOut(arrayEntries);
859 TVectorF ltmWithOut(arrayEntries);
860 TVectorF ltmrmsWithOut(arrayEntries);
861
862 TVectorF *vectorArray = new TVectorF[arrayEntries];
863 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
864 vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
865
866 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
867 AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
868 AliTPCCalROC* calROC = calPad->GetCalROC(isector);
869 AliTPCCalROC* outlierROC = 0;
870 if (outlierPad) outlierROC = outlierPad->GetCalROC(isector);
871 if (calROC) {
872 median[ivalue] = calROC->GetMedian();
873 mean[ivalue] = calROC->GetMean();
874 rms[ivalue] = calROC->GetRMS();
875 Double_t ltmrmsValue = 0;
876 ltm[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction);
877 ltmrms[ivalue] = ltmrmsValue;
878 if (outlierROC) {
879 medianWithOut[ivalue] = calROC->GetMedian(outlierROC);
880 meanWithOut[ivalue] = calROC->GetMean(outlierROC);
881 rmsWithOut[ivalue] = calROC->GetRMS(outlierROC);
882 ltmrmsValue = 0;
883 ltmWithOut[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction, outlierROC);
884 ltmrmsWithOut[ivalue] = ltmrmsValue;
885 }
886 }
887 else {
888 median[ivalue] = 0.;
889 mean[ivalue] = 0.;
890 rms[ivalue] = 0.;
891 ltm[ivalue] = 0.;
892 ltmrms[ivalue] = 0.;
893 medianWithOut[ivalue] = 0.;
894 meanWithOut[ivalue] = 0.;
895 rmsWithOut[ivalue] = 0.;
896 ltmWithOut[ivalue] = 0.;
897 ltmrmsWithOut[ivalue] = 0.;
898 }
899 }
900
901 //
902 // fill vectors of variable per pad
903 //
904 TVectorF *posArray = new TVectorF[8];
905 for (Int_t ivalue = 0; ivalue < 8; ivalue++)
906 posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
907
908 Float_t posG[3] = {0};
909 Float_t posL[3] = {0};
910 Int_t ichannel = 0;
911 for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) {
912 for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) {
913 tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL);
914 tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG);
915 posArray[0][ichannel] = irow;
916 posArray[1][ichannel] = ipad;
917 posArray[2][ichannel] = posL[0];
918 posArray[3][ichannel] = posL[1];
919 posArray[4][ichannel] = posG[0];
920 posArray[5][ichannel] = posG[1];
921 posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2);
922 posArray[7][ichannel] = ichannel;
923
924 // loop over array containing AliTPCCalPads
925 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
926 AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
927 AliTPCCalROC* calROC = calPad->GetCalROC(isector);
928 if (calROC)
929 (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad);
930 else
931 (vectorArray[ivalue])[ichannel] = 0;
932 }
933 ichannel++;
934 }
935 }
936
937 cstream << "calPads" <<
938 "sector=" << isector;
939
940 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
941 cstream << "calPads" <<
942 (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] <<
943 (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] <<
944 (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] <<
945 (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] <<
946 (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue];
947 if (outlierPad) {
948 cstream << "calPads" <<
949 (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] <<
950 (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] <<
951 (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] <<
952 (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] <<
953 (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue];
954 }
955 }
956
957 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
958 cstream << "calPads" <<
959 (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue];
960 }
961
962 if (mapFileName) {
963 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
964 if (isector < 36)
965 cstream << "calPads" <<
966 (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue];
967 else
968 cstream << "calPads" <<
969 (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue];
970 }
971 }
972
973 cstream << "calPads" <<
974 "row.=" << &posArray[0] <<
975 "pad.=" << &posArray[1] <<
976 "lx.=" << &posArray[2] <<
977 "ly.=" << &posArray[3] <<
978 "gx.=" << &posArray[4] <<
979 "gy.=" << &posArray[5] <<
980 "rpad.=" << &posArray[6] <<
981 "channel.=" << &posArray[7];
982
983 cstream << "calPads" <<
984 "\n";
985
986 delete[] posArray;
987 delete[] vectorArray;
988 }
989
990
991 delete[] names;
992 if (mapFileName) {
993 delete mapIROCs;
994 delete mapOROCs;
995 delete[] mapIROCArray;
996 delete[] mapOROCArray;
997 delete[] mapNames;
998 }
999}
3ac615eb 1000
f14d21a1 1001Int_t AliTPCcalibDB::GetRCUTriggerConfig() const
1002{
1003 //
1004 // return the RCU trigger configuration register
1005 //
1006 TMap *map=GetRCUconfig();
1007 if (!map) return -1;
1008 TVectorF *v=(TVectorF*)map->GetValue("TRGCONF_TRG_MODE");
1009 Float_t mode=-1;
1010 for (Int_t i=0; i<v->GetNrows(); ++i){
1011 Float_t newmode=v->GetMatrixArray()[i];
1012 if (newmode>-1){
1013 if (mode>-1&&newmode!=mode) AliWarning("Found different RCU trigger configurations!!!");
1014 mode=newmode;
1015 }
1016 }
1017 return (Int_t)mode;
1018}
1019
1020Bool_t AliTPCcalibDB::IsTrgL0()
1021{
1022 //
1023 // return if the FEE readout was triggered on L0
1024 //
88a69e6f 1025 if (fMode<0) return kFALSE;
1026 return (fMode==1);
f14d21a1 1027}
3ac615eb 1028
f14d21a1 1029Bool_t AliTPCcalibDB::IsTrgL1()
1030{
1031 //
1032 // return if the FEE readout was triggered on L1
1033 //
88a69e6f 1034 if (fMode<0) return kFALSE;
1035 return (fMode==0);
f14d21a1 1036}
3ac615eb 1037
1038void AliTPCcalibDB::RegisterExB(Int_t index, Float_t bz, Bool_t bdelete){
1039 //
1040 // Register static ExB correction map
1041 // index - registration index - used for visualization
1042 // bz - bz field in kGaus
1043
0a997b33 1044 // Float_t factor = bz/(-5.); // default b filed in Cheb with minus sign
1045 Float_t factor = bz/(5.); // default b filed in Cheb with minus sign
1046 // was chenged in the Revision ???? (Ruben can you add here number)
3ac615eb 1047
4642ac4b 1048 AliMagF* bmap = new AliMagF("MapsExB","MapsExB", factor,TMath::Sign(1.f,factor),AliMagF::k5kG);
3ac615eb 1049
1050 AliTPCExBFirst *exb = new AliTPCExBFirst(bmap,0.88*2.6400e+04,50,50,50);
1051 AliTPCExB::SetInstance(exb);
1052
1053 if (bdelete){
1054 delete bmap;
1055 }else{
1056 AliTPCExB::RegisterField(index,bmap);
1057 }
1058 if (index>=fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
1059 fgExBArray.AddAt(exb,index);
1060}
1061
1062
1063AliTPCExB* AliTPCcalibDB::GetExB(Float_t bz, Bool_t deleteB) {
1064 //
1065 // bz filed in KGaus not in tesla
1066 // Get ExB correction map
1067 // if doesn't exist - create it
1068 //
1069 Int_t index = TMath::Nint(5+bz);
1070 if (index>fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
1071 if (!fgExBArray.At(index)) AliTPCcalibDB::RegisterExB(index,bz,deleteB);
1072 return (AliTPCExB*)fgExBArray.At(index);
1073}
1074
1075
1076void AliTPCcalibDB::SetExBField(Float_t bz){
1077 //
1078 // Set magnetic filed for ExB correction
1079 //
1080 fExB = GetExB(bz,kFALSE);
1081}
bf85fe4d 1082
0a997b33 1083void AliTPCcalibDB::SetExBField(const AliMagF* bmap){
1084 //
1085 // Set magnetic field for ExB correction
1086 //
1087 AliTPCExBFirst *exb = new AliTPCExBFirst(bmap,0.88*2.6400e+04,50,50,50);
1088 AliTPCExB::SetInstance(exb);
1089 fExB=exb;
1090}
1091
bf85fe4d 1092
1093
5e1215d4 1094void AliTPCcalibDB::UpdateRunInformations( Int_t run, Bool_t force){
bf85fe4d 1095 //
1096 // - > Don't use it for reconstruction - Only for Calibration studies
1097 //
b96c3aef 1098 if (run<=0) return;
2b4c6ff5 1099 TObjString runstr(Form("%i",run));
14301155 1100 fRun=run;
bf85fe4d 1101 AliCDBEntry * entry = 0;
cc65e4f5 1102 if (run>= fRunList.fN){
bf85fe4d 1103 fRunList.Set(run*2+1);
cc65e4f5 1104 //
1105 //
1106 fALTROConfigData->Expand(run*2+1); // ALTRO configuration data
1107 fPulserData->Expand(run*2+1); // Calibration Pulser data
1108 fCEData->Expand(run*2+1); // CE data
d32e8676 1109 if (!fTimeGainSplines) fTimeGainSplines = new TObjArray(run*2+1);
cc65e4f5 1110 fTimeGainSplines->Expand(run*2+1); // Array of AliSplineFits: at 0 MIP position in
bf85fe4d 1111 }
cc65e4f5 1112 if (fRunList[run]>0 &&force==kFALSE) return;
1e722a63 1113
1114 fRunList[run]=1; // sign as used
1115
5e1215d4 1116 //
bf85fe4d 1117 entry = AliCDBManager::Instance()->Get("GRP/GRP/Data",run);
0231c65f 1118 if (entry) {
1119 AliGRPObject * grpRun = dynamic_cast<AliGRPObject*>(entry->GetObject());
1120 if (!grpRun){
1121 TMap* map = dynamic_cast<TMap*>(entry->GetObject());
1122 if (map){
e2914767 1123 //grpRun = new AliGRPObject;
1124 //grpRun->ReadValuesFromMap(map);
1125 grpRun = MakeGRPObjectFromMap(map);
1126
2b4c6ff5 1127 fGRPMaps.Add(new TObjString(runstr),map);
0231c65f 1128 }
1129 }
2b4c6ff5 1130 fGRPArray.Add(new TObjString(runstr),grpRun);
0231c65f 1131 }
bf85fe4d 1132 entry = AliCDBManager::Instance()->Get("TPC/Calib/Goofie",run);
5e1215d4 1133 if (entry){
2b4c6ff5 1134 fGoofieArray.Add(new TObjString(runstr),entry->GetObject());
5e1215d4 1135 }
e2914767 1136 //
2293155b 1137
e2914767 1138 //
a2c3785e 1139 entry = AliCDBManager::Instance()->Get("TPC/Calib/TimeGain",run);
5e1215d4 1140 if (entry) {
2b4c6ff5 1141 fTimeGainSplinesArray.Add(new TObjString(runstr),entry->GetObject());
2293155b 1142 }else{
13242232 1143 AliFatal("TPC - Missing calibration entry TimeGain");
5e1215d4 1144 }
1145 //
1146 entry = AliCDBManager::Instance()->Get("TPC/Calib/TimeDrift",run);
1147 if (entry) {
3f3549a3 1148 TObjArray * timeArray = (TObjArray*)entry->GetObject();
2b4c6ff5 1149 fDriftCorrectionArray.Add(new TObjString(runstr),entry->GetObject());
3f3549a3 1150 AliTPCCorrection * correctionTime = (AliTPCCorrection *)timeArray->FindObject("FitCorrectionTime");
1151 if (correctionTime && fComposedCorrectionArray){
1152 correctionTime->Init();
a8ef8a9c 1153 if (fComposedCorrectionArray->GetEntriesFast()<4) fComposedCorrectionArray->Expand(40);
3f3549a3 1154 fComposedCorrectionArray->AddAt(correctionTime,4); //add time dependent correction to the list of available corrections
1155 }
2293155b 1156 }else{
13242232 1157 AliFatal("TPC - Missing calibration entry TimeDrift");
5e1215d4 1158 }
a2c3785e 1159 //
bf85fe4d 1160 entry = AliCDBManager::Instance()->Get("TPC/Calib/Temperature",run);
5e1215d4 1161 if (entry) {
2b4c6ff5 1162 fTemperatureArray.Add(new TObjString(runstr),entry->GetObject());
5e1215d4 1163 }
8de4c8a6 1164
1165 // High voltage
1166 entry = AliCDBManager::Instance()->Get("TPC/Calib/HighVoltage",run);
2b4c6ff5 1167 if (!fVoltageArray.GetValue(runstr.GetName()) && entry) {
1168 fVoltageArray.Add(new TObjString(runstr),entry->GetObject());
8de4c8a6 1169 }
1170
1e722a63 1171 //apply fDButil filters
1172
1173 fDButil->UpdateFromCalibDB();
1174 if (fTemperature) fDButil->FilterTemperature(fTemperature);
da6c0bc9 1175
bfec3eeb 1176 AliDCSSensor * press = GetPressureSensor(run,0);
da6c0bc9 1177 AliTPCSensorTempArray * temp = GetTemperatureSensor(run);
1e722a63 1178 Bool_t accept=kTRUE;
1179 if (temp) {
1180 accept = fDButil->FilterTemperature(temp)>0.1;
1181 }
1182 if (press) {
7506b1e9 1183 const Double_t kMinP=900.;
1e722a63 1184 const Double_t kMaxP=1050.;
1185 const Double_t kMaxdP=10.;
1186 const Double_t kSigmaCut=4.;
1187 fDButil->FilterSensor(press,kMinP,kMaxP,kMaxdP,kSigmaCut);
1188 if (press->GetFit()==0) accept=kFALSE;
1189 }
5647625c 1190
1e722a63 1191 if (press && temp &&accept){
da6c0bc9 1192 AliTPCCalibVdrift * vdrift = new AliTPCCalibVdrift(temp, press,0);
2b4c6ff5 1193 fVdriftArray.Add(new TObjString(runstr),vdrift);
da6c0bc9 1194 }
5647625c 1195
1e722a63 1196 fDButil->FilterCE(120., 3., 4.,0);
1197 fDButil->FilterTracks(run, 10.,0);
5647625c 1198
bf85fe4d 1199}
1200
1201
1202Float_t AliTPCcalibDB::GetGain(Int_t sector, Int_t row, Int_t pad){
1203 //
92fb7d95 1204 // Get Gain factor for given pad
bf85fe4d 1205 //
1206 AliTPCCalPad *calPad = Instance()->fDedxGainFactor;;
1207 if (!calPad) return 0;
1208 return calPad->GetCalROC(sector)->GetValue(row,pad);
1209}
1210
7390f655 1211AliSplineFit* AliTPCcalibDB::GetVdriftSplineFit(const char* name, Int_t run){
1212 //
92fb7d95 1213 // GetDrift velocity spline fit
7390f655 1214 //
1215 TObjArray *arr=GetTimeVdriftSplineRun(run);
1216 if (!arr) return 0;
1217 return dynamic_cast<AliSplineFit*>(arr->FindObject(name));
1218}
1219
2cb269df 1220AliSplineFit* AliTPCcalibDB::CreateVdriftSplineFit(const char* graphName, Int_t run){
1221 //
1222 // create spline fit from the drift time graph in TimeDrift
1223 //
1224 TObjArray *arr=GetTimeVdriftSplineRun(run);
1225 if (!arr) return 0;
1226 TGraph *graph=dynamic_cast<TGraph*>(arr->FindObject(graphName));
1227 if (!graph) return 0;
1228 AliSplineFit *fit = new AliSplineFit();
1229 fit->SetGraph(graph);
1230 fit->SetMinPoints(graph->GetN()+1);
1231 fit->InitKnots(graph,2,0,0.001);
1232 fit->SplineFit(0);
1233 return fit;
1234}
8de77f00 1235
1236AliGRPObject *AliTPCcalibDB::GetGRP(Int_t run){
1237 //
1238 // Get GRP object for given run
1239 //
2b4c6ff5 1240 AliGRPObject * grpRun = dynamic_cast<AliGRPObject *>((Instance()->fGRPArray).GetValue(Form("%i",run)));
8de77f00 1241 if (!grpRun) {
5e1215d4 1242 Instance()->UpdateRunInformations(run);
2b4c6ff5 1243 grpRun = dynamic_cast<AliGRPObject *>(Instance()->fGRPArray.GetValue(Form("%i",run)));
8de77f00 1244 if (!grpRun) return 0;
1245 }
1246 return grpRun;
1247}
1248
0231c65f 1249TMap * AliTPCcalibDB::GetGRPMap(Int_t run){
1250 //
92fb7d95 1251 // Get GRP map for given run
0231c65f 1252 //
2b4c6ff5 1253 TMap * grpRun = dynamic_cast<TMap *>((Instance()->fGRPMaps).GetValue(Form("%i",run)));
0231c65f 1254 if (!grpRun) {
5e1215d4 1255 Instance()->UpdateRunInformations(run);
2b4c6ff5 1256 grpRun = dynamic_cast<TMap *>(Instance()->fGRPMaps.GetValue(Form("%i",run)));
0231c65f 1257 if (!grpRun) return 0;
1258 }
1259 return grpRun;
1260}
8de77f00 1261
1262
da6c0bc9 1263AliDCSSensor * AliTPCcalibDB::GetPressureSensor(Int_t run, Int_t type){
bf85fe4d 1264 //
0231c65f 1265 // Get Pressure sensor
bfec3eeb 1266 // run = run number
1267 // type = 0 - Cavern pressure
1268 // 1 - Suface pressure
0231c65f 1269 // First try to get if trom map - if existing (Old format of data storing)
bf85fe4d 1270 //
bfec3eeb 1271
1272
0231c65f 1273 TMap *map = GetGRPMap(run);
1274 if (map){
1275 AliDCSSensor * sensor = 0;
1276 TObject *osensor=0;
2cd3a697 1277 if (type==0) osensor = ((*map)("fCavernPressure"));
0231c65f 1278 if (type==1) osensor = ((*map)("fP2Pressure"));
1279 sensor =dynamic_cast<AliDCSSensor *>(osensor);
1280 if (sensor) return sensor;
1281 }
1282 //
1283 // If not map try to get it from the GRPObject
1284 //
2b4c6ff5 1285 AliGRPObject * grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.GetValue(Form("%i",run)));
bf85fe4d 1286 if (!grpRun) {
5e1215d4 1287 UpdateRunInformations(run);
2b4c6ff5 1288 grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.GetValue(Form("%i",run)));
bf85fe4d 1289 if (!grpRun) return 0;
1290 }
2cd3a697 1291 AliDCSSensor * sensor = grpRun->GetCavernAtmosPressure();
da6c0bc9 1292 if (type==1) sensor = grpRun->GetSurfaceAtmosPressure();
1293 return sensor;
bf85fe4d 1294}
1295
1296AliTPCSensorTempArray * AliTPCcalibDB::GetTemperatureSensor(Int_t run){
1297 //
1298 // Get temperature sensor array
1299 //
2b4c6ff5 1300 AliTPCSensorTempArray * tempArray = (AliTPCSensorTempArray *)fTemperatureArray.GetValue(Form("%i",run));
bf85fe4d 1301 if (!tempArray) {
5e1215d4 1302 UpdateRunInformations(run);
2b4c6ff5 1303 tempArray = (AliTPCSensorTempArray *)fTemperatureArray.GetValue(Form("%i",run));
bf85fe4d 1304 }
1305 return tempArray;
1306}
1307
a2c3785e 1308
1309TObjArray * AliTPCcalibDB::GetTimeGainSplinesRun(Int_t run){
bf85fe4d 1310 //
1311 // Get temperature sensor array
1312 //
2b4c6ff5 1313 TObjArray * gainSplines = (TObjArray *)fTimeGainSplinesArray.GetValue(Form("%i",run));
a2c3785e 1314 if (!gainSplines) {
5e1215d4 1315 UpdateRunInformations(run);
2b4c6ff5 1316 gainSplines = (TObjArray *)fTimeGainSplinesArray.GetValue(Form("%i",run));
bf85fe4d 1317 }
a2c3785e 1318 return gainSplines;
bf85fe4d 1319}
1320
7390f655 1321TObjArray * AliTPCcalibDB::GetTimeVdriftSplineRun(Int_t run){
1322 //
1323 // Get drift spline array
1324 //
2b4c6ff5 1325 TObjArray * driftSplines = (TObjArray *)fDriftCorrectionArray.GetValue(Form("%i",run));
7390f655 1326 if (!driftSplines) {
1327 UpdateRunInformations(run);
2b4c6ff5 1328 driftSplines = (TObjArray *)fDriftCorrectionArray.GetValue(Form("%i",run));
7390f655 1329 }
1330 return driftSplines;
1331}
1332
e2914767 1333AliDCSSensorArray * AliTPCcalibDB::GetVoltageSensors(Int_t run){
1334 //
1335 // Get temperature sensor array
1336 //
2b4c6ff5 1337 AliDCSSensorArray * voltageArray = (AliDCSSensorArray *)fVoltageArray.GetValue(Form("%i",run));
e2914767 1338 if (!voltageArray) {
5e1215d4 1339 UpdateRunInformations(run);
2b4c6ff5 1340 voltageArray = (AliDCSSensorArray *)fVoltageArray.GetValue(Form("%i",run));
e2914767 1341 }
1342 return voltageArray;
1343}
1344
99895a4f 1345AliDCSSensorArray * AliTPCcalibDB::GetGoofieSensors(Int_t run){
1346 //
1347 // Get temperature sensor array
1348 //
2b4c6ff5 1349 AliDCSSensorArray * goofieArray = (AliDCSSensorArray *)fGoofieArray.GetValue(Form("%i",run));
99895a4f 1350 if (!goofieArray) {
5e1215d4 1351 UpdateRunInformations(run);
2b4c6ff5 1352 goofieArray = (AliDCSSensorArray *)fGoofieArray.GetValue(Form("%i",run));
99895a4f 1353 }
1354 return goofieArray;
1355}
1356
1357
1358
da6c0bc9 1359AliTPCCalibVdrift * AliTPCcalibDB::GetVdrift(Int_t run){
1360 //
1361 // Get the interface to the the vdrift
1362 //
2b4c6ff5 1363 AliTPCCalibVdrift * vdrift = (AliTPCCalibVdrift*)fVdriftArray.GetValue(Form("%i",run));
da6c0bc9 1364 if (!vdrift) {
5e1215d4 1365 UpdateRunInformations(run);
2b4c6ff5 1366 vdrift= (AliTPCCalibVdrift*)fVdriftArray.GetValue(Form("%i",run));
da6c0bc9 1367 }
1368 return vdrift;
1369}
1370
892226be 1371Float_t AliTPCcalibDB::GetCEdriftTime(Int_t run, Int_t sector, Double_t timeStamp, Int_t *entries)
1372{
1373 //
1374 // GetCE drift time information for 'sector'
1375 // sector 72 is the mean drift time of the A-Side
1376 // sector 73 is the mean drift time of the C-Side
1377 // it timestamp==-1 return mean value
1378 //
1379 AliTPCcalibDB::Instance()->SetRun(run);
1380 TGraph *gr=AliTPCcalibDB::Instance()->GetCErocTgraph(sector);
1381 if (!gr||sector<0||sector>73) {
1382 if (entries) *entries=0;
1383 return 0.;
1384 }
1385 Float_t val=0.;
1386 if (timeStamp==-1.){
1387 val=gr->GetMean(2);
1388 }else{
1389 for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
1390 Double_t x,y;
1391 gr->GetPoint(ipoint,x,y);
1392 if (x<timeStamp) continue;
1393 val=y;
1394 break;
1395 }
1396 }
1397 return val;
1398}
1399
1400Float_t AliTPCcalibDB::GetCEchargeTime(Int_t run, Int_t sector, Double_t timeStamp, Int_t *entries)
1401{
1402 //
1403 // GetCE mean charge for 'sector'
1404 // it timestamp==-1 return mean value
1405 //
1406 AliTPCcalibDB::Instance()->SetRun(run);
1407 TGraph *gr=AliTPCcalibDB::Instance()->GetCErocQgraph(sector);
1408 if (!gr||sector<0||sector>71) {
1409 if (entries) *entries=0;
1410 return 0.;
1411 }
1412 Float_t val=0.;
1413 if (timeStamp==-1.){
1414 val=gr->GetMean(2);
1415 }else{
1416 for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
1417 Double_t x,y;
1418 gr->GetPoint(ipoint,x,y);
1419 if (x<timeStamp) continue;
1420 val=y;
1421 break;
1422 }
1423 }
1424 return val;
1425}
1426
7fff7612 1427Float_t AliTPCcalibDB::GetDCSSensorValue(AliDCSSensorArray *arr, Int_t timeStamp, const char * sensorName, Int_t sigDigits)
1428{
1429 //
1430 // Get Value for a DCS sensor 'sensorName', run 'run' at time 'timeStamp'
1431 //
1432 Float_t val=0;
1433 const TString sensorNameString(sensorName);
1434 AliDCSSensor *sensor = arr->GetSensor(sensorNameString);
1435 if (!sensor) return val;
892226be 1436 //use the dcs graph if possible
1437 TGraph *gr=sensor->GetGraph();
1438 if (gr){
1439 for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
1440 Double_t x,y;
1441 gr->GetPoint(ipoint,x,y);
7390f655 1442 Int_t time=TMath::Nint(sensor->GetStartTime()+x*3600); //time in graph is hours
892226be 1443 if (time<timeStamp) continue;
1444 val=y;
1445 break;
1446 }
1447 //if val is still 0, test if if the requested time if within 5min of the first/last
1448 //data point. If this is the case return the firs/last entry
1449 //the timestamps might not be syncronised for all calibration types, sometimes a 'pre'
1450 //and 'pos' period is requested. Especially to the HV this is not the case!
1451 //first point
1452 if (val==0 ){
1453 Double_t x,y;
1454 gr->GetPoint(0,x,y);
7390f655 1455 Int_t time=TMath::Nint(sensor->GetStartTime()+x*3600); //time in graph is hours
892226be 1456 if ((time-timeStamp)<5*60) val=y;
1457 }
1458 //last point
1459 if (val==0 ){
1460 Double_t x,y;
1461 gr->GetPoint(gr->GetN()-1,x,y);
7390f655 1462 Int_t time=TMath::Nint(sensor->GetStartTime()+x*3600); //time in graph is hours
892226be 1463 if ((timeStamp-time)<5*60) val=y;
1464 }
1465 } else {
1466 val=sensor->GetValue(timeStamp);
1467 }
7fff7612 1468 if (sigDigits>=0){
1469 val=(Float_t)TMath::Floor(val * TMath::Power(10., sigDigits) + .5) / TMath::Power(10., sigDigits);
1470 }
1471 return val;
1472}
1473
1474Float_t AliTPCcalibDB::GetDCSSensorMeanValue(AliDCSSensorArray *arr, const char * sensorName, Int_t sigDigits)
1475{
1476 //
1477 // Get mean Value for a DCS sensor 'sensorName' during run 'run'
1478 //
1479 Float_t val=0;
1480 const TString sensorNameString(sensorName);
1481 AliDCSSensor *sensor = arr->GetSensor(sensorNameString);
1482 if (!sensor) return val;
892226be 1483
1484 //use dcs graph if it exists
1485 TGraph *gr=sensor->GetGraph();
1486 if (gr){
1487 val=gr->GetMean(2);
1488 } else {
1489 //if we don't have the dcs graph, try to get some meaningful information
1490 if (!sensor->GetFit()) return val;
1491 Int_t nKnots=sensor->GetFit()->GetKnots();
1492 Double_t tMid=(sensor->GetEndTime()-sensor->GetStartTime())/2.;
1493 for (Int_t iKnot=0;iKnot<nKnots;++iKnot){
1494 if (sensor->GetFit()->GetX()[iKnot]>tMid/3600.) break;
1495 val=(Float_t)sensor->GetFit()->GetY0()[iKnot];
1496 }
7fff7612 1497 }
7fff7612 1498 if (sigDigits>=0){
60721370 1499 // val/=10;
7fff7612 1500 val=(Float_t)TMath::Floor(val * TMath::Power(10., sigDigits) + .5) / TMath::Power(10., sigDigits);
60721370 1501 // val*=10;
7fff7612 1502 }
1503 return val;
1504}
bf85fe4d 1505
2073b7a5 1506Float_t AliTPCcalibDB::GetChamberHighVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits, Bool_t current) {
e2914767 1507 //
1508 // return the chamber HV for given run and time: 0-35 IROC, 36-72 OROC
7fff7612 1509 // if timeStamp==-1 return mean value
1510 //
1511 Float_t val=0;
1512 TString sensorName="";
1513 TTimeStamp stamp(timeStamp);
1514 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
1515 if (!voltageArray || (sector<0) || (sector>71)) return val;
1516 Char_t sideName='A';
1517 if ((sector/18)%2==1) sideName='C';
1518 if (sector<36){
1519 //IROC
1520 sensorName=Form("TPC_ANODE_I_%c%02d_VMEAS",sideName,sector%18);
1521 }else{
1522 //OROC
1523 sensorName=Form("TPC_ANODE_O_%c%02d_0_VMEAS",sideName,sector%18);
1524 }
2073b7a5 1525 if (current){
1526 if (sector<36){
1527 //IROC
1528 sensorName=Form("TPC_ANODE_I_%c%02d_IMEAS",sideName,sector%18);
8de4c8a6 1529 }else{
2073b7a5 1530 //OROC
1531 sensorName=Form("TPC_ANODE_O_%c%02d_0_IMEAS",sideName,sector%18);
1532 }
8de4c8a6 1533
2073b7a5 1534 }
7fff7612 1535 if (timeStamp==-1){
1536 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1537 } else {
1538 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1539 }
1540 return val;
1541}
1542Float_t AliTPCcalibDB::GetSkirtVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
1543{
1544 //
1545 // Get the skirt voltage for 'run' at 'timeStamp' and 'sector': 0-35 IROC, 36-72 OROC
1546 // type corresponds to the following: 0 - IROC A-Side; 1 - IROC C-Side; 2 - OROC A-Side; 3 - OROC C-Side
1547 // if timeStamp==-1 return the mean value for the run
1548 //
1549 Float_t val=0;
1550 TString sensorName="";
1551 TTimeStamp stamp(timeStamp);
1552 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
1553 if (!voltageArray || (sector<0) || (sector>71)) return val;
1554 Char_t sideName='A';
1555 if ((sector/18)%2==1) sideName='C';
1556 sensorName=Form("TPC_SKIRT_%c_VMEAS",sideName);
1557 if (timeStamp==-1){
1558 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1559 } else {
1560 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1561 }
1562 return val;
1563}
1564
1565Float_t AliTPCcalibDB::GetCoverVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
1566{
1567 //
1568 // Get the cover voltage for run 'run' at time 'timeStamp'
1569 // type corresponds to the following: 0 - IROC A-Side; 1 - IROC C-Side; 2 - OROC A-Side; 3 - OROC C-Side
1570 // if timeStamp==-1 return the mean value for the run
e2914767 1571 //
7fff7612 1572 Float_t val=0;
1573 TString sensorName="";
e2914767 1574 TTimeStamp stamp(timeStamp);
1575 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
7fff7612 1576 if (!voltageArray || (sector<0) || (sector>71)) return val;
1577 Char_t sideName='A';
1578 if ((sector/18)%2==1) sideName='C';
1579 if (sector<36){
1580 //IROC
1581 sensorName=Form("TPC_COVER_I_%c_VMEAS",sideName);
1582 }else{
1583 //OROC
1584 sensorName=Form("TPC_COVER_O_%c_VMEAS",sideName);
1585 }
1586 if (timeStamp==-1){
1587 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1588 } else {
1589 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1590 }
1591 return val;
1592}
1593
1594Float_t AliTPCcalibDB::GetGGoffsetVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
1595{
1596 //
1597 // Get the GG offset voltage for run 'run' at time 'timeStamp'
1598 // type corresponds to the following: 0 - IROC A-Side; 1 - IROC C-Side; 2 - OROC A-Side; 3 - OROC C-Side
1599 // if timeStamp==-1 return the mean value for the run
1600 //
1601 Float_t val=0;
1602 TString sensorName="";
1603 TTimeStamp stamp(timeStamp);
1604 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
1605 if (!voltageArray || (sector<0) || (sector>71)) return val;
1606 Char_t sideName='A';
1607 if ((sector/18)%2==1) sideName='C';
1608 if (sector<36){
1609 //IROC
1610 sensorName=Form("TPC_GATE_I_%c_OFF_VMEAS",sideName);
1611 }else{
1612 //OROC
1613 sensorName=Form("TPC_GATE_O_%c_OFF_VMEAS",sideName);
1614 }
1615 if (timeStamp==-1){
1616 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1617 } else {
1618 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1619 }
1620 return val;
1621}
1622
1623Float_t AliTPCcalibDB::GetGGnegVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
1624{
1625 //
1626 // Get the GG offset voltage for run 'run' at time 'timeStamp'
1627 // type corresponds to the following: 0 - IROC A-Side; 1 - IROC C-Side; 2 - OROC A-Side; 3 - OROC C-Side
1628 // if timeStamp==-1 return the mean value for the run
1629 //
1630 Float_t val=0;
1631 TString sensorName="";
1632 TTimeStamp stamp(timeStamp);
1633 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
1634 if (!voltageArray || (sector<0) || (sector>71)) return val;
1635 Char_t sideName='A';
1636 if ((sector/18)%2==1) sideName='C';
1637 if (sector<36){
1638 //IROC
1639 sensorName=Form("TPC_GATE_I_%c_NEG_VMEAS",sideName);
1640 }else{
1641 //OROC
1642 sensorName=Form("TPC_GATE_O_%c_NEG_VMEAS",sideName);
1643 }
1644 if (timeStamp==-1){
1645 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1646 } else {
1647 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1648 }
1649 return val;
1650}
1651
1652Float_t AliTPCcalibDB::GetGGposVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
1653{
1654 //
1655 // Get the GG offset voltage for run 'run' at time 'timeStamp'
1656 // type corresponds to the following: 0 - IROC A-Side; 1 - IROC C-Side; 2 - OROC A-Side; 3 - OROC C-Side
1657 // if timeStamp==-1 return the mean value for the run
1658 //
1659 Float_t val=0;
1660 TString sensorName="";
1661 TTimeStamp stamp(timeStamp);
1662 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
1663 if (!voltageArray || (sector<0) || (sector>71)) return val;
1664 Char_t sideName='A';
1665 if ((sector/18)%2==1) sideName='C';
1666 if (sector<36){
1667 //IROC
1668 sensorName=Form("TPC_GATE_I_%c_POS_VMEAS",sideName);
1669 }else{
1670 //OROC
1671 sensorName=Form("TPC_GATE_O_%c_POS_VMEAS",sideName);
1672 }
1673 if (timeStamp==-1){
1674 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1675 } else {
1676 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1677 }
1678 return val;
e2914767 1679}
bf85fe4d 1680
da6c0bc9 1681Float_t AliTPCcalibDB::GetPressure(Int_t timeStamp, Int_t run, Int_t type){
bf85fe4d 1682 //
1683 // GetPressure for given time stamp and runt
1684 //
1685 TTimeStamp stamp(timeStamp);
da6c0bc9 1686 AliDCSSensor * sensor = Instance()->GetPressureSensor(run,type);
bf85fe4d 1687 if (!sensor) return 0;
bf85fe4d 1688 return sensor->GetValue(stamp);
1689}
1690
5312f439 1691Float_t AliTPCcalibDB::GetL3Current(Int_t run, Int_t statType){
1692 //
1693 // return L3 current
1694 // stat type is: AliGRPObject::Stats: kMean = 0, kTruncMean = 1, kMedian = 2, kSDMean = 3, kSDMedian = 4
1695 //
1696 Float_t current=-1;
1697 AliGRPObject *grp=AliTPCcalibDB::GetGRP(run);
1698 if (grp) current=grp->GetL3Current((AliGRPObject::Stats)statType);
1699 return current;
1700}
1701
1702Float_t AliTPCcalibDB::GetBz(Int_t run){
1703 //
e6970ab5 1704 // calculate BZ in T from L3 current
5312f439 1705 //
1706 Float_t bz=-1;
1707 Float_t current=AliTPCcalibDB::GetL3Current(run);
e6970ab5 1708 if (current>-1) bz=5*current/30000.*.1;
5312f439 1709 return bz;
1710}
1711
1712Char_t AliTPCcalibDB::GetL3Polarity(Int_t run) {
1713 //
1714 // get l3 polarity from GRP
1715 //
7390f655 1716 Char_t pol=-100;
1717 AliGRPObject *grp=AliTPCcalibDB::GetGRP(run);
1718 if (grp) pol=grp->GetL3Polarity();
1719 return pol;
5312f439 1720}
1721
1722TString AliTPCcalibDB::GetRunType(Int_t run){
1723 //
1724 // return run type from grp
1725 //
7390f655 1726
1727// TString type("UNKNOWN");
1728 AliGRPObject *grp=AliTPCcalibDB::GetGRP(run);
1729 if (grp) return grp->GetRunType();
1730 return "UNKNOWN";
5312f439 1731}
1732
7f7847fe 1733Float_t AliTPCcalibDB::GetValueGoofie(Int_t timeStamp, Int_t run, Int_t type){
1734 //
1735 // GetPressure for given time stamp and runt
1736 //
1737 TTimeStamp stamp(timeStamp);
1738 AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(run);
1739 if (!goofieArray) return 0;
1740 AliDCSSensor *sensor = goofieArray->GetSensor(type);
1741 return sensor->GetValue(stamp);
1742}
1743
1744
1745
1746
1747
1748
f0269955 1749Bool_t AliTPCcalibDB::GetTemperatureFit(Int_t timeStamp, Int_t run, Int_t side,TVectorD& fit){
1750 //
92fb7d95 1751 // GetTmeparature fit at parameter for given time stamp
f0269955 1752 //
1753 TTimeStamp tstamp(timeStamp);
64b48395 1754 AliTPCSensorTempArray* tempArray = Instance()->GetTemperatureSensor(run);
f0269955 1755 if (! tempArray) return kFALSE;
1756 AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray);
1757 TLinearFitter * fitter = tempMap->GetLinearFitter(3,side,tstamp);
1758 if (fitter){
1759 fitter->Eval();
1760 fitter->GetParameters(fit);
1761 }
1762 delete fitter;
1763 delete tempMap;
1764 if (!fitter) return kFALSE;
1765 return kTRUE;
1766}
1767
64b48395 1768Float_t AliTPCcalibDB::GetTemperature(Int_t timeStamp, Int_t run, Int_t side){
1769 //
92fb7d95 1770 // Get mean temperature
1771 //
12e42756 1772 TVectorD vec(5);
64b48395 1773 if (side==0) {
1774 GetTemperatureFit(timeStamp,run,0,vec);
1775 return vec[0];
1776 }
1777 if (side==1){
1778 GetTemperatureFit(timeStamp,run,0,vec);
1779 return vec[0];
1780 }
57dc06f2 1781 return 0;
64b48395 1782}
bf85fe4d 1783
1784
da6c0bc9 1785Double_t AliTPCcalibDB::GetPTRelative(UInt_t timeSec, Int_t run, Int_t side){
1786 //
1787 // Get relative P/T
1788 // time - absolute time
1789 // run - run number
1790 // side - 0 - A side 1-C side
1791 AliTPCCalibVdrift * vdrift = Instance()->GetVdrift(run);
1792 if (!vdrift) return 0;
1793 return vdrift->GetPTRelative(timeSec,side);
1794}
1795
e2914767 1796AliGRPObject * AliTPCcalibDB::MakeGRPObjectFromMap(TMap *map){
1797 //
1798 // Function to covert old GRP run information from TMap to GRPObject
1799 //
1800 // TMap * map = AliTPCcalibDB::GetGRPMap(52406);
1801 if (!map) return 0;
1802 AliDCSSensor * sensor = 0;
1803 TObject *osensor=0;
1804 osensor = ((*map)("fP2Pressure"));
1805 sensor =dynamic_cast<AliDCSSensor *>(osensor);
1806 //
1807 if (!sensor) return 0;
1808 //
1809 AliDCSSensor * sensor2 = new AliDCSSensor(*sensor);
2cd3a697 1810 osensor = ((*map)("fCavernPressure"));
e2914767 1811 TGraph * gr = new TGraph(2);
1812 gr->GetX()[0]= -100000.;
1813 gr->GetX()[1]= 1000000.;
1814 gr->GetY()[0]= atof(osensor->GetName());
1815 gr->GetY()[1]= atof(osensor->GetName());
1816 sensor2->SetGraph(gr);
1817 sensor2->SetFit(0);
1818
1819
1820 AliGRPObject *grpRun = new AliGRPObject;
1821 grpRun->ReadValuesFromMap(map);
1822 grpRun->SetCavernAtmosPressure(sensor2);
2cd3a697 1823 grpRun->SetCavernAtmosPressure(sensor2);
e2914767 1824 grpRun->SetSurfaceAtmosPressure(sensor);
1825 return grpRun;
1826}
1827
5312f439 1828Bool_t AliTPCcalibDB::CreateGUITree(Int_t run, const char* filename)
1829{
1830 //
1831 // Create a gui tree for run number 'run'
1832 //
e2914767 1833
5312f439 1834 if (!AliCDBManager::Instance()->GetDefaultStorage()){
1835 AliLog::Message(AliLog::kError, "Default Storage not set. Cannot create Calibration Tree!",
1836 MODULENAME(), "AliTPCcalibDB", FUNCTIONNAME(), __FILE__, __LINE__);
1837 return kFALSE;
1838 }
1839 //db instance
1840 AliTPCcalibDB *db=AliTPCcalibDB::Instance();
1841 // retrieve cal pad objects
1842 db->SetRun(run);
949d8707 1843 db->CreateGUITree(filename);
7fe54a9b 1844 return kTRUE;
949d8707 1845}
1846
1847Bool_t AliTPCcalibDB::CreateGUITree(const char* filename){
1848 //
1849 //
1850 //
1851 if (!AliCDBManager::Instance()->GetDefaultStorage()){
1852 AliError("Default Storage not set. Cannot create calibration Tree!");
1853 return kFALSE;
1854 }
56ce896d 1855 UpdateNonRec(); // load all infromation now
1856
5312f439 1857 AliTPCPreprocessorOnline prep;
1858 //noise and pedestals
949d8707 1859 if (GetPedestals()) prep.AddComponent(new AliTPCCalPad(*(GetPedestals())));
1860 if (GetPadNoise() ) prep.AddComponent(new AliTPCCalPad(*(GetPadNoise())));
5312f439 1861 //pulser data
949d8707 1862 if (GetPulserTmean()) prep.AddComponent(new AliTPCCalPad(*(GetPulserTmean())));
1863 if (GetPulserTrms() ) prep.AddComponent(new AliTPCCalPad(*(GetPulserTrms())));
1864 if (GetPulserQmean()) prep.AddComponent(new AliTPCCalPad(*(GetPulserQmean())));
5312f439 1865 //CE data
949d8707 1866 if (GetCETmean()) prep.AddComponent(new AliTPCCalPad(*(GetCETmean())));
1867 if (GetCETrms() ) prep.AddComponent(new AliTPCCalPad(*(GetCETrms())));
1868 if (GetCEQmean()) prep.AddComponent(new AliTPCCalPad(*(GetCEQmean())));
5312f439 1869 //Altro data
949d8707 1870 if (GetALTROAcqStart() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROAcqStart() )));
1871 if (GetALTROZsThr() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROZsThr() )));
1872 if (GetALTROFPED() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROFPED() )));
1873 if (GetALTROAcqStop() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROAcqStop() )));
1874 if (GetALTROMasked() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROMasked() )));
1875 //QA
1876 AliTPCdataQA *dataQA=GetDataQA();
1877 if (dataQA) {
1878 if (dataQA->GetNLocalMaxima())
1879 prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNLocalMaxima())));
1880 if (dataQA->GetMaxCharge())
1881 prep.AddComponent(new AliTPCCalPad(*(dataQA->GetMaxCharge())));
1882 if (dataQA->GetMeanCharge())
1883 prep.AddComponent(new AliTPCCalPad(*(dataQA->GetMeanCharge())));
1884 if (dataQA->GetNoThreshold())
1885 prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNoThreshold())));
1886 if (dataQA->GetNTimeBins())
1887 prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNTimeBins())));
1888 if (dataQA->GetNPads())
1889 prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNPads())));
1890 if (dataQA->GetTimePosition())
1891 prep.AddComponent(new AliTPCCalPad(*(dataQA->GetTimePosition())));
1892 }
1893
5312f439 1894 //
1895 TString file(filename);
2b4c6ff5 1896 if (file.IsNull()) file=Form("guiTreeRun_%i.root",fRun);
5312f439 1897 prep.DumpToFile(file.Data());
1898 return kTRUE;
1899}
e2914767 1900
7390f655 1901Bool_t AliTPCcalibDB::CreateRefFile(Int_t run, const char* filename)
1902{
1903 //
1904 // Create a gui tree for run number 'run'
1905 //
1906
1907 if (!AliCDBManager::Instance()->GetDefaultStorage()){
1908 AliLog::Message(AliLog::kError, "Default Storage not set. Cannot create Calibration Tree!",
1909 MODULENAME(), "AliTPCcalibDB", FUNCTIONNAME(), __FILE__, __LINE__);
1910 return kFALSE;
1911 }
1912 TString file(filename);
1913 if (file.IsNull()) file=Form("RefCalPads_%d.root",run);
1914 TDirectory *currDir=gDirectory;
1915 //db instance
1916 AliTPCcalibDB *db=AliTPCcalibDB::Instance();
1917 // retrieve cal pad objects
1918 db->SetRun(run);
1919 //open file
1920 TFile f(file.Data(),"recreate");
1921 //noise and pedestals
1922 db->GetPedestals()->Write("Pedestals");
1923 db->GetPadNoise()->Write("PadNoise");
1924 //pulser data
1925 db->GetPulserTmean()->Write("PulserTmean");
1926 db->GetPulserTrms()->Write("PulserTrms");
1927 db->GetPulserQmean()->Write("PulserQmean");
1928 //CE data
1929 db->GetCETmean()->Write("CETmean");
1930 db->GetCETrms()->Write("CETrms");
1931 db->GetCEQmean()->Write("CEQmean");
1932 //Altro data
1933 db->GetALTROAcqStart() ->Write("ALTROAcqStart");
1934 db->GetALTROZsThr() ->Write("ALTROZsThr");
1935 db->GetALTROFPED() ->Write("ALTROFPED");
1936 db->GetALTROAcqStop() ->Write("ALTROAcqStop");
1937 db->GetALTROMasked() ->Write("ALTROMasked");
1938 //
1939 f.Close();
1940 currDir->cd();
1941 return kTRUE;
1942}
17c90083 1943
1944
1945
817766d5 1946Double_t AliTPCcalibDB::GetVDriftCorrectionTime(Int_t timeStamp, Int_t run, Int_t /*side*/, Int_t mode){
17c90083 1947 //
1948 // Get time dependent drift velocity correction
1949 // multiplication factor vd = vdnom *(1+vdriftcorr)
1950 // Arguments:
1951 // mode determines the algorith how to combine the Laser Track, LaserCE and physics tracks
1952 // timestamp - timestamp
1953 // run - run number
1954 // side - the drift velocity per side (possible for laser and CE)
1955 //
1956 // Notice - Extrapolation outside of calibration range - using constant function
1957 //
b7c5eb40 1958 Double_t result=0;
1e722a63 1959 // mode 1 automatic mode - according to the distance to the valid calibration
1960 // -
cc65e4f5 1961 Double_t deltaP=0, driftP=0, wP = 0.;
1962 Double_t deltaITS=0,driftITS=0, wITS= 0.;
1963 Double_t deltaLT=0, driftLT=0, wLT = 0.;
1964 Double_t deltaCE=0, driftCE=0, wCE = 0.;
1e722a63 1965 driftP = fDButil->GetVDriftTPC(deltaP,run,timeStamp);
cc65e4f5 1966 driftITS= fDButil->GetVDriftTPCITS(deltaITS,run,timeStamp);
1e722a63 1967 driftCE = fDButil->GetVDriftTPCCE(deltaCE, run,timeStamp,36000,2);
1968 driftLT = fDButil->GetVDriftTPCLaserTracks(deltaLT,run,timeStamp,36000,2);
cc65e4f5 1969 deltaITS = TMath::Abs(deltaITS);
1e722a63 1970 deltaP = TMath::Abs(deltaP);
1971 deltaLT = TMath::Abs(deltaLT);
1972 deltaCE = TMath::Abs(deltaCE);
1973 if (mode==1) {
cc65e4f5 1974 const Double_t kEpsilon=0.00000000001;
1975 const Double_t kdeltaT=360.; // 10 minutes
a52d8b6f 1976 if(TMath::Abs(deltaITS) < 12*kdeltaT) {
5647625c 1977 result = driftITS;
1978 } else {
cc65e4f5 1979 wITS = 64.*kdeltaT/(deltaITS +kdeltaT);
1980 wLT = 16.*kdeltaT/(deltaLT +kdeltaT);
1981 wP = 0. *kdeltaT/(deltaP +kdeltaT);
1982 wCE = 1. *kdeltaT/(deltaCE +kdeltaT);
1983 //
1984 //
1985 if (TMath::Abs(driftP)<kEpsilon) wP=0; // invalid calibration
1986 if (TMath::Abs(driftITS)<kEpsilon)wITS=0; // invalid calibration
1987 if (TMath::Abs(driftLT)<kEpsilon) wLT=0; // invalid calibration
1e722a63 1988 if (TMath::Abs(driftCE)<kEpsilon) wCE=0; // invalid calibration
cc65e4f5 1989 if (wP+wITS+wLT+wCE<kEpsilon) return 0;
1990 result = (driftP*wP+driftITS*wITS+driftLT*wLT+driftCE*wCE)/(wP+wITS+wLT+wCE);
5647625c 1991 }
1992
1993
43a74775 1994 }
817766d5 1995
43a74775 1996 return result;
17c90083 1997}
1998
817766d5 1999Double_t AliTPCcalibDB::GetTime0CorrectionTime(Int_t timeStamp, Int_t run, Int_t /*side*/, Int_t mode){
17c90083 2000 //
43a74775 2001 // Get time dependent time 0 (trigger delay in cm) correction
17c90083 2002 // additive correction time0 = time0+ GetTime0CorrectionTime
2003 // Value etracted combining the vdrift correction using laser tracks and CE and the physics track matchin
2004 // Arguments:
2005 // mode determines the algorith how to combine the Laser Track and physics tracks
2006 // timestamp - timestamp
2007 // run - run number
2008 // side - the drift velocity per side (possible for laser and CE)
2009 //
2010 // Notice - Extrapolation outside of calibration range - using constant function
2011 //
817766d5 2012 Double_t result=0;
cc65e4f5 2013 if (mode==2) {
2014 // TPC-TPC mode
2015 result=fDButil->GetTriggerOffsetTPC(run,timeStamp);
2016 result *=fParam->GetZLength();
2017 }
2018 if (mode==1){
2019 // TPC-ITS mode
2020 Double_t dist=0;
86c39d37 2021 result= -fDButil->GetTime0TPCITS(dist, run, timeStamp)*fParam->GetDriftV()/1000000.;
cc65e4f5 2022 }
817766d5 2023 return result;
43a74775 2024
17c90083 2025}
2026
2027
2028
2029
43a74775 2030Double_t AliTPCcalibDB::GetVDriftCorrectionGy(Int_t timeStamp, Int_t run, Int_t side, Int_t /*mode*/){
17c90083 2031 //
2032 // Get global y correction drift velocity correction factor
2033 // additive factor vd = vdnom*(1+GetVDriftCorrectionGy *gy)
5647625c 2034 // Value etracted combining the vdrift correction using laser tracks and CE or TPC-ITS
17c90083 2035 // Arguments:
5647625c 2036 // mode determines the algorith how to combine the Laser Track, LaserCE or TPC-ITS
17c90083 2037 // timestamp - timestamp
2038 // run - run number
2039 // side - the drift velocity gy correction per side (CE and Laser tracks)
2040 //
2041 // Notice - Extrapolation outside of calibration range - using constant function
a8f8b6a1 2042 //
2043 if (run<=0 && fTransform) run = fTransform->GetCurrentRunNumber();
2044 UpdateRunInformations(run,kFALSE);
43a74775 2045 TObjArray *array =AliTPCcalibDB::Instance()->GetTimeVdriftSplineRun(run);
4429bfef 2046 if (!array) return 0;
5647625c 2047 Double_t result=0;
2048
2049 // use TPC-ITS if present
2050 TGraphErrors *gr= (TGraphErrors*)array->FindObject("ALIGN_ITSB_TPC_VDGY");
2051 if(gr) {
0fc78dbd 2052 result = AliTPCcalibDButil::EvalGraphConst(gr,timeStamp);
5647625c 2053
2054 // transform from [(cm/mus)/ m] to [1/cm]
2055 result /= (fParam->GetDriftV()/1000000.);
2056 result /= 100.;
2057
2058 //printf("result %e \n", result);
2059 return result;
2060 }
2061
2062 // use laser if ITS-TPC not present
43a74775 2063 TGraphErrors *laserA= (TGraphErrors*)array->FindObject("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_A");
2064 TGraphErrors *laserC= (TGraphErrors*)array->FindObject("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_C");
2065
43a74775 2066 if (laserA && laserC){
2067 result= (laserA->Eval(timeStamp)+laserC->Eval(timeStamp))*0.5;
2068 }
2069 if (laserA && side==0){
2070 result = (laserA->Eval(timeStamp));
2071 }
2072 if (laserC &&side==1){
2073 result = (laserC->Eval(timeStamp));
2074 }
5647625c 2075 //printf("laser result %e \n", -result/250.);
2076
43a74775 2077 return -result/250.; //normalized before
17c90083 2078}
949d8707 2079
72b94ffb 2080AliTPCCalPad* AliTPCcalibDB::MakeDeadMap(Double_t notInMap, const char* nameMappingFile) {
f6b5fa33 2081//
2082// Read list of active DDLs from OCDB entry
2083// Generate and return AliTPCCalPad containing 1 for all pads in active DDLs,
2084// 0 for all pads in non-active DDLs.
72b94ffb 2085// For DDLs with missing status information (no DCS input point to Shuttle),
2086// the value of the AliTPCCalPad entry is determined by the parameter
2087// notInMap (default value 1)
f6b5fa33 2088//
2089 char chinfo[1000];
2090
2091 TFile *fileMapping = new TFile(nameMappingFile, "read");
2092 AliTPCmapper *mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
2093 if (!mapping) {
4aa37f93 2094 snprintf(chinfo,1000,"Failed to get mapping object from %s. ...\n", nameMappingFile);
f6b5fa33 2095 AliError (chinfo);
2096 return 0;
2097 }
2098
2099 AliTPCCalPad *deadMap = new AliTPCCalPad("deadMap","deadMap");
2100 if (!deadMap) {
2101 AliError("Failed to allocate dead map AliTPCCalPad");
2102 return 0;
2103 }
2104
2105 /// get list of active DDLs from OCDB entry
2106 Int_t idDDL=0;
2107 if (!fALTROConfigData ) {
2108 AliError("No ALTRO config OCDB entry available");
2109 return 0;
2110 }
2111 TMap *activeDDL = (TMap*)fALTROConfigData->FindObject("DDLArray");
2112 TObjString *ddlArray=0;
2113 if (activeDDL) {
2114 ddlArray = (TObjString*)activeDDL->GetValue("DDLArray");
2115 if (!ddlArray) {
2116 AliError("Empty list of active DDLs in OCDB entry");
2117 return 0;
2118 }
2119 } else {
2120 AliError("List of active DDLs not available in OCDB entry");
2121 return 0;
2122 }
2123 TString arrDDL=ddlArray->GetString();
2124 Int_t offset = mapping->GetTpcDdlOffset();
2125 Double_t active;
2126 for (Int_t i=0; i<mapping->GetNumDdl(); i++) {
2127 idDDL= i+offset;
d150d64f 2128 if (idDDL<0) continue;
f6b5fa33 2129 Int_t patch = mapping->GetPatchFromEquipmentID(idDDL);
9f98a33d 2130 if (patch<0) continue;
f6b5fa33 2131 Int_t roc=mapping->GetRocFromEquipmentID(idDDL);
55d90f9a 2132 if (roc<0) continue;
f6b5fa33 2133 AliTPCCalROC *calRoc=deadMap->GetCalROC(roc);
2134 if (calRoc) {
2135 for ( Int_t branch = 0; branch < 2; branch++ ) {
2136 for ( Int_t fec = 0; fec < mapping->GetNfec(patch, branch); fec++ ) {
2137 for ( Int_t altro = 0; altro < 8; altro++ ) {
2138 for ( Int_t channel = 0; channel < 16; channel++ ) {
2139 Int_t hwadd = mapping->CodeHWAddress(branch, fec, altro, channel);
2140 Int_t row = mapping->GetPadRow(patch, hwadd); // row in a ROC (IROC or OROC)
2141// Int_t globalrow = mapping.GetGlobalPadRow(patch, hwadd); // row in full sector (IROC plus OROC)
2142 Int_t pad = mapping->GetPad(patch, hwadd);
72b94ffb 2143 if (!TString(arrDDL[i]).IsDigit()) {
2144 active = notInMap;
2145 } else {
2146 active=TString(arrDDL[i]).Atof();
2147 }
f6b5fa33 2148 calRoc->SetValue(row,pad,active);
2149 } // end channel for loop
2150 } // end altro for loop
2151 } // end fec for loop
2152 } // end branch for loop
2153 } // valid calROC
2154 } // end loop on active DDLs
2155 return deadMap;
2156}
f14d21a1 2157
2158
0b736a46 2159
2160AliTPCCorrection * AliTPCcalibDB::GetTPCComposedCorrection(Float_t field) const{
2161 //
2162 // GetComposed correction for given field setting
3f3549a3 2163 // If not specific correction for field used return correction for all field
2164 // - Complication needed to gaurantee OCDB back compatibility
2165 // - Not neeeded for the new space point correction
0b736a46 2166 if (!fComposedCorrectionArray) return 0;
3f3549a3 2167 if (field>0.1 && fComposedCorrectionArray->At(1)) {
2168 return (AliTPCCorrection *)fComposedCorrectionArray->At(1);
2169 }
2170 if (field<-0.1 &&fComposedCorrectionArray->At(2)) {
2171 return (AliTPCCorrection *)fComposedCorrectionArray->At(2);
2172 }
0b736a46 2173 return (AliTPCCorrection *)fComposedCorrectionArray->At(0);
2174
2175}
2176
3f3549a3 2177
2178AliTPCCorrection * AliTPCcalibDB::GetTPCComposedCorrectionDelta() const{
2179 //
2180 // GetComposedCorrection delta
2181 // Delta is time dependent - taken form the CalibTime OCDB entry
2182 //
2183 if (!fComposedCorrectionArray) return 0;
a8ef8a9c 2184 if (fRun<0) return 0;
2b4c6ff5 2185 if (fDriftCorrectionArray.GetValue(Form("%i",fRun))==0) return 0;
012c4694 2186 if (fComposedCorrectionArray->GetEntriesFast()<=4) {
2187 fComposedCorrectionArray->Expand(5);
2b4c6ff5 2188 TObjArray * timeArray =(TObjArray*)(fDriftCorrectionArray.GetValue(Form("%i",fRun)));
a8ef8a9c 2189 AliTPCCorrection * correctionTime = (AliTPCCorrection *)timeArray->FindObject("FitCorrectionTime");
2190 if (correctionTime){
2191 correctionTime->Init();
2192 fComposedCorrectionArray->AddAt(correctionTime,4); //add time dependent c
2193 }
2194 }
3f3549a3 2195 return (AliTPCCorrection *)fComposedCorrectionArray->At(4); //
2196}
2197