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 return;
62 }
63 RecoContainer recoData;
64 recoData.collectData(pc, *mDataRequest.get());
65 auto digits = pc.inputs().get<gsl::span<o2::trd::Digit>>("digits");
66 mPulseHeight->setInput(recoData, &digits);
67 mPulseHeight->reset();
68 mPulseHeight->process();
69 pc.outputs().snapshot(Output{"TRD", "PULSEHEIGHT", 0}, mPulseHeight->getPHData());
70 if (pc.transitionState() == TransitionHandlingState::Requested) {
71 LOG(info) << "Run stop requested, finalizing";
72 mRunStopRequested = true;
73 }
74 }
75
77 {
78 mPulseHeight->closeOutputFile();
79 if (mRunStopRequested) {
80 return;
81 }
82 }
83
84 void stop() final
85 {
86 }
87
88 private:
89 std::shared_ptr<DataRequest> mDataRequest;
90 std::unique_ptr<o2::trd::PulseHeight> mPulseHeight;
91 bool mRunStopRequested = false; // flag that run was stopped (and the last output is sent)
92};
93
94} // namespace trd
95
96namespace framework
97{
98
99DataProcessorSpec getTRDPulseHeightSpec(GID::mask_t src, bool digitsFromReader)
100{
101
102 std::vector<OutputSpec> outputs;
103 outputs.emplace_back(o2::header::gDataOriginTRD, "PULSEHEIGHT", 0, Lifetime::Timeframe);
104
105 bool isTPCavailable = false;
106 if (GID::includesSource(GID::Source::ITSTPC, src)) {
107 LOGF(debug, "Found ITS-TPC tracks as input, loading ITS-TPC-TRD");
108 src |= GID::getSourcesMask("ITS-TPC-TRD");
109 }
110 if (GID::includesSource(GID::Source::TPC, src)) {
111 LOGF(debug, "Found TPC tracks as input, loading TPC-TRD");
112 src |= GID::getSourcesMask("TPC-TRD");
113 isTPCavailable = true;
114 }
115 GID::mask_t srcClu = GID::getSourcesMask("TRD"); // we don't need all clusters, only TRD tracklets
116
117 auto dataRequest = std::make_shared<DataRequest>();
118 dataRequest->requestTracks(src, false);
119 dataRequest->requestClusters(srcClu, false);
120 dataRequest->inputs.emplace_back("digits", "TRD", "DIGITS", digitsFromReader ? 1 : 0);
121
122 return DataProcessorSpec{
123 "trd-pulseheight",
124 dataRequest->inputs,
125 outputs,
126 AlgorithmSpec{adaptFromTask<o2::trd::PuseHeightDevice>(dataRequest)},
127 Options{
128 {"enable-root-output", VariantType::Bool, false, {"output PH and debug data to root file"}}}};
129}
130} // namespace framework
131} // namespace o2
132
133#endif // O2_TRD_PULSEHEIGHTSPEC_H
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.
std::ostringstream debug
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.
Definition TFIDInfo.h:20
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