]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALSTURawStream.cxx
fixing r27675: adding missing files
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALSTURawStream.cxx
CommitLineData
a11f3c38 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16///////////////////////////////////////////////////////////////////////////////
17///
18/// This class provides access to EMCALSTU DDL raw data.
19///
20///////////////////////////////////////////////////////////////////////////////
21
22#include "AliEMCALSTURawStream.h"
23#include "AliRawReader.h"
24#include "AliLog.h"
25
26ClassImp(AliEMCALSTURawStream)
27
28//_____________________________________________________________________________
29AliEMCALSTURawStream::AliEMCALSTURawStream(AliRawReader* rawReader) :
30 fRawReader(rawReader),
31 fNum2x2Words(0)
32{
33 // reset arrays
34 memset(fJetPatchWords, 0, sizeof(fJetPatchWords));
35
36 // Reset RawStream
37 //
38 fRawReader->Reset();
39
40 // select the raw data corresponding to
41 // the EMCALSTU detector id
42 fRawReader->Select("EMCAL", kEMCALSTUDDL);
43}
44
45//_____________________________________________________________________________
46AliEMCALSTURawStream::AliEMCALSTURawStream(const AliEMCALSTURawStream& stream) :
47 TObject(stream),
48 fRawReader(NULL),
49 fNum2x2Words(0)
50{
51 // Copy constructor
52 AliFatal("Copy constructor not implemented");
53}
54
55//_____________________________________________________________________________
56AliEMCALSTURawStream& AliEMCALSTURawStream::operator = (const AliEMCALSTURawStream& source
57 /* stream */)
58{
59 // assignment operator; use copy ctor
60 if (&source == this) return *this;
61
62 new (this) AliEMCALSTURawStream(source);
63 return *this;
64}
65
66//_____________________________________________________________________________
67AliEMCALSTURawStream::~AliEMCALSTURawStream()
68{
69 // destructor
70}
71
72//_____________________________________________________________________________
73void AliEMCALSTURawStream::Reset()
74{
75 // reset raw stream params
76 if (fRawReader) fRawReader->Reset();
77}
78
79//_____________________________________________________________________________
80Bool_t AliEMCALSTURawStream::Next()
81{
82 // read the whole EMCALSTU raw data stream
83 // return kFALSE in case of error
84
85 UChar_t *data = NULL;
86
87 // EMCALSTU raw data should contain CDH so we don't need any mods a la
88 // fRawReader->RequireHeader(kTRUE);
89
90 // let's pick up the data block, if we can
91 if (!fRawReader->ReadNextData(data)) {
92 return kFALSE;
93 }
94
95 // check that the amount of data we picked up is what we expected
96 // 20080721 (DS): the rest of this method needs to be verified as the exact data format
97 // is defined
98 int nwordsExtra = fRawReader->GetDataSize() - (kNumJetPatchWords + kNumGammaJetPatchWords);
99 if ( nwordsExtra < 0 ) {
100 AliError(Form("Wrong EMCALSTU raw data size: %d", fRawReader->GetDataSize()));
101 return kFALSE;
102 }
103
104 // unpack the data into our local arrays
105 // jet-patch
106 int iword = 0;
107 int ioffset = 0;
108 for (iword = 0; iword<kNumJetPatchWords; iword++) {
109 fJetPatchWords[iword] = (data[iword] & 0xffffffff);
110 }
111 // gamma-jet patch
112 ioffset += kNumJetPatchWords;
113 for (iword = 0; iword<kNumGammaJetPatchWords; iword++) {
114 fGammaJetPatchWords[iword] = (data[iword+ioffset] & 0xffffffff);
115 }
116
117 // also 2x2sum's, if there appears to be enough/more data..
118 fNum2x2Words = 0;
119 if ( nwordsExtra > kNum2x2Words ) {
120 ioffset += kNumGammaJetPatchWords;
121 for (iword = 0; iword<kNum2x2Words; iword++) {
122 f2x2Words[iword] = (data[iword+ioffset] & 0xffffffff);
123 }
124 fNum2x2Words = kNum2x2Words;
125 }
126
127 return kTRUE;
128}
129