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"
45 #include "AliTRDgeometry.h"
47 #include "Cal/AliTRDCalROC.h"
48 #include "Cal/AliTRDCalPad.h"
49 #include "Cal/AliTRDCalDet.h"
50 #include "Cal/AliTRDCalDCS.h"
51 #include "Cal/AliTRDCalDCSv2.h"
52 #include "Cal/AliTRDCalDCSFEEv2.h"
53 #include "Cal/AliTRDCalPID.h"
54 #include "Cal/AliTRDCalMonitoring.h"
55 #include "Cal/AliTRDCalChamberStatus.h"
56 #include "Cal/AliTRDCalPadStatus.h"
57 #include "Cal/AliTRDCalSingleChamberStatus.h"
58 #include "Cal/AliTRDCalTrkAttach.h"
59 #include "Cal/AliTRDCalOnlineGainTable.h"
61 ClassImp(AliTRDcalibDB)
63 AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0;
64 Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
66 //_ singleton implementation __________________________________________________
67 AliTRDcalibDB* AliTRDcalibDB::Instance()
70 // Singleton implementation
71 // Returns an instance of this class, it is created if neccessary
74 if (fgTerminated != kFALSE) {
78 if (fgInstance == 0) {
79 fgInstance = new AliTRDcalibDB();
86 //_____________________________________________________________________________
87 void AliTRDcalibDB::Terminate()
90 // Singleton implementation
91 // Deletes the instance of this class and sets the terminated flag,
92 // instances cannot be requested anymore
93 // This function can be called several times.
98 if (fgInstance != 0) {
105 //_____________________________________________________________________________
106 AliTRDcalibDB::AliTRDcalibDB()
116 ,fOnlineGainTableID(0)
119 ,fTrapConfigVersion("")
122 // Default constructor
124 // TODO Default runnumber is set to 0, this should be changed later
125 // to an invalid value (e.g. -1) to prevent
126 // TODO invalid calibration data to be used.
129 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
134 // Create the sampled PRF
139 //_____________________________________________________________________________
140 AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
150 ,fOnlineGainTableID(0)
153 ,fTrapConfigVersion("")
156 // Copy constructor (not that it make any sense for a singleton...)
159 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
164 // Create the sampled PRF
169 //_____________________________________________________________________________
170 AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
173 // Assignment operator (same as above ...)
177 AliFatal("No assignment operator defined");
184 //_____________________________________________________________________________
185 AliTRDcalibDB::~AliTRDcalibDB()
205 //_caching functions____________________________________________________________
206 const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
209 // Retrieves a cdb object with the given id. The objects are cached as
210 // long as the run number is not changed.
212 // Put together the available objects here by using the lines
213 // a) For usual calibration objects:
215 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
217 // See function CacheCDBEntry for details.
219 // b) For calibration data which depends on two objects: One containing
220 // a value per detector and one the local fluctuations per pad:
222 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
224 // See function CacheMergeCDBEntry for details.
229 // Parameters defined per pad and chamber
231 return CacheCDBEntry(kIDVdriftPad ,"TRD/Calib/LocalVdrift");
233 case kIDVdriftChamber :
234 return CacheCDBEntry(kIDVdriftChamber ,"TRD/Calib/ChamberVdrift");
237 return CacheCDBEntry(kIDExBChamber ,"TRD/Calib/ChamberExB");
240 return CacheCDBEntry(kIDT0Pad ,"TRD/Calib/LocalT0");
243 return CacheCDBEntry(kIDT0Chamber ,"TRD/Calib/ChamberT0");
245 case kIDGainFactorPad :
246 return CacheCDBEntry(kIDGainFactorPad ,"TRD/Calib/LocalGainFactor");
248 case kIDGainFactorChamber :
249 return CacheCDBEntry(kIDGainFactorChamber ,"TRD/Calib/ChamberGainFactor");
252 case kIDOnlineGainFactor :
253 switch(GetOnlineGainTableID()) {
255 // For testing purposes only !!!
256 AliInfo("No gain table name from OCDB. Use default table!");
257 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01");
260 // Online gain table ID 1
261 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01");
264 // Online gain table ID 2
265 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN0_2011-01");
268 // Online gain table ID 3
269 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN8_2011-01");
272 // Online gain table ID 4
273 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-02");
276 // Online gain table ID 5
277 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-03");
280 // Online gain table ID 6
281 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN0_2012-01");
284 // Online gain table ID 7
285 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN8_2012-01");
288 // Online gain table ID 8
289 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2012-01");
292 AliError(Form("unknown gaintable requested with ID"));
296 case kIDNoiseChamber :
297 return CacheCDBEntry(kIDNoiseChamber ,"TRD/Calib/DetNoise");
300 return CacheCDBEntry(kIDNoisePad ,"TRD/Calib/PadNoise");
303 // Parameters defined per pad
305 return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth");
309 case kIDChamberStatus :
310 return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus");
313 return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus");
317 case kIDMonitoringData :
318 return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData");
321 return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE");
324 return CacheCDBEntry(kIDTrapConfig ,"TRD/Calib/TrapConfig");
327 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS");
330 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
333 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
336 return CacheCDBEntry(kIDPIDLQ1D ,"TRD/Calib/PIDLQ1D");
339 return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam");
342 return CacheCDBEntry(kIDAttach ,"TRD/Calib/TrkAttach");
345 return CacheCDBEntry(kIDPHQ ,"TRD/Calib/PHQ");
353 //_____________________________________________________________________________
354 AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
357 // Retrieves an entry with path <cdbPath> from the CDB.
360 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
362 AliError(Form("Failed to get entry: %s",cdbPath));
370 //_____________________________________________________________________________
371 const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
374 // Caches the entry <id> with cdb path <cdbPath>
377 if (!fCDBCache[id]) {
378 fCDBEntries[id] = GetCDBEntry(cdbPath);
379 if (fCDBEntries[id]) {
380 fCDBCache[id] = fCDBEntries[id]->GetObject();
381 if (id == kIDOnlineGainFactor)
382 AliInfo(Form("loaded gain table: %s", fCDBEntries[id]->GetId().GetAliCDBPath().GetPath().Data()));
386 return fCDBCache[id];
390 //_____________________________________________________________________________
391 void AliTRDcalibDB::SetRun(Long64_t run)
394 // Sets current run number. Calibration data is read from the corresponding file.
395 // When the run number changes the caching is invalidated.
408 //_____________________________________________________________________________
409 void AliTRDcalibDB::Invalidate()
412 // Invalidates cache (when run number is changed).
415 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
416 if (fCDBEntries[i]) {
417 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
418 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
422 delete fCDBEntries[i];
429 fOnlineGainTableID = 0;
433 //_____________________________________________________________________________
434 Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row)
437 // Returns the noise level in ADC counts for the given pad.
440 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
441 (GetCachedCDBObject(kIDNoisePad));
446 AliTRDCalROC *roc = calPad->GetCalROC(det);
451 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
452 (GetCachedCDBObject(kIDNoiseChamber));
457 return calChamber->GetValue(det) * roc->GetValue(col,row);
461 //_____________________________________________________________________________
462 AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det)
465 // Returns the Vdrift calibration object for a given ROC
466 // containing one number per pad
469 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
470 (GetCachedCDBObject(kIDNoisePad));
475 AliTRDCalROC *roc = calPad->GetCalROC(det);
485 //_____________________________________________________________________________
486 const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet()
489 // Returns the Vdrift calibration object
490 // containing one number per detector
493 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
494 (GetCachedCDBObject(kIDNoiseChamber));
504 //_____________________________________________________________________________
505 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
508 // Returns the drift velocity for the given pad.
511 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
512 (GetCachedCDBObject(kIDVdriftPad));
517 AliTRDCalROC *roc = calPad->GetCalROC(det);
522 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
523 (GetCachedCDBObject(kIDVdriftChamber));
528 return calChamber->GetValue(det) * roc->GetValue(col,row);
532 //_____________________________________________________________________________
533 AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
536 // Returns the Vdrift calibration object for a given ROC
537 // containing one number per pad
540 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
541 (GetCachedCDBObject(kIDVdriftPad));
546 AliTRDCalROC *roc = calPad->GetCalROC(det);
556 //_____________________________________________________________________________
557 const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
560 // Returns the Vdrift calibration object
561 // containing one number per detector
564 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
565 (GetCachedCDBObject(kIDVdriftChamber));
575 //_____________________________________________________________________________
576 TObjArray * AliTRDcalibDB::GetPHQ()
579 //return PHQ calibration object
581 TObjArray *arr = (TObjArray *) (GetCachedCDBObject(kIDPHQ));
585 //_____________________________________________________________________________
586 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
589 // Returns the average drift velocity for the given detector
592 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
593 (GetCachedCDBObject(kIDVdriftChamber));
598 return calDet->GetValue(det);
601 //_____________________________________________________________________________
602 const AliTRDCalDet *AliTRDcalibDB::GetExBDet()
605 // Returns the exB calibration object
606 // containing one number per detector
609 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> (GetCachedCDBObject(kIDExBChamber));
611 Double_t meanexb = 100.0;
612 if (calChamber) meanexb = calChamber->GetMean();
613 //printf("mean %f\n",meanexb);
615 if ((!calChamber) || (meanexb > 70.0)) {
617 const AliTRDCalDet *calChambervdrift = dynamic_cast<const AliTRDCalDet *>
618 (GetCachedCDBObject(kIDVdriftChamber));
619 if (!calChambervdrift) {
623 AliTRDCalDet *calDetExB = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
624 for(Int_t k = 0; k < 540; k++){
625 calDetExB->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(calChambervdrift->GetValue(k)));
630 else return calChamber;
633 //_____________________________________________________________________________
634 Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
637 // Returns t0 for the given pad.
640 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
641 (GetCachedCDBObject(kIDT0Pad));
646 AliTRDCalROC *roc = calPad->GetCalROC(det);
651 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
652 (GetCachedCDBObject(kIDT0Chamber));
657 return calChamber->GetValue(det) + roc->GetValue(col,row);
661 //_____________________________________________________________________________
662 AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
665 // Returns the t0 calibration object for a given ROC
666 // containing one number per pad
669 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
670 (GetCachedCDBObject(kIDT0Pad));
675 AliTRDCalROC *roc = calPad->GetCalROC(det);
685 //_____________________________________________________________________________
686 const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
689 // Returns the t0 calibration object
690 // containing one number per detector
693 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
694 (GetCachedCDBObject(kIDT0Chamber));
704 //_____________________________________________________________________________
705 Float_t AliTRDcalibDB::GetT0Average(Int_t det)
708 // Returns the average t0 for the given detector
711 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
712 (GetCachedCDBObject(kIDT0Pad));
717 AliTRDCalROC *roc = calPad->GetCalROC(det);
722 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
723 (GetCachedCDBObject(kIDT0Chamber));
729 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
730 sum += roc->GetValue(channel);
732 sum /= roc->GetNchannels();
733 sum += calDet->GetValue(det);
738 //_____________________________________________________________________________
739 AliTRDCalOnlineGainTableROC* AliTRDcalibDB::GetOnlineGainTableROC(Int_t det)
742 // Returns the online gain factor table for a given ROC.
745 if (!HasOnlineFilterGain()) {
749 const AliTRDCalOnlineGainTable *calOnline
750 = dynamic_cast<const AliTRDCalOnlineGainTable *>
751 (GetCachedCDBObject(kIDOnlineGainFactor));
756 return calOnline->GetGainTableROC(det);
760 //_____________________________________________________________________________
761 Float_t AliTRDcalibDB::GetOnlineGainFactor(Int_t det, Int_t col, Int_t row)
764 // Returns the online gain factor for the given pad.
767 if (!HasOnlineFilterGain()) {
771 const AliTRDCalOnlineGainTable *calOnline
772 = dynamic_cast<const AliTRDCalOnlineGainTable *>
773 (GetCachedCDBObject(kIDOnlineGainFactor));
778 return calOnline->GetGainCorrectionFactor(det,row,col);
782 //_____________________________________________________________________________
783 AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
786 // Returns the gain factor calibration object for a given ROC
789 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
790 (GetCachedCDBObject(kIDGainFactorPad));
795 AliTRDCalROC *roc = calPad->GetCalROC(det);
805 //_____________________________________________________________________________
806 Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
809 // Returns the gain factor for the given pad.
812 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
813 (GetCachedCDBObject(kIDGainFactorPad));
818 AliTRDCalROC *roc = calPad->GetCalROC(det);
823 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
824 (GetCachedCDBObject(kIDGainFactorChamber));
829 return calChamber->GetValue(det) * roc->GetValue(col,row);
833 //_____________________________________________________________________________
834 const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
837 // Returns the gain factor calibration object
838 // containing one number per detector
841 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
842 (GetCachedCDBObject(kIDGainFactorChamber));
852 //_____________________________________________________________________________
853 Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
856 // Returns the average gain factor for the given detector
859 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
860 (GetCachedCDBObject(kIDGainFactorChamber));
865 return calDet->GetValue(det);
869 //_____________________________________________________________________________
870 AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
873 // Returns the PRF calibration object for a given ROC
874 // containing one number per pad
877 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
878 (GetCachedCDBObject(kIDPRFWidth));
883 AliTRDCalROC *roc = calPad->GetCalROC(det);
893 //_____________________________________________________________________________
894 Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
897 // Returns the PRF width for the given pad.
900 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
901 (GetCachedCDBObject(kIDPRFWidth));
906 AliTRDCalROC *roc = calPad->GetCalROC(det);
911 return roc->GetValue(col,row);
915 //_____________________________________________________________________________
916 Int_t AliTRDcalibDB::ExtractTimeBinsFromString(TString tbstr)
918 // Check if there is any content in the string first
919 if (tbstr.Length() == 0) {
920 AliError("Parameter for number of timebins is empty!");
924 // Check if we have the correct config parameter
925 TString tbident = "tb";
926 TString tbsubstr = tbstr(0,2);
927 if (!tbsubstr.EqualTo(tbident)) {
928 AliError(Form("Parameter for number of timebins is corrupted (%s)!", tbstr.Data()));
933 // check if there is more than a number
934 if (!tbstr.IsDigit()) {
935 AliError(Form("Parameter for number of timebins is corrupted (%s)!", tbstr.Data()));
943 //_____________________________________________________________________________
944 Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS()
947 // Returns number of time bins from the DCS
950 // Get the corresponding parameter
951 TString cfgstr = "", cfgname = "";
952 GetGlobalConfiguration(cfgname);
953 if(cfgname.Length()==0)
955 GetDCSConfigParOption(cfgname, kTimebin, 0, cfgstr);
956 if(cfgstr.Length()==0)
958 return ExtractTimeBinsFromString(cfgstr);
962 //_____________________________________________________________________________
963 void AliTRDcalibDB::GetFilterType(TString &filterType)
966 // Returns the filter type
969 TString cfgname = "";
970 GetGlobalConfiguration(cfgname);
971 GetDCSConfigParOption(cfgname, kFltrSet, 0, filterType);
975 //_____________________________________________________________________________
976 Int_t AliTRDcalibDB::GetOnlineGainTableID()
979 // Get the gain table ID from the DCS
982 if (fOnlineGainTableID > 0) {
983 return fOnlineGainTableID;
986 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
991 Int_t esor = 0; // Take SOR
992 Int_t calver = 0; // Check CalDCS version
993 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
994 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
998 // No data for old DCS object available, anyway
1002 else if (calver == 2) {
1005 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1010 TString tableName = "";
1011 for (Int_t i = 0; i < 540; i++) {
1012 const AliTRDCalDCSFEEv2 *calDCSFEEv2 = calDCSv2->GetCalDCSFEEObj(0);
1013 tableName = calDCSFEEv2->GetGainTableName();
1014 if (tableName.Length() > 0) {
1018 if (tableName.CompareTo("Krypton_2011-01") == 0)
1019 fOnlineGainTableID = 1;
1020 else if (tableName.CompareTo("Gaintbl_Uniform_FGAN0_2011-01") == 0)
1021 fOnlineGainTableID = 2;
1022 else if (tableName.CompareTo("Gaintbl_Uniform_FGAN8_2011-01") == 0)
1023 fOnlineGainTableID = 3;
1024 else if (tableName.CompareTo("Krypton_2011-02") == 0)
1025 fOnlineGainTableID = 4;
1026 else if (tableName.CompareTo("Krypton_2011-03") == 0)
1027 fOnlineGainTableID = 5;
1028 else if (tableName.CompareTo("Gaintbl_Uniform_FGAN0_2012-01") == 0)
1029 fOnlineGainTableID = 6;
1030 else if (tableName.CompareTo("Gaintbl_Uniform_FGAN8_2012-01") == 0)
1031 fOnlineGainTableID = 7;
1032 else if (tableName.CompareTo("Krypton_2012-01") == 0)
1033 fOnlineGainTableID = 8;
1035 AliFatal(Form("unknown gaintable <%s> requested", tableName.Data()));
1037 AliInfo(Form("looking for gaintable: %s (id %i)",
1038 tableName.Data(), fOnlineGainTableID));
1040 if (fOnlineGainTableID > 0)
1041 return fOnlineGainTableID;
1045 AliError("NO DCS/DCSv2 OCDB entry found!");
1054 //_____________________________________________________________________________
1055 void AliTRDcalibDB::GetGlobalConfiguration(TString &config)
1058 // Get Configuration from the DCS
1061 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1063 AliError("No DCS CDB Object available!");
1068 Int_t idSOR = 0, idEOR=1; // The index of SOR and EOR
1069 Bool_t hasSOR = (dcsArr->At(idSOR));
1070 Bool_t hasEOR = (dcsArr->At(idEOR));
1071 TString cfgSOR = "", cfgEOR = ""; // The configuration at SOR/EOR
1073 // The SOR object is mandatory
1075 AliError("NO SOR object found in CDB file!");
1079 if (!hasEOR) AliWarning("NO EOR object found in CDB file!");
1081 // Check CalDCS version
1083 if (!strcmp(dcsArr->At(idSOR)->ClassName(),"AliTRDCalDCS")) calver = 1;
1084 else if (!strcmp(dcsArr->At(idSOR)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1086 // Get the configuration strings
1089 const AliTRDCalDCS *calSOR = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(idSOR));
1090 cfgSOR = calSOR->GetGlobalConfigName();
1092 const AliTRDCalDCS *calEOR = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(idEOR));
1093 cfgEOR = calEOR->GetGlobalConfigName();
1096 else if (calver == 2) {
1098 const AliTRDCalDCSv2 *calv2SOR = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(idSOR));
1099 cfgSOR = calv2SOR->GetGlobalConfigName();
1101 const AliTRDCalDCSv2 *calv2EOR = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(idEOR));
1102 cfgEOR = calv2EOR->GetGlobalConfigName();
1106 AliError("NO DCS/DCSv2 OCDB entry found!");
1111 // If there is no EOR entry, return the SOR value
1112 if (!hasEOR || cfgEOR.Length()==0) {
1117 // Check if the configuration is the same for both
1118 if (cfgSOR.EqualTo(cfgEOR)) {
1123 // When both SOR and EOR have an entry but are different, the config is not defined
1124 AliError("Inconsistent configuration at start and end of run found!");
1130 //_____________________________________________________________________________
1131 void AliTRDcalibDB::GetGlobalConfigurationVersion(TString &version)
1134 // Get Version of Configuration from the DCS
1137 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1143 Int_t esor = 0; // Take SOR
1144 Int_t calver = 0; // Check CalDCS version
1145 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1146 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1151 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
1156 version = calDCS->GetGlobalConfigVersion();
1159 else if (calver == 2) {
1162 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1167 version = calDCSv2->GetGlobalConfigVersion();
1172 AliError("NO DCS/DCSv2 OCDB entry found!");
1178 //_____________________________________________________________________________
1179 Int_t AliTRDcalibDB::GetNumberOfParsDCS(TString cname, Char_t delimiter)
1181 // Get the number of configuration parameters from the DCS config
1183 //AliInfo(Form("\"%s\" tokenized by \"%c\"", cname.Data(), delimiter));
1184 if(!cname.Length()) return -1; // -1 for the "cf"
1186 for(Int_t ich(1); ich<cname.Length()-1; ich++){ if(cname[ich]==delimiter) nconf++;}
1190 //_____________________________________________________________________________
1191 Int_t AliTRDcalibDB::GetNumberOfOptsDCS(TString cname, Int_t cfgType)
1193 // Get the number of options of a given configuration parameter from DCS
1195 Char_t cdelim = '_', // define the delimiters
1197 Int_t nconfig = GetNumberOfParsDCS(cname, cdelim);
1200 if ((nconfig == -1) || (nconfig < cfgType)) {
1201 AliError("Not enough parameters in DCS configuration name!");
1205 TObjArray *carr = cname.Tokenize(cdelim);
1206 Int_t nopt = GetNumberOfParsDCS(((TObjString*)carr->At(cfgType))->GetString(), odelim);
1207 carr->Delete(); delete carr;
1211 //_____________________________________________________________________________
1212 void AliTRDcalibDB::GetDCSConfigParOption(TString cname, Int_t cfgType, Int_t option, TString &cfgo)
1215 // Get a configuration (see enum in header file) or the options of a configuration
1216 // option == 0 returns the configuration itself
1217 // option > 0 returns the optional parameter Nr. (option) of the configuration (cfgType)
1220 Char_t cdelim = '_', // define the delimiters
1223 Int_t nconfig = GetNumberOfParsDCS(cname, cdelim);
1225 if (nconfig == -1) {
1226 AliError("DCS configuration name empty!");
1229 } else if (nconfig < cfgType) {
1230 AliError("Not enough parameters in DCS configuration name!");
1235 TObjArray *carr = cname.Tokenize(cdelim);
1236 TString cfgString(((TObjString*)carr->At(cfgType))->GetString());
1237 Int_t noptions = GetNumberOfParsDCS(cfgString, odelim);
1239 if (noptions < option) {
1240 AliError("Not enough options in DCS configuration name!");
1242 carr->Delete(); delete carr;
1245 TObjArray *oarr = cfgString.Tokenize(odelim);
1246 cfgo = ((TObjString*)oarr->At(option))->GetString();
1247 carr->Delete(); delete carr;
1248 oarr->Delete(); delete oarr;
1253 //_____________________________________________________________________________
1254 Bool_t AliTRDcalibDB::HasOnlineFilterPedestal()
1257 // Checks whether pedestal filter was applied online
1260 TString filterconfig;
1261 GetFilterType(filterconfig);
1263 return filterconfig.Contains("p");
1267 //_____________________________________________________________________________
1268 Bool_t AliTRDcalibDB::HasOnlineFilterGain()
1271 // Checks whether online gain filter was applied
1274 TString filterconfig;
1275 GetFilterType(filterconfig);
1277 return filterconfig.Contains("g");
1281 //_____________________________________________________________________________
1282 Bool_t AliTRDcalibDB::HasOnlineTailCancellation()
1285 // Checks whether online tail cancellation was applied
1288 TString filterconfig;
1289 GetFilterType(filterconfig);
1291 return filterconfig.Contains("t");
1295 //_____________________________________________________________________________
1296 Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
1299 // Returns the status of the given pad
1302 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1303 (GetCachedCDBObject(kIDPadStatus));
1308 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1313 return roc->GetStatus(col,row);
1317 //_____________________________________________________________________________
1318 AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
1321 // Returns the pad status calibration object for a given ROC
1324 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1325 (GetCachedCDBObject(kIDPadStatus));
1330 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1340 //_____________________________________________________________________________
1341 Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
1344 // Returns the status of the given chamber
1347 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
1348 (GetCachedCDBObject(kIDChamberStatus));
1353 return cal->GetStatus(det);
1357 //_____________________________________________________________________________
1358 AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
1361 // Returns the TRD reconstruction parameters from the OCDB
1364 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
1365 if (!recos) return 0x0;
1367 // calculate entry based on event type info
1368 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
1370 return (AliTRDrecoParam *) recos->UncheckedAt(n);
1374 //_____________________________________________________________________________
1375 Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
1378 // Returns status, see name of functions for details ;-)
1381 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1382 (GetCachedCDBObject(kIDPadStatus));
1387 return cal->IsMasked(det,col,row);
1391 //_____________________________________________________________________________
1392 Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
1395 // Returns status, see name of functions for details ;-)
1398 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1399 (GetCachedCDBObject(kIDPadStatus));
1404 return cal->IsBridgedLeft(det,col,row);
1408 //_____________________________________________________________________________
1409 Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
1412 // Returns status, see name of functions for details ;-)
1415 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1416 (GetCachedCDBObject(kIDPadStatus));
1421 return cal->IsBridgedRight(det,col,row);
1425 //_____________________________________________________________________________
1426 Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
1429 // Returns status, see name of functions for details ;-)
1432 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1433 (GetCachedCDBObject(kIDPadStatus));
1438 return cal->IsNotConnected(det,col,row);
1442 //_____________________________________________________________________________
1443 Bool_t AliTRDcalibDB::IsChamberGood(Int_t det)
1446 // Returns status, see name of functions for details ;-)
1449 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1450 (GetCachedCDBObject(kIDChamberStatus));
1455 return cal->IsGood(det);
1459 //_____________________________________________________________________________
1460 Bool_t AliTRDcalibDB::IsChamberNoData(Int_t det)
1463 // Returns status, see name of functions for details ;-)
1466 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1467 (GetCachedCDBObject(kIDChamberStatus));
1472 return cal->IsNoData(det);
1476 //_____________________________________________________________________________
1477 Bool_t AliTRDcalibDB::IsHalfChamberNoData(Int_t det, Int_t side)
1480 // Returns status, see name of functions for details ;-)
1483 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1484 (GetCachedCDBObject(kIDChamberStatus));
1489 return side > 0 ? cal->IsNoDataSideB(det) : cal->IsNoDataSideA(det);
1493 //_____________________________________________________________________________
1494 Bool_t AliTRDcalibDB::IsChamberBadCalibrated(Int_t det)
1497 // Returns status, see name of functions for details ;-)
1500 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1501 (GetCachedCDBObject(kIDChamberStatus));
1506 return cal->IsBadCalibrated(det);
1510 //_____________________________________________________________________________
1511 Bool_t AliTRDcalibDB::IsChamberNotCalibrated(Int_t det)
1514 // Returns status, see name of functions for details ;-)
1517 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1518 (GetCachedCDBObject(kIDChamberStatus));
1523 return cal->IsNotCalibrated(det);
1527 //_____________________________________________________________________________
1528 const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
1531 // Returns the object storing the distributions for PID with likelihood
1535 case AliTRDpidUtil::kLQ:
1536 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
1537 case AliTRDpidUtil::kNN:
1538 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
1539 case AliTRDpidUtil::kESD:
1540 return 0x0; // To avoid compiler warnings
1547 //_____________________________________________________________________________
1548 AliTRDPIDResponse *AliTRDcalibDB::GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod /*method*/)
1551 // Returns the PID response object for 1D-LQ
1554 if (!fPIDResponse) {
1555 AliDebug(2, "Setting new PID response.");
1557 fPIDResponse = new AliTRDPIDResponse;
1559 // Load Reference Histos from OCDB
1560 // if(method == AliTRDPIDResponse::kLQ1D){
1561 //fPIDResponse->SetPIDmethod(AliTRDPIDResponse::kLQ1D);
1562 const TObjArray *references = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDPIDLQ1D));
1564 TIter refs(references);
1565 TObject *obj = NULL;
1566 AliTRDPIDReference *ref = NULL;
1567 Bool_t hasReference = kFALSE;
1568 while ((obj = refs())){
1569 if ((ref = dynamic_cast<AliTRDPIDReference *>(obj))){
1570 AliDebug(2, "Setting new PID response object.");
1571 TDirectory *bkpdir = gDirectory;
1573 AliTRDPIDResponseObject *ro = new AliTRDPIDResponseObject;
1574 ro->SetPIDReference(ref);
1575 fPIDResponse->SetPIDResponseObject(ro);
1576 hasReference = kTRUE;
1577 gDirectory = bkpdir;
1582 if (!hasReference) {
1583 AliError("Reference histograms not found in the OCDB");
1589 return fPIDResponse;
1593 //_____________________________________________________________________________
1594 const AliTRDCalTrkAttach* AliTRDcalibDB::GetAttachObject()
1597 // Returns the object storing likelihood distributions for cluster to track attachment
1600 return dynamic_cast<const AliTRDCalTrkAttach*>(GetCachedCDBObject(kIDAttach));
1604 //_____________________________________________________________________________
1605 const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
1608 // Returns the object storing the monitoring data
1611 return dynamic_cast<const AliTRDCalMonitoring *>
1612 (GetCachedCDBObject(kIDMonitoringData));
1616 //_____________________________________________________________________________
1617 void AliTRDcalibDB::SamplePRF()
1620 // Samples the pad response function (should maybe go somewhere else ...)
1623 const Int_t kPRFbin = 61;
1625 Float_t prf[kNlayer][kPRFbin] = {
1626 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
1627 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1628 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1629 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1630 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1631 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1632 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1633 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1634 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1635 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1636 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1637 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1638 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1639 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1640 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1642 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1643 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1644 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1645 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1646 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1647 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1648 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1649 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1650 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1651 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1652 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1653 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1654 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1655 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1656 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1658 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1659 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1660 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1661 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1662 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1663 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1664 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1665 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1666 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1667 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1668 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1669 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1670 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1671 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1672 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1674 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1675 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1676 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1677 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1678 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1679 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1680 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1681 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1682 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1683 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1684 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1685 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1686 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1687 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1688 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1690 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1691 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1692 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1693 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1694 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1695 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1696 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1697 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1698 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1699 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1700 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1701 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1702 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1703 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1704 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1706 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1707 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1708 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1709 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1710 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1711 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1712 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1713 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1714 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1715 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1716 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1717 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1718 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1719 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1720 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1723 // More sampling precision with linear interpolation
1726 Float_t pad[kPRFbin];
1727 Int_t sPRFbin = kPRFbin;
1728 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
1729 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
1730 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
1733 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1734 fPRFpad = ((Int_t) (1.0 / fPRFwid));
1736 if (fPRFsmp) delete [] fPRFsmp;
1737 fPRFsmp = new Float_t[kNlayer*fPRFbin];
1743 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
1745 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
1747 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
1751 diff = bin - pad[ipos2++];
1752 } while ((diff > 0) && (ipos2 < kPRFbin));
1753 if (ipos2 == kPRFbin) {
1754 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1756 else if (ipos2 == 1) {
1757 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1761 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1763 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
1764 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
1773 //_____________________________________________________________________________
1774 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
1775 , Int_t layer, Double_t *pad) const
1778 // Applies the pad response
1779 // So far this is the fixed parametrization and should be replaced by
1780 // something dependent on calibration values
1783 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
1784 Int_t iOff = layer * fPRFbin;
1786 Int_t iBin0 = iBin - fPRFpad + iOff;
1787 Int_t iBin1 = iBin + iOff;
1788 Int_t iBin2 = iBin + fPRFpad + iOff;
1793 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
1796 pad[0] = signal * fPRFsmp[iBin0];
1798 pad[1] = signal * fPRFsmp[iBin1];
1799 if (iBin2 < (fPRFbin*kNlayer)) {
1800 pad[2] = signal * fPRFsmp[iBin2];
1815 AliTRDtrapConfig* AliTRDcalibDB::GetTrapConfig()
1817 // return an existing TRAPconfig or load it from the OCDB
1818 // in case of failure, a default TRAPconfig is created
1823 if ((fTrapConfigName.Length() <= 0) || (fTrapConfigVersion.Length() <= 0)) {
1824 // query the configuration to be used
1825 this->GetGlobalConfiguration(fTrapConfigName);
1826 this->GetGlobalConfigurationVersion(fTrapConfigVersion);
1829 // try to load the requested configuration
1830 this->LoadTrapConfig(fTrapConfigName, fTrapConfigVersion);
1832 // if we still don't have a valid TRAPconfig, create a default one
1834 AliWarning("Falling back to default configuration");
1835 static AliTRDtrapConfig trapConfigDefault("default", "default TRAP configuration");
1836 fTrapConfig = &trapConfigDefault;
1837 AliTRDtrapConfigHandler cfgHandler(fTrapConfig);
1839 cfgHandler.LoadConfig();
1842 AliInfo(Form("using TRAPconfig \"%s\"", fTrapConfig->GetTitle()));
1844 // we still have to load the gain tables
1845 // if the gain filter is active
1846 if (HasOnlineFilterGain()) {
1847 const Int_t nDets = AliTRDgeometry::Ndet();
1848 const Int_t nMcms = AliTRDgeometry::MCMmax();
1849 const Int_t nChs = AliTRDgeometry::ADCmax();
1851 // gain factors are per MCM
1852 // allocate the registers accordingly
1853 for (Int_t ch = 0; ch < nChs; ++ch) {
1854 AliTRDtrapConfig::TrapReg_t regFGAN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGA0 + ch);
1855 AliTRDtrapConfig::TrapReg_t regFGFN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGF0 + ch);
1856 fTrapConfig->SetTrapRegAlloc(regFGAN, AliTRDtrapConfig::kAllocByMCM);
1857 fTrapConfig->SetTrapRegAlloc(regFGFN, AliTRDtrapConfig::kAllocByMCM);
1860 for (Int_t iDet = 0; iDet < nDets; ++iDet) {
1861 AliTRDCalOnlineGainTableROC *gainTbl = GetOnlineGainTableROC(iDet);
1863 const Int_t nRobs = AliTRDgeometry::GetStack(iDet) == 2 ?
1864 AliTRDgeometry::ROBmaxC0() : AliTRDgeometry::ROBmaxC1();
1865 for (Int_t rob = 0; rob < nRobs; ++rob) {
1866 for (Int_t mcm = 0; mcm < nMcms; ++mcm) {
1867 AliTRDCalOnlineGainTableMCM *gainTblMCM = gainTbl->GetGainTableMCM(rob, mcm);
1869 // set ADC reference voltage
1870 fTrapConfig->SetTrapReg(AliTRDtrapConfig::kADCDAC, gainTblMCM->GetAdcdac(), iDet, rob, mcm);
1872 // set constants channel-wise
1873 for (Int_t ch = 0; ch < nChs; ++ch) {
1874 AliTRDtrapConfig::TrapReg_t regFGAN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGA0 + ch);
1875 AliTRDtrapConfig::TrapReg_t regFGFN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGF0 + ch);
1876 fTrapConfig->SetTrapReg(regFGAN, gainTblMCM->GetFGAN(ch), iDet, rob, mcm);
1877 fTrapConfig->SetTrapReg(regFGFN, gainTblMCM->GetFGFN(ch), iDet, rob, mcm);
1890 AliTRDtrapConfig* AliTRDcalibDB::LoadTrapConfig(const TString &name, const TString &version)
1892 // try to load the specified configuration from the OCDB
1893 // if it fails, or it does not exist, return null
1895 AliInfo(Form("looking for TRAPconfig \"%s.%s\"", name.Data(), version.Data()));
1897 const AliTRDCalTrapConfig *caltrap = dynamic_cast<const AliTRDCalTrapConfig*> (GetCachedCDBObject(kIDTrapConfig));
1900 TString configName(name);
1901 configName.Append(".");
1902 configName.Append(version);
1903 fTrapConfig = caltrap->Get(configName);
1907 AliError("No TRAPconfig entry found!");