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");
265 // Online gain table ID 5
266 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-03");
269 // Online gain table ID 6
270 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN0_2012-01");
273 // Online gain table ID 7
274 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN8_2012-01");
279 case kIDNoiseChamber :
280 return CacheCDBEntry(kIDNoiseChamber ,"TRD/Calib/DetNoise");
283 return CacheCDBEntry(kIDNoisePad ,"TRD/Calib/PadNoise");
286 // Parameters defined per pad
288 return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth");
292 case kIDChamberStatus :
293 return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus");
296 return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus");
300 case kIDMonitoringData :
301 return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData");
304 return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE");
307 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS");
310 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
313 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
316 return CacheCDBEntry(kIDPIDLQ1D ,"TRD/Calib/PIDLQ1D");
319 return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam");
322 return CacheCDBEntry(kIDAttach ,"TRD/Calib/TrkAttach");
330 //_____________________________________________________________________________
331 AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
334 // Retrieves an entry with path <cdbPath> from the CDB.
337 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
339 AliError(Form("Failed to get entry: %s",cdbPath));
347 //_____________________________________________________________________________
348 const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
351 // Caches the entry <id> with cdb path <cdbPath>
354 if (!fCDBCache[id]) {
355 fCDBEntries[id] = GetCDBEntry(cdbPath);
356 if (fCDBEntries[id]) {
357 fCDBCache[id] = fCDBEntries[id]->GetObject();
361 return fCDBCache[id];
365 //_____________________________________________________________________________
366 void AliTRDcalibDB::SetRun(Long64_t run)
369 // Sets current run number. Calibration data is read from the corresponding file.
370 // When the run number changes the caching is invalidated.
383 //_____________________________________________________________________________
384 void AliTRDcalibDB::Invalidate()
387 // Invalidates cache (when run number is changed).
390 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
391 if (fCDBEntries[i]) {
392 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
393 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
397 delete fCDBEntries[i];
404 fOnlineGainTableID = 0;
408 //_____________________________________________________________________________
409 Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row)
412 // Returns the noise level in ADC counts for the given pad.
415 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
416 (GetCachedCDBObject(kIDNoisePad));
421 AliTRDCalROC *roc = calPad->GetCalROC(det);
426 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
427 (GetCachedCDBObject(kIDNoiseChamber));
432 return calChamber->GetValue(det) * roc->GetValue(col,row);
436 //_____________________________________________________________________________
437 AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det)
440 // Returns the Vdrift calibration object for a given ROC
441 // containing one number per pad
444 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
445 (GetCachedCDBObject(kIDNoisePad));
450 AliTRDCalROC *roc = calPad->GetCalROC(det);
460 //_____________________________________________________________________________
461 const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet()
464 // Returns the Vdrift calibration object
465 // containing one number per detector
468 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
469 (GetCachedCDBObject(kIDNoiseChamber));
479 //_____________________________________________________________________________
480 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
483 // Returns the drift velocity for the given pad.
486 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
487 (GetCachedCDBObject(kIDVdriftPad));
492 AliTRDCalROC *roc = calPad->GetCalROC(det);
497 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
498 (GetCachedCDBObject(kIDVdriftChamber));
503 return calChamber->GetValue(det) * roc->GetValue(col,row);
507 //_____________________________________________________________________________
508 AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
511 // Returns the Vdrift calibration object for a given ROC
512 // containing one number per pad
515 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
516 (GetCachedCDBObject(kIDVdriftPad));
521 AliTRDCalROC *roc = calPad->GetCalROC(det);
531 //_____________________________________________________________________________
532 const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
535 // Returns the Vdrift calibration object
536 // containing one number per detector
539 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
540 (GetCachedCDBObject(kIDVdriftChamber));
550 //_____________________________________________________________________________
551 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
554 // Returns the average drift velocity for the given detector
557 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
558 (GetCachedCDBObject(kIDVdriftChamber));
563 return calDet->GetValue(det);
566 //_____________________________________________________________________________
567 const AliTRDCalDet *AliTRDcalibDB::GetExBDet()
570 // Returns the exB calibration object
571 // containing one number per detector
574 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> (GetCachedCDBObject(kIDExBChamber));
576 Double_t meanexb = 100.0;
577 if (calChamber) meanexb = calChamber->GetMean();
578 //printf("mean %f\n",meanexb);
580 if ((!calChamber) || (meanexb > 70.0)) {
582 const AliTRDCalDet *calChambervdrift = dynamic_cast<const AliTRDCalDet *>
583 (GetCachedCDBObject(kIDVdriftChamber));
584 if (!calChambervdrift) {
588 AliTRDCalDet *calDetExB = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
589 for(Int_t k = 0; k < 540; k++){
590 calDetExB->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(calChambervdrift->GetValue(k)));
595 else return calChamber;
598 //_____________________________________________________________________________
599 Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
602 // Returns t0 for the given pad.
605 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
606 (GetCachedCDBObject(kIDT0Pad));
611 AliTRDCalROC *roc = calPad->GetCalROC(det);
616 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
617 (GetCachedCDBObject(kIDT0Chamber));
622 return calChamber->GetValue(det) + roc->GetValue(col,row);
626 //_____________________________________________________________________________
627 AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
630 // Returns the t0 calibration object for a given ROC
631 // containing one number per pad
634 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
635 (GetCachedCDBObject(kIDT0Pad));
640 AliTRDCalROC *roc = calPad->GetCalROC(det);
650 //_____________________________________________________________________________
651 const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
654 // Returns the t0 calibration object
655 // containing one number per detector
658 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
659 (GetCachedCDBObject(kIDT0Chamber));
669 //_____________________________________________________________________________
670 Float_t AliTRDcalibDB::GetT0Average(Int_t det)
673 // Returns the average t0 for the given detector
676 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
677 (GetCachedCDBObject(kIDT0Pad));
682 AliTRDCalROC *roc = calPad->GetCalROC(det);
687 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
688 (GetCachedCDBObject(kIDT0Chamber));
694 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
695 sum += roc->GetValue(channel);
697 sum /= roc->GetNchannels();
698 sum += calDet->GetValue(det);
703 //_____________________________________________________________________________
704 Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
707 // Returns the gain factor for the given pad.
710 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
711 (GetCachedCDBObject(kIDGainFactorPad));
716 AliTRDCalROC *roc = calPad->GetCalROC(det);
721 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
722 (GetCachedCDBObject(kIDGainFactorChamber));
727 return calChamber->GetValue(det) * roc->GetValue(col,row);
731 //_____________________________________________________________________________
732 AliTRDCalOnlineGainTableROC* AliTRDcalibDB::GetOnlineGainTableROC(Int_t det)
735 // Returns the online gain factor table for a given ROC.
738 const AliTRDCalOnlineGainTable *calOnline
739 = dynamic_cast<const AliTRDCalOnlineGainTable *>
740 (GetCachedCDBObject(kIDOnlineGainFactor));
745 return calOnline->GetGainTableROC(det);
749 //_____________________________________________________________________________
750 Float_t AliTRDcalibDB::GetOnlineGainFactor(Int_t det, Int_t col, Int_t row)
753 // Returns the online gain factor for the given pad.
756 const AliTRDCalOnlineGainTable *calOnline
757 = dynamic_cast<const AliTRDCalOnlineGainTable *>
758 (GetCachedCDBObject(kIDOnlineGainFactor));
763 return calOnline->GetGainCorrectionFactor(det,row,col);
767 //_____________________________________________________________________________
768 AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
771 // Returns the gain factor calibration object for a given ROC
774 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
775 (GetCachedCDBObject(kIDGainFactorPad));
780 AliTRDCalROC *roc = calPad->GetCalROC(det);
790 //_____________________________________________________________________________
791 const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
794 // Returns the gain factor calibration object
795 // containing one number per detector
798 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
799 (GetCachedCDBObject(kIDGainFactorChamber));
809 //_____________________________________________________________________________
810 Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
813 // Returns the average gain factor for the given detector
816 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
817 (GetCachedCDBObject(kIDGainFactorChamber));
822 return calDet->GetValue(det);
826 //_____________________________________________________________________________
827 AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
830 // Returns the PRF calibration object for a given ROC
831 // containing one number per pad
834 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
835 (GetCachedCDBObject(kIDPRFWidth));
840 AliTRDCalROC *roc = calPad->GetCalROC(det);
850 //_____________________________________________________________________________
851 Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
854 // Returns the PRF width for the given pad.
857 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
858 (GetCachedCDBObject(kIDPRFWidth));
863 AliTRDCalROC *roc = calPad->GetCalROC(det);
868 return roc->GetValue(col,row);
872 //_____________________________________________________________________________
873 Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS()
876 // Returns Number of time bins from the DCS
879 Int_t nMixed = -2; // not the same number for all chambers
880 Int_t nUndef = -1; // default value - has not been set!
881 Int_t nTbSor = nUndef;
882 Int_t nTbEor = nUndef;
883 Int_t calver = 0; // Check CalDCS version
885 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
887 AliError("No DCS object found!");
891 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
892 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
896 const AliTRDCalDCS *calDCSsor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(0));
897 const AliTRDCalDCS *calDCSeor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(1));
899 // the SOR file is mandatory
900 AliError("NO SOR AliTRDCalDCS object found in CDB file!");
904 // this can happen if the run is shorter than a couple of seconds.
905 AliWarning("NO EOR AliTRDCalDCS object found in CDB file.");
909 nTbSor = calDCSsor->GetGlobalNumberOfTimeBins();
910 if (calDCSeor) nTbEor = calDCSeor->GetGlobalNumberOfTimeBins();
912 } else if (calver == 2) {
914 const AliTRDCalDCSv2 *calDCSsorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(0));
915 const AliTRDCalDCSv2 *calDCSeorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(1));
917 // the SOR file is mandatory
918 AliError("NO SOR AliTRDCalDCSv2 object found in CDB file!");
922 // this can happen if the run is shorter than a couple of seconds.
923 AliWarning("NO EOR AliTRDCalDCSv2 object found in CDB file.");
927 nTbSor = calDCSsorv2->GetGlobalNumberOfTimeBins();
928 if (calDCSeorv2) nTbEor = calDCSeorv2->GetGlobalNumberOfTimeBins();
930 } else AliError("NO DCS/DCSv2 OCDB entry found!");
932 // if they're the same return the value
933 // -2 means mixed, -1: no data, >= 0: good number of time bins
934 if (nTbSor == nTbEor) return nTbSor;
936 // if they're differing:
937 if (nTbSor == nMixed || nTbEor == nMixed) {
938 AliWarning("Inconsistent number of time bins found!");
942 // one is undefined, the other ok -> return that one
943 if (nTbSor == nUndef) return nTbEor;
944 if (nTbEor == nUndef) return nTbSor;
946 // only remains: two different numbers >= 0
951 //_____________________________________________________________________________
952 void AliTRDcalibDB::GetFilterType(TString &filterType)
955 // Returns the filter type
958 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
964 Int_t esor = 0; // Take SOR
965 Int_t calver = 0; // Check CalDCS version
966 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
967 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
972 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
977 filterType = calDCS->GetGlobalFilterType();
980 else if (calver == 2) {
983 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
988 filterType = calDCSv2->GetGlobalFilterType();
993 AliError("NO DCS/DCSv2 OCDB entry found!");
999 //_____________________________________________________________________________
1000 Int_t AliTRDcalibDB::GetOnlineGainTableID()
1003 // Get the gain table ID from the DCS
1006 if (fOnlineGainTableID > 0) {
1007 return fOnlineGainTableID;
1010 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1015 Int_t esor = 0; // Take SOR
1016 Int_t calver = 0; // Check CalDCS version
1017 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1018 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1022 // No data for old DCS object available, anyway
1026 else if (calver == 2) {
1029 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1034 TString tableName = "";
1035 for (Int_t i = 0; i < 540; i++) {
1036 const AliTRDCalDCSFEEv2 *calDCSFEEv2 = calDCSv2->GetCalDCSFEEObj(0);
1037 tableName = calDCSFEEv2->GetGainTableName();
1038 if (tableName.Length() > 0) {
1042 if (tableName.CompareTo("Krypton_2011-01") == 0) {
1043 fOnlineGainTableID = 1;
1044 return fOnlineGainTableID;
1046 if (tableName.CompareTo("Gaintbl_Uniform_FGAN0_2011-01") == 0) {
1047 fOnlineGainTableID = 2;
1048 return fOnlineGainTableID;
1050 if (tableName.CompareTo("Gaintbl_Uniform_FGAN8_2011-01") == 0) {
1051 fOnlineGainTableID = 3;
1052 return fOnlineGainTableID;
1054 if (tableName.CompareTo("Krypton_2011-02") == 0) {
1055 fOnlineGainTableID = 4;
1056 return fOnlineGainTableID;
1058 if (tableName.CompareTo("Krypton_2011-03") == 0) {
1059 fOnlineGainTableID = 5;
1060 return fOnlineGainTableID;
1062 if (tableName.CompareTo("Gaintbl_Uniform_FGAN0_2012-01") == 0) {
1063 fOnlineGainTableID = 6;
1064 return fOnlineGainTableID;
1066 if (tableName.CompareTo("Gaintbl_Uniform_FGAN8_2012-01") == 0) {
1067 fOnlineGainTableID = 7;
1068 return fOnlineGainTableID;
1074 AliError("NO DCS/DCSv2 OCDB entry found!");
1083 //_____________________________________________________________________________
1084 void AliTRDcalibDB::GetGlobalConfiguration(TString &config)
1087 // Get Configuration from the DCS
1090 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1096 Int_t esor = 0; // Take SOR
1097 Int_t calver = 0; // Check CalDCS version
1098 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1099 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1104 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
1109 config = calDCS->GetGlobalConfigName();
1112 else if (calver == 2) {
1115 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1120 config = calDCSv2->GetGlobalConfigName();
1125 AliError("NO DCS/DCSv2 OCDB entry found!");
1131 //_____________________________________________________________________________
1132 void AliTRDcalibDB::GetGlobalConfigurationVersion(TString &version)
1135 // Get Version of Configuration from the DCS
1138 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1144 Int_t esor = 0; // Take SOR
1145 Int_t calver = 0; // Check CalDCS version
1146 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1147 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1152 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
1157 version = calDCS->GetGlobalConfigVersion();
1160 else if (calver == 2) {
1163 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1168 version = calDCSv2->GetGlobalConfigVersion();
1173 AliError("NO DCS/DCSv2 OCDB entry found!");
1179 //_____________________________________________________________________________
1180 Bool_t AliTRDcalibDB::HasOnlineFilterPedestal()
1183 // Checks whether pedestal filter was applied online
1188 // Temporary: Get the filter config from the configuration name
1189 GetGlobalConfiguration(cname);
1190 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
1192 // TString filterconfig;
1193 //GetFilterType(filterconfig);
1195 return filterconfig.Contains("p");
1199 //_____________________________________________________________________________
1200 Bool_t AliTRDcalibDB::HasOnlineFilterGain()
1203 // Checks whether online gain filter was applied
1208 // Temporary: Get the filter config from the configuration name
1209 GetGlobalConfiguration(cname);
1210 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
1212 //TString filterconfig;
1213 //GetFilterType(filterconfig);
1215 return filterconfig.Contains("g");
1219 //_____________________________________________________________________________
1220 Bool_t AliTRDcalibDB::HasOnlineTailCancellation()
1223 // Checks whether online tail cancellation was applied
1228 // Temporary: Get the filter config from the configuration name
1229 GetGlobalConfiguration(cname);
1230 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
1232 //TString filterconfig;
1233 //GetFilterType(filterconfig);
1235 return filterconfig.Contains("t");
1239 //_____________________________________________________________________________
1240 Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
1243 // Returns the status of the given pad
1246 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1247 (GetCachedCDBObject(kIDPadStatus));
1252 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1257 return roc->GetStatus(col,row);
1261 //_____________________________________________________________________________
1262 AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
1265 // Returns the pad status calibration object for a given ROC
1268 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1269 (GetCachedCDBObject(kIDPadStatus));
1274 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1284 //_____________________________________________________________________________
1285 Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
1288 // Returns the status of the given chamber
1291 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
1292 (GetCachedCDBObject(kIDChamberStatus));
1297 return cal->GetStatus(det);
1301 //_____________________________________________________________________________
1302 AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
1305 // Returns the TRD reconstruction parameters from the OCDB
1308 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
1309 if (!recos) return 0x0;
1311 // calculate entry based on event type info
1312 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
1314 return (AliTRDrecoParam *) recos->UncheckedAt(n);
1318 //_____________________________________________________________________________
1319 Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
1322 // Returns status, see name of functions for details ;-)
1325 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1326 (GetCachedCDBObject(kIDPadStatus));
1331 return cal->IsMasked(det,col,row);
1335 //_____________________________________________________________________________
1336 Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
1339 // Returns status, see name of functions for details ;-)
1342 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1343 (GetCachedCDBObject(kIDPadStatus));
1348 return cal->IsBridgedLeft(det,col,row);
1352 //_____________________________________________________________________________
1353 Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
1356 // Returns status, see name of functions for details ;-)
1359 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1360 (GetCachedCDBObject(kIDPadStatus));
1365 return cal->IsBridgedRight(det,col,row);
1369 //_____________________________________________________________________________
1370 Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
1373 // Returns status, see name of functions for details ;-)
1376 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1377 (GetCachedCDBObject(kIDPadStatus));
1382 return cal->IsNotConnected(det,col,row);
1386 //_____________________________________________________________________________
1387 Bool_t AliTRDcalibDB::IsChamberGood(Int_t det)
1390 // Returns status, see name of functions for details ;-)
1393 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1394 (GetCachedCDBObject(kIDChamberStatus));
1399 return cal->IsGood(det);
1403 //_____________________________________________________________________________
1404 Bool_t AliTRDcalibDB::IsChamberNoData(Int_t det)
1407 // Returns status, see name of functions for details ;-)
1410 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1411 (GetCachedCDBObject(kIDChamberStatus));
1416 return cal->IsNoData(det);
1420 //_____________________________________________________________________________
1421 Bool_t AliTRDcalibDB::IsHalfChamberNoData(Int_t det, Int_t side)
1424 // Returns status, see name of functions for details ;-)
1427 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1428 (GetCachedCDBObject(kIDChamberStatus));
1433 return side > 0 ? cal->IsNoDataSideB(det) : cal->IsNoDataSideA(det);
1437 //_____________________________________________________________________________
1438 Bool_t AliTRDcalibDB::IsChamberBadCalibrated(Int_t det)
1441 // Returns status, see name of functions for details ;-)
1444 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1445 (GetCachedCDBObject(kIDChamberStatus));
1450 return cal->IsBadCalibrated(det);
1454 //_____________________________________________________________________________
1455 const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
1458 // Returns the object storing the distributions for PID with likelihood
1462 case AliTRDpidUtil::kLQ:
1463 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
1464 case AliTRDpidUtil::kNN:
1465 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
1466 case AliTRDpidUtil::kESD:
1467 return 0x0; // To avoid compiler warnings
1474 //_____________________________________________________________________________
1475 AliTRDPIDResponse *AliTRDcalibDB::GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod method)
1478 // Returns the PID response object for 1D-LQ
1481 if (!fPIDResponse) {
1483 fPIDResponse = new AliTRDPIDResponse;
1485 // Load Reference Histos from OCDB
1486 fPIDResponse->SetPIDmethod(method);
1487 const TObjArray *references = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDPIDLQ1D));
1489 TIter refs(references);
1490 TObject *obj = NULL;
1491 AliTRDPIDReference *ref = NULL;
1492 Bool_t hasReference = kFALSE;
1493 while ((obj = refs())){
1494 if ((ref = dynamic_cast<AliTRDPIDReference *>(obj))){
1495 fPIDResponse->Load(ref);
1496 hasReference = kTRUE;
1501 if (!hasReference) {
1502 AliError("Reference histograms not found in the OCDB");
1507 return fPIDResponse;
1511 //_____________________________________________________________________________
1512 const AliTRDCalTrkAttach* AliTRDcalibDB::GetAttachObject()
1515 // Returns the object storing likelihood distributions for cluster to track attachment
1518 return dynamic_cast<const AliTRDCalTrkAttach*>(GetCachedCDBObject(kIDAttach));
1522 //_____________________________________________________________________________
1523 const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
1526 // Returns the object storing the monitoring data
1529 return dynamic_cast<const AliTRDCalMonitoring *>
1530 (GetCachedCDBObject(kIDMonitoringData));
1534 //_____________________________________________________________________________
1535 void AliTRDcalibDB::SamplePRF()
1538 // Samples the pad response function (should maybe go somewhere else ...)
1541 const Int_t kPRFbin = 61;
1543 Float_t prf[kNlayer][kPRFbin] = {
1544 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
1545 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1546 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1547 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1548 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1549 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1550 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1551 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1552 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1553 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1554 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1555 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1556 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1557 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1558 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1560 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1561 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1562 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1563 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1564 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1565 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1566 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1567 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1568 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1569 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1570 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1571 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1572 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1573 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1574 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1576 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1577 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1578 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1579 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1580 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1581 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1582 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1583 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1584 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1585 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1586 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1587 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1588 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1589 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1590 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1592 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1593 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1594 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1595 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1596 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1597 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1598 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1599 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1600 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1601 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1602 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1603 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1604 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1605 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1606 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1608 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1609 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1610 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1611 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1612 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1613 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1614 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1615 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1616 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1617 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1618 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1619 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1620 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1621 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1622 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1624 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1625 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1626 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1627 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1628 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1629 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1630 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1631 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1632 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1633 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1634 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1635 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1636 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1637 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1638 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1641 // More sampling precision with linear interpolation
1644 Float_t pad[kPRFbin];
1645 Int_t sPRFbin = kPRFbin;
1646 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
1647 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
1648 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
1651 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1652 fPRFpad = ((Int_t) (1.0 / fPRFwid));
1654 if (fPRFsmp) delete [] fPRFsmp;
1655 fPRFsmp = new Float_t[kNlayer*fPRFbin];
1661 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
1663 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
1665 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
1669 diff = bin - pad[ipos2++];
1670 } while ((diff > 0) && (ipos2 < kPRFbin));
1671 if (ipos2 == kPRFbin) {
1672 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1674 else if (ipos2 == 1) {
1675 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
1679 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1681 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
1682 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
1691 //_____________________________________________________________________________
1692 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
1693 , Int_t layer, Double_t *pad) const
1696 // Applies the pad response
1697 // So far this is the fixed parametrization and should be replaced by
1698 // something dependent on calibration values
1701 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
1702 Int_t iOff = layer * fPRFbin;
1704 Int_t iBin0 = iBin - fPRFpad + iOff;
1705 Int_t iBin1 = iBin + iOff;
1706 Int_t iBin2 = iBin + fPRFpad + iOff;
1711 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
1714 pad[0] = signal * fPRFsmp[iBin0];
1716 pad[1] = signal * fPRFsmp[iBin1];
1717 if (iBin2 < (fPRFbin*kNlayer)) {
1718 pad[2] = signal * fPRFsmp[iBin2];