diff --git a/DataFormats/simulation/include/SimulationDataFormat/TimeStamp.h b/DataFormats/simulation/include/SimulationDataFormat/TimeStamp.h new file mode 100644 index 0000000000000..5f5559e314a57 --- /dev/null +++ b/DataFormats/simulation/include/SimulationDataFormat/TimeStamp.h @@ -0,0 +1,50 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifndef ALICEO2_SIM_TIMESTAMP_H +#define ALICEO2_SIM_TIMESTAMP_H + +#include "Rtypes.h" + +namespace o2 +{ +namespace dataformats +{ +// A minimal TimeStamp class for simulation in the spirit of FairTimeStamp +// but without having FairLinks attached +template +class TimeStamp +{ + public: + TimeStamp() = default; + TimeStamp(T time) { mTimeStamp = time; } + T getTimeStamp() const { return mTimeStamp; } + void setTimeStamp(T t) { mTimeStamp = t; } + private: + T mTimeStamp = 0; + ClassDefNV(TimeStamp, 1); +}; + +template +class TimeStampWithError : public TimeStamp +{ + public: + TimeStampWithError() = default; + TimeStampWithError(T t, E te) : TimeStamp(t), mTimeStampError(te) {} + E getTimeStampError() const { return mTimeStampError; } + void setTimeStampError(E te) { mTimeStampError = te; } + private: + E mTimeStampError = 0; + ClassDefNV(TimeStampWithError, 1); +}; +} +} + +#endif /* ALICEO2_SIM_TIMESTAMP_H */ diff --git a/DataFormats/simulation/src/SimulationDataLinkDef.h b/DataFormats/simulation/src/SimulationDataLinkDef.h index eb0aef6458905..7d0cf64595585 100644 --- a/DataFormats/simulation/src/SimulationDataLinkDef.h +++ b/DataFormats/simulation/src/SimulationDataLinkDef.h @@ -41,4 +41,12 @@ #pragma link C++ class std::vector+; #pragma link C++ class std::vector+; +// make all sorts of dictionaries for TimeStamp +#pragma link C++ class o2::dataformats::TimeStamp+; +#pragma link C++ class o2::dataformats::TimeStamp+; +#pragma link C++ class o2::dataformats::TimeStamp+; +#pragma link C++ class o2::dataformats::TimeStampWithError+; +#pragma link C++ class o2::dataformats::TimeStampWithError+; +#pragma link C++ class o2::dataformats::TimeStampWithError+; + #endif diff --git a/DataFormats/simulation/test/testBasicHits.cxx b/DataFormats/simulation/test/testBasicHits.cxx index 4d3936b29502c..a8fb14b5f7ccd 100644 --- a/DataFormats/simulation/test/testBasicHits.cxx +++ b/DataFormats/simulation/test/testBasicHits.cxx @@ -12,8 +12,9 @@ #define BOOST_TEST_MAIN #define BOOST_TEST_DYN_LINK #include -#include "SimulationDataFormat/BaseHits.h" #include "Math/GenVector/Transform3D.h" +#include "SimulationDataFormat/BaseHits.h" +#include "SimulationDataFormat/TimeStamp.h" #include "TFile.h" namespace o2 @@ -85,4 +86,12 @@ BOOST_AUTO_TEST_CASE(BasicXYZHit_ROOTIO) } } +// basic TimeStamp tests +BOOST_AUTO_TEST_CASE(TimeStamp) +{ + o2::dataformats::TimeStampWithError aTimeStamp(10., 0.1); + BOOST_CHECK_CLOSE(aTimeStamp.getTimeStampError(), 0.1, 1E-4); + BOOST_CHECK_CLOSE(aTimeStamp.getTimeStamp(), 10, 1E-4); +} + } // end namespace AliceO2 diff --git a/Detectors/ITSMFT/ITS/simulation/CMakeLists.txt b/Detectors/ITSMFT/ITS/simulation/CMakeLists.txt index 938ccb0b2f295..3b25a7dc6635f 100644 --- a/Detectors/ITSMFT/ITS/simulation/CMakeLists.txt +++ b/Detectors/ITSMFT/ITS/simulation/CMakeLists.txt @@ -8,11 +8,9 @@ set(SRCS src/V3Layer.cxx src/Detector.cxx src/DigitizerTask.cxx - src/DigitWriteoutBuffer.cxx ) set(HEADERS include/${MODULE_NAME}/Detector.h - include/${MODULE_NAME}/DigitWriteoutBuffer.h include/${MODULE_NAME}/DigitizerTask.h include/${MODULE_NAME}/V1Layer.h include/${MODULE_NAME}/V3Layer.h diff --git a/Detectors/ITSMFT/ITS/simulation/include/ITSSimulation/DigitWriteoutBuffer.h b/Detectors/ITSMFT/ITS/simulation/include/ITSSimulation/DigitWriteoutBuffer.h deleted file mode 100644 index fbae0354bf230..0000000000000 --- a/Detectors/ITSMFT/ITS/simulation/include/ITSSimulation/DigitWriteoutBuffer.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". -// -// See http://alice-o2.web.cern.ch/license for full licensing information. -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -// -// DigitWriteoutBuffer.h -// ALICEO2 -// -// Created by Markus Fasel on 21.07.15. -// -// - -#ifndef ALICEO2_ITS_DIGITWRITEOUTBUFFER_H_ -#define ALICEO2_ITS_DIGITWRITEOUTBUFFER_H_ - -#include -#include // for TString -#include "FairWriteoutBuffer.h" // for FairWriteoutBuffer -#include "Rtypes.h" // for DigitWriteoutBuffer::Class, Bool_t, etc -#include "ITSMFTBase/Digit.h" // for Digit - -namespace o2 { -namespace ITS { -class DigitWriteoutBuffer : public FairWriteoutBuffer -{ - public: - DigitWriteoutBuffer(); - - DigitWriteoutBuffer(TString branchname, TString foldername, Bool_t persistance); - - ~DigitWriteoutBuffer() override; - - // Implementation of virtual function required by the interface - void AddNewDataToTClonesArray(FairTimeStamp *) override; - - double FindTimeForData(FairTimeStamp *) override; - - void FillDataMap(FairTimeStamp *data, double activeTime) override; - - void EraseDataFromDataMap(FairTimeStamp *data) override; - - protected: - std::map mData_map; - - ClassDefOverride(DigitWriteoutBuffer, 1); -}; -} -} - -#endif /* defined(ALICEO2_ITS_DIGITWRITEOUTBUFFER_H_) */ diff --git a/Detectors/ITSMFT/ITS/simulation/src/DigitWriteoutBuffer.cxx b/Detectors/ITSMFT/ITS/simulation/src/DigitWriteoutBuffer.cxx deleted file mode 100644 index 22ac092f378d6..0000000000000 --- a/Detectors/ITSMFT/ITS/simulation/src/DigitWriteoutBuffer.cxx +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". -// -// See http://alice-o2.web.cern.ch/license for full licensing information. -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -// -// DigitWriteoutBuffer.cxx -// ALICEO2 -// -// Created by Markus Fasel on 21.07.15. -// -// -#include "ITSSimulation/DigitWriteoutBuffer.h" -#include "FairRootManager.h" // for FairRootManager -#include "TClonesArray.h" // for TClonesArray -#include "TString.h" // for TString - -class FairTimeStamp; - -ClassImp(o2::ITS::DigitWriteoutBuffer) - -using o2::ITSMFT::Digit; -using namespace o2::ITS; - -DigitWriteoutBuffer::DigitWriteoutBuffer() : - FairWriteoutBuffer(), - mData_map() -{ - -} - -DigitWriteoutBuffer::DigitWriteoutBuffer(TString branchname, TString foldername, Bool_t persistance) : - FairWriteoutBuffer(branchname, "o2::ITSMFT::Digit", foldername, persistance), - mData_map() -{ - -} - -DigitWriteoutBuffer::~DigitWriteoutBuffer() -= default; - -void DigitWriteoutBuffer::AddNewDataToTClonesArray(FairTimeStamp *timestamp) -{ - FairRootManager *iohandler = FairRootManager::Instance(); - TClonesArray *outputarray = iohandler->GetTClonesArray(fBranchName); - - new((*outputarray)[outputarray->GetEntries()])Digit(*(static_cast(timestamp))); -} - -double DigitWriteoutBuffer::FindTimeForData(FairTimeStamp *timestamp) -{ - Digit itsdigit = *(static_cast(timestamp)); - auto result = mData_map.find(itsdigit); - if (result != mData_map.end()) { - return result->second; - } - return -1; -} - -void DigitWriteoutBuffer::FillDataMap(FairTimeStamp *data, double activeTime) -{ - Digit itsdigit = *(static_cast(data)); - mData_map[itsdigit] = activeTime; -} - -void DigitWriteoutBuffer::EraseDataFromDataMap(FairTimeStamp *data) -{ - Digit itsdigit = *(static_cast(data)); - if (mData_map.find(itsdigit) != mData_map.end()) { - mData_map.erase(itsdigit); - } -} diff --git a/Detectors/ITSMFT/ITS/simulation/src/ITSSimulationLinkDef.h b/Detectors/ITSMFT/ITS/simulation/src/ITSSimulationLinkDef.h index 955248567e5a0..172ab14b4010b 100644 --- a/Detectors/ITSMFT/ITS/simulation/src/ITSSimulationLinkDef.h +++ b/Detectors/ITSMFT/ITS/simulation/src/ITSSimulationLinkDef.h @@ -19,7 +19,6 @@ #pragma link C++ class o2::ITS::V3Layer+; #pragma link C++ class o2::ITS::Detector+; #pragma link C++ class o2::Base::DetImpl+; -#pragma link C++ class o2::ITS::DigitWriteoutBuffer+; #pragma link C++ class o2::ITS::DigitizerTask+; #endif diff --git a/Detectors/ITSMFT/common/base/include/ITSMFTBase/Digit.h b/Detectors/ITSMFT/common/base/include/ITSMFTBase/Digit.h index a96f410c8ecfb..4554a22e79ed5 100644 --- a/Detectors/ITSMFT/common/base/include/ITSMFTBase/Digit.h +++ b/Detectors/ITSMFT/common/base/include/ITSMFTBase/Digit.h @@ -13,23 +13,9 @@ #ifndef ALICEO2_ITSMFT_DIGIT_H #define ALICEO2_ITSMFT_DIGIT_H -#ifndef __CLING__ - -#include // for base_object - -#endif - +#include "Rtypes.h" // for Double_t, ULong_t, etc #include "SimulationDataFormat/MCCompLabel.h" -#include "FairTimeStamp.h" // for FairTimeStamp -#include "Rtypes.h" // for Double_t, ULong_t, etc - -namespace boost -{ -namespace serialization -{ -class access; -} -} +#include "SimulationDataFormat/TimeStamp.h" namespace o2 { @@ -39,7 +25,9 @@ namespace ITSMFT /// \class Digit /// \brief Digit class for the ITS /// -class Digit : public FairTimeStamp + +using DigitBase = o2::dataformats::TimeStamp; +class Digit : public DigitBase { using Label = o2::MCCompLabel; @@ -58,7 +46,7 @@ class Digit : public FairTimeStamp Digit(UShort_t chipindex, UInt_t frame, UShort_t row, UShort_t col, Float_t charge, Double_t timestamp); /// Destructor - ~Digit() override; + ~Digit(); /// Addition operator /// Adds the charge of 2 digits @@ -144,18 +132,6 @@ class Digit : public FairTimeStamp return static_cast(key>>(8*(sizeof(UInt_t)+ROFrameOverFlowBits))); } - bool equal(FairTimeStamp* other) override - { - Digit* mydigi = dynamic_cast(other); - if (mydigi) { - if (mChipIndex == mydigi->getChipIndex() && mCol == mydigi->getColumn() && - mRow == mydigi->getRow() && getROFrame() == mydigi->getROFrame()) { - return true; - } - } - return false; - } - /// Test if the current digit is lower than the other /// Comparison is done based on the chip index and pixel index. Two /// options are possible for true: @@ -164,7 +140,6 @@ class Digit : public FairTimeStamp /// @param other The digit to compare with /// @return True if this digit has a lower total index, false otherwise // - using FairTimeStamp::operator<; // to avoid hiding virtual bool operator<(const Digit& other) const { /* if (mChipIndex < other.mChipIndex || */ @@ -190,27 +165,7 @@ class Digit : public FairTimeStamp return output; } - /// Serialization method of the Digit using boost serialization - /// @param ar Archive where digit is appended - /// @param version Unused - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - ar& mChipIndex; - ar& mRow; - ar& mCol; - ar& mCharge; - ar& mROFrame; - ar& mLabels; - } - private: -#ifndef __CLING__ - - friend class boost::serialization::access; - -#endif UShort_t mChipIndex = 0; ///< Chip index UShort_t mRow = 0; ///< Pixel index in X UShort_t mCol = 0; ///< Pixel index in Z @@ -221,8 +176,8 @@ class Digit : public FairTimeStamp static constexpr int ROFrameOverFlowBits = 3; ///< max bits occupied by ROFrame overflow record static constexpr UInt_t ROFrameOverFlowMask = (0x1< ClassImp(o2::ITSMFT::Digit) using namespace o2::ITSMFT; Digit::Digit(UShort_t chipindex, UInt_t frame, UShort_t row, UShort_t col, Float_t charge, Double_t time) - : FairTimeStamp(time), mChipIndex(chipindex), mRow(row), mCol(col), mCharge(charge), mROFrame(0) + : DigitBase(time), mChipIndex(chipindex), mRow(row), mCol(col), mCharge(charge), mROFrame(0) { setROFrame(frame); } @@ -52,8 +53,8 @@ const Digit Digit::operator+(const Digit& other) std::ostream& Digit::print(std::ostream& output) const { - output << "ITSMFTDigit chip [" << mChipIndex << "] R:" << mRow << " C:" << mCol << " Q: " - << mCharge << "ROFrame " << getROFrame() << "(" << getNOverflowFrames() << ") time " << fTimeStamp; + output << "ITSMFTDigit chip [" << mChipIndex << "] R:" << mRow << " C:" << mCol << " Q: " << mCharge << "ROFrame " + << getROFrame() << "(" << getNOverflowFrames() << ") time " << getTimeStamp(); for (int i=0;igetChipIndex(); chipData.roFrame = mLastDigit->getROFrame(); - chipData.timeStamp = mLastDigit->GetTimeStamp(); // time difference within the same TFrame does not matter, take 1st one + chipData.timeStamp = + mLastDigit->getTimeStamp(); // time difference within the same TFrame does not matter, take 1st one chipData.pixels.emplace_back(mLastDigit); mLastDigit = nullptr; diff --git a/Detectors/TOF/base/include/TOFBase/Digit.h b/Detectors/TOF/base/include/TOFBase/Digit.h index 86601e8cb175d..15b9067379851 100644 --- a/Detectors/TOF/base/include/TOFBase/Digit.h +++ b/Detectors/TOF/base/include/TOFBase/Digit.h @@ -11,9 +11,9 @@ #ifndef ALICEO2_TOF_DIGIT_H_ #define ALICEO2_TOF_DIGIT_H_ -#include "FairTimeStamp.h" -#include "Rtypes.h" +#include #include +#include "Rtypes.h" #ifndef __CINT__ #include // for base_object @@ -23,12 +23,13 @@ namespace o2 { namespace tof { /// \class Digit /// \brief TOF digit implementation -class Digit : public FairTimeStamp { -public: +class Digit : public o2::dataformats::TimeStamp +{ + public: Digit() = default; Digit(Double_t time, Int_t channel, Int_t tdc, Int_t tot, Int_t bc); - ~Digit() override = default; + ~Digit() = default; Int_t getChannel() const { return mChannel; } void setChannel(Int_t channel) { mChannel = channel; } @@ -54,7 +55,7 @@ class Digit : public FairTimeStamp { Int_t mTOT; ///< TOT bin number Int_t mBC; ///< Bunch Crossing - ClassDefOverride(Digit, 1); + ClassDefNV(Digit, 1); }; std::ostream &operator<<(std::ostream &stream, const Digit &dig); diff --git a/Detectors/TOF/base/src/Digit.cxx b/Detectors/TOF/base/src/Digit.cxx index 45f0bd657cff9..533696dcc7b15 100644 --- a/Detectors/TOF/base/src/Digit.cxx +++ b/Detectors/TOF/base/src/Digit.cxx @@ -9,19 +9,20 @@ // or submit itself to any jurisdiction. #include "TOFBase/Digit.h" +#include using namespace o2::tof; ClassImp(o2::tof::Digit); Digit::Digit(Double_t time, Int_t channel, Int_t tdc, Int_t tot, Int_t bc) - : FairTimeStamp(time), mChannel(channel), mTDC(tdc), mTOT(tot), mBC(bc) + : o2::dataformats::TimeStamp(time), mChannel(channel), mTDC(tdc), mTOT(tot), mBC(bc) { } void Digit::printStream(std::ostream& stream) const { - stream << "TOF Digit: Channel " << mChannel << " TDC " << mTDC << " TOT " << mTOT << " Time " << GetTimeStamp() + stream << "TOF Digit: Channel " << mChannel << " TDC " << mTDC << " TOT " << mTOT << " Time " << getTimeStamp() << "Bunch Crossing index" << mBC << "\n"; } diff --git a/Detectors/TOF/simulation/src/Digitizer.cxx b/Detectors/TOF/simulation/src/Digitizer.cxx index 5f44080d64f46..080bcdf38513b 100644 --- a/Detectors/TOF/simulation/src/Digitizer.cxx +++ b/Detectors/TOF/simulation/src/Digitizer.cxx @@ -204,7 +204,7 @@ void Digitizer::addDigit(Int_t channel, Float_t time, Float_t x, Float_t z, Floa if (newdigit.getTDC() < digit.getTDC()) { // adjust TOT digit.setTDC(newdigit.getTDC()); - digit.SetTimeStamp(newdigit.GetTimeStamp()); + digit.setTimeStamp(newdigit.getTimeStamp()); } else { // adjust TOT } diff --git a/Detectors/TPC/base/include/TPCBase/Digit.h b/Detectors/TPC/base/include/TPCBase/Digit.h index 2c01a32d4974c..30faacc47ff24 100644 --- a/Detectors/TPC/base/include/TPCBase/Digit.h +++ b/Detectors/TPC/base/include/TPCBase/Digit.h @@ -15,33 +15,17 @@ #ifndef ALICEO2_TPC_DIGIT_H_ #define ALICEO2_TPC_DIGIT_H_ +#include "SimulationDataFormat/TimeStamp.h" #include "TObject.h" namespace o2 { -namespace TPC { - -// A minimal (temporary) TimeStamp class, introduced here for -// reducing memory consumption to a minimum. -// This can be used only when MCtruth is not done using FairLinks. -class TimeStamp { -public: - TimeStamp() {} - TimeStamp(int time) { - mTimeStamp = time; - } - int GetTimeStamp() const { return mTimeStamp; } -private: - int mTimeStamp = 0; - ClassDefNV(TimeStamp, 1); -}; -using DigitBase = TimeStamp; - - +namespace TPC +{ /// \class Digit /// This is the definition of the common Digit object, which is the final entity after Digitization /// Its coordinates are defined by the CRU, the time bin, the pad row and the pad. /// It holds the ADC value of a given pad on the pad plane. - +using DigitBase = o2::dataformats::TimeStamp; class Digit : public DigitBase { public: @@ -79,11 +63,6 @@ class Digit : public DigitBase { /// \return pad of the Digit int getPad() const { return mPad; } - /// Get the timeBin of the Digit - /// \return timeBin of the Digit - int getTimeStamp() const { return static_cast(DigitBase::GetTimeStamp()); } - - protected: float mCharge; ///< ADC value of the Digit diff --git a/Detectors/TPC/reconstruction/include/TPCReconstruction/Cluster.h b/Detectors/TPC/reconstruction/include/TPCReconstruction/Cluster.h index 7025b3060bc54..d948835d909db 100644 --- a/Detectors/TPC/reconstruction/include/TPCReconstruction/Cluster.h +++ b/Detectors/TPC/reconstruction/include/TPCReconstruction/Cluster.h @@ -16,27 +16,15 @@ #ifndef __CINT__ #include // for base_object #endif +#include +#include -#include "FairTimeStamp.h" // for FairTimeStamp namespace boost { namespace serialization { class access; } } namespace o2{ namespace TPC{ +using ClusterTimeStamp = o2::dataformats::TimeStampWithError; -class ClusterTimeStamp { - public: - ClusterTimeStamp() {}; - ClusterTimeStamp(float t, float te) : mTimeStamp(t), mTimeStampError(te) {} - float getTimeStamp() const {return mTimeStamp;} - float getTimeStampError() const {return mTimeStampError;} - void setTimeStamp(float t) {mTimeStamp = t;} - void setTimeStampError(float te) {mTimeStampError = te;} - private: - float mTimeStamp = 0.f; - float mTimeStampError = 0.f; - ClassDefNV(ClusterTimeStamp, 1); -}; - /// \class Cluster /// \brief Cluster class for the TPC /// diff --git a/Detectors/TPC/reconstruction/src/Cluster.cxx b/Detectors/TPC/reconstruction/src/Cluster.cxx index 3fe4dff020c88..d4fa513163346 100644 --- a/Detectors/TPC/reconstruction/src/Cluster.cxx +++ b/Detectors/TPC/reconstruction/src/Cluster.cxx @@ -12,6 +12,7 @@ /// \brief Cluster structure for TPC clusters #include "TPCReconstruction/Cluster.h" +#include ClassImp(o2::TPC::ClusterTimeStamp); ClassImp(o2::TPC::Cluster); diff --git a/Detectors/TPC/reconstruction/src/HwClusterFinder.cxx b/Detectors/TPC/reconstruction/src/HwClusterFinder.cxx index a11545963f397..f6f4c3a489040 100644 --- a/Detectors/TPC/reconstruction/src/HwClusterFinder.cxx +++ b/Detectors/TPC/reconstruction/src/HwClusterFinder.cxx @@ -11,10 +11,10 @@ /// \file AliTPCUpgradeHwClusterFinder.cxx /// \brief HwClusterFinder for the TPC - #include "TPCReconstruction/HwClusterFinder.h" -#include "TPCReconstruction/ClusterContainer.h" +#include #include "TPCReconstruction/Cluster.h" +#include "TPCReconstruction/ClusterContainer.h" #include "FairLogger.h" diff --git a/Detectors/TPC/reconstruction/src/HwClusterer.cxx b/Detectors/TPC/reconstruction/src/HwClusterer.cxx index c43e5008bbb73..4809621d853a1 100644 --- a/Detectors/TPC/reconstruction/src/HwClusterer.cxx +++ b/Detectors/TPC/reconstruction/src/HwClusterer.cxx @@ -22,8 +22,9 @@ #include "FairLogger.h" #include "TMath.h" -#include #include +#include +#include std::mutex g_display_mutex; diff --git a/cmake/O2Dependencies.cmake b/cmake/O2Dependencies.cmake index da713d581d5e0..6b91efc088cd4 100644 --- a/cmake/O2Dependencies.cmake +++ b/cmake/O2Dependencies.cmake @@ -675,9 +675,11 @@ o2_define_bucket( ParBase MathUtils Core Hist Gpad + SimulationDataFormat INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/Common/MathUtils/include + ${CMAKE_SOURCE_DIR}/DataFormats/simulation/include ) o2_define_bucket(