Project
Loading...
Searching...
No Matches
TRDPulseHeightSpec.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef O2_TRD_PULSEHEIGHTSPEC_H
13#define O2_TRD_PULSEHEIGHTSPEC_H
14
17
18#include "Framework/Task.h"
26#include <cstring>
27
28using namespace o2::framework;
30
31namespace o2
32{
33namespace trd
34{
35
37{
38 public:
39 PuseHeightDevice(std::shared_ptr<DataRequest> dr) : mDataRequest(dr) {}
41 {
42 mPulseHeight = std::make_unique<PulseHeight>();
43 if (ic.options().get<bool>("enable-root-output")) {
44 mPulseHeight->createOutputFile();
45 }
46 if (getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) {
47 // apply artificial pad shift in case non-ideal alignment is used to compensate for shift in current alignment from real data
48 mPulseHeight->setApplyShift(false);
49 }
50 }
51
53 {
54 const auto& tinfo = pc.services().get<o2::framework::TimingInfo>();
55 if (tinfo.globalRunNumberChanged) { // new run is starting
56 mRunStopRequested = false;
57 }
58 if (mRunStopRequested) {
59 std::vector<PHData> mPHValues{}; // the calibration expects data at every TF, so inject dummy
60 pc.outputs().snapshot(Output{"TRD", "PULSEHEIGHT", 0}, mPHValues);
61 std::vector<PHDataHD> mPHValuesHD{}; // the calibration expects data at every TF, so inject dummy
62 pc.outputs().snapshot(Output{"TRD", "PULSEHEIGHTHD", 0}, mPHValuesHD);
63 return;
64 }
65 RecoContainer recoData;
66 recoData.collectData(pc, *mDataRequest.get());
67 auto digits = pc.inputs().get<gsl::span<o2::trd::Digit>>("digits");
68 mPulseHeight->setInput(recoData, &digits);
69 mPulseHeight->reset();
70 mPulseHeight->process();
71 pc.outputs().snapshot(Output{"TRD", "PULSEHEIGHT", 0}, mPulseHeight->getPHData());
72 if (pc.transitionState() == TransitionHandlingState::Requested) {
73 LOG(info) << "Run stop requested, finalizing";
74 mRunStopRequested = true;
75 }
76 }
77
79 {
80 mPulseHeight->closeOutputFile();
81 if (mRunStopRequested) {
82 return;
83 }
84 }
85
86 void stop() final
87 {
88 }
89
90 private:
91 std::shared_ptr<DataRequest> mDataRequest;
92 std::unique_ptr<o2::trd::PulseHeight> mPulseHeight;
93 bool mRunStopRequested = false; // flag that run was stopped (and the last output is sent)
94};
95
96} // namespace trd
97
98namespace framework
99{
100
101DataProcessorSpec getTRDPulseHeightSpec(GID::mask_t src, bool digitsFromReader)
102{
103
104 std::vector<OutputSpec> outputs;
105 outputs.emplace_back(o2::header::gDataOriginTRD, "PULSEHEIGHT", 0, Lifetime::Timeframe);
106
107 bool isTPCavailable = false;
108 if (GID::includesSource(GID::Source::ITSTPC, src)) {
109 LOGF(debug, "Found ITS-TPC tracks as input, loading ITS-TPC-TRD");
110 src |= GID::getSourcesMask("ITS-TPC-TRD");
111 }
112 if (GID::includesSource(GID::Source::TPC, src)) {
113 LOGF(debug, "Found TPC tracks as input, loading TPC-TRD");
114 src |= GID::getSourcesMask("TPC-TRD");
115 isTPCavailable = true;
116 }
117 GID::mask_t srcClu = GID::getSourcesMask("TRD"); // we don't need all clusters, only TRD tracklets
118
119 auto dataRequest = std::make_shared<DataRequest>();
120 dataRequest->requestTracks(src, false);
121 dataRequest->requestClusters(srcClu, false);
122 dataRequest->inputs.emplace_back("digits", "TRD", "DIGITS", digitsFromReader ? 1 : 0);
123
124 return DataProcessorSpec{
125 "trd-pulseheight",
126 dataRequest->inputs,
127 outputs,
128 AlgorithmSpec{adaptFromTask<o2::trd::PuseHeightDevice>(dataRequest)},
129 Options{
130 {"enable-root-output", VariantType::Bool, false, {"output PH and debug data to root file"}}}};
131}
132} // namespace framework
133} // namespace o2
134
135#endif // O2_TRD_PULSEHEIGHTSPEC_H
std::ostringstream debug
Helper for geometry and GRP related CCDB requests.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Creates PH spectra from TRD digits found on tracks.
static mask_t getSourcesMask(const std::string_view srcList)
void stop() final
This is invoked on stop.
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(o2::framework::InitContext &ic) final
PuseHeightDevice(std::shared_ptr< DataRequest > dr)
void run(o2::framework::ProcessingContext &pc) final
GLenum src
Definition glcorearb.h:1767
constexpr o2::header::DataOrigin gDataOriginTRD
Definition DataHeader.h:577
Defining PrimaryVertex explicitly as messageable.
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