AliRoot Core  edcc906 (edcc906)
AliTPCcalibDB.cxx
Go to the documentation of this file.
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 
70 
71 #include <iostream>
72 #include <fstream>
73 
74 
75 #include <AliCDBManager.h>
76 #include <AliCDBEntry.h>
77 #include <AliCDBId.h>
78 #include <AliLog.h>
79 #include <AliMagF.h>
80 #include <AliSplineFit.h>
81 #include <AliCTPTimeParams.h>
82 
83 #include "TGraphErrors.h"
84 #include "AliTPCcalibDB.h"
85 #include "AliTPCdataQA.h"
86 #include "AliTPCcalibDButil.h"
87 #include "AliTPCAltroMapping.h"
88 #include "AliTPCExB.h"
89 
90 #include "AliTPCCalROC.h"
91 #include "AliTPCCalPad.h"
92 #include "AliTPCSensorTempArray.h"
93 #include "AliGRPObject.h"
94 #include "AliTPCTransform.h"
95 #include "AliTPCmapper.h"
96 #include "AliTPCclusterMI.h"
97 
98 class AliCDBStorage;
99 class AliTPCCalDet;
100 //
101 //
102 
103 #include "TFile.h"
104 #include "TKey.h"
105 #include "TGraphErrors.h"
106 #include "TGeoGlobalMagField.h"
107 
108 #include "TObjArray.h"
109 #include "TObjString.h"
110 #include "TString.h"
111 #include "TDirectory.h"
112 #include "TArrayI.h"
113 #include "AliTPCCalPad.h"
114 #include "AliTPCCalibPulser.h"
115 #include "AliTPCCalibPedestal.h"
116 #include "AliTPCCalibCE.h"
117 #include "AliTPCExBFirst.h"
118 #include "AliTPCTempMap.h"
119 #include "AliTPCCalibVdrift.h"
120 #include "AliTPCCalibRaw.h"
121 #include "AliTPCParam.h"
122 #include "AliTPCCorrection.h"
125 #include "AliTimeStamp.h"
126 #include "AliTriggerRunScalers.h"
127 #include "AliTriggerScalers.h"
128 #include "AliTriggerScalersRecord.h"
129 #include "AliDAQ.h"
130 #include "AliTPCRecoParam.h"
132 ClassImp(AliTPCcalibDB)
134 
135 AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0;
136 Bool_t AliTPCcalibDB::fgTerminated = kFALSE;
137 TObjArray AliTPCcalibDB::fgExBArray;
138 
139 const char* AliTPCcalibDB::fgkGasSensorNames[AliTPCcalibDB::kNGasSensor] = {"TPC_GC_NEON", "TPC_GC_ARGON", "TPC_GC_CO2", "TPC_GC_N2", "TPC_An_L1Sr141_H2O", "TPC_An_L1Sr141_O2"};
140 
141 //_ singleton implementation __________________________________________________
143 {
146 
147  if (fgTerminated != kFALSE)
148  return 0;
149 
150  if (fgInstance == 0)
151  fgInstance = new AliTPCcalibDB();
152 
153  return fgInstance;
154 }
155 
157 {
161 
162  fgTerminated = kTRUE;
163 
164  if (fgInstance != 0)
165  {
166  delete fgInstance;
167  fgInstance = 0;
168  }
169 }
170 
171 //_____________________________________________________________________________
173  TObject(),
174  fRun(-1),
175  fTransform(0),
176  fExB(0),
177  fPadGainFactor(0),
179  fDedxGainFactor(0),
180  fPadTime0(0),
181  fDistortionMap(0),
184  fCorrectionMaps(0),
185  fPadNoise(0),
186  fPedestals(0),
187  fCalibRaw(0),
188  fDataQA(0),
189  fALTROConfigData(0),
190  fIonTailArray(0),
191  fPulserData(0),
192  fCEData(0),
193  fGasSensorArray(0x0),
194  fMaxTimeBinAllPads(-1),
195  fHVsensors(),
196  fGrRunState(0x0),
197  fTemperature(0),
198  fMapping(0),
199  fRunEventSpecie(AliRecoParam::kDefault),
200  fParam(0),
201  fClusterParam(0),
202  fRecoParamList(0),
203  fTimeGainSplines(0),
205  fGRPArray(1),
206  fGRPMaps(1),
207  fGoofieArray(1),
208  fVoltageArray(1),
209  fTemperatureArray(1),
210  fVdriftArray(1),
212  fRunList(1),
213  fBHasAlignmentOCDB(kFALSE), // Flag - has the alignment on the composed correction ?
214  fDButil(0),
215  fCTPTimeParams(0),
216  fMode(-1)
217 {
219 
220  fgInstance=this;
221  for (Int_t i=0;i<72;++i){
222  fChamberHVStatus[i]=kTRUE;
223  fChamberHVmedian[i]=-1;
226  }
227  Update(); // temporary
228  fTimeGainSplinesArray.SetOwner(); //own the keys
229  fGRPArray.SetOwner(); //own the keys
230  fGRPMaps.SetOwner(); //own the keys
231  fGoofieArray.SetOwner(); //own the keys
232  fVoltageArray.SetOwner(); //own the keys
233  fTemperatureArray.SetOwner(); //own the keys
234  fVdriftArray.SetOwner(); //own the keys
235  fDriftCorrectionArray.SetOwner(); //own the keys
236 }
237 
239  TObject(),
240  fRun(-1),
241  fTransform(0),
242  fExB(0),
243  fPadGainFactor(0),
245  fDedxGainFactor(0),
246  fPadTime0(0),
247  fDistortionMap(0),
250  fCorrectionMaps(0),
251  fPadNoise(0),
252  fPedestals(0),
253  fCalibRaw(0),
254  fDataQA(0),
255  fALTROConfigData(0),
256  fIonTailArray(0),
257  fPulserData(0),
258  fCEData(0),
259  fGasSensorArray(0x0),
260  fMaxTimeBinAllPads(-1),
261  fHVsensors(),
262  fGrRunState(0x0),
263  fTemperature(0),
264  fMapping(0),
265  fRunEventSpecie(AliRecoParam::kDefault),
266  fParam(0),
267  fClusterParam(0),
268  fRecoParamList(0),
269  fTimeGainSplines(0),
271  fGRPArray(0),
272  fGRPMaps(0),
273  fGoofieArray(0),
274  fVoltageArray(0),
275  fTemperatureArray(0),
276  fVdriftArray(0),
278  fRunList(0),
279  fBHasAlignmentOCDB(kFALSE), // Flag - has the alignment on the composed correction ?
280  fDButil(0),
281  fCTPTimeParams(0),
282  fMode(-1)
283 {
285 
286  Error("copy constructor","invalid -- singleton implementation");
287  for (Int_t i=0;i<72;++i){
288  fChamberHVStatus[i]=kTRUE;
289  fChamberHVmedian[i]=-1;
292  }
293  fTimeGainSplinesArray.SetOwner(); //own the keys
294  fGRPArray.SetOwner(); //own the keys
295  fGRPMaps.SetOwner(); //own the keys
296  fGoofieArray.SetOwner(); //own the keys
297  fVoltageArray.SetOwner(); //own the keys
298  fTemperatureArray.SetOwner(); //own the keys
299  fVdriftArray.SetOwner(); //own the keys
300  fDriftCorrectionArray.SetOwner(); //own the keys
301 }
302 
304 {
306 
307  Error("operator =", "assignment operator not implemented");
308  return *this;
309 }
310 
311 
312 
313 //_____________________________________________________________________________
315 {
319 
320  delete fActiveChannelMap;
321  delete fGrRunState;
322  fgInstance = 0;
323 }
324 
327 
328  return (fDistortionMap) ? (AliTPCCalPad*)fDistortionMap->At(i):0;
329 }
330 
331 //_____________________________________________________________________________
333  return (fRecoParamList) ? (AliTPCRecoParam*)fRecoParamList->At(i):0;
334 }
335 
336 //_____________________________________________________________________________
338 {
339  // return recoparam for specie matching to current GRP
340  if (!fRecoParamList) return 0;
341  for (int i=fRecoParamList->GetEntriesFast();i--;) {
342  AliTPCRecoParam* par = (AliTPCRecoParam*)fRecoParamList->UncheckedAt(i);
343  if (!par || !(par->GetEventSpecie()&fRunEventSpecie)) continue;
344  return par;
345  }
346  AliWarningF("Did not find recoparam for EventSpecie %s suggested by GRP",AliRecoParam::GetEventSpecieName(fRunEventSpecie));
347  return 0;
348 }
349 
350 
351 
352 //_____________________________________________________________________________
354 {
356 
357  char chinfo[1000];
358 
359  AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
360  if (!entry)
361  {
362  snprintf(chinfo,1000,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
363  AliError(chinfo);
364  return 0;
365  }
366  return entry;
367 }
368 
369 
370 //_____________________________________________________________________________
371 void AliTPCcalibDB::SetRun(Long64_t run)
372 {
374 
375  if (fRun == run)
376  return;
377  fRun = run;
378  Update();
379 }
380 
381 
382 
385 
386 
387  AliCDBEntry * entry=0x0;
388  Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
389  AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
391  //
393 
394  //RS: new TPC correction map (array of AliTPCChebCorr) will be loaded on demand
395  fCorrectionMaps = 0; // assuming that the object is managed by the OCDB
396  //
397 
398  entry = GetCDBEntry("TPC/Calib/Parameters");
399  if (entry){
400  //if (fPadNoise) delete fPadNoise;
401  entry->SetOwner(kTRUE);
402  fParam = (AliTPCParam*)(entry->GetObject());
403  }else{
404  AliFatal("TPC - Missing calibration entry TPC/Calib/Parameters");
405  }
406 
407  //
408  // check the presence of the detectors
409  try {
410  entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
411  } catch(...) {
412  AliInfo("No GRP entry found");
413  entry = 0x0;
414  }
415  if (entry) {
416  AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entry->GetObject());
417  if (!grpData) {printf("Failed to get GRP data for run %d\n",fRun); return;}
418  Int_t activeDetectors = grpData->GetDetectorMask();
419  TString detStr = AliDAQ::ListOfTriggeredDetectors(activeDetectors);
420  //printf("Detectors in the data:\n%s\n",detStr.Data());
421  if ( detStr.Contains("TPC")==0){
422  AliInfo("TPC not present in the run");
423  return;
424  }
426  AliInfoF("Run-specific EventSpecie set to %s",AliRecoParam::GetEventSpecieName(fRunEventSpecie));
427  }
428 
429  entry = GetCDBEntry("TPC/Calib/PadGainFactor");
430  if (entry){
431  //if (fPadGainFactor) delete fPadGainFactor;
432  entry->SetOwner(kTRUE);
434  }else{
435  AliFatal("TPC - Missing calibration entry TPC/Calib/PadGainFactor");
436  }
437  //
438  entry = GetCDBEntry("TPC/Calib/TimeGain");
439  if (entry){
440  //if (fTimeGainSplines) delete fTimeGainSplines;
441  entry->SetOwner(kTRUE);
442  fTimeGainSplines = (TObjArray*)entry->GetObject();
443  }else{
444  AliFatal("TPC - Missing calibration entry TPC/Calib/Timegain");
445  }
446  //
447  entry = GetCDBEntry("TPC/Calib/GainFactorDedx");
448  if (entry){
449  entry->SetOwner(kTRUE);
451  }else{
452  AliFatal("TPC - Missing calibration entry TPC/Calib/gainFactordEdx");
453  }
454  //
455  entry = GetCDBEntry("TPC/Calib/PadTime0");
456  if (entry){
457  //if (fPadTime0) delete fPadTime0;
458  entry->SetOwner(kTRUE);
459  fPadTime0 = (AliTPCCalPad*)entry->GetObject();
460  }else{
461  AliFatal("TPC - Missing calibration entry");
462  }
463 
464  entry = GetCDBEntry("TPC/Calib/Distortion");
465  if (entry){
466  //if (fPadTime0) delete fPadTime0;
467  entry->SetOwner(kTRUE);
468  fDistortionMap =dynamic_cast<TObjArray*>(entry->GetObject());
469  }else{
470  //AliFatal("TPC - Missing calibration entry")
471  }
472 
473 
474  //
475  //
476  entry = GetCDBEntry("TPC/Calib/PadNoise");
477  if (entry){
478  //if (fPadNoise) delete fPadNoise;
479  entry->SetOwner(kTRUE);
480  fPadNoise = (AliTPCCalPad*)entry->GetObject();
481  }else{
482  AliFatal("TPC - Missing calibration entry");
483  }
484 
485  entry = GetCDBEntry("TPC/Calib/Pedestals");
486  if (entry){
487  //if (fPedestals) delete fPedestals;
488  entry->SetOwner(kTRUE);
489  fPedestals = (AliTPCCalPad*)entry->GetObject();
490  }
491 
492  entry = GetCDBEntry("TPC/Calib/Temperature");
493  if (entry){
494  //if (fTemperature) delete fTemperature;
495  entry->SetOwner(kTRUE);
497  }
498 
499 
500  entry = GetCDBEntry("TPC/Calib/ClusterParam");
501  if (entry){
502  entry->SetOwner(kTRUE);
504  }else{
505  AliFatal("TPC - Missing calibration entry");
506  }
507 
508  entry = GetCDBEntry("TPC/Calib/RecoParam");
509  if (entry){
510  //PH entry->SetOwner(kTRUE);
511  fRecoParamList = dynamic_cast<TObjArray*>(entry->GetObject());
512 
513  }else{
514  AliFatal("TPC - Missing calibration entry TPC/Calib/RecoParam");
515  }
516 
517  //Gas sensor data
518  entry = GetCDBEntry("TPC/Calib/GasComposition");
519  if (entry){
520  entry->SetOwner(kTRUE);
522  }else{
523  AliWarning("Missing gas calibration entry");
524  }
525 
526  //ALTRO configuration data
527  entry = GetCDBEntry("TPC/Calib/AltroConfig");
528  if (entry){
529  entry->SetOwner(kTRUE);
530  fALTROConfigData=(TObjArray*)(entry->GetObject());
531  }else{
532  AliFatal("TPC - Missing calibration entry");
533  }
534 
535  //Calibration Pulser data
536  entry = GetCDBEntry("TPC/Calib/Pulser");
537  if (entry){
538  entry->SetOwner(kTRUE);
539  fPulserData=(TObjArray*)(entry->GetObject());
540  }
541 
542  //Calibration ION tail data
543  entry = GetCDBEntry("TPC/Calib/IonTail");
544  if (entry){
545  //delete fIonTailArray; fIonTailArray=NULL;
546  entry->SetOwner(kTRUE);
547  fIonTailArray=(TObjArray*)(entry->GetObject());
548  fIonTailArray->SetOwner(); //own the keys
549  }
550 
551  //CE data
552  entry = GetCDBEntry("TPC/Calib/CE");
553  if (entry){
554  entry->SetOwner(kTRUE);
555  fCEData=(TObjArray*)(entry->GetObject());
556  }
557  //RAW calibration data
558  // entry = GetCDBEntry("TPC/Calib/Raw");
559 
560  entry = GetCDBEntry("TPC/Calib/Mapping");
561  if (entry){
562  //if (fPadNoise) delete fPadNoise;
563  entry->SetOwner(kTRUE);
564  TObjArray * array = dynamic_cast<TObjArray*>(entry->GetObject());
565  if (array && array->GetEntriesFast()==6){
566  fMapping = new AliTPCAltroMapping*[6];
567  for (Int_t i=0; i<6; i++){
568  fMapping[i] = dynamic_cast<AliTPCAltroMapping*>(array->At(i));
569  }
570  }
571  }
572 
573  //CTP calibration data
574  entry = GetCDBEntry("GRP/CTP/CTPtiming");
575  if (entry){
576  //entry->SetOwner(kTRUE);
577  fCTPTimeParams=dynamic_cast<AliCTPTimeParams*>(entry->GetObject());
578  }else{
579  AliError("TPC - Missing calibration entry");
580  }
581  //TPC space point correction data
582  entry = GetCDBEntry("TPC/Calib/Correction");
583  if (entry){
584  //entry->SetOwner(kTRUE);
585  fComposedCorrection=dynamic_cast<AliTPCCorrection*>(entry->GetObject());
587  fComposedCorrectionArray=dynamic_cast<TObjArray*>(entry->GetObject());
589  for (Int_t i=0; i<fComposedCorrectionArray->GetEntries(); i++){
590  AliTPCComposedCorrection* composedCorrection= dynamic_cast<AliTPCComposedCorrection*>(fComposedCorrectionArray->At(i));
591  if (composedCorrection) {
592  composedCorrection->Init();
593  if (composedCorrection->GetCorrections()){
594  if (composedCorrection->GetCorrections()->FindObject("FitAlignTPC")){
595  fBHasAlignmentOCDB=kTRUE;
596  }
597  }
598  }
599  }
600  }
601  }else{
602  AliError("TPC - Missing calibration entry- TPC/Calib/Correction");
603  }
604 
605  //RCU trigger config mode
607  //
608  if (!fTransform) {
611  }
612 
613  // Chamber HV data
614  // needs to be called before InitDeadMap
616 
617  // Create Dead Channel Map
618  InitDeadMap();
619 
620  // Calculate derived ALTRO information
621  InitAltroData();
622 
623  //
624  AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
625 }
626 
627 
629 {
630  // TPC fast Chebyshev correction map, loaded on 1st demand
631  AliCDBEntry* entry = GetCDBEntry("TPC/Calib/CorrectionMaps");
632  if (entry) {
633  fCorrectionMaps = dynamic_cast<TObjArray*>(entry->GetObject());
634  }
635  else{
636  AliError("TPC - Missing calibration entry- TPC/Calib/CorrectionMaps");
637  }
638 }
639 
645 
646  AliCDBEntry * entry=0;
647  entry = GetCDBEntry("TPC/Calib/Raw");
648  if (entry){
649  entry->SetOwner(kTRUE);
650  TObjArray *arr=dynamic_cast<TObjArray*>(entry->GetObject());
651  if (arr) fCalibRaw=(AliTPCCalibRaw*)arr->At(0);
652  else fCalibRaw = (AliTPCCalibRaw*)(entry->GetObject());
653  }
654  //QA calibration data
655  entry = GetCDBEntry("TPC/Calib/QA");
656  if (entry){
657  entry->SetOwner(kTRUE);
658  fDataQA=dynamic_cast<AliTPCdataQA*>(entry->GetObject());
659  }
660  // High voltage
661  if (fRun>=0 && !fVoltageArray.GetValue(Form("%i",fRun))){
662  entry = AliCDBManager::Instance()->Get("TPC/Calib/HighVoltage",fRun);
663  if (entry) {
664  fVoltageArray.Add(new TObjString(Form("%i",fRun)),entry->GetObject());
665  }
666  }
667 
668 }
669 
670 Bool_t AliTPCcalibDB::GetTailcancelationGraphs(Int_t sector, TGraphErrors ** graphRes, Float_t * indexAmpGraphs){
671 
674 
675  //Int_t run = fTransform->GetCurrentRunNumber();
676  //SetRun(run);
677  //Float_t rocVoltage = GetChamberHighVoltage(run,sector, -1); // Get the voltage from OCDB with a getter (old function)
678 // Float_t rocVoltage=GetChamberHighVoltageMedian(sector); // Get the voltage from OCDB, new function from Jens
679 
680  Int_t nominalVoltage = (sector<36) ? 1240 : 1470 ; // nominal voltage of 2012 when the TRF functions were produced
681 
682  Float_t rocVoltage = nominalVoltage;
683 
684  if ( rocVoltage < nominalVoltage/2. || rocVoltage > nominalVoltage*2. )
685  {
686  AliInfo(Form("rocVoltage out of range: roc: %.2f, nominal: %i", rocVoltage, nominalVoltage));
687  return kFALSE;
688  }
689 
690  Int_t tempVoltage = 0;
691  Int_t trackAngle = 4; // (1=first, 2=second, 3=third, 4=first+second, 5=all tracks) note: 3rd is distorted by low freq
692  TString rocType = (sector<36) ? "iroc" : "oroc";
693  const Int_t ngraph=fIonTailArray->GetLast();
694 
695  // create array of voltages in order to select the proper TRF with closest voltage
696  Int_t voltages[ngraph]; // array of voltages
697  for (Int_t i=0; i<ngraph; i++){
698  voltages[i]=0;
699  }
700 
701  // loop over response functions in the TObjarray
702  Int_t nvoltages=0;
703  for (Int_t i=0;i<=ngraph;i++){
704 
705  // read the TRF object name in order to select proper TRF for the given sector
706  TString objname(fIonTailArray->At(i)->GetName());
707  if (!objname.Contains(rocType)) continue;
708 
709  TObjArray *objArr = objname.Tokenize("_");
710 
711  // select the roc type (IROC or OROC) and the trackAngle
712  if ( atoi(static_cast<TObjString*>(objArr->At(3))->GetName())==trackAngle )
713  {
714  // Create the voltage array for proper voltage value selection
715  voltages[nvoltages]=atoi(static_cast<TObjString*>(objArr->At(2))->GetName());
716  nvoltages++;
717  }
718  delete objArr;
719  }
720 
721  // find closest voltage value to ROC voltage (among the TRF' voltage array --> to select proper t.r.f.)
722  Int_t ampIndex = 0;
723  Int_t diffVoltage = TMath::Abs(rocVoltage - voltages[0]);
724  for (Int_t k=0;k<ngraph;k++) {
725  if (diffVoltage >= TMath::Abs(rocVoltage-voltages[k]) && voltages[k]!=0)
726  {
727  diffVoltage = TMath::Abs(rocVoltage-voltages[k]);
728  ampIndex = k;
729  }
730  }
731  tempVoltage = voltages[ampIndex]; // use closest voltage to current voltage
732  //if (run<140000) tempVoltage = nominalVoltage; // for 2010 data
733 
734  // assign TGraphErrors
735  Int_t igraph=0;
736  for (Int_t i=0; i<=ngraph; i++){
737 
738  // read TRFs for TObjArray and select the roc type (IROC or OROC) and the trackAngle
739  TGraphErrors * trfObj = static_cast<TGraphErrors*>(fIonTailArray->At(i));
740  TString objname(trfObj->GetName());
741  if (!objname.Contains(rocType)) continue; //choose ROC type
742 
743  TObjArray *objArr1 = objname.Tokenize("_");
744 
745  // TRF eleminations
746  TObjString* angleString = static_cast<TObjString*>(objArr1->At(3));
747  TObjString* voltageString = static_cast<TObjString*>(objArr1->At(2));
748  //choose angle and voltage
749  if ((atoi(angleString->GetName())==trackAngle) && (atoi(voltageString->GetName())==tempVoltage) )
750  {
751  // Apply Voltage scaling
752  Int_t voltage = atoi(voltageString->GetName());
753  Double_t voltageScaled = 1;
754  if (rocVoltage>0) voltageScaled = Double_t(voltage)/Double_t(rocVoltage); // for jens how it can happen that we have clusters at 0 HV ?
755  const Int_t nScaled = TMath::Nint(voltageScaled*trfObj->GetN())-1;
756  Double_t x;
757  Double_t y;
758 
759  delete graphRes[igraph];
760  graphRes[igraph] = new TGraphErrors(nScaled);
761 
762  for (Int_t j=0; j<nScaled; j++){
763  x = TMath::Nint(j*(voltageScaled));
764  y = (j<trfObj->GetN()) ? (1./voltageScaled)*trfObj->GetY()[j] : 0.;
765  graphRes[igraph]->SetPoint(j,x,y);
766  }
767 
768  // fill arrays for proper position and amplitude selections
769  TObjString* distanceToCenterOfGravity = static_cast<TObjString*>(objArr1->At(4));
770  indexAmpGraphs[igraph] = (distanceToCenterOfGravity->GetString().Atof())/10.;
771  // smooth voltage scaled graph
772  for (Int_t m=1; m<nScaled;m++){
773  if (graphRes[igraph]->GetY()[m]==0) graphRes[igraph]->GetY()[m] = graphRes[igraph]->GetY()[m-1];
774  }
775  igraph++;
776  }
777  delete objArr1;
778  }
779  return kTRUE;
780 }
781 
782 void AliTPCcalibDB::CreateObjectList(const Char_t *filename, TObjArray *calibObjects)
783 {
785 
786  if ( calibObjects == 0x0 ) return;
787  ifstream in;
788  in.open(filename);
789  if ( !in.is_open() ){
790  fprintf(stderr,"Error: cannot open list file '%s'", filename);
791  return;
792  }
793 
794  AliTPCCalPad *calPad=0x0;
795 
796  TString sFile;
797  sFile.ReadFile(in);
798  in.close();
799 
800  TObjArray *arrFileLine = sFile.Tokenize("\n");
801 
802  TIter nextLine(arrFileLine);
803 
804  TObjString *sObjLine=0x0;
805  while ( (sObjLine = (TObjString*)nextLine()) ){
806  TString sLine(sObjLine->GetString());
807 
808  TObjArray *arrNextCol = sLine.Tokenize("\t");
809 
810  TObjString *sObjType = (TObjString*)(arrNextCol->At(0));
811  TObjString *sObjFileName = (TObjString*)(arrNextCol->At(1));
812  delete arrNextCol;
813 
814  if ( !sObjType || ! sObjFileName ) continue;
815  TString sType(sObjType->GetString());
816  TString sFileName(sObjFileName->GetString());
817 // printf("%s\t%s\n",sType.Data(),sFileName.Data());
818 
819  TFile *fIn = TFile::Open(sFileName);
820  if ( !fIn ){
821  fprintf(stderr,"File not found: '%s'", sFileName.Data());
822  continue;
823  }
824 
825  if ( sType == "CE" ){
826  AliTPCCalibCE *ce = (AliTPCCalibCE*)fIn->Get("AliTPCCalibCE");
827 
828  calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadT0());
829  calPad->SetNameTitle("CETmean","CETmean");
830  calibObjects->Add(calPad);
831 
832  calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadQ());
833  calPad->SetNameTitle("CEQmean","CEQmean");
834  calibObjects->Add(calPad);
835 
836  calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadRMS());
837  calPad->SetNameTitle("CETrms","CETrms");
838  calibObjects->Add(calPad);
839 
840  } else if ( sType == "Pulser") {
841  AliTPCCalibPulser *sig = (AliTPCCalibPulser*)fIn->Get("AliTPCCalibPulser");
842 
843  calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadT0());
844  calPad->SetNameTitle("PulserTmean","PulserTmean");
845  calibObjects->Add(calPad);
846 
847  calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadQ());
848  calPad->SetNameTitle("PulserQmean","PulserQmean");
849  calibObjects->Add(calPad);
850 
851  calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadRMS());
852  calPad->SetNameTitle("PulserTrms","PulserTrms");
853  calibObjects->Add(calPad);
854 
855  } else if ( sType == "Pedestals") {
856  AliTPCCalibPedestal *ped = (AliTPCCalibPedestal*)fIn->Get("AliTPCCalibPedestal");
857 
858  calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadPedestal());
859  calPad->SetNameTitle("Pedestals","Pedestals");
860  calibObjects->Add(calPad);
861 
862  calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadRMS());
863  calPad->SetNameTitle("Noise","Noise");
864  calibObjects->Add(calPad);
865 
866  } else {
867  fprintf(stderr,"Undefined Type: '%s'",sType.Data());
868 
869  }
870  delete fIn;
871  }
872  delete arrFileLine;
873 }
874 
876 {
886 
887  // check necessary information
888  const Int_t run=GetRun();
889  if (run<0){
890  AliError("run not set in CDB manager. Cannot create active channel map");
891  return 0;
892  }
893  AliDCSSensorArray* voltageArray = GetVoltageSensors(run);
894  AliTPCCalPad* altroMap = GetALTROMasked();
895  TMap* mapddl = GetDDLMap();
896 
897  if (!voltageArray && !altroMap && !mapddl) {
898  AliError("All necessary information to create the activate channel are map missing.");
899  AliError(" -> Check existance of the OCDB entries: 'TPC/Calib/AltroConfig', 'TPC/Calib/HighVoltage'");
900  return 0;
901  }
902 
903  // mapping handler
904  AliTPCmapper map(gSystem->ExpandPathName("$ALICE_ROOT/TPC/mapping/"));
905 
906  //=============================================================
907  // Setup DDL map
908 
909  Bool_t ddlMap[216]={0};
910  for (Int_t iddl=0; iddl<216; ++iddl) ddlMap[iddl]=1;
911  if (mapddl){
912  TObjString *s = (TObjString*)mapddl->GetValue("DDLArray");
913  if (s){
914  for (Int_t iddl=0; iddl<216; ++iddl) {
915  ddlMap[iddl]=TString(s->GetString()(iddl))!="0";
916  if (!ddlMap[iddl]) {
917  Int_t roc = map.GetRocFromEquipmentID(iddl+768);
918  AliWarning(Form("Inactive DDL (#%d, ROC %2d) detected based on the 'DDLArray' in 'TPC/Calib/AltroConfig'. This will deactivate many channels.", iddl, roc));
919  }
920  }
921  }
922  } else {
923  AliError("DDL map missing. ActiveChannelMap can only be created with parts of the information.");
924  AliError(" -> Check existance of 'DDLArray' in the OCDB entry: 'TPC/Calib/AltroConfig'");
925  }
926  // Setup DDL map done
927  // ============================================================
928 
929  // ============================================================
930  // Set up channel masking from correction maps
931 
932  TBits maskedPads[72];
934 
935  // channel masking done
936  // ============================================================
937 
938  //=============================================================
939  // Setup active channel map
940  //
941 
942  if (!fActiveChannelMap) fActiveChannelMap=new AliTPCCalPad("ActiveChannelMap","ActiveChannelMap");
943 
944  if (!altroMap) {
945  AliError("ALTRO dead channel map missing. ActiveChannelMap can only be created with parts of the information.");
946  AliError(" -> Check existance of 'Masked' in the OCDB entry: 'TPC/Calib/AltroConfig'");
947  }
948 
949  AliTPCROC* tpcROC = AliTPCROC::Instance();
950 
951  for (Int_t iROC=0;iROC<AliTPCCalPad::kNsec;++iROC){
953  if (!roc){
954  AliError(Form("No ROC %d in active channel map",iROC));
955  continue;
956  }
957 
958  // check for bad voltage
959  // see UpdateChamberHighVoltageData()
960  if (!fChamberHVStatus[iROC]){
961  roc->Multiply(0.);
962  AliWarning(Form("Turning off all channels of ROC %2d due to a bad HV status", iROC));
963  AliWarning(" -> Check messages in UpdateChamberHighVoltageData()");
964  continue;
965  }
966 
967  AliTPCCalROC *masked=0x0;
968  if (altroMap) masked=altroMap->GetCalROC(iROC);
969 
970  Int_t numberOfDeactivatedChannels=0;
971  for (UInt_t irow=0; irow<roc->GetNrows(); ++irow){
972  // first channel in row
973  const Int_t channel0 = tpcROC->GetRowIndexes(iROC)[irow];
974 
975  for (UInt_t ipad=0; ipad<roc->GetNPads(irow); ++ipad){
976  //per default the channel is on
977  roc->SetValue(irow,ipad,1);
978 
979  // apply altro dead channel mask (inverse logik, it is not active, but inactive channles)
980  if (masked && masked->GetValue(irow, ipad)) roc->SetValue(irow, ipad ,0);
981 
982  // mask channels if a DDL is inactive
983  Int_t ddlId=map.GetEquipmentID(iROC, irow, ipad)-768;
984  if (ddlId>=0 && !ddlMap[ddlId]) roc->SetValue(irow, ipad ,0);
985 
986  // mask channels if error on space point coorection is too large
987  if (maskedPads[iROC].TestBitNumber(channel0+ipad)) roc->SetValue(irow, ipad ,0);
988 
989  if (roc->GetValue(irow, ipad)<0.0001) {
990  ++numberOfDeactivatedChannels;
991  }
992  }
993  }
994 
995  if (numberOfDeactivatedChannels>0) {
996  AliInfo(Form("Deactivated %4d channels in ROC %2d due to altro and DDL map states as well as chamber status and correction map",
997  numberOfDeactivatedChannels, iROC));
998  }
999  }
1000 
1001  return 1;
1002 }
1003 
1005 {
1011 
1012  // ===| Maximum time bin |====================================================
1013  //
1014  // Calculate the maximum time using the 'AcqStart' cal pad object from
1015  // TPC/Calib/AltroConfig
1016  // if this object is not available, the value will return the max time bin
1017  // stored in the AliTPCParam object from TPC/Calib/Parameter
1018  //
1019  // The samples in the ALTRO are numbered from 0 to 1023.
1020  // There is space for 15 "pre-trigger samples" which we don't make use of
1021  // For AcpStart = 0 the first time bin is 15 (no pre-trigger samples).
1022  // For AcqStop = 1008 the last sample is 1023
1023  // Therefore 15 is added to AcqStop
1024 
1025 
1026  fMaxTimeBinAllPads=-1;
1027 
1028  const AliTPCCalPad *calPadAcqStop = GetALTROAcqStop();
1029 
1030  if (calPadAcqStop) {
1031  //find max elememt
1032  // TODO: change this once the GetMaxElement function is implemented in AliTPCCalPad
1033  Float_t maxBin=-1;
1034  for (Int_t iroc=0; iroc<AliTPCCalPad::kNsec; ++iroc) {
1035  const AliTPCCalROC *roc = calPadAcqStop->GetCalROC(iroc);
1036  if (!roc) continue;
1037  for (Int_t ichannel=0; ichannel<roc->GetNchannels(); ++ichannel) {
1038  const Float_t val=roc->GetValue(ichannel);
1039  if (val>maxBin) maxBin=val;
1040  }
1041  }
1042  fMaxTimeBinAllPads = TMath::Nint(maxBin)+15;
1043  }
1044 
1045  if (fMaxTimeBinAllPads<0) {
1046  if (fParam) {
1047  AliWarning("Could not access 'AcqStop' map from AltroConfig or invalid max time bine. fMaxTimeBinAllPads will be set from AliTPCParam.");
1049  } else {
1050  // last fallback
1051  AliWarning("Could neither access 'Parameters' nor 'AcqStop' map from AltroConfig. fMaxTimeBinAllPads will be set to 1000.");
1052  fMaxTimeBinAllPads=1000;
1053  }
1054  }
1055 
1056  AliInfo(TString::Format("fMaxTimeBinAllPads set to %d", fMaxTimeBinAllPads).Data());
1057 }
1058 
1059 void AliTPCcalibDB::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad* outlierPad, Float_t ltmFraction) {
1064 
1065  AliTPCROC* tpcROCinstance = AliTPCROC::Instance();
1066 
1067  TObjArray* mapIROCs = 0;
1068  TObjArray* mapOROCs = 0;
1069  TVectorF *mapIROCArray = 0;
1070  TVectorF *mapOROCArray = 0;
1071  Int_t mapEntries = 0;
1072  TString* mapNames = 0;
1073 
1074  if (mapFileName) {
1075  TFile mapFile(mapFileName, "read");
1076 
1077  TList* listOfROCs = mapFile.GetListOfKeys();
1078  mapEntries = listOfROCs->GetEntries()/2;
1079  mapIROCs = new TObjArray(mapEntries*2);
1080  mapOROCs = new TObjArray(mapEntries*2);
1081  mapIROCArray = new TVectorF[mapEntries];
1082  mapOROCArray = new TVectorF[mapEntries];
1083 
1084  mapNames = new TString[mapEntries];
1085  for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
1086  TString nameROC(((TKey*)(listOfROCs->At(ivalue*2)))->GetName());
1087  nameROC.Remove(nameROC.Length()-4, 4);
1088  mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "IROC").Data()), ivalue);
1089  mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "OROC").Data()), ivalue);
1090  mapNames[ivalue].Append(nameROC);
1091  }
1092 
1093  for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
1094  mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0));
1095  mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36));
1096 
1097  for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++)
1098  (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel);
1099  for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++)
1100  (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel);
1101  }
1102 
1103  } // if (mapFileName)
1104 
1105  TTreeSRedirector cstream(fileName);
1106  Int_t arrayEntries = array->GetEntries();
1107 
1108  TString* names = new TString[arrayEntries];
1109  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
1110  names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName());
1111 
1112  for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) {
1113  //
1114  // get statistic for given sector
1115  //
1116  TVectorF median(arrayEntries);
1117  TVectorF mean(arrayEntries);
1118  TVectorF rms(arrayEntries);
1119  TVectorF ltm(arrayEntries);
1120  TVectorF ltmrms(arrayEntries);
1121  TVectorF medianWithOut(arrayEntries);
1122  TVectorF meanWithOut(arrayEntries);
1123  TVectorF rmsWithOut(arrayEntries);
1124  TVectorF ltmWithOut(arrayEntries);
1125  TVectorF ltmrmsWithOut(arrayEntries);
1126 
1127  TVectorF *vectorArray = new TVectorF[arrayEntries];
1128  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
1129  vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
1130 
1131  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
1132  AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
1133  AliTPCCalROC* calROC = calPad->GetCalROC(isector);
1134  AliTPCCalROC* outlierROC = 0;
1135  if (outlierPad) outlierROC = outlierPad->GetCalROC(isector);
1136  if (calROC) {
1137  median[ivalue] = calROC->GetMedian();
1138  mean[ivalue] = calROC->GetMean();
1139  rms[ivalue] = calROC->GetRMS();
1140  Double_t ltmrmsValue = 0;
1141  ltm[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction);
1142  ltmrms[ivalue] = ltmrmsValue;
1143  if (outlierROC) {
1144  medianWithOut[ivalue] = calROC->GetMedian(outlierROC);
1145  meanWithOut[ivalue] = calROC->GetMean(outlierROC);
1146  rmsWithOut[ivalue] = calROC->GetRMS(outlierROC);
1147  ltmrmsValue = 0;
1148  ltmWithOut[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction, outlierROC);
1149  ltmrmsWithOut[ivalue] = ltmrmsValue;
1150  }
1151  }
1152  else {
1153  median[ivalue] = 0.;
1154  mean[ivalue] = 0.;
1155  rms[ivalue] = 0.;
1156  ltm[ivalue] = 0.;
1157  ltmrms[ivalue] = 0.;
1158  medianWithOut[ivalue] = 0.;
1159  meanWithOut[ivalue] = 0.;
1160  rmsWithOut[ivalue] = 0.;
1161  ltmWithOut[ivalue] = 0.;
1162  ltmrmsWithOut[ivalue] = 0.;
1163  }
1164  }
1165 
1166  //
1167  // fill vectors of variable per pad
1168  //
1169  TVectorF *posArray = new TVectorF[8];
1170  for (Int_t ivalue = 0; ivalue < 8; ivalue++)
1171  posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
1172 
1173  Float_t posG[3] = {0};
1174  Float_t posL[3] = {0};
1175  Int_t ichannel = 0;
1176  for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) {
1177  for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) {
1178  tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL);
1179  tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG);
1180  posArray[0][ichannel] = irow;
1181  posArray[1][ichannel] = ipad;
1182  posArray[2][ichannel] = posL[0];
1183  posArray[3][ichannel] = posL[1];
1184  posArray[4][ichannel] = posG[0];
1185  posArray[5][ichannel] = posG[1];
1186  posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2);
1187  posArray[7][ichannel] = ichannel;
1188 
1189  // loop over array containing AliTPCCalPads
1190  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
1191  AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
1192  AliTPCCalROC* calROC = calPad->GetCalROC(isector);
1193  if (calROC)
1194  (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad);
1195  else
1196  (vectorArray[ivalue])[ichannel] = 0;
1197  }
1198  ichannel++;
1199  }
1200  }
1201 
1202  cstream << "calPads" <<
1203  "sector=" << isector;
1204 
1205  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
1206  cstream << "calPads" <<
1207  (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] <<
1208  (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] <<
1209  (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] <<
1210  (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] <<
1211  (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue];
1212  if (outlierPad) {
1213  cstream << "calPads" <<
1214  (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] <<
1215  (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] <<
1216  (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] <<
1217  (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] <<
1218  (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue];
1219  }
1220  }
1221 
1222  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
1223  cstream << "calPads" <<
1224  (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue];
1225  }
1226 
1227  if (mapFileName) {
1228  for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
1229  if (isector < 36)
1230  cstream << "calPads" <<
1231  (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue];
1232  else
1233  cstream << "calPads" <<
1234  (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue];
1235  }
1236  }
1237 
1238  cstream << "calPads" <<
1239  "row.=" << &posArray[0] <<
1240  "pad.=" << &posArray[1] <<
1241  "lx.=" << &posArray[2] <<
1242  "ly.=" << &posArray[3] <<
1243  "gx.=" << &posArray[4] <<
1244  "gy.=" << &posArray[5] <<
1245  "rpad.=" << &posArray[6] <<
1246  "channel.=" << &posArray[7];
1247 
1248  cstream << "calPads" <<
1249  "\n";
1250 
1251  delete[] posArray;
1252  delete[] vectorArray;
1253  }
1254 
1255 
1256  delete[] names;
1257  if (mapFileName) {
1258  delete mapIROCs;
1259  delete mapOROCs;
1260  delete[] mapIROCArray;
1261  delete[] mapOROCArray;
1262  delete[] mapNames;
1263  }
1264 }
1265 
1267 {
1269 
1270  TMap *map=GetRCUconfig();
1271  if (!map) return -1;
1272  TVectorF *v=(TVectorF*)map->GetValue("TRGCONF_TRG_MODE");
1273  Float_t mode=-1;
1274  for (Int_t i=0; i<v->GetNrows(); ++i){
1275  Float_t newmode=v->GetMatrixArray()[i];
1276  if (newmode>-1){
1277  if (mode>-1&&newmode!=mode) AliWarning("Found different RCU trigger configurations!!!");
1278  mode=newmode;
1279  }
1280  }
1281  return (Int_t)mode;
1282 }
1283 
1285 {
1287 
1288  if (fMode<0) return kFALSE;
1289  return (fMode==1);
1290 }
1291 
1293 {
1295 
1296  if (fMode<0) return kFALSE;
1297  return (fMode==0);
1298 }
1299 
1300 void AliTPCcalibDB::RegisterExB(Int_t index, Float_t bz, Bool_t bdelete){
1304 
1305  // Float_t factor = bz/(-5.); // default b filed in Cheb with minus sign
1306  Float_t factor = bz/(5.); // default b filed in Cheb with minus sign
1307  // was chenged in the Revision ???? (Ruben can you add here number)
1308 
1309  AliMagF* bmap = new AliMagF("MapsExB","MapsExB", factor,TMath::Sign(1.f,factor),AliMagF::k5kG);
1310 
1311  AliTPCExBFirst *exb = new AliTPCExBFirst(bmap,0.88*2.6400e+04,50,50,50);
1313 
1314  if (bdelete){
1315  delete bmap;
1316  }else{
1317  AliTPCExB::RegisterField(index,bmap);
1318  }
1319  if (index>=fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
1320  fgExBArray.AddAt(exb,index);
1321 }
1322 
1323 
1324 AliTPCExB* AliTPCcalibDB::GetExB(Float_t bz, Bool_t deleteB) {
1328 
1329  Int_t index = TMath::Nint(5+bz);
1330  if (index>fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
1331  if (!fgExBArray.At(index)) AliTPCcalibDB::RegisterExB(index,bz,deleteB);
1332  return (AliTPCExB*)fgExBArray.At(index);
1333 }
1334 
1335 
1338 
1339  fExB = GetExB(bz,kFALSE);
1340 }
1341 
1344 
1345  AliTPCExBFirst *exb = new AliTPCExBFirst(bmap,0.88*2.6400e+04,50,50,50);
1347  fExB=exb;
1348 }
1349 
1350 
1351 
1352 void AliTPCcalibDB::UpdateRunInformations( Int_t run, Bool_t force){
1354 
1355  if (run<=0) return;
1356  TObjString runstr(Form("%i",run));
1357  fRun=run;
1358  AliCDBEntry * entry = 0;
1359  if (run>= fRunList.fN){
1360  fRunList.Set(run*2+1);
1361  //
1362  if (fALTROConfigData) fALTROConfigData->Expand(run*2+1); // ALTRO configuration data
1363  if (fPulserData) fPulserData->Expand(run*2+1); // Calibration Pulser data
1364  if (fCEData) fCEData->Expand(run*2+1); // CE data
1365  if (!fTimeGainSplines) fTimeGainSplines = new TObjArray(run*2+1);
1366  fTimeGainSplines->Expand(run*2+1); // Array of AliSplineFits: at 0 MIP position in
1367  }
1368  if (fRunList[run]!=0 &&force==kFALSE) return;
1369 
1370  entry = AliCDBManager::Instance()->Get("GRP/GRP/Data",run);
1371  if (entry) {
1372  AliGRPObject * grpRun = dynamic_cast<AliGRPObject*>(entry->GetObject());
1373  if (!grpRun){
1374  TMap* map = dynamic_cast<TMap*>(entry->GetObject());
1375  if (map){
1376  grpRun = MakeGRPObjectFromMap(map);
1377  fGRPMaps.Add(new TObjString(runstr),map);
1378  }
1379  }
1380  fGRPArray.Add(new TObjString(runstr),(AliGRPObject*)grpRun->Clone());
1381  Int_t activeDetectors = grpRun->GetDetectorMask();
1382  TString detStr = AliDAQ::ListOfTriggeredDetectors(activeDetectors);
1383  if ( detStr.Contains("TPC")==0){
1384  AliInfo("TPC not present in the run");
1385  fRunList[run] = -1;
1386  return;
1387  }
1388  }
1389 
1390  fRunList[run]=1; // sign as used
1391 
1392 
1393  entry = AliCDBManager::Instance()->Get("TPC/Calib/Goofie",run);
1394  if (entry){
1395  fGoofieArray.Add(new TObjString(runstr),entry->GetObject());
1396  }
1397  //
1398 
1399  //
1400  entry = AliCDBManager::Instance()->Get("TPC/Calib/TimeGain",run);
1401  if (entry) {
1402  fTimeGainSplinesArray.Add(new TObjString(runstr),entry->GetObject());
1403  }else{
1404  AliFatal("TPC - Missing calibration entry TimeGain");
1405  }
1406  //
1407  entry = AliCDBManager::Instance()->Get("TPC/Calib/TimeDrift",run);
1408  if (entry) {
1409  TObjArray * timeArray = (TObjArray*)entry->GetObject();
1410  fDriftCorrectionArray.Add(new TObjString(runstr),entry->GetObject());
1411  AliTPCCorrection * correctionTime = (AliTPCCorrection *)timeArray->FindObject("FitCorrectionTime");
1412  if (correctionTime && fComposedCorrectionArray){
1413  correctionTime->Init();
1414  if (fComposedCorrectionArray->GetEntriesFast()<4) fComposedCorrectionArray->Expand(40);
1415  fComposedCorrectionArray->AddAt(correctionTime,4); //add time dependent correction to the list of available corrections
1416  }
1417  }else{
1418  AliFatal("TPC - Missing calibration entry TimeDrift");
1419  }
1420  //
1421  entry = AliCDBManager::Instance()->Get("TPC/Calib/Temperature",run);
1422  if (entry) {
1423  fTemperatureArray.Add(new TObjString(runstr),entry->GetObject());
1424  }
1425 
1426  // High voltage
1427  entry = AliCDBManager::Instance()->Get("TPC/Calib/HighVoltage",run);
1428  if (!fVoltageArray.GetValue(runstr.GetName()) && entry) {
1429  fVoltageArray.Add(new TObjString(runstr),entry->GetObject());
1430  }
1431 
1432  //apply fDButil filters
1433 
1436 
1437  AliDCSSensor * press = GetPressureSensor(run,0);
1439  Bool_t accept=kTRUE;
1440  if (temp) {
1441  accept = fDButil->FilterTemperature(temp)>0.1;
1442  }
1443  if (press) {
1444  const Double_t kMinP=900.;
1445  const Double_t kMaxP=1050.;
1446  const Double_t kMaxdP=10.;
1447  const Double_t kSigmaCut=4.;
1448  fDButil->FilterSensor(press,kMinP,kMaxP,kMaxdP,kSigmaCut);
1449  if (press->GetFit()==0) accept=kFALSE;
1450  }
1451 
1452  if (press && temp &&accept){
1453  AliTPCCalibVdrift * vdrift = new AliTPCCalibVdrift(temp, press,0);
1454  fVdriftArray.Add(new TObjString(runstr),vdrift);
1455  }
1456 
1457  fDButil->FilterCE(120., 3., 4.,0);
1458  fDButil->FilterTracks(run, 10.,0);
1459 
1460 }
1461 
1462 
1463 Float_t AliTPCcalibDB::GetGain(Int_t sector, Int_t row, Int_t pad){
1465 
1466  AliTPCCalPad *calPad = Instance()->fDedxGainFactor;;
1467  if (!calPad) return 0;
1468  return calPad->GetCalROC(sector)->GetValue(row,pad);
1469 }
1470 
1471 AliSplineFit* AliTPCcalibDB::GetVdriftSplineFit(const char* name, Int_t run){
1473 
1475  if (!arr) return 0;
1476  return dynamic_cast<AliSplineFit*>(arr->FindObject(name));
1477 }
1478 
1479 AliSplineFit* AliTPCcalibDB::CreateVdriftSplineFit(const char* graphName, Int_t run){
1481 
1483  if (!arr) return 0;
1484  TGraph *graph=dynamic_cast<TGraph*>(arr->FindObject(graphName));
1485  if (!graph) return 0;
1486  AliSplineFit *fit = new AliSplineFit();
1487  fit->SetGraph(graph);
1488  fit->SetMinPoints(graph->GetN()+1);
1489  fit->InitKnots(graph,2,0,0.001);
1490  fit->SplineFit(0);
1491  return fit;
1492 }
1493 
1496 
1497  AliGRPObject * grpRun = dynamic_cast<AliGRPObject *>((Instance()->fGRPArray).GetValue(Form("%i",run)));
1498  if (!grpRun) {
1500  grpRun = dynamic_cast<AliGRPObject *>(Instance()->fGRPArray.GetValue(Form("%i",run)));
1501  if (!grpRun) return 0;
1502  }
1503  return grpRun;
1504 }
1505 
1506 TMap * AliTPCcalibDB::GetGRPMap(Int_t run){
1508 
1509  TMap * grpRun = dynamic_cast<TMap *>((Instance()->fGRPMaps).GetValue(Form("%i",run)));
1510  if (!grpRun) {
1512  grpRun = dynamic_cast<TMap *>(Instance()->fGRPMaps.GetValue(Form("%i",run)));
1513  if (!grpRun) return 0;
1514  }
1515  return grpRun;
1516 }
1517 
1518 
1525 
1526 
1527  TMap *map = GetGRPMap(run);
1528  if (map){
1529  AliDCSSensor * sensor = 0;
1530  TObject *osensor=0;
1531  if (type==0) osensor = ((*map)("fCavernPressure"));
1532  if (type==1) osensor = ((*map)("fP2Pressure"));
1533  sensor =dynamic_cast<AliDCSSensor *>(osensor);
1534  if (sensor) return sensor;
1535  }
1536  //
1537  // If not map try to get it from the GRPObject
1538  //
1539  AliGRPObject * grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.GetValue(Form("%i",run)));
1540  if (!grpRun) {
1541  UpdateRunInformations(run);
1542  grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.GetValue(Form("%i",run)));
1543  if (!grpRun) return 0;
1544  }
1545  AliDCSSensor * sensor = grpRun->GetCavernAtmosPressure();
1546  if (type==1) sensor = grpRun->GetSurfaceAtmosPressure();
1547  return sensor;
1548 }
1549 
1552 
1553  AliTPCSensorTempArray * tempArray = (AliTPCSensorTempArray *)fTemperatureArray.GetValue(Form("%i",run));
1554  if (!tempArray) {
1555  UpdateRunInformations(run);
1556  tempArray = (AliTPCSensorTempArray *)fTemperatureArray.GetValue(Form("%i",run));
1557  }
1558  return tempArray;
1559 }
1560 
1561 
1564 
1565  TObjArray * gainSplines = (TObjArray *)fTimeGainSplinesArray.GetValue(Form("%i",run));
1566  if (!gainSplines) {
1567  UpdateRunInformations(run);
1568  gainSplines = (TObjArray *)fTimeGainSplinesArray.GetValue(Form("%i",run));
1569  }
1570  return gainSplines;
1571 }
1572 
1575 
1576  TObjArray * driftSplines = (TObjArray *)fDriftCorrectionArray.GetValue(Form("%i",run));
1577  if (!driftSplines) {
1578  UpdateRunInformations(run);
1579  driftSplines = (TObjArray *)fDriftCorrectionArray.GetValue(Form("%i",run));
1580  }
1581  return driftSplines;
1582 }
1583 
1586 
1587  AliDCSSensorArray * voltageArray = (AliDCSSensorArray *)fVoltageArray.GetValue(Form("%i",run));
1588  if (!voltageArray) {
1589  UpdateRunInformations(run);
1590  voltageArray = (AliDCSSensorArray *)fVoltageArray.GetValue(Form("%i",run));
1591  }
1592  return voltageArray;
1593 }
1594 
1597 
1598  AliDCSSensorArray * goofieArray = (AliDCSSensorArray *)fGoofieArray.GetValue(Form("%i",run));
1599  if (!goofieArray) {
1600  UpdateRunInformations(run);
1601  goofieArray = (AliDCSSensorArray *)fGoofieArray.GetValue(Form("%i",run));
1602  }
1603  return goofieArray;
1604 }
1605 
1606 
1607 
1610 
1611  AliTPCCalibVdrift * vdrift = (AliTPCCalibVdrift*)fVdriftArray.GetValue(Form("%i",run));
1612  if (!vdrift) {
1613  UpdateRunInformations(run);
1614  vdrift= (AliTPCCalibVdrift*)fVdriftArray.GetValue(Form("%i",run));
1615  }
1616  return vdrift;
1617 }
1618 
1619 Float_t AliTPCcalibDB::GetCEdriftTime(Int_t run, Int_t sector, Double_t timeStamp, Int_t *entries)
1620 {
1625 
1627  TGraph *gr=AliTPCcalibDB::Instance()->GetCErocTgraph(sector);
1628  if (!gr||sector<0||sector>73) {
1629  if (entries) *entries=0;
1630  return 0.;
1631  }
1632  Float_t val=0.;
1633  if (timeStamp==-1.){
1634  val=gr->GetMean(2);
1635  }else{
1636  for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
1637  Double_t x,y;
1638  gr->GetPoint(ipoint,x,y);
1639  if (x<timeStamp) continue;
1640  val=y;
1641  break;
1642  }
1643  }
1644  return val;
1645 }
1646 
1647 Float_t AliTPCcalibDB::GetCEchargeTime(Int_t run, Int_t sector, Double_t timeStamp, Int_t *entries)
1648 {
1651 
1653  TGraph *gr=AliTPCcalibDB::Instance()->GetCErocQgraph(sector);
1654  if (!gr||sector<0||sector>71) {
1655  if (entries) *entries=0;
1656  return 0.;
1657  }
1658  Float_t val=0.;
1659  if (timeStamp==-1.){
1660  val=gr->GetMean(2);
1661  }else{
1662  for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
1663  Double_t x,y;
1664  gr->GetPoint(ipoint,x,y);
1665  if (x<timeStamp) continue;
1666  val=y;
1667  break;
1668  }
1669  }
1670  return val;
1671 }
1672 
1673 Float_t AliTPCcalibDB::GetDCSSensorValue(AliDCSSensorArray *arr, Int_t timeStamp, const char * sensorName, Int_t sigDigits)
1674 {
1676 
1677  Float_t val=0;
1678  const TString sensorNameString(sensorName);
1679  AliDCSSensor *sensor = arr->GetSensor(sensorNameString);
1680  if (!sensor) return val;
1681 
1682  const Int_t startTime = Int_t(sensor->GetStartTime());
1683  const Int_t endTime = Int_t(sensor->GetEndTime());
1684 
1685  //use the dcs graph if possible
1686  TGraph *gr=sensor->GetGraph();
1687  if (gr){
1688  for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
1689  Double_t x,y;
1690  gr->GetPoint(ipoint,x,y);
1691  const Int_t time=TMath::Nint(startTime+x*3600.); //time in graph is hours
1692  if (time<=timeStamp && timeStamp<=endTime) {
1693  val=y;
1694  continue;
1695  }
1696  break;
1697  }
1698  //if val is still 0, test if if the requested time is within 5min of the first/last
1699  //data point or start/end time of the sensor. If this is the case return the firs/last entry
1700  //the timestamps might not be syncronised for all calibration types, sometimes a 'pre'
1701  //and 'pos' period is requested. Especially to the HV this is not the case!
1702  //first point
1703  if (val==0 ){
1704  Double_t x,y;
1705  gr->GetPoint(0,x,y);
1706  const Int_t time=TMath::Min(TMath::Nint(startTime+x*3600.), startTime); //time in graph is hours
1707  const Int_t dtime=time-timeStamp;
1708  if ( (dtime>=0) && (dtime<5*60) ) val=y;
1709  }
1710  //last point
1711  if (val==0 ){
1712  Double_t x,y;
1713  gr->GetPoint(gr->GetN()-1,x,y);
1714  const Int_t time=TMath::Max(TMath::Nint(startTime+x*3600.), endTime); //time in graph is hours
1715  const Int_t dtime=timeStamp-time;
1716  if ( (dtime>=0) && (dtime<5*60) ) val=y;
1717  }
1718  } else {
1719  val=sensor->GetValue(timeStamp);
1720  }
1721  if (sigDigits>=0){
1722  val=(Float_t)TMath::Floor(val * TMath::Power(10., sigDigits) + .5) / TMath::Power(10., sigDigits);
1723  }
1724  return val;
1725 }
1726 
1727 Float_t AliTPCcalibDB::GetDCSSensorMeanValue(AliDCSSensorArray *arr, const char * sensorName, Int_t sigDigits)
1728 {
1730 
1731  Float_t val=0;
1732  const TString sensorNameString(sensorName);
1733  AliDCSSensor *sensor = arr->GetSensor(sensorNameString);
1734  if (!sensor) return val;
1735 
1736  //use dcs graph if it exists
1737  TGraph *gr=sensor->GetGraph();
1738  if (gr){
1739  val=gr->GetMean(2);
1740  } else {
1741  //if we don't have the dcs graph, try to get some meaningful information
1742  if (!sensor->GetFit()) return val;
1743  Int_t nKnots=sensor->GetFit()->GetKnots();
1744  Double_t tMid=(sensor->GetEndTime()-sensor->GetStartTime())/2.;
1745  for (Int_t iKnot=0;iKnot<nKnots;++iKnot){
1746  if (sensor->GetFit()->GetX()[iKnot]>tMid/3600.) break;
1747  val=(Float_t)sensor->GetFit()->GetY0()[iKnot];
1748  }
1749  }
1750  if (sigDigits>=0){
1751  // val/=10;
1752  val=(Float_t)TMath::Floor(val * TMath::Power(10., sigDigits) + .5) / TMath::Power(10., sigDigits);
1753  // val*=10;
1754  }
1755  return val;
1756 }
1757 
1759 {
1760  // set bits for masked pads
1761  int nrowsMasked=0,npadsMasked=0,npadsTotMasked=0;
1763  AliInfo("Special reconstruction for residuals extraction, masking is disabled");
1764  return 0;
1765  }
1767  AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
1768  if (!fld || !man->IsDefaultStorageSet() || man->GetRun()<0) {
1769  AliFatal("OCDB of B-field is not initialized");
1770  }
1771  const int run = GetRun();
1772  // pick the recoparam matching to field (as low or high flux)
1774  /*
1775  AliRecoParam::EventSpecie_t spec = fld->GetBeamType()==AliMagF::kBeamTypeAA ? AliRecoParam::kHighMult : AliRecoParam::kLowMult;
1776  int parID=0;
1777  while( (param=GetRecoParam(parID++)) ) { if (param->GetEventSpecie()&spec) break;}
1778  */
1779  if (!param) AliFatal("Failed to extract recoparam");
1780  //
1781  if (!param->GetUseCorrectionMap()) {
1782  AliInfo("Residual correction maps are not used, no masking needed");
1783  return 0;
1784  }
1785 
1786  AliTPCTransform* transform = GetTransform();
1787  if (!transform) AliFatal("Failed to extract Transform");
1788  transform->SetCurrentRecoParam(param);
1789 
1790  // Load maps covering the run and build masks for disable full rows
1791  //
1792  // get reference map
1794  //
1795  // get correction maps
1797  arrMaps->SetOwner(kTRUE);
1798  if (!((AliTPCChebCorr*)arrMaps->UncheckedAt(0))->GetTimeDependent()) {
1799  // static maps are field-dependent
1801  arrMaps->Remove((TObject*)mapKeep);
1802  arrMaps->Delete();
1803  arrMaps->Add(mapKeep); // leave only maps needed for this run if the object was default one
1804  }
1805  int nMaps = arrMaps->GetEntriesFast();
1806 
1807  // mask full rows disabled in at least one of the maps
1808  TBits maskedRows[72];
1809  for (int isec=72;isec--;) { // flag masked full rows
1810  mapRef->GetNMaskedRows(isec,&maskedRows[isec]);
1811  for (int imap=nMaps;imap--;) ((AliTPCChebCorr*)arrMaps->UncheckedAt(imap))->GetNMaskedRows(isec,&maskedRows[isec]);
1812  const Int_t nrowsMaskedROC = maskedRows[isec].CountBits();
1813  nrowsMasked += nrowsMaskedROC;
1814  if (nrowsMaskedROC>0) AliInfoF("%3d rows masked in ROC%02d",nrowsMaskedROC,isec);
1815  }
1816  //
1817  // Now we need to mask individual pads where the assigned errors or distortions are too large
1818  // Since >1 map may cover the run, we query all off them in their central time stamps
1819  // 1) Make sure the maps are unique for this run
1820  AliGRPObject* grp = GetGRP(run);
1821  time_t tGRPmin = grp->GetTimeStart();
1822  time_t tGRPmax = grp->GetTimeEnd();
1823  time_t tCentGRP = (tGRPmin+tGRPmax)/2; // center of the run according to grp
1824  //
1825  time_t mapsT[nMaps];
1826  for (int i=0;i<nMaps;i++) {
1827  mapsT[i] = ((AliTPCChebCorr*)arrMaps->At(i))->GetTimeStampCenter();
1828  if (mapsT[i]<tGRPmin || mapsT[i]>tGRPmax) mapsT[i] = tCentGRP;
1829  }
1830  //
1831  delete arrMaps; // we don't need anymore these maps, Transform will load according to time stamp
1832  delete mapRef;
1833  //
1834  AliTPCROC* roc = AliTPCROC::Instance();
1835  double testv[3]={0.};
1836 
1837  // determine ranges for time-bin to be assigned to test cluster
1838  transform->SetCurrentTimeStamp(mapsT[0]);
1839  const double tbinMin=0.,tbinMax=800.0;
1840  testv[0] = 62.; testv[1] = 0.; testv[2] = tbinMin; // at highest pad of IROC, min drift-time
1841  transform->Local2RotatedGlobal(0,testv);
1842  const double ztMin = testv[2];
1843  testv[0] = 62.; testv[1] = 0.; testv[2] = tbinMax; // at highest pad of IROC, max drift-time
1844  transform->Local2RotatedGlobal(0,testv);
1845  const double ztMax = testv[2];
1846  const double tzSlope = (tbinMax-tbinMin)/(ztMax-ztMin);
1847  //
1848  // for test only >>>>>>>>>>
1849  // double *mxdist = (double*)param->GetBadPadMaxDistXYZ();
1850  // double *mxerr = (double*)param->GetBadPadMaxErrYZ();
1851  // mxdist[0] = 7.; mxdist[1] = 7.; mxdist[2] = 7.;
1852  // mxerr[0] = 2.; mxerr[1] = 2.;
1853  // for test only <<<<<<<<<<
1854  const double *padMaxDist = param->GetBadPadMaxDistXYZD();
1855  const double *padMaxErr = param->GetBadClusMaxErrYZ();
1856  const double maxErrY2 = padMaxErr[0]>0 ? padMaxErr[0]*padMaxErr[0] : -1.;
1857  const double maxErrZ2 = padMaxErr[1]>0 ? padMaxErr[1]*padMaxErr[1] : -1.;
1858  //
1859  const float tgLabTest = 0.2f; // check distortions/errors for this pad for high pt track at tgLab=0.2
1860  AliTPCclusterMI clProbe;
1861  for (int imap=0;imap<nMaps;imap++) {
1862  AliInfoF("Querying maps at time %ld",mapsT[imap]);
1863  transform->SetCurrentTimeStamp(mapsT[imap]);
1864  //
1865  for (int isec=72;isec--;) {
1866  TBits& padStatus = maskedPads[isec];
1867  for (int irow=roc->GetNRows(isec);irow--;) {
1868  const int npads = roc->GetNPads(isec, irow), channel0 = roc->GetRowIndexes(isec)[irow];
1869  if (maskedRows[isec].TestBitNumber(irow)) { // full row is masked
1870  for (int ipad=npads;ipad--;) padStatus.SetBitNumber(channel0+ipad); // mask all pads of the row
1871  //printf("ROC%d masked %d pads of full row %d\n",isec,npads,irow);
1872  npadsTotMasked += npads;
1873  continue;
1874  }
1875  const double xRow = roc->GetPadRowRadii(isec,irow), zTest = xRow*tgLabTest;
1876  const double tbinTest = tbinMin+(zTest-ztMin)*tzSlope; // define tbin at which distortions/errors will be evaluated
1877  for (int ipad=npads;ipad--;) {
1878  testv[0] = irow;
1879  testv[1] = 0.5+ipad; // pad center
1880  testv[2] = tbinTest;
1881  transform->Transform(testv,&isec,0,0);
1882  const float* clCorr = transform->GetLastMapCorrection();
1883  const float* clCorrRef = transform->GetLastMapCorrectionRef();
1884  Bool_t bad = kFALSE;
1885 
1886  // does the distortion exceed max.allowed?
1887  for (int dir=4;dir--;) if (padMaxDist[dir]>0. && TMath::Abs(clCorr[dir])>padMaxDist[dir]) {
1888  bad=kTRUE;
1889  // printf("ROC%2d row%2d pad%2d bad: distortion[%d]=%.2f exceeds threshold %.2f\n",
1890  // isec,npads,irow,dir,clCorr[dir],padMaxDist[dir]);
1891  break;
1892  }
1893 
1894  if (!bad) { // check errors assigned to such cluster
1895  clProbe.SetDetector(isec);
1896  clProbe.SetX(testv[0]); // store coordinates
1897  clProbe.SetY(testv[1]);
1898  clProbe.SetZ(testv[2]);
1899  clProbe.SetDistortions(clCorr[0]-clCorrRef[0],clCorr[1]-clCorrRef[1],clCorr[2]-clCorrRef[2]);
1900  clProbe.SetDistortionDispersion(clCorr[3]); // store distortions wrt ref and dispersion (ref already subtracted)
1901  const double errY2 = transform->ErrY2Syst(&clProbe,testv[1]/testv[0]);
1902  const double errZ2 = transform->ErrZ2Syst(&clProbe,testv[2]/testv[0]);
1903  if ( (maxErrY2>0 && errY2>maxErrY2) || (maxErrZ2>0 && errZ2>maxErrZ2) ) {
1904  bad=kTRUE;
1905  //printf("ROC%2d row%2d pad%2d bad: Errors^2 for Y:%.3e or Z:%.3e exceeds threshold %.3e|%.3e\n",
1906  // isec,npads,irow,errY2,errZ2,maxErrY2,maxErrZ2);
1907  }
1908  }
1909  //
1910  if (bad) {
1911  if (!padStatus.TestBitNumber(channel0+ipad)) npadsMasked++;
1912  padStatus.SetBitNumber(channel0+ipad);
1913  }
1914  } // loop over all pads of the row
1915  } // loop over all rows of the ROC
1916  } // loop over all ROCs
1917  } // loop over all maps
1918  //
1919  npadsTotMasked += npadsMasked;
1920  AliInfoF("masked %d pads (%d full padrows, %d individual pads)",
1921  npadsTotMasked,nrowsMasked,npadsMasked);
1922  transform->ResetCache();
1923  return npadsTotMasked;
1924  //
1925 }
1926 
1927 Bool_t AliTPCcalibDB::IsDataTakingActive(time_t timeStamp)
1928 {
1929  //
1930  // Check if the data taking is active.
1931  // This information ist based on the trigger scalers and calculated in UpdateChamberHighVoltageData() below.
1932  // in case there is no GRP object or no trigger scalers fGrRunState should be a NULL pointer
1933  // if this is the case we assume by default that the data taking is active
1934  // NOTE: The logik changed. Before v5-06-03-79-gc804e5a we assumed by default the data taking is inactive
1935  //
1936  if (!fGrRunState) return kTRUE;
1937  Double_t time=Double_t(timeStamp);
1938  Int_t currentPoint=0;
1939  Bool_t currentVal=fGrRunState->GetY()[currentPoint]>0.5;
1940  Bool_t retVal=currentVal;
1941  Double_t currentTime=fGrRunState->GetX()[currentPoint];
1942 
1943  while (time>currentTime){
1944  retVal=currentVal;
1945  if (currentPoint==fGrRunState->GetN()) break;
1946  currentVal=fGrRunState->GetY()[currentPoint]>0.5;
1947  currentTime=fGrRunState->GetX()[currentPoint];
1948  ++currentPoint;
1949  }
1950 
1951  return retVal;
1952 }
1953 
1955 {
1967 
1968  // reset active run state graph
1969  delete fGrRunState;
1970  fGrRunState=0x0;
1971 
1972  // start and end time of the run
1973  const Int_t run=GetRun();
1974  if (run<0) return;
1975 
1976  // if no valid run information - return
1977  AliGRPObject* grp = GetGRP(run);
1978  if (!grp) return;
1979 
1980  const Int_t startTimeGRP = grp->GetTimeStart();
1981  const Int_t stopTimeGRP = grp->GetTimeEnd();
1982 
1983  //
1984  // In case we use a generated GRP we cannot make use of the start time and end time information
1985  // therefore we cannot calculate proper HV information and will skip this
1986  //
1987  if (startTimeGRP==0 && stopTimeGRP==0) {
1988  AliWarning("Using a generated GRP with 'GetTimeStart()' and 'GetTimeEnd()' == 0. Cannot calculate HV information.");
1989  return;
1990  }
1991 
1992  //
1993  // check active state by analysing the scalers
1994  //
1995  // initialise graph with active running
1996  bool hltMode = getenv("HLT_ONLINE_MODE") && strcmp(getenv("HLT_ONLINE_MODE"), "on") == 0;
1997 
1998  AliCDBEntry *entry = NULL;
1999  if (!hltMode) entry = GetCDBEntry("GRP/CTP/Scalers");
2000  if (entry) {
2001  // entry->SetOwner(kTRUE);
2003  Int_t nchannels = sca->GetNumClasses(); // number of scaler channels (i.e. trigger classes)
2004  Int_t npoints = sca->GetScalersRecords()->GetEntries(); // number of samples
2005 
2006  // require at least two points from the scalers.
2007  if (npoints>1) {
2008  fGrRunState=new TGraph;
2009  fGrRunState->SetPoint(fGrRunState->GetN(),Double_t(startTimeGRP)-.001,0);
2010  fGrRunState->SetPoint(fGrRunState->GetN(),Double_t(startTimeGRP),1);
2011  ULong64_t lastSum=0;
2012  Double_t timeLast=Double_t(startTimeGRP);
2013  Bool_t active=kTRUE;
2014  for (int i=0; i<npoints; i++) {
2016  Double_t time = ((AliTimeStamp*) rec->GetTimeStamp())->GetSeconds();
2017  // check if time is inside the grp times. For dummy scaler entries the time might be compatible with 0
2018  if ( time<startTimeGRP || time>stopTimeGRP ){
2019  AliWarning(Form("Time of scaler record %d: %.0f is outside the GRP times (%d, %d). Skipping this record.", i, time, startTimeGRP, stopTimeGRP));
2020  continue;
2021  }
2022  ULong64_t sum=0;
2023  for (int j=0; j<nchannels; j++) sum += ((AliTriggerScalers*) rec->GetTriggerScalers()->At(j))->GetL2CA();
2024  if (TMath::Abs(time-timeLast)<.001 && sum==lastSum ) continue;
2025  if (active && sum==lastSum){
2026  fGrRunState->SetPoint(fGrRunState->GetN(),timeLast-.01,1);
2027  fGrRunState->SetPoint(fGrRunState->GetN(),timeLast,0);
2028  active=kFALSE;
2029  } else if (!active && sum>lastSum ){
2030  fGrRunState->SetPoint(fGrRunState->GetN(),timeLast-.01,0);
2031  fGrRunState->SetPoint(fGrRunState->GetN(),timeLast,1);
2032  active=kTRUE;
2033  }
2034  lastSum=sum;
2035  timeLast=time;
2036  }
2037  fGrRunState->SetPoint(fGrRunState->GetN(),Double_t(stopTimeGRP),active);
2038  fGrRunState->SetPoint(fGrRunState->GetN(),Double_t(stopTimeGRP)+.001,0);
2039  } else {
2040  AliWarning("Only one entry found in the trigger scalers. Most probably this is a dummy entry. Scaler information will not be used!");
2041  }
2042  }
2043 
2044 
2045  // reset all values
2046  for (Int_t iROC=0;iROC<72;++iROC) {
2047  fChamberHVmedian[iROC] = -1;
2048  fChamberHVgoodFraction[iROC] = 0.;
2049  fCurrentNominalVoltage[iROC] = -999.;
2050  fChamberHVStatus[iROC] = kFALSE;
2051  }
2052 
2053  AliDCSSensorArray* voltageArray = GetVoltageSensors(run);
2054  if (!voltageArray) {
2055  AliError("Voltage Array missing. Cannot calculate HV information!");
2056  AliError(" -> Check OCDB entry: 'TPC/Calib/HighVoltage'");
2057  return;
2058  }
2059 
2060  // max HV diffs before a chamber is masked
2061  const Float_t maxVdiff = fParam->GetMaxVoltageDeviation();
2062  const Float_t maxDipVoltage = fParam->GetMaxDipVoltage();
2063  const Float_t maxFracHVbad = fParam->GetMaxFractionHVbad();
2064 
2065  const Int_t samplingPeriod=1;
2066 
2067  // array with sampled voltages
2068  const Int_t maxSamples=(stopTimeGRP-startTimeGRP)/samplingPeriod + 10*samplingPeriod;
2069  Float_t *vSampled = new Float_t[maxSamples];
2070 
2071  // deviation of the median from the nominal voltage
2072  Double_t chamberMedianDeviation[72]={0.};
2073 
2074  for (Int_t iROC=0; iROC<72; ++iROC){
2075  chamberMedianDeviation[iROC]=0.;
2076  TString sensorName="";
2077  Char_t sideName='A';
2078  if ((iROC/18)%2==1) sideName='C';
2079  if (iROC<36) sensorName=Form("TPC_ANODE_I_%c%02d_VMEAS",sideName,iROC%18);
2080  else sensorName=Form("TPC_ANODE_O_%c%02d_0_VMEAS",sideName,iROC%18);
2081 
2082  AliDCSSensor *sensor = voltageArray->GetSensor(sensorName);
2083 
2084  fHVsensors[iROC]=sensor;
2085  if (!sensor) continue;
2086 
2087  Int_t nPointsSampled=0;
2088 
2089  TGraph *gr=sensor->GetGraph();
2090  if ( gr && gr->GetN()>0 ){
2091  //1. sample voltage over time
2092  // get a robust median
2093  // buffer sampled voltages
2094 
2095  // current sampling time
2096  Int_t time=startTimeGRP;
2097 
2098  // input graph sampling point
2099  const Int_t nGraph=gr->GetN();
2100  Int_t pointGraph=0;
2101 
2102  //initialise graph information
2103  Int_t timeGraph=stopTimeGRP;
2104  if (gr->GetN()>1) timeGraph=TMath::Nint(gr->GetX()[pointGraph+1]*3600+sensor->GetStartTime());
2105  Double_t sampledHV=gr->GetY()[pointGraph++];
2106 
2107  while (time<stopTimeGRP){
2108  while (timeGraph<=time && pointGraph+1<nGraph){
2109  timeGraph=TMath::Nint(gr->GetX()[pointGraph+1]*3600+sensor->GetStartTime());
2110  sampledHV=gr->GetY()[pointGraph++];
2111  }
2112  time+=samplingPeriod;
2113  if (!IsDataTakingActive(time-samplingPeriod)) continue;
2114  vSampled[nPointsSampled++]=sampledHV;
2115 
2116  // in case the last HV point is not the one at EOR (change in acceptance band
2117  // handling in the PreProcessor), the while loop above will not set the last
2118  // value in the active data taking period. Force this!
2119  if (pointGraph+1==nGraph) {
2120  sampledHV = gr->GetY()[nGraph-1];
2121  }
2122  }
2123 
2124  if (nPointsSampled<1) continue;
2125 
2126  fChamberHVmedian[iROC]=TMath::Median(nPointsSampled,vSampled);
2127  chamberMedianDeviation[iROC]=fChamberHVmedian[iROC]-fParam->GetNominalVoltage(iROC);
2128 
2129  //2. calculate good HV fraction
2130  Int_t ngood=0;
2131  for (Int_t ipoint=0; ipoint<nPointsSampled; ++ipoint) {
2132  if (TMath::Abs(vSampled[ipoint]-fChamberHVmedian[iROC])<maxDipVoltage) ++ngood;
2133  }
2134 
2135  fChamberHVgoodFraction[iROC]=Float_t(ngood)/Float_t(nPointsSampled);
2136  } else if (!gr && !sensor->GetFit() ){
2137  // This is an exception handling.
2138  // It was observed that for some rund in the 2010 data taking no HV info is available
2139  // for some sectors. However they were active. So take care about this
2140  fChamberHVmedian[iROC] = fParam->GetNominalVoltage(iROC);
2141  fChamberHVgoodFraction[iROC] = 1.;
2142  AliWarning(Form("ROC %d detected without HV Splines and HV graph. Will set median HV to nominal voltage",iROC));
2143  } else {
2144  AliError(Form("No Graph or graph without points found for HV sensor of ROC %d",iROC));
2145  }
2146  }
2147 
2148  delete [] vSampled;
2149  vSampled=0x0;
2150 
2151  // get median deviation from all chambers (detect e.g. -50V)
2152  const Double_t medianIROC=TMath::Median( 36, chamberMedianDeviation );
2153  const Double_t medianOROC=TMath::Median( 36, chamberMedianDeviation+36 );
2154 
2155  // Define current default voltages
2156  for (Int_t iROC=0;iROC<72/*AliTPCCalPad::kNsec*/;++iROC){
2157  const Float_t averageDeviation=(iROC<36)?medianIROC:medianOROC;
2158  fCurrentNominalVoltage[iROC]=fParam->GetNominalVoltage(iROC)+averageDeviation;
2159  }
2160 
2161  //
2162  // Check HV status
2163  //
2164  Int_t nbad=0;
2165  for (Int_t iROC=0;iROC<72/*AliTPCCalPad::kNsec*/;++iROC){
2166  fChamberHVStatus[iROC]=kTRUE;
2167  const Float_t averageDeviation=(iROC<36)?medianIROC:medianOROC;
2168 
2169  //a. Deviation of median from current nominal voltage
2170  // allow larger than nominal voltages
2171  if (fCurrentNominalVoltage[iROC]-fChamberHVmedian[iROC] > maxVdiff) {
2172  AliWarning(Form("Low voltage detected for ROC %2d",iROC));
2173  AliWarning(Form(" -> Based on nominal voltage: %.2f + averge deviation: %.2f = current nominal voltage: %.2f - meadian HV: %.2f > max diff: %.2f",
2174  fParam->GetNominalVoltage(iROC), averageDeviation, fCurrentNominalVoltage[iROC], fChamberHVmedian[iROC], maxVdiff));
2175  AliWarning(" -> Check consistent usage of HV information in the OCDB entry: 'TPC/Calib/HighVoltage'");
2176  AliWarning(" -> and the nominal voltages in the OCDB entry: 'TPC/Calib/Parameters'");
2177  fChamberHVStatus[iROC]=kFALSE;
2178  }
2179 
2180  //b. Fraction of bad hv values
2181  if ( 1.-fChamberHVgoodFraction[iROC] > maxFracHVbad ) {
2182  AliWarning(Form("Large fraction of low HV readings detected in ROC %2d: %.2f > %.2f",
2183  iROC, 1.-fChamberHVgoodFraction[iROC], maxFracHVbad));
2184  AliWarning(Form(" -> Based on HV information from OCDB entry: 'TPC/Calib/HighVoltage' with median voltage: %.2f", fChamberHVmedian[iROC]));
2185  AliWarning( " -> Check with experts if this chamber had HV problems in this run");
2186  fChamberHVStatus[iROC]=kFALSE;
2187  }
2188 
2189  if (!fChamberHVStatus[iROC]) {
2190  ++nbad;
2191  }
2192  }
2193 
2194  // check if all chamber are off
2195  if (nbad==72) {
2196  AliFatal("Something went wrong in the chamber HV status calculation. Check warning messages above. All chambers would be deactivated!");
2197  }
2198 }
2199 Float_t AliTPCcalibDB::GetGasSensorValue(EDcsGasSensor type, Int_t timeStamp/*=-1*/, Int_t sigDigits/*=-1*/)
2200 {
2203 
2204  if (!fGasSensorArray || Int_t(type)<0 || Int_t(type)>=Int_t(kNGasSensor) ) return 0.;
2205 
2206  // ===| Average value |===
2207  if (timeStamp==-1){
2209  }
2210 
2211  // ===| Value at given time stamp |===
2212  TTimeStamp stamp(timeStamp);
2213  return AliTPCcalibDB::GetDCSSensorValue(fGasSensorArray, timeStamp, fgkGasSensorNames[Int_t(type)], sigDigits);
2214 }
2215 
2216 
2217 Float_t AliTPCcalibDB::GetChamberHighVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits, Bool_t current) {
2220 
2221  Float_t val=0;
2222  TString sensorName="";
2223  TTimeStamp stamp(timeStamp);
2225  if (!voltageArray || (sector<0) || (sector>71)) return val;
2226  Char_t sideName='A';
2227  if ((sector/18)%2==1) sideName='C';
2228  if (sector<36){
2229  //IROC
2230  sensorName=Form("TPC_ANODE_I_%c%02d_VMEAS",sideName,sector%18);
2231  }else{
2232  //OROC
2233  sensorName=Form("TPC_ANODE_O_%c%02d_0_VMEAS",sideName,sector%18);
2234  }
2235  if (current){
2236  if (sector<36){
2237  //IROC
2238  sensorName=Form("TPC_ANODE_I_%c%02d_IMEAS",sideName,sector%18);
2239  }else{
2240  //OROC
2241  sensorName=Form("TPC_ANODE_O_%c%02d_0_IMEAS",sideName,sector%18);
2242  }
2243 
2244  }
2245  if (timeStamp==-1){
2246  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2247  } else {
2248  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2249  }
2250  return val;
2251 }
2252 Float_t AliTPCcalibDB::GetSkirtVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
2253 {
2257 
2258  Float_t val=0;
2259  TString sensorName="";
2260  TTimeStamp stamp(timeStamp);
2262  if (!voltageArray || (sector<0) || (sector>71)) return val;
2263  Char_t sideName='A';
2264  if ((sector/18)%2==1) sideName='C';
2265  sensorName=Form("TPC_SKIRT_%c_VMEAS",sideName);
2266  if (timeStamp==-1){
2267  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2268  } else {
2269  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2270  }
2271  return val;
2272 }
2273 
2274 Float_t AliTPCcalibDB::GetCoverVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
2275 {
2279 
2280  Float_t val=0;
2281  TString sensorName="";
2282  TTimeStamp stamp(timeStamp);
2284  if (!voltageArray || (sector<0) || (sector>71)) return val;
2285  Char_t sideName='A';
2286  if ((sector/18)%2==1) sideName='C';
2287  if (sector<36){
2288  //IROC
2289  sensorName=Form("TPC_COVER_I_%c_VMEAS",sideName);
2290  }else{
2291  //OROC
2292  sensorName=Form("TPC_COVER_O_%c_VMEAS",sideName);
2293  }
2294  if (timeStamp==-1){
2295  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2296  } else {
2297  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2298  }
2299  return val;
2300 }
2301 
2302 Float_t AliTPCcalibDB::GetGGoffsetVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
2303 {
2307 
2308  Float_t val=0;
2309  TString sensorName="";
2310  TTimeStamp stamp(timeStamp);
2312  if (!voltageArray || (sector<0) || (sector>71)) return val;
2313  Char_t sideName='A';
2314  if ((sector/18)%2==1) sideName='C';
2315  if (sector<36){
2316  //IROC
2317  sensorName=Form("TPC_GATE_I_%c_OFF_VMEAS",sideName);
2318  }else{
2319  //OROC
2320  sensorName=Form("TPC_GATE_O_%c_OFF_VMEAS",sideName);
2321  }
2322  if (timeStamp==-1){
2323  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2324  } else {
2325  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2326  }
2327  return val;
2328 }
2329 
2330 Float_t AliTPCcalibDB::GetGGnegVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
2331 {
2335 
2336  Float_t val=0;
2337  TString sensorName="";
2338  TTimeStamp stamp(timeStamp);
2340  if (!voltageArray || (sector<0) || (sector>71)) return val;
2341  Char_t sideName='A';
2342  if ((sector/18)%2==1) sideName='C';
2343  if (sector<36){
2344  //IROC
2345  sensorName=Form("TPC_GATE_I_%c_NEG_VMEAS",sideName);
2346  }else{
2347  //OROC
2348  sensorName=Form("TPC_GATE_O_%c_NEG_VMEAS",sideName);
2349  }
2350  if (timeStamp==-1){
2351  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2352  } else {
2353  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2354  }
2355  return val;
2356 }
2357 
2358 Float_t AliTPCcalibDB::GetGGposVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
2359 {
2363 
2364  Float_t val=0;
2365  TString sensorName="";
2366  TTimeStamp stamp(timeStamp);
2368  if (!voltageArray || (sector<0) || (sector>71)) return val;
2369  Char_t sideName='A';
2370  if ((sector/18)%2==1) sideName='C';
2371  if (sector<36){
2372  //IROC
2373  sensorName=Form("TPC_GATE_I_%c_POS_VMEAS",sideName);
2374  }else{
2375  //OROC
2376  sensorName=Form("TPC_GATE_O_%c_POS_VMEAS",sideName);
2377  }
2378  if (timeStamp==-1){
2379  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2380  } else {
2381  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2382  }
2383  return val;
2384 }
2385 
2386 Float_t AliTPCcalibDB::GetPressure(Int_t timeStamp, Int_t run, Int_t type){
2388 
2389  TTimeStamp stamp(timeStamp);
2390  AliDCSSensor * sensor = Instance()->GetPressureSensor(run,type);
2391  if (!sensor) return 0;
2392  return sensor->GetValue(stamp);
2393 }
2394 
2395 Float_t AliTPCcalibDB::GetL3Current(Int_t run, Int_t statType){
2398 
2399  Float_t current=-1;
2401  if (grp) current=grp->GetL3Current((AliGRPObject::Stats)statType);
2402  return current;
2403 }
2404 
2405 Float_t AliTPCcalibDB::GetBz(Int_t run){
2407 
2408  Float_t bz=-1;
2409  Float_t current=AliTPCcalibDB::GetL3Current(run);
2410  if (current>-1) bz=5*current/30000.*.1;
2411  return bz;
2412 }
2413 
2414 Char_t AliTPCcalibDB::GetL3Polarity(Int_t run) {
2416 
2417  Char_t pol=-100;
2419  if (grp) pol=grp->GetL3Polarity();
2420  return pol;
2421 }
2422 
2423 TString AliTPCcalibDB::GetRunType(Int_t run){
2425 
2426 // TString type("UNKNOWN");
2428  if (grp) return grp->GetRunType();
2429  return "UNKNOWN";
2430 }
2431 
2432 Float_t AliTPCcalibDB::GetValueGoofie(Int_t timeStamp, Int_t run, Int_t type){
2434 
2435  TTimeStamp stamp(timeStamp);
2437  if (!goofieArray) return 0;
2438  AliDCSSensor *sensor = goofieArray->GetSensor(type);
2439  return sensor->GetValue(stamp);
2440 }
2441 
2442 
2443 
2444 
2445 
2446 
2447 Bool_t AliTPCcalibDB::GetTemperatureFit(Int_t timeStamp, Int_t run, Int_t side,TVectorD& fit){
2449 
2450  TTimeStamp tstamp(timeStamp);
2452  if (! tempArray) return kFALSE;
2453  AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray);
2454  TLinearFitter * fitter = tempMap->GetLinearFitter(3,side,tstamp);
2455  if (fitter){
2456  fitter->Eval();
2457  fitter->GetParameters(fit);
2458  }
2459  delete fitter;
2460  delete tempMap;
2461  if (!fitter) return kFALSE;
2462  return kTRUE;
2463 }
2464 
2465 Float_t AliTPCcalibDB::GetTemperature(Int_t timeStamp, Int_t run, Int_t side){
2467 
2468  TVectorD vec(5);
2469  if (side==0) {
2470  GetTemperatureFit(timeStamp,run,0,vec);
2471  return vec[0];
2472  }
2473  if (side==1){
2474  GetTemperatureFit(timeStamp,run,0,vec);
2475  return vec[0];
2476  }
2477  return 0;
2478 }
2479 
2480 
2481 Double_t AliTPCcalibDB::GetPTRelative(UInt_t timeSec, Int_t run, Int_t side){
2486 
2488  if (!vdrift) return 0;
2489  return vdrift->GetPTRelative(timeSec,side);
2490 }
2491 
2496 
2497  if (!map) return 0;
2498  AliDCSSensor * sensor = 0;
2499  TObject *osensor=0;
2500  osensor = ((*map)("fP2Pressure"));
2501  sensor =dynamic_cast<AliDCSSensor *>(osensor);
2502  //
2503  if (!sensor) return 0;
2504  //
2505  AliDCSSensor * sensor2 = new AliDCSSensor(*sensor);
2506  osensor = ((*map)("fCavernPressure"));
2507  TGraph * gr = new TGraph(2);
2508  gr->GetX()[0]= -100000.;
2509  gr->GetX()[1]= 1000000.;
2510  gr->GetY()[0]= atof(osensor->GetName());
2511  gr->GetY()[1]= atof(osensor->GetName());
2512  sensor2->SetGraph(gr);
2513  sensor2->SetFit(0);
2514 
2515 
2516  AliGRPObject *grpRun = new AliGRPObject;
2517  grpRun->ReadValuesFromMap(map);
2518  grpRun->SetCavernAtmosPressure(sensor2);
2519  grpRun->SetCavernAtmosPressure(sensor2);
2520  grpRun->SetSurfaceAtmosPressure(sensor);
2521  return grpRun;
2522 }
2523 
2524 Bool_t AliTPCcalibDB::CreateGUITree(Int_t run, const char* filename)
2525 {
2527 
2528  if (!AliCDBManager::Instance()->GetDefaultStorage()){
2529  AliLog::Message(AliLog::kError, "Default Storage not set. Cannot create Calibration Tree!",
2530  MODULENAME(), "AliTPCcalibDB", FUNCTIONNAME(), __FILE__, __LINE__);
2531  return kFALSE;
2532  }
2533  //db instance
2535  // retrieve cal pad objects
2536  db->SetRun(run);
2537  db->CreateGUITree(filename);
2538  return kTRUE;
2539 }
2540 
2541 Bool_t AliTPCcalibDB::CreateGUITree(const char* filename){
2543 
2544  if (!AliCDBManager::Instance()->GetDefaultStorage()){
2545  AliError("Default Storage not set. Cannot create calibration Tree!");
2546  return kFALSE;
2547  }
2548  UpdateNonRec(); // load all infromation now
2549 
2552 
2553  // gain map
2555  //noise and pedestals
2556  if (GetPedestals()) prep.AddComponent(new AliTPCCalPad(*(GetPedestals())));
2557  if (GetPadNoise() ) prep.AddComponent(new AliTPCCalPad(*(GetPadNoise())));
2558  //pulser data
2559  if (GetPulserTmean()) prep.AddComponent(new AliTPCCalPad(*(GetPulserTmean())));
2560  if (GetPulserTrms() ) prep.AddComponent(new AliTPCCalPad(*(GetPulserTrms())));
2561  if (GetPulserQmean()) prep.AddComponent(new AliTPCCalPad(*(GetPulserQmean())));
2562  //CE data
2563  if (GetCETmean()) prep.AddComponent(new AliTPCCalPad(*(GetCETmean())));
2564  if (GetCETrms() ) prep.AddComponent(new AliTPCCalPad(*(GetCETrms())));
2565  if (GetCEQmean()) prep.AddComponent(new AliTPCCalPad(*(GetCEQmean())));
2566  //Altro data
2568  if (GetALTROZsThr() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROZsThr() )));
2569  if (GetALTROFPED() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROFPED() )));
2570  if (GetALTROAcqStop() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROAcqStop() )));
2571  if (GetALTROMasked() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROMasked() )));
2572  //QA
2573  AliTPCdataQA *dataQA=GetDataQA();
2574  if (dataQA) {
2575  if (dataQA->GetNLocalMaxima())
2576  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNLocalMaxima())));
2577  if (dataQA->GetMaxCharge())
2578  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetMaxCharge())));
2579  if (dataQA->GetMeanCharge())
2580  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetMeanCharge())));
2581  if (dataQA->GetNoThreshold())
2582  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNoThreshold())));
2583  if (dataQA->GetNTimeBins())
2584  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNTimeBins())));
2585  if (dataQA->GetNPads())
2586  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNPads())));
2587  if (dataQA->GetTimePosition())
2588  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetTimePosition())));
2589  }
2590 
2591  //
2592  TString file(filename);
2593  if (file.IsNull()) file=Form("guiTreeRun_%i.root",fRun);
2594  prep.DumpToFile(file.Data());
2595  return kTRUE;
2596 }
2597 
2598 Bool_t AliTPCcalibDB::CreateRefFile(Int_t run, const char* filename)
2599 {
2601 
2602  if (!AliCDBManager::Instance()->GetDefaultStorage()){
2603  AliLog::Message(AliLog::kError, "Default Storage not set. Cannot create Calibration Tree!",
2604  MODULENAME(), "AliTPCcalibDB", FUNCTIONNAME(), __FILE__, __LINE__);
2605  return kFALSE;
2606  }
2607  TString file(filename);
2608  if (file.IsNull()) file=Form("RefCalPads_%d.root",run);
2609  TDirectory *currDir=gDirectory;
2610  //db instance
2612  // retrieve cal pad objects
2613  db->SetRun(run);
2614  //open file
2615  TFile f(file.Data(),"recreate");
2616  //noise and pedestals
2617  db->GetPedestals()->Write("Pedestals");
2618  db->GetPadNoise()->Write("PadNoise");
2619  //pulser data
2620  db->GetPulserTmean()->Write("PulserTmean");
2621  db->GetPulserTrms()->Write("PulserTrms");
2622  db->GetPulserQmean()->Write("PulserQmean");
2623  //CE data
2624  db->GetCETmean()->Write("CETmean");
2625  db->GetCETrms()->Write("CETrms");
2626  db->GetCEQmean()->Write("CEQmean");
2627  //Altro data
2628  db->GetALTROAcqStart() ->Write("ALTROAcqStart");
2629  db->GetALTROZsThr() ->Write("ALTROZsThr");
2630  db->GetALTROFPED() ->Write("ALTROFPED");
2631  db->GetALTROAcqStop() ->Write("ALTROAcqStop");
2632  db->GetALTROMasked() ->Write("ALTROMasked");
2633  //
2634  f.Close();
2635  currDir->cd();
2636  return kTRUE;
2637 }
2638 
2639 
2640 
2641 Double_t AliTPCcalibDB::GetVDriftCorrectionTime(Int_t timeStamp, Int_t run, Int_t /*side*/, Int_t mode){
2651 
2652  Double_t result=0;
2653  // mode 1 automatic mode - according to the distance to the valid calibration
2654  // -
2655  Double_t deltaP=0, driftP=0, wP = 0.;
2656  Double_t deltaITS=0,driftITS=0, wITS= 0.;
2657  Double_t deltaLT=0, driftLT=0, wLT = 0.;
2658  Double_t deltaCE=0, driftCE=0, wCE = 0.;
2659  driftP = fDButil->GetVDriftTPC(deltaP,run,timeStamp);
2660  driftITS= fDButil->GetVDriftTPCITS(deltaITS,run,timeStamp);
2661  driftCE = fDButil->GetVDriftTPCCE(deltaCE, run,timeStamp,36000,2);
2662  driftLT = fDButil->GetVDriftTPCLaserTracks(deltaLT,run,timeStamp,36000,2);
2663  deltaITS = TMath::Abs(deltaITS);
2664  deltaP = TMath::Abs(deltaP);
2665  deltaLT = TMath::Abs(deltaLT);
2666  deltaCE = TMath::Abs(deltaCE);
2667  if (mode==1) {
2668  const Double_t kEpsilon=0.00000000001;
2669  const Double_t kdeltaT=360.; // 10 minutes
2670  if(TMath::Abs(deltaITS) < 12*kdeltaT) {
2671  result = driftITS;
2672  } else {
2673  wITS = 64.*kdeltaT/(deltaITS +kdeltaT);
2674  wLT = 16.*kdeltaT/(deltaLT +kdeltaT);
2675  wP = 0. *kdeltaT/(deltaP +kdeltaT);
2676  wCE = 1. *kdeltaT/(deltaCE +kdeltaT);
2677  //
2678  //
2679  if (TMath::Abs(driftP)<kEpsilon) wP=0; // invalid calibration
2680  if (TMath::Abs(driftITS)<kEpsilon)wITS=0; // invalid calibration
2681  if (TMath::Abs(driftLT)<kEpsilon) wLT=0; // invalid calibration
2682  if (TMath::Abs(driftCE)<kEpsilon) wCE=0; // invalid calibration
2683  if (wP+wITS+wLT+wCE<kEpsilon) return 0;
2684  result = (driftP*wP+driftITS*wITS+driftLT*wLT+driftCE*wCE)/(wP+wITS+wLT+wCE);
2685  }
2686 
2687 
2688  }
2689 
2690  return result;
2691 }
2692 
2693 Double_t AliTPCcalibDB::GetTime0CorrectionTime(Int_t timeStamp, Int_t run, Int_t /*side*/, Int_t mode){
2704 
2705  Double_t result=0;
2706  if (mode==2) {
2707  // TPC-TPC mode
2708  result=fDButil->GetTriggerOffsetTPC(run,timeStamp);
2709  result *=fParam->GetZLength();
2710  }
2711  if (mode==1){
2712  // TPC-ITS mode
2713  Double_t dist=0;
2714  result= -fDButil->GetTime0TPCITS(dist, run, timeStamp)*fParam->GetDriftV()/1000000.;
2715  }
2716  return result;
2717 
2718 }
2719 
2720 
2721 
2722 
2723 Double_t AliTPCcalibDB::GetVDriftCorrectionGy(Int_t timeStamp, Int_t run, Int_t side, Int_t /*mode*/){
2734 
2735  if (run<=0 && fTransform) run = fTransform->GetCurrentRunNumber();
2736  UpdateRunInformations(run,kFALSE);
2738  if (!array) return 0;
2739  Double_t result=0;
2740 
2741  // use TPC-ITS if present
2742  TGraphErrors *gr= (TGraphErrors*)array->FindObject("ALIGN_ITSB_TPC_VDGY");
2743  if (!gr) gr = (TGraphErrors*)array->FindObject("ALIGN_TOFB_TPC_VDGY");
2744  if(gr) {
2745  result = AliTPCcalibDButil::EvalGraphConst(gr,timeStamp);
2746 
2747  // transform from [(cm/mus)/ m] to [1/cm]
2748  result /= (fParam->GetDriftV()/1000000.);
2749  result /= 100.;
2750 
2751  //printf("result %e \n", result);
2752  return result;
2753  }
2754 
2755  // use laser if ITS-TPC not present
2756  TGraphErrors *laserA= (TGraphErrors*)array->FindObject("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_A");
2757  TGraphErrors *laserC= (TGraphErrors*)array->FindObject("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_C");
2758 
2759  if (laserA && laserC){
2760  result= (laserA->Eval(timeStamp)+laserC->Eval(timeStamp))*0.5;
2761  }
2762  if (laserA && side==0){
2763  result = (laserA->Eval(timeStamp));
2764  }
2765  if (laserC &&side==1){
2766  result = (laserC->Eval(timeStamp));
2767  }
2768  //printf("laser result %e \n", -result/250.);
2769 
2770  return -result/250.; //normalized before
2771 }
2772 
2773 
2774 Double_t AliTPCcalibDB::GetVDriftCorrectionDeltaZ(Int_t /*timeStamp*/, Int_t run, Int_t /*side*/, Int_t /*mode*/){
2777 
2778  // Arguments:
2779  // mode determines the algorith how to combine the Laser Track, LaserCE or TPC-ITS
2780  // timestamp - not used
2781  // run - run number
2782  // side - common for boith sides
2783  //
2784  if (run<=0 && fTransform) run = fTransform->GetCurrentRunNumber();
2785  UpdateRunInformations(run,kFALSE);
2787  if (!array) return 0;
2788  Double_t result=0;
2789 
2790  // use TPC-ITS if present
2791  TGraphErrors *gr= (TGraphErrors*)array->FindObject("ALIGN_ITSB_TPC_DELTAZ");
2792  if(gr) {
2793  result = TMath::Mean(gr->GetN(), gr->GetY());
2794  }
2795  return result;
2796 }
2797 
2798 
2799 
2800 
2801 AliTPCCalPad* AliTPCcalibDB::MakeDeadMap(Double_t notInMap, const char* nameMappingFile) {
2808 
2809  char chinfo[1000];
2810 
2811  TFile *fileMapping = new TFile(nameMappingFile, "read");
2812  AliTPCmapper *mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
2813  if (!mapping) {
2814  snprintf(chinfo,1000,"Failed to get mapping object from %s. ...\n", nameMappingFile);
2815  AliError (chinfo);
2816  return 0;
2817  }
2818 
2819  AliTPCCalPad *deadMap = new AliTPCCalPad("deadMap","deadMap");
2820  if (!deadMap) {
2821  AliError("Failed to allocate dead map AliTPCCalPad");
2822  return 0;
2823  }
2824 
2826  Int_t idDDL=0;
2827  if (!fALTROConfigData ) {
2828  AliError("No ALTRO config OCDB entry available");
2829  return 0;
2830  }
2831  TMap *activeDDL = (TMap*)fALTROConfigData->FindObject("DDLArray");
2832  TObjString *ddlArray=0;
2833  if (activeDDL) {
2834  ddlArray = (TObjString*)activeDDL->GetValue("DDLArray");
2835  if (!ddlArray) {
2836  AliError("Empty list of active DDLs in OCDB entry");
2837  return 0;
2838  }
2839  } else {
2840  AliError("List of active DDLs not available in OCDB entry");
2841  return 0;
2842  }
2843  TString arrDDL=ddlArray->GetString();
2844  Int_t offset = mapping->GetTpcDdlOffset();
2845  Double_t active;
2846  for (Int_t i=0; i<mapping->GetNumDdl(); i++) {
2847  idDDL= i+offset;
2848  if (idDDL<0) continue;
2849  Int_t patch = mapping->GetPatchFromEquipmentID(idDDL);
2850  if (patch<0) continue;
2851  Int_t roc=mapping->GetRocFromEquipmentID(idDDL);
2852  if (roc<0) continue;
2853  AliTPCCalROC *calRoc=deadMap->GetCalROC(roc);
2854  if (calRoc) {
2855  for ( Int_t branch = 0; branch < 2; branch++ ) {
2856  for ( Int_t fec = 0; fec < mapping->GetNfec(patch, branch); fec++ ) {
2857  for ( Int_t altro = 0; altro < 8; altro++ ) {
2858  for ( Int_t channel = 0; channel < 16; channel++ ) {
2859  Int_t hwadd = mapping->CodeHWAddress(branch, fec, altro, channel);
2860  Int_t row = mapping->GetPadRow(patch, hwadd); // row in a ROC (IROC or OROC)
2861 // Int_t globalrow = mapping.GetGlobalPadRow(patch, hwadd); // row in full sector (IROC plus OROC)
2862  Int_t pad = mapping->GetPad(patch, hwadd);
2863  if (!TString(arrDDL[i]).IsDigit()) {
2864  active = notInMap;
2865  } else {
2866  active=TString(arrDDL[i]).Atof();
2867  }
2868  calRoc->SetValue(row,pad,active);
2869  } // end channel for loop
2870  } // end altro for loop
2871  } // end fec for loop
2872  } // end branch for loop
2873  } // valid calROC
2874  } // end loop on active DDLs
2875  return deadMap;
2876 }
2877 
2878 
2879 
2885 
2886  if (!fComposedCorrectionArray) return 0;
2887  if (field>0.1 && fComposedCorrectionArray->At(1)) {
2888  return (AliTPCCorrection *)fComposedCorrectionArray->At(1);
2889  }
2890  if (field<-0.1 &&fComposedCorrectionArray->At(2)) {
2891  return (AliTPCCorrection *)fComposedCorrectionArray->At(2);
2892  }
2893  return (AliTPCCorrection *)fComposedCorrectionArray->At(0);
2894 
2895 }
2896 
2897 
2901 
2902  if (!fComposedCorrectionArray) return 0;
2903  if (fRun<0) return 0;
2904  if (fDriftCorrectionArray.GetValue(Form("%i",fRun))==0) return 0;
2905  if (fComposedCorrectionArray->GetEntriesFast()<=4) {
2906  fComposedCorrectionArray->Expand(5);
2907  TObjArray * timeArray =(TObjArray*)(fDriftCorrectionArray.GetValue(Form("%i",fRun)));
2908  AliTPCCorrection * correctionTime = (AliTPCCorrection *)timeArray->FindObject("FitCorrectionTime");
2909  if (correctionTime){
2910  correctionTime->Init();
2911  fComposedCorrectionArray->AddAt(correctionTime,4); //add time dependent c
2912  }
2913  }
2914  return (AliTPCCorrection *)fComposedCorrectionArray->At(4); //
2915 }
2916 
2917 Double_t AliTPCcalibDB::GetGainCorrectionHVandPT(Int_t timeStamp, Int_t run, Int_t sector, Int_t deltaCache, Int_t mode){
2935 
2936  static Float_t gGainCorrection[72];
2937  static Float_t gGainCorrectionPT[72];
2938  static Float_t gGainCorrectionHV[72];
2939  static Int_t gTimeStamp=-99999999;
2940  static Bool_t hasTimeDependent=kFALSE;
2941  if ( TMath::Abs(timeStamp-gTimeStamp)> deltaCache){
2942  //
2943  TGraphErrors * graphGHV = 0;
2944  TGraphErrors * graphGPT = 0;
2945  TObjArray *timeGainSplines = GetTimeGainSplinesRun(run);
2946  if (timeGainSplines){
2947  graphGHV = (TGraphErrors*) timeGainSplines->FindObject("GainSlopesHV");
2948  graphGPT = (TGraphErrors*) timeGainSplines->FindObject("GainSlopesPT");
2949  if (graphGHV) hasTimeDependent=kTRUE;
2950  }
2951  if (!graphGHV) graphGHV = fParam->GetGainSlopesHV();
2952  if (!graphGPT) graphGPT = fParam->GetGainSlopesPT();
2953  //
2954  for (Int_t isec=0; isec<72; isec++){
2955  Double_t HV= GetChamberHighVoltage(run,isec, timeStamp);
2956  if (HV<=0){ // check if the HV was available
2958  AliWarningF("Could not get proper HV for run,sec,time (%d, %2d, %d), using current nominal voltage: %.2f", run, isec, timeStamp, HV);
2959 // AliDCSSensor* sensor = GetChamberHVSensor(isec);
2960 // if (sensor && sensor->GetGraph()==NULL && sensor->GetFit()==NULL){
2961 // HV=fParam->GetNominalVoltage(isec);
2962 // }
2963  }
2964  Double_t deltaHV= HV - fParam->GetNominalVoltage(isec);
2965  Double_t deltaGHV=0;
2966  Double_t deltaGPT=0;
2967  if (graphGHV) deltaGHV = graphGHV->GetY()[isec]*deltaHV;
2968  if (graphGPT) deltaGPT = graphGPT->GetY()[isec]*GetPTRelative(timeStamp,run,0);
2969  gGainCorrection[isec]=(1.+deltaGHV)*(1.+deltaGPT);
2970  gGainCorrectionPT[isec]=1+deltaGPT;
2971  gGainCorrectionHV[isec]=1+deltaGHV;
2972  }
2973  gTimeStamp=timeStamp;
2974  }
2975  if (mode==0){
2976  if (hasTimeDependent) return gGainCorrection[sector];
2977  if (!hasTimeDependent) return 1;
2978  }
2979  if (mode==1) return gGainCorrection[sector];
2980  if (mode==2) return gGainCorrectionPT[sector];
2981  if (mode==3) return gGainCorrectionHV[sector];
2982  return 1;
2983 }
TString GetRunType() const
Definition: AliGRPObject.h:62
static const char * GetEventSpecieName(EventSpecie_t es)
static AliTPCcalibDB * Instance()
static Float_t GetGain(Int_t sector, Int_t row, Int_t pad)
static Double_t EvalGraphConst(TGraph *const graph, Double_t xref)
TMap fDriftCorrectionArray
! array of drift correction
static void CreateObjectList(const Char_t *filename, TObjArray *calibObjects)
static Float_t GetBz(Int_t run)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
UInt_t GetNPads(UInt_t sector, UInt_t row) const
Definition: AliTPCROC.h:30
Float_t GetMaxDipVoltage() const
Definition: AliTPCParam.h:384
const Double_t kEpsilon
Double_t GetTime0CorrectionTime(Int_t timeStamp, Int_t run, Int_t side, Int_t mode)
TFile * Open(const char *filename, Long64_t &nevents)
UChar_t GetNumClasses() const
const TObjArray * GetCalPadRMS() const
Bool_t fBHasAlignmentOCDB
Flag - alignment from the Transformation class.
static Char_t GetL3Polarity(Int_t run)
UInt_t GetEndTime() const
Definition: AliDCSSensor.h:52
AliTPCCalROC * GetCalROC(Int_t sector) const
Definition: AliTPCCalPad.h:39
UInt_t GetDetectorMask() const
Definition: AliGRPObject.h:60
AliTPCRecoParam * GetRecoParamFromGRP() const
const TObjArray * GetCalPadRMS() const
Definition: AliTPCCalibCE.h:57
time_t GetTimeStart() const
Definition: AliGRPObject.h:55
const TObjArray * GetScalersRecords() const
AliSplineFit * GetFit() const
Definition: AliDCSSensor.h:54
static Double_t GetPTRelative(UInt_t timeSec, Int_t run, Int_t side)
Int_t GetRun() const
Double_t * GetX() const
Definition: AliSplineFit.h:37
void SetGraph(TGraph *gr)
Definition: AliDCSSensor.h:64
AliTPCCalPad * fPadTime0
Time0 calibration entry.
AliTPCCalPad * GetMaxCharge() const
Definition: AliTPCdataQA.h:60
TObjArray * fIonTailArray
array of graphs with the ion tail
static Double_t GetVDriftTPC(Double_t &dist, Int_t run, Int_t timeStamp, Double_t deltaT=86400, Double_t deltaTLaser=3600, Int_t valType=0)
Float_t GetGasSensorValue(EDcsGasSensor type, Int_t timeStamp=-1, Int_t sigDigits=-1)
TMap * GetRCUconfig() const
Definition: AliTPCcalibDB.h:95
TMap fTimeGainSplinesArray
! array Array of AliSplineFits: at 0 MIP position in time ; at 1 Fermi Plateau from cosmics ...
Double_t GetMedian(AliTPCCalROC *const outlierROC=0, EPadType padType=kAll) const
#define TObjArray
TVectorD vec
Definition: AnalyzeLaser.C:8
Double_t GetRMS(AliTPCCalROC *const outlierROC=0, EPadType padType=kAll) const
AliDCSSensor * fHVsensors[72]
HV sensors.
Int_t fMaxTimeBinAllPads
Maximum Time bin in whole TPC extracted from AltroConfig.
void SetExBField(Float_t bz)
Class providing the calibration parameters by accessing the CDB.
Definition: AliTPCcalibDB.h:44
TGraph * fGrRunState
store information if run is active or paused
void UpdateChamberHighVoltageData()
Manager and of geomety classes for set: TPC.
Definition: AliTPCParam.h:18
static void FilterTracks(Int_t run, Double_t cutSigma=20., TTreeSRedirector *const pcstream=0)
AliTPCCalPad * GetALTROFPED() const
Definition: AliTPCcalibDB.h:91
AliTPCmapper.
Definition: AliTPCmapper.h:15
static Float_t GetGGoffsetVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0)
UInt_t GetNRows(UInt_t sector) const
Definition: AliTPCROC.h:28
Implementation of the TPC transformation class.
TObjArray * fComposedCorrectionArray
space point corrections for different field setting
Float_t GetDriftV() const
Definition: AliTPCParam.h:342
Float_t GetMaxFractionHVbad() const
Definition: AliTPCParam.h:385
static Float_t GetValueGoofie(Int_t timeStamp, Int_t run, Int_t type)
Float_t GetMaxVoltageDeviation() const
Definition: AliTPCParam.h:383
Float_t GetValue(UInt_t row, UInt_t pad) const
Definition: AliTPCCalROC.h:38
Implementation of the TPC pedestal calibration.
void Multiply(Float_t c1)
AliTPCTransform * fTransform
object responsible for spacial corrections
static void Terminate()
TMap fGoofieArray
! array of GOOFIE values -per run
static const char * fgkGasSensorNames[kNGasSensor]
DCS gas sensor names.
static void Message(UInt_t level, const char *message, const char *module, const char *className, const char *function, const char *file, Int_t line)
Definition: AliLog.cxx:929
const TObjArray * GetCalPadT0() const
Definition: AliTPCCalibCE.h:54
Int_t GetPad(Int_t patch, Int_t hwAddress) const
AliDCSSensor * GetPressureSensor(Int_t run, Int_t type=0)
const TObjArray * GetTriggerScalers() const
AliTPCCalPad * fPadNoise
Noise calibration entry.
#define FUNCTIONNAME()
Definition: AliLog.h:198
void SetCacheFlag(Bool_t cacheFlag)
static Float_t FilterSensor(AliDCSSensor *sensor, Double_t ymin, Double_t ymax, Double_t maxdy, Double_t sigmaCut)
TPC calibration class for temperature maps and tendencies.
Definition: AliTPCTempMap.h:19
UInt_t GetNChannels(UInt_t sector) const
Definition: AliTPCROC.h:29
static Double_t GetVDriftTPCCE(Double_t &dist, Int_t run, Int_t timeStamp, Double_t deltaT=43200, Int_t side=2)
TMap fVoltageArray
! array of Chamber HV values -per run
virtual void Transform(Double_t *x, Int_t *i, UInt_t time, Int_t coordinateType)
AliTPCExB * GetExB() const
Definition: AliTPCcalibDB.h:64
void GetPositionLocal(UInt_t sector, UInt_t row, UInt_t pad, Float_t *pos)
Definition: AliTPCROC.cxx:414
AliTPCCalPad * GetPedestals() const
Definition: AliTPCcalibDB.h:83
Char_t GetL3Polarity() const
Definition: AliGRPObject.h:67
AliTPCCalPad * fPadGainFactor
Gain calibration entry.
TObjArray * GetTimeGainSplinesRun(Int_t run)
AliTPCCalPad * fActiveChannelMap
Map of active channels calculated on the fly.
AliDCSSensor * GetSensor(Int_t IdDCS)
static void FilterCE(Double_t deltaT=100, Double_t cutAbs=10, Double_t cutSigma=4., TTreeSRedirector *const pcstream=0)
AliTPCCalPad * GetNTimeBins() const
Definition: AliTPCdataQA.h:66
#define AliInfoF(message,...)
Definition: AliLog.h:499
UInt_t GetStartTime() const
Definition: AliDCSSensor.h:51
TGraph * GetCErocQgraph(const Int_t roc) const
void SetZ(Float_t z)
Definition: AliCluster.h:69
static Float_t GetChamberHighVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0, Bool_t current=kFALSE)
AliTPCCalPad * GetTimePosition() const
Definition: AliTPCdataQA.h:68
static Bool_t fgTerminated
termination control
TMap fTemperatureArray
! array of temperature sensors - per run
Int_t GetNfec(Int_t patch, Int_t branch) const
void SetCurrentRun(Int_t run)
Float_t fChamberHVgoodFraction[72]
fraction of time the chamber has a good HV (wrt. robust median)
npoints
Definition: driftITSTPC.C:85
AliTPCdataQA * GetDataQA() const
AliSplineFit fit
Definition: CalibTime.C:30
void SetFit(AliSplineFit *f)
Definition: AliDCSSensor.h:65
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
Int_t CodeHWAddress(Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
const Float_t * GetLastMapCorrectionRef() const
static Double_t GetTime0TPCITS(Double_t &dist, Int_t run, Int_t timeStamp)
static const char * ListOfTriggeredDetectors(UInt_t detectorPattern)
Definition: AliDAQ.cxx:438
const TObjArray * GetCalPadRMS() const
Class providing the calculation of derived quantities (mean,rms,fits,...) of calibration entries...
#define AliWarning(message)
Definition: AliLog.h:541
AliDCSSensorArray * GetVoltageSensors(Int_t run)
static Float_t GetPressure(Int_t timeStamp, Int_t run, Int_t type=0)
TObjArray * array
Definition: AnalyzeLaser.C:12
AliTPCCorrection * fComposedCorrection
general space point corrections
AliCDBEntry * Get(const AliCDBId &query, Bool_t forceCaching=kFALSE)
static void SetInstance(AliTPCExB *const param)
Definition: AliTPCExB.h:31
const Double_t * GetBadPadMaxDistXYZD() const
Int_t GetRCUTriggerConfig() const
static TString GetRunType(Int_t run)
TMap fGRPMaps
! array of GRPs maps - per run - old data
TString GetBeamType() const
Definition: AliGRPObject.h:58
AliTPCCorrection class.
Implementation of the TPC pulser calibration.
void sum()
void SplineFit(Int_t nder)
static Float_t GetSkirtVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0)
virtual ~AliTPCcalibDB()
Int_t GetNumDdl() const
Definition: AliTPCmapper.h:103
Bool_t GetTailcancelationGraphs(Int_t sector, TGraphErrors **graphRes, Float_t *indexAmpGraphs)
static Float_t FilterTemperature(AliTPCSensorTempArray *tempArray, Double_t ymin=15, Double_t ymax=22, Double_t sigmaCut=5)
UInt_t GetNPads(UInt_t row) const
Definition: AliTPCCalROC.h:37
TPC cluster error, shape and charge parameterization as function of drift length and inclination angl...
TLinearFitter * GetLinearFitter(Int_t type, Int_t side, UInt_t timeSec)
Bool_t CreateGUITree(const char *filename="")
void SetCurrentTimeStamp(time_t timeStamp)
AliGRPObject * MakeGRPObjectFromMap(TMap *map)
TObject * GetObject()
Definition: AliCDBEntry.h:56
AliTPCSensorTempArray * GetTemperature() const
Float_t fChamberHVmedian[72]
median chamber high voltage
AliTPCCalPad * GetCEQmean() const
const Double_t * GetBadClusMaxErrYZ() const
AliTPCComposedCorrection class.
static Float_t GetL3Current(Int_t run, Int_t statType=0)
Implementation of the TPC cluser.
AliTPCCalPad * fDedxGainFactor
Gain calibration entry - for dEdx.
void SetDistortions(float dx, float dy, float dz)
Float_t fCurrentNominalVoltage[72]
current nominal voltages
AliTPCSensorTempArray * fTemperature
Temperature calibration entry.
AliTPCTransform * GetTransform() const
Definition: AliTPCcalibDB.h:63
TTimeStamp startTime(2009, 8, 7, 0, 0, 0)
Bool_t GetCacheFlag() const
AliTPCcalibDB & operator=(const AliTPCcalibDB &)
Double_t GetMean(AliTPCCalROC *const outlierROC=0, EPadType padType=kAll) const
AliCTPTimeParams * fCTPTimeParams
CTP timing parameters.
void GetPositionGlobal(UInt_t sector, UInt_t row, UInt_t pad, Float_t *pos)
Definition: AliTPCROC.cxx:432
void UpdateRunInformations(Int_t run, Bool_t force=kFALSE)
void SetCavernAtmosPressure(AliDCSSensor *const cavernAtmosPressure)
Definition: AliGRPObject.h:128
#define AliInfo(message)
Definition: AliLog.h:484
static void MakeTree(const char *fileName, TObjArray *array, const char *mapFileName=0, AliTPCCalPad *outlierPad=0, Float_t ltmFraction=0.9)
TGraph * GetGraph() const
Definition: AliDCSSensor.h:53
virtual void SetDetector(Int_t detector)
Int_t fMode
RCU trigger config mode.
TGraph * gr
Definition: CalibTime.C:25
const UInt_t * GetRowIndexes(UInt_t sector) const
Definition: AliTPCROC.h:33
TObjArray * fPulserData
Calibration Pulser data.
const TObjArray * GetCalPadT0() const
AliDCSSensor * GetSurfaceAtmosPressure() const
Definition: AliGRPObject.h:77
Int_t GetNMaskedRows(int sector72, TBits *masked=0) const
Geometry class for a single ROC.
Definition: AliTPCROC.h:14
static EventSpecie_t SuggestRunEventSpecie(const char *runTypeGRP, const char *beamTypeGRP, const char *lhcStateGRP)
AliTPCCalPad * GetPulserQmean() const
AliTPCCalPad * GetALTROAcqStop() const
Definition: AliTPCcalibDB.h:92
void SetValue(UInt_t row, UInt_t pad, Float_t vd)
Definition: AliTPCCalROC.h:40
void Add(Float_t c1)
TObjArray * fDistortionMap
distortion map
Int_t GetPadRow(Int_t patch, Int_t hwAddress) const
TObjArray * fCEData
CE data.
AliTPCCalPad * GetCETmean() const
void LoadCorrectionMaps()
AliTPCCalPad * GetPadNoise() const
Definition: AliTPCcalibDB.h:82
AliTPCCalPad * GetPulserTmean() const
static Float_t GetGGnegVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0)
AliTPCCalPad * GetPulserTrms() const
static void RegisterField(Int_t index, AliMagF *magf)
Definition: AliTPCExB.cxx:215
Double_t GetVDriftCorrectionGy(Int_t timeStamp, Int_t run, Int_t side, Int_t mode)
static Float_t GetDCSSensorMeanValue(AliDCSSensorArray *arr, const char *sensorName, Int_t sigDigits=-1)
AliTPCdataQA * fDataQA
qa object
void rec(const char *filename="raw.root")
Definition: rec.C:1
void SetX(Float_t x)
Definition: AliCluster.h:67
void SetY(Float_t y)
Definition: AliCluster.h:68
Bool_t IsDataTakingActive(time_t timeStamp)
TObjArray * GetTimeVdriftSplineRun(Int_t run)
AliCDBEntry * GetCDBEntry(const char *cdbPath)
AliTPCClusterParam * fClusterParam
TPC cluster error, shape and Q parameterization.
Float_t * GetL3Current() const
Definition: AliGRPObject.h:69
Int_t GetPatchFromEquipmentID(Int_t equipmentID) const
Int_t GetTpcDdlOffset() const
Definition: AliTPCmapper.h:102
Bool_t fChamberHVStatus[72]
Status of the Chamber, HV wise (on/off)
TPC calibration base class for one ROC.
Definition: AliTPCCalROC.h:20
UInt_t GetCurrentRunNumber() const
const Float_t kSigmaCut
AliTPCParam * fParam
TPC parameters.
void SetSurfaceAtmosPressure(AliDCSSensor *const surfacePressure)
Definition: AliGRPObject.h:130
AliTPCCalPad * GetNPads() const
Definition: AliTPCdataQA.h:67
const TObjArray * GetCalPadPedestal() const
static const Double_t * GetPrimaryDCACut()
Int_t fRun
current run number
Float_t GetNominalVoltage(UInt_t i) const
Definition: AliTPCParam.h:382
TObjArray * fALTROConfigData
ALTRO configuration data.
Bool_t GetUseCorrectionMap() const
time_t GetTimeEnd() const
Definition: AliGRPObject.h:56
void ReadValuesFromMap(const TMap *map)
const Float_t * GetLastMapCorrection() const
static TObjArray fgExBArray
array of ExB corrections
#define AliWarningF(message,...)
Definition: AliLog.h:556
Definition: AliCDBEntry.h:18
static TMap * GetGRPMap(Int_t run)
TGraphErrors * GetGainSlopesPT() const
Definition: AliTPCParam.h:347
const char * names[10]
#define AliFatal(message)
Definition: AliLog.h:640
AliTPCCorrection * GetTPCComposedCorrectionDelta() const
TF1 * f
Definition: interpolTest.C:21
static Float_t GetCoverVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0)
AliTPCCalPad * GetMeanCharge() const
Definition: AliTPCdataQA.h:61
AliSplineFit * GetVdriftSplineFit(const char *name, Int_t run)
TCollection * GetCorrections() const
TGraphErrors * GetGainSlopesHV() const
Definition: AliTPCParam.h:346
Double_t GetValue(UInt_t timeSec)
static Float_t GetGGposVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0)
UInt_t GetNchannels() const
Definition: AliTPCCalROC.h:34
static TObjArray * LoadCorrectionMaps(Bool_t refMap, Bool_t corrMode=kTRUE)
AliTPCCorrection * GetTPCComposedCorrection() const
Definition: AliTPCcalibDB.h:74
AliDCSSensor * GetCavernAtmosPressure() const
Definition: AliGRPObject.h:75
void SetRun(Long64_t run)
static void RegisterExB(Int_t index, Float_t bz, Bool_t bdelete)
AliDCSSensorArray * GetGoofieSensors(Int_t run)
void DumpToFile(const char *fileName)
Long64_t GetRun() const
Definition: AliTPCcalibDB.h:59
AliDCSSensorArray * fGasSensorArray
Gas sensors.
static AliGRPObject * GetGRP(Int_t run)
AliTPCExB * fExB
ExB correction factor.
AliTPCCalPad * GetActiveChannelMap() const
Definition: AliTPCcalibDB.h:70
Preprocessor class for HLT and DAQ.
Double_t GetGainCorrectionHVandPT(Int_t timeStamp, Int_t run, Int_t sector, Int_t deltaCache, Int_t mode)
void SetMinPoints(Int_t minPoints)
Definition: AliSplineFit.h:53
AliTPCCalPad * GetALTROAcqStart() const
Definition: AliTPCcalibDB.h:89
TPC calibration class for parameters which saved per pad.
Int_t grp(UInt_t run, TString &gdc)
Definition: onlineReco.C:70
const TObjArray * GetCalPadQ() const
Definition: AliTPCCalibCE.h:56
AliSplineFit * CreateVdriftSplineFit(const char *graphName, Int_t run)
static Double_t GetVDriftTPCITS(Double_t &dist, Int_t run, Int_t timeStamp)
TGraph * GetCErocTgraph(const Int_t roc) const
AliTPCCalPad * GetNLocalMaxima() const
Definition: AliTPCdataQA.h:62
#define MODULENAME()
Definition: AliLog.h:189
Int_t GetRocFromEquipmentID(Int_t equipmentID) const
Int_t GetKnots() const
Definition: AliSplineFit.h:36
void SetDistortionDispersion(float d)
AliTPCCalPad * GetDedxGainFactor() const
Definition: AliTPCcalibDB.h:71
static Double_t GetVDriftTPCLaserTracks(Double_t &dist, Int_t run, Int_t timeStamp, Double_t deltaT=43200, Int_t side=2)
Double_t GetVDriftCorrectionDeltaZ(Int_t timeStamp, Int_t run, Int_t side, Int_t mode)
TTree * db
Definition: kNNSpeed.C:21
TObjArray * fCorrectionMaps
RS: new fast Chebyshev parameterization maps.
static AliTPCcalibDB * fgInstance
singleton control
Double_t ErrZ2Syst(const AliTPCclusterMI *cl, const double tgAngLam)
static Bool_t CreateRefFile(Int_t run, const char *filename="")
TMap fVdriftArray
! array of v drift interfaces
Double_t vdrift
Definition: DriftKalman.C:98
static Float_t GetDCSSensorValue(AliDCSSensorArray *arr, Int_t timeStamp, const char *sensorName, Int_t sigDigits=-1)
static Float_t GetCEdriftTime(Int_t run, Int_t sector, Double_t timeStamp=-1., Int_t *entries=0)
static AliTPCROC * Instance()
Definition: AliTPCROC.cxx:34
Implementation of the TPC Central Electrode calibration.
Definition: AliTPCCalibCE.h:29
void SetOwner(Bool_t owner)
Definition: AliCDBEntry.h:64
AliTPCCalibVdrift * GetVdrift(Int_t run)
class TVectorT< Double_t > TVectorD
#define AliError(message)
Definition: AliLog.h:591
Class with TPC reconstruction parameters.
TString GetLHCState() const
Definition: AliGRPObject.h:63
AliTPCCalibRaw * fCalibRaw
raw data calibration entry
TArrayI fRunList
! run list - indicates try to get the run param
void SetCurrentRecoParam(AliTPCRecoParam *param)
TObjArray * fRecoParamList
List of TPC reco param objects.
AliTPCAltroMapping ** fMapping
Altro mapping.
Float_t GetZLength(Int_t sector=0) const
Definition: AliTPCParam.h:841
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
static Bool_t GetTemperatureFit(Int_t timeStamp, Int_t run, Int_t side, TVectorD &fit)
AliTPCCalPad * GetNoThreshold() const
Definition: AliTPCdataQA.h:59
void SetGraph(TGraph *graph)
Definition: AliSplineFit.h:52
UInt_t GetNSectors() const
Definition: AliTPCROC.h:27
TObjArray * fTimeGainSplines
Array of AliSplineFits: at 0 MIP position in time ; at 1 Fermi Plateau from cosmics.
AliTPCCalPad * GetALTROZsThr() const
Definition: AliTPCcalibDB.h:90
Bool_t IsDefaultStorageSet() const
Definition: AliCDBManager.h:60
static Float_t GetCEchargeTime(Int_t run, Int_t sector, Double_t timeStamp=-1., Int_t *entries=0)
Double_t GetLTM(Double_t *const sigma=0, Double_t fraction=0.9, AliTPCCalROC *const outlierROC=0, EPadType padType=kAll)
static AliTPCChebCorr * LoadFieldDependendStaticCorrectionMap(Bool_t ref, Bool_t corrMode=kTRUE, TObjArray *mapsArrProvided=0)
AliTPCCalPad * GetDistortionMap(Int_t i) const
Int_t GetMaxTBin() const
Definition: AliTPCParam.h:371
virtual void Init()
AliTPCCalPad * GetALTROMasked() const
Definition: AliTPCcalibDB.h:93
AliRecoParam::EventSpecie_t fRunEventSpecie
Event specie suggested for the run according to GRP.
Double_t GetVDriftCorrectionTime(Int_t timeStamp, Int_t run, Int_t side, Int_t mode)
Float_t GetPadRowRadii(UInt_t isec, UInt_t irow) const
Definition: AliTPCROC.h:56
Abstract class for ExB effect parameterization.
Definition: AliTPCExB.h:10
AliTPCcalibDButil * fDButil
utility class
const TObjArray * GetCalPadQ() const
AliTriggerScalersRecord * GetScalersRecord(Int_t index) const
const AliTimeStamp * GetTimeStamp() const
Int_t GetMaskedChannelsFromCorrectionMaps(TBits maskedPads[72])
AliTPCCalPad * GetCETrms() const
AliTPCCalPad * MakeDeadMap(Double_t notInMap=1, const char *nameMappingFile="$ALICE_ROOT/TPC/Calib/tpcMapping.root")
This implementation AliTPCExB is using an aproximate calculation of the ExB effect.
AliTPCRecoParam * GetRecoParam(Int_t i) const
TMap * GetDDLMap() const
Definition: AliTPCcalibDB.h:94
Double_t GetPTRelative(UInt_t absTimeSec, Int_t side)
UInt_t GetNrows() const
Definition: AliTPCCalROC.h:33
Double_t ErrY2Syst(const AliTPCclusterMI *cl, const double tgAngPhi)
Float_t GetChamberCurrentNominalHighVoltage(UInt_t roc) const
void Local2RotatedGlobal(Int_t sec, Double_t *x) const
AliTPCCalPad * fPedestals
Pedestal calibration entry.
Double_t * GetY0() const
Definition: AliSplineFit.h:38
AliTPCSensorTempArray * GetTemperatureSensor(Int_t run)
void InitKnots(TGraph *graph, Int_t min, Int_t iter, Double_t maxDelta)
Int_t GetEventSpecie() const
TMap fGRPArray
! array of GRPs - per run
Implementation of the TPC Raw drift velocity and Altro L1 Phase calibration.
static Double_t GetTriggerOffsetTPC(Int_t run, Int_t timeStamp, Double_t deltaT=86400, Double_t deltaTLaser=3600, Int_t valType=0)