Project
Loading...
Searching...
No Matches
RawWriter.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 ALICEO2_PHOS_RAWWRITER_H
13#define ALICEO2_PHOS_RAWWRITER_H
14
15#include <gsl/span>
16
17#include <array>
18#include <fstream>
19#include <memory>
20#include <string>
21#include <map>
22#include <vector>
23
24#include "Rtypes.h"
25
30#include "PHOSBase/RCUTrailer.h"
31
32namespace o2
33{
34
35namespace phos
36{
37
38static constexpr short kNPHOSSAMPLES = 30;
39static constexpr short kNPRESAMPLES = 2;
40static constexpr short kOVERFLOW = 970;
41static constexpr float kPHOSTIMETICK = 100.;
42
43struct AltroBunch {
45 std::vector<int> mADCs;
46};
47
49 int mSRUid;
50 std::map<short, std::vector<o2::phos::Digit*>> mChannels;
51};
52
54{
55 public:
56 enum class FileFor_t {
57 kFullDet,
58 kCRORC,
59 kLink
60 };
61 RawWriter() = default;
62 RawWriter(const char* outputdir) { setOutputLocation(outputdir); }
63 ~RawWriter() = default;
64
65 o2::raw::RawFileWriter& getWriter() const { return *mRawWriter; }
66
67 void setOutputLocation(const char* outputdir) { mOutputLocation = outputdir; }
68 void setFileFor(FileFor_t filefor) { mFileFor = filefor; }
69
70 void init();
71 void digitsToRaw(gsl::span<o2::phos::Digit> digits, gsl::span<o2::phos::TriggerRecord> triggers);
72 bool processTrigger(const gsl::span<o2::phos::Digit> digitsbranch, const o2::phos::TriggerRecord& trg);
73
74 int carryOverMethod(const header::RDHAny* rdh, const gsl::span<char> data,
75 const char* ptr, int maxSize, int splitID,
76 std::vector<char>& trailer, std::vector<char>& header) const;
77
78 protected:
79 void createTRUBunches(short truId, const std::vector<o2::phos::Digit*>& channelDigits, std::vector<o2::phos::AltroBunch>& bunchs);
80 void createRawBunches(short absId, const std::vector<o2::phos::Digit*>& digits, std::vector<o2::phos::AltroBunch>& bunchHG,
81 std::vector<o2::phos::AltroBunch>& bunchLG, bool& isLGFilled);
82
83 std::vector<uint32_t> encodeBunchData(const std::vector<uint32_t>& data);
84 void fillGamma2(float amp, float time, short* samples);
85 // std::tuple<int, int, int> getOnlineID(int towerID);
86 // std::tuple<int, int> getLinkAssignment(int ddlID);
87
88 std::vector<char> createRCUTrailer(int payloadsize, int feca, int fecb, double timesample, double l1phase);
89
90 private:
92 std::string mOutputLocation = "./";
93 std::unique_ptr<const CalibParams> mCalibParams;
94 gsl::span<o2::phos::Digit> mDigits;
95 std::vector<SRUDigitContainer> mSRUdata;
96 std::vector<SRUDigitContainer> mTRUdata;
97 std::unique_ptr<o2::raw::RawFileWriter> mRawWriter;
98
99 ClassDefNV(RawWriter, 1);
100};
101
102} // namespace phos
103
104} // namespace o2
105
106#endif
int16_t time
Definition RawEventData.h:4
Utility class to write detectors data to (multiple) raw data file(s) respecting CRU format.
TBranch * ptr
void createTRUBunches(short truId, const std::vector< o2::phos::Digit * > &channelDigits, std::vector< o2::phos::AltroBunch > &bunchs)
void createRawBunches(short absId, const std::vector< o2::phos::Digit * > &digits, std::vector< o2::phos::AltroBunch > &bunchHG, std::vector< o2::phos::AltroBunch > &bunchLG, bool &isLGFilled)
std::vector< char > createRCUTrailer(int payloadsize, int feca, int fecb, double timesample, double l1phase)
o2::raw::RawFileWriter & getWriter() const
Definition RawWriter.h:65
void fillGamma2(float amp, float time, short *samples)
void setFileFor(FileFor_t filefor)
Definition RawWriter.h:68
void setOutputLocation(const char *outputdir)
Definition RawWriter.h:67
void digitsToRaw(gsl::span< o2::phos::Digit > digits, gsl::span< o2::phos::TriggerRecord > triggers)
Definition RawWriter.cxx:67
std::vector< uint32_t > encodeBunchData(const std::vector< uint32_t > &data)
bool processTrigger(const gsl::span< o2::phos::Digit > digitsbranch, const o2::phos::TriggerRecord &trg)
Definition RawWriter.cxx:91
int carryOverMethod(const header::RDHAny *rdh, const gsl::span< char > data, const char *ptr, int maxSize, int splitID, std::vector< char > &trailer, std::vector< char > &header) const
RawWriter(const char *outputdir)
Definition RawWriter.h:62
Header for data corresponding to the same hardware trigger adapted from DataFormatsEMCAL/TriggerRecor...
GLboolean * data
Definition glcorearb.h:298
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< int > mADCs
Definition RawWriter.h:45
std::map< short, std::vector< o2::phos::Digit * > > mChannels
Definition RawWriter.h:50
std::vector< Digit > digits