@@ -35,24 +35,33 @@ namespace emcal
3535{
3636
3737class Geometry ;
38+
39+ // / \struct AltroBunch
40+ // / \brief ALTRO bunch information obtained from digits
3841struct AltroBunch {
39- int mStarttime ;
40- std::vector<int > mADCs ;
42+ int mStarttime ; // /< Start time of the bunch
43+ std::vector<int > mADCs ; // /< ADCs belonging to the bunch
4144};
4245
46+ // / \struct ChannelData
47+ // / \brief Structure for mapping digits to Channels within a SRU
4348struct ChannelData {
44- int mRow ;
45- int mCol ;
46- std::vector<o2::emcal::Digit*> mDigits ;
49+ int mRow ; // /< Row of the channel
50+ int mCol ; // /< Column of the channel
51+ std::vector<o2::emcal::Digit*> mDigits ; // /< Digits for the channel within the current event
4752};
4853
54+ // / \struct SRUDigitContainer
55+ // / \brief Structure for organizing digits within the SRU
4956struct SRUDigitContainer {
50- int mSRUid ;
51- std::map<int , ChannelData> mChannels ;
57+ int mSRUid ; // /< DDL of the SRU
58+ std::map<int , ChannelData> mChannels ; // /< Containers for channels within the SRU
5259};
5360
61+ // / \union ChannelHeader
62+ // / \brief Bitfield encoding channel headers
5463union ChannelHeader {
55- uint32_t mDataWord ;
64+ uint32_t mDataWord ; // /< Full data word representation
5665 struct {
5766 uint32_t mHardwareAddress : 16 ; // /< Bits 0 - 15: Hardware address
5867 uint32_t mPayloadSize : 10 ; // /< Bits 16 - 25: Payload size
@@ -62,8 +71,10 @@ union ChannelHeader {
6271 };
6372};
6473
74+ // / \union CaloBunchWord
75+ // / \brief Encoding of ALTRO words (32 bit consisting of 3 10-bit words)
6576union CaloBunchWord {
66- uint32_t mDataWord ;
77+ uint32_t mDataWord ; // /< Full data word representation
6778 struct {
6879 uint32_t mWord2 : 10 ; // /< Bits 0 - 9 : Word 2
6980 uint32_t mWord1 : 10 ; // /< Bits 10 - 19 : Word 1
@@ -72,45 +83,135 @@ union CaloBunchWord {
7283 };
7384};
7485
86+ // / \class RawWriter
87+ // / \brief Raw data creator for EMCAL raw data based on EMCAL digits
88+ // / \ingroup EMCALsimulation
89+ // / \author Markus Fasel <markus.fasel@cern.ch>, Oak Ridge National Laboratory
90+ // / \author Hadi Hassan, Oak Ridge National Laboratory
91+ // / \since Jan 24, 2020
7592class RawWriter
7693{
7794 public:
95+ // / \enum FileFor_t
96+ // / \brief Definition of the granularity of the raw files
7897 enum class FileFor_t {
79- kFullDet ,
80- kSubDet ,
81- kLink
98+ kFullDet , // /< Full detector (EMCAL + DCAL)
99+ kSubDet , // /< Subdetector (EMCAL/DCAL separate)
100+ kLink // /< Per link
82101 };
102+
103+ // / \brief Dummy constructor
83104 RawWriter () = default ;
105+
106+ // / \brief Constructor, defining output location
107+ // / \param outputdir Output directiory
108+ // /
109+ // / Initializing the output directory. The output files
110+ // / can be found in the output directory with the granularity
111+ // / defined via setFileFor
84112 RawWriter (const char * outputdir) { setOutputLocation (outputdir); }
113+
114+ // / \brief Destructor
85115 ~RawWriter () = default ;
86116
117+ // / \brief Get access to underlying RawFileWriter
118+ // / \return RawFileWriter
87119 o2::raw::RawFileWriter& getWriter () const { return *mRawWriter ; }
88120
89121 void setOutputLocation (const char * outputdir) { mOutputLocation = outputdir; }
90122 void setDigits (gsl::span<o2::emcal::Digit> digits) { mDigits = digits; }
123+
124+ // / \brief Set the granularity of the output file
125+ // / \param filefor Output granularity
126+ // /
127+ // / Output files can be created for
128+ // / - Whole EMCAL
129+ // / - Subdetector (EMCAL or DCAL)
130+ // / - Link
91131 void setFileFor (FileFor_t filefor) { mFileFor = filefor; }
132+
133+ // / \brief Set the number of ADC samples in the readout window
134+ // / \param nsapmles Number of time samples
92135 void setNumberOfADCSamples (int nsamples) { mNADCSamples = nsamples; }
136+
137+ // / \brief Set min. ADC samples expected in a calo bunch
138+ // / \param nsamples Minimum number of ADC samples
139+ void setMinADCSamplesBunch (int nsamples) { mMinADCBunch = nsamples; }
140+
141+ // / \brief Set pedestal threshold used to accept ADC values when creating the bunches
142+ // / \param pedestal Pedestal value
93143 void setPedestal (int pedestal) { mPedestal = pedestal; }
144+
145+ // / \brief Set the geometry parameters
146+ // / \param geo EMCAL geometry
94147 void setGeometry (o2::emcal::Geometry* geo) { mGeometry = geo; }
95148
96149 void init ();
150+
151+ // / \brief Converting digits from a full timeframe to raw pages
152+ // / \param digits Vector of digits belonging to the same timeframe
153+ // / \param triggers trigger records with ranges in digits container of data for the various events in the timeframe
154+ // /
155+ // / Processing all events from within a timeframe. See processTrigger for more information
156+ // / about the digit to raw converion of a single event.
97157 void digitsToRaw (gsl::span<o2::emcal::Digit> digits, gsl::span<o2::emcal::TriggerRecord> triggers);
158+
159+ // / \brief Processing digits to raw conversion for the digits from the current event
160+ // / \param trg Trigger record providing collision information and data range for the current event
161+ // /
162+ // / Digits are first sorted according to SRUs and within their channels and time samples.
163+ // / For each SRU and channel within the SRU calo bunches are created. In case at least one
164+ // / valid calo bunch is found channels are created, and they data words are organized in a
165+ // / raw stream, which is closed by the RCU trailer of the given stream. The content of the
166+ // / stream is then passed to the RawFileWriter for page splitting and output streaming.
98167 bool processTrigger (const o2::emcal::TriggerRecord& trg);
99168
100169 int carryOverMethod (const header::RDHAny* rdh, const gsl::span<char > data,
101170 const char * ptr, int maxSize, int splitID,
102171 std::vector<char >& trailer, std::vector<char >& header) const ;
103172
104173 protected:
174+ // / \brief Parse digits vector in channel and create ALTRO bunches
175+ // / \param channelDigits Vector with digits in the channel for the current event
176+ // /
177+ // / Channels are parsed in a time-reversed order. Bunches are selected for ranges of
178+ // / digits where the ADC value is consecutively above the pedestal. Only bunches having
179+ // / a min. amount of ADC samples are selected.
105180 std::vector<AltroBunch> findBunches (const std::vector<o2::emcal::Digit*>& channelDigits);
106181
182+ // / \brief Create channel header
183+ // / \param hardwareAddress Hardware address
184+ // / \param payloadSize Size of the payload of the channel in 10-bit ALTRO words
185+ // / \param isBadChannel If true the channel is a bad channel at hardware level
107186 ChannelHeader createChannelHeader (int hardwareAddress, int payloadSize, bool isBadChannel);
187+
188+ // / \brief Creating RCU trailer
189+ // / \param payloadsize Size of the payload as 32bit word
190+ // / \param timesampe Length of the time sample (for L1 phase calculation)
191+ // / \param triggertime Time of the trigger (for L1 phase calculation)
192+ // / \param feeID Link ID
193+ // /
194+ // / Creating RCU trailer. Also setting the values of the ALTRO Config registers based
195+ // / on the settings in the raw writer. The RCU trailer is then encoded and converted to
196+ // / 8-bit words.
108197 std::vector<char > createRCUTrailer (int payloadsize, double timesample, uint64_t triggertime, int feeID);
198+
199+ // / \brief Encoding words of the ALTRO bunch into 32-bit words
200+ // / \param data ALTRO bunch information
201+ // / \return Encoded ALTRO words
202+ // /
203+ // / Converting ALTRO bunch into ALTRO words. For the ALTRO bunch the following structure is
204+ // / expected:
205+ // / - bunch size including bunch header size (2)
206+ // / - start time
207+ // / - ADC samples
208+ // / The input data is converted to 10 but ALTRO words and put on the stream.
109209 std::vector<int > encodeBunchData (const std::vector<int >& data);
110210
111211 private:
112212 int mNADCSamples = 15 ; // /< Number of time samples
113- int mPedestal = 0 ; // /< Pedestal
213+ int mPedestal = 1 ; // /< Pedestal
214+ int mMinADCBunch = 3 ; // /< Min. number of ADC samples in ALTRO bunch
114215 FileFor_t mFileFor = FileFor_t::kFullDet ; // /< Granularity of the output files
115216 o2::emcal::Geometry* mGeometry = nullptr ; // /< EMCAL geometry
116217 std::string mOutputLocation ; // /< Rawfile name
0 commit comments