diff --git a/DataFormats/Detectors/CMakeLists.txt b/DataFormats/Detectors/CMakeLists.txt index 18b0ed448459c..a4ad99788afb7 100644 --- a/DataFormats/Detectors/CMakeLists.txt +++ b/DataFormats/Detectors/CMakeLists.txt @@ -21,7 +21,7 @@ add_subdirectory(ZDC) add_subdirectory(TRD) add_subdirectory(PHOS) add_subdirectory(CPV) - +add_subdirectory(CTP) if(ENABLE_UPGRADES) add_subdirectory(Upgrades) else() diff --git a/DataFormats/Detectors/CTP/CMakeLists.txt b/DataFormats/Detectors/CTP/CMakeLists.txt new file mode 100644 index 0000000000000..5fb16dad4f15f --- /dev/null +++ b/DataFormats/Detectors/CTP/CMakeLists.txt @@ -0,0 +1,19 @@ +# 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. + +o2_add_library(DataFormatsCTP + SOURCES src/Digits.cxx + PUBLIC_LINK_LIBRARIES O2::CommonDataFormat + O2::Headers + O2::SimulationDataFormat + O2::DataFormatsFT0) +o2_target_root_dictionary(DataFormatsCTP + HEADERS include/DataFormatsCTP/Digits.h) + diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Digits.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Digits.h new file mode 100644 index 0000000000000..1c2de16b31b92 --- /dev/null +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Digits.h @@ -0,0 +1,52 @@ +// 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 _CTP_DIGITS_H_ +#define _CTP_DIGITS_H_ +#include "DetectorsCommonDataFormats/DetID.h" +#include "CommonDataFormat/InteractionRecord.h" +#include "DataFormatsFT0/Digit.h" +#include +#include + +namespace o2 +{ +namespace ctp +{ +static constexpr uint32_t CTP_NINPUTS = 46; +static constexpr uint32_t CTP_NCLASSES = 64; +static constexpr uint32_t CTP_MAXL0PERDET = 5; +// Positions of CTP Detector inputs in CTPInputMask +static constexpr std::pair> CTP_INPUTMASK_FV0(0, 0x1f); +static constexpr std::pair> CTP_INPUTMASK_FT0(5, 0x1f); +struct CTPDigit { + o2::InteractionRecord mIntRecord; + std::bitset mCTPInputMask; + std::bitset mCTPClassMask; + CTPDigit() = default; + void printStream(std::ostream& stream) const; + ClassDefNV(CTPDigit, 1); +}; +struct CTPInputDigit { + o2::InteractionRecord mIntRecord; + std::bitset mInputsMask; + std::int32_t mDetector; + CTPInputDigit() = default; + CTPInputDigit(o2::InteractionRecord IntRecord, std::bitset InputsMask, uint32_t DetID) + { + mIntRecord = IntRecord; + mInputsMask = InputsMask; + mDetector = DetID; + } + ClassDefNV(CTPInputDigit, 1) +}; +} // namespace ctp +} // namespace o2 +#endif //_CTP_DIGITS_H diff --git a/DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h b/DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h new file mode 100644 index 0000000000000..c155641020168 --- /dev/null +++ b/DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h @@ -0,0 +1,20 @@ +// 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. + +#ifdef __CLING__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; +#pragma link C++ class o2::ctp::CTPDigit + ; +#pragma link C++ class vector < o2::ctp::CTPDigit> + ; +#pragma link C++ class o2::ctp::CTPInputDigit + ; +#pragma link C++ class vector < o2::ctp::CTPInputDigit> + ; +#endif diff --git a/DataFormats/Detectors/CTP/src/Digits.cxx b/DataFormats/Detectors/CTP/src/Digits.cxx new file mode 100644 index 0000000000000..7b02a59f6312c --- /dev/null +++ b/DataFormats/Detectors/CTP/src/Digits.cxx @@ -0,0 +1,20 @@ +// 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. + +#include "DataFormatsCTP/Digits.h" +#include + +using namespace o2::ctp; + +void CTPDigit::printStream(std::ostream& stream) const +{ + stream << "CTP Digit: BC " << mIntRecord.bc << " orbit " << mIntRecord.orbit << std::endl; + stream << "Input Mask: " << mCTPInputMask << " Class Mask: " << mCTPClassMask << std::endl; +} \ No newline at end of file diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h index 5db215c4457b7..d0152ee515eb8 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h @@ -68,13 +68,14 @@ class DetID static constexpr ID FV0 = 13; static constexpr ID FDD = 14; static constexpr ID ACO = 15; + static constexpr ID CTP = 16; #ifdef ENABLE_UPGRADES - static constexpr ID IT3 = 16; - static constexpr ID TRK = 17; - static constexpr ID FT3 = 18; + static constexpr ID IT3 = 17; + static constexpr ID TRK = 18; + static constexpr ID FT3 = 19; static constexpr ID Last = FT3; #else - static constexpr ID Last = ACO; ///< if extra detectors added, update this !!! + static constexpr ID Last = CTP; ///< if extra detectors added, update this !!! #endif static constexpr ID First = ITS; @@ -135,9 +136,9 @@ class DetID static constexpr const char* sDetNames[nDetectors + 1] = ///< defined detector names #ifdef ENABLE_UPGRADES - {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "ACO", "IT3", "TRK", "FT3", nullptr}; + {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "ACO", "CTP", "IT3", "TRK", "FT3", nullptr}; #else - {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "ACO", nullptr}; + {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "ACO", "CTP", nullptr}; #endif // detector names, will be defined in DataSources static constexpr std::array sMasks = ///< detectot masks @@ -155,7 +156,8 @@ class DetID sOrigins = ///< detector data origins {o2h::gDataOriginITS, o2h::gDataOriginTPC, o2h::gDataOriginTRD, o2h::gDataOriginTOF, o2h::gDataOriginPHS, o2h::gDataOriginCPV, o2h::gDataOriginEMC, o2h::gDataOriginHMP, o2h::gDataOriginMFT, o2h::gDataOriginMCH, - o2h::gDataOriginMID, o2h::gDataOriginZDC, o2h::gDataOriginFT0, o2h::gDataOriginFV0, o2h::gDataOriginFDD, o2h::gDataOriginACO + o2h::gDataOriginMID, o2h::gDataOriginZDC, o2h::gDataOriginFT0, o2h::gDataOriginFV0, o2h::gDataOriginFDD, + o2h::gDataOriginACO, o2h::gDataOriginCTP #ifdef ENABLE_UPGRADES , o2h::gDataOriginIT3, o2h::gDataOriginTRK, o2h::gDataOriginFT3 diff --git a/Detectors/CMakeLists.txt b/Detectors/CMakeLists.txt index 1a5c7813cec03..41a3e8a0da254 100644 --- a/Detectors/CMakeLists.txt +++ b/Detectors/CMakeLists.txt @@ -14,6 +14,7 @@ add_subdirectory(CTF) add_subdirectory(Passive) # must be first as some detector's macros use it +add_subdirectory(CTP) add_subdirectory(PHOS) add_subdirectory(CPV) add_subdirectory(EMCAL) diff --git a/Detectors/CTP/CMakeLists.txt b/Detectors/CTP/CMakeLists.txt new file mode 100644 index 0000000000000..2f0c018d5ebbc --- /dev/null +++ b/Detectors/CTP/CMakeLists.txt @@ -0,0 +1,12 @@ +# 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. + +add_subdirectory(simulation) +add_subdirectory(workflow) diff --git a/Detectors/CTP/simulation/CMakeLists.txt b/Detectors/CTP/simulation/CMakeLists.txt new file mode 100644 index 0000000000000..f54e0ff4d0814 --- /dev/null +++ b/Detectors/CTP/simulation/CMakeLists.txt @@ -0,0 +1,17 @@ +# 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. + +o2_add_library(CTPSimulation + SOURCES src/Digitizer.cxx + PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat O2::Framework + O2::DataFormatsCTP + O2::Headers) +o2_target_root_dictionary(CTPSimulation HEADERS + include/CTPSimulation/Digitizer.h) \ No newline at end of file diff --git a/Detectors/CTP/simulation/include/CTPSimulation/Digitizer.h b/Detectors/CTP/simulation/include/CTPSimulation/Digitizer.h new file mode 100644 index 0000000000000..6bcfb29467da1 --- /dev/null +++ b/Detectors/CTP/simulation/include/CTPSimulation/Digitizer.h @@ -0,0 +1,36 @@ +// 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_CTP_DIGITIZER_H +#define ALICEO2_CTP_DIGITIZER_H + +#include "CommonDataFormat/InteractionRecord.h" +#include "DataFormatsCTP/Digits.h" + +#include + +namespace o2 +{ +namespace ctp +{ +class Digitizer +{ + public: + Digitizer() = default; + ~Digitizer() = default; + std::vector process(const gsl::span digits); + void calculateClassMask(std::vector inputs, std::bitset& classmask); + void init(); + + private: + ClassDefNV(Digitizer, 1); +}; +} // namespace ctp +} // namespace o2 +#endif //ALICEO2_CTP_DIGITIZER_H diff --git a/Detectors/CTP/simulation/src/CTPSimulationLinkDef.h b/Detectors/CTP/simulation/src/CTPSimulationLinkDef.h new file mode 100644 index 0000000000000..af1e5c8043e99 --- /dev/null +++ b/Detectors/CTP/simulation/src/CTPSimulationLinkDef.h @@ -0,0 +1,17 @@ +// 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. +#ifdef __CLING__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class o2::ctp::Digitizer + ; +#endif \ No newline at end of file diff --git a/Detectors/CTP/simulation/src/Digitizer.cxx b/Detectors/CTP/simulation/src/Digitizer.cxx new file mode 100644 index 0000000000000..dceb22d2efb4d --- /dev/null +++ b/Detectors/CTP/simulation/src/Digitizer.cxx @@ -0,0 +1,76 @@ +// 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. + +#include "CTPSimulation/Digitizer.h" +#include "TRandom.h" +#include +#include "FairLogger.h" +#include + +using namespace o2::ctp; + +ClassImp(Digitizer); + +std::vector Digitizer::process(const gsl::span digits) +{ + std::map> prerawdata; + for (auto const& inp : digits) { + auto res = prerawdata.find(inp.mIntRecord); + if (res == prerawdata.end()) { + std::vector inputs; + inputs.push_back(&inp); + prerawdata[inp.mIntRecord] = inputs; + } else { + res->second.push_back(&inp); + } + } + std::vector vrawdata; + for (auto const& coll : prerawdata) { + CTPDigit data; + data.mIntRecord = coll.first; + std::bitset inpmaskcoll = 0; + for (auto const inp : coll.second) { + switch (inp->mDetector) { + case o2::detectors::DetID::FT0: { + std::bitset inpmask = std::bitset( + (inp->mInputsMask & CTP_INPUTMASK_FT0.second).to_ullong()); + inpmaskcoll |= inpmask << CTP_INPUTMASK_FT0.first; + break; + } + case o2::detectors::DetID::FV0: { + std::bitset inpmask = std::bitset( + (inp->mInputsMask & CTP_INPUTMASK_FT0.second).to_ullong()); + inpmaskcoll |= inpmask << CTP_INPUTMASK_FT0.first; + break; + } + default: + // Error + LOG(ERROR) << "CTP Digitizer: unknown detector:" << inp->mDetector; + break; + } + } + data.mCTPInputMask = inpmaskcoll; + calculateClassMask(coll.second, data.mCTPClassMask); + vrawdata.emplace_back(data); + } + return std::move(vrawdata); +} +void Digitizer::calculateClassMask(std::vector inputs, std::bitset& classmask) +{ + // Example of Min Bias as V0 or T0 + classmask = 0; + if (inputs.size() > 1) { + classmask = 1; + } +} +void Digitizer::init() +{ + LOG(INFO) << " @@@ CTP Digitizer::init. Nothing done. " << std::endl; +} diff --git a/Detectors/CTP/workflow/CMakeLists.txt b/Detectors/CTP/workflow/CMakeLists.txt new file mode 100644 index 0000000000000..1aeb02e1ab208 --- /dev/null +++ b/Detectors/CTP/workflow/CMakeLists.txt @@ -0,0 +1,15 @@ +# 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. + +o2_add_library(CTPWorkflow + SOURCES src/CTPDigitWriterSpec.cxx + PUBLIC_LINK_LIBRARIES O2::Framework + O2::DataFormatsCTP + O2::DPLUtils) \ No newline at end of file diff --git a/Detectors/CTP/workflow/include/CTPWorkflow/CTPDigitWriterSpec.h b/Detectors/CTP/workflow/include/CTPWorkflow/CTPDigitWriterSpec.h new file mode 100644 index 0000000000000..bf41c076e385b --- /dev/null +++ b/Detectors/CTP/workflow/include/CTPWorkflow/CTPDigitWriterSpec.h @@ -0,0 +1,28 @@ +// 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 O2_CTPDIGITWRITERSPEC_H +#define O2_CTPDIGITWRITERSPEC_H + +#include "Framework/DataProcessorSpec.h" +#include "DPLUtils/MakeRootTreeWriterSpec.h" +#include "Framework/InputSpec.h" +#include "DataFormatsCTP/Digits.h" + +using namespace o2::framework; +namespace o2 +{ +namespace ctp +{ +framework::DataProcessorSpec getCTPDigitWriterSpec(bool raw = true); +} +} // namespace o2 + +#endif //O2_CTPDIGITWRITERSPEC_H diff --git a/Detectors/CTP/workflow/src/CTPDigitWriterSpec.cxx b/Detectors/CTP/workflow/src/CTPDigitWriterSpec.cxx new file mode 100644 index 0000000000000..7b956954bfe79 --- /dev/null +++ b/Detectors/CTP/workflow/src/CTPDigitWriterSpec.cxx @@ -0,0 +1,35 @@ +// 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. + +#include "CTPWorkflow/CTPDigitWriterSpec.h" + +namespace o2 +{ +namespace ctp +{ +template +using BranchDefinition = framework::MakeRootTreeWriterSpec::BranchDefinition; + +framework::DataProcessorSpec getCTPDigitWriterSpec(bool raw) +{ + using InputSpec = framework::InputSpec; + using MakeRootTreeWriterSpec = framework::MakeRootTreeWriterSpec; + // Spectators for logging + auto logger = [](std::vector const& vecDigits) { + LOG(INFO) << "CTPDigitWriter pulled " << vecDigits.size() << " digits"; + }; + return MakeRootTreeWriterSpec(raw ? "ctp-digit-writer-dec" : "ctp-digit-writer", + raw ? "o2_ctpdigits.root" : "ctpdigits.root", + MakeRootTreeWriterSpec::TreeAttributes{"o2sim", "Tree with CTP digits"}, + BranchDefinition>{InputSpec{"digit", "CTP", "DIGITS", 0}, "CTPDigits", logger})(); +} + +} // namespace ctp +} // namespace o2 diff --git a/Steer/DigitizerWorkflow/CMakeLists.txt b/Steer/DigitizerWorkflow/CMakeLists.txt index ca2e6d516a84a..60a487738a5ce 100644 --- a/Steer/DigitizerWorkflow/CMakeLists.txt +++ b/Steer/DigitizerWorkflow/CMakeLists.txt @@ -12,6 +12,7 @@ o2_add_executable(digitizer-workflow COMPONENT_NAME sim SOURCES src/EMCALDigitWriterSpec.cxx src/EMCALDigitizerSpec.cxx + src/CTPDigitizerSpec.cxx src/FT0DigitizerSpec.cxx src/FV0DigitizerSpec.cxx src/FDDDigitizerSpec.cxx @@ -35,7 +36,9 @@ o2_add_executable(digitizer-workflow O2::FT0Simulation O2::FV0Simulation O2::FDDSimulation - O2::FDDWorkflow + O2::CTPSimulation + O2::CTPWorkflow + O2::FDDWorkflow O2::HMPIDSimulation O2::ITSMFTSimulation O2::ITSSimulation @@ -62,7 +65,7 @@ o2_add_executable(digitizer-workflow o2_add_executable(mctruth-testworkflow COMPONENT_NAME sim SOURCES src/MCTruthTestWorkflow.cxx - src/MCTruthSourceSpec.cxx + src/MCTruthSourceSpec.cxx src/MCTruthWriterSpec.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::SimulationDataFormat) diff --git a/Steer/DigitizerWorkflow/src/CTPDigitizerSpec.cxx b/Steer/DigitizerWorkflow/src/CTPDigitizerSpec.cxx new file mode 100644 index 0000000000000..198e7cc074810 --- /dev/null +++ b/Steer/DigitizerWorkflow/src/CTPDigitizerSpec.cxx @@ -0,0 +1,105 @@ +// 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. + +#include "CTPDigitizerSpec.h" +#include "Framework/ControlService.h" +#include "Framework/ConfigParamRegistry.h" +#include "Framework/DataProcessorSpec.h" +#include "Framework//Task.h" +#include "DetectorsBase/BaseDPLDigitizer.h" +#include "DataFormatsCTP/Digits.h" +#include "Steer/HitProcessingManager.h" // for DigitizationContext +#include "DetectorsCommonDataFormats/DetID.h" +#include "CTPSimulation/Digitizer.h" +#include "DataFormatsFT0/Digit.h" +#include "DataFormatsFV0/BCData.h" + +#include +#include + +using namespace o2::framework; +namespace o2 +{ +namespace ctp +{ +class CTPDPLDigitizerTask : public o2::base::BaseDPLDigitizer +{ + using GRP = o2::parameters::GRPObject; + + public: + CTPDPLDigitizerTask() : o2::base::BaseDPLDigitizer(), mDigitizer() {} + ~CTPDPLDigitizerTask() override = default; + void initDigitizerTask(framework::InitContext& ic) override + { + mDigitizer.init(); + } + void run(framework::ProcessingContext& pc) + { + // read collision context from input + //auto context = pc.inputs().get("collisioncontext"); + //const bool withQED = context->isQEDProvided(); + //auto& timesview = context->getEventRecords(withQED); + // read ctp inputs from input + auto ft0inputs = pc.inputs().get>("ft0"); + auto fv0inputs = pc.inputs().get>("fv0"); + + // if there is nothing to do ... return + if ((ft0inputs.size() == 0) && (fv0inputs.size() == 0)) { + return; + } + std::vector finputs; + TStopwatch timer; + timer.Start(); + LOG(INFO) << "CALLING CTP DIGITIZATION"; + for (const auto& inp : ft0inputs) { + CTPInputDigit finpdigit(inp.mIntRecord, inp.mInputs, o2::detectors::DetID::FT0); + finputs.emplace_back(finpdigit); + } + for (const auto& inp : fv0inputs) { + CTPInputDigit finpdigit(inp.mIntRecord, inp.mInputs, o2::detectors::DetID::FT0); + finputs.emplace_back(finpdigit); + } + gsl::span ginputs(finputs); + auto digits = mDigitizer.process(ginputs); + // send out to next stage + LOG(INFO) << "CTP DIGITS being sent."; + pc.outputs().snapshot(Output{"CTP", "DIGITS", 0, Lifetime::Timeframe}, digits); + LOG(INFO) << "CTP PRESENT being sent."; + pc.outputs().snapshot(Output{"CTP", "ROMode", 0, Lifetime::Timeframe}, mROMode); + timer.Stop(); + LOG(INFO) << "CTP Digitization took " << timer.CpuTime() << "s"; + } + + protected: + o2::parameters::GRPObject::ROMode mROMode = o2::parameters::GRPObject::PRESENT; + o2::ctp::Digitizer mDigitizer; ///< Digitizer +}; +o2::framework::DataProcessorSpec getCTPDigitizerSpec(int channel, std::vector& detList, bool mctruth) +{ + std::vector inputs; + std::vector output; + if (std::find(detList.begin(), detList.end(), o2::detectors::DetID::FT0) != detList.end()) { + inputs.emplace_back("ft0", "FT0", "TRIGGERINPUT", 0, Lifetime::Timeframe); + } + if (std::find(detList.begin(), detList.end(), o2::detectors::DetID::FV0) != detList.end()) { + inputs.emplace_back("fv0", "FV0", "TRIGGERINPUT", 0, Lifetime::Timeframe); + } + output.emplace_back("CTP", "DIGITS", 0, Lifetime::Timeframe); + output.emplace_back("CTP", "ROMode", 0, Lifetime::Timeframe); + return DataProcessorSpec{ + "CTPDigitizer", + inputs, + output, + AlgorithmSpec{adaptFromTask()}, + Options{{"pileup", VariantType::Int, 1, {"whether to run in continuous time mode"}}, + {"disable-qed", o2::framework::VariantType::Bool, false, {"disable QED handling"}}}}; +} +} // namespace ctp +} // namespace o2 diff --git a/Steer/DigitizerWorkflow/src/CTPDigitizerSpec.h b/Steer/DigitizerWorkflow/src/CTPDigitizerSpec.h new file mode 100644 index 0000000000000..ec54535616264 --- /dev/null +++ b/Steer/DigitizerWorkflow/src/CTPDigitizerSpec.h @@ -0,0 +1,27 @@ +// 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 STEER_DIGITIZERWORKFLOW_CTPDIGITIZER_H_ +#define STEER_DIGITIZERWORKFLOW_CTPDIGITIZER_H_ + +#include "Framework/DataProcessorSpec.h" +#include "DetectorsCommonDataFormats/DetID.h" + +namespace o2 +{ +namespace ctp +{ + +o2::framework::DataProcessorSpec getCTPDigitizerSpec(int channel, std::vector& detList, bool mctruth = true); + +} // namespace ctp +} // end namespace o2 + +#endif /* STEER_DIGITIZERWORKFLOW_CTPDIGITIZER_H_ */ diff --git a/Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx b/Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx index ac7e755fd7eee..bc54b8c607584 100644 --- a/Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx +++ b/Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx @@ -43,6 +43,10 @@ #include "FT0DigitizerSpec.h" #include "FT0DigitWriterSpec.h" +// for CTP +#include "CTPDigitizerSpec.h" +#include "CTPWorkflow/CTPDigitWriterSpec.h" + // for FV0 #include "FV0DigitizerSpec.h" #include "FV0DigitWriterSpec.h" @@ -593,7 +597,14 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) // add PHOS writer specs.emplace_back(o2::cpv::getCPVDigitWriterSpec(mctruth)); } - + // the CTP part + if (isEnabled(o2::detectors::DetID::CTP)) { + detList.emplace_back(o2::detectors::DetID::CTP); + // connect the CTP digitization + specs.emplace_back(o2::ctp::getCTPDigitizerSpec(fanoutsize++, detList)); + // connect the CTP digit writer + specs.emplace_back(o2::ctp::getCTPDigitWriterSpec(false)); + } // GRP updater: must come after all detectors since requires their list specs.emplace_back(o2::parameters::getGRPUpdaterSpec(grpfile, detList)); diff --git a/macro/o2sim.C b/macro/o2sim.C index f49086c474a36..45f51a45b94c1 100644 --- a/macro/o2sim.C +++ b/macro/o2sim.C @@ -150,6 +150,11 @@ FairRunSim* o2sim_init(bool asservice) } grp.addDetReadOut(o2::detectors::DetID(det->GetDetId())); } + // CTP is not a physical detector, just flag in the GRP if requested + if (isActivated("CTP")) { + grp.addDetReadOut(o2::detectors::DetID::CTP); + } + grp.print(); printf("VMC: %p\n", TVirtualMC::GetMC()); auto field = dynamic_cast(run->GetField());