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/AliTRDCalDCSFEEv2.h"
47 #include "Cal/AliTRDCalPID.h"
48 #include "Cal/AliTRDCalMonitoring.h"
49 #include "Cal/AliTRDCalChamberStatus.h"
50 #include "Cal/AliTRDCalPadStatus.h"
51 #include "Cal/AliTRDCalSingleChamberStatus.h"
52 #include "Cal/AliTRDCalTrkAttach.h"
53 #include "Cal/AliTRDCalOnlineGainTable.h"
55 ClassImp(AliTRDcalibDB)
57 AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0;
58 Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
60 //_ singleton implementation __________________________________________________
61 AliTRDcalibDB* AliTRDcalibDB::Instance()
64 // Singleton implementation
65 // Returns an instance of this class, it is created if neccessary
68 if (fgTerminated != kFALSE) {
72 if (fgInstance == 0) {
73 fgInstance = new AliTRDcalibDB();
80 //_____________________________________________________________________________
81 void AliTRDcalibDB::Terminate()
84 // Singleton implementation
85 // Deletes the instance of this class and sets the terminated flag,
86 // instances cannot be requested anymore
87 // This function can be called several times.
92 if (fgInstance != 0) {
99 //_____________________________________________________________________________
100 AliTRDcalibDB::AliTRDcalibDB()
110 ,fOnlineGainTableID(0)
113 // Default constructor
115 // TODO Default runnumber is set to 0, this should be changed later
116 // to an invalid value (e.g. -1) to prevent
117 // TODO invalid calibration data to be used.
120 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
125 // Create the sampled PRF
130 //_____________________________________________________________________________
131 AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
141 ,fOnlineGainTableID(0)
144 // Copy constructor (not that it make any sense for a singleton...)
147 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
152 // Create the sampled PRF
157 //_____________________________________________________________________________
158 AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
161 // Assignment operator (same as above ...)
165 AliFatal("No assignment operator defined");
172 //_____________________________________________________________________________
173 AliTRDcalibDB::~AliTRDcalibDB()
193 //_caching functions____________________________________________________________
194 const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
197 // Retrieves a cdb object with the given id. The objects are cached as
198 // long as the run number is not changed.
200 // Put together the available objects here by using the lines
201 // a) For usual calibration objects:
203 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
205 // See function CacheCDBEntry for details.
207 // b) For calibration data which depends on two objects: One containing
208 // a value per detector and one the local fluctuations per pad:
210 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
212 // See function CacheMergeCDBEntry for details.
217 // Parameters defined per pad and chamber
219 return CacheCDBEntry(kIDVdriftPad ,"TRD/Calib/LocalVdrift");
221 case kIDVdriftChamber :
222 return CacheCDBEntry(kIDVdriftChamber ,"TRD/Calib/ChamberVdrift");
225 return CacheCDBEntry(kIDT0Pad ,"TRD/Calib/LocalT0");
228 return CacheCDBEntry(kIDT0Chamber ,"TRD/Calib/ChamberT0");
230 case kIDGainFactorPad :
231 return CacheCDBEntry(kIDGainFactorPad ,"TRD/Calib/LocalGainFactor");
233 case kIDGainFactorChamber :
234 return CacheCDBEntry(kIDGainFactorChamber ,"TRD/Calib/ChamberGainFactor");
237 case kIDOnlineGainFactor :
238 switch(GetOnlineGainTableID()) {
240 // For testing purposes only !!!
241 AliInfo("No gain table name from OCDB. Use default table!");
242 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01");
245 // Online gain table ID 1
246 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01");
251 case kIDNoiseChamber :
252 return CacheCDBEntry(kIDNoiseChamber ,"TRD/Calib/DetNoise");
255 return CacheCDBEntry(kIDNoisePad ,"TRD/Calib/PadNoise");
258 // Parameters defined per pad
260 return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth");
264 case kIDChamberStatus :
265 return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus");
268 return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus");
272 case kIDMonitoringData :
273 return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData");
276 return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE");
279 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS");
282 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
285 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
288 return CacheCDBEntry(kIDPIDLQ1D ,"TRD/Calib/PIDLQ1D");
291 return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam");
294 return CacheCDBEntry(kIDAttach ,"TRD/Calib/TrkAttach");
302 //_____________________________________________________________________________
303 AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
306 // Retrieves an entry with path <cdbPath> from the CDB.
309 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
311 AliError(Form("Failed to get entry: %s",cdbPath));
319 //_____________________________________________________________________________
320 const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
323 // Caches the entry <id> with cdb path <cdbPath>
326 if (!fCDBCache[id]) {
327 fCDBEntries[id] = GetCDBEntry(cdbPath);
328 if (fCDBEntries[id]) {
329 fCDBCache[id] = fCDBEntries[id]->GetObject();
333 return fCDBCache[id];
337 //_____________________________________________________________________________
338 void AliTRDcalibDB::SetRun(Long64_t run)
341 // Sets current run number. Calibration data is read from the corresponding file.
342 // When the run number changes the caching is invalidated.
355 //_____________________________________________________________________________
356 void AliTRDcalibDB::Invalidate()
359 // Invalidates cache (when run number is changed).
362 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
363 if (fCDBEntries[i]) {
364 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
365 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
369 delete fCDBEntries[i];
376 fOnlineGainTableID = 0;
380 //_____________________________________________________________________________
381 Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row)
384 // Returns the noise level in ADC counts for the given pad.
387 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
388 (GetCachedCDBObject(kIDNoisePad));
393 AliTRDCalROC *roc = calPad->GetCalROC(det);
398 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
399 (GetCachedCDBObject(kIDNoiseChamber));
404 return calChamber->GetValue(det) * roc->GetValue(col,row);
408 //_____________________________________________________________________________
409 AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det)
412 // Returns the Vdrift calibration object for a given ROC
413 // containing one number per pad
416 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
417 (GetCachedCDBObject(kIDNoisePad));
422 AliTRDCalROC *roc = calPad->GetCalROC(det);
432 //_____________________________________________________________________________
433 const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet()
436 // Returns the Vdrift calibration object
437 // containing one number per detector
440 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
441 (GetCachedCDBObject(kIDNoiseChamber));
451 //_____________________________________________________________________________
452 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
455 // Returns the drift velocity for the given pad.
458 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
459 (GetCachedCDBObject(kIDVdriftPad));
464 AliTRDCalROC *roc = calPad->GetCalROC(det);
469 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
470 (GetCachedCDBObject(kIDVdriftChamber));
475 return calChamber->GetValue(det) * roc->GetValue(col,row);
479 //_____________________________________________________________________________
480 AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
483 // Returns the Vdrift calibration object for a given ROC
484 // containing one number per pad
487 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
488 (GetCachedCDBObject(kIDVdriftPad));
493 AliTRDCalROC *roc = calPad->GetCalROC(det);
503 //_____________________________________________________________________________
504 const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
507 // Returns the Vdrift calibration object
508 // containing one number per detector
511 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
512 (GetCachedCDBObject(kIDVdriftChamber));
522 //_____________________________________________________________________________
523 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
526 // Returns the average drift velocity for the given detector
529 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
530 (GetCachedCDBObject(kIDVdriftChamber));
535 return calDet->GetValue(det);
539 //_____________________________________________________________________________
540 Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
543 // Returns t0 for the given pad.
546 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
547 (GetCachedCDBObject(kIDT0Pad));
552 AliTRDCalROC *roc = calPad->GetCalROC(det);
557 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
558 (GetCachedCDBObject(kIDT0Chamber));
563 return calChamber->GetValue(det) + roc->GetValue(col,row);
567 //_____________________________________________________________________________
568 AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
571 // Returns the t0 calibration object for a given ROC
572 // containing one number per pad
575 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
576 (GetCachedCDBObject(kIDT0Pad));
581 AliTRDCalROC *roc = calPad->GetCalROC(det);
591 //_____________________________________________________________________________
592 const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
595 // Returns the t0 calibration object
596 // containing one number per detector
599 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
600 (GetCachedCDBObject(kIDT0Chamber));
610 //_____________________________________________________________________________
611 Float_t AliTRDcalibDB::GetT0Average(Int_t det)
614 // Returns the average t0 for the given detector
617 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
618 (GetCachedCDBObject(kIDT0Pad));
623 AliTRDCalROC *roc = calPad->GetCalROC(det);
628 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
629 (GetCachedCDBObject(kIDT0Chamber));
635 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
636 sum += roc->GetValue(channel);
638 sum /= roc->GetNchannels();
639 sum += calDet->GetValue(det);
644 //_____________________________________________________________________________
645 Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
648 // Returns the gain factor for the given pad.
651 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
652 (GetCachedCDBObject(kIDGainFactorPad));
657 AliTRDCalROC *roc = calPad->GetCalROC(det);
662 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
663 (GetCachedCDBObject(kIDGainFactorChamber));
668 return calChamber->GetValue(det) * roc->GetValue(col,row);
672 //_____________________________________________________________________________
673 AliTRDCalOnlineGainTableROC* AliTRDcalibDB::GetOnlineGainTableROC(Int_t det)
676 // Returns the online gain factor table for a given ROC.
679 const AliTRDCalOnlineGainTable *calOnline
680 = dynamic_cast<const AliTRDCalOnlineGainTable *>
681 (GetCachedCDBObject(kIDOnlineGainFactor));
686 return calOnline->GetGainTableROC(det);
690 //_____________________________________________________________________________
691 Float_t AliTRDcalibDB::GetOnlineGainFactor(Int_t det, Int_t col, Int_t row)
694 // Returns the online gain factor for the given pad.
697 const AliTRDCalOnlineGainTable *calOnline
698 = dynamic_cast<const AliTRDCalOnlineGainTable *>
699 (GetCachedCDBObject(kIDOnlineGainFactor));
704 return calOnline->GetGainCorrectionFactor(det,row,col);
708 //_____________________________________________________________________________
709 AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
712 // Returns the gain factor calibration object for a given ROC
715 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
716 (GetCachedCDBObject(kIDGainFactorPad));
721 AliTRDCalROC *roc = calPad->GetCalROC(det);
731 //_____________________________________________________________________________
732 const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
735 // Returns the gain factor calibration object
736 // containing one number per detector
739 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
740 (GetCachedCDBObject(kIDGainFactorChamber));
750 //_____________________________________________________________________________
751 Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
754 // Returns the average gain factor for the given detector
757 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
758 (GetCachedCDBObject(kIDGainFactorChamber));
763 return calDet->GetValue(det);
767 //_____________________________________________________________________________
768 AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
771 // Returns the PRF calibration object for a given ROC
772 // containing one number per pad
775 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
776 (GetCachedCDBObject(kIDPRFWidth));
781 AliTRDCalROC *roc = calPad->GetCalROC(det);
791 //_____________________________________________________________________________
792 Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
795 // Returns the PRF width for the given pad.
798 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
799 (GetCachedCDBObject(kIDPRFWidth));
804 AliTRDCalROC *roc = calPad->GetCalROC(det);
809 return roc->GetValue(col,row);
813 //_____________________________________________________________________________
814 Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS()
817 // Returns Number of time bins from the DCS
820 Int_t nMixed = -2; // not the same number for all chambers
821 Int_t nUndef = -1; // default value - has not been set!
822 Int_t nTbSor = nUndef;
823 Int_t nTbEor = nUndef;
824 Int_t calver = 0; // Check CalDCS version
826 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
828 AliError("No DCS object found!");
832 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
833 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
837 const AliTRDCalDCS *calDCSsor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(0));
838 const AliTRDCalDCS *calDCSeor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(1));
840 // the SOR file is mandatory
841 AliError("NO SOR AliTRDCalDCS object found in CDB file!");
845 // this can happen if the run is shorter than a couple of seconds.
846 AliWarning("NO EOR AliTRDCalDCS object found in CDB file.");
850 nTbSor = calDCSsor->GetGlobalNumberOfTimeBins();
851 if (calDCSeor) nTbEor = calDCSeor->GetGlobalNumberOfTimeBins();
853 } else if (calver == 2) {
855 const AliTRDCalDCSv2 *calDCSsorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(0));
856 const AliTRDCalDCSv2 *calDCSeorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(1));
858 // the SOR file is mandatory
859 AliError("NO SOR AliTRDCalDCSv2 object found in CDB file!");
863 // this can happen if the run is shorter than a couple of seconds.
864 AliWarning("NO EOR AliTRDCalDCSv2 object found in CDB file.");
868 nTbSor = calDCSsorv2->GetGlobalNumberOfTimeBins();
869 if (calDCSeorv2) nTbEor = calDCSeorv2->GetGlobalNumberOfTimeBins();
871 } else AliError("NO DCS/DCSv2 OCDB entry found!");
873 // if they're the same return the value
874 // -2 means mixed, -1: no data, >= 0: good number of time bins
875 if (nTbSor == nTbEor) return nTbSor;
877 // if they're differing:
878 if (nTbSor == nMixed || nTbEor == nMixed) {
879 AliWarning("Inconsistent number of time bins found!");
883 // one is undefined, the other ok -> return that one
884 if (nTbSor == nUndef) return nTbEor;
885 if (nTbEor == nUndef) return nTbSor;
887 // only remains: two different numbers >= 0
892 //_____________________________________________________________________________
893 void AliTRDcalibDB::GetFilterType(TString &filterType)
896 // Returns the filter type
899 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
905 Int_t esor = 0; // Take SOR
906 Int_t calver = 0; // Check CalDCS version
907 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
908 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
913 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
918 filterType = calDCS->GetGlobalFilterType();
921 else if (calver == 2) {
924 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
929 filterType = calDCSv2->GetGlobalFilterType();
934 AliError("NO DCS/DCSv2 OCDB entry found!");
940 //_____________________________________________________________________________
941 Int_t AliTRDcalibDB::GetOnlineGainTableID()
944 // Get the gain table ID from the DCS
947 if (fOnlineGainTableID > 0) {
948 return fOnlineGainTableID;
951 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
956 Int_t esor = 0; // Take SOR
957 Int_t calver = 0; // Check CalDCS version
958 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
959 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
963 // No data for old DCS object available, anyway
967 else if (calver == 2) {
970 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
975 TString tableName = "";
976 for (Int_t i = 0; i < 540; i++) {
977 const AliTRDCalDCSFEEv2 *calDCSFEEv2 = calDCSv2->GetCalDCSFEEObj(0);
978 tableName = calDCSFEEv2->GetGainTableName();
979 if (tableName.Length() > 0) {
983 if (tableName.CompareTo("Krypton_2011-01") == 0) {
984 fOnlineGainTableID = 1;
985 return fOnlineGainTableID;
991 AliError("NO DCS/DCSv2 OCDB entry found!");
1000 //_____________________________________________________________________________
1001 void AliTRDcalibDB::GetGlobalConfiguration(TString &config)
1004 // Get Configuration from the DCS
1007 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1013 Int_t esor = 0; // Take SOR
1014 Int_t calver = 0; // Check CalDCS version
1015 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1016 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1021 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
1026 config = calDCS->GetGlobalConfigName();
1029 else if (calver == 2) {
1032 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1037 config = calDCSv2->GetGlobalConfigName();
1042 AliError("NO DCS/DCSv2 OCDB entry found!");
1048 //_____________________________________________________________________________
1049 Bool_t AliTRDcalibDB::HasOnlineFilterPedestal()
1052 // Checks whether pedestal filter was applied online
1057 // Temporary: Get the filter config from the configuration name
1058 GetGlobalConfiguration(cname);
1059 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
1061 // TString filterconfig;
1062 //GetFilterType(filterconfig);
1064 return filterconfig.Contains("p");
1068 //_____________________________________________________________________________
1069 Bool_t AliTRDcalibDB::HasOnlineFilterGain()
1072 // Checks whether online gain filter was applied
1077 // Temporary: Get the filter config from the configuration name
1078 GetGlobalConfiguration(cname);
1079 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
1081 //TString filterconfig;
1082 //GetFilterType(filterconfig);
1084 return filterconfig.Contains("g");
1088 //_____________________________________________________________________________
1089 Bool_t AliTRDcalibDB::HasOnlineTailCancellation()
1092 // Checks whether online tail cancellation was applied
1097 // Temporary: Get the filter config from the configuration name
1098 GetGlobalConfiguration(cname);
1099 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
1101 //TString filterconfig;
1102 //GetFilterType(filterconfig);
1104 return filterconfig.Contains("t");
1108 //_____________________________________________________________________________
1109 Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
1112 // Returns the status of the given pad
1115 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1116 (GetCachedCDBObject(kIDPadStatus));
1121 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1126 return roc->GetStatus(col,row);
1130 //_____________________________________________________________________________
1131 AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
1134 // Returns the pad status calibration object for a given ROC
1137 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1138 (GetCachedCDBObject(kIDPadStatus));
1143 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1153 //_____________________________________________________________________________
1154 Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
1157 // Returns the status of the given chamber
1160 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
1161 (GetCachedCDBObject(kIDChamberStatus));
1166 return cal->GetStatus(det);
1170 //_____________________________________________________________________________
1171 AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
1174 // Returns the TRD reconstruction parameters from the OCDB
1177 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
1178 if (!recos) return 0x0;
1180 // calculate entry based on event type info
1181 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
1183 return (AliTRDrecoParam *) recos->UncheckedAt(n);
1187 //_____________________________________________________________________________
1188 Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
1191 // Returns status, see name of functions for details ;-)
1194 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1195 (GetCachedCDBObject(kIDPadStatus));
1200 return cal->IsMasked(det,col,row);
1204 //_____________________________________________________________________________
1205 Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
1208 // Returns status, see name of functions for details ;-)
1211 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1212 (GetCachedCDBObject(kIDPadStatus));
1217 return cal->IsBridgedLeft(det,col,row);
1221 //_____________________________________________________________________________
1222 Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
1225 // Returns status, see name of functions for details ;-)
1228 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1229 (GetCachedCDBObject(kIDPadStatus));
1234 return cal->IsBridgedRight(det,col,row);
1238 //_____________________________________________________________________________
1239 Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
1242 // Returns status, see name of functions for details ;-)
1245 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1246 (GetCachedCDBObject(kIDPadStatus));
1251 return cal->IsNotConnected(det,col,row);
1255 //_____________________________________________________________________________
1256 Bool_t AliTRDcalibDB::IsChamberInstalled(Int_t det)
1259 // Returns status, see name of functions for details ;-)
1262 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1263 (GetCachedCDBObject(kIDChamberStatus));
1268 return cal->IsInstalled(det);
1272 //_____________________________________________________________________________
1273 Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
1276 // Returns status, see name of functions for details ;-)
1279 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1280 (GetCachedCDBObject(kIDChamberStatus));
1285 return cal->IsMasked(det);
1289 //_____________________________________________________________________________
1290 Bool_t AliTRDcalibDB::IsHalfChamberMasked(Int_t det, Int_t side)
1293 // Returns status, see name of functions for details ;-)
1296 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1297 (GetCachedCDBObject(kIDChamberStatus));
1302 return side > 0 ? cal->IsHalfChamberSideBMasked(det) : cal->IsHalfChamberSideAMasked(det);
1306 //_____________________________________________________________________________
1307 const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
1310 // Returns the object storing the distributions for PID with likelihood
1314 case AliTRDpidUtil::kLQ:
1315 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
1316 case AliTRDpidUtil::kNN:
1317 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
1318 case AliTRDpidUtil::kESD:
1319 return 0x0; // To avoid compiler warnings
1326 //_____________________________________________________________________________
1327 AliTRDPIDResponse *AliTRDcalibDB::GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod method)
1330 // Returns the PID response object for 1D-LQ
1333 if (!fPIDResponse) {
1335 fPIDResponse = new AliTRDPIDResponse;
1337 // Load Reference Histos from OCDB
1338 fPIDResponse->SetPIDmethod(method);
1339 const TObjArray *references = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDPIDLQ1D));
1341 TIter refs(references);
1342 TObject *obj = NULL;
1343 AliTRDPIDReference *ref = NULL;
1344 Bool_t hasReference = kFALSE;
1345 while ((obj = refs())){
1346 if ((ref = dynamic_cast<AliTRDPIDReference *>(obj))){
1347 fPIDResponse->Load(ref);
1348 hasReference = kTRUE;
1353 if (!hasReference) {
1354 AliError("Reference histograms not found in the OCDB");
1359 return fPIDResponse;
1363 //_____________________________________________________________________________
1364 const AliTRDCalTrkAttach* AliTRDcalibDB::GetAttachObject()
1367 // Returns the object storing likelihood distributions for cluster to track attachment
1370 return dynamic_cast<const AliTRDCalTrkAttach*>(GetCachedCDBObject(kIDAttach));
1374 //_____________________________________________________________________________
1375 const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
1378 // Returns the object storing the monitoring data
1381 return dynamic_cast<const AliTRDCalMonitoring *>
1382 (GetCachedCDBObject(kIDMonitoringData));
1386 //_____________________________________________________________________________
1387 void AliTRDcalibDB::SamplePRF()
1390 // Samples the pad response function (should maybe go somewhere else ...)
1393 const Int_t kPRFbin = 61;
1395 Float_t prf[kNlayer][kPRFbin] = {
1396 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
1397 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1398 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1399 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1400 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1401 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1402 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1403 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1404 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1405 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1406 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1407 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1408 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1409 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1410 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1412 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1413 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1414 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1415 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1416 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1417 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1418 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1419 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1420 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1421 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1422 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1423 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1424 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1425 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1426 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1428 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1429 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1430 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1431 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1432 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1433 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1434 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1435 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1436 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1437 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1438 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1439 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1440 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1441 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1442 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1444 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1445 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1446 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1447 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1448 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1449 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1450 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1451 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1452 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1453 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1454 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1455 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1456 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1457 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1458 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1460 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1461 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1462 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1463 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1464 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1465 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1466 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1467 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1468 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1469 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1470 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1471 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1472 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1473 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1474 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1476 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1477 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1478 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1479 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1480 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1481 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1482 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1483 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1484 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1485 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1486 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1487 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1488 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1489 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1490 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1493 // More sampling precision with linear interpolation
1496 Float_t pad[kPRFbin];
1497 Int_t sPRFbin = kPRFbin;
1498 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
1499 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
1500 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
1503 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1504 fPRFpad = ((Int_t) (1.0 / fPRFwid));
1506 if (fPRFsmp) delete [] fPRFsmp;
1507 fPRFsmp = new Float_t[kNlayer*fPRFbin];
1513 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
1515 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
1517 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
1521 diff = bin - pad[ipos2++];
1522 } while ((diff > 0) && (ipos2 < kPRFbin));
1523 if (ipos2 == kPRFbin) {
1524 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1526 else if (ipos2 == 1) {
1527 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1531 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1533 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
1534 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
1543 //_____________________________________________________________________________
1544 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
1545 , Int_t layer, Double_t *pad) const
1548 // Applies the pad response
1549 // So far this is the fixed parametrization and should be replaced by
1550 // something dependent on calibration values
1553 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
1554 Int_t iOff = layer * fPRFbin;
1556 Int_t iBin0 = iBin - fPRFpad + iOff;
1557 Int_t iBin1 = iBin + iOff;
1558 Int_t iBin2 = iBin + fPRFpad + iOff;
1563 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
1566 pad[0] = signal * fPRFsmp[iBin0];
1568 pad[1] = signal * fPRFsmp[iBin1];
1569 if (iBin2 < (fPRFbin*kNlayer)) {
1570 pad[2] = signal * fPRFsmp[iBin2];