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 "AliTRDPIDReference.h"
39 #include "AliTRDcalibDB.h"
41 #include "Cal/AliTRDCalROC.h"
42 #include "Cal/AliTRDCalPad.h"
43 #include "Cal/AliTRDCalDet.h"
44 #include "Cal/AliTRDCalDCS.h"
45 #include "Cal/AliTRDCalDCSv2.h"
46 #include "Cal/AliTRDCalPID.h"
47 #include "Cal/AliTRDCalMonitoring.h"
48 #include "Cal/AliTRDCalChamberStatus.h"
49 #include "Cal/AliTRDCalPadStatus.h"
50 #include "Cal/AliTRDCalSingleChamberStatus.h"
51 #include "Cal/AliTRDCalTrkAttach.h"
53 ClassImp(AliTRDcalibDB)
55 AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0;
56 Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
58 //_ singleton implementation __________________________________________________
59 AliTRDcalibDB* AliTRDcalibDB::Instance()
62 // Singleton implementation
63 // Returns an instance of this class, it is created if neccessary
66 if (fgTerminated != kFALSE) {
70 if (fgInstance == 0) {
71 fgInstance = new AliTRDcalibDB();
78 //_____________________________________________________________________________
79 void AliTRDcalibDB::Terminate()
82 // Singleton implementation
83 // Deletes the instance of this class and sets the terminated flag,
84 // instances cannot be requested anymore
85 // This function can be called several times.
90 if (fgInstance != 0) {
97 //_____________________________________________________________________________
98 AliTRDcalibDB::AliTRDcalibDB()
110 // Default constructor
112 // TODO Default runnumber is set to 0, this should be changed later
113 // to an invalid value (e.g. -1) to prevent
114 // TODO invalid calibration data to be used.
117 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
122 // Create the sampled PRF
127 //_____________________________________________________________________________
128 AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
140 // Copy constructor (not that it make any sense for a singleton...)
143 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
148 // Create the sampled PRF
153 //_____________________________________________________________________________
154 AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
157 // Assignment operator (same as above ...)
161 AliFatal("No assignment operator defined");
168 //_____________________________________________________________________________
169 AliTRDcalibDB::~AliTRDcalibDB()
179 if(fPIDResponse) delete fPIDResponse;
185 //_caching functions____________________________________________________________
186 const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
189 // Retrieves a cdb object with the given id. The objects are cached as
190 // long as the run number is not changed.
192 // Put together the available objects here by using the lines
193 // a) For usual calibration objects:
195 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
197 // See function CacheCDBEntry for details.
199 // b) For calibration data which depends on two objects: One containing
200 // a value per detector and one the local fluctuations per pad:
202 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
204 // See function CacheMergeCDBEntry for details.
209 // Parameters defined per pad and chamber
211 return CacheCDBEntry(kIDVdriftPad ,"TRD/Calib/LocalVdrift");
213 case kIDVdriftChamber :
214 return CacheCDBEntry(kIDVdriftChamber ,"TRD/Calib/ChamberVdrift");
217 return CacheCDBEntry(kIDT0Pad ,"TRD/Calib/LocalT0");
220 return CacheCDBEntry(kIDT0Chamber ,"TRD/Calib/ChamberT0");
222 case kIDGainFactorPad :
223 return CacheCDBEntry(kIDGainFactorPad ,"TRD/Calib/LocalGainFactor");
225 case kIDGainFactorChamber :
226 return CacheCDBEntry(kIDGainFactorChamber ,"TRD/Calib/ChamberGainFactor");
228 case kIDNoiseChamber :
229 return CacheCDBEntry(kIDNoiseChamber ,"TRD/Calib/DetNoise");
232 return CacheCDBEntry(kIDNoisePad ,"TRD/Calib/PadNoise");
236 // Parameters defined per pad
238 return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth");
242 case kIDChamberStatus :
243 return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus");
246 return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus");
250 case kIDMonitoringData :
251 return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData");
254 return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE");
257 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS");
260 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
262 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
265 return CacheCDBEntry(kIDPIDLQ1D ,"TRD/Calib/PIDLQ1D");
268 return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam");
271 return CacheCDBEntry(kIDAttach ,"TRD/Calib/TrkAttach");
279 //_____________________________________________________________________________
280 AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
283 // Retrieves an entry with path <cdbPath> from the CDB.
286 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
288 AliError(Form("Failed to get entry: %s",cdbPath));
296 //_____________________________________________________________________________
297 const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
300 // Caches the entry <id> with cdb path <cdbPath>
303 if (!fCDBCache[id]) {
304 fCDBEntries[id] = GetCDBEntry(cdbPath);
305 if (fCDBEntries[id]) {
306 fCDBCache[id] = fCDBEntries[id]->GetObject();
310 return fCDBCache[id];
313 //_____________________________________________________________________________
314 void AliTRDcalibDB::SetRun(Long64_t run)
317 // Sets current run number. Calibration data is read from the corresponding file.
318 // When the run number changes the caching is invalidated.
331 //_____________________________________________________________________________
332 void AliTRDcalibDB::Invalidate()
335 // Invalidates cache (when run number is changed).
338 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
339 if (fCDBEntries[i]) {
340 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
341 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
345 delete fCDBEntries[i];
353 //_____________________________________________________________________________
354 Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row)
357 // Returns the noise level in ADC counts for the given pad.
360 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
361 (GetCachedCDBObject(kIDNoisePad));
366 AliTRDCalROC *roc = calPad->GetCalROC(det);
371 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
372 (GetCachedCDBObject(kIDNoiseChamber));
377 return calChamber->GetValue(det) * roc->GetValue(col,row);
381 //_____________________________________________________________________________
382 AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det)
385 // Returns the Vdrift calibration object for a given ROC
386 // containing one number per pad
389 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
390 (GetCachedCDBObject(kIDNoisePad));
395 AliTRDCalROC *roc = calPad->GetCalROC(det);
405 //_____________________________________________________________________________
406 const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet()
409 // Returns the Vdrift calibration object
410 // containing one number per detector
413 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
414 (GetCachedCDBObject(kIDNoiseChamber));
424 //_____________________________________________________________________________
425 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
428 // Returns the drift velocity for the given pad.
431 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
432 (GetCachedCDBObject(kIDVdriftPad));
437 AliTRDCalROC *roc = calPad->GetCalROC(det);
442 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
443 (GetCachedCDBObject(kIDVdriftChamber));
448 return calChamber->GetValue(det) * roc->GetValue(col,row);
452 //_____________________________________________________________________________
453 AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
456 // Returns the Vdrift calibration object for a given ROC
457 // containing one number per pad
460 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
461 (GetCachedCDBObject(kIDVdriftPad));
466 AliTRDCalROC *roc = calPad->GetCalROC(det);
476 //_____________________________________________________________________________
477 const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
480 // Returns the Vdrift calibration object
481 // containing one number per detector
484 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
485 (GetCachedCDBObject(kIDVdriftChamber));
495 //_____________________________________________________________________________
496 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
499 // Returns the average drift velocity for the given detector
502 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
503 (GetCachedCDBObject(kIDVdriftChamber));
508 return calDet->GetValue(det);
512 //_____________________________________________________________________________
513 Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
516 // Returns t0 for the given pad.
519 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
520 (GetCachedCDBObject(kIDT0Pad));
525 AliTRDCalROC *roc = calPad->GetCalROC(det);
530 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
531 (GetCachedCDBObject(kIDT0Chamber));
536 return calChamber->GetValue(det) + roc->GetValue(col,row);
540 //_____________________________________________________________________________
541 AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
544 // Returns the t0 calibration object for a given ROC
545 // containing one number per pad
548 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
549 (GetCachedCDBObject(kIDT0Pad));
554 AliTRDCalROC *roc = calPad->GetCalROC(det);
564 //_____________________________________________________________________________
565 const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
568 // Returns the t0 calibration object
569 // containing one number per detector
572 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
573 (GetCachedCDBObject(kIDT0Chamber));
583 //_____________________________________________________________________________
584 Float_t AliTRDcalibDB::GetT0Average(Int_t det)
587 // Returns the average t0 for the given detector
590 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
591 (GetCachedCDBObject(kIDT0Pad));
596 AliTRDCalROC *roc = calPad->GetCalROC(det);
601 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
602 (GetCachedCDBObject(kIDT0Chamber));
608 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
609 sum += roc->GetValue(channel);
611 sum /= roc->GetNchannels();
612 sum += calDet->GetValue(det);
617 //_____________________________________________________________________________
618 Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
621 // Returns the gain factor for the given pad.
624 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
625 (GetCachedCDBObject(kIDGainFactorPad));
630 AliTRDCalROC *roc = calPad->GetCalROC(det);
635 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
636 (GetCachedCDBObject(kIDGainFactorChamber));
641 return calChamber->GetValue(det) * roc->GetValue(col,row);
645 //_____________________________________________________________________________
646 AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
649 // Returns the gain factor calibration object for a given ROC
652 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
653 (GetCachedCDBObject(kIDGainFactorPad));
658 AliTRDCalROC *roc = calPad->GetCalROC(det);
668 //_____________________________________________________________________________
669 const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
672 // Returns the gain factor calibration object
673 // containing one number per detector
676 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
677 (GetCachedCDBObject(kIDGainFactorChamber));
687 //_____________________________________________________________________________
688 Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
691 // Returns the average gain factor for the given detector
694 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
695 (GetCachedCDBObject(kIDGainFactorChamber));
700 return calDet->GetValue(det);
704 //_____________________________________________________________________________
705 AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
708 // Returns the PRF calibration object for a given ROC
709 // containing one number per pad
712 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
713 (GetCachedCDBObject(kIDPRFWidth));
718 AliTRDCalROC *roc = calPad->GetCalROC(det);
728 //_____________________________________________________________________________
729 Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
732 // Returns the PRF width for the given pad.
735 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
736 (GetCachedCDBObject(kIDPRFWidth));
741 AliTRDCalROC *roc = calPad->GetCalROC(det);
746 return roc->GetValue(col,row);
750 //_____________________________________________________________________________
751 Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS()
754 // Returns Number of time bins from the DCS
757 Int_t nMixed = -2; // not the same number for all chambers
758 Int_t nUndef = -1; // default value - has not been set!
759 Int_t nTbSor = nUndef;
760 Int_t nTbEor = nUndef;
761 Int_t calver = 0; // Check CalDCS version
763 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
765 AliError("No DCS object found!");
769 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
770 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
774 const AliTRDCalDCS *calDCSsor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(0));
775 const AliTRDCalDCS *calDCSeor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(1));
777 // the SOR file is mandatory
778 AliError("NO SOR AliTRDCalDCS object found in CDB file!");
782 // this can happen if the run is shorter than a couple of seconds.
783 AliWarning("NO EOR AliTRDCalDCS object found in CDB file.");
787 nTbSor = calDCSsor->GetGlobalNumberOfTimeBins();
788 if (calDCSeor) nTbEor = calDCSeor->GetGlobalNumberOfTimeBins();
790 } else if (calver == 2) {
792 const AliTRDCalDCSv2 *calDCSsorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(0));
793 const AliTRDCalDCSv2 *calDCSeorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(1));
795 // the SOR file is mandatory
796 AliError("NO SOR AliTRDCalDCSv2 object found in CDB file!");
800 // this can happen if the run is shorter than a couple of seconds.
801 AliWarning("NO EOR AliTRDCalDCSv2 object found in CDB file.");
805 nTbSor = calDCSsorv2->GetGlobalNumberOfTimeBins();
806 if (calDCSeorv2) nTbEor = calDCSeorv2->GetGlobalNumberOfTimeBins();
808 } else AliError("NO DCS/DCSv2 OCDB entry found!");
810 // if they're the same return the value
811 // -2 means mixed, -1: no data, >= 0: good number of time bins
812 if (nTbSor == nTbEor) return nTbSor;
814 // if they're differing:
815 if (nTbSor == nMixed || nTbEor == nMixed) {
816 AliWarning("Inconsistent number of time bins found!");
820 // one is undefined, the other ok -> return that one
821 if (nTbSor == nUndef) return nTbEor;
822 if (nTbEor == nUndef) return nTbSor;
824 // only remains: two different numbers >= 0
828 //_____________________________________________________________________________
829 void AliTRDcalibDB::GetFilterType(TString &filterType)
832 // Returns the filter type
835 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
841 Int_t esor = 0; // Take SOR
842 Int_t calver = 0; // Check CalDCS version
843 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
844 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
848 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
853 filterType = calDCS->GetGlobalFilterType();
854 } else if (calver == 2) {
856 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
861 filterType = calDCSv2->GetGlobalFilterType();
862 } else AliError("NO DCS/DCSv2 OCDB entry found!");
866 //_____________________________________________________________________________
867 void AliTRDcalibDB::GetGlobalConfiguration(TString &config){
869 // Get Configuration from the DCS
872 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
878 Int_t esor = 0; // Take SOR
879 Int_t calver = 0; // Check CalDCS version
880 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
881 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
885 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
890 config = calDCS->GetGlobalConfigName();
891 } else if (calver == 2) {
893 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
898 config = calDCSv2->GetGlobalConfigName();
899 } else AliError("NO DCS/DCSv2 OCDB entry found!");
903 //_____________________________________________________________________________
904 Bool_t AliTRDcalibDB::HasOnlineFilterPedestal()
907 // Checks whether pedestal filter was applied online
910 // Temporary: Get the filter config from the configuration name
911 GetGlobalConfiguration(cname);
912 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
913 // TString filterconfig;
914 //GetFilterType(filterconfig);
915 return filterconfig.Contains("p");
918 //_____________________________________________________________________________
919 Bool_t AliTRDcalibDB::HasOnlineFilterGain(){
921 // Checks whether online gain filter was applied
924 // Temporary: Get the filter config from the configuration name
925 GetGlobalConfiguration(cname);
926 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
927 //TString filterconfig;
928 //GetFilterType(filterconfig);
929 return filterconfig.Contains("g");
932 //_____________________________________________________________________________
933 Bool_t AliTRDcalibDB::HasOnlineTailCancellation(){
935 // Checks whether online tail cancellation was applied
938 // Temporary: Get the filter config from the configuration name
939 GetGlobalConfiguration(cname);
940 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
941 //TString filterconfig;
942 //GetFilterType(filterconfig);
943 return filterconfig.Contains("t");
946 //_____________________________________________________________________________
947 Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
950 // Returns the status of the given pad
953 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
954 (GetCachedCDBObject(kIDPadStatus));
959 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
964 return roc->GetStatus(col,row);
968 //_____________________________________________________________________________
969 AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
972 // Returns the pad status calibration object for a given ROC
975 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
976 (GetCachedCDBObject(kIDPadStatus));
981 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
991 //_____________________________________________________________________________
992 Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
995 // Returns the status of the given chamber
998 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
999 (GetCachedCDBObject(kIDChamberStatus));
1004 return cal->GetStatus(det);
1008 //_____________________________________________________________________________
1009 AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
1012 // Returns the TRD reconstruction parameters from the OCDB
1015 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
1016 if (!recos) return 0x0;
1018 // calculate entry based on event type info
1019 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
1021 return (AliTRDrecoParam*)recos->UncheckedAt(n);
1025 //_____________________________________________________________________________
1026 Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
1029 // Returns status, see name of functions for details ;-)
1032 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1033 (GetCachedCDBObject(kIDPadStatus));
1038 return cal->IsMasked(det,col,row);
1042 //_____________________________________________________________________________
1043 Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
1046 // Returns status, see name of functions for details ;-)
1049 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1050 (GetCachedCDBObject(kIDPadStatus));
1055 return cal->IsBridgedLeft(det,col,row);
1059 //_____________________________________________________________________________
1060 Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
1063 // Returns status, see name of functions for details ;-)
1066 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1067 (GetCachedCDBObject(kIDPadStatus));
1072 return cal->IsBridgedRight(det,col,row);
1076 //_____________________________________________________________________________
1077 Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
1080 // Returns status, see name of functions for details ;-)
1083 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1084 (GetCachedCDBObject(kIDPadStatus));
1089 return cal->IsNotConnected(det,col,row);
1093 //_____________________________________________________________________________
1094 Bool_t AliTRDcalibDB::IsChamberInstalled(Int_t det)
1097 // Returns status, see name of functions for details ;-)
1100 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1101 (GetCachedCDBObject(kIDChamberStatus));
1106 return cal->IsInstalled(det);
1110 //_____________________________________________________________________________
1111 Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
1114 // Returns status, see name of functions for details ;-)
1117 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1118 (GetCachedCDBObject(kIDChamberStatus));
1123 return cal->IsMasked(det);
1126 //_____________________________________________________________________________
1127 Bool_t AliTRDcalibDB::IsHalfChamberMasked(Int_t det, Int_t side){
1129 // Returns status, see name of functions for details ;-)
1132 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1133 (GetCachedCDBObject(kIDChamberStatus));
1138 return side > 0 ? cal->IsHalfChamberSideBMasked(det) : cal->IsHalfChamberSideAMasked(det);
1141 //_____________________________________________________________________________
1142 const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
1145 // Returns the object storing the distributions for PID with likelihood
1149 case AliTRDpidUtil::kLQ:
1150 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
1151 case AliTRDpidUtil::kNN:
1152 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
1153 case AliTRDpidUtil::kESD:
1154 return 0x0; // To avoid compiler warnings
1161 //_____________________________________________________________________________
1162 AliTRDPIDResponse *AliTRDcalibDB::GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod method){
1164 fPIDResponse = new AliTRDPIDResponse;
1165 // Load Reference Histos from OCDB
1166 fPIDResponse->SetPIDmethod(method);
1167 const TObjArray *references = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDPIDLQ1D));
1168 TIter refs(references);
1169 TObject *obj = NULL;
1170 AliTRDPIDReference *ref = NULL;
1171 Bool_t hasReference = kFALSE;
1172 while((obj = refs())){
1173 if((ref = dynamic_cast<AliTRDPIDReference *>(obj))){
1174 fPIDResponse->Load(ref);
1175 hasReference = kTRUE;
1179 if(!hasReference) AliError("Reference histograms not found in the OCDB");
1181 return fPIDResponse;
1184 //_____________________________________________________________________________
1185 const AliTRDCalTrkAttach* AliTRDcalibDB::GetAttachObject()
1188 // Returns the object storing likelihood distributions for cluster to track attachment
1190 return dynamic_cast<const AliTRDCalTrkAttach*>(GetCachedCDBObject(kIDAttach));
1194 //_____________________________________________________________________________
1195 const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
1198 // Returns the object storing the monitoring data
1201 return dynamic_cast<const AliTRDCalMonitoring *>
1202 (GetCachedCDBObject(kIDMonitoringData));
1206 //_____________________________________________________________________________
1207 void AliTRDcalibDB::SamplePRF()
1210 // Samples the pad response function (should maybe go somewhere else ...)
1213 const Int_t kPRFbin = 61;
1215 Float_t prf[kNlayer][kPRFbin] = {
1216 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
1217 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1218 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1219 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1220 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1221 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1222 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1223 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1224 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1225 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1226 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1227 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1228 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1229 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1230 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1232 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1233 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1234 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1235 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1236 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1237 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1238 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1239 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1240 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1241 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1242 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1243 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1244 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1245 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1246 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1248 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1249 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1250 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1251 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1252 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1253 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1254 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1255 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1256 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1257 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1258 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1259 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1260 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1261 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1262 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1264 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1265 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1266 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1267 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1268 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1269 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1270 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1271 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1272 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1273 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1274 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1275 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1276 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1277 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1278 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1280 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1281 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1282 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1283 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1284 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1285 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1286 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1287 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1288 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1289 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1290 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1291 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1292 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1293 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1294 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1296 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1297 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1298 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1299 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1300 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1301 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1302 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1303 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1304 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1305 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1306 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1307 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1308 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1309 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1310 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1313 // More sampling precision with linear interpolation
1316 Float_t pad[kPRFbin];
1317 Int_t sPRFbin = kPRFbin;
1318 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
1319 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
1320 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
1323 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1324 fPRFpad = ((Int_t) (1.0 / fPRFwid));
1326 if (fPRFsmp) delete [] fPRFsmp;
1327 fPRFsmp = new Float_t[kNlayer*fPRFbin];
1333 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
1335 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
1337 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
1341 diff = bin - pad[ipos2++];
1342 } while ((diff > 0) && (ipos2 < kPRFbin));
1343 if (ipos2 == kPRFbin) {
1344 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1346 else if (ipos2 == 1) {
1347 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1351 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1353 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
1354 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
1363 //_____________________________________________________________________________
1364 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
1365 , Int_t layer, Double_t *pad) const
1368 // Applies the pad response
1369 // So far this is the fixed parametrization and should be replaced by
1370 // something dependent on calibration values
1373 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
1374 Int_t iOff = layer * fPRFbin;
1376 Int_t iBin0 = iBin - fPRFpad + iOff;
1377 Int_t iBin1 = iBin + iOff;
1378 Int_t iBin2 = iBin + fPRFpad + iOff;
1383 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
1386 pad[0] = signal * fPRFsmp[iBin0];
1388 pad[1] = signal * fPRFsmp[iBin1];
1389 if (iBin2 < (fPRFbin*kNlayer)) {
1390 pad[2] = signal * fPRFsmp[iBin2];