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 ///////////////////////////////////////////////////////////////////////////////
31 #include <TClonesArray.h>
32 #include <TObjArray.h>
34 #include "AliCDBManager.h"
35 #include "AliCDBEntry.h"
38 #include "AliTRDcalibDB.h"
40 #include "Cal/AliTRDCalROC.h"
41 #include "Cal/AliTRDCalPad.h"
42 #include "Cal/AliTRDCalDet.h"
43 #include "Cal/AliTRDCalDCS.h"
44 #include "Cal/AliTRDCalDCSv2.h"
45 #include "Cal/AliTRDCalPID.h"
46 #include "Cal/AliTRDCalMonitoring.h"
47 #include "Cal/AliTRDCalChamberStatus.h"
48 #include "Cal/AliTRDCalPadStatus.h"
49 #include "Cal/AliTRDCalSingleChamberStatus.h"
51 ClassImp(AliTRDcalibDB)
53 AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0;
54 Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
56 //_ singleton implementation __________________________________________________
57 AliTRDcalibDB* AliTRDcalibDB::Instance()
60 // Singleton implementation
61 // Returns an instance of this class, it is created if neccessary
64 if (fgTerminated != kFALSE) {
68 if (fgInstance == 0) {
69 fgInstance = new AliTRDcalibDB();
76 //_____________________________________________________________________________
77 void AliTRDcalibDB::Terminate()
80 // Singleton implementation
81 // Deletes the instance of this class and sets the terminated flag,
82 // instances cannot be requested anymore
83 // This function can be called several times.
88 if (fgInstance != 0) {
95 //_____________________________________________________________________________
96 AliTRDcalibDB::AliTRDcalibDB()
107 // Default constructor
109 // TODO Default runnumber is set to 0, this should be changed later
110 // to an invalid value (e.g. -1) to prevent
111 // TODO invalid calibration data to be used.
114 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
119 // Create the sampled PRF
124 //_____________________________________________________________________________
125 AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
136 // Copy constructor (not that it make any sense for a singleton...)
139 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
144 // Create the sampled PRF
149 //_____________________________________________________________________________
150 AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
153 // Assignment operator (same as above ...)
157 AliFatal("No assignment operator defined");
164 //_____________________________________________________________________________
165 AliTRDcalibDB::~AliTRDcalibDB()
180 //_caching functions____________________________________________________________
181 const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
184 // Retrieves a cdb object with the given id. The objects are cached as
185 // long as the run number is not changed.
187 // Put together the available objects here by using the lines
188 // a) For usual calibration objects:
190 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
192 // See function CacheCDBEntry for details.
194 // b) For calibration data which depends on two objects: One containing
195 // a value per detector and one the local fluctuations per pad:
197 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
199 // See function CacheMergeCDBEntry for details.
204 // Parameters defined per pad and chamber
206 return CacheCDBEntry(kIDVdriftPad ,"TRD/Calib/LocalVdrift");
208 case kIDVdriftChamber :
209 return CacheCDBEntry(kIDVdriftChamber ,"TRD/Calib/ChamberVdrift");
212 return CacheCDBEntry(kIDT0Pad ,"TRD/Calib/LocalT0");
215 return CacheCDBEntry(kIDT0Chamber ,"TRD/Calib/ChamberT0");
217 case kIDGainFactorPad :
218 return CacheCDBEntry(kIDGainFactorPad ,"TRD/Calib/LocalGainFactor");
220 case kIDGainFactorChamber :
221 return CacheCDBEntry(kIDGainFactorChamber ,"TRD/Calib/ChamberGainFactor");
223 case kIDNoiseChamber :
224 return CacheCDBEntry(kIDNoiseChamber ,"TRD/Calib/DetNoise");
227 return CacheCDBEntry(kIDNoisePad ,"TRD/Calib/PadNoise");
231 // Parameters defined per pad
233 return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth");
237 case kIDChamberStatus :
238 return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus");
241 return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus");
245 case kIDMonitoringData :
246 return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData");
249 return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE");
252 if (GetCDBEntry("TRD/Calib/DCSv2"))
253 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCSv2");
255 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS");
258 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
260 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
263 return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam");
272 //_____________________________________________________________________________
273 AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
276 // Retrieves an entry with path <cdbPath> from the CDB.
279 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
281 AliError(Form("Failed to get entry: %s",cdbPath));
289 //_____________________________________________________________________________
290 const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
293 // Caches the entry <id> with cdb path <cdbPath>
296 if (!fCDBCache[id]) {
297 fCDBEntries[id] = GetCDBEntry(cdbPath);
298 if (fCDBEntries[id]) {
299 fCDBCache[id] = fCDBEntries[id]->GetObject();
303 return fCDBCache[id];
307 //_____________________________________________________________________________
308 void AliTRDcalibDB::SetRun(Long64_t run)
311 // Sets current run number. Calibration data is read from the corresponding file.
312 // When the run number changes the caching is invalidated.
325 //_____________________________________________________________________________
326 void AliTRDcalibDB::Invalidate()
329 // Invalidates cache (when run number is changed).
332 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
333 if (fCDBEntries[i]) {
334 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
335 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
339 delete fCDBEntries[i];
347 //_____________________________________________________________________________
348 Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row)
351 // Returns the noise level in ADC counts for the given pad.
354 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
355 (GetCachedCDBObject(kIDNoisePad));
360 AliTRDCalROC *roc = calPad->GetCalROC(det);
365 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
366 (GetCachedCDBObject(kIDNoiseChamber));
371 return calChamber->GetValue(det) * roc->GetValue(col,row);
375 //_____________________________________________________________________________
376 AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det)
379 // Returns the Vdrift calibration object for a given ROC
380 // containing one number per pad
383 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
384 (GetCachedCDBObject(kIDNoisePad));
389 AliTRDCalROC *roc = calPad->GetCalROC(det);
399 //_____________________________________________________________________________
400 const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet()
403 // Returns the Vdrift calibration object
404 // containing one number per detector
407 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
408 (GetCachedCDBObject(kIDNoiseChamber));
418 //_____________________________________________________________________________
419 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
422 // Returns the drift velocity for the given pad.
425 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
426 (GetCachedCDBObject(kIDVdriftPad));
431 AliTRDCalROC *roc = calPad->GetCalROC(det);
436 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
437 (GetCachedCDBObject(kIDVdriftChamber));
442 return calChamber->GetValue(det) * roc->GetValue(col,row);
446 //_____________________________________________________________________________
447 AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
450 // Returns the Vdrift calibration object for a given ROC
451 // containing one number per pad
454 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
455 (GetCachedCDBObject(kIDVdriftPad));
460 AliTRDCalROC *roc = calPad->GetCalROC(det);
470 //_____________________________________________________________________________
471 const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
474 // Returns the Vdrift calibration object
475 // containing one number per detector
478 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
479 (GetCachedCDBObject(kIDVdriftChamber));
489 //_____________________________________________________________________________
490 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
493 // Returns the average drift velocity for the given detector
496 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
497 (GetCachedCDBObject(kIDVdriftChamber));
502 return calDet->GetValue(det);
506 //_____________________________________________________________________________
507 Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
510 // Returns t0 for the given pad.
513 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
514 (GetCachedCDBObject(kIDT0Pad));
519 AliTRDCalROC *roc = calPad->GetCalROC(det);
524 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
525 (GetCachedCDBObject(kIDT0Chamber));
530 return calChamber->GetValue(det) + roc->GetValue(col,row);
534 //_____________________________________________________________________________
535 AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
538 // Returns the t0 calibration object for a given ROC
539 // containing one number per pad
542 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
543 (GetCachedCDBObject(kIDT0Pad));
548 AliTRDCalROC *roc = calPad->GetCalROC(det);
558 //_____________________________________________________________________________
559 const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
562 // Returns the t0 calibration object
563 // containing one number per detector
566 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
567 (GetCachedCDBObject(kIDT0Chamber));
577 //_____________________________________________________________________________
578 Float_t AliTRDcalibDB::GetT0Average(Int_t det)
581 // Returns the average t0 for the given detector
584 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
585 (GetCachedCDBObject(kIDT0Pad));
590 AliTRDCalROC *roc = calPad->GetCalROC(det);
595 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
596 (GetCachedCDBObject(kIDT0Chamber));
602 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
603 sum += roc->GetValue(channel);
605 sum /= roc->GetNchannels();
606 sum += calDet->GetValue(det);
611 //_____________________________________________________________________________
612 Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
615 // Returns the gain factor for the given pad.
618 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
619 (GetCachedCDBObject(kIDGainFactorPad));
624 AliTRDCalROC *roc = calPad->GetCalROC(det);
629 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
630 (GetCachedCDBObject(kIDGainFactorChamber));
635 return calChamber->GetValue(det) * roc->GetValue(col,row);
639 //_____________________________________________________________________________
640 AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
643 // Returns the gain factor calibration object for a given ROC
646 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
647 (GetCachedCDBObject(kIDGainFactorPad));
652 AliTRDCalROC *roc = calPad->GetCalROC(det);
662 //_____________________________________________________________________________
663 const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
666 // Returns the gain factor calibration object
667 // containing one number per detector
670 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
671 (GetCachedCDBObject(kIDGainFactorChamber));
681 //_____________________________________________________________________________
682 Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
685 // Returns the average gain factor for the given detector
688 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
689 (GetCachedCDBObject(kIDGainFactorChamber));
694 return calDet->GetValue(det);
698 //_____________________________________________________________________________
699 AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
702 // Returns the PRF calibration object for a given ROC
703 // containing one number per pad
706 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
707 (GetCachedCDBObject(kIDPRFWidth));
712 AliTRDCalROC *roc = calPad->GetCalROC(det);
722 //_____________________________________________________________________________
723 Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
726 // Returns the PRF width for the given pad.
729 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
730 (GetCachedCDBObject(kIDPRFWidth));
735 AliTRDCalROC *roc = calPad->GetCalROC(det);
740 return roc->GetValue(col,row);
744 //_____________________________________________________________________________
745 Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS()
748 // Returns Number of time bins from the DCS
751 Int_t nMixed = -2; // not the same number for all chambers
752 Int_t nUndef = -1; // default value - has not been set!
753 Int_t nTbSor = nUndef;
754 Int_t nTbEor = nUndef;
756 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
759 AliError("No DCS object found!");
763 if (GetCDBEntry("TRD/Calib/DCSv2")) {
764 // if there is a DCSv2 object
765 const AliTRDCalDCSv2 *calDCSsorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(0));
766 const AliTRDCalDCSv2 *calDCSeorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(1));
769 // the SOR file is mandatory
770 AliError("NO SOR AliTRDCalDCSv2 object found in CDB file!");
775 // this can happen if the run is shorter than a couple of seconds.
776 AliWarning("NO EOR AliTRDCalDCSv2 object found in CDB file.");
780 nTbSor = calDCSsorv2->GetGlobalNumberOfTimeBins();
781 if (calDCSeorv2) nTbEor = calDCSeorv2->GetGlobalNumberOfTimeBins();
783 // if there is a DCS object
784 const AliTRDCalDCS *calDCSsor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(0));
785 const AliTRDCalDCS *calDCSeor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(1));
788 // the SOR file is mandatory
789 AliError("NO SOR AliTRDCalDCS object found in CDB file!");
794 // this can happen if the run is shorter than a couple of seconds.
795 AliWarning("NO EOR AliTRDCalDCS object found in CDB file.");
799 nTbSor = calDCSsor->GetGlobalNumberOfTimeBins();
800 if (calDCSeor) nTbEor = calDCSeor->GetGlobalNumberOfTimeBins();
803 // if they're the same return the value
804 // -2 means mixed, -1: no data, >= 0: good number of time bins
805 if (nTbSor == nTbEor) return nTbSor;
807 // if they're differing:
808 if (nTbSor == nMixed || nTbEor == nMixed) {
809 AliWarning("Inconsistent number of time bins found!");
813 // one is undefined, the other ok -> return that one
814 if (nTbSor == nUndef) return nTbEor;
815 if (nTbEor == nUndef) return nTbSor;
817 // only remains: two different numbers >= 0
821 //_____________________________________________________________________________
822 void AliTRDcalibDB::GetFilterType(TString &filterType)
825 // Returns the filter type
828 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
833 if (GetCDBEntry("TRD/Calib/DCSv2")) {
834 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(0)); // Take SOR
840 filterType = calDCSv2->GetGlobalFilterType();
842 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(0)); // Take SOR
848 filterType = calDCS->GetGlobalFilterType();
852 //_____________________________________________________________________________
853 void AliTRDcalibDB::GetGlobalConfiguration(TString &config){
855 // Get Configuration from the DCS
857 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
863 if (GetCDBEntry("TRD/Calib/DCSv2")) {
864 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(0)); // Take SOR
870 config = calDCSv2->GetGlobalConfigName();
872 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(0)); // Take SOR
878 config = calDCS->GetGlobalConfigName();
882 //_____________________________________________________________________________
883 Bool_t AliTRDcalibDB::HasOnlineFilterPedestal()
886 // Checks whether pedestal filter was applied online
889 // Temporary: Get the filter config from the configuration name
890 GetGlobalConfiguration(cname);
891 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
892 // TString filterconfig;
893 //GetFilterType(filterconfig);
894 return filterconfig.Contains("p");
897 //_____________________________________________________________________________
898 Bool_t AliTRDcalibDB::HasOnlineFilterGain(){
900 // Checks whether online gain filter was applied
903 // Temporary: Get the filter config from the configuration name
904 GetGlobalConfiguration(cname);
905 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
906 //TString filterconfig;
907 //GetFilterType(filterconfig);
908 return filterconfig.Contains("g");
911 //_____________________________________________________________________________
912 Bool_t AliTRDcalibDB::HasOnlineTailCancellation(){
914 // Checks whether online tail cancellation was applied
917 // Temporary: Get the filter config from the configuration name
918 GetGlobalConfiguration(cname);
919 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
920 //TString filterconfig;
921 //GetFilterType(filterconfig);
922 return filterconfig.Contains("t");
925 //_____________________________________________________________________________
926 Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
929 // Returns the status of the given pad
932 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
933 (GetCachedCDBObject(kIDPadStatus));
938 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
943 return roc->GetStatus(col,row);
947 //_____________________________________________________________________________
948 AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
951 // Returns the pad status calibration object for a given ROC
954 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
955 (GetCachedCDBObject(kIDPadStatus));
960 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
970 //_____________________________________________________________________________
971 Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
974 // Returns the status of the given chamber
977 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
978 (GetCachedCDBObject(kIDChamberStatus));
983 return cal->GetStatus(det);
987 //_____________________________________________________________________________
988 AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
991 // Returns the TRD reconstruction parameters from the OCDB
994 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
995 if (!recos) return 0x0;
997 // calculate entry based on event type info
998 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
1000 return (AliTRDrecoParam*)recos->UncheckedAt(n);
1004 //_____________________________________________________________________________
1005 Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
1008 // Returns status, see name of functions for details ;-)
1011 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1012 (GetCachedCDBObject(kIDPadStatus));
1017 return cal->IsMasked(det,col,row);
1021 //_____________________________________________________________________________
1022 Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
1025 // Returns status, see name of functions for details ;-)
1028 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1029 (GetCachedCDBObject(kIDPadStatus));
1034 return cal->IsBridgedLeft(det,col,row);
1038 //_____________________________________________________________________________
1039 Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
1042 // Returns status, see name of functions for details ;-)
1045 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1046 (GetCachedCDBObject(kIDPadStatus));
1051 return cal->IsBridgedRight(det,col,row);
1055 //_____________________________________________________________________________
1056 Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
1059 // Returns status, see name of functions for details ;-)
1062 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1063 (GetCachedCDBObject(kIDPadStatus));
1068 return cal->IsNotConnected(det,col,row);
1072 //_____________________________________________________________________________
1073 Bool_t AliTRDcalibDB::IsChamberInstalled(Int_t det)
1076 // Returns status, see name of functions for details ;-)
1079 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1080 (GetCachedCDBObject(kIDChamberStatus));
1085 return cal->IsInstalled(det);
1089 //_____________________________________________________________________________
1090 Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
1093 // Returns status, see name of functions for details ;-)
1096 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1097 (GetCachedCDBObject(kIDChamberStatus));
1102 return cal->IsMasked(det);
1105 //_____________________________________________________________________________
1106 Bool_t AliTRDcalibDB::IsHalfChamberMasked(Int_t det, Int_t side){
1108 // Returns status, see name of functions for details ;-)
1111 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1112 (GetCachedCDBObject(kIDChamberStatus));
1117 return side > 0 ? cal->IsHalfChamberSideBMasked(det) : cal->IsHalfChamberSideAMasked(det);
1120 //_____________________________________________________________________________
1121 const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
1124 // Returns the object storing the distributions for PID with likelihood
1128 case AliTRDpidUtil::kLQ:
1129 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
1130 case AliTRDpidUtil::kNN:
1131 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
1132 case AliTRDpidUtil::kESD:
1133 return 0x0; // To avoid compiler warnings
1140 //_____________________________________________________________________________
1141 const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
1144 // Returns the object storing the monitoring data
1147 return dynamic_cast<const AliTRDCalMonitoring *>
1148 (GetCachedCDBObject(kIDMonitoringData));
1152 //_____________________________________________________________________________
1153 void AliTRDcalibDB::SamplePRF()
1156 // Samples the pad response function (should maybe go somewhere else ...)
1159 const Int_t kPRFbin = 61;
1161 Float_t prf[kNlayer][kPRFbin] = {
1162 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
1163 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1164 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1165 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1166 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1167 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1168 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1169 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1170 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1171 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1172 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1173 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1174 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1175 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1176 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1178 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1179 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1180 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1181 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1182 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1183 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1184 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1185 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1186 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1187 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1188 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1189 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1190 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1191 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1192 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1194 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1195 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1196 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1197 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1198 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1199 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1200 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1201 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1202 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1203 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1204 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1205 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1206 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1207 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1208 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1210 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1211 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1212 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1213 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1214 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1215 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1216 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1217 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1218 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1219 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1220 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1221 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1222 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1223 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1224 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1226 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1227 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1228 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1229 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1230 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1231 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1232 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1233 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1234 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1235 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1236 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1237 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1238 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1239 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1240 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1242 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1243 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1244 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1245 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1246 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1247 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1248 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1249 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1250 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1251 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1252 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1253 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1254 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1255 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1256 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1259 // More sampling precision with linear interpolation
1262 Float_t pad[kPRFbin];
1263 Int_t sPRFbin = kPRFbin;
1264 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
1265 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
1266 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
1269 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1270 fPRFpad = ((Int_t) (1.0 / fPRFwid));
1272 if (fPRFsmp) delete [] fPRFsmp;
1273 fPRFsmp = new Float_t[kNlayer*fPRFbin];
1279 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
1281 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
1283 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
1287 diff = bin - pad[ipos2++];
1288 } while ((diff > 0) && (ipos2 < kPRFbin));
1289 if (ipos2 == kPRFbin) {
1290 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1292 else if (ipos2 == 1) {
1293 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1297 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1299 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
1300 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
1309 //_____________________________________________________________________________
1310 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
1311 , Int_t layer, Double_t *pad) const
1314 // Applies the pad response
1315 // So far this is the fixed parametrization and should be replaced by
1316 // something dependent on calibration values
1319 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
1320 Int_t iOff = layer * fPRFbin;
1322 Int_t iBin0 = iBin - fPRFpad + iOff;
1323 Int_t iBin1 = iBin + iOff;
1324 Int_t iBin2 = iBin + fPRFpad + iOff;
1329 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
1332 pad[0] = signal * fPRFsmp[iBin0];
1334 pad[1] = signal * fPRFsmp[iBin1];
1335 if (iBin2 < (fPRFbin*kNlayer)) {
1336 pad[2] = signal * fPRFsmp[iBin2];