30#include "TStopwatch.h"
58 bool mUseCCDB =
false;
59 bool mIsCalib =
false;
60 bool mIsCosmic =
false;
62 bool mUpdateCCDB =
false;
63 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
68 explicit TOFDPLClustererTask(std::shared_ptr<o2::base::GRPGeomRequest> gr,
bool useMC,
bool useCCDB,
bool doCalib,
bool isCosmic, std::string ccdb_url,
bool isForCalib) : mGGCCDBRequest(gr), mUseMC(useMC), mUseCCDB(useCCDB), mIsCalib(doCalib), mIsCosmic(isCosmic), mCCDBurl(ccdb_url), mForCalib(isForCalib) {}
76 mTimeWin = ic.
options().
get<
int>(
"cluster-time-window");
77 LOG(
debug) <<
"Is calibration from cluster on? " << mIsCalib;
78 LOG(
debug) <<
"DeltaTime for clusterization = " << mTimeWin <<
" ps";
79 LOG(
debug) <<
"Is cosmics? " << mIsCosmic;
86 std::fill(mMultPerLongBC.begin(), mMultPerLongBC.end(), 0);
112 std::fill(mMultPerLongBC.begin(), mMultPerLongBC.end(), 0);
116 auto row = pc.
inputs().
get<gsl::span<o2::tof::ReadoutWindowData>>(
"readoutwin");
119 updateTimeDependentParams(pc);
123 auto labelvector = std::make_shared<std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>>();
125 auto digitlabels = pc.
inputs().
get<std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>*>(
"tofdigitlabels");
126 *labelvector.get() = std::move(*digitlabels);
131 if (!mUseCCDB && !mCalibApi) {
135 lhcPhaseDummy->addLHCphase(0, 0);
136 lhcPhaseDummy->addLHCphase(2000000000, 0);
139 channelCalibDummy->addTimeSlewingInfo(ich, 0, 0);
142 channelCalibDummy->setFractionUnderPeak(sector, channelInSector, 1);
155 mClustersArray.clear();
161 mCosmicProcessor.
clear();
164 for (
unsigned int i = 0;
i <
row.size();
i++) {
170 for (
int crate = 0; crate < 72; crate++) {
172 int nwords = kw +
row[
i].getDiagnosticInCrate(crate);
174 for (; kw < nwords; kw++) {
175 if (patterns[kw] > 28) {
179 slot = patterns[kw] - 28;
182 if (slot < 3 || slot > 12) {
186 }
else if (slot > -1) {
187 eword += 1 << patterns[kw];
193 auto digitsRO =
row[
i].getBunchChannelData(
digits);
197 mCosmicProcessor.
process(mReader,
i != 0);
201 mClusterer.
process(mReader, mClustersArray, &(labelvector->at(
i)));
203 mClusterer.
process(mReader, mClustersArray,
nullptr);
207 <<
" DIGITS TO " << mClustersArray.size() <<
" CLUSTERS";
212 for (
const auto& cls : mClustersArray) {
213 double timeCl = cls.getTime();
214 int channel = cls.getMainContributingChannel();
217 timeCl -= sqrt(
pos[0] *
pos[0] +
pos[1] *
pos[1] +
pos[2] *
pos[2]) * 33.3564095 - 3000;
220 if (longBC < 0 || longBC >= mMultPerLongBC.size()) {
223 mMultPerLongBC[longBC]++;
240 std::vector<CosmicInfo>* cosmicInfo = mCosmicProcessor.
getCosmicInfo();
242 std::vector<CalibInfoTrackCl>* cosmicTrack = mCosmicProcessor.
getCosmicTrack();
253 LOGF(
debug,
"TOF Clusterer total timing: Cpu: %.3e Real: %.3e s in %d slots",
254 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
261 static bool initOnceDone =
false;
265 for (
auto bc : bcs) {
285 LOG(info) <<
"Update CCDB objects since new";
300 DigitDataReader mReader;
301 Clusterer mClusterer;
302 CosmicProcessor mCosmicProcessor;
305 std::vector<Cluster> mClustersArray;
307 std::vector<CalibInfoCluster> mClusterCalInfo;
308 bool mForCalib =
false;
310 std::vector<int> mMultPerLongBC;
315 std::vector<InputSpec> inputs;
323 inputs.emplace_back(
"tofccdbDia",
"TOF",
"DiagnosticCal", 0, Lifetime::Condition,
ccdbParamSpec(
"TOF/Calib/Diagnostic"));
324 inputs.emplace_back(
"tofccdbLHCphase",
"TOF",
"LHCphaseCal", 0, Lifetime::Condition,
ccdbParamSpec(
"TOF/Calib/LHCphase"));
325 inputs.emplace_back(
"tofccdbChannelCalib",
"TOF",
"ChannelCalibCal", 0, Lifetime::Condition,
ccdbParamSpec(
"TOF/Calib/ChannelCalib"));
332 std::vector<OutputSpec> outputs;
347 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
359 AlgorithmSpec{adaptFromTask<TOFDPLClustererTask>(ggRequest, useMC, useCCDB, doCalib, isCosmic, ccdb_url, isForCalib)},
360 Options{{
"cluster-time-window", VariantType::Int, 5000, {
"time window for clusterization in ps"}}}};
Class to store the output of the matching to TOF for calibration.
Class to use TOF calibration (decalibration, calibration)
Class to store the output of the matching to TOF for calibration.
Managing digitsi in a RO window to provide cosmics candidates.
Definition of the TOF hit reader.
Helper for geometry and GRP related CCDB requests.
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the TOF cluster finder.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
void loadDiagnosticFrequencies()
void setTimeStamp(long t)
void processError(int crate, int trm, int mask)
void setDeltaTforClustering(float val)
std::vector< o2::tof::CalibInfoCluster > * getInfoFromCluster()
void setCalibStored(bool val=true)
void setFirstOrbit(uint64_t orb)
void setCalibFromCluster(bool val=1)
void setCalibApi(CalibApi *calibApi)
void addDiagnostic(const Diagnostic &dia)
void process(DataReader &r, std::vector< Cluster > &clusters, MCLabelContainer const *digitMCTruth)
void setMCTruthContainer(o2::dataformats::MCTruthContainer< o2::MCCompLabel > *truth)
std::vector< CalibInfoTrackCl > * getCosmicTrack()
std::vector< int > * getCosmicTrackSize()
void process(DigitDataReader &r, bool fill=true)
std::vector< CosmicInfo > * getCosmicInfo()
Diagnostic class for TOF.
void setDigitArray(const gsl::span< const o2::tof::Digit > *a)
static constexpr Double_t BC_TIME_INPS_INV
static void getPos(Int_t *det, Float_t *pos)
static void getVolumeIndices(Int_t index, Int_t *detId)
void init(framework::InitContext &ic)
TOFDPLClustererTask(std::shared_ptr< o2::base::GRPGeomRequest > gr, bool useMC, bool useCCDB, bool doCalib, bool isCosmic, std::string ccdb_url, bool isForCalib)
void finaliseCCDB(o2::framework::ConcreteDataMatcher matcher, void *obj)
void endOfStream(EndOfStreamContext &ec)
void run(framework::ProcessingContext &pc)
static void addInteractionBC(int bc, bool fromCollisonCotext=false)
constexpr o2::header::DataOrigin gDataOriginTOF
constexpr int LHCMaxBunches
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
std::vector< T, o2::pmr::polymorphic_allocator< T > > vector
o2::framework::DataProcessorSpec getTOFClusterizerSpec(bool useMC, bool useCCDB=0, bool doCalib=0, bool isCosmic=0, std::string ccdb_url="", bool isForCalib=false)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits