AliRoot Core  d69033e (d69033e)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
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"};
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),
178  fActiveChannelMap(0),
179  fDedxGainFactor(0),
180  fPadTime0(0),
181  fDistortionMap(0),
182  fComposedCorrection(0),
183  fComposedCorrectionArray(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),
204  fTimeGainSplinesArray(1),
205  fGRPArray(1),
206  fGRPMaps(1),
207  fGoofieArray(1),
208  fVoltageArray(1),
209  fTemperatureArray(1),
210  fVdriftArray(1),
211  fDriftCorrectionArray(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),
244  fActiveChannelMap(0),
245  fDedxGainFactor(0),
246  fPadTime0(0),
247  fDistortionMap(0),
248  fComposedCorrection(0),
249  fComposedCorrectionArray(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),
270  fTimeGainSplinesArray(1),
271  fGRPArray(0),
272  fGRPMaps(0),
273  fGoofieArray(0),
274  fVoltageArray(0),
275  fTemperatureArray(0),
276  fVdriftArray(0),
277  fDriftCorrectionArray(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 //_____________________________________________________________________________
353 AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
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  //
392  fRun = AliCDBManager::Instance()->GetRun();
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  }
425  fRunEventSpecie = AliRecoParam::SuggestRunEventSpecie(grpData->GetRunType(),grpData->GetBeamType(),grpData->GetLHCState());
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);
433  fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
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);
450  fDedxGainFactor = (AliTPCCalPad*)entry->GetObject();
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);
496  fTemperature = (AliTPCSensorTempArray*)entry->GetObject();
497  }
498 
499 
500  entry = GetCDBEntry("TPC/Calib/ClusterParam");
501  if (entry){
502  entry->SetOwner(kTRUE);
503  fClusterParam = (AliTPCClusterParam*)(entry->GetObject());
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);
521  fGasSensorArray=(AliDCSSensorArray*)(entry->GetObject());
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) {
610  fTransform->SetCurrentRun(AliCDBManager::Instance()->GetRun());
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 chnnel 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",
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/Parameters
1018 
1019  fMaxTimeBinAllPads=-1;
1020 
1021  const AliTPCCalPad *calPadAcqStop = GetALTROAcqStop();
1022 
1023  if (calPadAcqStop) {
1024  //find max elememt
1025  // TODO: change this once the GetMaxElement function is implemented in AliTPCCalPad
1026  Float_t maxBin=-1;
1027  for (Int_t iroc=0; iroc<AliTPCCalPad::kNsec; ++iroc) {
1028  const AliTPCCalROC *roc = calPadAcqStop->GetCalROC(iroc);
1029  if (!roc) continue;
1030  for (Int_t ichannel=0; ichannel<roc->GetNchannels(); ++ichannel) {
1031  const Float_t val=roc->GetValue(ichannel);
1032  if (val>maxBin) maxBin=val;
1033  }
1034  }
1035  fMaxTimeBinAllPads = TMath::Nint(maxBin);
1036  }
1037 
1038  if (fMaxTimeBinAllPads<0) {
1039  if (fParam) {
1040  AliWarning("Could not access 'AcqStop' map from AltroConfig or invalid max time bine. fMaxTimeBinAllPads will be set from AliTPCParam.");
1042  } else {
1043  // last fallback
1044  AliWarning("Could neither access 'Parameters' nor 'AcqStop' map from AltroConfig. fMaxTimeBinAllPads will be set to 1000.");
1045  fMaxTimeBinAllPads=1000;
1046  }
1047  }
1048 
1049  AliInfo(TString::Format("fMaxTimeBinAllPads set to %d", fMaxTimeBinAllPads).Data());
1050 }
1051 
1052 void AliTPCcalibDB::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad* outlierPad, Float_t ltmFraction) {
1057 
1058  AliTPCROC* tpcROCinstance = AliTPCROC::Instance();
1059 
1060  TObjArray* mapIROCs = 0;
1061  TObjArray* mapOROCs = 0;
1062  TVectorF *mapIROCArray = 0;
1063  TVectorF *mapOROCArray = 0;
1064  Int_t mapEntries = 0;
1065  TString* mapNames = 0;
1066 
1067  if (mapFileName) {
1068  TFile mapFile(mapFileName, "read");
1069 
1070  TList* listOfROCs = mapFile.GetListOfKeys();
1071  mapEntries = listOfROCs->GetEntries()/2;
1072  mapIROCs = new TObjArray(mapEntries*2);
1073  mapOROCs = new TObjArray(mapEntries*2);
1074  mapIROCArray = new TVectorF[mapEntries];
1075  mapOROCArray = new TVectorF[mapEntries];
1076 
1077  mapNames = new TString[mapEntries];
1078  for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
1079  TString nameROC(((TKey*)(listOfROCs->At(ivalue*2)))->GetName());
1080  nameROC.Remove(nameROC.Length()-4, 4);
1081  mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "IROC").Data()), ivalue);
1082  mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "OROC").Data()), ivalue);
1083  mapNames[ivalue].Append(nameROC);
1084  }
1085 
1086  for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
1087  mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0));
1088  mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36));
1089 
1090  for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++)
1091  (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel);
1092  for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++)
1093  (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel);
1094  }
1095 
1096  } // if (mapFileName)
1097 
1098  TTreeSRedirector cstream(fileName);
1099  Int_t arrayEntries = array->GetEntries();
1100 
1101  TString* names = new TString[arrayEntries];
1102  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
1103  names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName());
1104 
1105  for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) {
1106  //
1107  // get statistic for given sector
1108  //
1109  TVectorF median(arrayEntries);
1110  TVectorF mean(arrayEntries);
1111  TVectorF rms(arrayEntries);
1112  TVectorF ltm(arrayEntries);
1113  TVectorF ltmrms(arrayEntries);
1114  TVectorF medianWithOut(arrayEntries);
1115  TVectorF meanWithOut(arrayEntries);
1116  TVectorF rmsWithOut(arrayEntries);
1117  TVectorF ltmWithOut(arrayEntries);
1118  TVectorF ltmrmsWithOut(arrayEntries);
1119 
1120  TVectorF *vectorArray = new TVectorF[arrayEntries];
1121  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
1122  vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
1123 
1124  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
1125  AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
1126  AliTPCCalROC* calROC = calPad->GetCalROC(isector);
1127  AliTPCCalROC* outlierROC = 0;
1128  if (outlierPad) outlierROC = outlierPad->GetCalROC(isector);
1129  if (calROC) {
1130  median[ivalue] = calROC->GetMedian();
1131  mean[ivalue] = calROC->GetMean();
1132  rms[ivalue] = calROC->GetRMS();
1133  Double_t ltmrmsValue = 0;
1134  ltm[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction);
1135  ltmrms[ivalue] = ltmrmsValue;
1136  if (outlierROC) {
1137  medianWithOut[ivalue] = calROC->GetMedian(outlierROC);
1138  meanWithOut[ivalue] = calROC->GetMean(outlierROC);
1139  rmsWithOut[ivalue] = calROC->GetRMS(outlierROC);
1140  ltmrmsValue = 0;
1141  ltmWithOut[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction, outlierROC);
1142  ltmrmsWithOut[ivalue] = ltmrmsValue;
1143  }
1144  }
1145  else {
1146  median[ivalue] = 0.;
1147  mean[ivalue] = 0.;
1148  rms[ivalue] = 0.;
1149  ltm[ivalue] = 0.;
1150  ltmrms[ivalue] = 0.;
1151  medianWithOut[ivalue] = 0.;
1152  meanWithOut[ivalue] = 0.;
1153  rmsWithOut[ivalue] = 0.;
1154  ltmWithOut[ivalue] = 0.;
1155  ltmrmsWithOut[ivalue] = 0.;
1156  }
1157  }
1158 
1159  //
1160  // fill vectors of variable per pad
1161  //
1162  TVectorF *posArray = new TVectorF[8];
1163  for (Int_t ivalue = 0; ivalue < 8; ivalue++)
1164  posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
1165 
1166  Float_t posG[3] = {0};
1167  Float_t posL[3] = {0};
1168  Int_t ichannel = 0;
1169  for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) {
1170  for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) {
1171  tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL);
1172  tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG);
1173  posArray[0][ichannel] = irow;
1174  posArray[1][ichannel] = ipad;
1175  posArray[2][ichannel] = posL[0];
1176  posArray[3][ichannel] = posL[1];
1177  posArray[4][ichannel] = posG[0];
1178  posArray[5][ichannel] = posG[1];
1179  posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2);
1180  posArray[7][ichannel] = ichannel;
1181 
1182  // loop over array containing AliTPCCalPads
1183  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
1184  AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
1185  AliTPCCalROC* calROC = calPad->GetCalROC(isector);
1186  if (calROC)
1187  (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad);
1188  else
1189  (vectorArray[ivalue])[ichannel] = 0;
1190  }
1191  ichannel++;
1192  }
1193  }
1194 
1195  cstream << "calPads" <<
1196  "sector=" << isector;
1197 
1198  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
1199  cstream << "calPads" <<
1200  (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] <<
1201  (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] <<
1202  (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] <<
1203  (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] <<
1204  (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue];
1205  if (outlierPad) {
1206  cstream << "calPads" <<
1207  (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] <<
1208  (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] <<
1209  (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] <<
1210  (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] <<
1211  (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue];
1212  }
1213  }
1214 
1215  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
1216  cstream << "calPads" <<
1217  (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue];
1218  }
1219 
1220  if (mapFileName) {
1221  for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
1222  if (isector < 36)
1223  cstream << "calPads" <<
1224  (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue];
1225  else
1226  cstream << "calPads" <<
1227  (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue];
1228  }
1229  }
1230 
1231  cstream << "calPads" <<
1232  "row.=" << &posArray[0] <<
1233  "pad.=" << &posArray[1] <<
1234  "lx.=" << &posArray[2] <<
1235  "ly.=" << &posArray[3] <<
1236  "gx.=" << &posArray[4] <<
1237  "gy.=" << &posArray[5] <<
1238  "rpad.=" << &posArray[6] <<
1239  "channel.=" << &posArray[7];
1240 
1241  cstream << "calPads" <<
1242  "\n";
1243 
1244  delete[] posArray;
1245  delete[] vectorArray;
1246  }
1247 
1248 
1249  delete[] names;
1250  if (mapFileName) {
1251  delete mapIROCs;
1252  delete mapOROCs;
1253  delete[] mapIROCArray;
1254  delete[] mapOROCArray;
1255  delete[] mapNames;
1256  }
1257 }
1258 
1260 {
1262 
1263  TMap *map=GetRCUconfig();
1264  if (!map) return -1;
1265  TVectorF *v=(TVectorF*)map->GetValue("TRGCONF_TRG_MODE");
1266  Float_t mode=-1;
1267  for (Int_t i=0; i<v->GetNrows(); ++i){
1268  Float_t newmode=v->GetMatrixArray()[i];
1269  if (newmode>-1){
1270  if (mode>-1&&newmode!=mode) AliWarning("Found different RCU trigger configurations!!!");
1271  mode=newmode;
1272  }
1273  }
1274  return (Int_t)mode;
1275 }
1276 
1278 {
1280 
1281  if (fMode<0) return kFALSE;
1282  return (fMode==1);
1283 }
1284 
1286 {
1288 
1289  if (fMode<0) return kFALSE;
1290  return (fMode==0);
1291 }
1292 
1293 void AliTPCcalibDB::RegisterExB(Int_t index, Float_t bz, Bool_t bdelete){
1297 
1298  // Float_t factor = bz/(-5.); // default b filed in Cheb with minus sign
1299  Float_t factor = bz/(5.); // default b filed in Cheb with minus sign
1300  // was chenged in the Revision ???? (Ruben can you add here number)
1301 
1302  AliMagF* bmap = new AliMagF("MapsExB","MapsExB", factor,TMath::Sign(1.f,factor),AliMagF::k5kG);
1303 
1304  AliTPCExBFirst *exb = new AliTPCExBFirst(bmap,0.88*2.6400e+04,50,50,50);
1306 
1307  if (bdelete){
1308  delete bmap;
1309  }else{
1310  AliTPCExB::RegisterField(index,bmap);
1311  }
1312  if (index>=fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
1313  fgExBArray.AddAt(exb,index);
1314 }
1315 
1316 
1317 AliTPCExB* AliTPCcalibDB::GetExB(Float_t bz, Bool_t deleteB) {
1321 
1322  Int_t index = TMath::Nint(5+bz);
1323  if (index>fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
1324  if (!fgExBArray.At(index)) AliTPCcalibDB::RegisterExB(index,bz,deleteB);
1325  return (AliTPCExB*)fgExBArray.At(index);
1326 }
1327 
1328 
1331 
1332  fExB = GetExB(bz,kFALSE);
1333 }
1334 
1335 void AliTPCcalibDB::SetExBField(const AliMagF* bmap){
1337 
1338  AliTPCExBFirst *exb = new AliTPCExBFirst(bmap,0.88*2.6400e+04,50,50,50);
1340  fExB=exb;
1341 }
1342 
1343 
1344 
1345 void AliTPCcalibDB::UpdateRunInformations( Int_t run, Bool_t force){
1347 
1348  if (run<=0) return;
1349  TObjString runstr(Form("%i",run));
1350  fRun=run;
1351  AliCDBEntry * entry = 0;
1352  if (run>= fRunList.fN){
1353  fRunList.Set(run*2+1);
1354  //
1355  //
1356  fALTROConfigData->Expand(run*2+1); // ALTRO configuration data
1357  fPulserData->Expand(run*2+1); // Calibration Pulser data
1358  fCEData->Expand(run*2+1); // CE data
1359  if (!fTimeGainSplines) fTimeGainSplines = new TObjArray(run*2+1);
1360  fTimeGainSplines->Expand(run*2+1); // Array of AliSplineFits: at 0 MIP position in
1361  }
1362  if (fRunList[run]>0 &&force==kFALSE) return;
1363 
1364  fRunList[run]=1; // sign as used
1365 
1366  //
1367  entry = AliCDBManager::Instance()->Get("GRP/GRP/Data",run);
1368  if (entry) {
1369  AliGRPObject * grpRun = dynamic_cast<AliGRPObject*>(entry->GetObject());
1370  if (!grpRun){
1371  TMap* map = dynamic_cast<TMap*>(entry->GetObject());
1372  if (map){
1373  //grpRun = new AliGRPObject;
1374  //grpRun->ReadValuesFromMap(map);
1375  grpRun = MakeGRPObjectFromMap(map);
1376 
1377  fGRPMaps.Add(new TObjString(runstr),map);
1378  }
1379  }
1380  fGRPArray.Add(new TObjString(runstr),(AliGRPObject*)grpRun->Clone());
1381  }
1382  entry = AliCDBManager::Instance()->Get("TPC/Calib/Goofie",run);
1383  if (entry){
1384  fGoofieArray.Add(new TObjString(runstr),entry->GetObject());
1385  }
1386  //
1387 
1388  //
1389  entry = AliCDBManager::Instance()->Get("TPC/Calib/TimeGain",run);
1390  if (entry) {
1391  fTimeGainSplinesArray.Add(new TObjString(runstr),entry->GetObject());
1392  }else{
1393  AliFatal("TPC - Missing calibration entry TimeGain");
1394  }
1395  //
1396  entry = AliCDBManager::Instance()->Get("TPC/Calib/TimeDrift",run);
1397  if (entry) {
1398  TObjArray * timeArray = (TObjArray*)entry->GetObject();
1399  fDriftCorrectionArray.Add(new TObjString(runstr),entry->GetObject());
1400  AliTPCCorrection * correctionTime = (AliTPCCorrection *)timeArray->FindObject("FitCorrectionTime");
1401  if (correctionTime && fComposedCorrectionArray){
1402  correctionTime->Init();
1403  if (fComposedCorrectionArray->GetEntriesFast()<4) fComposedCorrectionArray->Expand(40);
1404  fComposedCorrectionArray->AddAt(correctionTime,4); //add time dependent correction to the list of available corrections
1405  }
1406  }else{
1407  AliFatal("TPC - Missing calibration entry TimeDrift");
1408  }
1409  //
1410  entry = AliCDBManager::Instance()->Get("TPC/Calib/Temperature",run);
1411  if (entry) {
1412  fTemperatureArray.Add(new TObjString(runstr),entry->GetObject());
1413  }
1414 
1415  // High voltage
1416  entry = AliCDBManager::Instance()->Get("TPC/Calib/HighVoltage",run);
1417  if (!fVoltageArray.GetValue(runstr.GetName()) && entry) {
1418  fVoltageArray.Add(new TObjString(runstr),entry->GetObject());
1419  }
1420 
1421  //apply fDButil filters
1422 
1425 
1426  AliDCSSensor * press = GetPressureSensor(run,0);
1428  Bool_t accept=kTRUE;
1429  if (temp) {
1430  accept = fDButil->FilterTemperature(temp)>0.1;
1431  }
1432  if (press) {
1433  const Double_t kMinP=900.;
1434  const Double_t kMaxP=1050.;
1435  const Double_t kMaxdP=10.;
1436  const Double_t kSigmaCut=4.;
1437  fDButil->FilterSensor(press,kMinP,kMaxP,kMaxdP,kSigmaCut);
1438  if (press->GetFit()==0) accept=kFALSE;
1439  }
1440 
1441  if (press && temp &&accept){
1442  AliTPCCalibVdrift * vdrift = new AliTPCCalibVdrift(temp, press,0);
1443  fVdriftArray.Add(new TObjString(runstr),vdrift);
1444  }
1445 
1446  fDButil->FilterCE(120., 3., 4.,0);
1447  fDButil->FilterTracks(run, 10.,0);
1448 
1449 }
1450 
1451 
1452 Float_t AliTPCcalibDB::GetGain(Int_t sector, Int_t row, Int_t pad){
1454 
1455  AliTPCCalPad *calPad = Instance()->fDedxGainFactor;;
1456  if (!calPad) return 0;
1457  return calPad->GetCalROC(sector)->GetValue(row,pad);
1458 }
1459 
1460 AliSplineFit* AliTPCcalibDB::GetVdriftSplineFit(const char* name, Int_t run){
1462 
1464  if (!arr) return 0;
1465  return dynamic_cast<AliSplineFit*>(arr->FindObject(name));
1466 }
1467 
1468 AliSplineFit* AliTPCcalibDB::CreateVdriftSplineFit(const char* graphName, Int_t run){
1470 
1472  if (!arr) return 0;
1473  TGraph *graph=dynamic_cast<TGraph*>(arr->FindObject(graphName));
1474  if (!graph) return 0;
1475  AliSplineFit *fit = new AliSplineFit();
1476  fit->SetGraph(graph);
1477  fit->SetMinPoints(graph->GetN()+1);
1478  fit->InitKnots(graph,2,0,0.001);
1479  fit->SplineFit(0);
1480  return fit;
1481 }
1482 
1483 AliGRPObject *AliTPCcalibDB::GetGRP(Int_t run){
1485 
1486  AliGRPObject * grpRun = dynamic_cast<AliGRPObject *>((Instance()->fGRPArray).GetValue(Form("%i",run)));
1487  if (!grpRun) {
1489  grpRun = dynamic_cast<AliGRPObject *>(Instance()->fGRPArray.GetValue(Form("%i",run)));
1490  if (!grpRun) return 0;
1491  }
1492  return grpRun;
1493 }
1494 
1495 TMap * AliTPCcalibDB::GetGRPMap(Int_t run){
1497 
1498  TMap * grpRun = dynamic_cast<TMap *>((Instance()->fGRPMaps).GetValue(Form("%i",run)));
1499  if (!grpRun) {
1501  grpRun = dynamic_cast<TMap *>(Instance()->fGRPMaps.GetValue(Form("%i",run)));
1502  if (!grpRun) return 0;
1503  }
1504  return grpRun;
1505 }
1506 
1507 
1508 AliDCSSensor * AliTPCcalibDB::GetPressureSensor(Int_t run, Int_t type){
1514 
1515 
1516  TMap *map = GetGRPMap(run);
1517  if (map){
1518  AliDCSSensor * sensor = 0;
1519  TObject *osensor=0;
1520  if (type==0) osensor = ((*map)("fCavernPressure"));
1521  if (type==1) osensor = ((*map)("fP2Pressure"));
1522  sensor =dynamic_cast<AliDCSSensor *>(osensor);
1523  if (sensor) return sensor;
1524  }
1525  //
1526  // If not map try to get it from the GRPObject
1527  //
1528  AliGRPObject * grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.GetValue(Form("%i",run)));
1529  if (!grpRun) {
1530  UpdateRunInformations(run);
1531  grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.GetValue(Form("%i",run)));
1532  if (!grpRun) return 0;
1533  }
1534  AliDCSSensor * sensor = grpRun->GetCavernAtmosPressure();
1535  if (type==1) sensor = grpRun->GetSurfaceAtmosPressure();
1536  return sensor;
1537 }
1538 
1541 
1542  AliTPCSensorTempArray * tempArray = (AliTPCSensorTempArray *)fTemperatureArray.GetValue(Form("%i",run));
1543  if (!tempArray) {
1544  UpdateRunInformations(run);
1545  tempArray = (AliTPCSensorTempArray *)fTemperatureArray.GetValue(Form("%i",run));
1546  }
1547  return tempArray;
1548 }
1549 
1550 
1553 
1554  TObjArray * gainSplines = (TObjArray *)fTimeGainSplinesArray.GetValue(Form("%i",run));
1555  if (!gainSplines) {
1556  UpdateRunInformations(run);
1557  gainSplines = (TObjArray *)fTimeGainSplinesArray.GetValue(Form("%i",run));
1558  }
1559  return gainSplines;
1560 }
1561 
1564 
1565  TObjArray * driftSplines = (TObjArray *)fDriftCorrectionArray.GetValue(Form("%i",run));
1566  if (!driftSplines) {
1567  UpdateRunInformations(run);
1568  driftSplines = (TObjArray *)fDriftCorrectionArray.GetValue(Form("%i",run));
1569  }
1570  return driftSplines;
1571 }
1572 
1573 AliDCSSensorArray * AliTPCcalibDB::GetVoltageSensors(Int_t run){
1575 
1576  AliDCSSensorArray * voltageArray = (AliDCSSensorArray *)fVoltageArray.GetValue(Form("%i",run));
1577  if (!voltageArray) {
1578  UpdateRunInformations(run);
1579  voltageArray = (AliDCSSensorArray *)fVoltageArray.GetValue(Form("%i",run));
1580  }
1581  return voltageArray;
1582 }
1583 
1584 AliDCSSensorArray * AliTPCcalibDB::GetGoofieSensors(Int_t run){
1586 
1587  AliDCSSensorArray * goofieArray = (AliDCSSensorArray *)fGoofieArray.GetValue(Form("%i",run));
1588  if (!goofieArray) {
1589  UpdateRunInformations(run);
1590  goofieArray = (AliDCSSensorArray *)fGoofieArray.GetValue(Form("%i",run));
1591  }
1592  return goofieArray;
1593 }
1594 
1595 
1596 
1599 
1600  AliTPCCalibVdrift * vdrift = (AliTPCCalibVdrift*)fVdriftArray.GetValue(Form("%i",run));
1601  if (!vdrift) {
1602  UpdateRunInformations(run);
1603  vdrift= (AliTPCCalibVdrift*)fVdriftArray.GetValue(Form("%i",run));
1604  }
1605  return vdrift;
1606 }
1607 
1608 Float_t AliTPCcalibDB::GetCEdriftTime(Int_t run, Int_t sector, Double_t timeStamp, Int_t *entries)
1609 {
1614 
1616  TGraph *gr=AliTPCcalibDB::Instance()->GetCErocTgraph(sector);
1617  if (!gr||sector<0||sector>73) {
1618  if (entries) *entries=0;
1619  return 0.;
1620  }
1621  Float_t val=0.;
1622  if (timeStamp==-1.){
1623  val=gr->GetMean(2);
1624  }else{
1625  for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
1626  Double_t x,y;
1627  gr->GetPoint(ipoint,x,y);
1628  if (x<timeStamp) continue;
1629  val=y;
1630  break;
1631  }
1632  }
1633  return val;
1634 }
1635 
1636 Float_t AliTPCcalibDB::GetCEchargeTime(Int_t run, Int_t sector, Double_t timeStamp, Int_t *entries)
1637 {
1640 
1642  TGraph *gr=AliTPCcalibDB::Instance()->GetCErocQgraph(sector);
1643  if (!gr||sector<0||sector>71) {
1644  if (entries) *entries=0;
1645  return 0.;
1646  }
1647  Float_t val=0.;
1648  if (timeStamp==-1.){
1649  val=gr->GetMean(2);
1650  }else{
1651  for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
1652  Double_t x,y;
1653  gr->GetPoint(ipoint,x,y);
1654  if (x<timeStamp) continue;
1655  val=y;
1656  break;
1657  }
1658  }
1659  return val;
1660 }
1661 
1662 Float_t AliTPCcalibDB::GetDCSSensorValue(AliDCSSensorArray *arr, Int_t timeStamp, const char * sensorName, Int_t sigDigits)
1663 {
1665 
1666  Float_t val=0;
1667  const TString sensorNameString(sensorName);
1668  AliDCSSensor *sensor = arr->GetSensor(sensorNameString);
1669  if (!sensor) return val;
1670 
1671  const Int_t startTime = Int_t(sensor->GetStartTime());
1672  const Int_t endTime = Int_t(sensor->GetEndTime());
1673 
1674  //use the dcs graph if possible
1675  TGraph *gr=sensor->GetGraph();
1676  if (gr){
1677  for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
1678  Double_t x,y;
1679  gr->GetPoint(ipoint,x,y);
1680  const Int_t time=TMath::Nint(startTime+x*3600.); //time in graph is hours
1681  if (time<=timeStamp && timeStamp<=endTime) {
1682  val=y;
1683  continue;
1684  }
1685  break;
1686  }
1687  //if val is still 0, test if if the requested time is within 5min of the first/last
1688  //data point or start/end time of the sensor. If this is the case return the firs/last entry
1689  //the timestamps might not be syncronised for all calibration types, sometimes a 'pre'
1690  //and 'pos' period is requested. Especially to the HV this is not the case!
1691  //first point
1692  if (val==0 ){
1693  Double_t x,y;
1694  gr->GetPoint(0,x,y);
1695  const Int_t time=TMath::Min(TMath::Nint(startTime+x*3600.), startTime); //time in graph is hours
1696  const Int_t dtime=time-timeStamp;
1697  if ( (dtime>=0) && (dtime<5*60) ) val=y;
1698  }
1699  //last point
1700  if (val==0 ){
1701  Double_t x,y;
1702  gr->GetPoint(gr->GetN()-1,x,y);
1703  const Int_t time=TMath::Max(TMath::Nint(startTime+x*3600.), endTime); //time in graph is hours
1704  const Int_t dtime=timeStamp-time;
1705  if ( (dtime>=0) && (dtime<5*60) ) val=y;
1706  }
1707  } else {
1708  val=sensor->GetValue(timeStamp);
1709  }
1710  if (sigDigits>=0){
1711  val=(Float_t)TMath::Floor(val * TMath::Power(10., sigDigits) + .5) / TMath::Power(10., sigDigits);
1712  }
1713  return val;
1714 }
1715 
1716 Float_t AliTPCcalibDB::GetDCSSensorMeanValue(AliDCSSensorArray *arr, const char * sensorName, Int_t sigDigits)
1717 {
1719 
1720  Float_t val=0;
1721  const TString sensorNameString(sensorName);
1722  AliDCSSensor *sensor = arr->GetSensor(sensorNameString);
1723  if (!sensor) return val;
1724 
1725  //use dcs graph if it exists
1726  TGraph *gr=sensor->GetGraph();
1727  if (gr){
1728  val=gr->GetMean(2);
1729  } else {
1730  //if we don't have the dcs graph, try to get some meaningful information
1731  if (!sensor->GetFit()) return val;
1732  Int_t nKnots=sensor->GetFit()->GetKnots();
1733  Double_t tMid=(sensor->GetEndTime()-sensor->GetStartTime())/2.;
1734  for (Int_t iKnot=0;iKnot<nKnots;++iKnot){
1735  if (sensor->GetFit()->GetX()[iKnot]>tMid/3600.) break;
1736  val=(Float_t)sensor->GetFit()->GetY0()[iKnot];
1737  }
1738  }
1739  if (sigDigits>=0){
1740  // val/=10;
1741  val=(Float_t)TMath::Floor(val * TMath::Power(10., sigDigits) + .5) / TMath::Power(10., sigDigits);
1742  // val*=10;
1743  }
1744  return val;
1745 }
1746 
1748 {
1749  // set bits for masked pads
1750  int nrowsMasked=0,npadsMasked=0,npadsTotMasked=0;
1752  AliInfo("Special reconstruction for residuals extraction, masking is disabled");
1753  return 0;
1754  }
1755  AliCDBManager* man = AliCDBManager::Instance();
1756  AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
1757  if (!fld || !man->IsDefaultStorageSet() || man->GetRun()<0) {
1758  AliFatal("OCDB of B-field is not initialized");
1759  }
1760  const int run = GetRun();
1761  // pick the recoparam matching to field (as low or high flux)
1763  /*
1764  AliRecoParam::EventSpecie_t spec = fld->GetBeamType()==AliMagF::kBeamTypeAA ? AliRecoParam::kHighMult : AliRecoParam::kLowMult;
1765  int parID=0;
1766  while( (param=GetRecoParam(parID++)) ) { if (param->GetEventSpecie()&spec) break;}
1767  */
1768  if (!param) AliFatal("Failed to extract recoparam");
1769  //
1770  if (!param->GetUseCorrectionMap()) {
1771  AliInfo("Residual correction maps are not used, no masking needed");
1772  return 0;
1773  }
1774 
1775  AliTPCTransform* transform = GetTransform();
1776  if (!transform) AliFatal("Failed to extract Transform");
1777  transform->SetCurrentRecoParam(param);
1778 
1779  // Load maps covering the run and build masks for disable full rows
1780  //
1781  // get reference map
1783  //
1784  // get correction maps
1786  arrMaps->SetOwner(kTRUE);
1787  if (!((AliTPCChebCorr*)arrMaps->UncheckedAt(0))->GetTimeDependent()) {
1788  // static maps are field-dependent
1790  arrMaps->Remove((TObject*)mapKeep);
1791  arrMaps->Delete();
1792  arrMaps->Add(mapKeep); // leave only maps needed for this run if the object was default one
1793  }
1794  int nMaps = arrMaps->GetEntriesFast();
1795 
1796  // mask full rows disabled in at least one of the maps
1797  TBits maskedRows[72];
1798  for (int isec=72;isec--;) { // flag masked full rows
1799  mapRef->GetNMaskedRows(isec,&maskedRows[isec]);
1800  for (int imap=nMaps;imap--;) ((AliTPCChebCorr*)arrMaps->UncheckedAt(imap))->GetNMaskedRows(isec,&maskedRows[isec]);
1801  nrowsMasked += maskedRows[isec].CountBits();
1802  // printf("ROC%d masked %d rows\n",isec,maskedRows[isec].CountBits());
1803  }
1804  //
1805  // Now we need to mask individual pads where the assigned errors or distortions are too large
1806  // Since >1 map may cover the run, we query all off them in their central time stamps
1807  // 1) Make sure the maps are unique for this run
1808  AliGRPObject* grp = GetGRP(run);
1809  time_t tGRPmin = grp->GetTimeStart();
1810  time_t tGRPmax = grp->GetTimeEnd();
1811  time_t tCentGRP = (tGRPmin+tGRPmax)/2; // center of the run according to grp
1812  //
1813  time_t mapsT[nMaps];
1814  for (int i=0;i<nMaps;i++) {
1815  mapsT[i] = ((AliTPCChebCorr*)arrMaps->At(i))->GetTimeStampCenter();
1816  if (mapsT[i]<tGRPmin || mapsT[i]>tCentGRP) mapsT[i] = tCentGRP;
1817  }
1818  //
1819  delete arrMaps; // we don't need anymore these maps, Transform will load according to time stamp
1820  delete mapRef;
1821  //
1822  AliTPCROC* roc = AliTPCROC::Instance();
1823  double testv[3]={0.};
1824 
1825  // determine ranges for time-bin to be assigned to test cluster
1826  transform->SetCurrentTimeStamp(mapsT[0]);
1827  const double tbinMin=0.,tbinMax=800.0;
1828  testv[0] = 62.; testv[1] = 0.; testv[2] = tbinMin; // at highest pad of IROC, min drift-time
1829  transform->Local2RotatedGlobal(0,testv);
1830  const double ztMin = testv[2];
1831  testv[0] = 62.; testv[1] = 0.; testv[2] = tbinMax; // at highest pad of IROC, max drift-time
1832  transform->Local2RotatedGlobal(0,testv);
1833  const double ztMax = testv[2];
1834  const double tzSlope = (tbinMax-tbinMin)/(ztMax-ztMin);
1835  //
1836  // for test only >>>>>>>>>>
1837  // double *mxdist = (double*)param->GetBadPadMaxDistXYZ();
1838  // double *mxerr = (double*)param->GetBadPadMaxErrYZ();
1839  // mxdist[0] = 7.; mxdist[1] = 7.; mxdist[2] = 7.;
1840  // mxerr[0] = 2.; mxerr[1] = 2.;
1841  // for test only <<<<<<<<<<
1842  const double *padMaxDist = param->GetBadPadMaxDistXYZD();
1843  const double *padMaxErr = param->GetBadClusMaxErrYZ();
1844  const double maxErrY2 = padMaxErr[0]>0 ? padMaxErr[0]*padMaxErr[0] : -1.;
1845  const double maxErrZ2 = padMaxErr[1]>0 ? padMaxErr[1]*padMaxErr[1] : -1.;
1846  //
1847  const float tgLabTest = 0.2f; // check distortions/errors for this pad for high pt track at tgLab=0.2
1848  AliTPCclusterMI clProbe;
1849  for (int imap=0;imap<nMaps;imap++) {
1850  AliInfoF("Querying maps at time %ld",mapsT[imap]);
1851  transform->SetCurrentTimeStamp(mapsT[imap]);
1852  //
1853  for (int isec=72;isec--;) {
1854  TBits& padStatus = maskedPads[isec];
1855  for (int irow=roc->GetNRows(isec);irow--;) {
1856  const int npads = roc->GetNPads(isec, irow), channel0 = roc->GetRowIndexes(isec)[irow];
1857  if (maskedRows[isec].TestBitNumber(irow)) { // full row is masked
1858  for (int ipad=npads;ipad--;) padStatus.SetBitNumber(channel0+ipad); // mask all pads of the row
1859  //printf("ROC%d masked %d pads of full row %d\n",isec,npads,irow);
1860  npadsTotMasked += npads;
1861  continue;
1862  }
1863  const double xRow = roc->GetPadRowRadii(isec,irow), zTest = xRow*tgLabTest;
1864  const double tbinTest = tbinMin+(zTest-ztMin)*tzSlope; // define tbin at which distortions/errors will be evaluated
1865  for (int ipad=npads;ipad--;) {
1866  testv[0] = irow;
1867  testv[1] = 0.5+ipad; // pad center
1868  testv[2] = tbinTest;
1869  transform->Transform(testv,&isec,0,0);
1870  const float* clCorr = transform->GetLastMapCorrection();
1871  const float* clCorrRef = transform->GetLastMapCorrectionRef();
1872  Bool_t bad = kFALSE;
1873 
1874  // does the distortion exceed max.allowed?
1875  for (int dir=4;dir--;) if (padMaxDist[dir]>0. && TMath::Abs(clCorr[dir])>padMaxDist[dir]) {
1876  bad=kTRUE;
1877  // printf("ROC%2d row%2d pad%2d bad: distortion[%d]=%.2f exceeds threshold %.2f\n",
1878  // isec,npads,irow,dir,clCorr[dir],padMaxDist[dir]);
1879  break;
1880  }
1881 
1882  if (!bad) { // check errors assigned to such cluster
1883  clProbe.SetDetector(isec);
1884  clProbe.SetX(testv[0]); // store coordinates
1885  clProbe.SetY(testv[1]);
1886  clProbe.SetZ(testv[2]);
1887  clProbe.SetDistortions(clCorr[0]-clCorrRef[0],clCorr[1]-clCorrRef[1],clCorr[2]-clCorrRef[2]);
1888  clProbe.SetDistortionDispersion(clCorr[3]); // store distortions wrt ref and dispersion (ref already subtracted)
1889  const double errY2 = transform->ErrY2Syst(&clProbe,testv[1]/testv[0]);
1890  const double errZ2 = transform->ErrZ2Syst(&clProbe,testv[2]/testv[0]);
1891  if ( (maxErrY2>0 && errY2>maxErrY2) || (maxErrZ2>0 && errZ2>maxErrZ2) ) {
1892  bad=kTRUE;
1893  //printf("ROC%2d row%2d pad%2d bad: Errors^2 for Y:%.3e or Z:%.3e exceeds threshold %.3e|%.3e\n",
1894  // isec,npads,irow,errY2,errZ2,maxErrY2,maxErrZ2);
1895  }
1896  }
1897  //
1898  if (bad) {
1899  if (!padStatus.TestBitNumber(channel0+ipad)) npadsMasked++;
1900  padStatus.SetBitNumber(channel0+ipad);
1901  }
1902  } // loop over all pads of the row
1903  } // loop over all rows of the ROC
1904  } // loop over all ROCs
1905  } // loop over all maps
1906  //
1907  npadsTotMasked += npadsMasked;
1908  AliInfoF("masked %d pads (%d full padrows, %d individual pads)",
1909  npadsTotMasked,nrowsMasked,npadsMasked);
1910  transform->ResetCache();
1911  return npadsTotMasked;
1912  //
1913 }
1914 
1915 Bool_t AliTPCcalibDB::IsDataTakingActive(time_t timeStamp)
1916 {
1917  //
1918  // Check if the data taking is active.
1919  // This information ist based on the trigger scalers and calculated in UpdateChamberHighVoltageData() below.
1920  // in case there is no GRP object or no trigger scalers fGrRunState should be a NULL pointer
1921  // if this is the case we assume by default that the data taking is active
1922  // NOTE: The logik changed. Before v5-06-03-79-gc804e5a we assumed by default the data taking is inactive
1923  //
1924  if (!fGrRunState) return kTRUE;
1925  Double_t time=Double_t(timeStamp);
1926  Int_t currentPoint=0;
1927  Bool_t currentVal=fGrRunState->GetY()[currentPoint]>0.5;
1928  Bool_t retVal=currentVal;
1929  Double_t currentTime=fGrRunState->GetX()[currentPoint];
1930 
1931  while (time>currentTime){
1932  retVal=currentVal;
1933  if (currentPoint==fGrRunState->GetN()) break;
1934  currentVal=fGrRunState->GetY()[currentPoint]>0.5;
1935  currentTime=fGrRunState->GetX()[currentPoint];
1936  ++currentPoint;
1937  }
1938 
1939  return retVal;
1940 }
1941 
1943 {
1955 
1956  // reset active run state graph
1957  delete fGrRunState;
1958  fGrRunState=0x0;
1959 
1960  // start and end time of the run
1961  const Int_t run=GetRun();
1962  if (run<0) return;
1963 
1964  // if no valid run information - return
1965  AliGRPObject* grp = GetGRP(run);
1966  if (!grp) return;
1967 
1968  const Int_t startTimeGRP = grp->GetTimeStart();
1969  const Int_t stopTimeGRP = grp->GetTimeEnd();
1970 
1971  //
1972  // In case we use a generated GRP we cannot make use of the start time and end time information
1973  // therefore we cannot calculate proper HV information and will skip this
1974  //
1975  if (startTimeGRP==0 && stopTimeGRP==0) {
1976  AliWarning("Using a generated GRP with 'GetTimeStart()' and 'GetTimeEnd()' == 0. Cannot calculate HV information.");
1977  return;
1978  }
1979 
1980  //
1981  // check active state by analysing the scalers
1982  //
1983  // initialise graph with active running
1984  const char* hltMode = NULL;
1985  hltMode = gSystem->Getenv("HLT_ONLINE_MODE");
1986 
1987  AliCDBEntry *entry = NULL;
1988  if (!hltMode) entry = GetCDBEntry("GRP/CTP/Scalers");
1989  if (entry) {
1990  // entry->SetOwner(kTRUE);
1991  AliTriggerRunScalers *sca = (AliTriggerRunScalers*)entry->GetObject();
1992  Int_t nchannels = sca->GetNumClasses(); // number of scaler channels (i.e. trigger classes)
1993  Int_t npoints = sca->GetScalersRecords()->GetEntries(); // number of samples
1994 
1995  // require at least two points from the scalers.
1996  if (npoints>1) {
1997  fGrRunState=new TGraph;
1998  fGrRunState->SetPoint(fGrRunState->GetN(),Double_t(startTimeGRP)-.001,0);
1999  fGrRunState->SetPoint(fGrRunState->GetN(),Double_t(startTimeGRP),1);
2000  ULong64_t lastSum=0;
2001  Double_t timeLast=Double_t(startTimeGRP);
2002  Bool_t active=kTRUE;
2003  for (int i=0; i<npoints; i++) {
2004  AliTriggerScalersRecord *rec = (AliTriggerScalersRecord *) sca->GetScalersRecord(i);
2005  Double_t time = ((AliTimeStamp*) rec->GetTimeStamp())->GetSeconds();
2006  // check if time is inside the grp times. For dummy scaler entries the time might be compatible with 0
2007  if ( time<startTimeGRP || time>stopTimeGRP ){
2008  AliWarning(Form("Time of scaler record %d: %.0f is outside the GRP times (%d, %d). Skipping this record.", i, time, startTimeGRP, stopTimeGRP));
2009  continue;
2010  }
2011  ULong64_t sum=0;
2012  for (int j=0; j<nchannels; j++) sum += ((AliTriggerScalers*) rec->GetTriggerScalers()->At(j))->GetL2CA();
2013  if (TMath::Abs(time-timeLast)<.001 && sum==lastSum ) continue;
2014  if (active && sum==lastSum){
2015  fGrRunState->SetPoint(fGrRunState->GetN(),timeLast-.01,1);
2016  fGrRunState->SetPoint(fGrRunState->GetN(),timeLast,0);
2017  active=kFALSE;
2018  } else if (!active && sum>lastSum ){
2019  fGrRunState->SetPoint(fGrRunState->GetN(),timeLast-.01,0);
2020  fGrRunState->SetPoint(fGrRunState->GetN(),timeLast,1);
2021  active=kTRUE;
2022  }
2023  lastSum=sum;
2024  timeLast=time;
2025  }
2026  fGrRunState->SetPoint(fGrRunState->GetN(),Double_t(stopTimeGRP),active);
2027  fGrRunState->SetPoint(fGrRunState->GetN(),Double_t(stopTimeGRP)+.001,0);
2028  } else {
2029  AliWarning("Only one entry found in the trigger scalers. Most probably this is a dummy entry. Scaler information will not be used!");
2030  }
2031  }
2032 
2033 
2034  // reset all values
2035  for (Int_t iROC=0;iROC<72;++iROC) {
2036  fChamberHVmedian[iROC] = -1;
2037  fChamberHVgoodFraction[iROC] = 0.;
2038  fCurrentNominalVoltage[iROC] = -999.;
2039  fChamberHVStatus[iROC] = kFALSE;
2040  }
2041 
2042  AliDCSSensorArray* voltageArray = GetVoltageSensors(run);
2043  if (!voltageArray) {
2044  AliError("Voltage Array missing. Cannot calculate HV information!");
2045  AliError(" -> Check OCDB entry: 'TPC/Calib/HighVoltage'");
2046  return;
2047  }
2048 
2049  // max HV diffs before a chamber is masked
2050  const Float_t maxVdiff = fParam->GetMaxVoltageDeviation();
2051  const Float_t maxDipVoltage = fParam->GetMaxDipVoltage();
2052  const Float_t maxFracHVbad = fParam->GetMaxFractionHVbad();
2053 
2054  const Int_t samplingPeriod=1;
2055 
2056  // array with sampled voltages
2057  const Int_t maxSamples=(stopTimeGRP-startTimeGRP)/samplingPeriod + 10*samplingPeriod;
2058  Float_t *vSampled = new Float_t[maxSamples];
2059 
2060  // deviation of the median from the nominal voltage
2061  Double_t chamberMedianDeviation[72]={0.};
2062 
2063  for (Int_t iROC=0; iROC<72; ++iROC){
2064  chamberMedianDeviation[iROC]=0.;
2065  TString sensorName="";
2066  Char_t sideName='A';
2067  if ((iROC/18)%2==1) sideName='C';
2068  if (iROC<36) sensorName=Form("TPC_ANODE_I_%c%02d_VMEAS",sideName,iROC%18);
2069  else sensorName=Form("TPC_ANODE_O_%c%02d_0_VMEAS",sideName,iROC%18);
2070 
2071  AliDCSSensor *sensor = voltageArray->GetSensor(sensorName);
2072 
2073  fHVsensors[iROC]=sensor;
2074  if (!sensor) continue;
2075 
2076  Int_t nPointsSampled=0;
2077 
2078  TGraph *gr=sensor->GetGraph();
2079  if ( gr && gr->GetN()>0 ){
2080  //1. sample voltage over time
2081  // get a robust median
2082  // buffer sampled voltages
2083 
2084  // current sampling time
2085  Int_t time=startTimeGRP;
2086 
2087  // input graph sampling point
2088  const Int_t nGraph=gr->GetN();
2089  Int_t pointGraph=0;
2090 
2091  //initialise graph information
2092  Int_t timeGraph=stopTimeGRP;
2093  if (gr->GetN()>1) timeGraph=TMath::Nint(gr->GetX()[pointGraph+1]*3600+sensor->GetStartTime());
2094  Double_t sampledHV=gr->GetY()[pointGraph++];
2095 
2096  while (time<stopTimeGRP){
2097  while (timeGraph<=time && pointGraph+1<nGraph){
2098  timeGraph=TMath::Nint(gr->GetX()[pointGraph+1]*3600+sensor->GetStartTime());
2099  sampledHV=gr->GetY()[pointGraph++];
2100  }
2101  time+=samplingPeriod;
2102  if (!IsDataTakingActive(time-samplingPeriod)) continue;
2103  vSampled[nPointsSampled++]=sampledHV;
2104  }
2105 
2106  if (nPointsSampled<1) continue;
2107 
2108  fChamberHVmedian[iROC]=TMath::Median(nPointsSampled,vSampled);
2109  chamberMedianDeviation[iROC]=fChamberHVmedian[iROC]-fParam->GetNominalVoltage(iROC);
2110 
2111  //2. calculate good HV fraction
2112  Int_t ngood=0;
2113  for (Int_t ipoint=0; ipoint<nPointsSampled; ++ipoint) {
2114  if (TMath::Abs(vSampled[ipoint]-fChamberHVmedian[iROC])<maxDipVoltage) ++ngood;
2115  }
2116 
2117  fChamberHVgoodFraction[iROC]=Float_t(ngood)/Float_t(nPointsSampled);
2118  } else if (!gr && !sensor->GetFit() ){
2119  // This is an exception handling.
2120  // It was observed that for some rund in the 2010 data taking no HV info is available
2121  // for some sectors. However they were active. So take care about this
2122  fChamberHVmedian[iROC] = fParam->GetNominalVoltage(iROC);
2123  fChamberHVgoodFraction[iROC] = 1.;
2124  AliWarning(Form("ROC %d detected without HV Splines and HV graph. Will set median HV to nominal voltage",iROC));
2125  } else {
2126  AliError(Form("No Graph or graph without points found for HV sensor of ROC %d",iROC));
2127  }
2128  }
2129 
2130  delete [] vSampled;
2131  vSampled=0x0;
2132 
2133  // get median deviation from all chambers (detect e.g. -50V)
2134  const Double_t medianIROC=TMath::Median( 36, chamberMedianDeviation );
2135  const Double_t medianOROC=TMath::Median( 36, chamberMedianDeviation+36 );
2136 
2137  // Define current default voltages
2138  for (Int_t iROC=0;iROC<72/*AliTPCCalPad::kNsec*/;++iROC){
2139  const Float_t averageDeviation=(iROC<36)?medianIROC:medianOROC;
2140  fCurrentNominalVoltage[iROC]=fParam->GetNominalVoltage(iROC)+averageDeviation;
2141  }
2142 
2143  //
2144  // Check HV status
2145  //
2146  Int_t nbad=0;
2147  for (Int_t iROC=0;iROC<72/*AliTPCCalPad::kNsec*/;++iROC){
2148  fChamberHVStatus[iROC]=kTRUE;
2149  const Float_t averageDeviation=(iROC<36)?medianIROC:medianOROC;
2150 
2151  //a. Deviation of median from current nominal voltage
2152  // allow larger than nominal voltages
2153  if (fCurrentNominalVoltage[iROC]-fChamberHVmedian[iROC] > maxVdiff) {
2154  AliWarning(Form("Low voltage detected for ROC %2d",iROC));
2155  AliWarning(Form(" -> Based on nominal voltage: %.2f + averge deviation: %.2f = current nominal voltage: %.2f - meadian HV: %.2f > max diff: %.2f",
2156  fParam->GetNominalVoltage(iROC), averageDeviation, fCurrentNominalVoltage[iROC], fChamberHVmedian[iROC], maxVdiff));
2157  AliWarning(" -> Check consistent usage of HV information in the OCDB entry: 'TPC/Calib/HighVoltage'");
2158  AliWarning(" -> and the nominal voltages in the OCDB entry: 'TPC/Calib/Parameters'");
2159  fChamberHVStatus[iROC]=kFALSE;
2160  }
2161 
2162  //b. Fraction of bad hv values
2163  if ( 1.-fChamberHVgoodFraction[iROC] > maxFracHVbad ) {
2164  AliWarning(Form("Large fraction of low HV readings detected in ROC %2d: %.2f > %.2f",
2165  iROC, 1.-fChamberHVgoodFraction[iROC], maxFracHVbad));
2166  AliWarning(Form(" -> Based on HV information from OCDB entry: 'TPC/Calib/HighVoltage' with median voltage: %.2f", fChamberHVmedian[iROC]));
2167  AliWarning( " -> Check with experts if this chamber had HV problems in this run");
2168  fChamberHVStatus[iROC]=kFALSE;
2169  }
2170 
2171  if (!fChamberHVStatus[iROC]) {
2172  ++nbad;
2173  }
2174  }
2175 
2176  // check if all chamber are off
2177  if (nbad==72) {
2178  AliFatal("Something went wrong in the chamber HV status calculation. Check warning messages above. All chambers would be deactivated!");
2179  }
2180 }
2181 Float_t AliTPCcalibDB::GetGasSensorValue(EDcsGasSensor type, Int_t timeStamp/*=-1*/, Int_t sigDigits/*=-1*/)
2182 {
2185 
2186  if (!fGasSensorArray || Int_t(type)<0 || Int_t(type)>=Int_t(kNGasSensor) ) return 0.;
2187 
2188  // ===| Average value |===
2189  if (timeStamp==-1){
2191  }
2192 
2193  // ===| Value at given time stamp |===
2194  TTimeStamp stamp(timeStamp);
2195  return AliTPCcalibDB::GetDCSSensorValue(fGasSensorArray, timeStamp, fgkGasSensorNames[Int_t(type)], sigDigits);
2196 }
2197 
2198 
2199 Float_t AliTPCcalibDB::GetChamberHighVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits, Bool_t current) {
2202 
2203  Float_t val=0;
2204  TString sensorName="";
2205  TTimeStamp stamp(timeStamp);
2206  AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
2207  if (!voltageArray || (sector<0) || (sector>71)) return val;
2208  Char_t sideName='A';
2209  if ((sector/18)%2==1) sideName='C';
2210  if (sector<36){
2211  //IROC
2212  sensorName=Form("TPC_ANODE_I_%c%02d_VMEAS",sideName,sector%18);
2213  }else{
2214  //OROC
2215  sensorName=Form("TPC_ANODE_O_%c%02d_0_VMEAS",sideName,sector%18);
2216  }
2217  if (current){
2218  if (sector<36){
2219  //IROC
2220  sensorName=Form("TPC_ANODE_I_%c%02d_IMEAS",sideName,sector%18);
2221  }else{
2222  //OROC
2223  sensorName=Form("TPC_ANODE_O_%c%02d_0_IMEAS",sideName,sector%18);
2224  }
2225 
2226  }
2227  if (timeStamp==-1){
2228  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2229  } else {
2230  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2231  }
2232  return val;
2233 }
2234 Float_t AliTPCcalibDB::GetSkirtVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
2235 {
2239 
2240  Float_t val=0;
2241  TString sensorName="";
2242  TTimeStamp stamp(timeStamp);
2243  AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
2244  if (!voltageArray || (sector<0) || (sector>71)) return val;
2245  Char_t sideName='A';
2246  if ((sector/18)%2==1) sideName='C';
2247  sensorName=Form("TPC_SKIRT_%c_VMEAS",sideName);
2248  if (timeStamp==-1){
2249  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2250  } else {
2251  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2252  }
2253  return val;
2254 }
2255 
2256 Float_t AliTPCcalibDB::GetCoverVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
2257 {
2261 
2262  Float_t val=0;
2263  TString sensorName="";
2264  TTimeStamp stamp(timeStamp);
2265  AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
2266  if (!voltageArray || (sector<0) || (sector>71)) return val;
2267  Char_t sideName='A';
2268  if ((sector/18)%2==1) sideName='C';
2269  if (sector<36){
2270  //IROC
2271  sensorName=Form("TPC_COVER_I_%c_VMEAS",sideName);
2272  }else{
2273  //OROC
2274  sensorName=Form("TPC_COVER_O_%c_VMEAS",sideName);
2275  }
2276  if (timeStamp==-1){
2277  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2278  } else {
2279  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2280  }
2281  return val;
2282 }
2283 
2284 Float_t AliTPCcalibDB::GetGGoffsetVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
2285 {
2289 
2290  Float_t val=0;
2291  TString sensorName="";
2292  TTimeStamp stamp(timeStamp);
2293  AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
2294  if (!voltageArray || (sector<0) || (sector>71)) return val;
2295  Char_t sideName='A';
2296  if ((sector/18)%2==1) sideName='C';
2297  if (sector<36){
2298  //IROC
2299  sensorName=Form("TPC_GATE_I_%c_OFF_VMEAS",sideName);
2300  }else{
2301  //OROC
2302  sensorName=Form("TPC_GATE_O_%c_OFF_VMEAS",sideName);
2303  }
2304  if (timeStamp==-1){
2305  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2306  } else {
2307  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2308  }
2309  return val;
2310 }
2311 
2312 Float_t AliTPCcalibDB::GetGGnegVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
2313 {
2317 
2318  Float_t val=0;
2319  TString sensorName="";
2320  TTimeStamp stamp(timeStamp);
2321  AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
2322  if (!voltageArray || (sector<0) || (sector>71)) return val;
2323  Char_t sideName='A';
2324  if ((sector/18)%2==1) sideName='C';
2325  if (sector<36){
2326  //IROC
2327  sensorName=Form("TPC_GATE_I_%c_NEG_VMEAS",sideName);
2328  }else{
2329  //OROC
2330  sensorName=Form("TPC_GATE_O_%c_NEG_VMEAS",sideName);
2331  }
2332  if (timeStamp==-1){
2333  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2334  } else {
2335  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2336  }
2337  return val;
2338 }
2339 
2340 Float_t AliTPCcalibDB::GetGGposVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
2341 {
2345 
2346  Float_t val=0;
2347  TString sensorName="";
2348  TTimeStamp stamp(timeStamp);
2349  AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
2350  if (!voltageArray || (sector<0) || (sector>71)) return val;
2351  Char_t sideName='A';
2352  if ((sector/18)%2==1) sideName='C';
2353  if (sector<36){
2354  //IROC
2355  sensorName=Form("TPC_GATE_I_%c_POS_VMEAS",sideName);
2356  }else{
2357  //OROC
2358  sensorName=Form("TPC_GATE_O_%c_POS_VMEAS",sideName);
2359  }
2360  if (timeStamp==-1){
2361  val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
2362  } else {
2363  val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
2364  }
2365  return val;
2366 }
2367 
2368 Float_t AliTPCcalibDB::GetPressure(Int_t timeStamp, Int_t run, Int_t type){
2370 
2371  TTimeStamp stamp(timeStamp);
2372  AliDCSSensor * sensor = Instance()->GetPressureSensor(run,type);
2373  if (!sensor) return 0;
2374  return sensor->GetValue(stamp);
2375 }
2376 
2377 Float_t AliTPCcalibDB::GetL3Current(Int_t run, Int_t statType){
2380 
2381  Float_t current=-1;
2382  AliGRPObject *grp=AliTPCcalibDB::GetGRP(run);
2383  if (grp) current=grp->GetL3Current((AliGRPObject::Stats)statType);
2384  return current;
2385 }
2386 
2387 Float_t AliTPCcalibDB::GetBz(Int_t run){
2389 
2390  Float_t bz=-1;
2391  Float_t current=AliTPCcalibDB::GetL3Current(run);
2392  if (current>-1) bz=5*current/30000.*.1;
2393  return bz;
2394 }
2395 
2396 Char_t AliTPCcalibDB::GetL3Polarity(Int_t run) {
2398 
2399  Char_t pol=-100;
2400  AliGRPObject *grp=AliTPCcalibDB::GetGRP(run);
2401  if (grp) pol=grp->GetL3Polarity();
2402  return pol;
2403 }
2404 
2405 TString AliTPCcalibDB::GetRunType(Int_t run){
2407 
2408 // TString type("UNKNOWN");
2409  AliGRPObject *grp=AliTPCcalibDB::GetGRP(run);
2410  if (grp) return grp->GetRunType();
2411  return "UNKNOWN";
2412 }
2413 
2414 Float_t AliTPCcalibDB::GetValueGoofie(Int_t timeStamp, Int_t run, Int_t type){
2416 
2417  TTimeStamp stamp(timeStamp);
2418  AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(run);
2419  if (!goofieArray) return 0;
2420  AliDCSSensor *sensor = goofieArray->GetSensor(type);
2421  return sensor->GetValue(stamp);
2422 }
2423 
2424 
2425 
2426 
2427 
2428 
2429 Bool_t AliTPCcalibDB::GetTemperatureFit(Int_t timeStamp, Int_t run, Int_t side,TVectorD& fit){
2431 
2432  TTimeStamp tstamp(timeStamp);
2434  if (! tempArray) return kFALSE;
2435  AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray);
2436  TLinearFitter * fitter = tempMap->GetLinearFitter(3,side,tstamp);
2437  if (fitter){
2438  fitter->Eval();
2439  fitter->GetParameters(fit);
2440  }
2441  delete fitter;
2442  delete tempMap;
2443  if (!fitter) return kFALSE;
2444  return kTRUE;
2445 }
2446 
2447 Float_t AliTPCcalibDB::GetTemperature(Int_t timeStamp, Int_t run, Int_t side){
2449 
2450  TVectorD vec(5);
2451  if (side==0) {
2452  GetTemperatureFit(timeStamp,run,0,vec);
2453  return vec[0];
2454  }
2455  if (side==1){
2456  GetTemperatureFit(timeStamp,run,0,vec);
2457  return vec[0];
2458  }
2459  return 0;
2460 }
2461 
2462 
2463 Double_t AliTPCcalibDB::GetPTRelative(UInt_t timeSec, Int_t run, Int_t side){
2468 
2470  if (!vdrift) return 0;
2471  return vdrift->GetPTRelative(timeSec,side);
2472 }
2473 
2474 AliGRPObject * AliTPCcalibDB::MakeGRPObjectFromMap(TMap *map){
2478 
2479  if (!map) return 0;
2480  AliDCSSensor * sensor = 0;
2481  TObject *osensor=0;
2482  osensor = ((*map)("fP2Pressure"));
2483  sensor =dynamic_cast<AliDCSSensor *>(osensor);
2484  //
2485  if (!sensor) return 0;
2486  //
2487  AliDCSSensor * sensor2 = new AliDCSSensor(*sensor);
2488  osensor = ((*map)("fCavernPressure"));
2489  TGraph * gr = new TGraph(2);
2490  gr->GetX()[0]= -100000.;
2491  gr->GetX()[1]= 1000000.;
2492  gr->GetY()[0]= atof(osensor->GetName());
2493  gr->GetY()[1]= atof(osensor->GetName());
2494  sensor2->SetGraph(gr);
2495  sensor2->SetFit(0);
2496 
2497 
2498  AliGRPObject *grpRun = new AliGRPObject;
2499  grpRun->ReadValuesFromMap(map);
2500  grpRun->SetCavernAtmosPressure(sensor2);
2501  grpRun->SetCavernAtmosPressure(sensor2);
2502  grpRun->SetSurfaceAtmosPressure(sensor);
2503  return grpRun;
2504 }
2505 
2506 Bool_t AliTPCcalibDB::CreateGUITree(Int_t run, const char* filename)
2507 {
2509 
2510  if (!AliCDBManager::Instance()->GetDefaultStorage()){
2511  AliLog::Message(AliLog::kError, "Default Storage not set. Cannot create Calibration Tree!",
2512  MODULENAME(), "AliTPCcalibDB", FUNCTIONNAME(), __FILE__, __LINE__);
2513  return kFALSE;
2514  }
2515  //db instance
2517  // retrieve cal pad objects
2518  db->SetRun(run);
2519  db->CreateGUITree(filename);
2520  return kTRUE;
2521 }
2522 
2523 Bool_t AliTPCcalibDB::CreateGUITree(const char* filename){
2525 
2526  if (!AliCDBManager::Instance()->GetDefaultStorage()){
2527  AliError("Default Storage not set. Cannot create calibration Tree!");
2528  return kFALSE;
2529  }
2530  UpdateNonRec(); // load all infromation now
2531 
2534 
2535  // gain map
2537  //noise and pedestals
2538  if (GetPedestals()) prep.AddComponent(new AliTPCCalPad(*(GetPedestals())));
2539  if (GetPadNoise() ) prep.AddComponent(new AliTPCCalPad(*(GetPadNoise())));
2540  //pulser data
2541  if (GetPulserTmean()) prep.AddComponent(new AliTPCCalPad(*(GetPulserTmean())));
2542  if (GetPulserTrms() ) prep.AddComponent(new AliTPCCalPad(*(GetPulserTrms())));
2543  if (GetPulserQmean()) prep.AddComponent(new AliTPCCalPad(*(GetPulserQmean())));
2544  //CE data
2545  if (GetCETmean()) prep.AddComponent(new AliTPCCalPad(*(GetCETmean())));
2546  if (GetCETrms() ) prep.AddComponent(new AliTPCCalPad(*(GetCETrms())));
2547  if (GetCEQmean()) prep.AddComponent(new AliTPCCalPad(*(GetCEQmean())));
2548  //Altro data
2550  if (GetALTROZsThr() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROZsThr() )));
2551  if (GetALTROFPED() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROFPED() )));
2552  if (GetALTROAcqStop() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROAcqStop() )));
2553  if (GetALTROMasked() ) prep.AddComponent(new AliTPCCalPad(*(GetALTROMasked() )));
2554  //QA
2555  AliTPCdataQA *dataQA=GetDataQA();
2556  if (dataQA) {
2557  if (dataQA->GetNLocalMaxima())
2558  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNLocalMaxima())));
2559  if (dataQA->GetMaxCharge())
2560  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetMaxCharge())));
2561  if (dataQA->GetMeanCharge())
2562  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetMeanCharge())));
2563  if (dataQA->GetNoThreshold())
2564  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNoThreshold())));
2565  if (dataQA->GetNTimeBins())
2566  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNTimeBins())));
2567  if (dataQA->GetNPads())
2568  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetNPads())));
2569  if (dataQA->GetTimePosition())
2570  prep.AddComponent(new AliTPCCalPad(*(dataQA->GetTimePosition())));
2571  }
2572 
2573  //
2574  TString file(filename);
2575  if (file.IsNull()) file=Form("guiTreeRun_%i.root",fRun);
2576  prep.DumpToFile(file.Data());
2577  return kTRUE;
2578 }
2579 
2580 Bool_t AliTPCcalibDB::CreateRefFile(Int_t run, const char* filename)
2581 {
2583 
2584  if (!AliCDBManager::Instance()->GetDefaultStorage()){
2585  AliLog::Message(AliLog::kError, "Default Storage not set. Cannot create Calibration Tree!",
2586  MODULENAME(), "AliTPCcalibDB", FUNCTIONNAME(), __FILE__, __LINE__);
2587  return kFALSE;
2588  }
2589  TString file(filename);
2590  if (file.IsNull()) file=Form("RefCalPads_%d.root",run);
2591  TDirectory *currDir=gDirectory;
2592  //db instance
2594  // retrieve cal pad objects
2595  db->SetRun(run);
2596  //open file
2597  TFile f(file.Data(),"recreate");
2598  //noise and pedestals
2599  db->GetPedestals()->Write("Pedestals");
2600  db->GetPadNoise()->Write("PadNoise");
2601  //pulser data
2602  db->GetPulserTmean()->Write("PulserTmean");
2603  db->GetPulserTrms()->Write("PulserTrms");
2604  db->GetPulserQmean()->Write("PulserQmean");
2605  //CE data
2606  db->GetCETmean()->Write("CETmean");
2607  db->GetCETrms()->Write("CETrms");
2608  db->GetCEQmean()->Write("CEQmean");
2609  //Altro data
2610  db->GetALTROAcqStart() ->Write("ALTROAcqStart");
2611  db->GetALTROZsThr() ->Write("ALTROZsThr");
2612  db->GetALTROFPED() ->Write("ALTROFPED");
2613  db->GetALTROAcqStop() ->Write("ALTROAcqStop");
2614  db->GetALTROMasked() ->Write("ALTROMasked");
2615  //
2616  f.Close();
2617  currDir->cd();
2618  return kTRUE;
2619 }
2620 
2621 
2622 
2623 Double_t AliTPCcalibDB::GetVDriftCorrectionTime(Int_t timeStamp, Int_t run, Int_t /*side*/, Int_t mode){
2633 
2634  Double_t result=0;
2635  // mode 1 automatic mode - according to the distance to the valid calibration
2636  // -
2637  Double_t deltaP=0, driftP=0, wP = 0.;
2638  Double_t deltaITS=0,driftITS=0, wITS= 0.;
2639  Double_t deltaLT=0, driftLT=0, wLT = 0.;
2640  Double_t deltaCE=0, driftCE=0, wCE = 0.;
2641  driftP = fDButil->GetVDriftTPC(deltaP,run,timeStamp);
2642  driftITS= fDButil->GetVDriftTPCITS(deltaITS,run,timeStamp);
2643  driftCE = fDButil->GetVDriftTPCCE(deltaCE, run,timeStamp,36000,2);
2644  driftLT = fDButil->GetVDriftTPCLaserTracks(deltaLT,run,timeStamp,36000,2);
2645  deltaITS = TMath::Abs(deltaITS);
2646  deltaP = TMath::Abs(deltaP);
2647  deltaLT = TMath::Abs(deltaLT);
2648  deltaCE = TMath::Abs(deltaCE);
2649  if (mode==1) {
2650  const Double_t kEpsilon=0.00000000001;
2651  const Double_t kdeltaT=360.; // 10 minutes
2652  if(TMath::Abs(deltaITS) < 12*kdeltaT) {
2653  result = driftITS;
2654  } else {
2655  wITS = 64.*kdeltaT/(deltaITS +kdeltaT);
2656  wLT = 16.*kdeltaT/(deltaLT +kdeltaT);
2657  wP = 0. *kdeltaT/(deltaP +kdeltaT);
2658  wCE = 1. *kdeltaT/(deltaCE +kdeltaT);
2659  //
2660  //
2661  if (TMath::Abs(driftP)<kEpsilon) wP=0; // invalid calibration
2662  if (TMath::Abs(driftITS)<kEpsilon)wITS=0; // invalid calibration
2663  if (TMath::Abs(driftLT)<kEpsilon) wLT=0; // invalid calibration
2664  if (TMath::Abs(driftCE)<kEpsilon) wCE=0; // invalid calibration
2665  if (wP+wITS+wLT+wCE<kEpsilon) return 0;
2666  result = (driftP*wP+driftITS*wITS+driftLT*wLT+driftCE*wCE)/(wP+wITS+wLT+wCE);
2667  }
2668 
2669 
2670  }
2671 
2672  return result;
2673 }
2674 
2675 Double_t AliTPCcalibDB::GetTime0CorrectionTime(Int_t timeStamp, Int_t run, Int_t /*side*/, Int_t mode){
2686 
2687  Double_t result=0;
2688  if (mode==2) {
2689  // TPC-TPC mode
2690  result=fDButil->GetTriggerOffsetTPC(run,timeStamp);
2691  result *=fParam->GetZLength();
2692  }
2693  if (mode==1){
2694  // TPC-ITS mode
2695  Double_t dist=0;
2696  result= -fDButil->GetTime0TPCITS(dist, run, timeStamp)*fParam->GetDriftV()/1000000.;
2697  }
2698  return result;
2699 
2700 }
2701 
2702 
2703 
2704 
2705 Double_t AliTPCcalibDB::GetVDriftCorrectionGy(Int_t timeStamp, Int_t run, Int_t side, Int_t /*mode*/){
2716 
2717  if (run<=0 && fTransform) run = fTransform->GetCurrentRunNumber();
2718  UpdateRunInformations(run,kFALSE);
2720  if (!array) return 0;
2721  Double_t result=0;
2722 
2723  // use TPC-ITS if present
2724  TGraphErrors *gr= (TGraphErrors*)array->FindObject("ALIGN_ITSB_TPC_VDGY");
2725  if (!gr) gr = (TGraphErrors*)array->FindObject("ALIGN_TOFB_TPC_VDGY");
2726  if(gr) {
2727  result = AliTPCcalibDButil::EvalGraphConst(gr,timeStamp);
2728 
2729  // transform from [(cm/mus)/ m] to [1/cm]
2730  result /= (fParam->GetDriftV()/1000000.);
2731  result /= 100.;
2732 
2733  //printf("result %e \n", result);
2734  return result;
2735  }
2736 
2737  // use laser if ITS-TPC not present
2738  TGraphErrors *laserA= (TGraphErrors*)array->FindObject("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_A");
2739  TGraphErrors *laserC= (TGraphErrors*)array->FindObject("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_C");
2740 
2741  if (laserA && laserC){
2742  result= (laserA->Eval(timeStamp)+laserC->Eval(timeStamp))*0.5;
2743  }
2744  if (laserA && side==0){
2745  result = (laserA->Eval(timeStamp));
2746  }
2747  if (laserC &&side==1){
2748  result = (laserC->Eval(timeStamp));
2749  }
2750  //printf("laser result %e \n", -result/250.);
2751 
2752  return -result/250.; //normalized before
2753 }
2754 
2755 
2756 Double_t AliTPCcalibDB::GetVDriftCorrectionDeltaZ(Int_t /*timeStamp*/, Int_t run, Int_t /*side*/, Int_t /*mode*/){
2759 
2760  // Arguments:
2761  // mode determines the algorith how to combine the Laser Track, LaserCE or TPC-ITS
2762  // timestamp - not used
2763  // run - run number
2764  // side - common for boith sides
2765  //
2766  if (run<=0 && fTransform) run = fTransform->GetCurrentRunNumber();
2767  UpdateRunInformations(run,kFALSE);
2769  if (!array) return 0;
2770  Double_t result=0;
2771 
2772  // use TPC-ITS if present
2773  TGraphErrors *gr= (TGraphErrors*)array->FindObject("ALIGN_ITSB_TPC_DELTAZ");
2774  if(gr) {
2775  result = TMath::Mean(gr->GetN(), gr->GetY());
2776  }
2777  return result;
2778 }
2779 
2780 
2781 
2782 
2783 AliTPCCalPad* AliTPCcalibDB::MakeDeadMap(Double_t notInMap, const char* nameMappingFile) {
2790 
2791  char chinfo[1000];
2792 
2793  TFile *fileMapping = new TFile(nameMappingFile, "read");
2794  AliTPCmapper *mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
2795  if (!mapping) {
2796  snprintf(chinfo,1000,"Failed to get mapping object from %s. ...\n", nameMappingFile);
2797  AliError (chinfo);
2798  return 0;
2799  }
2800 
2801  AliTPCCalPad *deadMap = new AliTPCCalPad("deadMap","deadMap");
2802  if (!deadMap) {
2803  AliError("Failed to allocate dead map AliTPCCalPad");
2804  return 0;
2805  }
2806 
2808  Int_t idDDL=0;
2809  if (!fALTROConfigData ) {
2810  AliError("No ALTRO config OCDB entry available");
2811  return 0;
2812  }
2813  TMap *activeDDL = (TMap*)fALTROConfigData->FindObject("DDLArray");
2814  TObjString *ddlArray=0;
2815  if (activeDDL) {
2816  ddlArray = (TObjString*)activeDDL->GetValue("DDLArray");
2817  if (!ddlArray) {
2818  AliError("Empty list of active DDLs in OCDB entry");
2819  return 0;
2820  }
2821  } else {
2822  AliError("List of active DDLs not available in OCDB entry");
2823  return 0;
2824  }
2825  TString arrDDL=ddlArray->GetString();
2826  Int_t offset = mapping->GetTpcDdlOffset();
2827  Double_t active;
2828  for (Int_t i=0; i<mapping->GetNumDdl(); i++) {
2829  idDDL= i+offset;
2830  if (idDDL<0) continue;
2831  Int_t patch = mapping->GetPatchFromEquipmentID(idDDL);
2832  if (patch<0) continue;
2833  Int_t roc=mapping->GetRocFromEquipmentID(idDDL);
2834  if (roc<0) continue;
2835  AliTPCCalROC *calRoc=deadMap->GetCalROC(roc);
2836  if (calRoc) {
2837  for ( Int_t branch = 0; branch < 2; branch++ ) {
2838  for ( Int_t fec = 0; fec < mapping->GetNfec(patch, branch); fec++ ) {
2839  for ( Int_t altro = 0; altro < 8; altro++ ) {
2840  for ( Int_t channel = 0; channel < 16; channel++ ) {
2841  Int_t hwadd = mapping->CodeHWAddress(branch, fec, altro, channel);
2842  Int_t row = mapping->GetPadRow(patch, hwadd); // row in a ROC (IROC or OROC)
2843 // Int_t globalrow = mapping.GetGlobalPadRow(patch, hwadd); // row in full sector (IROC plus OROC)
2844  Int_t pad = mapping->GetPad(patch, hwadd);
2845  if (!TString(arrDDL[i]).IsDigit()) {
2846  active = notInMap;
2847  } else {
2848  active=TString(arrDDL[i]).Atof();
2849  }
2850  calRoc->SetValue(row,pad,active);
2851  } // end channel for loop
2852  } // end altro for loop
2853  } // end fec for loop
2854  } // end branch for loop
2855  } // valid calROC
2856  } // end loop on active DDLs
2857  return deadMap;
2858 }
2859 
2860 
2861 
2867 
2868  if (!fComposedCorrectionArray) return 0;
2869  if (field>0.1 && fComposedCorrectionArray->At(1)) {
2870  return (AliTPCCorrection *)fComposedCorrectionArray->At(1);
2871  }
2872  if (field<-0.1 &&fComposedCorrectionArray->At(2)) {
2873  return (AliTPCCorrection *)fComposedCorrectionArray->At(2);
2874  }
2875  return (AliTPCCorrection *)fComposedCorrectionArray->At(0);
2876 
2877 }
2878 
2879 
2883 
2884  if (!fComposedCorrectionArray) return 0;
2885  if (fRun<0) return 0;
2886  if (fDriftCorrectionArray.GetValue(Form("%i",fRun))==0) return 0;
2887  if (fComposedCorrectionArray->GetEntriesFast()<=4) {
2888  fComposedCorrectionArray->Expand(5);
2889  TObjArray * timeArray =(TObjArray*)(fDriftCorrectionArray.GetValue(Form("%i",fRun)));
2890  AliTPCCorrection * correctionTime = (AliTPCCorrection *)timeArray->FindObject("FitCorrectionTime");
2891  if (correctionTime){
2892  correctionTime->Init();
2893  fComposedCorrectionArray->AddAt(correctionTime,4); //add time dependent c
2894  }
2895  }
2896  return (AliTPCCorrection *)fComposedCorrectionArray->At(4); //
2897 }
2898 
2899 Double_t AliTPCcalibDB::GetGainCorrectionHVandPT(Int_t timeStamp, Int_t run, Int_t sector, Int_t deltaCache, Int_t mode){
2917 
2918  static Float_t gGainCorrection[72];
2919  static Float_t gGainCorrectionPT[72];
2920  static Float_t gGainCorrectionHV[72];
2921  static Int_t gTimeStamp=-99999999;
2922  static Bool_t hasTimeDependent=kFALSE;
2923  if ( TMath::Abs(timeStamp-gTimeStamp)> deltaCache){
2924  //
2925  TGraphErrors * graphGHV = 0;
2926  TGraphErrors * graphGPT = 0;
2927  TObjArray *timeGainSplines = GetTimeGainSplinesRun(run);
2928  if (timeGainSplines){
2929  graphGHV = (TGraphErrors*) timeGainSplines->FindObject("GainSlopesHV");
2930  graphGPT = (TGraphErrors*) timeGainSplines->FindObject("GainSlopesPT");
2931  if (graphGHV) hasTimeDependent=kTRUE;
2932  }
2933  if (!graphGHV) graphGHV = fParam->GetGainSlopesHV();
2934  if (!graphGPT) graphGPT = fParam->GetGainSlopesPT();
2935  //
2936  for (Int_t isec=0; isec<72; isec++){
2937  Double_t HV= GetChamberHighVoltage(run,isec, timeStamp);
2938  if (HV<=0){ // check if the HV was available
2940  AliWarningF("Could not get proper HV for run,sec,time (%d, %2d, %d), using current nominal voltage: %.2f", run, isec, timeStamp, HV);
2941 // AliDCSSensor* sensor = GetChamberHVSensor(isec);
2942 // if (sensor && sensor->GetGraph()==NULL && sensor->GetFit()==NULL){
2943 // HV=fParam->GetNominalVoltage(isec);
2944 // }
2945  }
2946  Double_t deltaHV= HV - fParam->GetNominalVoltage(isec);
2947  Double_t deltaGHV=0;
2948  Double_t deltaGPT=0;
2949  if (graphGHV) deltaGHV = graphGHV->GetY()[isec]*deltaHV;
2950  if (graphGPT) deltaGPT = graphGPT->GetY()[isec]*GetPTRelative(timeStamp,run,0);
2951  gGainCorrection[isec]=(1.+deltaGHV)*(1.+deltaGPT);
2952  gGainCorrectionPT[isec]=1+deltaGPT;
2953  gGainCorrectionHV[isec]=1+deltaGHV;
2954  }
2955  gTimeStamp=timeStamp;
2956  }
2957  if (mode==0){
2958  if (hasTimeDependent) return gGainCorrection[sector];
2959  if (!hasTimeDependent) return 1;
2960  }
2961  if (mode==1) return gGainCorrection[sector];
2962  if (mode==2) return gGainCorrectionPT[sector];
2963  if (mode==3) return gGainCorrectionHV[sector];
2964  return 1;
2965 }
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)
const TObjArray * GetCalPadRMS() const
Bool_t fBHasAlignmentOCDB
Flag - alignment from the Transformation class.
static Char_t GetL3Polarity(Int_t run)
AliTPCCalROC * GetCalROC(Int_t sector) const
Definition: AliTPCCalPad.h:39
AliTPCRecoParam * GetRecoParamFromGRP() const
const TObjArray * GetCalPadRMS() const
Definition: AliTPCCalibCE.h:57
static Double_t GetPTRelative(UInt_t timeSec, Int_t run, Int_t side)
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)
TFile f("CalibObjects.root")
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.
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)
AliTPCCalPad * fPadNoise
Noise calibration entry.
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
AliTPCCalPad * fPadGainFactor
Gain calibration entry.
TObjArray * GetTimeGainSplinesRun(Int_t run)
AliTPCCalPad * fActiveChannelMap
Map of active channels calculated on the fly.
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
TGraph * GetCErocQgraph(const Int_t roc) const
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
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)
const TObjArray * GetCalPadRMS() const
Class providing the calculation of derived quantities (mean,rms,fits,...) of calibration entries...
AliDCSSensorArray * GetVoltageSensors(Int_t run)
static Float_t GetPressure(Int_t timeStamp, Int_t run, Int_t type=0)
AliTPCCorrection * fComposedCorrection
general space point corrections
TObjArray * array
Definition: AnalyzeLaser.C:12
static void SetInstance(AliTPCExB *const param)
Definition: AliTPCExB.h:31
const Double_t * GetBadPadMaxDistXYZD() const
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t GetRCUTriggerConfig() const
static TString GetRunType(Int_t run)
TMap fGRPMaps
! array of GRPs maps - per run - old data
AliTPCCorrection class.
Implementation of the TPC pulser calibration.
void sum()
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)
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)
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)
static void MakeTree(const char *fileName, TObjArray *array, const char *mapFileName=0, AliTPCCalPad *outlierPad=0, Float_t ltmFraction=0.9)
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
Int_t GetNMaskedRows(int sector72, TBits *masked=0) const
Geometry class for a single ROC.
Definition: AliTPCROC.h:14
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
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.
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.
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
const Float_t * GetLastMapCorrection() const
static TObjArray fgExBArray
array of ExB corrections
static TMap * GetGRPMap(Int_t run)
TGraphErrors * GetGainSlopesPT() const
Definition: AliTPCParam.h:347
AliTPCCorrection * GetTPCComposedCorrectionDelta() const
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
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
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)
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
Int_t GetRocFromEquipmentID(Int_t equipmentID) const
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)
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
AliTPCCalibVdrift * GetVdrift(Int_t run)
Class with TPC reconstruction parameters.
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 Bool_t GetTemperatureFit(Int_t timeStamp, Int_t run, Int_t side, TVectorD &fit)
AliTPCCalPad * GetNoThreshold() const
Definition: AliTPCdataQA.h:59
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
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
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.
AliTPCSensorTempArray * GetTemperatureSensor(Int_t run)
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)