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 ///////////////////////////////////////////////////////////////////////////////
32 #include <TClonesArray.h>
33 #include <TObjArray.h>
35 #include "AliCDBManager.h"
36 #include "AliCDBEntry.h"
39 #include "AliTRDPIDReference.h"
40 #include "AliTRDPIDResponseObject.h"
41 #include "AliTRDcalibDB.h"
42 #include "AliTRDtrapConfig.h"
43 #include "AliTRDtrapConfigHandler.h"
44 #include "AliTRDCommonParam.h"
45 #include "AliTRDgeometry.h"
47 #include "Cal/AliTRDCalROC.h"
48 #include "Cal/AliTRDCalPad.h"
49 #include "Cal/AliTRDCalDet.h"
50 #include "Cal/AliTRDCalDCS.h"
51 #include "Cal/AliTRDCalDCSFEE.h"
52 #include "Cal/AliTRDCalDCSv2.h"
53 #include "Cal/AliTRDCalDCSFEEv2.h"
54 #include "Cal/AliTRDCalPID.h"
55 #include "Cal/AliTRDCalMonitoring.h"
56 #include "Cal/AliTRDCalChamberStatus.h"
57 #include "Cal/AliTRDCalPadStatus.h"
58 #include "Cal/AliTRDCalSingleChamberStatus.h"
59 #include "Cal/AliTRDCalTrkAttach.h"
60 #include "Cal/AliTRDCalOnlineGainTable.h"
62 ClassImp(AliTRDcalibDB)
64 AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0;
65 Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
67 //_ singleton implementation __________________________________________________
68 AliTRDcalibDB* AliTRDcalibDB::Instance()
71 // Singleton implementation
72 // Returns an instance of this class, it is created if neccessary
75 if (fgTerminated != kFALSE) {
79 if (fgInstance == 0) {
80 fgInstance = new AliTRDcalibDB();
87 //_____________________________________________________________________________
88 void AliTRDcalibDB::Terminate()
91 // Singleton implementation
92 // Deletes the instance of this class and sets the terminated flag,
93 // instances cannot be requested anymore
94 // This function can be called several times.
99 if (fgInstance != 0) {
106 //_____________________________________________________________________________
107 AliTRDcalibDB::AliTRDcalibDB()
117 ,fOnlineGainTableID(0)
120 ,fTrapConfigVersion("")
123 // Default constructor
125 // TODO Default runnumber is set to 0, this should be changed later
126 // to an invalid value (e.g. -1) to prevent
127 // TODO invalid calibration data to be used.
130 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
135 // Create the sampled PRF
140 //_____________________________________________________________________________
141 AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
151 ,fOnlineGainTableID(0)
154 ,fTrapConfigVersion("")
157 // Copy constructor (not that it make any sense for a singleton...)
160 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
165 // Create the sampled PRF
170 //_____________________________________________________________________________
171 AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
174 // Assignment operator (same as above ...)
178 AliFatal("No assignment operator defined");
185 //_____________________________________________________________________________
186 AliTRDcalibDB::~AliTRDcalibDB()
206 //_caching functions____________________________________________________________
207 const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
210 // Retrieves a cdb object with the given id. The objects are cached as
211 // long as the run number is not changed.
213 // Put together the available objects here by using the lines
214 // a) For usual calibration objects:
216 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
218 // See function CacheCDBEntry for details.
220 // b) For calibration data which depends on two objects: One containing
221 // a value per detector and one the local fluctuations per pad:
223 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
225 // See function CacheMergeCDBEntry for details.
230 // Parameters defined per pad and chamber
232 return CacheCDBEntry(kIDVdriftPad ,"TRD/Calib/LocalVdrift");
234 case kIDVdriftChamber :
235 return CacheCDBEntry(kIDVdriftChamber ,"TRD/Calib/ChamberVdrift");
238 return CacheCDBEntry(kIDExBChamber ,"TRD/Calib/ChamberExB");
241 return CacheCDBEntry(kIDT0Pad ,"TRD/Calib/LocalT0");
244 return CacheCDBEntry(kIDT0Chamber ,"TRD/Calib/ChamberT0");
246 case kIDGainFactorPad :
247 return CacheCDBEntry(kIDGainFactorPad ,"TRD/Calib/LocalGainFactor");
249 case kIDGainFactorChamber :
250 return CacheCDBEntry(kIDGainFactorChamber ,"TRD/Calib/ChamberGainFactor");
253 case kIDOnlineGainFactor :
254 switch(GetOnlineGainTableID()) {
256 // For testing purposes only !!!
257 AliInfo("No gain table name from OCDB. Use default table!");
258 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01");
261 // Online gain table ID 1
262 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01");
265 // Online gain table ID 2
266 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN0_2011-01");
269 // Online gain table ID 3
270 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN8_2011-01");
273 // Online gain table ID 4
274 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-02");
277 // Online gain table ID 5
278 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-03");
281 // Online gain table ID 6
282 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN0_2012-01");
285 // Online gain table ID 7
286 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN8_2012-01");
289 // Online gain table ID 8
290 return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2012-01");
293 AliError(Form("unknown gaintable requested with ID"));
297 case kIDNoiseChamber :
298 return CacheCDBEntry(kIDNoiseChamber ,"TRD/Calib/DetNoise");
301 return CacheCDBEntry(kIDNoisePad ,"TRD/Calib/PadNoise");
304 // Parameters defined per pad
306 return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth");
310 case kIDChamberStatus :
311 return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus");
314 return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus");
318 case kIDMonitoringData :
319 return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData");
322 return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE");
325 return CacheCDBEntry(kIDTrapConfig ,"TRD/Calib/TrapConfig");
328 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS");
331 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
334 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
337 return CacheCDBEntry(kIDPIDLQ1D ,"TRD/Calib/PIDLQ1D");
340 return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam");
343 return CacheCDBEntry(kIDAttach ,"TRD/Calib/TrkAttach");
346 return CacheCDBEntry(kIDPHQ ,"TRD/Calib/PHQ");
354 //_____________________________________________________________________________
355 AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
358 // Retrieves an entry with path <cdbPath> from the CDB.
361 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
363 AliError(Form("Failed to get entry: %s",cdbPath));
371 //_____________________________________________________________________________
372 const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
375 // Caches the entry <id> with cdb path <cdbPath>
378 if (!fCDBCache[id]) {
379 fCDBEntries[id] = GetCDBEntry(cdbPath);
380 if (fCDBEntries[id]) {
381 fCDBCache[id] = fCDBEntries[id]->GetObject();
382 if (id == kIDOnlineGainFactor)
383 AliInfo(Form("loaded gain table: %s", fCDBEntries[id]->GetId().GetAliCDBPath().GetPath().Data()));
387 return fCDBCache[id];
391 //_____________________________________________________________________________
392 void AliTRDcalibDB::SetRun(Long64_t run)
395 // Sets current run number. Calibration data is read from the corresponding file.
396 // When the run number changes the caching is invalidated.
409 //_____________________________________________________________________________
410 void AliTRDcalibDB::Invalidate()
413 // Invalidates cache (when run number is changed).
416 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
417 if (fCDBEntries[i]) {
418 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
419 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
423 delete fCDBEntries[i];
430 fOnlineGainTableID = 0;
434 //_____________________________________________________________________________
435 Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row)
438 // Returns the noise level in ADC counts for the given pad.
441 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
442 (GetCachedCDBObject(kIDNoisePad));
447 AliTRDCalROC *roc = calPad->GetCalROC(det);
452 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
453 (GetCachedCDBObject(kIDNoiseChamber));
458 return calChamber->GetValue(det) * roc->GetValue(col,row);
462 //_____________________________________________________________________________
463 AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det)
466 // Returns the Vdrift calibration object for a given ROC
467 // containing one number per pad
470 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
471 (GetCachedCDBObject(kIDNoisePad));
476 AliTRDCalROC *roc = calPad->GetCalROC(det);
486 //_____________________________________________________________________________
487 const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet()
490 // Returns the Vdrift calibration object
491 // containing one number per detector
494 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
495 (GetCachedCDBObject(kIDNoiseChamber));
505 //_____________________________________________________________________________
506 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
509 // Returns the drift velocity for the given pad.
512 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
513 (GetCachedCDBObject(kIDVdriftPad));
518 AliTRDCalROC *roc = calPad->GetCalROC(det);
523 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
524 (GetCachedCDBObject(kIDVdriftChamber));
529 return calChamber->GetValue(det) * roc->GetValue(col,row);
533 //_____________________________________________________________________________
534 AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
537 // Returns the Vdrift calibration object for a given ROC
538 // containing one number per pad
541 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
542 (GetCachedCDBObject(kIDVdriftPad));
547 AliTRDCalROC *roc = calPad->GetCalROC(det);
557 //_____________________________________________________________________________
558 const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
561 // Returns the Vdrift calibration object
562 // containing one number per detector
565 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
566 (GetCachedCDBObject(kIDVdriftChamber));
576 //_____________________________________________________________________________
577 TObjArray * AliTRDcalibDB::GetPHQ()
580 //return PHQ calibration object
582 TObjArray *arr = (TObjArray *) (GetCachedCDBObject(kIDPHQ));
586 //_____________________________________________________________________________
587 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
590 // Returns the average drift velocity for the given detector
593 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
594 (GetCachedCDBObject(kIDVdriftChamber));
599 return calDet->GetValue(det);
602 //_____________________________________________________________________________
603 const AliTRDCalDet *AliTRDcalibDB::GetExBDet()
606 // Returns the exB calibration object
607 // containing one number per detector
610 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> (GetCachedCDBObject(kIDExBChamber));
612 Double_t meanexb = 100.0;
613 if (calChamber) meanexb = calChamber->GetMean();
614 //printf("mean %f\n",meanexb);
616 if ((!calChamber) || (meanexb > 70.0)) {
618 const AliTRDCalDet *calChambervdrift = dynamic_cast<const AliTRDCalDet *>
619 (GetCachedCDBObject(kIDVdriftChamber));
620 if (!calChambervdrift) {
624 AliTRDCalDet *calDetExB = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
625 for(Int_t k = 0; k < 540; k++){
626 calDetExB->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(calChambervdrift->GetValue(k)));
631 else return calChamber;
634 //_____________________________________________________________________________
635 Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
638 // Returns t0 for the given pad.
641 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
642 (GetCachedCDBObject(kIDT0Pad));
647 AliTRDCalROC *roc = calPad->GetCalROC(det);
652 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
653 (GetCachedCDBObject(kIDT0Chamber));
658 return calChamber->GetValue(det) + roc->GetValue(col,row);
662 //_____________________________________________________________________________
663 AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
666 // Returns the t0 calibration object for a given ROC
667 // containing one number per pad
670 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
671 (GetCachedCDBObject(kIDT0Pad));
676 AliTRDCalROC *roc = calPad->GetCalROC(det);
686 //_____________________________________________________________________________
687 const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
690 // Returns the t0 calibration object
691 // containing one number per detector
694 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
695 (GetCachedCDBObject(kIDT0Chamber));
705 //_____________________________________________________________________________
706 Float_t AliTRDcalibDB::GetT0Average(Int_t det)
709 // Returns the average t0 for the given detector
712 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
713 (GetCachedCDBObject(kIDT0Pad));
718 AliTRDCalROC *roc = calPad->GetCalROC(det);
723 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
724 (GetCachedCDBObject(kIDT0Chamber));
730 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
731 sum += roc->GetValue(channel);
733 sum /= roc->GetNchannels();
734 sum += calDet->GetValue(det);
739 //_____________________________________________________________________________
740 AliTRDCalOnlineGainTableROC* AliTRDcalibDB::GetOnlineGainTableROC(Int_t det)
743 // Returns the online gain factor table for a given ROC.
746 if (!HasOnlineFilterGain()) {
750 const AliTRDCalOnlineGainTable *calOnline
751 = dynamic_cast<const AliTRDCalOnlineGainTable *>
752 (GetCachedCDBObject(kIDOnlineGainFactor));
757 return calOnline->GetGainTableROC(det);
761 //_____________________________________________________________________________
762 Float_t AliTRDcalibDB::GetOnlineGainFactor(Int_t det, Int_t col, Int_t row)
765 // Returns the online gain factor for the given pad.
768 if (!HasOnlineFilterGain()) {
772 const AliTRDCalOnlineGainTable *calOnline
773 = dynamic_cast<const AliTRDCalOnlineGainTable *>
774 (GetCachedCDBObject(kIDOnlineGainFactor));
779 return calOnline->GetGainCorrectionFactor(det,row,col);
783 //_____________________________________________________________________________
784 AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
787 // Returns the gain factor calibration object for a given ROC
790 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
791 (GetCachedCDBObject(kIDGainFactorPad));
796 AliTRDCalROC *roc = calPad->GetCalROC(det);
806 //_____________________________________________________________________________
807 Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
810 // Returns the gain factor for the given pad.
813 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
814 (GetCachedCDBObject(kIDGainFactorPad));
819 AliTRDCalROC *roc = calPad->GetCalROC(det);
824 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
825 (GetCachedCDBObject(kIDGainFactorChamber));
830 return calChamber->GetValue(det) * roc->GetValue(col,row);
834 //_____________________________________________________________________________
835 const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
838 // Returns the gain factor calibration object
839 // containing one number per detector
842 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
843 (GetCachedCDBObject(kIDGainFactorChamber));
853 //_____________________________________________________________________________
854 Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
857 // Returns the average gain factor for the given detector
860 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
861 (GetCachedCDBObject(kIDGainFactorChamber));
866 return calDet->GetValue(det);
870 //_____________________________________________________________________________
871 AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
874 // Returns the PRF calibration object for a given ROC
875 // containing one number per pad
878 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
879 (GetCachedCDBObject(kIDPRFWidth));
884 AliTRDCalROC *roc = calPad->GetCalROC(det);
894 //_____________________________________________________________________________
895 Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
898 // Returns the PRF width for the given pad.
901 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
902 (GetCachedCDBObject(kIDPRFWidth));
907 AliTRDCalROC *roc = calPad->GetCalROC(det);
912 return roc->GetValue(col,row);
916 //_____________________________________________________________________________
917 Int_t AliTRDcalibDB::ExtractTimeBinsFromString(TString tbstr)
919 // Check if there is any content in the string first
920 if (tbstr.Length() == 0) {
921 AliError("Parameter for number of timebins is empty!");
925 // Check if we have the correct config parameter
926 TString tbident = "tb";
927 TString tbsubstr = tbstr(0,2);
928 if (!tbsubstr.EqualTo(tbident)) {
929 AliError(Form("Parameter for number of timebins is corrupted (%s)!", tbstr.Data()));
934 // check if there is more than a number
935 if (!tbstr.IsDigit()) {
936 AliError(Form("Parameter for number of timebins is corrupted (%s)!", tbstr.Data()));
944 //_____________________________________________________________________________
945 Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCSBoard(){
946 // This is an old way to extract the number of time bins,
947 // only to be used as a fallback to see whether there's
948 // a patched OCDB object!
951 // Get the array with SOR and EOR
952 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
955 // Check CalDCS version
957 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
958 else if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
962 AliTRDCalDCS *calSOR = dynamic_cast<AliTRDCalDCS *>(dcsArr->At(0));
967 nTB=calSOR->GetGlobalNumberOfTimeBins();
968 AliTRDCalDCS *calEOR = dynamic_cast<AliTRDCalDCS *>(dcsArr->At(1));
969 if(calEOR && calEOR->GetGlobalNumberOfTimeBins()!=nTB)
972 else if (calver == 2) {
974 AliTRDCalDCSv2 *calSOR = dynamic_cast<AliTRDCalDCSv2 *>(dcsArr->At(0));
979 nTB=calSOR->GetGlobalNumberOfTimeBins();
980 AliTRDCalDCSv2 *calEOR = dynamic_cast<AliTRDCalDCSv2 *>(dcsArr->At(1));
981 if(calEOR && calEOR->GetGlobalNumberOfTimeBins()!=nTB)
985 // No version 1 nor version 2 object
992 //_____________________________________________________________________________
993 Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS()
996 // Returns number of time bins from the DCS
999 // Initialize with values indicating no information
1002 // Extract the global configuration name
1003 GetGlobalConfigurationByChamber(cfg,kTimebin);
1004 // Extract the number of time bins from
1005 // the global configuration
1007 nTB = ExtractTimeBinsFromString(cfg);
1010 // All well, we could extract the number
1011 // of time bins from the configuration name
1015 // No number of time bins from config name.
1016 // No board responded or similar.
1017 // We patched some OCDB entries with
1018 // only the global number of time bins set.
1019 // We should get these here
1020 nTB=GetNumberOfTimeBinsDCSBoard();
1022 AliWarning("Using old method for number of time bins."
1023 " This is probably a patched OCDB entry");
1028 AliError("No number of time bins either"
1029 " from config name or patched OCDB entry");
1035 // // Get the corresponding parameter
1036 // TString cfgstr = "", cfgname = "";
1037 // GetGlobalConfiguration(cfgname);
1038 // if(cfgname.Length()==0)
1040 // GetDCSConfigParOption(cfgname, kTimebin, 0, cfgstr);
1041 // if(cfgstr.Length()==0)
1043 // return ExtractTimeBinsFromString(cfgstr);
1047 //_____________________________________________________________________________
1048 void AliTRDcalibDB::GetFilterType(TString &filterType)
1051 // Returns the filter type
1054 TString cfgname = "";
1055 GetGlobalConfiguration(cfgname);
1056 GetDCSConfigParOption(cfgname, kFltrSet, 0, filterType);
1060 //_____________________________________________________________________________
1061 Int_t AliTRDcalibDB::GetOnlineGainTableID()
1064 // Get the gain table ID from the DCS
1067 if (fOnlineGainTableID > 0) {
1068 return fOnlineGainTableID;
1071 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1076 Int_t esor = 0; // Take SOR
1077 Int_t calver = 0; // Check CalDCS version
1078 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1079 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1083 // No data for old DCS object available, anyway
1087 else if (calver == 2) {
1090 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1095 TString tableName = "";
1096 for (Int_t i = 0; i < 540; i++) {
1097 const AliTRDCalDCSFEEv2 *calDCSFEEv2 = calDCSv2->GetCalDCSFEEObj(0);
1098 tableName = calDCSFEEv2->GetGainTableName();
1099 if (tableName.Length() > 0) {
1103 if (tableName.CompareTo("Krypton_2011-01") == 0)
1104 fOnlineGainTableID = 1;
1105 else if (tableName.CompareTo("Gaintbl_Uniform_FGAN0_2011-01") == 0)
1106 fOnlineGainTableID = 2;
1107 else if (tableName.CompareTo("Gaintbl_Uniform_FGAN8_2011-01") == 0)
1108 fOnlineGainTableID = 3;
1109 else if (tableName.CompareTo("Krypton_2011-02") == 0)
1110 fOnlineGainTableID = 4;
1111 else if (tableName.CompareTo("Krypton_2011-03") == 0)
1112 fOnlineGainTableID = 5;
1113 else if (tableName.CompareTo("Gaintbl_Uniform_FGAN0_2012-01") == 0)
1114 fOnlineGainTableID = 6;
1115 else if (tableName.CompareTo("Gaintbl_Uniform_FGAN8_2012-01") == 0)
1116 fOnlineGainTableID = 7;
1117 else if (tableName.CompareTo("Krypton_2012-01") == 0)
1118 fOnlineGainTableID = 8;
1120 AliFatal(Form("unknown gaintable <%s> requested", tableName.Data()));
1122 AliInfo(Form("looking for gaintable: %s (id %i)",
1123 tableName.Data(), fOnlineGainTableID));
1125 if (fOnlineGainTableID > 0)
1126 return fOnlineGainTableID;
1130 AliError("NO DCS/DCSv2 OCDB entry found!");
1139 //_____________________________________________________________________________
1140 void AliTRDcalibDB::GetGlobalConfiguration(TString &config)
1143 // Get Configuration from the DCS
1146 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1148 AliError("No DCS CDB Object available!");
1153 Int_t idSOR = 0, idEOR=1; // The index of SOR and EOR
1154 Bool_t hasSOR = (dcsArr->At(idSOR));
1155 Bool_t hasEOR = (dcsArr->At(idEOR));
1156 TString cfgSOR = "", cfgEOR = ""; // The configuration at SOR/EOR
1158 // The SOR object is mandatory
1160 AliError("NO SOR object found in CDB file!");
1164 if (!hasEOR) AliWarning("NO EOR object found in CDB file!");
1166 // Check CalDCS version
1168 if (!strcmp(dcsArr->At(idSOR)->ClassName(),"AliTRDCalDCS")) calver = 1;
1169 else if (!strcmp(dcsArr->At(idSOR)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1171 // Get the configuration strings
1174 const AliTRDCalDCS *calSOR = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(idSOR));
1175 cfgSOR = calSOR->GetGlobalConfigName();
1177 const AliTRDCalDCS *calEOR = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(idEOR));
1178 cfgEOR = calEOR->GetGlobalConfigName();
1181 else if (calver == 2) {
1183 const AliTRDCalDCSv2 *calv2SOR = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(idSOR));
1184 cfgSOR = calv2SOR->GetGlobalConfigName();
1186 const AliTRDCalDCSv2 *calv2EOR = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(idEOR));
1187 cfgEOR = calv2EOR->GetGlobalConfigName();
1191 AliError("NO DCS/DCSv2 OCDB entry found!");
1196 // If there is no EOR entry, return the SOR value
1197 if (!hasEOR || cfgEOR.Length()==0) {
1202 // Check if the configuration is the same for both
1203 if (cfgSOR.EqualTo(cfgEOR)) {
1208 // When both SOR and EOR have an entry but are different, the config is not defined
1209 AliError("Inconsistent configuration at start and end of run found!");
1214 //_____________________________________________________________________________
1215 void AliTRDcalibDB::GetGlobalConfigurationByChamber(TString &config,Int_t par, Int_t opt)
1218 // Get Configuration from the DCS
1221 // par is the enumeration from kFltrSet = 1 ... kAddOpti 6
1223 // cf_p_nozs_tb30_csmtrk_ptrg
1225 // kFltrSet kTimebin kTrigSet
1226 // kReadout kTrkMode
1227 // opt is 0 for the value itself and 1,2,3 for the first, second option
1228 // opt has standard value of 0 in header file
1231 // The point is that we extract the parameter/option for
1232 // each of the 540 chambers and compare only this
1233 // parameter/option for a global value, not the full
1234 // configuration name with all parameters
1236 // Get the array with SOR and EOR
1237 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1239 AliError("No DCS CDB Object available!");
1244 // Check CalDCS version
1246 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1247 else if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1249 // Get the configuration strings
1254 // Loop over SOR/EOR
1255 for(Int_t iSEOR=0;iSEOR<2;iSEOR++){
1258 AliTRDCalDCS *cal = dynamic_cast<AliTRDCalDCS *>(dcsArr->At(iSEOR));
1262 AliError("NO SOR object found in CDB file!");
1267 AliWarning("NO EOR object found in CDB file!");
1270 } // Check DCS object is there
1272 // Loop over 540 chambers
1275 // Find the first chamber in SOR
1277 // Loop until we find the first chamber
1278 for(;iDet<kNdet;iDet++){
1279 const AliTRDCalDCSFEE *DCSFEEObj = cal->GetCalDCSFEEObj(iDet);
1280 // Check it's an installed chamber that responded
1281 if(DCSFEEObj && !DCSFEEObj->GetStatusBit()) {
1283 // We ask for a valid configuration name starting with cf_
1284 if(DCSFEEObj->GetConfigName().BeginsWith("cf_")){
1285 // Set the parameter of the first good ROC as global,
1286 // we take only the requested part!
1287 GetDCSConfigParOption(DCSFEEObj->GetConfigName(), par, opt, config);
1288 // Increase counter to not look at this chamber again
1292 } // End: valid config name
1293 } // End: first good chamber
1294 } // End: find the first chamber
1297 // Now compare the other chambers with the first one
1298 for(;iDet<kNdet;iDet++){
1299 const AliTRDCalDCSFEE *DCSFEEObj = cal->GetCalDCSFEEObj(iDet);
1300 // Check it's an installed chamber that responded
1301 if(DCSFEEObj && !DCSFEEObj->GetStatusBit()) {
1303 // We ask for a valid configuration name starting with cf_
1304 if(DCSFEEObj->GetConfigName().BeginsWith("cf_")){
1306 // Get the parameter/option of this chamber
1308 GetDCSConfigParOption(DCSFEEObj->GetConfigName(), par, opt, tmpcfg);
1309 // Compare with the global value
1310 if(config.CompareTo(tmpcfg)){
1311 // Two cases mixed or changed during run
1313 AliError("Mixed DCS configuration for different chambers!");
1317 AliError("Inconsistent configuration at start and end of run found!");
1322 }// Valid config name
1324 } // Second half loop
1325 } // Loop over 540 chambers
1326 } // Loop over SOR / EOR
1331 else if (calver == 2) {
1333 // Loop over SOR/EOR
1334 for(Int_t iSEOR=0;iSEOR<2;iSEOR++){
1337 AliTRDCalDCSv2 *cal = dynamic_cast<AliTRDCalDCSv2 *>(dcsArr->At(iSEOR));
1341 AliError("NO SOR object found in CDB file!");
1346 AliWarning("NO EOR object found in CDB file!");
1349 } // Check DCS object is there
1351 // Loop over 540 chambers
1354 // Find the first chamber in SOR
1356 // Loop until we find the first chamber
1357 for(;iDet<kNdet;iDet++){
1358 const AliTRDCalDCSFEEv2 *DCSFEEObj = cal->GetCalDCSFEEObj(iDet);
1359 // Check it's an installed chamber that responded
1360 if(DCSFEEObj && !DCSFEEObj->GetStatusBit()) {
1361 // Check for a valid config name
1362 if(DCSFEEObj->GetConfigName().BeginsWith("cf_")){
1364 // Set the parameter of the first good ROC as global,
1365 // we take only the requested part!
1366 GetDCSConfigParOption(DCSFEEObj->GetConfigName(), par, opt, config);
1367 // Increase counter to not look at this chamber again
1371 } // End: valid config name
1372 } // End: first good chamber
1373 } // End: find the first chamber
1376 // Now compare the other chambers with the first one
1377 for(;iDet<kNdet;iDet++){
1378 const AliTRDCalDCSFEEv2 *DCSFEEObj = cal->GetCalDCSFEEObj(iDet);
1379 // Check it's an installed chamber that responded
1380 if(DCSFEEObj && !DCSFEEObj->GetStatusBit()) {
1382 // Check for a valid config name
1383 if(DCSFEEObj->GetConfigName().BeginsWith("cf_")){
1385 // Get the parameter/option of this chamber
1387 GetDCSConfigParOption(DCSFEEObj->GetConfigName(), par, opt, tmpcfg);
1388 // Compare with the global value
1389 if(config.CompareTo(tmpcfg)){
1390 // Two cases mixed or changed during run
1392 AliError("Mixed DCS configuration for different chambers!");
1396 AliError("Inconsistent configuration at start and end of run found!");
1401 } // End: valid config name
1402 } // End: Good chamber
1403 } // End: Second half loop
1404 } // Loop over 540 chambers
1405 } // Loop over SOR / EOR
1408 AliError("NO DCS/DCSv2 OCDB entry found!");
1414 //_____________________________________________________________________________
1415 void AliTRDcalibDB::GetGlobalConfigurationVersion(TString &version)
1418 // Get Version of Configuration from the DCS
1421 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
1427 Int_t esor = 0; // Take SOR
1428 Int_t calver = 0; // Check CalDCS version
1429 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1;
1430 if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2;
1435 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor));
1440 version = calDCS->GetGlobalConfigVersion();
1443 else if (calver == 2) {
1446 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor));
1451 version = calDCSv2->GetGlobalConfigVersion();
1456 AliError("NO DCS/DCSv2 OCDB entry found!");
1462 //_____________________________________________________________________________
1463 Int_t AliTRDcalibDB::GetNumberOfParsDCS(TString cname, Char_t delimiter)
1465 // Get the number of configuration parameters from the DCS config
1467 //AliInfo(Form("\"%s\" tokenized by \"%c\"", cname.Data(), delimiter));
1468 if(!cname.Length()) return -1; // -1 for the "cf"
1470 for(Int_t ich(1); ich<cname.Length()-1; ich++){ if(cname[ich]==delimiter) nconf++;}
1474 //_____________________________________________________________________________
1475 Int_t AliTRDcalibDB::GetNumberOfOptsDCS(TString cname, Int_t cfgType)
1477 // Get the number of options of a given configuration parameter from DCS
1479 Char_t cdelim = '_', // define the delimiters
1481 Int_t nconfig = GetNumberOfParsDCS(cname, cdelim);
1484 if ((nconfig == -1) || (nconfig < cfgType)) {
1485 AliError("Not enough parameters in DCS configuration name!");
1489 TObjArray *carr = cname.Tokenize(cdelim);
1490 Int_t nopt = GetNumberOfParsDCS(((TObjString*)carr->At(cfgType))->GetString(), odelim);
1491 carr->Delete(); delete carr;
1495 //_____________________________________________________________________________
1496 void AliTRDcalibDB::GetDCSConfigParOption(TString cname, Int_t cfgType, Int_t option, TString &cfgo)
1499 // Get a configuration (see enum in header file) or the options of a configuration
1500 // option == 0 returns the configuration itself
1501 // option > 0 returns the optional parameter Nr. (option) of the configuration (cfgType)
1504 Char_t cdelim = '_', // define the delimiters
1507 Int_t nconfig = GetNumberOfParsDCS(cname, cdelim);
1509 if (nconfig == -1) {
1510 AliError("DCS configuration name empty!");
1513 } else if (nconfig < cfgType) {
1514 AliError(Form("Not enough parameters in DCS configuration name!"
1515 " Name %s",cname.Data()));
1520 TObjArray *carr = cname.Tokenize(cdelim);
1521 TString cfgString(((TObjString*)carr->At(cfgType))->GetString());
1522 Int_t noptions = GetNumberOfParsDCS(cfgString, odelim);
1524 if (noptions < option) {
1525 AliError(Form("Not enough options in DCS configuration name!"
1526 " Name %s",cname.Data()));
1528 carr->Delete(); delete carr;
1531 TObjArray *oarr = cfgString.Tokenize(odelim);
1532 cfgo = ((TObjString*)oarr->At(option))->GetString();
1533 carr->Delete(); delete carr;
1534 oarr->Delete(); delete oarr;
1539 //_____________________________________________________________________________
1540 Bool_t AliTRDcalibDB::HasOnlineFilterPedestal()
1543 // Checks whether pedestal filter was applied online
1546 TString filterconfig;
1547 GetFilterType(filterconfig);
1549 return filterconfig.Contains("p");
1553 //_____________________________________________________________________________
1554 Bool_t AliTRDcalibDB::HasOnlineFilterGain()
1557 // Checks whether online gain filter was applied
1560 TString filterconfig;
1561 GetFilterType(filterconfig);
1563 return filterconfig.Contains("g");
1567 //_____________________________________________________________________________
1568 Bool_t AliTRDcalibDB::HasOnlineTailCancellation()
1571 // Checks whether online tail cancellation was applied
1574 TString filterconfig;
1575 GetFilterType(filterconfig);
1577 return filterconfig.Contains("t");
1581 //_____________________________________________________________________________
1582 Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
1585 // Returns the status of the given pad
1588 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1589 (GetCachedCDBObject(kIDPadStatus));
1594 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1599 return roc->GetStatus(col,row);
1603 //_____________________________________________________________________________
1604 AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
1607 // Returns the pad status calibration object for a given ROC
1610 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1611 (GetCachedCDBObject(kIDPadStatus));
1616 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
1626 //_____________________________________________________________________________
1627 Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
1630 // Returns the status of the given chamber
1633 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
1634 (GetCachedCDBObject(kIDChamberStatus));
1639 return cal->GetStatus(det);
1643 //_____________________________________________________________________________
1644 AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
1647 // Returns the TRD reconstruction parameters from the OCDB
1650 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
1651 if (!recos) return 0x0;
1653 // calculate entry based on event type info
1654 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
1656 return (AliTRDrecoParam *) recos->UncheckedAt(n);
1660 //_____________________________________________________________________________
1661 Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
1664 // Returns status, see name of functions for details ;-)
1667 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1668 (GetCachedCDBObject(kIDPadStatus));
1673 return cal->IsMasked(det,col,row);
1677 //_____________________________________________________________________________
1678 Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
1681 // Returns status, see name of functions for details ;-)
1684 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1685 (GetCachedCDBObject(kIDPadStatus));
1690 return cal->IsBridgedLeft(det,col,row);
1694 //_____________________________________________________________________________
1695 Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
1698 // Returns status, see name of functions for details ;-)
1701 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1702 (GetCachedCDBObject(kIDPadStatus));
1707 return cal->IsBridgedRight(det,col,row);
1711 //_____________________________________________________________________________
1712 Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
1715 // Returns status, see name of functions for details ;-)
1718 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1719 (GetCachedCDBObject(kIDPadStatus));
1724 return cal->IsNotConnected(det,col,row);
1728 //_____________________________________________________________________________
1729 Bool_t AliTRDcalibDB::IsChamberGood(Int_t det)
1732 // Returns status, see name of functions for details ;-)
1735 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1736 (GetCachedCDBObject(kIDChamberStatus));
1741 return cal->IsGood(det);
1745 //_____________________________________________________________________________
1746 Bool_t AliTRDcalibDB::IsChamberNoData(Int_t det)
1749 // Returns status, see name of functions for details ;-)
1752 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1753 (GetCachedCDBObject(kIDChamberStatus));
1758 return cal->IsNoData(det);
1762 //_____________________________________________________________________________
1763 Bool_t AliTRDcalibDB::IsHalfChamberNoData(Int_t det, Int_t side)
1766 // Returns status, see name of functions for details ;-)
1769 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1770 (GetCachedCDBObject(kIDChamberStatus));
1775 return side > 0 ? cal->IsNoDataSideB(det) : cal->IsNoDataSideA(det);
1779 //_____________________________________________________________________________
1780 Bool_t AliTRDcalibDB::IsChamberBadCalibrated(Int_t det)
1783 // Returns status, see name of functions for details ;-)
1786 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1787 (GetCachedCDBObject(kIDChamberStatus));
1792 return cal->IsBadCalibrated(det);
1796 //_____________________________________________________________________________
1797 Bool_t AliTRDcalibDB::IsChamberNotCalibrated(Int_t det)
1800 // Returns status, see name of functions for details ;-)
1803 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1804 (GetCachedCDBObject(kIDChamberStatus));
1809 return cal->IsNotCalibrated(det);
1813 //_____________________________________________________________________________
1814 const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
1817 // Returns the object storing the distributions for PID with likelihood
1821 case AliTRDpidUtil::kLQ:
1822 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
1823 case AliTRDpidUtil::kNN:
1824 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
1825 case AliTRDpidUtil::kESD:
1826 return 0x0; // To avoid compiler warnings
1833 //_____________________________________________________________________________
1834 AliTRDPIDResponse *AliTRDcalibDB::GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod /*method*/)
1837 // Returns the PID response object for 1D-LQ
1840 if (!fPIDResponse) {
1841 AliDebug(2, "Setting new PID response.");
1843 fPIDResponse = new AliTRDPIDResponse;
1845 // Load Reference Histos from OCDB
1846 // if(method == AliTRDPIDResponse::kLQ1D){
1847 //fPIDResponse->SetPIDmethod(AliTRDPIDResponse::kLQ1D);
1848 const TObjArray *references = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDPIDLQ1D));
1850 TIter refs(references);
1851 TObject *obj = NULL;
1852 AliTRDPIDReference *ref = NULL;
1853 Bool_t hasReference = kFALSE;
1854 while ((obj = refs())){
1855 if ((ref = dynamic_cast<AliTRDPIDReference *>(obj))){
1856 AliDebug(2, "Setting new PID response object.");
1857 TDirectory *bkpdir = gDirectory;
1859 AliTRDPIDResponseObject *ro = new AliTRDPIDResponseObject;
1860 ro->SetPIDReference(ref);
1861 fPIDResponse->SetPIDResponseObject(ro);
1862 hasReference = kTRUE;
1863 gDirectory = bkpdir;
1868 if (!hasReference) {
1869 AliError("Reference histograms not found in the OCDB");
1875 return fPIDResponse;
1879 //_____________________________________________________________________________
1880 const AliTRDCalTrkAttach* AliTRDcalibDB::GetAttachObject()
1883 // Returns the object storing likelihood distributions for cluster to track attachment
1886 return dynamic_cast<const AliTRDCalTrkAttach*>(GetCachedCDBObject(kIDAttach));
1890 //_____________________________________________________________________________
1891 const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
1894 // Returns the object storing the monitoring data
1897 return dynamic_cast<const AliTRDCalMonitoring *>
1898 (GetCachedCDBObject(kIDMonitoringData));
1902 //_____________________________________________________________________________
1903 void AliTRDcalibDB::SamplePRF()
1906 // Samples the pad response function (should maybe go somewhere else ...)
1909 const Int_t kPRFbin = 61;
1911 Float_t prf[kNlayer][kPRFbin] = {
1912 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
1913 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1914 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1915 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1916 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1917 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1918 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1919 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1920 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1921 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1922 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1923 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1924 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1925 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1926 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1928 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1929 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1930 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1931 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1932 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1933 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1934 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1935 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1936 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1937 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1938 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1939 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1940 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1941 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1942 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1944 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1945 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1946 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1947 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1948 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1949 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1950 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1951 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1952 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1953 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1954 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1955 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1956 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1957 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1958 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1960 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1961 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1962 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1963 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1964 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1965 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1966 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1967 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1968 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1969 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1970 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1971 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1972 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1973 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1974 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1976 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1977 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1978 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1979 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1980 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1981 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1982 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1983 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1984 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1985 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1986 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1987 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1988 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1989 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1990 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1992 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1993 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1994 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1995 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1996 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1997 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1998 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1999 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
2000 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
2001 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
2002 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
2003 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
2004 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
2005 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
2006 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
2009 // More sampling precision with linear interpolation
2012 Float_t pad[kPRFbin];
2013 Int_t sPRFbin = kPRFbin;
2014 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
2015 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
2016 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
2019 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
2020 fPRFpad = ((Int_t) (1.0 / fPRFwid));
2022 if (fPRFsmp) delete [] fPRFsmp;
2023 fPRFsmp = new Float_t[kNlayer*fPRFbin];
2029 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
2031 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
2033 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
2037 diff = bin - pad[ipos2++];
2038 } while ((diff > 0) && (ipos2 < kPRFbin));
2039 if (ipos2 == kPRFbin) {
2040 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
2042 else if (ipos2 == 1) {
2043 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
2047 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
2049 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
2050 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
2059 //_____________________________________________________________________________
2060 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
2061 , Int_t layer, Double_t *pad) const
2064 // Applies the pad response
2065 // So far this is the fixed parametrization and should be replaced by
2066 // something dependent on calibration values
2069 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
2070 Int_t iOff = layer * fPRFbin;
2072 Int_t iBin0 = iBin - fPRFpad + iOff;
2073 Int_t iBin1 = iBin + iOff;
2074 Int_t iBin2 = iBin + fPRFpad + iOff;
2079 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
2082 pad[0] = signal * fPRFsmp[iBin0];
2084 pad[1] = signal * fPRFsmp[iBin1];
2085 if (iBin2 < (fPRFbin*kNlayer)) {
2086 pad[2] = signal * fPRFsmp[iBin2];
2101 AliTRDtrapConfig* AliTRDcalibDB::GetTrapConfig()
2103 // return an existing TRAPconfig or load it from the OCDB
2104 // in case of failure, a default TRAPconfig is created
2109 if ((fTrapConfigName.Length() <= 0) || (fTrapConfigVersion.Length() <= 0)) {
2110 // query the configuration to be used
2111 this->GetGlobalConfiguration(fTrapConfigName);
2112 this->GetGlobalConfigurationVersion(fTrapConfigVersion);
2115 // try to load the requested configuration
2116 this->LoadTrapConfig(fTrapConfigName, fTrapConfigVersion);
2118 // if we still don't have a valid TRAPconfig, create a default one
2120 AliWarning("Falling back to default configuration");
2121 static AliTRDtrapConfig trapConfigDefault("default", "default TRAP configuration");
2122 fTrapConfig = &trapConfigDefault;
2123 AliTRDtrapConfigHandler cfgHandler(fTrapConfig);
2125 cfgHandler.LoadConfig();
2128 AliInfo(Form("using TRAPconfig \"%s\"", fTrapConfig->GetTitle()));
2130 // we still have to load the gain tables
2131 // if the gain filter is active
2132 if (HasOnlineFilterGain()) {
2133 const Int_t nDets = AliTRDgeometry::Ndet();
2134 const Int_t nMcms = AliTRDgeometry::MCMmax();
2135 const Int_t nChs = AliTRDgeometry::ADCmax();
2137 // gain factors are per MCM
2138 // allocate the registers accordingly
2139 for (Int_t ch = 0; ch < nChs; ++ch) {
2140 AliTRDtrapConfig::TrapReg_t regFGAN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGA0 + ch);
2141 AliTRDtrapConfig::TrapReg_t regFGFN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGF0 + ch);
2142 fTrapConfig->SetTrapRegAlloc(regFGAN, AliTRDtrapConfig::kAllocByMCM);
2143 fTrapConfig->SetTrapRegAlloc(regFGFN, AliTRDtrapConfig::kAllocByMCM);
2146 for (Int_t iDet = 0; iDet < nDets; ++iDet) {
2147 AliTRDCalOnlineGainTableROC *gainTbl = GetOnlineGainTableROC(iDet);
2149 const Int_t nRobs = AliTRDgeometry::GetStack(iDet) == 2 ?
2150 AliTRDgeometry::ROBmaxC0() : AliTRDgeometry::ROBmaxC1();
2151 for (Int_t rob = 0; rob < nRobs; ++rob) {
2152 for (Int_t mcm = 0; mcm < nMcms; ++mcm) {
2153 AliTRDCalOnlineGainTableMCM *gainTblMCM = gainTbl->GetGainTableMCM(rob, mcm);
2155 // set ADC reference voltage
2156 fTrapConfig->SetTrapReg(AliTRDtrapConfig::kADCDAC, gainTblMCM->GetAdcdac(), iDet, rob, mcm);
2158 // set constants channel-wise
2159 for (Int_t ch = 0; ch < nChs; ++ch) {
2160 AliTRDtrapConfig::TrapReg_t regFGAN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGA0 + ch);
2161 AliTRDtrapConfig::TrapReg_t regFGFN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGF0 + ch);
2162 fTrapConfig->SetTrapReg(regFGAN, gainTblMCM->GetFGAN(ch), iDet, rob, mcm);
2163 fTrapConfig->SetTrapReg(regFGFN, gainTblMCM->GetFGFN(ch), iDet, rob, mcm);
2176 AliTRDtrapConfig* AliTRDcalibDB::LoadTrapConfig(const TString &name, const TString &version)
2178 // try to load the specified configuration from the OCDB
2179 // if it fails, or it does not exist, return null
2181 AliInfo(Form("looking for TRAPconfig \"%s.%s\"", name.Data(), version.Data()));
2183 const AliTRDCalTrapConfig *caltrap = dynamic_cast<const AliTRDCalTrapConfig*> (GetCachedCDBObject(kIDTrapConfig));
2186 TString configName(name);
2187 configName.Append(".");
2188 configName.Append(version);
2189 fTrapConfig = caltrap->Get(configName);
2193 AliError("No TRAPconfig entry found!");