From f3c6fd9c19e6a891c9736b792b609f6784b49598 Mon Sep 17 00:00:00 2001 From: noferini Date: Sun, 21 Nov 2021 22:58:03 +0100 Subject: [PATCH 1/2] fixes in TOF calibration workflow --- .../DataFormatsTOF/CalibTimeSlewingParamTOF.h | 1 + .../TOF/src/CalibTimeSlewingParamTOF.cxx | 21 +++++++ Detectors/GlobalTracking/src/MatchTOF.cxx | 13 +++-- .../src/TOFEventTimeChecker.cxx | 2 +- Detectors/TOF/base/include/TOFBase/Utils.h | 10 ++-- Detectors/TOF/base/src/Utils.cxx | 49 ++++++++++++++++- .../TOFCalibration/TOFChannelCalibrator.h | 29 ++++++++++ .../calibration/src/TOFChannelCalibrator.cxx | 55 +++++++++++++++---- .../testWorkflow/tof-calib-workflow.cxx | 1 + .../workflowIO/src/CalibInfoReaderSpec.cxx | 4 +- 10 files changed, 159 insertions(+), 26 deletions(-) diff --git a/DataFormats/Detectors/TOF/include/DataFormatsTOF/CalibTimeSlewingParamTOF.h b/DataFormats/Detectors/TOF/include/DataFormatsTOF/CalibTimeSlewingParamTOF.h index e014ddf7b7232..c96fad2ef81a7 100644 --- a/DataFormats/Detectors/TOF/include/DataFormatsTOF/CalibTimeSlewingParamTOF.h +++ b/DataFormats/Detectors/TOF/include/DataFormatsTOF/CalibTimeSlewingParamTOF.h @@ -84,6 +84,7 @@ class CalibTimeSlewingParamTOF } CalibTimeSlewingParamTOF& operator+=(const CalibTimeSlewingParamTOF& other); + void bind(); private: std::array mChannelStartSec0; diff --git a/DataFormats/Detectors/TOF/src/CalibTimeSlewingParamTOF.cxx b/DataFormats/Detectors/TOF/src/CalibTimeSlewingParamTOF.cxx index 4831572cfd860..b07e4a8bdc984 100644 --- a/DataFormats/Detectors/TOF/src/CalibTimeSlewingParamTOF.cxx +++ b/DataFormats/Detectors/TOF/src/CalibTimeSlewingParamTOF.cxx @@ -35,6 +35,27 @@ float CalibTimeSlewingParamTOF::getChannelOffset(int channel) const { return evalTimeSlewing(channel, 0); } +void CalibTimeSlewingParamTOF::bind() +{ + mGlobalOffset[0] = &mGlobalOffsetSec0; + mGlobalOffset[1] = &mGlobalOffsetSec1; + mGlobalOffset[2] = &mGlobalOffsetSec2; + mGlobalOffset[3] = &mGlobalOffsetSec3; + mGlobalOffset[4] = &mGlobalOffsetSec4; + mGlobalOffset[5] = &mGlobalOffsetSec5; + mGlobalOffset[6] = &mGlobalOffsetSec6; + mGlobalOffset[7] = &mGlobalOffsetSec7; + mGlobalOffset[8] = &mGlobalOffsetSec8; + mGlobalOffset[9] = &mGlobalOffsetSec9; + mGlobalOffset[10] = &mGlobalOffsetSec10; + mGlobalOffset[11] = &mGlobalOffsetSec11; + mGlobalOffset[12] = &mGlobalOffsetSec12; + mGlobalOffset[13] = &mGlobalOffsetSec13; + mGlobalOffset[14] = &mGlobalOffsetSec14; + mGlobalOffset[15] = &mGlobalOffsetSec15; + mGlobalOffset[16] = &mGlobalOffsetSec16; + mGlobalOffset[17] = &mGlobalOffsetSec17; +} //______________________________________________ float CalibTimeSlewingParamTOF::evalTimeSlewing(int channel, float totIn) const diff --git a/Detectors/GlobalTracking/src/MatchTOF.cxx b/Detectors/GlobalTracking/src/MatchTOF.cxx index 40ba3bb454af6..f26dc7f556642 100644 --- a/Detectors/GlobalTracking/src/MatchTOF.cxx +++ b/Detectors/GlobalTracking/src/MatchTOF.cxx @@ -65,6 +65,8 @@ void MatchTOF::run(const o2::globaltracking::RecoContainer& inp) mTimerMatchITSTPC.Reset(); mTimerTot.Reset(); + mCalibInfoTOF.clear(); + for (int i = 0; i < trkType::SIZEALL; i++) { mMatchedTracks[i].clear(); mOutTOFLabels[i].clear(); @@ -1093,10 +1095,13 @@ void MatchTOF::selectBestMatches() } // add also calibration infos - mCalibInfoTOF.emplace_back(mTOFClusWork[matchingPair.getTOFClIndex()].getMainContributingChannel(), - int(mTOFClusWork[matchingPair.getTOFClIndex()].getTimeRaw() * 1E12), // add time stamp - mTOFClusWork[matchingPair.getTOFClIndex()].getTimeRaw() - intLT.getTOF(o2::track::PID::Pion) - t0info, - mTOFClusWork[matchingPair.getTOFClIndex()].getTot()); + if (sourceID == o2::dataformats::GlobalTrackID::ITSTPC) { + mCalibInfoTOF.emplace_back(mTOFClusWork[matchingPair.getTOFClIndex()].getMainContributingChannel(), + int(mTOFClusWork[matchingPair.getTOFClIndex()].getTimeRaw() * 1E-12), // add time stamp + mTOFClusWork[matchingPair.getTOFClIndex()].getTimeRaw() - t0info - intLT.getTOF(o2::track::PID::Pion), + mTOFClusWork[matchingPair.getTOFClIndex()].getTot()); + } + if (mMCTruthON) { const auto& labelsTOF = mTOFClusLabels->getLabels(matchingPair.getTOFClIndex()); auto& labelTrack = mTracksLblWork[trkType][itrk]; diff --git a/Detectors/GlobalTrackingWorkflow/src/TOFEventTimeChecker.cxx b/Detectors/GlobalTrackingWorkflow/src/TOFEventTimeChecker.cxx index 6c7f9fd3b57ce..d902dc60e3e35 100644 --- a/Detectors/GlobalTrackingWorkflow/src/TOFEventTimeChecker.cxx +++ b/Detectors/GlobalTrackingWorkflow/src/TOFEventTimeChecker.cxx @@ -84,7 +84,7 @@ using TimeSlewing = o2::dataformats::CalibTimeSlewingParamTOF; bool MyFilter(const MyTrack& tr) { - return (tr.mP < 2.0 && tr.mEta > o2::tof::Utils::mEtaMin && tr.mEta < o2::tof::Utils::mEtaMax && tr.mHasTOF); + return (tr.mP < 2.0 && tr.mEta > o2::tof::Utils::mEtaMin && tr.mEta < o2::tof::Utils::mEtaMax && tr.mHasTOF && tr.mSource == 1); } // accept all namespace o2 diff --git a/Detectors/TOF/base/include/TOFBase/Utils.h b/Detectors/TOF/base/include/TOFBase/Utils.h index 52bc371632430..ca02df99d175f 100644 --- a/Detectors/TOF/base/include/TOFBase/Utils.h +++ b/Detectors/TOF/base/include/TOFBase/Utils.h @@ -30,12 +30,12 @@ class Utils static bool hasFillScheme(); static int getNinteractionBC(); - static void addBC(float toftime); - static void addBC(double toftime) { addBC(float(toftime)); } - static void addInteractionBC(int bc) { mFillScheme.push_back(bc); } + static void addBC(float toftime, bool subLatency = false); + static void addBC(double toftime, bool subLatency = false) { addBC(float(toftime), subLatency); } + static void addInteractionBC(int bc, bool subLatency = false) { mFillScheme.push_back(bc); } static int getInteractionBC(int ibc) { return mFillScheme[ibc]; } - static double subtractInteractionBC(double time); - static float subtractInteractionBC(float time); + static double subtractInteractionBC(double time, bool subLatency = false); + static float subtractInteractionBC(float time, bool subLatency = false); static void init(); static void printFillScheme(); diff --git a/Detectors/TOF/base/src/Utils.cxx b/Detectors/TOF/base/src/Utils.cxx index 6027cc409fc74..ec63abc273ec8 100644 --- a/Detectors/TOF/base/src/Utils.cxx +++ b/Detectors/TOF/base/src/Utils.cxx @@ -52,9 +52,21 @@ int Utils::getNinteractionBC() return mFillScheme.size(); } -double Utils::subtractInteractionBC(double time) +double Utils::subtractInteractionBC(double time, bool subLatency) { + static const int deltalat = o2::tof::Geo::BC_IN_ORBIT - o2::tof::Geo::LATENCYWINDOW_IN_BC; int bc = int(time * o2::tof::Geo::BC_TIME_INPS_INV + 0.2); + + if (subLatency) { + if (bc >= o2::tof::Geo::LATENCYWINDOW_IN_BC) { + bc -= o2::tof::Geo::LATENCYWINDOW_IN_BC; + time -= o2::tof::Geo::LATENCYWINDOW_IN_BC * o2::tof::Geo::BC_TIME_INPS; + } else { + bc += deltalat; + time += deltalat * o2::tof::Geo::BC_TIME_INPS; + } + } + int bcOrbit = bc % o2::constants::lhc::LHCMaxBunches; int dbc = o2::constants::lhc::LHCMaxBunches, bcc = bc; @@ -77,9 +89,21 @@ double Utils::subtractInteractionBC(double time) return time; } -float Utils::subtractInteractionBC(float time) +float Utils::subtractInteractionBC(float time, bool subLatency) { + static const int deltalat = o2::tof::Geo::BC_IN_ORBIT - o2::tof::Geo::LATENCYWINDOW_IN_BC; int bc = int(time * o2::tof::Geo::BC_TIME_INPS_INV + 0.2); + + if (subLatency) { + if (bc >= o2::tof::Geo::LATENCYWINDOW_IN_BC) { + bc -= o2::tof::Geo::LATENCYWINDOW_IN_BC; + time -= o2::tof::Geo::LATENCYWINDOW_IN_BC * o2::tof::Geo::BC_TIME_INPS; + } else { + bc += deltalat; + time += deltalat * o2::tof::Geo::BC_TIME_INPS; + } + } + int bcOrbit = bc % o2::constants::lhc::LHCMaxBunches; int dbc = o2::constants::lhc::LHCMaxBunches, bcc = bc; @@ -88,13 +112,21 @@ float Utils::subtractInteractionBC(float time) bcc = bc - bcOrbit + getInteractionBC(k); dbc = abs(bcOrbit - getInteractionBC(k)); } + if (abs(bcOrbit - getInteractionBC(k) + o2::constants::lhc::LHCMaxBunches) < dbc) { // in case k is close to the right border (last BC of the orbit) + bcc = bc - bcOrbit + getInteractionBC(k) - o2::constants::lhc::LHCMaxBunches; + dbc = abs(bcOrbit - getInteractionBC(k) + o2::constants::lhc::LHCMaxBunches); + } + if (abs(bcOrbit - getInteractionBC(k) - o2::constants::lhc::LHCMaxBunches) < dbc) { // in case k is close to the left border (BC=0) + bcc = bc - bcOrbit + getInteractionBC(k) + o2::constants::lhc::LHCMaxBunches; + dbc = abs(bcOrbit - getInteractionBC(k) - o2::constants::lhc::LHCMaxBunches); + } } time -= o2::tof::Geo::BC_TIME_INPS * bcc; return time; } -void Utils::addBC(float toftime) +void Utils::addBC(float toftime, bool subLatency) { if (!mIsInit) { init(); @@ -114,8 +146,19 @@ void Utils::addBC(float toftime) } // just fill + static const int deltalat = o2::tof::Geo::BC_IN_ORBIT - o2::tof::Geo::LATENCYWINDOW_IN_BC; int bc = int(toftime * o2::tof::Geo::BC_TIME_INPS_INV + 0.2) % o2::constants::lhc::LHCMaxBunches; + if (subLatency) { + if (bc >= o2::tof::Geo::LATENCYWINDOW_IN_BC) { + bc -= o2::tof::Geo::LATENCYWINDOW_IN_BC; + toftime -= o2::tof::Geo::LATENCYWINDOW_IN_BC * o2::tof::Geo::BC_TIME_INPS; + } else { + bc += deltalat; + toftime += deltalat * o2::tof::Geo::BC_TIME_INPS; + } + } + mBCmult[bc]++; if (mBCmult[bc] > mMaxBC) { diff --git a/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h b/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h index 55f5563f6696f..0ddd4709cff2f 100644 --- a/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h +++ b/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h @@ -37,6 +37,13 @@ #include "CCDB/CcdbApi.h" #include +//#define DEBUGGING + +#ifdef DEBUGGING +#include "TProfile.h" +#include "TH2F.h" +#endif + using o2::math_utils::fitGaus; namespace o2 @@ -59,7 +66,11 @@ class TOFChannelData LOG(INFO) << "Default c-tor, not to be used"; } +#ifndef DEBUGGING TOFChannelData(int nb, float r, CalibTOFapi* cta, int nElsPerSector = o2::tof::Geo::NPADSXSECTOR, bool perstrip = false, bool safe = false) : mNBins(nb), mRange(r), mCalibTOFapi(cta), mNElsPerSector(nElsPerSector), mPerStrip(perstrip), mSafeMode(safe) +#else + TOFChannelData(int nb, float r, CalibTOFapi* cta, int nElsPerSector = o2::tof::Geo::NPADSXSECTOR, bool perstrip = false, bool safe = false, TH2F* h = nullptr) : mNBins(nb), mRange(r), mCalibTOFapi(cta), mNElsPerSector(nElsPerSector), mPerStrip(perstrip), mSafeMode(safe), mChannelDist(h) +#endif { if (r <= 0. || nb < 1) { throw std::runtime_error("Wrong initialization of the histogram"); @@ -111,6 +122,10 @@ class TOFChannelData std::array mHisto; std::vector mEntries; // vector containing number of entries per channel +#ifdef DEBUGGING + TH2F* mChannelDist; +#endif + CalibTOFapi* mCalibTOFapi = nullptr; // calibTOFapi to correct the t-text int mNElsPerSector = o2::tof::Geo::NPADSXSECTOR; @@ -131,6 +146,11 @@ class TOFChannelCalibrator final : public o2::calibration::TimeSlotCalibration; using TimeSlewingVector = std::vector; +#ifdef DEBUGGING + TProfile* mFitCal; //("fitCal",";channel;offset (ps)",13104,0,157248); + TH2F* mChannelDist; //("channelDist",";channel; t - t_{exp}^{#pi} (ps)",13104,0,157248,1000,-100000,100000); +#endif + protected: std::deque>& getSlots() { return o2::calibration::TimeSlotCalibration::getSlots(); } @@ -166,6 +186,10 @@ class TOFChannelCalibrator final : public o2::calibration::TimeSlotCalibration(mNBins, mRange, mCalibTOFapi, nElements, mPerStrip, mSafeMode)); +#else + slot.setContainer(std::make_unique(mNBins, mRange, mCalibTOFapi, nElements, mPerStrip, mSafeMode, mChannelDist)); +#endif + return slot; } diff --git a/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx b/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx index ee3cfa9acc6ac..970b32443c54d 100644 --- a/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx +++ b/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx @@ -24,8 +24,6 @@ #include #endif -//#define DEBUGGING - namespace o2 { namespace tof @@ -52,7 +50,7 @@ void TOFChannelData::fill(const gsl::span d for (int j = 0; j < data.size(); j++) { float dtraw = data[j].getDeltaTimePi(); float dt = mCalibTOFapi->getTimeCalibration(data[j].getTOFChIndex(), data[j].getTot()); - dt = o2::tof::Utils::subtractInteractionBC(dt); + dt = o2::tof::Utils::subtractInteractionBC(dt, true); if (dt > -50000 && dt < 50000) { sumdt += dt; ngood++; @@ -84,14 +82,18 @@ void TOFChannelData::fill(const gsl::span d auto dtcorr = dt - corr; if (!Utils::hasFillScheme()) { - Utils::addBC(dtcorr); + Utils::addBC(dtcorr, true); continue; } - dtcorr = Utils::subtractInteractionBC(dtcorr); + dtcorr = Utils::subtractInteractionBC(dtcorr, true); + + LOG(INFO) << "inserting in channel " << ch << ": dt = " << Utils::subtractInteractionBC(dt, true) << ", tot = " << tot << ", corr = " << corr << ", corrected dt = " << dtcorr; - LOG(DEBUG) << "inserting in channel " << ch << ": dt = " << Utils::subtractInteractionBC(dt) << ", tot = " << tot << ", corr = " << corr << ", corrected dt = " << dtcorr; +#ifdef DEBUGGING + mChannelDist->Fill(ch, dtcorr); +#endif if (!mPerStrip) { mHisto[sector](dtcorr, chInSect); // we pass the calibrated time @@ -161,6 +163,10 @@ void TOFChannelData::fill(const gsl::span data) mHisto[sector](dt, combInSect); // we pass the difference of the *calibrated* times mEntries[comb + NCOMBINSTRIP * absoluteStrip] += 1; + +#ifdef DEBUGGING + mChannelDist->Fill(comb + NCOMBINSTRIP * absoluteStrip, dt); +#endif } } @@ -419,6 +425,7 @@ void TOFChannelCalibrator::finalizeSlotWithCosmics(Slot& slot) // for the CCDB entry std::map md; TimeSlewing& ts = mCalibTOFapi->getSlewParamObj(); // we take the current CCDB object, since we want to simply update the offset + ts.bind(); int nbins = c->getNbins(); float range = c->getRange(); @@ -451,9 +458,6 @@ void TOFChannelCalibrator::finalizeSlotWithCosmics(Slot& slot) int offsetPairInSector = sector * Geo::NSTRIPXSECTOR * NCOMBINSTRIP; int offsetsector = sector * Geo::NSTRIPXSECTOR * Geo::NPADS; for (int istrip = 0; istrip < Geo::NSTRIPXSECTOR; istrip++) { -#ifdef DEBUGGING - system(Form("echo \"\" >strip_%d_%d", sector, istrip)); -#endif LOG(INFO) << "Processing strip " << istrip; double fracUnderPeak[Geo::NPADS] = {0.}; bool isChON[96] = {false}; @@ -531,9 +535,6 @@ void TOFChannelCalibrator::finalizeSlotWithCosmics(Slot& slot) float integral = c->integral(ich, intmin, intmax); edeltat[allpoints] = 20 + fitValues[2] / sqrt(integral); // TODO: for now put by default to 20 ps since it was seen to be reasonable; but it should come from the fit: who gives us the error from the fit ?????? localFitter.AddPoint(&(xp[allpoints]), deltat[allpoints], edeltat[allpoints]); -#ifdef DEBUGGING - system(Form("echo \"%d %f %f\" >>strip_%d_%d", ipair, deltat[allpoints], edeltat[allpoints], sector, istrip)); -#endif goodpoints++; allpoints++; int ch1 = ipair % 96; @@ -549,6 +550,11 @@ void TOFChannelCalibrator::finalizeSlotWithCosmics(Slot& slot) if (fracUnderPeak[ch2] < fractionUnderPeak) { fracUnderPeak[ch2] = fractionUnderPeak; } + +#ifdef DEBUGGING +// mFitCal->Fill(ipair + offsetPairInStrip + offsetPairInSector, fitValues[1]); +#endif + } // end loop pairs // fit strip offset @@ -590,10 +596,17 @@ void TOFChannelCalibrator::finalizeSlotWithCosmics(Slot& slot) LOG(INFO) << "Sector = " << sector << ", strip = " << istrip << " fitted by thread = " << ithread << " with Chi/NDF " << localFitter.GetChisquare() << "/" << goodpoints - localFitter.GetNumberFreeParameters(); LOG(DEBUG) << "Strip = " << istrip << " fitted by thread = " << ithread << " with Chi/NDF " << localFitter.GetChisquare() << "/" << goodpoints - localFitter.GetNumberFreeParameters(); + // if(localFitter.GetChisquare() > (goodpoints - localFitter.GetNumberFreeParameters())*10){ + // continue; + // } + //update calibrations for (int ichLocal = 0; ichLocal < Geo::NPADS; ichLocal++) { int ich = ichLocal + offsetstrip; ts.updateOffsetInfo(ich, localFitter.GetParameter(ichLocal)); +#ifdef DEBUGGING + mFitCal->Fill(ich, localFitter.GetParameter(ichLocal)); +#endif ts.setFractionUnderPeak(ich / Geo::NPADSXSECTOR, ich % Geo::NPADSXSECTOR, fracUnderPeak[ichLocal]); ts.setSigmaPeak(ich / Geo::NPADSXSECTOR, ich % Geo::NPADSXSECTOR, abs(std::sqrt(localFitter.GetCovarianceMatrixElement(ichLocal, ichLocal)))); } @@ -605,6 +618,13 @@ void TOFChannelCalibrator::finalizeSlotWithCosmics(Slot& slot) auto flName = o2::ccdb::CcdbApi::generateFileName(clName); mInfoVector.emplace_back("TOF/Calib/ChannelCalib", clName, flName, md, slot.getTFStart(), 99999999999999); mTimeSlewingVector.emplace_back(ts); + +#ifdef DEBUGGING + TFile fout("debug_tof_cal.root", "RECREATE"); + mFitCal->Write(); + mChannelDist->Write(); + fout.Close(); +#endif } //_____________________________________________ @@ -622,6 +642,7 @@ void TOFChannelCalibrator::finalizeSlotWithTracks(Slot& slot) // for the CCDB entry std::map md; TimeSlewing& ts = mCalibTOFapi->getSlewParamObj(); // we take the current CCDB object, since we want to simply update the offset + ts.bind(); #ifdef WITH_OPENMP if (mNThreads < 1) { @@ -705,6 +726,9 @@ void TOFChannelCalibrator::finalizeSlotWithTracks(Slot& slot) ts.setFractionUnderPeak(ich / Geo::NPADSXSECTOR, ich % Geo::NPADSXSECTOR, fractionUnderPeak); ts.setSigmaPeak(ich / Geo::NPADSXSECTOR, ich % Geo::NPADSXSECTOR, abs(fitValues[2])); ts.updateOffsetInfo(ich, fitValues[1]); +#ifdef DEBUGGING + mFitCal->Fill(ich, fitValues[1]); +#endif LOG(DEBUG) << "udpdate channel " << ich << " with " << fitValues[1] << " offset in ps"; } // end loop channels in sector } // end loop over sectors @@ -713,6 +737,13 @@ void TOFChannelCalibrator::finalizeSlotWithTracks(Slot& slot) mInfoVector.emplace_back("TOF/Calib/ChannelCalib", clName, flName, md, slot.getTFStart(), 99999999999999); mTimeSlewingVector.emplace_back(ts); +#ifdef DEBUGGING + TFile fout("debug_tof_cal.root", "RECREATE"); + mFitCal->Write(); + mChannelDist->Write(); + fout.Close(); +#endif + Utils::printFillScheme(); } diff --git a/Detectors/TOF/calibration/testWorkflow/tof-calib-workflow.cxx b/Detectors/TOF/calibration/testWorkflow/tof-calib-workflow.cxx index 12f0a74965755..f97a3af4bf26e 100644 --- a/Detectors/TOF/calibration/testWorkflow/tof-calib-workflow.cxx +++ b/Detectors/TOF/calibration/testWorkflow/tof-calib-workflow.cxx @@ -14,6 +14,7 @@ #include "Framework/DataProcessorSpec.h" #include "DataFormatsTOF/CalibInfoTOF.h" #include "DataFormatsTOF/CalibInfoCluster.h" +#include "TOFBase/Utils.h" using namespace o2::framework; // we need to add workflow options before including Framework/runDataProcessing diff --git a/Detectors/TOF/workflowIO/src/CalibInfoReaderSpec.cxx b/Detectors/TOF/workflowIO/src/CalibInfoReaderSpec.cxx index b98d74c03b3ee..0aa6234284f09 100644 --- a/Detectors/TOF/workflowIO/src/CalibInfoReaderSpec.cxx +++ b/Detectors/TOF/workflowIO/src/CalibInfoReaderSpec.cxx @@ -60,12 +60,14 @@ void CalibInfoReader::run(ProcessingContext& pc) mTree = (TTree*)fin->Get("calibTOF"); mCurrentEntry = 0; mTree->SetBranchAddress("TOFCalibInfo", &mPvect); + LOG(DEBUG) << "Open " << filename; } if ((mGlobalEntry % mNinstances) == mInstance) { mTree->GetEvent(mCurrentEntry); + LOG(DEBUG) << "Current entry " << mCurrentEntry; LOG(DEBUG) << "Send " << mVect.size() << " calib infos"; pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, mTOFTPC ? ddCalib_tpc : ddCalib, 0, Lifetime::Timeframe}, mVect); - usleep(10000); + usleep(100); } mGlobalEntry++; mCurrentEntry++; From d3d2ce41b2c7e9021fdded94214d16de1dfdd836 Mon Sep 17 00:00:00 2001 From: noferini Date: Mon, 22 Nov 2021 13:02:11 +0100 Subject: [PATCH 2/2] mv calib api and event maker to tof base --- .../DataFormatsTOF/CalibTimeSlewingParamTOF.h | 2 +- .../Detectors/TOF/src/CalibTimeSlewingParamTOF.cxx | 13 +++++++++++++ .../src/TOFEventTimeChecker.cxx | 2 +- Detectors/TOF/base/CMakeLists.txt | 5 ++++- .../include/TOFBase}/CalibTOFapi.h | 0 .../include/TOFBase}/EventTimeMaker.h | 0 .../TOF/{calibration => base}/src/CalibTOFapi.cxx | 2 +- .../{reconstruction => base}/src/EventTimeMaker.cxx | 2 +- Detectors/TOF/base/src/TOFBaseLinkDef.h | 5 +++++ Detectors/TOF/calibration/CMakeLists.txt | 6 ++---- .../calibration/include/TOFCalibration/CalibTOF.h | 2 +- .../include/TOFCalibration/LHCClockCalibrator.h | 2 +- .../include/TOFCalibration/TOFChannelCalibrator.h | 2 +- .../TOF/calibration/src/TOFCalibrationLinkDef.h | 1 - .../TOF/calibration/src/TOFChannelCalibrator.cxx | 6 +++--- Detectors/TOF/prototyping/macroEvTime.C | 2 +- Detectors/TOF/prototyping/testCCDB.C | 2 +- Detectors/TOF/reconstruction/CMakeLists.txt | 4 +--- .../include/TOFReconstruction/Clusterer.h | 2 +- .../reconstruction/src/TOFReconstructionLinkDef.h | 4 ---- .../simulation/include/TOFSimulation/Digitizer.h | 2 +- Detectors/TOF/workflow/src/TOFClusterizerSpec.cxx | 2 +- Steer/DigitizerWorkflow/src/TOFDigitizerSpec.cxx | 2 +- macro/run_clus_tof.C | 3 +-- 24 files changed, 42 insertions(+), 31 deletions(-) rename Detectors/TOF/{calibration/include/TOFCalibration => base/include/TOFBase}/CalibTOFapi.h (100%) rename Detectors/TOF/{reconstruction/include/TOFReconstruction => base/include/TOFBase}/EventTimeMaker.h (100%) rename Detectors/TOF/{calibration => base}/src/CalibTOFapi.cxx (98%) rename Detectors/TOF/{reconstruction => base}/src/EventTimeMaker.cxx (99%) diff --git a/DataFormats/Detectors/TOF/include/DataFormatsTOF/CalibTimeSlewingParamTOF.h b/DataFormats/Detectors/TOF/include/DataFormatsTOF/CalibTimeSlewingParamTOF.h index c96fad2ef81a7..5e1a99c90f4f6 100644 --- a/DataFormats/Detectors/TOF/include/DataFormatsTOF/CalibTimeSlewingParamTOF.h +++ b/DataFormats/Detectors/TOF/include/DataFormatsTOF/CalibTimeSlewingParamTOF.h @@ -32,7 +32,7 @@ class CalibTimeSlewingParamTOF CalibTimeSlewingParamTOF(); - CalibTimeSlewingParamTOF(const CalibTimeSlewingParamTOF& source) = default; + CalibTimeSlewingParamTOF(const CalibTimeSlewingParamTOF& source); CalibTimeSlewingParamTOF& operator=(const CalibTimeSlewingParamTOF& source) = default; diff --git a/DataFormats/Detectors/TOF/src/CalibTimeSlewingParamTOF.cxx b/DataFormats/Detectors/TOF/src/CalibTimeSlewingParamTOF.cxx index b07e4a8bdc984..0d47e2c224511 100644 --- a/DataFormats/Detectors/TOF/src/CalibTimeSlewingParamTOF.cxx +++ b/DataFormats/Detectors/TOF/src/CalibTimeSlewingParamTOF.cxx @@ -185,7 +185,20 @@ CalibTimeSlewingParamTOF& CalibTimeSlewingParamTOF::operator+=(const CalibTimeSl (*(mChannelStart[i])) = (*(other.mChannelStart[i])); *(mFractionUnderPeak[i]) = *(other.mFractionUnderPeak[i]); *(mSigmaPeak[i]) = *(other.mSigmaPeak[i]); + *(mGlobalOffset[i]) = *(other.mGlobalOffset[i]); } } return *this; } +//______________________________________________ +CalibTimeSlewingParamTOF::CalibTimeSlewingParamTOF(const CalibTimeSlewingParamTOF& source) +{ + bind(); + for (int i = 0; i < NSECTORS; i++) { + *(mTimeSlewing[i]) = *(source.mTimeSlewing[i]); + (*(mChannelStart[i])) = (*(source.mChannelStart[i])); + *(mFractionUnderPeak[i]) = *(source.mFractionUnderPeak[i]); + *(mSigmaPeak[i]) = *(source.mSigmaPeak[i]); + *(mGlobalOffset[i]) = *(source.mGlobalOffset[i]); + } +} diff --git a/Detectors/GlobalTrackingWorkflow/src/TOFEventTimeChecker.cxx b/Detectors/GlobalTrackingWorkflow/src/TOFEventTimeChecker.cxx index d902dc60e3e35..5dbf44fa36e81 100644 --- a/Detectors/GlobalTrackingWorkflow/src/TOFEventTimeChecker.cxx +++ b/Detectors/GlobalTrackingWorkflow/src/TOFEventTimeChecker.cxx @@ -37,7 +37,7 @@ #include "TOFBase/Geo.h" #include "TOFBase/Utils.h" #include "DataFormatsTOF/Cluster.h" -#include "TOFReconstruction/EventTimeMaker.h" +#include "TOFBase/EventTimeMaker.h" //#include "GlobalTracking/MatchTOF.h" #include "GlobalTrackingWorkflow/TOFEventTimeChecker.h" diff --git a/Detectors/TOF/base/CMakeLists.txt b/Detectors/TOF/base/CMakeLists.txt index 9006fa349cc94..7045896c85ab4 100644 --- a/Detectors/TOF/base/CMakeLists.txt +++ b/Detectors/TOF/base/CMakeLists.txt @@ -17,13 +17,16 @@ o2_add_library(TOFBase src/Strip.cxx src/WindowFiller.cxx src/Utils.cxx + src/CalibTOFapi.cxx + src/EventTimeMaker.cxx PUBLIC_LINK_LIBRARIES Boost::serialization FairRoot::Base Microsoft.GSL::GSL O2::DetectorsBase O2::CommonDataFormat O2::DetectorsRaw O2::DataFormatsTOF) o2_target_root_dictionary(TOFBase HEADERS include/TOFBase/Geo.h include/TOFBase/Digit.h include/TOFBase/Utils.h - include/TOFBase/Strip.h include/TOFBase/WindowFiller.h) + include/TOFBase/Strip.h include/TOFBase/WindowFiller.h include/TOFBase/CalibTOFapi.h + include/TOFBase/EventTimeMaker.h) o2_add_test(TOFIndex SOURCES test/testTOFIndex.cxx diff --git a/Detectors/TOF/calibration/include/TOFCalibration/CalibTOFapi.h b/Detectors/TOF/base/include/TOFBase/CalibTOFapi.h similarity index 100% rename from Detectors/TOF/calibration/include/TOFCalibration/CalibTOFapi.h rename to Detectors/TOF/base/include/TOFBase/CalibTOFapi.h diff --git a/Detectors/TOF/reconstruction/include/TOFReconstruction/EventTimeMaker.h b/Detectors/TOF/base/include/TOFBase/EventTimeMaker.h similarity index 100% rename from Detectors/TOF/reconstruction/include/TOFReconstruction/EventTimeMaker.h rename to Detectors/TOF/base/include/TOFBase/EventTimeMaker.h diff --git a/Detectors/TOF/calibration/src/CalibTOFapi.cxx b/Detectors/TOF/base/src/CalibTOFapi.cxx similarity index 98% rename from Detectors/TOF/calibration/src/CalibTOFapi.cxx rename to Detectors/TOF/base/src/CalibTOFapi.cxx index e6f0689ca023c..2d200619ef75e 100644 --- a/Detectors/TOF/calibration/src/CalibTOFapi.cxx +++ b/Detectors/TOF/base/src/CalibTOFapi.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include "TOFCalibration/CalibTOFapi.h" +#include "TOFBase/CalibTOFapi.h" #include "FairLogger.h" // for LOG using namespace o2::tof; diff --git a/Detectors/TOF/reconstruction/src/EventTimeMaker.cxx b/Detectors/TOF/base/src/EventTimeMaker.cxx similarity index 99% rename from Detectors/TOF/reconstruction/src/EventTimeMaker.cxx rename to Detectors/TOF/base/src/EventTimeMaker.cxx index b5da91a3029e3..b87ae5d68ff72 100644 --- a/Detectors/TOF/reconstruction/src/EventTimeMaker.cxx +++ b/Detectors/TOF/base/src/EventTimeMaker.cxx @@ -19,7 +19,7 @@ #include "TRandom.h" #include "TMath.h" -#include "TOFReconstruction/EventTimeMaker.h" +#include "TOFBase/EventTimeMaker.h" namespace o2 { diff --git a/Detectors/TOF/base/src/TOFBaseLinkDef.h b/Detectors/TOF/base/src/TOFBaseLinkDef.h index 31de4a72646d9..2498069dd8124 100644 --- a/Detectors/TOF/base/src/TOFBaseLinkDef.h +++ b/Detectors/TOF/base/src/TOFBaseLinkDef.h @@ -25,5 +25,10 @@ #pragma link C++ class vector < o2::tof::ReadoutWindowData> + ; #pragma link C++ class o2::tof::DigitHeader + ; #pragma link C++ class vector < o2::tof::DigitHeader> + ; +#pragma link C++ class o2::tof::CalibTOFapi + ; +#pragma link C++ class o2::tof::eventTimeTrack + ; +#pragma link C++ class o2::tof::eventTimeTrackTest + ; +#pragma link C++ class vector < o2::tof::eventTimeTrack> + ; +#pragma link C++ class vector < o2::tof::eventTimeTrackTest> + ; #pragma link C++ class vector < unsigned int> + ; #endif diff --git a/Detectors/TOF/calibration/CMakeLists.txt b/Detectors/TOF/calibration/CMakeLists.txt index 5aa860652a7a2..7138fadd8585a 100644 --- a/Detectors/TOF/calibration/CMakeLists.txt +++ b/Detectors/TOF/calibration/CMakeLists.txt @@ -11,8 +11,7 @@ o2_add_library(TOFCalibration TARGETVARNAME targetName - SOURCES src/CalibTOFapi.cxx - src/CalibTOF.cxx + SOURCES src/CalibTOF.cxx src/CollectCalibInfoTOF.cxx src/LHCClockCalibrator.cxx src/TOFChannelCalibrator.cxx @@ -30,8 +29,7 @@ o2_add_library(TOFCalibration o2_target_root_dictionary(TOFCalibration - HEADERS include/TOFCalibration/CalibTOFapi.h - include/TOFCalibration/CalibTOF.h + HEADERS include/TOFCalibration/CalibTOF.h include/TOFCalibration/LHCClockCalibrator.h include/TOFCalibration/TOFChannelCalibrator.h include/TOFCalibration/TOFCalibCollector.h diff --git a/Detectors/TOF/calibration/include/TOFCalibration/CalibTOF.h b/Detectors/TOF/calibration/include/TOFCalibration/CalibTOF.h index 229b79d1ac442..fe014c6a9747b 100644 --- a/Detectors/TOF/calibration/include/TOFCalibration/CalibTOF.h +++ b/Detectors/TOF/calibration/include/TOFCalibration/CalibTOF.h @@ -31,7 +31,7 @@ #include "TF1.h" #include "TFile.h" #include "TGraphErrors.h" -#include "TOFCalibration/CalibTOFapi.h" +#include "TOFBase/CalibTOFapi.h" class TTree; diff --git a/Detectors/TOF/calibration/include/TOFCalibration/LHCClockCalibrator.h b/Detectors/TOF/calibration/include/TOFCalibration/LHCClockCalibrator.h index e1803ccd740ea..b53ed8f23db45 100644 --- a/Detectors/TOF/calibration/include/TOFCalibration/LHCClockCalibrator.h +++ b/Detectors/TOF/calibration/include/TOFCalibration/LHCClockCalibrator.h @@ -15,7 +15,7 @@ #include "DetectorsCalibration/TimeSlotCalibration.h" #include "DetectorsCalibration/TimeSlot.h" #include "DataFormatsTOF/CalibInfoTOF.h" -#include "TOFCalibration/CalibTOFapi.h" +#include "TOFBase/CalibTOFapi.h" #include "DataFormatsTOF/CalibLHCphaseTOF.h" #include "TOFBase/Geo.h" #include "CCDB/CcdbObjectInfo.h" diff --git a/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h b/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h index 0ddd4709cff2f..4da2cd062f64a 100644 --- a/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h +++ b/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h @@ -19,7 +19,7 @@ #include "DataFormatsTOF/CalibLHCphaseTOF.h" #include "TOFBase/Geo.h" #include "CCDB/CcdbObjectInfo.h" -#include "TOFCalibration/CalibTOFapi.h" +#include "TOFBase/CalibTOFapi.h" #include #include diff --git a/Detectors/TOF/calibration/src/TOFCalibrationLinkDef.h b/Detectors/TOF/calibration/src/TOFCalibrationLinkDef.h index 380067e313f8c..42380caf307a4 100644 --- a/Detectors/TOF/calibration/src/TOFCalibrationLinkDef.h +++ b/Detectors/TOF/calibration/src/TOFCalibrationLinkDef.h @@ -15,7 +15,6 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class o2::tof::CalibTOFapi + ; #pragma link C++ class o2::globaltracking::CalibTOF + ; #pragma link C++ class o2::globaltracking::CollectCalibInfoTOF + ; diff --git a/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx b/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx index 970b32443c54d..345b660969943 100644 --- a/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx +++ b/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx @@ -89,7 +89,7 @@ void TOFChannelData::fill(const gsl::span d dtcorr = Utils::subtractInteractionBC(dtcorr, true); - LOG(INFO) << "inserting in channel " << ch << ": dt = " << Utils::subtractInteractionBC(dt, true) << ", tot = " << tot << ", corr = " << corr << ", corrected dt = " << dtcorr; + LOG(DEBUG) << "inserting in channel " << ch << ": dt = " << Utils::subtractInteractionBC(dt, true) << ", tot = " << tot << ", corr = " << corr << ", corrected dt = " << dtcorr; #ifdef DEBUGGING mChannelDist->Fill(ch, dtcorr); @@ -425,7 +425,7 @@ void TOFChannelCalibrator::finalizeSlotWithCosmics(Slot& slot) // for the CCDB entry std::map md; TimeSlewing& ts = mCalibTOFapi->getSlewParamObj(); // we take the current CCDB object, since we want to simply update the offset - ts.bind(); + // ts.bind(); int nbins = c->getNbins(); float range = c->getRange(); @@ -642,7 +642,7 @@ void TOFChannelCalibrator::finalizeSlotWithTracks(Slot& slot) // for the CCDB entry std::map md; TimeSlewing& ts = mCalibTOFapi->getSlewParamObj(); // we take the current CCDB object, since we want to simply update the offset - ts.bind(); + // ts.bind(); #ifdef WITH_OPENMP if (mNThreads < 1) { diff --git a/Detectors/TOF/prototyping/macroEvTime.C b/Detectors/TOF/prototyping/macroEvTime.C index e28b4fd16ad33..ab1de99dd5ca2 100644 --- a/Detectors/TOF/prototyping/macroEvTime.C +++ b/Detectors/TOF/prototyping/macroEvTime.C @@ -1,5 +1,5 @@ #if !defined(__CLING__) || defined(__ROOTCLING__) -#include "TOFReconstruction/EventTimeMaker.h" +#include "TOFBase/EventTimeMaker.h" #endif using namespace o2::tof; diff --git a/Detectors/TOF/prototyping/testCCDB.C b/Detectors/TOF/prototyping/testCCDB.C index e817af8e203eb..2d6bbe16c6e87 100644 --- a/Detectors/TOF/prototyping/testCCDB.C +++ b/Detectors/TOF/prototyping/testCCDB.C @@ -3,7 +3,7 @@ #include #include "TTree.h" #include "TFile.h" -#include "TOFCalibration/CalibTOFapi.h" +#include "TOFBase/CalibTOFapi.h" #include "DataFormatsTOF/CalibTimeSlewingParamTOF.h" #include "DataFormatsTOF/CalibLHCphaseTOF.h" #endif diff --git a/Detectors/TOF/reconstruction/CMakeLists.txt b/Detectors/TOF/reconstruction/CMakeLists.txt index 0e79336416683..c72511710362d 100644 --- a/Detectors/TOF/reconstruction/CMakeLists.txt +++ b/Detectors/TOF/reconstruction/CMakeLists.txt @@ -15,14 +15,13 @@ o2_add_library(TOFReconstruction src/DecoderBase.cxx src/Decoder.cxx src/CTFCoder.cxx - src/EventTimeMaker.cxx src/CosmicProcessor.cxx PUBLIC_LINK_LIBRARIES O2::TOFBase O2::DataFormatsTOF O2::SimulationDataFormat O2::CommonDataFormat O2::DataFormatsTOF O2::rANS O2::DPLUtils - O2::TOFCalibration O2::DetectorsRaw) + O2::DetectorsRaw) o2_target_root_dictionary(TOFReconstruction HEADERS include/TOFReconstruction/DataReader.h @@ -32,5 +31,4 @@ o2_target_root_dictionary(TOFReconstruction include/TOFReconstruction/DecoderBase.h include/TOFReconstruction/Decoder.h include/TOFReconstruction/CTFCoder.h - include/TOFReconstruction/EventTimeMaker.h include/TOFReconstruction/CosmicProcessor.h) diff --git a/Detectors/TOF/reconstruction/include/TOFReconstruction/Clusterer.h b/Detectors/TOF/reconstruction/include/TOFReconstruction/Clusterer.h index 6c5d579e52396..c4a921ced1f17 100644 --- a/Detectors/TOF/reconstruction/include/TOFReconstruction/Clusterer.h +++ b/Detectors/TOF/reconstruction/include/TOFReconstruction/Clusterer.h @@ -22,7 +22,7 @@ #include "TOFReconstruction/DataReader.h" #include "SimulationDataFormat/MCTruthContainer.h" #include "SimulationDataFormat/MCCompLabel.h" -#include "TOFCalibration/CalibTOFapi.h" +#include "TOFBase/CalibTOFapi.h" #include "DataFormatsTOF/Diagnostic.h" namespace o2 diff --git a/Detectors/TOF/reconstruction/src/TOFReconstructionLinkDef.h b/Detectors/TOF/reconstruction/src/TOFReconstructionLinkDef.h index 0d2e468fdba8e..d0a7b4b527c1c 100644 --- a/Detectors/TOF/reconstruction/src/TOFReconstructionLinkDef.h +++ b/Detectors/TOF/reconstruction/src/TOFReconstructionLinkDef.h @@ -23,9 +23,5 @@ #pragma link C++ class o2::tof::compressed::Decoder + ; #pragma link C++ class o2::tof::CTFCoder + ; #pragma link C++ class o2::tof::CosmicProcessor + ; -#pragma link C++ class o2::tof::eventTimeTrack + ; -#pragma link C++ class o2::tof::eventTimeTrackTest + ; -#pragma link C++ class vector < o2::tof::eventTimeTrack> + ; -#pragma link C++ class vector < o2::tof::eventTimeTrackTest> + ; #endif diff --git a/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h b/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h index 59ab55b7bbf47..abdbfc0531334 100644 --- a/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h +++ b/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h @@ -19,7 +19,7 @@ #include "TOFSimulation/Detector.h" #include "SimulationDataFormat/MCTruthContainer.h" #include "TOFSimulation/MCLabel.h" -#include "TOFCalibration/CalibTOFapi.h" +#include "TOFBase/CalibTOFapi.h" namespace o2 { diff --git a/Detectors/TOF/workflow/src/TOFClusterizerSpec.cxx b/Detectors/TOF/workflow/src/TOFClusterizerSpec.cxx index e47af04f75b88..f1e6475b9d3d0 100644 --- a/Detectors/TOF/workflow/src/TOFClusterizerSpec.cxx +++ b/Detectors/TOF/workflow/src/TOFClusterizerSpec.cxx @@ -26,7 +26,7 @@ #include "SimulationDataFormat/MCCompLabel.h" #include "DataFormatsTOF/CalibLHCphaseTOF.h" #include "DataFormatsTOF/CalibTimeSlewingParamTOF.h" -#include "TOFCalibration/CalibTOFapi.h" +#include "TOFBase/CalibTOFapi.h" #include "TStopwatch.h" #include "Framework/ConfigParamRegistry.h" #include "Framework/DataRefUtils.h" diff --git a/Steer/DigitizerWorkflow/src/TOFDigitizerSpec.cxx b/Steer/DigitizerWorkflow/src/TOFDigitizerSpec.cxx index 086a4e7a91ea7..b2a450a88b75a 100644 --- a/Steer/DigitizerWorkflow/src/TOFDigitizerSpec.cxx +++ b/Steer/DigitizerWorkflow/src/TOFDigitizerSpec.cxx @@ -26,7 +26,7 @@ #include #include "DataFormatsTOF/CalibLHCphaseTOF.h" #include "DataFormatsTOF/CalibTimeSlewingParamTOF.h" -#include "TOFCalibration/CalibTOFapi.h" +#include "TOFBase/CalibTOFapi.h" #include "SimConfig/DigiParams.h" #include "DetectorsBase/BaseDPLDigitizer.h" diff --git a/macro/run_clus_tof.C b/macro/run_clus_tof.C index ecbc258f1dc70..c538cdf368e05 100644 --- a/macro/run_clus_tof.C +++ b/macro/run_clus_tof.C @@ -30,10 +30,9 @@ #include "TOFReconstruction/ClustererTask.h" #include "DataFormatsTOF/CalibLHCphaseTOF.h" #include "DataFormatsTOF/CalibTimeSlewingParamTOF.h" -#include "TOFCalibration/CalibTOFapi.h" +#include "TOFBase/CalibTOFapi.h" #include "TOFReconstruction/Clusterer.h" #include "TOFReconstruction/DataReader.h" -#include "TOFCalibration/CalibTOFapi.h" #endif void run_clus_tof(std::string outputfile = "tofclusters.root", std::string inputfile = "tofdigits.root", bool isMC = true)