1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // Class providing the calibration parameters by accessing the CDB //
22 // Request an instance with AliTRDcalibDB::Instance() //
23 // If a new event is processed set the event number with SetRun //
24 // Then request the calibration data //
27 // Jan Fiete Grosse-Oetringhaus (Jan.Fiete.Grosse-Oetringhaus@cern.ch) //
29 ///////////////////////////////////////////////////////////////////////////////
32 #include <TClonesArray.h>
33 #include <TObjArray.h>
35 #include "AliCDBManager.h"
36 #include "AliCDBEntry.h"
39 #include "AliTRDPIDReference.h"
40 #include "AliTRDPIDResponseObject.h"
41 #include "AliTRDcalibDB.h"
42 #include "AliTRDtrapConfig.h"
43 #include "AliTRDtrapConfigHandler.h"
44 #include "AliTRDCommonParam.h"
46 #include "Cal/AliTRDCalROC.h"
47 #include "Cal/AliTRDCalPad.h"
48 #include "Cal/AliTRDCalDet.h"
49 #include "Cal/AliTRDCalDCS.h"
50 #include "Cal/AliTRDCalDCSv2.h"
51 #include "Cal/AliTRDCalDCSFEEv2.h"
52 #include "Cal/AliTRDCalPID.h"
53 #include "Cal/AliTRDCalMonitoring.h"
54 #include "Cal/AliTRDCalChamberStatus.h"
55 #include "Cal/AliTRDCalPadStatus.h"
56 #include "Cal/AliTRDCalSingleChamberStatus.h"
57 #include "Cal/AliTRDCalTrkAttach.h"
58 #include "Cal/AliTRDCalOnlineGainTable.h"
60 ClassImp(AliTRDcalibDB)
62 AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0;
63 Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
65 //_ singleton implementation __________________________________________________
66 AliTRDcalibDB* AliTRDcalibDB::Instance()
69 // Singleton implementation
70 // Returns an instance of this class, it is created if neccessary
73 if (fgTerminated != kFALSE) {
77 if (fgInstance == 0) {
78 fgInstance = new AliTRDcalibDB();
85 //_____________________________________________________________________________
86 void AliTRDcalibDB::Terminate()
89 // Singleton implementation
90 // Deletes the instance of this class and sets the terminated flag,
91 // instances cannot be requested anymore
92 // This function can be called several times.
97 if (fgInstance != 0) {
104 //_____________________________________________________________________________
105 AliTRDcalibDB::AliTRDcalibDB()
115 ,fOnlineGainTableID(0)
118 ,fTrapConfigVersion("")
121 // Default constructor
123 // TODO Default runnumber is set to 0, this should be changed later
124 // to an invalid value (e.g. -1) to prevent
125 // TODO invalid calibration data to be used.
128 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
133 // Create the sampled PRF
138 //_____________________________________________________________________________
139 AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
149 ,fOnlineGainTableID(0)
152 ,fTrapConfigVersion("")
155 // Copy constructor (not that it make any sense for a singleton...)
158 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
163 // Create the sampled PRF
168 //_____________________________________________________________________________
169 AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
172 // Assignment operator (same as above ...)
176 AliFatal("No assignment operator defined");
183 //_____________________________________________________________________________
184 AliTRDcalibDB::~AliTRDcalibDB()
204 //_caching functions____________________________________________________________
205 const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
208 // Retrieves a cdb object with the given id. The objects are cached as
209 // long as the run number is not changed.
211 // Put together the available objects here by using the lines
212 // a) For usual calibration objects:
214 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
216 // See function CacheCDBEntry for details.
218 // b) For calibration data which depends on two objects: One containing
219 // a value per detector and one the local fluctuations per pad:
221 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
223 // See function CacheMergeCDBEntry for details.
228 // Parameters defined per pad and chamber
230 return CacheCDBEntry(kIDVdriftPad ,"TRD/Calib/LocalVdrift");
232 case kIDVdriftChamber :
233 return CacheCDBEntry(kIDVdriftChamber ,"TRD/Calib/ChamberVdrift");
236 return CacheCDBEntry(kIDExBChamber ,"TRD/Calib/ChamberExB");
239 return CacheCDBEntry(kIDT0Pad ,"TRD/Calib/LocalT0");
242 return CacheCDBEntry(kIDT0Chamber ,"TRD/Calib/ChamberT0");
244 case kIDGainFactorPad :
245 return CacheCDBEntry(kIDGainFactorPad ,"TRD/Calib/LocalGainFactor");
247 case kIDGainFactorChamber :
248 return CacheCDBEntry(kIDGainFactorChamber ,"TRD/Calib/ChamberGainFactor");
251 case kIDOnlineGainFactor :
252 switch(GetOnlineGainTableID()) {
254 // For testing purposes only !!!
255 AliInfo("No gain table name from OCDB. Use default table!");
256 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01");
259 // Online gain table ID 1
260 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01");
263 // Online gain table ID 2
264 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN0_2011-01");
267 // Online gain table ID 3
268 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN8_2011-01");
271 // Online gain table ID 4
272 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-02");
275 // Online gain table ID 5
276 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-03");
279 // Online gain table ID 6
280 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN0_2012-01");
283 // Online gain table ID 7
284 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN8_2012-01");
287 // Online gain table ID 8
288 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2012-01");
293 case kIDNoiseChamber :
294 return CacheCDBEntry(kIDNoiseChamber ,"TRD/Calib/DetNoise");
297 return CacheCDBEntry(kIDNoisePad ,"TRD/Calib/PadNoise");
300 // Parameters defined per pad
302 return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth");
306 case kIDChamberStatus :
307 return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus");
310 return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus");
314 case kIDMonitoringData :
315 return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData");
318 return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE");
321 return CacheCDBEntry(kIDFEE ,"TRD/Calib/TrapConfig");
324 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS");
327 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
330 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
333 return CacheCDBEntry(kIDPIDLQ1D ,"TRD/Calib/PIDLQ1D");
336 return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam");
339 return CacheCDBEntry(kIDAttach ,"TRD/Calib/TrkAttach");
342 return CacheCDBEntry(kIDPHQ ,"TRD/Calib/PHQ");
350 //_____________________________________________________________________________
351 AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
354 // Retrieves an entry with path <cdbPath> from the CDB.
357 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
359 AliError(Form("Failed to get entry: %s",cdbPath));
367 //_____________________________________________________________________________
368 const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
371 // Caches the entry <id> with cdb path <cdbPath>
374 if (!fCDBCache[id]) {
375 fCDBEntries[id] = GetCDBEntry(cdbPath);
376 if (fCDBEntries[id]) {
377 fCDBCache[id] = fCDBEntries[id]->GetObject();
381 return fCDBCache[id];
385 //_____________________________________________________________________________
386 void AliTRDcalibDB::SetRun(Long64_t run)
389 // Sets current run number. Calibration data is read from the corresponding file.
390 // When the run number changes the caching is invalidated.
403 //_____________________________________________________________________________
404 void AliTRDcalibDB::Invalidate()
407 // Invalidates cache (when run number is changed).
410 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
411 if (fCDBEntries[i]) {
412 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
413 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
417 delete fCDBEntries[i];
424 fOnlineGainTableID = 0;
428 //_____________________________________________________________________________
429 Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row)
432 // Returns the noise level in ADC counts for the given pad.
435 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
436 (GetCachedCDBObject(kIDNoisePad));
441 AliTRDCalROC *roc = calPad->GetCalROC(det);
446 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
447 (GetCachedCDBObject(kIDNoiseChamber));
452 return calChamber->GetValue(det) * roc->GetValue(col,row);
456 //_____________________________________________________________________________
457 AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det)
460 // Returns the Vdrift calibration object for a given ROC
461 // containing one number per pad
464 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
465 (GetCachedCDBObject(kIDNoisePad));
470 AliTRDCalROC *roc = calPad->GetCalROC(det);
480 //_____________________________________________________________________________
481 const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet()
484 // Returns the Vdrift calibration object
485 // containing one number per detector
488 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
489 (GetCachedCDBObject(kIDNoiseChamber));
499 //_____________________________________________________________________________
500 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
503 // Returns the drift velocity for the given pad.
506 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
507 (GetCachedCDBObject(kIDVdriftPad));
512 AliTRDCalROC *roc = calPad->GetCalROC(det);
517 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
518 (GetCachedCDBObject(kIDVdriftChamber));
523 return calChamber->GetValue(det) * roc->GetValue(col,row);
527 //_____________________________________________________________________________
528 AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
531 // Returns the Vdrift calibration object for a given ROC
532 // containing one number per pad
535 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
536 (GetCachedCDBObject(kIDVdriftPad));
541 AliTRDCalROC *roc = calPad->GetCalROC(det);
551 //_____________________________________________________________________________
552 const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
555 // Returns the Vdrift calibration object
556 // containing one number per detector
559 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
560 (GetCachedCDBObject(kIDVdriftChamber));
570 //_____________________________________________________________________________
571 TObjArray * AliTRDcalibDB::GetPHQ()
574 //return PHQ calibration object
576 TObjArray *arr = (TObjArray *) (GetCachedCDBObject(kIDPHQ));
580 //_____________________________________________________________________________
581 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
584 // Returns the average drift velocity for the given detector
587 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
588 (GetCachedCDBObject(kIDVdriftChamber));
593 return calDet->GetValue(det);
596 //_____________________________________________________________________________
597 const AliTRDCalDet *AliTRDcalibDB::GetExBDet()
600 // Returns the exB calibration object
601 // containing one number per detector
604 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> (GetCachedCDBObject(kIDExBChamber));
606 Double_t meanexb = 100.0;
607 if (calChamber) meanexb = calChamber->GetMean();
608 //printf("mean %f\n",meanexb);
610 if ((!calChamber) || (meanexb > 70.0)) {
612 const AliTRDCalDet *calChambervdrift = dynamic_cast<const AliTRDCalDet *>
613 (GetCachedCDBObject(kIDVdriftChamber));
614 if (!calChambervdrift) {
618 AliTRDCalDet *calDetExB = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
619 for(Int_t k = 0; k < 540; k++){
620 calDetExB->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(calChambervdrift->GetValue(k)));
625 else return calChamber;
628 //_____________________________________________________________________________
629 Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
632 // Returns t0 for the given pad.
635 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
636 (GetCachedCDBObject(kIDT0Pad));
641 AliTRDCalROC *roc = calPad->GetCalROC(det);
646 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
647 (GetCachedCDBObject(kIDT0Chamber));
652 return calChamber->GetValue(det) + roc->GetValue(col,row);
656 //_____________________________________________________________________________
657 AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
660 // Returns the t0 calibration object for a given ROC
661 // containing one number per pad
664 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
665 (GetCachedCDBObject(kIDT0Pad));
670 AliTRDCalROC *roc = calPad->GetCalROC(det);
680 //_____________________________________________________________________________
681 const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
684 // Returns the t0 calibration object
685 // containing one number per detector
688 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
689 (GetCachedCDBObject(kIDT0Chamber));
699 //_____________________________________________________________________________
700 Float_t AliTRDcalibDB::GetT0Average(Int_t det)
703 // Returns the average t0 for the given detector
706 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
707 (GetCachedCDBObject(kIDT0Pad));
712 AliTRDCalROC *roc = calPad->GetCalROC(det);
717 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
718 (GetCachedCDBObject(kIDT0Chamber));
724 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
725 sum += roc->GetValue(channel);
727 sum /= roc->GetNchannels();
728 sum += calDet->GetValue(det);
733 //_____________________________________________________________________________
734 AliTRDCalOnlineGainTableROC* AliTRDcalibDB::GetOnlineGainTableROC(Int_t det)
737 // Returns the online gain factor table for a given ROC.
740 if (!HasOnlineFilterGain()) {
744 const AliTRDCalOnlineGainTable *calOnline
745 = dynamic_cast<const AliTRDCalOnlineGainTable *>
746 (GetCachedCDBObject(kIDOnlineGainFactor));
751 return calOnline->GetGainTableROC(det);
755 //_____________________________________________________________________________
756 Float_t AliTRDcalibDB::GetOnlineGainFactor(Int_t det, Int_t col, Int_t row)
759 // Returns the online gain factor for the given pad.
762 if (!HasOnlineFilterGain()) {
766 const AliTRDCalOnlineGainTable *calOnline
767 = dynamic_cast<const AliTRDCalOnlineGainTable *>
768 (GetCachedCDBObject(kIDOnlineGainFactor));
773 return calOnline->GetGainCorrectionFactor(det,row,col);
777 //_____________________________________________________________________________
778 AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
781 // Returns the gain factor calibration object for a given ROC
784 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
785 (GetCachedCDBObject(kIDGainFactorPad));
790 AliTRDCalROC *roc = calPad->GetCalROC(det);
800 //_____________________________________________________________________________
801 Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
804 // Returns the gain factor for the given pad.
807 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
808 (GetCachedCDBObject(kIDGainFactorPad));
813 AliTRDCalROC *roc = calPad->GetCalROC(det);
818 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
819 (GetCachedCDBObject(kIDGainFactorChamber));
824 return calChamber->GetValue(det) * roc->GetValue(col,row);
828 //_____________________________________________________________________________
829 const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
832 // Returns the gain factor calibration object
833 // containing one number per detector
836 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
837 (GetCachedCDBObject(kIDGainFactorChamber));
847 //_____________________________________________________________________________
848 Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
851 // Returns the average gain factor for the given detector
854 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
855 (GetCachedCDBObject(kIDGainFactorChamber));
860 return calDet->GetValue(det);
864 //_____________________________________________________________________________
865 AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
868 // Returns the PRF calibration object for a given ROC
869 // containing one number per pad
872 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
873 (GetCachedCDBObject(kIDPRFWidth));
878 AliTRDCalROC *roc = calPad->GetCalROC(det);
888 //_____________________________________________________________________________
889 Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
892 // Returns the PRF width for the given pad.
895 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
896 (GetCachedCDBObject(kIDPRFWidth));
901 AliTRDCalROC *roc = calPad->GetCalROC(det);
906 return roc->GetValue(col,row);
910 //_____________________________________________________________________________
911 Int_t AliTRDcalibDB::ExtractTimeBinsFromString(TString tbstr)
913 // Check if there is any content in the string first
914 if (tbstr.Length() == 0) {
915 AliError("Parameter for number of timebins is empty!");
919 // Check if we have the correct config parameter
920 TString tbident = "tb";
921 TString tbsubstr = tbstr(0,2);
922 if (!tbsubstr.EqualTo(tbident)) {
923 AliError(Form("Parameter for number of timebins is corrupted (%s)!", tbstr.Data()));
928 // check if there is more than a number
929 if (!tbstr.IsDigit()) {
930 AliError(Form("Parameter for number of timebins is corrupted (%s)!", tbstr.Data()));
938 //_____________________________________________________________________________
939 Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS()
942 // Returns number of time bins from the DCS
945 // Get the corresponding parameter
946 TString cfgstr = "", cfgname = "";
947 GetGlobalConfiguration(cfgname);
948 if(cfgname.Length()==0)
950 GetDCSConfigParOption(cfgname, kTimebin, 0, cfgstr);
951 if(cfgstr.Length()==0)
953 return ExtractTimeBinsFromString(cfgstr);
957 //_____________________________________________________________________________
958 void AliTRDcalibDB::GetFilterType(TString &filterType)
961 // Returns the filter type
964 TString cfgname = "";
965 GetGlobalConfiguration(cfgname);
966 GetDCSConfigParOption(cfgname, kFltrSet, 0, filterType);
970 //_____________________________________________________________________________
971 Int_t AliTRDcalibDB::GetOnlineGainTableID()
974 // Get the gain table ID from the DCS
977 if (fOnlineGainTableID > 0) {
978 return fOnlineGainTableID;
981 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
986 Int_t esor = 0; // Take SOR
987 Int_t calver = 0; // Check CalDCS version
988 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
989 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
993 // No data for old DCS object available, anyway
997 else if (calver == 2) {
1000 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1005 TString tableName = "";
1006 for (Int_t i = 0; i < 540; i++) {
1007 const AliTRDCalDCSFEEv2 *calDCSFEEv2 = calDCSv2->GetCalDCSFEEObj(0);
1008 tableName = calDCSFEEv2->GetGainTableName();
1009 if (tableName.Length() > 0) {
1013 if (tableName.CompareTo("Krypton_2011-01") == 0) {
1014 fOnlineGainTableID = 1;
1015 return fOnlineGainTableID;
1017 if (tableName.CompareTo("Gaintbl_Uniform_FGAN0_2011-01") == 0) {
1018 fOnlineGainTableID = 2;
1019 return fOnlineGainTableID;
1021 if (tableName.CompareTo("Gaintbl_Uniform_FGAN8_2011-01") == 0) {
1022 fOnlineGainTableID = 3;
1023 return fOnlineGainTableID;
1025 if (tableName.CompareTo("Krypton_2011-02") == 0) {
1026 fOnlineGainTableID = 4;
1027 return fOnlineGainTableID;
1029 if (tableName.CompareTo("Krypton_2011-03") == 0) {
1030 fOnlineGainTableID = 5;
1031 return fOnlineGainTableID;
1033 if (tableName.CompareTo("Gaintbl_Uniform_FGAN0_2012-01") == 0) {
1034 fOnlineGainTableID = 6;
1035 return fOnlineGainTableID;
1037 if (tableName.CompareTo("Gaintbl_Uniform_FGAN8_2012-01") == 0) {
1038 fOnlineGainTableID = 7;
1039 return fOnlineGainTableID;
1041 if (tableName.CompareTo("Krypton_2011-03") == 0) {
1042 fOnlineGainTableID = 8;
1043 return fOnlineGainTableID;
1049 AliError("NO DCS/DCSv2 OCDB entry found!");
1058 //_____________________________________________________________________________
1059 void AliTRDcalibDB::GetGlobalConfiguration(TString &config)
1062 // Get Configuration from the DCS
1065 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1067 AliError("No DCS CDB Object available!");
1072 Int_t idSOR = 0, idEOR=1; // The index of SOR and EOR
1073 Bool_t hasSOR = (dcsArr->At(idSOR));
1074 Bool_t hasEOR = (dcsArr->At(idEOR));
1075 TString cfgSOR = "", cfgEOR = ""; // The configuration at SOR/EOR
1077 // The SOR object is mandatory
1079 AliError("NO SOR object found in CDB file!");
1083 if (!hasEOR) AliWarning("NO EOR object found in CDB file!");
1085 // Check CalDCS version
1087 if (!strcmp(dcsArr->At(idSOR)->ClassName(),"AliTRDCalDCS")) calver = 1;
1088 else if (!strcmp(dcsArr->At(idSOR)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1090 // Get the configuration strings
1093 const AliTRDCalDCS *calSOR = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(idSOR));
1094 cfgSOR = calSOR->GetGlobalConfigName();
1096 const AliTRDCalDCS *calEOR = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(idEOR));
1097 cfgEOR = calEOR->GetGlobalConfigName();
1100 else if (calver == 2) {
1102 const AliTRDCalDCSv2 *calv2SOR = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(idSOR));
1103 cfgSOR = calv2SOR->GetGlobalConfigName();
1105 const AliTRDCalDCSv2 *calv2EOR = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(idEOR));
1106 cfgEOR = calv2EOR->GetGlobalConfigName();
1110 AliError("NO DCS/DCSv2 OCDB entry found!");
1115 // If there is no EOR entry, return the SOR value
1116 if (!hasEOR || cfgEOR.Length()==0) {
1121 // Check if the configuration is the same for both
1122 if (cfgSOR.EqualTo(cfgEOR)) {
1127 // When both SOR and EOR have an entry but are different, the config is not defined
1128 AliError("Inconsistent configuration at start and end of run found!");
1134 //_____________________________________________________________________________
1135 void AliTRDcalibDB::GetGlobalConfigurationVersion(TString &version)
1138 // Get Version of Configuration from the DCS
1141 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1147 Int_t esor = 0; // Take SOR
1148 Int_t calver = 0; // Check CalDCS version
1149 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1150 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1155 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
1160 version = calDCS->GetGlobalConfigVersion();
1163 else if (calver == 2) {
1166 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1171 version = calDCSv2->GetGlobalConfigVersion();
1176 AliError("NO DCS/DCSv2 OCDB entry found!");
1182 //_____________________________________________________________________________
1183 Int_t AliTRDcalibDB::GetNumberOfParsDCS(TString cname, Char_t delimiter)
1185 // Get the number of configuration parameters from the DCS config
1187 //AliInfo(Form("\"%s\" tokenized by \"%c\"", cname.Data(), delimiter));
1188 if(!cname.Length()) return -1; // -1 for the "cf"
1190 for(Int_t ich(1); ich<cname.Length()-1; ich++){ if(cname[ich]==delimiter) nconf++;}
1194 //_____________________________________________________________________________
1195 Int_t AliTRDcalibDB::GetNumberOfOptsDCS(TString cname, Int_t cfgType)
1197 // Get the number of options of a given configuration parameter from DCS
1199 Char_t cdelim = '_', // define the delimiters
1201 Int_t nconfig = GetNumberOfParsDCS(cname, cdelim);
1204 if ((nconfig == -1) || (nconfig < cfgType)) {
1205 AliError("Not enough parameters in DCS configuration name!");
1209 TObjArray *carr = cname.Tokenize(cdelim);
1210 Int_t nopt = GetNumberOfParsDCS(((TObjString*)carr->At(cfgType))->GetString(), odelim);
1211 carr->Delete(); delete carr;
1215 //_____________________________________________________________________________
1216 void AliTRDcalibDB::GetDCSConfigParOption(TString cname, Int_t cfgType, Int_t option, TString &cfgo)
1219 // Get a configuration (see enum in header file) or the options of a configuration
1220 // option == 0 returns the configuration itself
1221 // option > 0 returns the optional parameter Nr. (option) of the configuration (cfgType)
1224 Char_t cdelim = '_', // define the delimiters
1227 Int_t nconfig = GetNumberOfParsDCS(cname, cdelim);
1229 if (nconfig == -1) {
1230 AliError("DCS configuration name empty!");
1233 } else if (nconfig < cfgType) {
1234 AliError("Not enough parameters in DCS configuration name!");
1239 TObjArray *carr = cname.Tokenize(cdelim);
1240 TString cfgString(((TObjString*)carr->At(cfgType))->GetString());
1241 Int_t noptions = GetNumberOfParsDCS(cfgString, odelim);
1243 if (noptions < option) {
1244 AliError("Not enough options in DCS configuration name!");
1246 carr->Delete(); delete carr;
1249 TObjArray *oarr = cfgString.Tokenize(odelim);
1250 cfgo = ((TObjString*)oarr->At(option))->GetString();
1251 carr->Delete(); delete carr;
1252 oarr->Delete(); delete oarr;
1257 //_____________________________________________________________________________
1258 Bool_t AliTRDcalibDB::HasOnlineFilterPedestal()
1261 // Checks whether pedestal filter was applied online
1264 TString filterconfig;
1265 GetFilterType(filterconfig);
1267 return filterconfig.Contains("p");
1271 //_____________________________________________________________________________
1272 Bool_t AliTRDcalibDB::HasOnlineFilterGain()
1275 // Checks whether online gain filter was applied
1278 TString filterconfig;
1279 GetFilterType(filterconfig);
1281 return filterconfig.Contains("g");
1285 //_____________________________________________________________________________
1286 Bool_t AliTRDcalibDB::HasOnlineTailCancellation()
1289 // Checks whether online tail cancellation was applied
1292 TString filterconfig;
1293 GetFilterType(filterconfig);
1295 return filterconfig.Contains("t");
1299 //_____________________________________________________________________________
1300 Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
1303 // Returns the status of the given pad
1306 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1307 (GetCachedCDBObject(kIDPadStatus));
1312 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1317 return roc->GetStatus(col,row);
1321 //_____________________________________________________________________________
1322 AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
1325 // Returns the pad status calibration object for a given ROC
1328 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1329 (GetCachedCDBObject(kIDPadStatus));
1334 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1344 //_____________________________________________________________________________
1345 Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
1348 // Returns the status of the given chamber
1351 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
1352 (GetCachedCDBObject(kIDChamberStatus));
1357 return cal->GetStatus(det);
1361 //_____________________________________________________________________________
1362 AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
1365 // Returns the TRD reconstruction parameters from the OCDB
1368 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
1369 if (!recos) return 0x0;
1371 // calculate entry based on event type info
1372 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
1374 return (AliTRDrecoParam *) recos->UncheckedAt(n);
1378 //_____________________________________________________________________________
1379 Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
1382 // Returns status, see name of functions for details ;-)
1385 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1386 (GetCachedCDBObject(kIDPadStatus));
1391 return cal->IsMasked(det,col,row);
1395 //_____________________________________________________________________________
1396 Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
1399 // Returns status, see name of functions for details ;-)
1402 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1403 (GetCachedCDBObject(kIDPadStatus));
1408 return cal->IsBridgedLeft(det,col,row);
1412 //_____________________________________________________________________________
1413 Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
1416 // Returns status, see name of functions for details ;-)
1419 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1420 (GetCachedCDBObject(kIDPadStatus));
1425 return cal->IsBridgedRight(det,col,row);
1429 //_____________________________________________________________________________
1430 Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
1433 // Returns status, see name of functions for details ;-)
1436 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1437 (GetCachedCDBObject(kIDPadStatus));
1442 return cal->IsNotConnected(det,col,row);
1446 //_____________________________________________________________________________
1447 Bool_t AliTRDcalibDB::IsChamberGood(Int_t det)
1450 // Returns status, see name of functions for details ;-)
1453 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1454 (GetCachedCDBObject(kIDChamberStatus));
1459 return cal->IsGood(det);
1463 //_____________________________________________________________________________
1464 Bool_t AliTRDcalibDB::IsChamberNoData(Int_t det)
1467 // Returns status, see name of functions for details ;-)
1470 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1471 (GetCachedCDBObject(kIDChamberStatus));
1476 return cal->IsNoData(det);
1480 //_____________________________________________________________________________
1481 Bool_t AliTRDcalibDB::IsHalfChamberNoData(Int_t det, Int_t side)
1484 // Returns status, see name of functions for details ;-)
1487 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1488 (GetCachedCDBObject(kIDChamberStatus));
1493 return side > 0 ? cal->IsNoDataSideB(det) : cal->IsNoDataSideA(det);
1497 //_____________________________________________________________________________
1498 Bool_t AliTRDcalibDB::IsChamberBadCalibrated(Int_t det)
1501 // Returns status, see name of functions for details ;-)
1504 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1505 (GetCachedCDBObject(kIDChamberStatus));
1510 return cal->IsBadCalibrated(det);
1514 //_____________________________________________________________________________
1515 Bool_t AliTRDcalibDB::IsChamberNotCalibrated(Int_t det)
1518 // Returns status, see name of functions for details ;-)
1521 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1522 (GetCachedCDBObject(kIDChamberStatus));
1527 return cal->IsNotCalibrated(det);
1531 //_____________________________________________________________________________
1532 const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
1535 // Returns the object storing the distributions for PID with likelihood
1539 case AliTRDpidUtil::kLQ:
1540 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
1541 case AliTRDpidUtil::kNN:
1542 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
1543 case AliTRDpidUtil::kESD:
1544 return 0x0; // To avoid compiler warnings
1551 //_____________________________________________________________________________
1552 AliTRDPIDResponse *AliTRDcalibDB::GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod /*method*/)
1555 // Returns the PID response object for 1D-LQ
1558 if (!fPIDResponse) {
1559 AliDebug(2, "Setting new PID response.");
1561 fPIDResponse = new AliTRDPIDResponse;
1563 // Load Reference Histos from OCDB
1564 // if(method == AliTRDPIDResponse::kLQ1D){
1565 //fPIDResponse->SetPIDmethod(AliTRDPIDResponse::kLQ1D);
1566 const TObjArray *references = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDPIDLQ1D));
1568 TIter refs(references);
1569 TObject *obj = NULL;
1570 AliTRDPIDReference *ref = NULL;
1571 Bool_t hasReference = kFALSE;
1572 while ((obj = refs())){
1573 if ((ref = dynamic_cast<AliTRDPIDReference *>(obj))){
1574 AliDebug(2, "Setting new PID response object.");
1575 TDirectory *bkpdir = gDirectory;
1577 AliTRDPIDResponseObject *ro = new AliTRDPIDResponseObject;
1578 ro->SetPIDReference(ref);
1579 fPIDResponse->SetPIDResponseObject(ro);
1580 hasReference = kTRUE;
1581 gDirectory = bkpdir;
1586 if (!hasReference) {
1587 AliError("Reference histograms not found in the OCDB");
1593 return fPIDResponse;
1597 //_____________________________________________________________________________
1598 const AliTRDCalTrkAttach* AliTRDcalibDB::GetAttachObject()
1601 // Returns the object storing likelihood distributions for cluster to track attachment
1604 return dynamic_cast<const AliTRDCalTrkAttach*>(GetCachedCDBObject(kIDAttach));
1608 //_____________________________________________________________________________
1609 const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
1612 // Returns the object storing the monitoring data
1615 return dynamic_cast<const AliTRDCalMonitoring *>
1616 (GetCachedCDBObject(kIDMonitoringData));
1620 //_____________________________________________________________________________
1621 void AliTRDcalibDB::SamplePRF()
1624 // Samples the pad response function (should maybe go somewhere else ...)
1627 const Int_t kPRFbin = 61;
1629 Float_t prf[kNlayer][kPRFbin] = {
1630 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
1631 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1632 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1633 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1634 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1635 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1636 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1637 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1638 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1639 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1640 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1641 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1642 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1643 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1644 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1646 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1647 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1648 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1649 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1650 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1651 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1652 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1653 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1654 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1655 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1656 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1657 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1658 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1659 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1660 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1662 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1663 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1664 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1665 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1666 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1667 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1668 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1669 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1670 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1671 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1672 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1673 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1674 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1675 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1676 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1678 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1679 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1680 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1681 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1682 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1683 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1684 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1685 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1686 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1687 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1688 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1689 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1690 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1691 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1692 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1694 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1695 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1696 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1697 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1698 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1699 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1700 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1701 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1702 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1703 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1704 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1705 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1706 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1707 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1708 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1710 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1711 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1712 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1713 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1714 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1715 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1716 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1717 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1718 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1719 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1720 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1721 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1722 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1723 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1724 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1727 // More sampling precision with linear interpolation
1730 Float_t pad[kPRFbin];
1731 Int_t sPRFbin = kPRFbin;
1732 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
1733 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
1734 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
1737 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1738 fPRFpad = ((Int_t) (1.0 / fPRFwid));
1740 if (fPRFsmp) delete [] fPRFsmp;
1741 fPRFsmp = new Float_t[kNlayer*fPRFbin];
1747 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
1749 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
1751 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
1755 diff = bin - pad[ipos2++];
1756 } while ((diff > 0) && (ipos2 < kPRFbin));
1757 if (ipos2 == kPRFbin) {
1758 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1760 else if (ipos2 == 1) {
1761 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1765 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1767 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
1768 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
1777 //_____________________________________________________________________________
1778 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
1779 , Int_t layer, Double_t *pad) const
1782 // Applies the pad response
1783 // So far this is the fixed parametrization and should be replaced by
1784 // something dependent on calibration values
1787 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
1788 Int_t iOff = layer * fPRFbin;
1790 Int_t iBin0 = iBin - fPRFpad + iOff;
1791 Int_t iBin1 = iBin + iOff;
1792 Int_t iBin2 = iBin + fPRFpad + iOff;
1797 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
1800 pad[0] = signal * fPRFsmp[iBin0];
1802 pad[1] = signal * fPRFsmp[iBin1];
1803 if (iBin2 < (fPRFbin*kNlayer)) {
1804 pad[2] = signal * fPRFsmp[iBin2];
1819 AliTRDtrapConfig* AliTRDcalibDB::GetTrapConfig()
1821 // return an existing TRAPconfig or load it from the OCDB
1822 // in case of failure, a default TRAPconfig is created
1827 if ((fTrapConfigName.Length() <= 0) || (fTrapConfigVersion.Length() <= 0)) {
1828 // query the configuration to be used
1829 this->GetGlobalConfiguration(fTrapConfigName);
1830 this->GetGlobalConfigurationVersion(fTrapConfigVersion);
1833 // try to load the requested configuration
1834 this->LoadTrapConfig(fTrapConfigName, fTrapConfigVersion);
1836 // if we still don't have a valid TRAPconfig, create a default one
1838 AliWarning("Falling back to default configuration");
1839 fTrapConfig = new AliTRDtrapConfig("default", "default TRAP configuration");
1840 AliTRDtrapConfigHandler cfgHandler(fTrapConfig);
1842 cfgHandler.LoadConfig();
1845 AliInfo(Form("using TRAPconfig \"%s\"", fTrapConfig->GetTitle()));
1852 AliTRDtrapConfig* AliTRDcalibDB::LoadTrapConfig(const TString &name, const TString &version)
1854 // try to load the specified configuration from the OCDB
1855 // if it fails, or it does not exist, return null
1857 AliInfo(Form("looking for TRAPconfig \"%s.%s\"", name.Data(), version.Data()));
1859 const AliTRDCalTrapConfig *caltrap = dynamic_cast<const AliTRDCalTrapConfig*> (GetCachedCDBObject(kIDTrapConfig));
1862 TString configName(name);
1863 configName.Append(".");
1864 configName.Append(version);
1865 fTrapConfig = caltrap->Get(configName);
1869 AliError("No TRAPconfig entry found!");