|
11 | 11 | #include "TOFCalibration/CalibTOFapi.h" |
12 | 12 |
|
13 | 13 | using namespace o2::tof; |
14 | | -using ccdbManager = o2::ccdb::BasicCCDBManager; |
15 | 14 |
|
16 | | -ClassImp(CalibTOFapi); |
| 15 | +ClassImp(o2::tof::CalibTOFapi); |
17 | 16 |
|
18 | | -CalibTOFapi(const std::string db) { |
| 17 | +CalibTOFapi::CalibTOFapi(const std::string url) { |
| 18 | + |
| 19 | + // setting the URL to the CCDB manager |
| 20 | + |
| 21 | + setURL(url); |
| 22 | + |
| 23 | +} |
| 24 | + |
| 25 | + |
| 26 | +//______________________________________________________________________ |
| 27 | + |
| 28 | +void CalibTOFapi::readLHCphase() { |
| 29 | + |
| 30 | + // getting the LHCphase calibration |
| 31 | + |
| 32 | + auto& mgr = ccdbManager::instance(); |
| 33 | + mLHCphase = mgr.getForTimeStamp<lhcPhase>("TOF/LHCphase", mTimeStamp); |
| 34 | + |
| 35 | +} |
| 36 | + |
| 37 | +//______________________________________________________________________ |
| 38 | + |
| 39 | +void CalibTOFapi::readTimeSlewingParam() { |
| 40 | + |
| 41 | + // getting the TimeSlewing calibration |
| 42 | + // it includes also offset and information on problematic |
19 | 43 |
|
20 | | - mCCDB = db; |
21 | 44 | auto& mgr = ccdbManager::instance(); |
22 | | - mgr.setURL(db); |
| 45 | + mSlewParam = mgr.getForTimeStamp<slewParam>("TOF/ChannelCalib", mTimeStamp); |
| 46 | + |
| 47 | +} |
| 48 | + |
| 49 | +//______________________________________________________________________ |
23 | 50 |
|
| 51 | +void CalibTOFapi::writeLHCphase(lhcPhase* phase, std::map<std::string, std::string> metadataLHCphase, ulong minTimeStamp, ulong maxTimeStamp) { |
| 52 | + |
| 53 | + // write LHCphase object to CCDB |
| 54 | + |
| 55 | + auto& mgr = ccdbManager::instance(); |
| 56 | + CcdbApi api; |
| 57 | + api.init(mgr.getURL()); |
| 58 | + api.storeAsTFileAny(phase, "TOF/LHCphase", metadataLHCphase, minTimeStamp, maxTimeStamp); |
| 59 | + |
24 | 60 | } |
25 | 61 |
|
26 | 62 | //______________________________________________________________________ |
27 | 63 |
|
| 64 | +void CalibTOFapi::writeTimeSlewingParam(slewParam* param, std::map<std::string, std::string> metadataChannelCalib, ulong minTimeStamp, ulong maxTimeStamp) { |
| 65 | + |
| 66 | + // write TiemSlewing object to CCDB (it includes offset + problematic) |
| 67 | + |
| 68 | + auto& mgr = ccdbManager::instance(); |
| 69 | + CcdbApi api; |
| 70 | + api.init(mgr.getURL()); |
| 71 | + if (maxTimeStamp == 0) { |
| 72 | + api.storeAsTFileAny(param, "TOF/ChannelCalib", metadataChannelCalib, minTimeStamp); |
| 73 | + } |
| 74 | + else api.storeAsTFileAny(param, "TOF/ChannelCalib", metadataChannelCalib, minTimeStamp, maxTimeStamp); |
| 75 | + |
| 76 | +} |
| 77 | + |
| 78 | +//______________________________________________________________________ |
| 79 | + |
| 80 | +bool CalibTOFapi::isProblematic(int ich) { |
| 81 | + |
| 82 | + // method to know if the channel was problematic or not |
| 83 | + |
| 84 | + return mSlewParam->isProblematic(ich); |
| 85 | + |
| 86 | +} |
| 87 | + |
| 88 | +//______________________________________________________________________ |
| 89 | + |
| 90 | +float CalibTOFapi::getTimeCalibration(int ich, float tot) { |
| 91 | + |
| 92 | + // time calibration to correct measured TOF times |
| 93 | + |
| 94 | + float corr = 0; |
| 95 | + |
| 96 | + // LHCphase |
| 97 | + corr += mLHCphase->getLHCphase(int(mTimeStamp/1000)); // timestamp that we use in LHCPhase is in seconds, but for CCDB we need it in ms |
| 98 | + |
| 99 | + // time slewing + channel offset |
| 100 | + corr += mSlewParam->evalTimeSlewing(ich, tot); |
| 101 | + |
| 102 | + return corr; |
| 103 | + |
| 104 | +} |
| 105 | + |
| 106 | +//______________________________________________________________________ |
| 107 | + |
| 108 | +float CalibTOFapi::getTimeDecalibration(int ich, float tot) { |
| 109 | + |
| 110 | + // time decalibration for simulation (it is just the opposite of the calibration) |
| 111 | + |
| 112 | + return -getTimeCalibration(ich, tot); |
| 113 | + |
| 114 | +} |
| 115 | + |
0 commit comments