Skip to content
Merged

ctpdev #5758

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DataFormats/Detectors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 19 additions & 0 deletions DataFormats/Detectors/CTP/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

52 changes: 52 additions & 0 deletions DataFormats/Detectors/CTP/include/DataFormatsCTP/Digits.h
Original file line number Diff line number Diff line change
@@ -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 <bitset>
#include <iosfwd>

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<uint32_t, std::bitset<CTP_MAXL0PERDET>> CTP_INPUTMASK_FV0(0, 0x1f);
static constexpr std::pair<uint32_t, std::bitset<CTP_MAXL0PERDET>> CTP_INPUTMASK_FT0(5, 0x1f);
struct CTPDigit {
o2::InteractionRecord mIntRecord;
std::bitset<CTP_NINPUTS> mCTPInputMask;
std::bitset<CTP_NCLASSES> mCTPClassMask;
CTPDigit() = default;
void printStream(std::ostream& stream) const;
ClassDefNV(CTPDigit, 1);
};
struct CTPInputDigit {
o2::InteractionRecord mIntRecord;
std::bitset<CTP_MAXL0PERDET> mInputsMask;
std::int32_t mDetector;
CTPInputDigit() = default;
CTPInputDigit(o2::InteractionRecord IntRecord, std::bitset<CTP_MAXL0PERDET> InputsMask, uint32_t DetID)
{
mIntRecord = IntRecord;
mInputsMask = InputsMask;
mDetector = DetID;
}
ClassDefNV(CTPInputDigit, 1)
};
} // namespace ctp
} // namespace o2
#endif //_CTP_DIGITS_H
20 changes: 20 additions & 0 deletions DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions DataFormats/Detectors/CTP/src/Digits.cxx
Original file line number Diff line number Diff line change
@@ -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 <iostream>

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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<mask_t, nDetectors> sMasks = ///< detectot masks
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions Detectors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions Detectors/CTP/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 17 additions & 0 deletions Detectors/CTP/simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
36 changes: 36 additions & 0 deletions Detectors/CTP/simulation/include/CTPSimulation/Digitizer.h
Original file line number Diff line number Diff line change
@@ -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 <gsl/span>

namespace o2
{
namespace ctp
{
class Digitizer
{
public:
Digitizer() = default;
~Digitizer() = default;
std::vector<CTPDigit> process(const gsl::span<o2::ctp::CTPInputDigit> digits);
void calculateClassMask(std::vector<const CTPInputDigit*> inputs, std::bitset<CTP_NCLASSES>& classmask);
void init();

private:
ClassDefNV(Digitizer, 1);
};
} // namespace ctp
} // namespace o2
#endif //ALICEO2_CTP_DIGITIZER_H
17 changes: 17 additions & 0 deletions Detectors/CTP/simulation/src/CTPSimulationLinkDef.h
Original file line number Diff line number Diff line change
@@ -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
76 changes: 76 additions & 0 deletions Detectors/CTP/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
@@ -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 <cassert>
#include "FairLogger.h"
#include <bitset>

using namespace o2::ctp;

ClassImp(Digitizer);

std::vector<CTPDigit> Digitizer::process(const gsl::span<o2::ctp::CTPInputDigit> digits)
{
std::map<o2::InteractionRecord, std::vector<const CTPInputDigit*>> prerawdata;
for (auto const& inp : digits) {
auto res = prerawdata.find(inp.mIntRecord);
if (res == prerawdata.end()) {
std::vector<const CTPInputDigit*> inputs;
inputs.push_back(&inp);
prerawdata[inp.mIntRecord] = inputs;
} else {
res->second.push_back(&inp);
}
}
std::vector<CTPDigit> vrawdata;
for (auto const& coll : prerawdata) {
CTPDigit data;
data.mIntRecord = coll.first;
std::bitset<CTP_NINPUTS> inpmaskcoll = 0;
for (auto const inp : coll.second) {
switch (inp->mDetector) {
case o2::detectors::DetID::FT0: {
std::bitset<CTP_NINPUTS> inpmask = std::bitset<CTP_NINPUTS>(
(inp->mInputsMask & CTP_INPUTMASK_FT0.second).to_ullong());
inpmaskcoll |= inpmask << CTP_INPUTMASK_FT0.first;
break;
}
case o2::detectors::DetID::FV0: {
std::bitset<CTP_NINPUTS> inpmask = std::bitset<CTP_NINPUTS>(
(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<const CTPInputDigit*> inputs, std::bitset<CTP_NCLASSES>& 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;
}
15 changes: 15 additions & 0 deletions Detectors/CTP/workflow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
28 changes: 28 additions & 0 deletions Detectors/CTP/workflow/include/CTPWorkflow/CTPDigitWriterSpec.h
Original file line number Diff line number Diff line change
@@ -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
Loading