Adding high voltage to the tree
[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>
c5bbaa2c 87
88#include "AliTPCcalibDB.h"
d6834f5f 89#include "AliTPCAltroMapping.h"
418bbcaf 90#include "AliTPCExB.h"
c5bbaa2c 91
92#include "AliTPCCalROC.h"
93#include "AliTPCCalPad.h"
54472e4f 94#include "AliTPCSensorTempArray.h"
bf85fe4d 95#include "AliGRPObject.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"
bf85fe4d 114#include "AliTPCTempMap.h"
da6c0bc9 115#include "AliTPCCalibVdrift.h"
86df2b3a 116
117
118
c5bbaa2c 119
120ClassImp(AliTPCcalibDB)
121
122AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0;
123Bool_t AliTPCcalibDB::fgTerminated = kFALSE;
3ac615eb 124TObjArray AliTPCcalibDB::fgExBArray; // array of ExB corrections
c5bbaa2c 125
126
127//_ singleton implementation __________________________________________________
128AliTPCcalibDB* AliTPCcalibDB::Instance()
129{
130 //
131 // Singleton implementation
132 // Returns an instance of this class, it is created if neccessary
133 //
134
135 if (fgTerminated != kFALSE)
136 return 0;
137
138 if (fgInstance == 0)
139 fgInstance = new AliTPCcalibDB();
140
141 return fgInstance;
142}
143
144void AliTPCcalibDB::Terminate()
145{
146 //
147 // Singleton implementation
148 // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
149 // This function can be called several times.
150 //
151
152 fgTerminated = kTRUE;
153
154 if (fgInstance != 0)
155 {
156 delete fgInstance;
157 fgInstance = 0;
158 }
159}
160
161//_____________________________________________________________________________
e4dce695 162AliTPCcalibDB::AliTPCcalibDB():
9389f9a4 163 TObject(),
e4dce695 164 fRun(-1),
f5344549 165 fTransform(0),
481f877b 166 fExB(0),
e4dce695 167 fPadGainFactor(0),
9f6e9f81 168 fDedxGainFactor(0),
e4dce695 169 fPadTime0(0),
e4dce695 170 fPadNoise(0),
171 fPedestals(0),
172 fTemperature(0),
d6834f5f 173 fMapping(0),
96305e49 174 fParam(0),
a2c3785e 175 fClusterParam(0),
176 fTimeGainSplines(0),
177 fTimeGainSplinesArray(100000),
da6c0bc9 178 fGRPArray(100000), //! array of GRPs - per run - JUST for calibration studies
0231c65f 179 fGRPMaps(100000), //! array of GRPs - per run - JUST for calibration studies
da6c0bc9 180 fGoofieArray(100000), //! array of GOOFIE values -per run - Just for calibration studies
e2914767 181 fVoltageArray(100000),
da6c0bc9 182 fTemperatureArray(100000), //! array of temperature sensors - per run - Just for calibration studies
183 fVdriftArray(100000), //! array of v drift interfaces
5e1215d4 184 fDriftCorrectionArray(100000), //! array of drift correction
bf85fe4d 185 fRunList(100000) //! run list - indicates try to get the run param
186
c5bbaa2c 187{
188 //
189 // constructor
190 //
54472e4f 191 //
c5bbaa2c 192 Update(); // temporary
193}
194
9389f9a4 195AliTPCcalibDB::AliTPCcalibDB(const AliTPCcalibDB& ):
196 TObject(),
197 fRun(-1),
198 fTransform(0),
199 fExB(0),
200 fPadGainFactor(0),
9f6e9f81 201 fDedxGainFactor(0),
9389f9a4 202 fPadTime0(0),
203 fPadNoise(0),
204 fPedestals(0),
205 fTemperature(0),
206 fMapping(0),
9389f9a4 207 fParam(0),
bf85fe4d 208 fClusterParam(0),
a2c3785e 209 fTimeGainSplines(0),
210 fTimeGainSplinesArray(100000),
bf85fe4d 211 fGRPArray(0), //! array of GRPs - per run - JUST for calibration studies
0231c65f 212 fGRPMaps(0), //! array of GRPs - per run - JUST for calibration studies
bf85fe4d 213 fGoofieArray(0), //! array of GOOFIE values -per run - Just for calibration studies
e2914767 214 fVoltageArray(0),
bf85fe4d 215 fTemperatureArray(0), //! array of temperature sensors - per run - Just for calibration studies
da6c0bc9 216 fVdriftArray(0), //! array of v drift interfaces
5e1215d4 217 fDriftCorrectionArray(0), //! array of v drift interfaces
bf85fe4d 218 fRunList(0) //! run list - indicates try to get the run param
9389f9a4 219{
220 //
221 // Copy constructor invalid -- singleton implementation
222 //
223 Error("copy constructor","invalid -- singleton implementation");
224}
225
226AliTPCcalibDB& AliTPCcalibDB::operator= (const AliTPCcalibDB& )
227{
228//
229// Singleton implementation - no assignment operator
230//
231 Error("operator =", "assignment operator not implemented");
232 return *this;
233}
234
235
236
c5bbaa2c 237//_____________________________________________________________________________
238AliTPCcalibDB::~AliTPCcalibDB()
239{
240 //
241 // destructor
242 //
68751c2c 243
244 // don't delete anything, CDB cache is active!
245 //if (fPadGainFactor) delete fPadGainFactor;
246 //if (fPadTime0) delete fPadTime0;
68751c2c 247 //if (fPadNoise) delete fPadNoise;
c5bbaa2c 248}
249
250
251//_____________________________________________________________________________
252AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
253{
254 //
255 // Retrieves an entry with path <cdbPath> from the CDB.
256 //
257 char chinfo[1000];
258
68751c2c 259 AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
c5bbaa2c 260 if (!entry)
261 {
262 sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
263 AliError(chinfo);
264 return 0;
265 }
266 return entry;
267}
268
269
270//_____________________________________________________________________________
271void AliTPCcalibDB::SetRun(Long64_t run)
272{
273 //
274 // Sets current run number. Calibration data is read from the corresponding file.
275 //
276 if (fRun == run)
277 return;
a2c3785e 278 fRun = run;
c5bbaa2c 279 Update();
280}
281
282
283
284void AliTPCcalibDB::Update(){
a2c3785e 285 //
286 AliCDBEntry * entry=0;
68751c2c 287
288 Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
289 AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
290
c5bbaa2c 291 //
292 entry = GetCDBEntry("TPC/Calib/PadGainFactor");
293 if (entry){
68751c2c 294 //if (fPadGainFactor) delete fPadGainFactor;
c5bbaa2c 295 entry->SetOwner(kTRUE);
296 fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
297 }
298 //
3af3fbc4 299 entry = GetCDBEntry("TPC/Calib/TimeGain");
300 if (entry){
301 //if (fTimeGainSplines) delete fTimeGainSplines;
302 entry->SetOwner(kTRUE);
303 fTimeGainSplines = (TObjArray*)entry->GetObject();
304 }
305 //
9f6e9f81 306 entry = GetCDBEntry("TPC/Calib/GainFactorDedx");
307 if (entry){
308 entry->SetOwner(kTRUE);
309 fDedxGainFactor = (AliTPCCalPad*)entry->GetObject();
310 }
311 //
c5bbaa2c 312 entry = GetCDBEntry("TPC/Calib/PadTime0");
313 if (entry){
68751c2c 314 //if (fPadTime0) delete fPadTime0;
c5bbaa2c 315 entry->SetOwner(kTRUE);
316 fPadTime0 = (AliTPCCalPad*)entry->GetObject();
317 }
318 //
c5bbaa2c 319 //
320 entry = GetCDBEntry("TPC/Calib/PadNoise");
321 if (entry){
68751c2c 322 //if (fPadNoise) delete fPadNoise;
c5bbaa2c 323 entry->SetOwner(kTRUE);
324 fPadNoise = (AliTPCCalPad*)entry->GetObject();
325 }
8477f500 326
327 entry = GetCDBEntry("TPC/Calib/Pedestals");
328 if (entry){
329 //if (fPedestals) delete fPedestals;
330 entry->SetOwner(kTRUE);
331 fPedestals = (AliTPCCalPad*)entry->GetObject();
332 }
333
54472e4f 334 entry = GetCDBEntry("TPC/Calib/Temperature");
335 if (entry){
336 //if (fTemperature) delete fTemperature;
337 entry->SetOwner(kTRUE);
338 fTemperature = (AliTPCSensorTempArray*)entry->GetObject();
339 }
340
8477f500 341 entry = GetCDBEntry("TPC/Calib/Parameters");
342 if (entry){
54472e4f 343 //if (fPadNoise) delete fPadNoise;
8477f500 344 entry->SetOwner(kTRUE);
a778f7e3 345 fParam = (AliTPCParam*)(entry->GetObject()->Clone());
8477f500 346 }
347
96305e49 348 entry = GetCDBEntry("TPC/Calib/ClusterParam");
349 if (entry){
350 //if (fPadNoise) delete fPadNoise;
351 entry->SetOwner(kTRUE);
352 fClusterParam = (AliTPCClusterParam*)(entry->GetObject()->Clone());
353 }
354
d6834f5f 355 entry = GetCDBEntry("TPC/Calib/Mapping");
356 if (entry){
357 //if (fPadNoise) delete fPadNoise;
358 entry->SetOwner(kTRUE);
359 TObjArray * array = dynamic_cast<TObjArray*>(entry->GetObject());
360 if (array && array->GetEntriesFast()==6){
361 fMapping = new AliTPCAltroMapping*[6];
362 for (Int_t i=0; i<6; i++){
363 fMapping[i] = dynamic_cast<AliTPCAltroMapping*>(array->At(i));
364 }
365 }
366 }
367
368
369
3ac615eb 370 //entry = GetCDBEntry("TPC/Calib/ExB");
371 //if (entry) {
372 // entry->SetOwner(kTRUE);
373 // fExB=dynamic_cast<AliTPCExB*>(entry->GetObject()->Clone());
374 //}
375 //
376 // ExB - calculate during initialization
377 // -
f4d5fd21 378 fExB = GetExB(-5,kTRUE);
379 //
f5344549 380 if (!fTransform) {
381 fTransform=new AliTPCTransform();
bfec3eeb 382 fTransform->SetCurrentRun(AliCDBManager::Instance()->GetRun());
f5344549 383 }
8477f500 384
c5bbaa2c 385 //
68751c2c 386 AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
387
c5bbaa2c 388}
e4dce695 389
86df2b3a 390
391
392void AliTPCcalibDB::CreateObjectList(const Char_t *filename, TObjArray *calibObjects)
393{
418bbcaf 394//
395// Create calibration objects and read contents from OCDB
396//
86df2b3a 397 if ( calibObjects == 0x0 ) return;
398 ifstream in;
399 in.open(filename);
400 if ( !in.is_open() ){
401 fprintf(stderr,"Error: cannot open list file '%s'", filename);
402 return;
403 }
404
405 AliTPCCalPad *calPad=0x0;
406
407 TString sFile;
408 sFile.ReadFile(in);
409 in.close();
410
411 TObjArray *arrFileLine = sFile.Tokenize("\n");
412
413 TIter nextLine(arrFileLine);
414
415 TObjString *sObjLine=0x0;
2c632057 416 while ( (sObjLine = (TObjString*)nextLine()) ){
86df2b3a 417 TString sLine(sObjLine->GetString());
418
419 TObjArray *arrNextCol = sLine.Tokenize("\t");
420
421 TObjString *sObjType = (TObjString*)(arrNextCol->At(0));
422 TObjString *sObjFileName = (TObjString*)(arrNextCol->At(1));
423
424 if ( !sObjType || ! sObjFileName ) continue;
425 TString sType(sObjType->GetString());
426 TString sFileName(sObjFileName->GetString());
427 printf("%s\t%s\n",sType.Data(),sFileName.Data());
428
429 TFile *fIn = TFile::Open(sFileName);
430 if ( !fIn ){
431 fprintf(stderr,"File not found: '%s'", sFileName.Data());
432 continue;
433 }
434
435 if ( sType == "CE" ){
436 AliTPCCalibCE *ce = (AliTPCCalibCE*)fIn->Get("AliTPCCalibCE");
437
438 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadT0());
439 calPad->SetNameTitle("CETmean","CETmean");
440 calibObjects->Add(calPad);
441
442 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadQ());
443 calPad->SetNameTitle("CEQmean","CEQmean");
444 calibObjects->Add(calPad);
445
446 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadRMS());
447 calPad->SetNameTitle("CETrms","CETrms");
448 calibObjects->Add(calPad);
449
450 } else if ( sType == "Pulser") {
0fe7645c 451 AliTPCCalibPulser *sig = (AliTPCCalibPulser*)fIn->Get("AliTPCCalibPulser");
86df2b3a 452
453 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadT0());
454 calPad->SetNameTitle("PulserTmean","PulserTmean");
455 calibObjects->Add(calPad);
456
457 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadQ());
458 calPad->SetNameTitle("PulserQmean","PulserQmean");
459 calibObjects->Add(calPad);
460
461 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadRMS());
462 calPad->SetNameTitle("PulserTrms","PulserTrms");
463 calibObjects->Add(calPad);
464
465 } else if ( sType == "Pedestals") {
466 AliTPCCalibPedestal *ped = (AliTPCCalibPedestal*)fIn->Get("AliTPCCalibPedestal");
467
468 calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadPedestal());
469 calPad->SetNameTitle("Pedestals","Pedestals");
470 calibObjects->Add(calPad);
471
472 calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadRMS());
473 calPad->SetNameTitle("Noise","Noise");
474 calibObjects->Add(calPad);
475
476 } else {
477 fprintf(stderr,"Undefined Type: '%s'",sType.Data());
478
479 }
480 delete fIn;
481 }
482}
483
484
485
486void AliTPCcalibDB::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad* outlierPad, Float_t ltmFraction) {
487 //
488 // Write a tree with all available information
418bbcaf 489 // if mapFileName is specified, the Map information are also written to the tree
86df2b3a 490 // pads specified in outlierPad are not used for calculating statistics
491 // - the same function as AliTPCCalPad::MakeTree -
492 //
493 AliTPCROC* tpcROCinstance = AliTPCROC::Instance();
494
495 TObjArray* mapIROCs = 0;
496 TObjArray* mapOROCs = 0;
497 TVectorF *mapIROCArray = 0;
498 TVectorF *mapOROCArray = 0;
499 Int_t mapEntries = 0;
500 TString* mapNames = 0;
501
502 if (mapFileName) {
503 TFile mapFile(mapFileName, "read");
504
505 TList* listOfROCs = mapFile.GetListOfKeys();
506 mapEntries = listOfROCs->GetEntries()/2;
507 mapIROCs = new TObjArray(mapEntries*2);
508 mapOROCs = new TObjArray(mapEntries*2);
509 mapIROCArray = new TVectorF[mapEntries];
510 mapOROCArray = new TVectorF[mapEntries];
511
512 mapNames = new TString[mapEntries];
513 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
418bbcaf 514 TString nameROC(((TKey*)(listOfROCs->At(ivalue*2)))->GetName());
515 nameROC.Remove(nameROC.Length()-4, 4);
516 mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "IROC").Data()), ivalue);
517 mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "OROC").Data()), ivalue);
518 mapNames[ivalue].Append(nameROC);
86df2b3a 519 }
520
521 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
522 mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0));
523 mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36));
524
525 for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++)
526 (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel);
527 for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++)
528 (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel);
529 }
530
531 } // if (mapFileName)
532
533 TTreeSRedirector cstream(fileName);
534 Int_t arrayEntries = array->GetEntries();
535
536 TString* names = new TString[arrayEntries];
537 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
538 names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName());
539
540 for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) {
541 //
542 // get statistic for given sector
543 //
544 TVectorF median(arrayEntries);
545 TVectorF mean(arrayEntries);
546 TVectorF rms(arrayEntries);
547 TVectorF ltm(arrayEntries);
548 TVectorF ltmrms(arrayEntries);
549 TVectorF medianWithOut(arrayEntries);
550 TVectorF meanWithOut(arrayEntries);
551 TVectorF rmsWithOut(arrayEntries);
552 TVectorF ltmWithOut(arrayEntries);
553 TVectorF ltmrmsWithOut(arrayEntries);
554
555 TVectorF *vectorArray = new TVectorF[arrayEntries];
556 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
557 vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
558
559 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
560 AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
561 AliTPCCalROC* calROC = calPad->GetCalROC(isector);
562 AliTPCCalROC* outlierROC = 0;
563 if (outlierPad) outlierROC = outlierPad->GetCalROC(isector);
564 if (calROC) {
565 median[ivalue] = calROC->GetMedian();
566 mean[ivalue] = calROC->GetMean();
567 rms[ivalue] = calROC->GetRMS();
568 Double_t ltmrmsValue = 0;
569 ltm[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction);
570 ltmrms[ivalue] = ltmrmsValue;
571 if (outlierROC) {
572 medianWithOut[ivalue] = calROC->GetMedian(outlierROC);
573 meanWithOut[ivalue] = calROC->GetMean(outlierROC);
574 rmsWithOut[ivalue] = calROC->GetRMS(outlierROC);
575 ltmrmsValue = 0;
576 ltmWithOut[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction, outlierROC);
577 ltmrmsWithOut[ivalue] = ltmrmsValue;
578 }
579 }
580 else {
581 median[ivalue] = 0.;
582 mean[ivalue] = 0.;
583 rms[ivalue] = 0.;
584 ltm[ivalue] = 0.;
585 ltmrms[ivalue] = 0.;
586 medianWithOut[ivalue] = 0.;
587 meanWithOut[ivalue] = 0.;
588 rmsWithOut[ivalue] = 0.;
589 ltmWithOut[ivalue] = 0.;
590 ltmrmsWithOut[ivalue] = 0.;
591 }
592 }
593
594 //
595 // fill vectors of variable per pad
596 //
597 TVectorF *posArray = new TVectorF[8];
598 for (Int_t ivalue = 0; ivalue < 8; ivalue++)
599 posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
600
601 Float_t posG[3] = {0};
602 Float_t posL[3] = {0};
603 Int_t ichannel = 0;
604 for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) {
605 for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) {
606 tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL);
607 tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG);
608 posArray[0][ichannel] = irow;
609 posArray[1][ichannel] = ipad;
610 posArray[2][ichannel] = posL[0];
611 posArray[3][ichannel] = posL[1];
612 posArray[4][ichannel] = posG[0];
613 posArray[5][ichannel] = posG[1];
614 posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2);
615 posArray[7][ichannel] = ichannel;
616
617 // loop over array containing AliTPCCalPads
618 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
619 AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
620 AliTPCCalROC* calROC = calPad->GetCalROC(isector);
621 if (calROC)
622 (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad);
623 else
624 (vectorArray[ivalue])[ichannel] = 0;
625 }
626 ichannel++;
627 }
628 }
629
630 cstream << "calPads" <<
631 "sector=" << isector;
632
633 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
634 cstream << "calPads" <<
635 (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] <<
636 (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] <<
637 (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] <<
638 (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] <<
639 (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue];
640 if (outlierPad) {
641 cstream << "calPads" <<
642 (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] <<
643 (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] <<
644 (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] <<
645 (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] <<
646 (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue];
647 }
648 }
649
650 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
651 cstream << "calPads" <<
652 (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue];
653 }
654
655 if (mapFileName) {
656 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
657 if (isector < 36)
658 cstream << "calPads" <<
659 (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue];
660 else
661 cstream << "calPads" <<
662 (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue];
663 }
664 }
665
666 cstream << "calPads" <<
667 "row.=" << &posArray[0] <<
668 "pad.=" << &posArray[1] <<
669 "lx.=" << &posArray[2] <<
670 "ly.=" << &posArray[3] <<
671 "gx.=" << &posArray[4] <<
672 "gy.=" << &posArray[5] <<
673 "rpad.=" << &posArray[6] <<
674 "channel.=" << &posArray[7];
675
676 cstream << "calPads" <<
677 "\n";
678
679 delete[] posArray;
680 delete[] vectorArray;
681 }
682
683
684 delete[] names;
685 if (mapFileName) {
686 delete mapIROCs;
687 delete mapOROCs;
688 delete[] mapIROCArray;
689 delete[] mapOROCArray;
690 delete[] mapNames;
691 }
692}
3ac615eb 693
694
695
696void AliTPCcalibDB::RegisterExB(Int_t index, Float_t bz, Bool_t bdelete){
697 //
698 // Register static ExB correction map
699 // index - registration index - used for visualization
700 // bz - bz field in kGaus
701
702 Float_t factor = bz/(-5.); // default b filed in Cheb with minus sign
703
f7a1cc68 704 AliMagF* bmap = new AliMagF("MapsExB","MapsExB", 2,factor,1., 10.,AliMagF::k5kG,"$(ALICE_ROOT)/data/maps/mfchebKGI_sym.root");
3ac615eb 705
706 AliTPCExBFirst *exb = new AliTPCExBFirst(bmap,0.88*2.6400e+04,50,50,50);
707 AliTPCExB::SetInstance(exb);
708
709 if (bdelete){
710 delete bmap;
711 }else{
712 AliTPCExB::RegisterField(index,bmap);
713 }
714 if (index>=fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
715 fgExBArray.AddAt(exb,index);
716}
717
718
719AliTPCExB* AliTPCcalibDB::GetExB(Float_t bz, Bool_t deleteB) {
720 //
721 // bz filed in KGaus not in tesla
722 // Get ExB correction map
723 // if doesn't exist - create it
724 //
725 Int_t index = TMath::Nint(5+bz);
726 if (index>fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
727 if (!fgExBArray.At(index)) AliTPCcalibDB::RegisterExB(index,bz,deleteB);
728 return (AliTPCExB*)fgExBArray.At(index);
729}
730
731
732void AliTPCcalibDB::SetExBField(Float_t bz){
733 //
734 // Set magnetic filed for ExB correction
735 //
736 fExB = GetExB(bz,kFALSE);
737}
bf85fe4d 738
739
740
5e1215d4 741
742
743void AliTPCcalibDB::UpdateRunInformations( Int_t run, Bool_t force){
bf85fe4d 744 //
745 // - > Don't use it for reconstruction - Only for Calibration studies
746 //
747 AliCDBEntry * entry = 0;
748 if (run>= fRunList.GetSize()){
749 fRunList.Set(run*2+1);
da6c0bc9 750 fGRPArray.Expand(run*2+1);
0231c65f 751 fGRPMaps.Expand(run*2+1);
e2914767 752 fGoofieArray.Expand(run*2+1);
753 fVoltageArray.Expand(run*2+1);
da6c0bc9 754 fTemperatureArray.Expand(run*2+1);
755 fVdriftArray.Expand(run*2+1);
5e1215d4 756 fDriftCorrectionArray.Expand(run*2+1);
a2c3785e 757 fTimeGainSplinesArray.Expand(run*2+1);
bf85fe4d 758 }
5e1215d4 759 if (fRunList[run]>0 &&force==kFALSE) return;
760 //
bf85fe4d 761 entry = AliCDBManager::Instance()->Get("GRP/GRP/Data",run);
0231c65f 762 if (entry) {
763 AliGRPObject * grpRun = dynamic_cast<AliGRPObject*>(entry->GetObject());
764 if (!grpRun){
765 TMap* map = dynamic_cast<TMap*>(entry->GetObject());
766 if (map){
e2914767 767 //grpRun = new AliGRPObject;
768 //grpRun->ReadValuesFromMap(map);
769 grpRun = MakeGRPObjectFromMap(map);
770
0231c65f 771 fGRPMaps.AddAt(map,run);
772 }
773 }
774 fGRPArray.AddAt(grpRun,run);
775 }
bf85fe4d 776 entry = AliCDBManager::Instance()->Get("TPC/Calib/Goofie",run);
5e1215d4 777 if (entry){
778 fGoofieArray.AddAt(entry->GetObject(),run);
779 }
e2914767 780 //
781 entry = AliCDBManager::Instance()->Get("TPC/Calib/HighVoltage",run);
5e1215d4 782 if (entry) {
783 fVoltageArray.AddAt(entry->GetObject(),run);
784 }
e2914767 785 //
a2c3785e 786 entry = AliCDBManager::Instance()->Get("TPC/Calib/TimeGain",run);
5e1215d4 787 if (entry) {
788 fTimeGainSplinesArray.AddAt(entry->GetObject(),run);
789 }
790 //
791 entry = AliCDBManager::Instance()->Get("TPC/Calib/TimeDrift",run);
792 if (entry) {
793 fDriftCorrectionArray.AddAt(entry->GetObject(),run);
794 }
a2c3785e 795 //
bf85fe4d 796 entry = AliCDBManager::Instance()->Get("TPC/Calib/Temperature",run);
5e1215d4 797 if (entry) {
798 fTemperatureArray.AddAt(entry->GetObject(),run);
799 }
bf85fe4d 800 fRunList[run]=1; // sign as used
da6c0bc9 801
bfec3eeb 802 AliDCSSensor * press = GetPressureSensor(run,0);
da6c0bc9 803 AliTPCSensorTempArray * temp = GetTemperatureSensor(run);
804 if (press && temp){
805 AliTPCCalibVdrift * vdrift = new AliTPCCalibVdrift(temp, press,0);
806 fVdriftArray.AddAt(vdrift,run);
807 }
bf85fe4d 808}
809
810
811Float_t AliTPCcalibDB::GetGain(Int_t sector, Int_t row, Int_t pad){
812 //
813 //
814 AliTPCCalPad *calPad = Instance()->fDedxGainFactor;;
815 if (!calPad) return 0;
816 return calPad->GetCalROC(sector)->GetValue(row,pad);
817}
818
8de77f00 819
820AliGRPObject *AliTPCcalibDB::GetGRP(Int_t run){
821 //
822 // Get GRP object for given run
823 //
824 AliGRPObject * grpRun = dynamic_cast<AliGRPObject *>((Instance()->fGRPArray).At(run));
825 if (!grpRun) {
5e1215d4 826 Instance()->UpdateRunInformations(run);
8de77f00 827 grpRun = dynamic_cast<AliGRPObject *>(Instance()->fGRPArray.At(run));
828 if (!grpRun) return 0;
829 }
830 return grpRun;
831}
832
0231c65f 833TMap * AliTPCcalibDB::GetGRPMap(Int_t run){
834 //
835 //
836 //
837 TMap * grpRun = dynamic_cast<TMap *>((Instance()->fGRPMaps).At(run));
838 if (!grpRun) {
5e1215d4 839 Instance()->UpdateRunInformations(run);
0231c65f 840 grpRun = dynamic_cast<TMap *>(Instance()->fGRPMaps.At(run));
841 if (!grpRun) return 0;
842 }
843 return grpRun;
844}
8de77f00 845
846
da6c0bc9 847AliDCSSensor * AliTPCcalibDB::GetPressureSensor(Int_t run, Int_t type){
bf85fe4d 848 //
0231c65f 849 // Get Pressure sensor
bfec3eeb 850 // run = run number
851 // type = 0 - Cavern pressure
852 // 1 - Suface pressure
0231c65f 853 // First try to get if trom map - if existing (Old format of data storing)
bf85fe4d 854 //
bfec3eeb 855
856
0231c65f 857 TMap *map = GetGRPMap(run);
858 if (map){
859 AliDCSSensor * sensor = 0;
860 TObject *osensor=0;
861 if (type==0) osensor = ((*map)("fCavernPressure"));
862 if (type==1) osensor = ((*map)("fP2Pressure"));
863 sensor =dynamic_cast<AliDCSSensor *>(osensor);
864 if (sensor) return sensor;
865 }
866 //
867 // If not map try to get it from the GRPObject
868 //
869 AliGRPObject * grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.At(run));
bf85fe4d 870 if (!grpRun) {
5e1215d4 871 UpdateRunInformations(run);
efdbb95a 872 grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.At(run));
bf85fe4d 873 if (!grpRun) return 0;
874 }
875 AliDCSSensor * sensor = grpRun->GetCavernAtmosPressure();
da6c0bc9 876 if (type==1) sensor = grpRun->GetSurfaceAtmosPressure();
877 return sensor;
bf85fe4d 878}
879
880AliTPCSensorTempArray * AliTPCcalibDB::GetTemperatureSensor(Int_t run){
881 //
882 // Get temperature sensor array
883 //
884 AliTPCSensorTempArray * tempArray = (AliTPCSensorTempArray *)fTemperatureArray.At(run);
885 if (!tempArray) {
5e1215d4 886 UpdateRunInformations(run);
bf85fe4d 887 tempArray = (AliTPCSensorTempArray *)fTemperatureArray.At(run);
888 }
889 return tempArray;
890}
891
a2c3785e 892
893TObjArray * AliTPCcalibDB::GetTimeGainSplinesRun(Int_t run){
bf85fe4d 894 //
895 // Get temperature sensor array
896 //
a2c3785e 897 TObjArray * gainSplines = (TObjArray *)fTimeGainSplinesArray.At(run);
898 if (!gainSplines) {
5e1215d4 899 UpdateRunInformations(run);
a2c3785e 900 gainSplines = (TObjArray *)fTimeGainSplinesArray.At(run);
bf85fe4d 901 }
a2c3785e 902 return gainSplines;
bf85fe4d 903}
904
e2914767 905AliDCSSensorArray * AliTPCcalibDB::GetVoltageSensors(Int_t run){
906 //
907 // Get temperature sensor array
908 //
909 AliDCSSensorArray * voltageArray = (AliDCSSensorArray *)fVoltageArray.At(run);
910 if (!voltageArray) {
5e1215d4 911 UpdateRunInformations(run);
e2914767 912 voltageArray = (AliDCSSensorArray *)fVoltageArray.At(run);
913 }
914 return voltageArray;
915}
916
99895a4f 917AliDCSSensorArray * AliTPCcalibDB::GetGoofieSensors(Int_t run){
918 //
919 // Get temperature sensor array
920 //
921 AliDCSSensorArray * goofieArray = (AliDCSSensorArray *)fGoofieArray.At(run);
922 if (!goofieArray) {
5e1215d4 923 UpdateRunInformations(run);
99895a4f 924 goofieArray = (AliDCSSensorArray *)fGoofieArray.At(run);
925 }
926 return goofieArray;
927}
928
929
930
da6c0bc9 931AliTPCCalibVdrift * AliTPCcalibDB::GetVdrift(Int_t run){
932 //
933 // Get the interface to the the vdrift
934 //
935 AliTPCCalibVdrift * vdrift = (AliTPCCalibVdrift*)fVdriftArray.At(run);
936 if (!vdrift) {
5e1215d4 937 UpdateRunInformations(run);
da6c0bc9 938 vdrift= (AliTPCCalibVdrift*)fVdriftArray.At(run);
939 }
940 return vdrift;
941}
942
bf85fe4d 943
e2914767 944Float_t AliTPCcalibDB::GetChamberHighVoltage(Int_t timeStamp, Int_t run, Int_t sector) {
945 //
946 // return the chamber HV for given run and time: 0-35 IROC, 36-72 OROC
947 //
948 TTimeStamp stamp(timeStamp);
949 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
950 if (!voltageArray) return 0;
951 AliDCSSensor *sensor = voltageArray->GetSensor((sector+1)*3);
952 if (!sensor) return 0;
953 return sensor->GetValue(stamp);
954}
bf85fe4d 955
da6c0bc9 956Float_t AliTPCcalibDB::GetPressure(Int_t timeStamp, Int_t run, Int_t type){
bf85fe4d 957 //
958 // GetPressure for given time stamp and runt
959 //
960 TTimeStamp stamp(timeStamp);
da6c0bc9 961 AliDCSSensor * sensor = Instance()->GetPressureSensor(run,type);
bf85fe4d 962 if (!sensor) return 0;
bf85fe4d 963 return sensor->GetValue(stamp);
964}
965
7f7847fe 966Float_t AliTPCcalibDB::GetValueGoofie(Int_t timeStamp, Int_t run, Int_t type){
967 //
968 // GetPressure for given time stamp and runt
969 //
970 TTimeStamp stamp(timeStamp);
971 AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(run);
972 if (!goofieArray) return 0;
973 AliDCSSensor *sensor = goofieArray->GetSensor(type);
974 return sensor->GetValue(stamp);
975}
976
977
978
979
980
981
f0269955 982Bool_t AliTPCcalibDB::GetTemperatureFit(Int_t timeStamp, Int_t run, Int_t side,TVectorD& fit){
983 //
984 //
985 //
986 TTimeStamp tstamp(timeStamp);
64b48395 987 AliTPCSensorTempArray* tempArray = Instance()->GetTemperatureSensor(run);
f0269955 988 if (! tempArray) return kFALSE;
989 AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray);
990 TLinearFitter * fitter = tempMap->GetLinearFitter(3,side,tstamp);
991 if (fitter){
992 fitter->Eval();
993 fitter->GetParameters(fit);
994 }
995 delete fitter;
996 delete tempMap;
997 if (!fitter) return kFALSE;
998 return kTRUE;
999}
1000
64b48395 1001Float_t AliTPCcalibDB::GetTemperature(Int_t timeStamp, Int_t run, Int_t side){
1002 //
1003 //
1004 //
12e42756 1005 TVectorD vec(5);
64b48395 1006 if (side==0) {
1007 GetTemperatureFit(timeStamp,run,0,vec);
1008 return vec[0];
1009 }
1010 if (side==1){
1011 GetTemperatureFit(timeStamp,run,0,vec);
1012 return vec[0];
1013 }
57dc06f2 1014 return 0;
64b48395 1015}
bf85fe4d 1016
1017
da6c0bc9 1018Double_t AliTPCcalibDB::GetPTRelative(UInt_t timeSec, Int_t run, Int_t side){
1019 //
1020 // Get relative P/T
1021 // time - absolute time
1022 // run - run number
1023 // side - 0 - A side 1-C side
1024 AliTPCCalibVdrift * vdrift = Instance()->GetVdrift(run);
1025 if (!vdrift) return 0;
1026 return vdrift->GetPTRelative(timeSec,side);
1027}
1028
bf85fe4d 1029
1030void AliTPCcalibDB::ProcessEnv(const char * runList){
1031 //
1032 // Example test function - how to use the environment variables
1033 // runList - ascii file with run numbers
1034 // output - dcsTime.root file with tree
1035
1036 ifstream in;
1037 in.open(runList);
1038 Int_t irun=0;
1039 TTreeSRedirector *pcstream = new TTreeSRedirector("dcsTime.root");
1040 while(in.good()) {
1041 in >> irun;
1042 if (irun==0) continue;
1043 printf("Processing run %d\n",irun);
1044 AliDCSSensor * sensorPressure = AliTPCcalibDB::Instance()->GetPressureSensor(irun);
1045 if (!sensorPressure) continue;
1046 AliTPCSensorTempArray * tempArray = AliTPCcalibDB::Instance()->GetTemperatureSensor(irun);
1047 AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray);
1048 AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(irun);
1049 //
1050 Int_t startTime = sensorPressure->GetStartTime();
1051 Int_t endTime = sensorPressure->GetEndTime();
1052 Int_t dtime = TMath::Max((endTime-startTime)/20,10*60);
1053 for (Int_t itime=startTime; itime<endTime; itime+=dtime){
1054 //
1055 TTimeStamp tstamp(itime);
1056 Float_t valuePressure = sensorPressure->GetValue(tstamp);
1057
1058 TLinearFitter * fitter = 0;
1059 TVectorD vecTemp[10];
1060 if (itime<tempArray->GetStartTime().GetSec() || itime>tempArray->GetEndTime().GetSec()){
1061 }else{
1062 for (Int_t itype=0; itype<5; itype++)
1063 for (Int_t iside=0; iside<2; iside++){
1064 fitter= tempMap->GetLinearFitter(itype,iside,tstamp);
1065 if (!fitter) continue;
1066 fitter->Eval(); fitter->GetParameters(vecTemp[itype+iside*5]);
1067 delete fitter;
1068 }
1069 }
1070
1071 TVectorD vecGoofie, vecEntries, vecMean, vecMedian,vecRMS;
1072 if (goofieArray){
1073 vecGoofie.ResizeTo(goofieArray->NumSensors());
1074 ProcessGoofie(goofieArray, vecEntries ,vecMedian, vecMean, vecRMS);
1075 //
1076 for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){
1077 AliDCSSensor *gsensor = goofieArray->GetSensor(isensor);
1078 if (gsensor){
1079 vecGoofie[isensor] = gsensor->GetValue(tstamp);
1080 }
1081 }
1082 }
1083
1084
1085 //tempMap->GetLinearFitter(0,0,itime);
1086 (*pcstream)<<"dcs"<<
1087 "run="<<irun<<
1088 "time="<<itime<<
1089 "goofie.="<<&vecGoofie<<
1090 "goofieE.="<<&vecEntries<<
1091 "goofieMean.="<<&vecMean<<
1092 "goofieMedian.="<<&vecMedian<<
1093 "goofieRMS.="<<&vecRMS<<
1094 "press="<<valuePressure<<
1095 "temp00.="<<&vecTemp[0]<<
1096 "temp10.="<<&vecTemp[1]<<
1097 "temp20.="<<&vecTemp[2]<<
1098 "temp30.="<<&vecTemp[3]<<
1099 "temp40.="<<&vecTemp[4]<<
1100 "temp01.="<<&vecTemp[5]<<
1101 "temp11.="<<&vecTemp[6]<<
1102 "temp21.="<<&vecTemp[7]<<
1103 "temp31.="<<&vecTemp[8]<<
1104 "temp41.="<<&vecTemp[9]<<
1105 "\n";
1106 }
1107 }
1108 delete pcstream;
1109}
1110
1111
1112void AliTPCcalibDB::ProcessGoofie( AliDCSSensorArray* goofieArray, TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS){
1113 /*
1114
1115 1 TPC_ANODE_I_A00_STAT
1116 2 TPC_DVM_CO2
1117 3 TPC_DVM_DriftVelocity
1118 4 TPC_DVM_FCageHV
1119 5 TPC_DVM_GainFar
1120 6 TPC_DVM_GainNear
1121 7 TPC_DVM_N2
1122 8 TPC_DVM_NumberOfSparks
1123 9 TPC_DVM_PeakAreaFar
1124 10 TPC_DVM_PeakAreaNear
1125 11 TPC_DVM_PeakPosFar
1126 12 TPC_DVM_PeakPosNear
1127 13 TPC_DVM_PickupHV
1128 14 TPC_DVM_Pressure
1129 15 TPC_DVM_T1_Over_P
1130 16 TPC_DVM_T2_Over_P
1131 17 TPC_DVM_T_Over_P
1132 18 TPC_DVM_TemperatureS1
1133 */
1134 //
1135 //
1136 // TVectorD vecMedian; TVectorD vecEntries; TVectorD vecMean; TVectorD vecRMS;
1137 Double_t kEpsilon=0.0000000001;
1138 Double_t kBig=100000000000.;
1139 Int_t nsensors = goofieArray->NumSensors();
1140 vecEntries.ResizeTo(nsensors);
1141 vecMedian.ResizeTo(nsensors);
1142 vecMean.ResizeTo(nsensors);
1143 vecRMS.ResizeTo(nsensors);
1144 TVectorF values;
1145 for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){
1146 AliDCSSensor *gsensor = goofieArray->GetSensor(isensor);
1147 if (gsensor && gsensor->GetGraph()){
1148 Int_t npoints = gsensor->GetGraph()->GetN();
1149 // filter zeroes
1150 values.ResizeTo(npoints);
1151 Int_t nused =0;
1152 for (Int_t ipoint=0; ipoint<npoints; ipoint++){
1153 if (TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])>kEpsilon &&
1154 TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])<kBig ){
1155 values[nused]=gsensor->GetGraph()->GetY()[ipoint];
1156 nused++;
1157 }
1158 }
1159 //
1160 vecEntries[isensor]= nused;
1161 if (nused>1){
1162 vecMedian[isensor] = TMath::Median(nused,values.GetMatrixArray());
1163 vecMean[isensor] = TMath::Mean(nused,values.GetMatrixArray());
1164 vecRMS[isensor] = TMath::RMS(nused,values.GetMatrixArray());
1165 }
1166 }
1167 }
1168}
1169
e2914767 1170
1171
1172AliGRPObject * AliTPCcalibDB::MakeGRPObjectFromMap(TMap *map){
1173 //
1174 // Function to covert old GRP run information from TMap to GRPObject
1175 //
1176 // TMap * map = AliTPCcalibDB::GetGRPMap(52406);
1177 if (!map) return 0;
1178 AliDCSSensor * sensor = 0;
1179 TObject *osensor=0;
1180 osensor = ((*map)("fP2Pressure"));
1181 sensor =dynamic_cast<AliDCSSensor *>(osensor);
1182 //
1183 if (!sensor) return 0;
1184 //
1185 AliDCSSensor * sensor2 = new AliDCSSensor(*sensor);
1186 osensor = ((*map)("fCavernPressure"));
1187 TGraph * gr = new TGraph(2);
1188 gr->GetX()[0]= -100000.;
1189 gr->GetX()[1]= 1000000.;
1190 gr->GetY()[0]= atof(osensor->GetName());
1191 gr->GetY()[1]= atof(osensor->GetName());
1192 sensor2->SetGraph(gr);
1193 sensor2->SetFit(0);
1194
1195
1196 AliGRPObject *grpRun = new AliGRPObject;
1197 grpRun->ReadValuesFromMap(map);
1198 grpRun->SetCavernAtmosPressure(sensor2);
1199 grpRun->SetSurfaceAtmosPressure(sensor);
1200 return grpRun;
1201}
1202
1203
1204