]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RAW/AliCaloRawStream.cxx
added library definition for libHLTshuttle
[u/mrichter/AliRoot.git] / RAW / AliCaloRawStream.cxx
CommitLineData
d84933b0 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/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19///
20/// This class provides access to PHOS/EMCAL digits in raw data.
21///
22/// It loops over all PHOS/EMCAL digits in the raw data given by the AliRawReader.
23/// The Next method goes to the next digit. If there are no digits left
24/// it returns kFALSE.
25/// Several getters provide information about the current digit.
26/// usage:
27/// root > AliRawReaderFile rawReader ;
28/// root > AliCaloRawStream input(&rawReader) ;
29/// root > while (input.Next()) .....
30///
31///Modification: Class exported from PHOS to be used by EMCAL and PHOS
32///November 2006 Gustavo Conesa Balbastre
33///////////////////////////////////////////////////////////////////////////////
34
35#include <TString.h>
36#include <TSystem.h>
37
38#include "AliCaloRawStream.h"
39#include "AliRawReader.h"
40#include "AliCaloAltroMapping.h"
41
42ClassImp(AliCaloRawStream)
43
44
45//_____________________________________________________________________________
467957dc 46AliCaloRawStream::AliCaloRawStream(AliRawReader* rawReader, TString calo, AliAltroMapping **mapping) :
d84933b0 47 AliAltroRawStream(rawReader),
48 fModule(-1),
49 fPrevModule(-1),
50 fRow(-1),
51 fPrevRow(-1),
52 fColumn(-1),
53 fPrevColumn(-1),
467957dc 54 fGain(0),
55 fNRCU(0),
56 fExternalMapping(kFALSE)
d84933b0 57{
58// create an object to read PHOS/EMCAL raw digits
59
60 SelectRawData(calo);
61
62 // PHOS and EMCAL have differen number of RCU per module
63 fNRCU = 4;
64 if(calo == "EMCAL") fNRCU = 2;
65
467957dc 66 if (mapping == NULL) {
67 TString path = gSystem->Getenv("ALICE_ROOT");
68 path += "/"+calo+"/mapping/RCU";
69 TString path2;
70 for(Int_t i = 0; i < fNRCU; i++) {
71 path2 = path;
72 path2 += i;
73 path2 += ".data";
74 fMapping[i] = new AliCaloAltroMapping(path2.Data());
75 }
76 }
77 else {
78 fExternalMapping = kTRUE;
79 for(Int_t i = 0; i < fNRCU; i++)
80 fMapping[i] = mapping[i];
d84933b0 81 }
82
83 SetNoAltroMapping(kFALSE);
84}
85
86//_____________________________________________________________________________
87AliCaloRawStream::AliCaloRawStream(const AliCaloRawStream& stream) :
88 AliAltroRawStream(stream),
89 fModule(-1),
90 fPrevModule(-1),
91 fRow(-1),
92 fPrevRow(-1),
93 fColumn(-1),
94 fPrevColumn(-1),
95 fGain(0),
467957dc 96 fNRCU(0),
97 fExternalMapping(kFALSE)
d84933b0 98{
99 Fatal("AliCaloRawStream", "copy constructor not implemented");
100}
101
102//_____________________________________________________________________________
103AliCaloRawStream& AliCaloRawStream::operator = (const AliCaloRawStream&
104 /* stream */)
105{
106 Fatal("operator =", "assignment operator not implemented");
107 return *this;
108}
109
110//_____________________________________________________________________________
111AliCaloRawStream::~AliCaloRawStream()
112{
113// destructor
114
467957dc 115 if (!fExternalMapping)
116 for(Int_t i = 0; i < fNRCU; i++)
117 delete fMapping[i];
d84933b0 118}
119
120//_____________________________________________________________________________
121void AliCaloRawStream::Reset()
122{
123 // reset phos/emcal raw stream params
124 AliAltroRawStream::Reset();
125 fModule = fPrevModule = fRow = fPrevRow = fColumn = fPrevColumn = -1;
126 fGain = 0;
127}
128
129//_____________________________________________________________________________
130Bool_t AliCaloRawStream::Next()
131{
132 // Read next PHOS/EMCAL signal
133 // Apply the PHOS/EMCAL altro mapping to get
134 // the module,row and column indeces
135 fPrevModule = fModule;
136 fPrevRow = fRow;
137 fPrevColumn = fColumn;
138 if (AliAltroRawStream::Next()) {
139 if (IsNewHWAddress())
140 ApplyAltroMapping();
141 return kTRUE;
142 }
143 else
144 return kFALSE;
145}
146
147//_____________________________________________________________________________
148void AliCaloRawStream::ApplyAltroMapping()
149{
150 // Take the DDL index, load
151 // the corresponding altro mapping
152 // object and fill the sector,row and pad indeces
153 Int_t ddlNumber = GetDDLNumber();
154 fModule = ddlNumber / fNRCU;
155
156 Int_t rcuIndex = ddlNumber % fNRCU;
157
158 Short_t hwAddress = GetHWAddress();
159 fRow = fMapping[rcuIndex]->GetPadRow(hwAddress);
160 fColumn = fMapping[rcuIndex]->GetPad(hwAddress);
161 fGain = fMapping[rcuIndex]->GetSector(hwAddress);
162
163}