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"
40 #include "AliTRDCommonParam.h"
42 #include "Cal/AliTRDCalROC.h"
43 #include "Cal/AliTRDCalPad.h"
44 #include "Cal/AliTRDCalDet.h"
45 #include "Cal/AliTRDCalDCS.h"
46 #include "Cal/AliTRDCalDCSv2.h"
47 #include "Cal/AliTRDCalDCSFEEv2.h"
48 #include "Cal/AliTRDCalPID.h"
49 #include "Cal/AliTRDCalMonitoring.h"
50 #include "Cal/AliTRDCalChamberStatus.h"
51 #include "Cal/AliTRDCalPadStatus.h"
52 #include "Cal/AliTRDCalSingleChamberStatus.h"
53 #include "Cal/AliTRDCalTrkAttach.h"
54 #include "Cal/AliTRDCalOnlineGainTable.h"
56 ClassImp(AliTRDcalibDB)
58 AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0;
59 Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
61 //_ singleton implementation __________________________________________________
62 AliTRDcalibDB* AliTRDcalibDB::Instance()
65 // Singleton implementation
66 // Returns an instance of this class, it is created if neccessary
69 if (fgTerminated != kFALSE) {
73 if (fgInstance == 0) {
74 fgInstance = new AliTRDcalibDB();
81 //_____________________________________________________________________________
82 void AliTRDcalibDB::Terminate()
85 // Singleton implementation
86 // Deletes the instance of this class and sets the terminated flag,
87 // instances cannot be requested anymore
88 // This function can be called several times.
93 if (fgInstance != 0) {
100 //_____________________________________________________________________________
101 AliTRDcalibDB::AliTRDcalibDB()
111 ,fOnlineGainTableID(0)
114 // Default constructor
116 // TODO Default runnumber is set to 0, this should be changed later
117 // to an invalid value (e.g. -1) to prevent
118 // TODO invalid calibration data to be used.
121 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
126 // Create the sampled PRF
131 //_____________________________________________________________________________
132 AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
142 ,fOnlineGainTableID(0)
145 // Copy constructor (not that it make any sense for a singleton...)
148 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
153 // Create the sampled PRF
158 //_____________________________________________________________________________
159 AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
162 // Assignment operator (same as above ...)
166 AliFatal("No assignment operator defined");
173 //_____________________________________________________________________________
174 AliTRDcalibDB::~AliTRDcalibDB()
194 //_caching functions____________________________________________________________
195 const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
198 // Retrieves a cdb object with the given id. The objects are cached as
199 // long as the run number is not changed.
201 // Put together the available objects here by using the lines
202 // a) For usual calibration objects:
204 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
206 // See function CacheCDBEntry for details.
208 // b) For calibration data which depends on two objects: One containing
209 // a value per detector and one the local fluctuations per pad:
211 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
213 // See function CacheMergeCDBEntry for details.
218 // Parameters defined per pad and chamber
220 return CacheCDBEntry(kIDVdriftPad ,"TRD/Calib/LocalVdrift");
222 case kIDVdriftChamber :
223 return CacheCDBEntry(kIDVdriftChamber ,"TRD/Calib/ChamberVdrift");
226 return CacheCDBEntry(kIDExBChamber ,"TRD/Calib/ChamberExB");
229 return CacheCDBEntry(kIDT0Pad ,"TRD/Calib/LocalT0");
232 return CacheCDBEntry(kIDT0Chamber ,"TRD/Calib/ChamberT0");
234 case kIDGainFactorPad :
235 return CacheCDBEntry(kIDGainFactorPad ,"TRD/Calib/LocalGainFactor");
237 case kIDGainFactorChamber :
238 return CacheCDBEntry(kIDGainFactorChamber ,"TRD/Calib/ChamberGainFactor");
241 case kIDOnlineGainFactor :
242 switch(GetOnlineGainTableID()) {
244 // For testing purposes only !!!
245 AliInfo("No gain table name from OCDB. Use default table!");
246 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01");
249 // Online gain table ID 1
250 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01");
253 // Online gain table ID 2
254 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN0_2011-01");
257 // Online gain table ID 3
258 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN8_2011-01");
261 // Online gain table ID 4
262 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-02");
267 case kIDNoiseChamber :
268 return CacheCDBEntry(kIDNoiseChamber ,"TRD/Calib/DetNoise");
271 return CacheCDBEntry(kIDNoisePad ,"TRD/Calib/PadNoise");
274 // Parameters defined per pad
276 return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth");
280 case kIDChamberStatus :
281 return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus");
284 return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus");
288 case kIDMonitoringData :
289 return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData");
292 return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE");
295 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS");
298 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
301 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
304 return CacheCDBEntry(kIDPIDLQ1D ,"TRD/Calib/PIDLQ1D");
307 return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam");
310 return CacheCDBEntry(kIDAttach ,"TRD/Calib/TrkAttach");
318 //_____________________________________________________________________________
319 AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
322 // Retrieves an entry with path <cdbPath> from the CDB.
325 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
327 AliError(Form("Failed to get entry: %s",cdbPath));
335 //_____________________________________________________________________________
336 const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
339 // Caches the entry <id> with cdb path <cdbPath>
342 if (!fCDBCache[id]) {
343 fCDBEntries[id] = GetCDBEntry(cdbPath);
344 if (fCDBEntries[id]) {
345 fCDBCache[id] = fCDBEntries[id]->GetObject();
349 return fCDBCache[id];
353 //_____________________________________________________________________________
354 void AliTRDcalibDB::SetRun(Long64_t run)
357 // Sets current run number. Calibration data is read from the corresponding file.
358 // When the run number changes the caching is invalidated.
371 //_____________________________________________________________________________
372 void AliTRDcalibDB::Invalidate()
375 // Invalidates cache (when run number is changed).
378 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
379 if (fCDBEntries[i]) {
380 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
381 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
385 delete fCDBEntries[i];
392 fOnlineGainTableID = 0;
396 //_____________________________________________________________________________
397 Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row)
400 // Returns the noise level in ADC counts for the given pad.
403 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
404 (GetCachedCDBObject(kIDNoisePad));
409 AliTRDCalROC *roc = calPad->GetCalROC(det);
414 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
415 (GetCachedCDBObject(kIDNoiseChamber));
420 return calChamber->GetValue(det) * roc->GetValue(col,row);
424 //_____________________________________________________________________________
425 AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det)
428 // Returns the Vdrift calibration object for a given ROC
429 // containing one number per pad
432 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
433 (GetCachedCDBObject(kIDNoisePad));
438 AliTRDCalROC *roc = calPad->GetCalROC(det);
448 //_____________________________________________________________________________
449 const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet()
452 // Returns the Vdrift calibration object
453 // containing one number per detector
456 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
457 (GetCachedCDBObject(kIDNoiseChamber));
467 //_____________________________________________________________________________
468 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
471 // Returns the drift velocity for the given pad.
474 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
475 (GetCachedCDBObject(kIDVdriftPad));
480 AliTRDCalROC *roc = calPad->GetCalROC(det);
485 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
486 (GetCachedCDBObject(kIDVdriftChamber));
491 return calChamber->GetValue(det) * roc->GetValue(col,row);
495 //_____________________________________________________________________________
496 AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
499 // Returns the Vdrift calibration object for a given ROC
500 // containing one number per pad
503 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
504 (GetCachedCDBObject(kIDVdriftPad));
509 AliTRDCalROC *roc = calPad->GetCalROC(det);
519 //_____________________________________________________________________________
520 const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
523 // Returns the Vdrift calibration object
524 // containing one number per detector
527 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
528 (GetCachedCDBObject(kIDVdriftChamber));
538 //_____________________________________________________________________________
539 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
542 // Returns the average drift velocity for the given detector
545 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
546 (GetCachedCDBObject(kIDVdriftChamber));
551 return calDet->GetValue(det);
554 //_____________________________________________________________________________
555 const AliTRDCalDet *AliTRDcalibDB::GetExBDet()
558 // Returns the exB calibration object
559 // containing one number per detector
562 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> (GetCachedCDBObject(kIDExBChamber));
564 Double_t meanexb = 100.0;
565 if (calChamber) meanexb = calChamber->GetMean();
566 //printf("mean %f\n",meanexb);
568 if ((!calChamber) || (meanexb > 70.0)) {
570 const AliTRDCalDet *calChambervdrift = dynamic_cast<const AliTRDCalDet *>
571 (GetCachedCDBObject(kIDVdriftChamber));
572 if (!calChambervdrift) {
576 AliTRDCalDet *calDetExB = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
577 for(Int_t k = 0; k < 540; k++){
578 calDetExB->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(calChambervdrift->GetValue(k)));
583 else return calChamber;
586 //_____________________________________________________________________________
587 Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
590 // Returns t0 for the given pad.
593 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
594 (GetCachedCDBObject(kIDT0Pad));
599 AliTRDCalROC *roc = calPad->GetCalROC(det);
604 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
605 (GetCachedCDBObject(kIDT0Chamber));
610 return calChamber->GetValue(det) + roc->GetValue(col,row);
614 //_____________________________________________________________________________
615 AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
618 // Returns the t0 calibration object for a given ROC
619 // containing one number per pad
622 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
623 (GetCachedCDBObject(kIDT0Pad));
628 AliTRDCalROC *roc = calPad->GetCalROC(det);
638 //_____________________________________________________________________________
639 const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
642 // Returns the t0 calibration object
643 // containing one number per detector
646 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
647 (GetCachedCDBObject(kIDT0Chamber));
657 //_____________________________________________________________________________
658 Float_t AliTRDcalibDB::GetT0Average(Int_t det)
661 // Returns the average t0 for the given detector
664 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
665 (GetCachedCDBObject(kIDT0Pad));
670 AliTRDCalROC *roc = calPad->GetCalROC(det);
675 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
676 (GetCachedCDBObject(kIDT0Chamber));
682 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
683 sum += roc->GetValue(channel);
685 sum /= roc->GetNchannels();
686 sum += calDet->GetValue(det);
691 //_____________________________________________________________________________
692 Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
695 // Returns the gain factor for the given pad.
698 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
699 (GetCachedCDBObject(kIDGainFactorPad));
704 AliTRDCalROC *roc = calPad->GetCalROC(det);
709 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
710 (GetCachedCDBObject(kIDGainFactorChamber));
715 return calChamber->GetValue(det) * roc->GetValue(col,row);
719 //_____________________________________________________________________________
720 AliTRDCalOnlineGainTableROC* AliTRDcalibDB::GetOnlineGainTableROC(Int_t det)
723 // Returns the online gain factor table for a given ROC.
726 const AliTRDCalOnlineGainTable *calOnline
727 = dynamic_cast<const AliTRDCalOnlineGainTable *>
728 (GetCachedCDBObject(kIDOnlineGainFactor));
733 return calOnline->GetGainTableROC(det);
737 //_____________________________________________________________________________
738 Float_t AliTRDcalibDB::GetOnlineGainFactor(Int_t det, Int_t col, Int_t row)
741 // Returns the online gain factor for the given pad.
744 const AliTRDCalOnlineGainTable *calOnline
745 = dynamic_cast<const AliTRDCalOnlineGainTable *>
746 (GetCachedCDBObject(kIDOnlineGainFactor));
751 return calOnline->GetGainCorrectionFactor(det,row,col);
755 //_____________________________________________________________________________
756 AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
759 // Returns the gain factor calibration object for a given ROC
762 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
763 (GetCachedCDBObject(kIDGainFactorPad));
768 AliTRDCalROC *roc = calPad->GetCalROC(det);
778 //_____________________________________________________________________________
779 const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
782 // Returns the gain factor calibration object
783 // containing one number per detector
786 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
787 (GetCachedCDBObject(kIDGainFactorChamber));
797 //_____________________________________________________________________________
798 Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
801 // Returns the average gain factor for the given detector
804 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
805 (GetCachedCDBObject(kIDGainFactorChamber));
810 return calDet->GetValue(det);
814 //_____________________________________________________________________________
815 AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
818 // Returns the PRF calibration object for a given ROC
819 // containing one number per pad
822 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
823 (GetCachedCDBObject(kIDPRFWidth));
828 AliTRDCalROC *roc = calPad->GetCalROC(det);
838 //_____________________________________________________________________________
839 Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
842 // Returns the PRF width for the given pad.
845 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
846 (GetCachedCDBObject(kIDPRFWidth));
851 AliTRDCalROC *roc = calPad->GetCalROC(det);
856 return roc->GetValue(col,row);
860 //_____________________________________________________________________________
861 Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS()
864 // Returns Number of time bins from the DCS
867 Int_t nMixed = -2; // not the same number for all chambers
868 Int_t nUndef = -1; // default value - has not been set!
869 Int_t nTbSor = nUndef;
870 Int_t nTbEor = nUndef;
871 Int_t calver = 0; // Check CalDCS version
873 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
875 AliError("No DCS object found!");
879 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
880 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
884 const AliTRDCalDCS *calDCSsor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(0));
885 const AliTRDCalDCS *calDCSeor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(1));
887 // the SOR file is mandatory
888 AliError("NO SOR AliTRDCalDCS object found in CDB file!");
892 // this can happen if the run is shorter than a couple of seconds.
893 AliWarning("NO EOR AliTRDCalDCS object found in CDB file.");
897 nTbSor = calDCSsor->GetGlobalNumberOfTimeBins();
898 if (calDCSeor) nTbEor = calDCSeor->GetGlobalNumberOfTimeBins();
900 } else if (calver == 2) {
902 const AliTRDCalDCSv2 *calDCSsorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(0));
903 const AliTRDCalDCSv2 *calDCSeorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(1));
905 // the SOR file is mandatory
906 AliError("NO SOR AliTRDCalDCSv2 object found in CDB file!");
910 // this can happen if the run is shorter than a couple of seconds.
911 AliWarning("NO EOR AliTRDCalDCSv2 object found in CDB file.");
915 nTbSor = calDCSsorv2->GetGlobalNumberOfTimeBins();
916 if (calDCSeorv2) nTbEor = calDCSeorv2->GetGlobalNumberOfTimeBins();
918 } else AliError("NO DCS/DCSv2 OCDB entry found!");
920 // if they're the same return the value
921 // -2 means mixed, -1: no data, >= 0: good number of time bins
922 if (nTbSor == nTbEor) return nTbSor;
924 // if they're differing:
925 if (nTbSor == nMixed || nTbEor == nMixed) {
926 AliWarning("Inconsistent number of time bins found!");
930 // one is undefined, the other ok -> return that one
931 if (nTbSor == nUndef) return nTbEor;
932 if (nTbEor == nUndef) return nTbSor;
934 // only remains: two different numbers >= 0
939 //_____________________________________________________________________________
940 void AliTRDcalibDB::GetFilterType(TString &filterType)
943 // Returns the filter type
946 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
952 Int_t esor = 0; // Take SOR
953 Int_t calver = 0; // Check CalDCS version
954 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
955 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
960 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
965 filterType = calDCS->GetGlobalFilterType();
968 else if (calver == 2) {
971 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
976 filterType = calDCSv2->GetGlobalFilterType();
981 AliError("NO DCS/DCSv2 OCDB entry found!");
987 //_____________________________________________________________________________
988 Int_t AliTRDcalibDB::GetOnlineGainTableID()
991 // Get the gain table ID from the DCS
994 if (fOnlineGainTableID > 0) {
995 return fOnlineGainTableID;
998 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1003 Int_t esor = 0; // Take SOR
1004 Int_t calver = 0; // Check CalDCS version
1005 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1006 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1010 // No data for old DCS object available, anyway
1014 else if (calver == 2) {
1017 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1022 TString tableName = "";
1023 for (Int_t i = 0; i < 540; i++) {
1024 const AliTRDCalDCSFEEv2 *calDCSFEEv2 = calDCSv2->GetCalDCSFEEObj(0);
1025 tableName = calDCSFEEv2->GetGainTableName();
1026 if (tableName.Length() > 0) {
1030 if (tableName.CompareTo("Krypton_2011-01") == 0) {
1031 fOnlineGainTableID = 1;
1032 return fOnlineGainTableID;
1034 if (tableName.CompareTo("Gaintbl_Uniform_FGAN0_2011-01") == 0) {
1035 fOnlineGainTableID = 2;
1036 return fOnlineGainTableID;
1038 if (tableName.CompareTo("Gaintbl_Uniform_FGAN8_2011-01") == 0) {
1039 fOnlineGainTableID = 3;
1040 return fOnlineGainTableID;
1042 if (tableName.CompareTo("Krypton_2011-02") == 0) {
1043 fOnlineGainTableID = 4;
1044 return fOnlineGainTableID;
1050 AliError("NO DCS/DCSv2 OCDB entry found!");
1059 //_____________________________________________________________________________
1060 void AliTRDcalibDB::GetGlobalConfiguration(TString &config)
1063 // Get Configuration from the DCS
1066 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1072 Int_t esor = 0; // Take SOR
1073 Int_t calver = 0; // Check CalDCS version
1074 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1075 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1080 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
1085 config = calDCS->GetGlobalConfigName();
1088 else if (calver == 2) {
1091 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1096 config = calDCSv2->GetGlobalConfigName();
1101 AliError("NO DCS/DCSv2 OCDB entry found!");
1107 //_____________________________________________________________________________
1108 void AliTRDcalibDB::GetGlobalConfigurationVersion(TString &version)
1111 // Get Version of Configuration from the DCS
1114 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1120 Int_t esor = 0; // Take SOR
1121 Int_t calver = 0; // Check CalDCS version
1122 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1123 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1128 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
1133 version = calDCS->GetGlobalConfigVersion();
1136 else if (calver == 2) {
1139 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1144 version = calDCSv2->GetGlobalConfigVersion();
1149 AliError("NO DCS/DCSv2 OCDB entry found!");
1155 //_____________________________________________________________________________
1156 Bool_t AliTRDcalibDB::HasOnlineFilterPedestal()
1159 // Checks whether pedestal filter was applied online
1164 // Temporary: Get the filter config from the configuration name
1165 GetGlobalConfiguration(cname);
1166 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
1168 // TString filterconfig;
1169 //GetFilterType(filterconfig);
1171 return filterconfig.Contains("p");
1175 //_____________________________________________________________________________
1176 Bool_t AliTRDcalibDB::HasOnlineFilterGain()
1179 // Checks whether online gain filter was applied
1184 // Temporary: Get the filter config from the configuration name
1185 GetGlobalConfiguration(cname);
1186 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
1188 //TString filterconfig;
1189 //GetFilterType(filterconfig);
1191 return filterconfig.Contains("g");
1195 //_____________________________________________________________________________
1196 Bool_t AliTRDcalibDB::HasOnlineTailCancellation()
1199 // Checks whether online tail cancellation was applied
1204 // Temporary: Get the filter config from the configuration name
1205 GetGlobalConfiguration(cname);
1206 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
1208 //TString filterconfig;
1209 //GetFilterType(filterconfig);
1211 return filterconfig.Contains("t");
1215 //_____________________________________________________________________________
1216 Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
1219 // Returns the status of the given pad
1222 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1223 (GetCachedCDBObject(kIDPadStatus));
1228 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1233 return roc->GetStatus(col,row);
1237 //_____________________________________________________________________________
1238 AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
1241 // Returns the pad status calibration object for a given ROC
1244 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1245 (GetCachedCDBObject(kIDPadStatus));
1250 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1260 //_____________________________________________________________________________
1261 Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
1264 // Returns the status of the given chamber
1267 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
1268 (GetCachedCDBObject(kIDChamberStatus));
1273 return cal->GetStatus(det);
1277 //_____________________________________________________________________________
1278 AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
1281 // Returns the TRD reconstruction parameters from the OCDB
1284 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
1285 if (!recos) return 0x0;
1287 // calculate entry based on event type info
1288 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
1290 return (AliTRDrecoParam *) recos->UncheckedAt(n);
1294 //_____________________________________________________________________________
1295 Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
1298 // Returns status, see name of functions for details ;-)
1301 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1302 (GetCachedCDBObject(kIDPadStatus));
1307 return cal->IsMasked(det,col,row);
1311 //_____________________________________________________________________________
1312 Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
1315 // Returns status, see name of functions for details ;-)
1318 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1319 (GetCachedCDBObject(kIDPadStatus));
1324 return cal->IsBridgedLeft(det,col,row);
1328 //_____________________________________________________________________________
1329 Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
1332 // Returns status, see name of functions for details ;-)
1335 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1336 (GetCachedCDBObject(kIDPadStatus));
1341 return cal->IsBridgedRight(det,col,row);
1345 //_____________________________________________________________________________
1346 Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
1349 // Returns status, see name of functions for details ;-)
1352 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1353 (GetCachedCDBObject(kIDPadStatus));
1358 return cal->IsNotConnected(det,col,row);
1362 //_____________________________________________________________________________
1363 Bool_t AliTRDcalibDB::IsChamberGood(Int_t det)
1366 // Returns status, see name of functions for details ;-)
1369 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1370 (GetCachedCDBObject(kIDChamberStatus));
1375 return cal->IsGood(det);
1379 //_____________________________________________________________________________
1380 Bool_t AliTRDcalibDB::IsChamberNoData(Int_t det)
1383 // Returns status, see name of functions for details ;-)
1386 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1387 (GetCachedCDBObject(kIDChamberStatus));
1392 return cal->IsNoData(det);
1396 //_____________________________________________________________________________
1397 Bool_t AliTRDcalibDB::IsHalfChamberNoData(Int_t det, Int_t side)
1400 // Returns status, see name of functions for details ;-)
1403 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1404 (GetCachedCDBObject(kIDChamberStatus));
1409 return side > 0 ? cal->IsNoDataSideB(det) : cal->IsNoDataSideA(det);
1413 //_____________________________________________________________________________
1414 Bool_t AliTRDcalibDB::IsChamberBadCalibrated(Int_t det)
1417 // Returns status, see name of functions for details ;-)
1420 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1421 (GetCachedCDBObject(kIDChamberStatus));
1426 return cal->IsBadCalibrated(det);
1430 //_____________________________________________________________________________
1431 const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
1434 // Returns the object storing the distributions for PID with likelihood
1438 case AliTRDpidUtil::kLQ:
1439 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
1440 case AliTRDpidUtil::kNN:
1441 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
1442 case AliTRDpidUtil::kESD:
1443 return 0x0; // To avoid compiler warnings
1450 //_____________________________________________________________________________
1451 AliTRDPIDResponse *AliTRDcalibDB::GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod method)
1454 // Returns the PID response object for 1D-LQ
1457 if (!fPIDResponse) {
1459 fPIDResponse = new AliTRDPIDResponse;
1461 // Load Reference Histos from OCDB
1462 fPIDResponse->SetPIDmethod(method);
1463 const TObjArray *references = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDPIDLQ1D));
1465 TIter refs(references);
1466 TObject *obj = NULL;
1467 AliTRDPIDReference *ref = NULL;
1468 Bool_t hasReference = kFALSE;
1469 while ((obj = refs())){
1470 if ((ref = dynamic_cast<AliTRDPIDReference *>(obj))){
1471 fPIDResponse->Load(ref);
1472 hasReference = kTRUE;
1477 if (!hasReference) {
1478 AliError("Reference histograms not found in the OCDB");
1483 return fPIDResponse;
1487 //_____________________________________________________________________________
1488 const AliTRDCalTrkAttach* AliTRDcalibDB::GetAttachObject()
1491 // Returns the object storing likelihood distributions for cluster to track attachment
1494 return dynamic_cast<const AliTRDCalTrkAttach*>(GetCachedCDBObject(kIDAttach));
1498 //_____________________________________________________________________________
1499 const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
1502 // Returns the object storing the monitoring data
1505 return dynamic_cast<const AliTRDCalMonitoring *>
1506 (GetCachedCDBObject(kIDMonitoringData));
1510 //_____________________________________________________________________________
1511 void AliTRDcalibDB::SamplePRF()
1514 // Samples the pad response function (should maybe go somewhere else ...)
1517 const Int_t kPRFbin = 61;
1519 Float_t prf[kNlayer][kPRFbin] = {
1520 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
1521 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1522 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1523 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1524 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1525 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1526 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1527 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1528 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1529 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1530 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1531 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1532 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1533 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1534 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1536 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1537 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1538 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1539 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1540 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1541 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1542 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1543 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1544 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1545 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1546 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1547 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1548 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1549 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1550 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1552 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1553 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1554 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1555 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1556 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1557 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1558 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1559 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1560 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1561 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1562 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1563 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1564 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1565 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1566 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1568 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1569 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1570 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1571 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1572 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1573 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1574 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1575 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1576 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1577 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1578 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1579 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1580 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1581 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1582 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1584 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1585 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1586 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1587 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1588 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1589 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1590 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1591 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1592 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1593 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1594 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1595 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1596 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1597 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1598 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1600 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1601 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1602 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1603 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1604 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1605 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1606 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1607 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1608 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1609 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1610 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1611 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1612 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1613 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1614 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1617 // More sampling precision with linear interpolation
1620 Float_t pad[kPRFbin];
1621 Int_t sPRFbin = kPRFbin;
1622 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
1623 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
1624 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
1627 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1628 fPRFpad = ((Int_t) (1.0 / fPRFwid));
1630 if (fPRFsmp) delete [] fPRFsmp;
1631 fPRFsmp = new Float_t[kNlayer*fPRFbin];
1637 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
1639 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
1641 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
1645 diff = bin - pad[ipos2++];
1646 } while ((diff > 0) && (ipos2 < kPRFbin));
1647 if (ipos2 == kPRFbin) {
1648 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1650 else if (ipos2 == 1) {
1651 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1655 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1657 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
1658 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
1667 //_____________________________________________________________________________
1668 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
1669 , Int_t layer, Double_t *pad) const
1672 // Applies the pad response
1673 // So far this is the fixed parametrization and should be replaced by
1674 // something dependent on calibration values
1677 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
1678 Int_t iOff = layer * fPRFbin;
1680 Int_t iBin0 = iBin - fPRFpad + iOff;
1681 Int_t iBin1 = iBin + iOff;
1682 Int_t iBin2 = iBin + fPRFpad + iOff;
1687 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
1690 pad[0] = signal * fPRFsmp[iBin0];
1692 pad[1] = signal * fPRFsmp[iBin1];
1693 if (iBin2 < (fPRFbin*kNlayer)) {
1694 pad[2] = signal * fPRFsmp[iBin2];