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)
1185 // Get the number of configuration parameters from the DCS config
1187 TString cdelim = "_";
1188 TObjArray *carr = cname.Tokenize(cdelim);
1189 return carr->GetEntries() - 1; // -1 for the "cf"
1193 //_____________________________________________________________________________
1194 Int_t AliTRDcalibDB::GetNumberOfOptsDCS(TString cname, Int_t cfgType)
1196 // Get the number of options of a given configuration parameter from DCS
1198 TString cdelim = "_";
1199 TString odelim = "-";
1201 TObjArray *carr = cname.Tokenize(cdelim);
1202 Int_t nconfig = carr->GetEntries();
1205 if ((nconfig == 0) || ((nconfig-1) < cfgType)) {
1206 AliError("Not enough parameters in DCS configuration name!");
1210 TString fullcfg = ((TObjString*)carr->At(cfgType))->GetString();
1211 TObjArray *oarr = fullcfg.Tokenize(odelim);
1212 return oarr->GetEntries() -1; // -1 for the parameter name
1216 //_____________________________________________________________________________
1217 void AliTRDcalibDB::GetDCSConfigParOption(TString cname, Int_t cfgType, Int_t option, TString &cfgo)
1220 // Get a configuration (see enum in header file) or the options of a configuration
1221 // option == 0 returns the configuration itself
1222 // option > 0 returns the optional parameter Nr. (option) of the configuration (cfgType)
1225 // define the delimiters
1226 TString cdelim = "_";
1227 TString odelim = "-";
1229 TObjArray *carr = cname.Tokenize(cdelim);
1230 Int_t nconfig = carr->GetEntries();
1234 AliError("DCS configuration name empty!");
1237 } else if ((nconfig-1) < cfgType) {
1238 AliError("Not enough parameters in DCS configuration name!");
1243 TString fullcfg = ((TObjString*)carr->At(cfgType))->GetString();
1244 TObjArray *oarr = fullcfg.Tokenize(odelim);
1245 Int_t noptions = oarr->GetEntries();
1248 if ((noptions-1) < option) {
1249 AliError("Not enough options in DCS configuration name!");
1254 cfgo = ((TObjString*)oarr->At(option))->GetString();
1259 //_____________________________________________________________________________
1260 Bool_t AliTRDcalibDB::HasOnlineFilterPedestal()
1263 // Checks whether pedestal filter was applied online
1266 TString filterconfig;
1267 GetFilterType(filterconfig);
1269 return filterconfig.Contains("p");
1273 //_____________________________________________________________________________
1274 Bool_t AliTRDcalibDB::HasOnlineFilterGain()
1277 // Checks whether online gain filter was applied
1280 TString filterconfig;
1281 GetFilterType(filterconfig);
1283 return filterconfig.Contains("g");
1287 //_____________________________________________________________________________
1288 Bool_t AliTRDcalibDB::HasOnlineTailCancellation()
1291 // Checks whether online tail cancellation was applied
1294 TString filterconfig;
1295 GetFilterType(filterconfig);
1297 return filterconfig.Contains("t");
1301 //_____________________________________________________________________________
1302 Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
1305 // Returns the status of the given pad
1308 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1309 (GetCachedCDBObject(kIDPadStatus));
1314 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1319 return roc->GetStatus(col,row);
1323 //_____________________________________________________________________________
1324 AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
1327 // Returns the pad status calibration object for a given ROC
1330 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1331 (GetCachedCDBObject(kIDPadStatus));
1336 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1346 //_____________________________________________________________________________
1347 Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
1350 // Returns the status of the given chamber
1353 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
1354 (GetCachedCDBObject(kIDChamberStatus));
1359 return cal->GetStatus(det);
1363 //_____________________________________________________________________________
1364 AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
1367 // Returns the TRD reconstruction parameters from the OCDB
1370 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
1371 if (!recos) return 0x0;
1373 // calculate entry based on event type info
1374 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
1376 return (AliTRDrecoParam *) recos->UncheckedAt(n);
1380 //_____________________________________________________________________________
1381 Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
1384 // Returns status, see name of functions for details ;-)
1387 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1388 (GetCachedCDBObject(kIDPadStatus));
1393 return cal->IsMasked(det,col,row);
1397 //_____________________________________________________________________________
1398 Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
1401 // Returns status, see name of functions for details ;-)
1404 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1405 (GetCachedCDBObject(kIDPadStatus));
1410 return cal->IsBridgedLeft(det,col,row);
1414 //_____________________________________________________________________________
1415 Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
1418 // Returns status, see name of functions for details ;-)
1421 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1422 (GetCachedCDBObject(kIDPadStatus));
1427 return cal->IsBridgedRight(det,col,row);
1431 //_____________________________________________________________________________
1432 Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
1435 // Returns status, see name of functions for details ;-)
1438 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1439 (GetCachedCDBObject(kIDPadStatus));
1444 return cal->IsNotConnected(det,col,row);
1448 //_____________________________________________________________________________
1449 Bool_t AliTRDcalibDB::IsChamberGood(Int_t det)
1452 // Returns status, see name of functions for details ;-)
1455 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1456 (GetCachedCDBObject(kIDChamberStatus));
1461 return cal->IsGood(det);
1465 //_____________________________________________________________________________
1466 Bool_t AliTRDcalibDB::IsChamberNoData(Int_t det)
1469 // Returns status, see name of functions for details ;-)
1472 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1473 (GetCachedCDBObject(kIDChamberStatus));
1478 return cal->IsNoData(det);
1482 //_____________________________________________________________________________
1483 Bool_t AliTRDcalibDB::IsHalfChamberNoData(Int_t det, Int_t side)
1486 // Returns status, see name of functions for details ;-)
1489 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1490 (GetCachedCDBObject(kIDChamberStatus));
1495 return side > 0 ? cal->IsNoDataSideB(det) : cal->IsNoDataSideA(det);
1499 //_____________________________________________________________________________
1500 Bool_t AliTRDcalibDB::IsChamberBadCalibrated(Int_t det)
1503 // Returns status, see name of functions for details ;-)
1506 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1507 (GetCachedCDBObject(kIDChamberStatus));
1512 return cal->IsBadCalibrated(det);
1516 //_____________________________________________________________________________
1517 const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
1520 // Returns the object storing the distributions for PID with likelihood
1524 case AliTRDpidUtil::kLQ:
1525 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
1526 case AliTRDpidUtil::kNN:
1527 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
1528 case AliTRDpidUtil::kESD:
1529 return 0x0; // To avoid compiler warnings
1536 //_____________________________________________________________________________
1537 AliTRDPIDResponse *AliTRDcalibDB::GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod /*method*/)
1540 // Returns the PID response object for 1D-LQ
1543 if (!fPIDResponse) {
1544 AliDebug(2, "Setting new PID response.");
1546 fPIDResponse = new AliTRDPIDResponse;
1548 // Load Reference Histos from OCDB
1549 // if(method == AliTRDPIDResponse::kLQ1D){
1550 fPIDResponse->SetPIDmethod(AliTRDPIDResponse::kLQ1D);
1551 const TObjArray *references = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDPIDLQ1D));
1553 TIter refs(references);
1554 TObject *obj = NULL;
1555 AliTRDPIDReference *ref = NULL;
1556 Bool_t hasReference = kFALSE;
1557 while ((obj = refs())){
1558 if ((ref = dynamic_cast<AliTRDPIDReference *>(obj))){
1559 AliDebug(2, "Setting new PID response object.");
1560 TDirectory *bkpdir = gDirectory;
1562 AliTRDPIDResponseObject *ro = new AliTRDPIDResponseObject;
1563 ro->SetPIDReference(ref);
1564 fPIDResponse->SetPIDResponseObject(ro);
1565 hasReference = kTRUE;
1566 gDirectory = bkpdir;
1571 if (!hasReference) {
1572 AliError("Reference histograms not found in the OCDB");
1578 return fPIDResponse;
1582 //_____________________________________________________________________________
1583 const AliTRDCalTrkAttach* AliTRDcalibDB::GetAttachObject()
1586 // Returns the object storing likelihood distributions for cluster to track attachment
1589 return dynamic_cast<const AliTRDCalTrkAttach*>(GetCachedCDBObject(kIDAttach));
1593 //_____________________________________________________________________________
1594 const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
1597 // Returns the object storing the monitoring data
1600 return dynamic_cast<const AliTRDCalMonitoring *>
1601 (GetCachedCDBObject(kIDMonitoringData));
1605 //_____________________________________________________________________________
1606 void AliTRDcalibDB::SamplePRF()
1609 // Samples the pad response function (should maybe go somewhere else ...)
1612 const Int_t kPRFbin = 61;
1614 Float_t prf[kNlayer][kPRFbin] = {
1615 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
1616 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1617 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1618 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1619 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1620 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1621 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1622 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1623 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1624 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1625 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1626 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1627 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1628 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1629 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1631 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1632 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1633 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1634 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1635 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1636 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1637 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1638 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1639 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1640 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1641 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1642 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1643 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1644 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1645 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1647 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1648 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1649 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1650 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1651 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1652 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1653 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1654 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1655 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1656 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1657 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1658 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1659 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1660 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1661 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1663 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1664 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1665 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1666 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1667 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1668 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1669 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1670 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1671 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1672 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1673 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1674 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1675 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1676 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1677 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1679 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1680 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1681 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1682 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1683 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1684 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1685 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1686 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1687 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1688 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1689 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1690 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1691 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1692 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1693 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1695 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1696 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1697 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1698 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1699 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1700 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1701 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1702 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1703 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1704 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1705 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1706 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1707 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1708 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1709 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1712 // More sampling precision with linear interpolation
1715 Float_t pad[kPRFbin];
1716 Int_t sPRFbin = kPRFbin;
1717 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
1718 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
1719 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
1722 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1723 fPRFpad = ((Int_t) (1.0 / fPRFwid));
1725 if (fPRFsmp) delete [] fPRFsmp;
1726 fPRFsmp = new Float_t[kNlayer*fPRFbin];
1732 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
1734 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
1736 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
1740 diff = bin - pad[ipos2++];
1741 } while ((diff > 0) && (ipos2 < kPRFbin));
1742 if (ipos2 == kPRFbin) {
1743 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1745 else if (ipos2 == 1) {
1746 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1750 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1752 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
1753 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
1762 //_____________________________________________________________________________
1763 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
1764 , Int_t layer, Double_t *pad) const
1767 // Applies the pad response
1768 // So far this is the fixed parametrization and should be replaced by
1769 // something dependent on calibration values
1772 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
1773 Int_t iOff = layer * fPRFbin;
1775 Int_t iBin0 = iBin - fPRFpad + iOff;
1776 Int_t iBin1 = iBin + iOff;
1777 Int_t iBin2 = iBin + fPRFpad + iOff;
1782 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
1785 pad[0] = signal * fPRFsmp[iBin0];
1787 pad[1] = signal * fPRFsmp[iBin1];
1788 if (iBin2 < (fPRFbin*kNlayer)) {
1789 pad[2] = signal * fPRFsmp[iBin2];
1804 AliTRDtrapConfig* AliTRDcalibDB::GetTrapConfig()
1806 // return an existing TRAPconfig or load it from the OCDB
1807 // in case of failure, a default TRAPconfig is created
1812 if ((fTrapConfigName.Length() <= 0) || (fTrapConfigVersion.Length() <= 0)) {
1813 // query the configuration to be used
1815 this->GetGlobalConfiguration(configName);
1816 TString configVersion;
1817 this->GetGlobalConfigurationVersion(configVersion);
1820 // try to load the requested configuration
1821 this->LoadTrapConfig(fTrapConfigName, fTrapConfigVersion);
1823 // if we still don't have a valid TRAPconfig, create a default one
1825 AliWarning("Falling back to default configuration");
1826 fTrapConfig = new AliTRDtrapConfig("default", "default TRAP configuration");
1827 AliTRDtrapConfigHandler cfgHandler(fTrapConfig);
1829 cfgHandler.LoadConfig();
1832 AliInfo(Form("using TRAPconfig \"%s\"", fTrapConfig->GetTitle()));
1839 AliTRDtrapConfig* AliTRDcalibDB::LoadTrapConfig(const TString &name, const TString &version)
1841 // try to load the specified configuration from the OCDB
1842 // if it fails, or it does not exist, return null
1844 AliInfo(Form("looking for TRAPconfig \"%s.%s\"", name.Data(), version.Data()));
1846 const AliTRDCalTrapConfig *caltrap = dynamic_cast<const AliTRDCalTrapConfig*> (GetCachedCDBObject(kIDTrapConfig));
1849 TString configName(name);
1850 configName.Append(".");
1851 configName.Append(version);
1852 fTrapConfig = caltrap->Get(configName);
1856 AliError("No TRAPconfig entry found!");