Eff C++ warning removal (Marian)
[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
51// in AliTPCtracker::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>
85#include <AliLog.h>
3ac615eb 86#include <AliMagF.h>
87#include <AliMagWrapCheb.h>
c5bbaa2c 88
89#include "AliTPCcalibDB.h"
d6834f5f 90#include "AliTPCAltroMapping.h"
418bbcaf 91#include "AliTPCExB.h"
c5bbaa2c 92
93#include "AliTPCCalROC.h"
94#include "AliTPCCalPad.h"
54472e4f 95#include "AliTPCSensorTempArray.h"
418bbcaf 96#include "AliTPCTransform.h"
d6834f5f 97
418bbcaf 98class AliCDBStorage;
99class AliTPCCalDet;
86df2b3a 100//
101//
102
86df2b3a 103#include "TFile.h"
104#include "TKey.h"
105
106#include "TObjArray.h"
107#include "TObjString.h"
108#include "TString.h"
109#include "AliTPCCalPad.h"
0fe7645c 110#include "AliTPCCalibPulser.h"
86df2b3a 111#include "AliTPCCalibPedestal.h"
112#include "AliTPCCalibCE.h"
3ac615eb 113#include "AliTPCExBFirst.h"
86df2b3a 114
115
116
117
c5bbaa2c 118
119ClassImp(AliTPCcalibDB)
120
121AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0;
122Bool_t AliTPCcalibDB::fgTerminated = kFALSE;
3ac615eb 123TObjArray AliTPCcalibDB::fgExBArray; // array of ExB corrections
c5bbaa2c 124
125
126//_ singleton implementation __________________________________________________
127AliTPCcalibDB* AliTPCcalibDB::Instance()
128{
129 //
130 // Singleton implementation
131 // Returns an instance of this class, it is created if neccessary
132 //
133
134 if (fgTerminated != kFALSE)
135 return 0;
136
137 if (fgInstance == 0)
138 fgInstance = new AliTPCcalibDB();
139
140 return fgInstance;
141}
142
143void AliTPCcalibDB::Terminate()
144{
145 //
146 // Singleton implementation
147 // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
148 // This function can be called several times.
149 //
150
151 fgTerminated = kTRUE;
152
153 if (fgInstance != 0)
154 {
155 delete fgInstance;
156 fgInstance = 0;
157 }
158}
159
160//_____________________________________________________________________________
e4dce695 161AliTPCcalibDB::AliTPCcalibDB():
9389f9a4 162 TObject(),
e4dce695 163 fRun(-1),
f5344549 164 fTransform(0),
481f877b 165 fExB(0),
e4dce695 166 fPadGainFactor(0),
9f6e9f81 167 fDedxGainFactor(0),
e4dce695 168 fPadTime0(0),
e4dce695 169 fPadNoise(0),
170 fPedestals(0),
171 fTemperature(0),
d6834f5f 172 fMapping(0),
96305e49 173 fParam(0),
174 fClusterParam(0)
c5bbaa2c 175{
176 //
177 // constructor
178 //
54472e4f 179 //
c5bbaa2c 180 Update(); // temporary
181}
182
9389f9a4 183AliTPCcalibDB::AliTPCcalibDB(const AliTPCcalibDB& ):
184 TObject(),
185 fRun(-1),
186 fTransform(0),
187 fExB(0),
188 fPadGainFactor(0),
9f6e9f81 189 fDedxGainFactor(0),
9389f9a4 190 fPadTime0(0),
191 fPadNoise(0),
192 fPedestals(0),
193 fTemperature(0),
194 fMapping(0),
9389f9a4 195 fParam(0),
196 fClusterParam(0)
197
198{
199 //
200 // Copy constructor invalid -- singleton implementation
201 //
202 Error("copy constructor","invalid -- singleton implementation");
203}
204
205AliTPCcalibDB& AliTPCcalibDB::operator= (const AliTPCcalibDB& )
206{
207//
208// Singleton implementation - no assignment operator
209//
210 Error("operator =", "assignment operator not implemented");
211 return *this;
212}
213
214
215
c5bbaa2c 216//_____________________________________________________________________________
217AliTPCcalibDB::~AliTPCcalibDB()
218{
219 //
220 // destructor
221 //
68751c2c 222
223 // don't delete anything, CDB cache is active!
224 //if (fPadGainFactor) delete fPadGainFactor;
225 //if (fPadTime0) delete fPadTime0;
68751c2c 226 //if (fPadNoise) delete fPadNoise;
c5bbaa2c 227}
228
229
230//_____________________________________________________________________________
231AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
232{
233 //
234 // Retrieves an entry with path <cdbPath> from the CDB.
235 //
236 char chinfo[1000];
237
68751c2c 238 AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
c5bbaa2c 239 if (!entry)
240 {
241 sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
242 AliError(chinfo);
243 return 0;
244 }
245 return entry;
246}
247
248
249//_____________________________________________________________________________
250void AliTPCcalibDB::SetRun(Long64_t run)
251{
252 //
253 // Sets current run number. Calibration data is read from the corresponding file.
254 //
255 if (fRun == run)
256 return;
257 fRun = run;
258 Update();
259}
260
261
262
263void AliTPCcalibDB::Update(){
264 //
265 AliCDBEntry * entry=0;
68751c2c 266
267 Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
268 AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
269
c5bbaa2c 270 //
271 entry = GetCDBEntry("TPC/Calib/PadGainFactor");
272 if (entry){
68751c2c 273 //if (fPadGainFactor) delete fPadGainFactor;
c5bbaa2c 274 entry->SetOwner(kTRUE);
275 fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
276 }
277 //
9f6e9f81 278 entry = GetCDBEntry("TPC/Calib/GainFactorDedx");
279 if (entry){
280 entry->SetOwner(kTRUE);
281 fDedxGainFactor = (AliTPCCalPad*)entry->GetObject();
282 }
283 //
c5bbaa2c 284 entry = GetCDBEntry("TPC/Calib/PadTime0");
285 if (entry){
68751c2c 286 //if (fPadTime0) delete fPadTime0;
c5bbaa2c 287 entry->SetOwner(kTRUE);
288 fPadTime0 = (AliTPCCalPad*)entry->GetObject();
289 }
290 //
c5bbaa2c 291 //
292 entry = GetCDBEntry("TPC/Calib/PadNoise");
293 if (entry){
68751c2c 294 //if (fPadNoise) delete fPadNoise;
c5bbaa2c 295 entry->SetOwner(kTRUE);
296 fPadNoise = (AliTPCCalPad*)entry->GetObject();
297 }
8477f500 298
299 entry = GetCDBEntry("TPC/Calib/Pedestals");
300 if (entry){
301 //if (fPedestals) delete fPedestals;
302 entry->SetOwner(kTRUE);
303 fPedestals = (AliTPCCalPad*)entry->GetObject();
304 }
305
54472e4f 306 entry = GetCDBEntry("TPC/Calib/Temperature");
307 if (entry){
308 //if (fTemperature) delete fTemperature;
309 entry->SetOwner(kTRUE);
310 fTemperature = (AliTPCSensorTempArray*)entry->GetObject();
311 }
312
8477f500 313 entry = GetCDBEntry("TPC/Calib/Parameters");
314 if (entry){
54472e4f 315 //if (fPadNoise) delete fPadNoise;
8477f500 316 entry->SetOwner(kTRUE);
a778f7e3 317 fParam = (AliTPCParam*)(entry->GetObject()->Clone());
8477f500 318 }
319
96305e49 320 entry = GetCDBEntry("TPC/Calib/ClusterParam");
321 if (entry){
322 //if (fPadNoise) delete fPadNoise;
323 entry->SetOwner(kTRUE);
324 fClusterParam = (AliTPCClusterParam*)(entry->GetObject()->Clone());
325 }
326
d6834f5f 327 entry = GetCDBEntry("TPC/Calib/Mapping");
328 if (entry){
329 //if (fPadNoise) delete fPadNoise;
330 entry->SetOwner(kTRUE);
331 TObjArray * array = dynamic_cast<TObjArray*>(entry->GetObject());
332 if (array && array->GetEntriesFast()==6){
333 fMapping = new AliTPCAltroMapping*[6];
334 for (Int_t i=0; i<6; i++){
335 fMapping[i] = dynamic_cast<AliTPCAltroMapping*>(array->At(i));
336 }
337 }
338 }
339
340
341
3ac615eb 342 //entry = GetCDBEntry("TPC/Calib/ExB");
343 //if (entry) {
344 // entry->SetOwner(kTRUE);
345 // fExB=dynamic_cast<AliTPCExB*>(entry->GetObject()->Clone());
346 //}
347 //
348 // ExB - calculate during initialization
349 // -
f4d5fd21 350 fExB = GetExB(-5,kTRUE);
351 //
f5344549 352 if (!fTransform) {
353 fTransform=new AliTPCTransform();
354 }
8477f500 355
c5bbaa2c 356 //
68751c2c 357 AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
358
c5bbaa2c 359}
e4dce695 360
86df2b3a 361
362
363void AliTPCcalibDB::CreateObjectList(const Char_t *filename, TObjArray *calibObjects)
364{
418bbcaf 365//
366// Create calibration objects and read contents from OCDB
367//
86df2b3a 368 if ( calibObjects == 0x0 ) return;
369 ifstream in;
370 in.open(filename);
371 if ( !in.is_open() ){
372 fprintf(stderr,"Error: cannot open list file '%s'", filename);
373 return;
374 }
375
376 AliTPCCalPad *calPad=0x0;
377
378 TString sFile;
379 sFile.ReadFile(in);
380 in.close();
381
382 TObjArray *arrFileLine = sFile.Tokenize("\n");
383
384 TIter nextLine(arrFileLine);
385
386 TObjString *sObjLine=0x0;
2c632057 387 while ( (sObjLine = (TObjString*)nextLine()) ){
86df2b3a 388 TString sLine(sObjLine->GetString());
389
390 TObjArray *arrNextCol = sLine.Tokenize("\t");
391
392 TObjString *sObjType = (TObjString*)(arrNextCol->At(0));
393 TObjString *sObjFileName = (TObjString*)(arrNextCol->At(1));
394
395 if ( !sObjType || ! sObjFileName ) continue;
396 TString sType(sObjType->GetString());
397 TString sFileName(sObjFileName->GetString());
398 printf("%s\t%s\n",sType.Data(),sFileName.Data());
399
400 TFile *fIn = TFile::Open(sFileName);
401 if ( !fIn ){
402 fprintf(stderr,"File not found: '%s'", sFileName.Data());
403 continue;
404 }
405
406 if ( sType == "CE" ){
407 AliTPCCalibCE *ce = (AliTPCCalibCE*)fIn->Get("AliTPCCalibCE");
408
409 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadT0());
410 calPad->SetNameTitle("CETmean","CETmean");
411 calibObjects->Add(calPad);
412
413 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadQ());
414 calPad->SetNameTitle("CEQmean","CEQmean");
415 calibObjects->Add(calPad);
416
417 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadRMS());
418 calPad->SetNameTitle("CETrms","CETrms");
419 calibObjects->Add(calPad);
420
421 } else if ( sType == "Pulser") {
0fe7645c 422 AliTPCCalibPulser *sig = (AliTPCCalibPulser*)fIn->Get("AliTPCCalibPulser");
86df2b3a 423
424 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadT0());
425 calPad->SetNameTitle("PulserTmean","PulserTmean");
426 calibObjects->Add(calPad);
427
428 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadQ());
429 calPad->SetNameTitle("PulserQmean","PulserQmean");
430 calibObjects->Add(calPad);
431
432 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadRMS());
433 calPad->SetNameTitle("PulserTrms","PulserTrms");
434 calibObjects->Add(calPad);
435
436 } else if ( sType == "Pedestals") {
437 AliTPCCalibPedestal *ped = (AliTPCCalibPedestal*)fIn->Get("AliTPCCalibPedestal");
438
439 calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadPedestal());
440 calPad->SetNameTitle("Pedestals","Pedestals");
441 calibObjects->Add(calPad);
442
443 calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadRMS());
444 calPad->SetNameTitle("Noise","Noise");
445 calibObjects->Add(calPad);
446
447 } else {
448 fprintf(stderr,"Undefined Type: '%s'",sType.Data());
449
450 }
451 delete fIn;
452 }
453}
454
455
456
457void AliTPCcalibDB::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad* outlierPad, Float_t ltmFraction) {
458 //
459 // Write a tree with all available information
418bbcaf 460 // if mapFileName is specified, the Map information are also written to the tree
86df2b3a 461 // pads specified in outlierPad are not used for calculating statistics
462 // - the same function as AliTPCCalPad::MakeTree -
463 //
464 AliTPCROC* tpcROCinstance = AliTPCROC::Instance();
465
466 TObjArray* mapIROCs = 0;
467 TObjArray* mapOROCs = 0;
468 TVectorF *mapIROCArray = 0;
469 TVectorF *mapOROCArray = 0;
470 Int_t mapEntries = 0;
471 TString* mapNames = 0;
472
473 if (mapFileName) {
474 TFile mapFile(mapFileName, "read");
475
476 TList* listOfROCs = mapFile.GetListOfKeys();
477 mapEntries = listOfROCs->GetEntries()/2;
478 mapIROCs = new TObjArray(mapEntries*2);
479 mapOROCs = new TObjArray(mapEntries*2);
480 mapIROCArray = new TVectorF[mapEntries];
481 mapOROCArray = new TVectorF[mapEntries];
482
483 mapNames = new TString[mapEntries];
484 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
418bbcaf 485 TString nameROC(((TKey*)(listOfROCs->At(ivalue*2)))->GetName());
486 nameROC.Remove(nameROC.Length()-4, 4);
487 mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "IROC").Data()), ivalue);
488 mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "OROC").Data()), ivalue);
489 mapNames[ivalue].Append(nameROC);
86df2b3a 490 }
491
492 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
493 mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0));
494 mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36));
495
496 for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++)
497 (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel);
498 for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++)
499 (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel);
500 }
501
502 } // if (mapFileName)
503
504 TTreeSRedirector cstream(fileName);
505 Int_t arrayEntries = array->GetEntries();
506
507 TString* names = new TString[arrayEntries];
508 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
509 names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName());
510
511 for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) {
512 //
513 // get statistic for given sector
514 //
515 TVectorF median(arrayEntries);
516 TVectorF mean(arrayEntries);
517 TVectorF rms(arrayEntries);
518 TVectorF ltm(arrayEntries);
519 TVectorF ltmrms(arrayEntries);
520 TVectorF medianWithOut(arrayEntries);
521 TVectorF meanWithOut(arrayEntries);
522 TVectorF rmsWithOut(arrayEntries);
523 TVectorF ltmWithOut(arrayEntries);
524 TVectorF ltmrmsWithOut(arrayEntries);
525
526 TVectorF *vectorArray = new TVectorF[arrayEntries];
527 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
528 vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
529
530 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
531 AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
532 AliTPCCalROC* calROC = calPad->GetCalROC(isector);
533 AliTPCCalROC* outlierROC = 0;
534 if (outlierPad) outlierROC = outlierPad->GetCalROC(isector);
535 if (calROC) {
536 median[ivalue] = calROC->GetMedian();
537 mean[ivalue] = calROC->GetMean();
538 rms[ivalue] = calROC->GetRMS();
539 Double_t ltmrmsValue = 0;
540 ltm[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction);
541 ltmrms[ivalue] = ltmrmsValue;
542 if (outlierROC) {
543 medianWithOut[ivalue] = calROC->GetMedian(outlierROC);
544 meanWithOut[ivalue] = calROC->GetMean(outlierROC);
545 rmsWithOut[ivalue] = calROC->GetRMS(outlierROC);
546 ltmrmsValue = 0;
547 ltmWithOut[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction, outlierROC);
548 ltmrmsWithOut[ivalue] = ltmrmsValue;
549 }
550 }
551 else {
552 median[ivalue] = 0.;
553 mean[ivalue] = 0.;
554 rms[ivalue] = 0.;
555 ltm[ivalue] = 0.;
556 ltmrms[ivalue] = 0.;
557 medianWithOut[ivalue] = 0.;
558 meanWithOut[ivalue] = 0.;
559 rmsWithOut[ivalue] = 0.;
560 ltmWithOut[ivalue] = 0.;
561 ltmrmsWithOut[ivalue] = 0.;
562 }
563 }
564
565 //
566 // fill vectors of variable per pad
567 //
568 TVectorF *posArray = new TVectorF[8];
569 for (Int_t ivalue = 0; ivalue < 8; ivalue++)
570 posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
571
572 Float_t posG[3] = {0};
573 Float_t posL[3] = {0};
574 Int_t ichannel = 0;
575 for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) {
576 for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) {
577 tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL);
578 tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG);
579 posArray[0][ichannel] = irow;
580 posArray[1][ichannel] = ipad;
581 posArray[2][ichannel] = posL[0];
582 posArray[3][ichannel] = posL[1];
583 posArray[4][ichannel] = posG[0];
584 posArray[5][ichannel] = posG[1];
585 posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2);
586 posArray[7][ichannel] = ichannel;
587
588 // loop over array containing AliTPCCalPads
589 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
590 AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
591 AliTPCCalROC* calROC = calPad->GetCalROC(isector);
592 if (calROC)
593 (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad);
594 else
595 (vectorArray[ivalue])[ichannel] = 0;
596 }
597 ichannel++;
598 }
599 }
600
601 cstream << "calPads" <<
602 "sector=" << isector;
603
604 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
605 cstream << "calPads" <<
606 (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] <<
607 (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] <<
608 (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] <<
609 (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] <<
610 (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue];
611 if (outlierPad) {
612 cstream << "calPads" <<
613 (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] <<
614 (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] <<
615 (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] <<
616 (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] <<
617 (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue];
618 }
619 }
620
621 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
622 cstream << "calPads" <<
623 (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue];
624 }
625
626 if (mapFileName) {
627 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
628 if (isector < 36)
629 cstream << "calPads" <<
630 (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue];
631 else
632 cstream << "calPads" <<
633 (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue];
634 }
635 }
636
637 cstream << "calPads" <<
638 "row.=" << &posArray[0] <<
639 "pad.=" << &posArray[1] <<
640 "lx.=" << &posArray[2] <<
641 "ly.=" << &posArray[3] <<
642 "gx.=" << &posArray[4] <<
643 "gy.=" << &posArray[5] <<
644 "rpad.=" << &posArray[6] <<
645 "channel.=" << &posArray[7];
646
647 cstream << "calPads" <<
648 "\n";
649
650 delete[] posArray;
651 delete[] vectorArray;
652 }
653
654
655 delete[] names;
656 if (mapFileName) {
657 delete mapIROCs;
658 delete mapOROCs;
659 delete[] mapIROCArray;
660 delete[] mapOROCArray;
661 delete[] mapNames;
662 }
663}
3ac615eb 664
665
666
667void AliTPCcalibDB::RegisterExB(Int_t index, Float_t bz, Bool_t bdelete){
668 //
669 // Register static ExB correction map
670 // index - registration index - used for visualization
671 // bz - bz field in kGaus
672
673 Float_t factor = bz/(-5.); // default b filed in Cheb with minus sign
674
675 AliMagF* bmap = new AliMagWrapCheb("Maps","Maps", 2, factor, 10., AliMagWrapCheb::k5kG,kTRUE,"$(ALICE_ROOT)/data/maps/mfchebKGI_sym.root");
676
677 AliTPCExBFirst *exb = new AliTPCExBFirst(bmap,0.88*2.6400e+04,50,50,50);
678 AliTPCExB::SetInstance(exb);
679
680 if (bdelete){
681 delete bmap;
682 }else{
683 AliTPCExB::RegisterField(index,bmap);
684 }
685 if (index>=fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
686 fgExBArray.AddAt(exb,index);
687}
688
689
690AliTPCExB* AliTPCcalibDB::GetExB(Float_t bz, Bool_t deleteB) {
691 //
692 // bz filed in KGaus not in tesla
693 // Get ExB correction map
694 // if doesn't exist - create it
695 //
696 Int_t index = TMath::Nint(5+bz);
697 if (index>fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
698 if (!fgExBArray.At(index)) AliTPCcalibDB::RegisterExB(index,bz,deleteB);
699 return (AliTPCExB*)fgExBArray.At(index);
700}
701
702
703void AliTPCcalibDB::SetExBField(Float_t bz){
704 //
705 // Set magnetic filed for ExB correction
706 //
108953e9 707 printf("Set magnetic field for ExB correction = %f\n",bz);
3ac615eb 708 fExB = GetExB(bz,kFALSE);
709}