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"
50 #include "Cal/AliTRDCalTrkAttach.h"
52 ClassImp(AliTRDcalibDB)
54 AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0;
55 Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
57 //_ singleton implementation __________________________________________________
58 AliTRDcalibDB* AliTRDcalibDB::Instance()
61 // Singleton implementation
62 // Returns an instance of this class, it is created if neccessary
65 if (fgTerminated != kFALSE) {
69 if (fgInstance == 0) {
70 fgInstance = new AliTRDcalibDB();
77 //_____________________________________________________________________________
78 void AliTRDcalibDB::Terminate()
81 // Singleton implementation
82 // Deletes the instance of this class and sets the terminated flag,
83 // instances cannot be requested anymore
84 // This function can be called several times.
89 if (fgInstance != 0) {
96 //_____________________________________________________________________________
97 AliTRDcalibDB::AliTRDcalibDB()
109 // Default constructor
111 // TODO Default runnumber is set to 0, this should be changed later
112 // to an invalid value (e.g. -1) to prevent
113 // TODO invalid calibration data to be used.
116 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
121 // Create the sampled PRF
126 //_____________________________________________________________________________
127 AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
139 // Copy constructor (not that it make any sense for a singleton...)
142 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
147 // Create the sampled PRF
152 //_____________________________________________________________________________
153 AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
156 // Assignment operator (same as above ...)
160 AliFatal("No assignment operator defined");
167 //_____________________________________________________________________________
168 AliTRDcalibDB::~AliTRDcalibDB()
178 if(fPIDResponse) delete fPIDResponse;
184 //_caching functions____________________________________________________________
185 const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
188 // Retrieves a cdb object with the given id. The objects are cached as
189 // long as the run number is not changed.
191 // Put together the available objects here by using the lines
192 // a) For usual calibration objects:
194 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
196 // See function CacheCDBEntry for details.
198 // b) For calibration data which depends on two objects: One containing
199 // a value per detector and one the local fluctuations per pad:
201 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
203 // See function CacheMergeCDBEntry for details.
208 // Parameters defined per pad and chamber
210 return CacheCDBEntry(kIDVdriftPad ,"TRD/Calib/LocalVdrift");
212 case kIDVdriftChamber :
213 return CacheCDBEntry(kIDVdriftChamber ,"TRD/Calib/ChamberVdrift");
216 return CacheCDBEntry(kIDT0Pad ,"TRD/Calib/LocalT0");
219 return CacheCDBEntry(kIDT0Chamber ,"TRD/Calib/ChamberT0");
221 case kIDGainFactorPad :
222 return CacheCDBEntry(kIDGainFactorPad ,"TRD/Calib/LocalGainFactor");
224 case kIDGainFactorChamber :
225 return CacheCDBEntry(kIDGainFactorChamber ,"TRD/Calib/ChamberGainFactor");
227 case kIDNoiseChamber :
228 return CacheCDBEntry(kIDNoiseChamber ,"TRD/Calib/DetNoise");
231 return CacheCDBEntry(kIDNoisePad ,"TRD/Calib/PadNoise");
235 // Parameters defined per pad
237 return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth");
241 case kIDChamberStatus :
242 return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus");
245 return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus");
249 case kIDMonitoringData :
250 return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData");
253 return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE");
256 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS");
259 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
261 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
264 return CacheCDBEntry(kIDPIDLQ1D ,"TRD/Calib/PIDLQ1D");
267 return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam");
270 return CacheCDBEntry(kIDAttach ,"TRD/Calib/TrkAttach");
278 //_____________________________________________________________________________
279 AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
282 // Retrieves an entry with path <cdbPath> from the CDB.
285 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
287 AliError(Form("Failed to get entry: %s",cdbPath));
295 //_____________________________________________________________________________
296 const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
299 // Caches the entry <id> with cdb path <cdbPath>
302 if (!fCDBCache[id]) {
303 fCDBEntries[id] = GetCDBEntry(cdbPath);
304 if (fCDBEntries[id]) {
305 fCDBCache[id] = fCDBEntries[id]->GetObject();
309 return fCDBCache[id];
312 //_____________________________________________________________________________
313 void AliTRDcalibDB::SetRun(Long64_t run)
316 // Sets current run number. Calibration data is read from the corresponding file.
317 // When the run number changes the caching is invalidated.
330 //_____________________________________________________________________________
331 void AliTRDcalibDB::Invalidate()
334 // Invalidates cache (when run number is changed).
337 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
338 if (fCDBEntries[i]) {
339 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
340 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
344 delete fCDBEntries[i];
352 //_____________________________________________________________________________
353 Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row)
356 // Returns the noise level in ADC counts for the given pad.
359 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
360 (GetCachedCDBObject(kIDNoisePad));
365 AliTRDCalROC *roc = calPad->GetCalROC(det);
370 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
371 (GetCachedCDBObject(kIDNoiseChamber));
376 return calChamber->GetValue(det) * roc->GetValue(col,row);
380 //_____________________________________________________________________________
381 AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det)
384 // Returns the Vdrift calibration object for a given ROC
385 // containing one number per pad
388 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
389 (GetCachedCDBObject(kIDNoisePad));
394 AliTRDCalROC *roc = calPad->GetCalROC(det);
404 //_____________________________________________________________________________
405 const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet()
408 // Returns the Vdrift calibration object
409 // containing one number per detector
412 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
413 (GetCachedCDBObject(kIDNoiseChamber));
423 //_____________________________________________________________________________
424 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
427 // Returns the drift velocity for the given pad.
430 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
431 (GetCachedCDBObject(kIDVdriftPad));
436 AliTRDCalROC *roc = calPad->GetCalROC(det);
441 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
442 (GetCachedCDBObject(kIDVdriftChamber));
447 return calChamber->GetValue(det) * roc->GetValue(col,row);
451 //_____________________________________________________________________________
452 AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
455 // Returns the Vdrift calibration object for a given ROC
456 // containing one number per pad
459 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
460 (GetCachedCDBObject(kIDVdriftPad));
465 AliTRDCalROC *roc = calPad->GetCalROC(det);
475 //_____________________________________________________________________________
476 const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
479 // Returns the Vdrift calibration object
480 // containing one number per detector
483 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
484 (GetCachedCDBObject(kIDVdriftChamber));
494 //_____________________________________________________________________________
495 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
498 // Returns the average drift velocity for the given detector
501 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
502 (GetCachedCDBObject(kIDVdriftChamber));
507 return calDet->GetValue(det);
511 //_____________________________________________________________________________
512 Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
515 // Returns t0 for the given pad.
518 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
519 (GetCachedCDBObject(kIDT0Pad));
524 AliTRDCalROC *roc = calPad->GetCalROC(det);
529 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
530 (GetCachedCDBObject(kIDT0Chamber));
535 return calChamber->GetValue(det) + roc->GetValue(col,row);
539 //_____________________________________________________________________________
540 AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
543 // Returns the t0 calibration object for a given ROC
544 // containing one number per pad
547 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
548 (GetCachedCDBObject(kIDT0Pad));
553 AliTRDCalROC *roc = calPad->GetCalROC(det);
563 //_____________________________________________________________________________
564 const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
567 // Returns the t0 calibration object
568 // containing one number per detector
571 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
572 (GetCachedCDBObject(kIDT0Chamber));
582 //_____________________________________________________________________________
583 Float_t AliTRDcalibDB::GetT0Average(Int_t det)
586 // Returns the average t0 for the given detector
589 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
590 (GetCachedCDBObject(kIDT0Pad));
595 AliTRDCalROC *roc = calPad->GetCalROC(det);
600 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
601 (GetCachedCDBObject(kIDT0Chamber));
607 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
608 sum += roc->GetValue(channel);
610 sum /= roc->GetNchannels();
611 sum += calDet->GetValue(det);
616 //_____________________________________________________________________________
617 Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
620 // Returns the gain factor for the given pad.
623 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
624 (GetCachedCDBObject(kIDGainFactorPad));
629 AliTRDCalROC *roc = calPad->GetCalROC(det);
634 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
635 (GetCachedCDBObject(kIDGainFactorChamber));
640 return calChamber->GetValue(det) * roc->GetValue(col,row);
644 //_____________________________________________________________________________
645 AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
648 // Returns the gain factor calibration object for a given ROC
651 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
652 (GetCachedCDBObject(kIDGainFactorPad));
657 AliTRDCalROC *roc = calPad->GetCalROC(det);
667 //_____________________________________________________________________________
668 const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
671 // Returns the gain factor calibration object
672 // containing one number per detector
675 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
676 (GetCachedCDBObject(kIDGainFactorChamber));
686 //_____________________________________________________________________________
687 Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
690 // Returns the average gain factor for the given detector
693 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
694 (GetCachedCDBObject(kIDGainFactorChamber));
699 return calDet->GetValue(det);
703 //_____________________________________________________________________________
704 AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
707 // Returns the PRF calibration object for a given ROC
708 // containing one number per pad
711 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
712 (GetCachedCDBObject(kIDPRFWidth));
717 AliTRDCalROC *roc = calPad->GetCalROC(det);
727 //_____________________________________________________________________________
728 Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
731 // Returns the PRF width for the given pad.
734 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
735 (GetCachedCDBObject(kIDPRFWidth));
740 AliTRDCalROC *roc = calPad->GetCalROC(det);
745 return roc->GetValue(col,row);
749 //_____________________________________________________________________________
750 Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS()
753 // Returns Number of time bins from the DCS
756 Int_t nMixed = -2; // not the same number for all chambers
757 Int_t nUndef = -1; // default value - has not been set!
758 Int_t nTbSor = nUndef;
759 Int_t nTbEor = nUndef;
760 Int_t calver = 0; // Check CalDCS version
762 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
764 AliError("No DCS object found!");
768 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
769 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
773 const AliTRDCalDCS *calDCSsor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(0));
774 const AliTRDCalDCS *calDCSeor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(1));
776 // the SOR file is mandatory
777 AliError("NO SOR AliTRDCalDCS object found in CDB file!");
781 // this can happen if the run is shorter than a couple of seconds.
782 AliWarning("NO EOR AliTRDCalDCS object found in CDB file.");
786 nTbSor = calDCSsor->GetGlobalNumberOfTimeBins();
787 if (calDCSeor) nTbEor = calDCSeor->GetGlobalNumberOfTimeBins();
789 } else if (calver == 2) {
791 const AliTRDCalDCSv2 *calDCSsorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(0));
792 const AliTRDCalDCSv2 *calDCSeorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(1));
794 // the SOR file is mandatory
795 AliError("NO SOR AliTRDCalDCSv2 object found in CDB file!");
799 // this can happen if the run is shorter than a couple of seconds.
800 AliWarning("NO EOR AliTRDCalDCSv2 object found in CDB file.");
804 nTbSor = calDCSsorv2->GetGlobalNumberOfTimeBins();
805 if (calDCSeorv2) nTbEor = calDCSeorv2->GetGlobalNumberOfTimeBins();
807 } else AliError("NO DCS/DCSv2 OCDB entry found!");
809 // if they're the same return the value
810 // -2 means mixed, -1: no data, >= 0: good number of time bins
811 if (nTbSor == nTbEor) return nTbSor;
813 // if they're differing:
814 if (nTbSor == nMixed || nTbEor == nMixed) {
815 AliWarning("Inconsistent number of time bins found!");
819 // one is undefined, the other ok -> return that one
820 if (nTbSor == nUndef) return nTbEor;
821 if (nTbEor == nUndef) return nTbSor;
823 // only remains: two different numbers >= 0
827 //_____________________________________________________________________________
828 void AliTRDcalibDB::GetFilterType(TString &filterType)
831 // Returns the filter type
834 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
840 Int_t esor = 0; // Take SOR
841 Int_t calver = 0; // Check CalDCS version
842 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
843 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
847 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
852 filterType = calDCS->GetGlobalFilterType();
853 } else if (calver == 2) {
855 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
860 filterType = calDCSv2->GetGlobalFilterType();
861 } else AliError("NO DCS/DCSv2 OCDB entry found!");
865 //_____________________________________________________________________________
866 void AliTRDcalibDB::GetGlobalConfiguration(TString &config){
868 // Get Configuration from the DCS
871 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
877 Int_t esor = 0; // Take SOR
878 Int_t calver = 0; // Check CalDCS version
879 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
880 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
884 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
889 config = calDCS->GetGlobalConfigName();
890 } else if (calver == 2) {
892 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
897 config = calDCSv2->GetGlobalConfigName();
898 } else AliError("NO DCS/DCSv2 OCDB entry found!");
902 //_____________________________________________________________________________
903 Bool_t AliTRDcalibDB::HasOnlineFilterPedestal()
906 // Checks whether pedestal filter was applied online
909 // Temporary: Get the filter config from the configuration name
910 GetGlobalConfiguration(cname);
911 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
912 // TString filterconfig;
913 //GetFilterType(filterconfig);
914 return filterconfig.Contains("p");
917 //_____________________________________________________________________________
918 Bool_t AliTRDcalibDB::HasOnlineFilterGain(){
920 // Checks whether online gain filter was applied
923 // Temporary: Get the filter config from the configuration name
924 GetGlobalConfiguration(cname);
925 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
926 //TString filterconfig;
927 //GetFilterType(filterconfig);
928 return filterconfig.Contains("g");
931 //_____________________________________________________________________________
932 Bool_t AliTRDcalibDB::HasOnlineTailCancellation(){
934 // Checks whether online tail cancellation was applied
937 // Temporary: Get the filter config from the configuration name
938 GetGlobalConfiguration(cname);
939 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
940 //TString filterconfig;
941 //GetFilterType(filterconfig);
942 return filterconfig.Contains("t");
945 //_____________________________________________________________________________
946 Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
949 // Returns the status of the given pad
952 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
953 (GetCachedCDBObject(kIDPadStatus));
958 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
963 return roc->GetStatus(col,row);
967 //_____________________________________________________________________________
968 AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
971 // Returns the pad status calibration object for a given ROC
974 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
975 (GetCachedCDBObject(kIDPadStatus));
980 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
990 //_____________________________________________________________________________
991 Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
994 // Returns the status of the given chamber
997 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
998 (GetCachedCDBObject(kIDChamberStatus));
1003 return cal->GetStatus(det);
1007 //_____________________________________________________________________________
1008 AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
1011 // Returns the TRD reconstruction parameters from the OCDB
1014 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
1015 if (!recos) return 0x0;
1017 // calculate entry based on event type info
1018 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
1020 return (AliTRDrecoParam*)recos->UncheckedAt(n);
1024 //_____________________________________________________________________________
1025 Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
1028 // Returns status, see name of functions for details ;-)
1031 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1032 (GetCachedCDBObject(kIDPadStatus));
1037 return cal->IsMasked(det,col,row);
1041 //_____________________________________________________________________________
1042 Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
1045 // Returns status, see name of functions for details ;-)
1048 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1049 (GetCachedCDBObject(kIDPadStatus));
1054 return cal->IsBridgedLeft(det,col,row);
1058 //_____________________________________________________________________________
1059 Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
1062 // Returns status, see name of functions for details ;-)
1065 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1066 (GetCachedCDBObject(kIDPadStatus));
1071 return cal->IsBridgedRight(det,col,row);
1075 //_____________________________________________________________________________
1076 Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
1079 // Returns status, see name of functions for details ;-)
1082 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1083 (GetCachedCDBObject(kIDPadStatus));
1088 return cal->IsNotConnected(det,col,row);
1092 //_____________________________________________________________________________
1093 Bool_t AliTRDcalibDB::IsChamberInstalled(Int_t det)
1096 // Returns status, see name of functions for details ;-)
1099 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1100 (GetCachedCDBObject(kIDChamberStatus));
1105 return cal->IsInstalled(det);
1109 //_____________________________________________________________________________
1110 Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
1113 // Returns status, see name of functions for details ;-)
1116 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1117 (GetCachedCDBObject(kIDChamberStatus));
1122 return cal->IsMasked(det);
1125 //_____________________________________________________________________________
1126 Bool_t AliTRDcalibDB::IsHalfChamberMasked(Int_t det, Int_t side){
1128 // Returns status, see name of functions for details ;-)
1131 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1132 (GetCachedCDBObject(kIDChamberStatus));
1137 return side > 0 ? cal->IsHalfChamberSideBMasked(det) : cal->IsHalfChamberSideAMasked(det);
1140 //_____________________________________________________________________________
1141 const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
1144 // Returns the object storing the distributions for PID with likelihood
1148 case AliTRDpidUtil::kLQ:
1149 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
1150 case AliTRDpidUtil::kNN:
1151 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
1152 case AliTRDpidUtil::kESD:
1153 return 0x0; // To avoid compiler warnings
1160 //_____________________________________________________________________________
1161 AliTRDPIDResponse *AliTRDcalibDB::GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod method){
1163 fPIDResponse = new AliTRDPIDResponse;
1164 // Load Reference Histos from OCDB
1165 fPIDResponse->SetPIDmethod(method);
1166 fPIDResponse->Load(dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDPIDLQ1D)));
1168 return fPIDResponse;
1171 //_____________________________________________________________________________
1172 const AliTRDCalTrkAttach* AliTRDcalibDB::GetAttachObject()
1175 // Returns the object storing likelihood distributions for cluster to track attachment
1177 return dynamic_cast<const AliTRDCalTrkAttach*>(GetCachedCDBObject(kIDAttach));
1181 //_____________________________________________________________________________
1182 const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
1185 // Returns the object storing the monitoring data
1188 return dynamic_cast<const AliTRDCalMonitoring *>
1189 (GetCachedCDBObject(kIDMonitoringData));
1193 //_____________________________________________________________________________
1194 void AliTRDcalibDB::SamplePRF()
1197 // Samples the pad response function (should maybe go somewhere else ...)
1200 const Int_t kPRFbin = 61;
1202 Float_t prf[kNlayer][kPRFbin] = {
1203 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
1204 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1205 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1206 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1207 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1208 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1209 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1210 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1211 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1212 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1213 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1214 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1215 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1216 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1217 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1219 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1220 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1221 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1222 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1223 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1224 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1225 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1226 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1227 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1228 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1229 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1230 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1231 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1232 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1233 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1235 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1236 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1237 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1238 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1239 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1240 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1241 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1242 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1243 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1244 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1245 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1246 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1247 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1248 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1249 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1251 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1252 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1253 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1254 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1255 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1256 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1257 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1258 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1259 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1260 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1261 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1262 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1263 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1264 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1265 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1267 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1268 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1269 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1270 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1271 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1272 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1273 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1274 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1275 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1276 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1277 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1278 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1279 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1280 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1281 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1283 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1284 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1285 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1286 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1287 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1288 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1289 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1290 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1291 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1292 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1293 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1294 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1295 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1296 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1297 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1300 // More sampling precision with linear interpolation
1303 Float_t pad[kPRFbin];
1304 Int_t sPRFbin = kPRFbin;
1305 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
1306 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
1307 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
1310 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1311 fPRFpad = ((Int_t) (1.0 / fPRFwid));
1313 if (fPRFsmp) delete [] fPRFsmp;
1314 fPRFsmp = new Float_t[kNlayer*fPRFbin];
1320 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
1322 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
1324 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
1328 diff = bin - pad[ipos2++];
1329 } while ((diff > 0) && (ipos2 < kPRFbin));
1330 if (ipos2 == kPRFbin) {
1331 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1333 else if (ipos2 == 1) {
1334 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1338 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1340 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
1341 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
1350 //_____________________________________________________________________________
1351 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
1352 , Int_t layer, Double_t *pad) const
1355 // Applies the pad response
1356 // So far this is the fixed parametrization and should be replaced by
1357 // something dependent on calibration values
1360 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
1361 Int_t iOff = layer * fPRFbin;
1363 Int_t iBin0 = iBin - fPRFpad + iOff;
1364 Int_t iBin1 = iBin + iOff;
1365 Int_t iBin2 = iBin + fPRFpad + iOff;
1370 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
1373 pad[0] = signal * fPRFsmp[iBin0];
1375 pad[1] = signal * fPRFsmp[iBin1];
1376 if (iBin2 < (fPRFbin*kNlayer)) {
1377 pad[2] = signal * fPRFsmp[iBin2];