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_EMCAL_RAWWRITER_H
13#define ALICEO2_EMCAL_RAWWRITER_H
14
15#include <gsl/span>
16
17#include <array>
18#include <cstdint>
19#include <fstream>
20#include <memory>
21#include <string>
22#include <map>
23#include <vector>
24
25#include "Rtypes.h"
26
28#include "EMCALBase/Mapper.h"
32
33namespace o2
34{
35
36namespace emcal
37{
38
39class Geometry;
40
53
65
73{
74 public:
77 enum class FileFor_t {
78 kFullDet,
79 kSubDet,
80 kCRORC,
81 kLink
82 };
83
85 RawWriter() = default;
86
93 RawWriter(const char* outputdir) { setOutputLocation(outputdir); }
94
96 ~RawWriter() = default;
97
100 o2::raw::RawFileWriter& getWriter() const { return *mRawWriter; }
101
102 void setOutputLocation(const char* outputdir) { mOutputLocation = outputdir; }
103 void setDigits(gsl::span<o2::emcal::Digit> digits) { mDigits = digits; }
104
112 void setFileFor(FileFor_t filefor) { mFileFor = filefor; }
113
116 void setNumberOfADCSamples(int nsamples) { mNADCSamples = nsamples; }
117
120 void setMinADCSamplesBunch(int nsamples) { mMinADCBunch = nsamples; }
121
124 void setPedestal(int pedestal) { mPedestal = pedestal; }
125
128 void setGeometry(o2::emcal::Geometry* geo) { mGeometry = geo; }
129
130 void init();
131
138 void digitsToRaw(gsl::span<o2::emcal::Digit> digits, gsl::span<o2::emcal::TriggerRecord> triggers);
139
149
150 int carryOverMethod(const header::RDHAny* rdh, const gsl::span<char> data,
151 const char* ptr, int maxSize, int splitID,
152 std::vector<char>& trailer, std::vector<char>& header) const;
153
154 protected:
155 void createPayload(o2::emcal::ChannelData channel, o2::emcal::ChannelType_t chanType, int ddlID, std::vector<char>& payload, bool& saturatedBunch);
156
163 std::vector<AltroBunch> findBunches(const std::vector<o2::emcal::Digit*>& channelDigits, ChannelType_t channelType);
164
169 ChannelHeader createChannelHeader(int hardwareAddress, int payloadSize, bool isBadChannel);
170
180 std::vector<char> createRCUTrailer(int payloadsize, double timesample, uint64_t triggertime, int feeID);
181
192 std::vector<int> encodeBunchData(const std::vector<int>& data);
193
196 int getBranchIndexFromHwAddress(int hwaddress) { return ((hwaddress >> 11) & 0x1); }
197
200 int getFecIndexFromHwAddress(int hwaddress) { return ((hwaddress >> 7) & 0xF); }
201
204 int getChannelIndexFromHwAddress(int hwaddress) { return (hwaddress & 0xF); }
205
206 private:
207 int mNADCSamples = 15;
208 int mPedestal = 1;
209 int mMinADCBunch = 3;
210 FileFor_t mFileFor = FileFor_t::kFullDet;
211 o2::emcal::Geometry* mGeometry = nullptr;
212 std::string mOutputLocation;
213 std::unique_ptr<o2::emcal::MappingHandler> mMappingHandler;
214 gsl::span<o2::emcal::Digit> mDigits;
215 std::vector<SRUDigitContainer> mSRUdata;
216 std::unique_ptr<o2::raw::RawFileWriter> mRawWriter;
217
218 ClassDefNV(RawWriter, 1);
219};
220
221} // namespace emcal
222
223} // namespace o2
224
225#endif
size_t maxSize
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
std::vector< uint16_t > nsamples
Definition testDigit.cxx:38
Utility class to write detectors data to (multiple) raw data file(s) respecting CRU format.
TBranch * ptr
EMCAL geometry definition.
Definition Geometry.h:42
Raw data creator for EMCAL raw data based on EMCAL digits.
Definition RawWriter.h:73
std::vector< char > createRCUTrailer(int payloadsize, double timesample, uint64_t triggertime, int feeID)
Creating RCU trailer.
ChannelHeader createChannelHeader(int hardwareAddress, int payloadSize, bool isBadChannel)
Create channel header.
~RawWriter()=default
Destructor.
bool processTrigger(const o2::emcal::TriggerRecord &trg)
Processing digits to raw conversion for the digits from the current event.
Definition RawWriter.cxx:85
void setNumberOfADCSamples(int nsamples)
Set the number of ADC samples in the readout window.
Definition RawWriter.h:116
o2::raw::RawFileWriter & getWriter() const
Get access to underlying RawFileWriter.
Definition RawWriter.h:100
FileFor_t
Definition of the granularity of the raw files.
Definition RawWriter.h:77
@ kSubDet
Subdetector (EMCAL/DCAL separate)
@ kFullDet
Full detector (EMCAL + DCAL)
int getChannelIndexFromHwAddress(int hwaddress)
Extracting Channel index in FEC from the hardware address.
Definition RawWriter.h:204
void setGeometry(o2::emcal::Geometry *geo)
Set the geometry parameters.
Definition RawWriter.h:128
RawWriter(const char *outputdir)
Constructor, defining output location.
Definition RawWriter.h:93
int getFecIndexFromHwAddress(int hwaddress)
Extracting FEC index in branch from the hardware address.
Definition RawWriter.h:200
void setOutputLocation(const char *outputdir)
Definition RawWriter.h:102
void setPedestal(int pedestal)
Set pedestal threshold used to accept ADC values when creating the bunches.
Definition RawWriter.h:124
void setFileFor(FileFor_t filefor)
Set the granularity of the output file.
Definition RawWriter.h:112
int getBranchIndexFromHwAddress(int hwaddress)
Extracting branch index from the hardware address.
Definition RawWriter.h:196
std::vector< AltroBunch > findBunches(const std::vector< o2::emcal::Digit * > &channelDigits, ChannelType_t channelType)
Parse digits vector in channel and create ALTRO bunches.
void setMinADCSamplesBunch(int nsamples)
Set min. ADC samples expected in a calo bunch.
Definition RawWriter.h:120
void createPayload(o2::emcal::ChannelData channel, o2::emcal::ChannelType_t chanType, int ddlID, std::vector< char > &payload, bool &saturatedBunch)
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
void setDigits(gsl::span< o2::emcal::Digit > digits)
Definition RawWriter.h:103
void digitsToRaw(gsl::span< o2::emcal::Digit > digits, gsl::span< o2::emcal::TriggerRecord > triggers)
Converting digits from a full timeframe to raw pages.
Definition RawWriter.cxx:77
RawWriter()=default
Dummy constructor.
std::vector< int > encodeBunchData(const std::vector< int > &data)
Encoding words of the ALTRO bunch into 32-bit words.
Header for data corresponding to the same hardware trigger.
ChannelType_t
Type of a raw data channel.
Definition Constants.h:33
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Structure for mapping digits to Channels within a SRU.
Definition AltroHelper.h:40
std::vector< Digit > digits
Encoding of ALTRO words (32 bit consisting of 3 10-bit words)
Definition RawWriter.h:56
uint32_t mWord2
Bits 0 - 9 : Word 2.
Definition RawWriter.h:59
uint32_t mZero
Bits 30 - 31 : zeroed.
Definition RawWriter.h:62
uint32_t mWord0
Bits 20 - 29 : Word 0.
Definition RawWriter.h:61
uint32_t mDataWord
Full data word representation.
Definition RawWriter.h:57
uint32_t mWord1
Bits 10 - 19 : Word 1.
Definition RawWriter.h:60
Bitfield encoding channel headers.
Definition RawWriter.h:43
uint32_t mPayloadSize
Bits 16 - 25: Payload size.
Definition RawWriter.h:47
uint32_t mZero1
Bits 26 - 28: zeroed.
Definition RawWriter.h:48
uint32_t mDataWord
Full data word representation.
Definition RawWriter.h:44
uint32_t mHardwareAddress
Bits 0 - 15: Hardware address.
Definition RawWriter.h:46
uint32_t mHeaderBits
Bits 30 - 31: channel header bits (1)
Definition RawWriter.h:50
uint32_t mBadChannel
Bit 29: Bad channel status.
Definition RawWriter.h:49