]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RAW/AliCaloRawStream.cxx
Corrected reading of the RCU register ALTROCFG1.
[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),
c7ecf7e8 54 fCaloFlag(0),
55 fFilter(0),
467957dc 56 fNRCU(0),
cee89af9 57 fNSides(0),
58 fCalo(calo),
467957dc 59 fExternalMapping(kFALSE)
d84933b0 60{
cee89af9 61 // create an object to read PHOS/EMCAL raw digits
d84933b0 62 SelectRawData(calo);
63
64 // PHOS and EMCAL have differen number of RCU per module
cee89af9 65 //For PHOS
d84933b0 66 fNRCU = 4;
cee89af9 67 fNSides = 1;
68 //For EMCAL
69 TString sides[]={"A","C"};
70 if(fCalo == "EMCAL") {
71 fNRCU = 2;
72 fNSides = 2;
73 }
d84933b0 74
467957dc 75 if (mapping == NULL) {
76 TString path = gSystem->Getenv("ALICE_ROOT");
cee89af9 77 path += "/"+fCalo+"/mapping/RCU";
467957dc 78 TString path2;
cee89af9 79 for(Int_t j = 0; j < fNSides; j++){
80 for(Int_t i = 0; i < fNRCU; i++) {
81 path2 = path;
82 path2 += i;
83 if(fCalo == "EMCAL") path2 += sides[j];
84 path2 += ".data";
85 //printf("AliCaloRawStream::RCU: %s\n",path2.Data());
86 fMapping[i] = new AliCaloAltroMapping(path2.Data());
87 }
467957dc 88 }
89 }
90 else {
91 fExternalMapping = kTRUE;
cee89af9 92 //printf("AliCaloRawStream::External mapping N: RCU %d, sides %d \n", fNRCU,fNSides);
93 for(Int_t i = 0; i < fNRCU*fNSides; i++)
467957dc 94 fMapping[i] = mapping[i];
cee89af9 95
d84933b0 96 }
cee89af9 97
d84933b0 98 SetNoAltroMapping(kFALSE);
99}
100
101//_____________________________________________________________________________
102AliCaloRawStream::AliCaloRawStream(const AliCaloRawStream& stream) :
103 AliAltroRawStream(stream),
104 fModule(-1),
105 fPrevModule(-1),
106 fRow(-1),
107 fPrevRow(-1),
108 fColumn(-1),
109 fPrevColumn(-1),
c7ecf7e8 110 fCaloFlag(0),
111 fFilter(0),
467957dc 112 fNRCU(0),
cee89af9 113 fNSides(0),
114 fCalo(""),
467957dc 115 fExternalMapping(kFALSE)
d84933b0 116{
117 Fatal("AliCaloRawStream", "copy constructor not implemented");
118}
119
120//_____________________________________________________________________________
121AliCaloRawStream& AliCaloRawStream::operator = (const AliCaloRawStream&
122 /* stream */)
123{
124 Fatal("operator =", "assignment operator not implemented");
125 return *this;
126}
127
128//_____________________________________________________________________________
129AliCaloRawStream::~AliCaloRawStream()
130{
131// destructor
132
467957dc 133 if (!fExternalMapping)
cee89af9 134 for(Int_t i = 0; i < fNRCU*fNSides; i++)
467957dc 135 delete fMapping[i];
d84933b0 136}
137
138//_____________________________________________________________________________
139void AliCaloRawStream::Reset()
140{
141 // reset phos/emcal raw stream params
142 AliAltroRawStream::Reset();
143 fModule = fPrevModule = fRow = fPrevRow = fColumn = fPrevColumn = -1;
c7ecf7e8 144 fFilter = fCaloFlag = 0;
cee89af9 145 fCalo="";
d84933b0 146}
147
148//_____________________________________________________________________________
149Bool_t AliCaloRawStream::Next()
150{
151 // Read next PHOS/EMCAL signal
152 // Apply the PHOS/EMCAL altro mapping to get
153 // the module,row and column indeces
154 fPrevModule = fModule;
155 fPrevRow = fRow;
156 fPrevColumn = fColumn;
157 if (AliAltroRawStream::Next()) {
c7ecf7e8 158 if (IsNewHWAddress()) {
d84933b0 159 ApplyAltroMapping();
c7ecf7e8 160 if ( fFilter > 0 ) { // some data should be filtered out
161 if ( (fFilter & (1<<fCaloFlag)) != 0) {
162 // this particular data should be filtered out
163 Next(); // go to the next address instead
164 }
165 }
166 }
d84933b0 167 return kTRUE;
168 }
169 else
170 return kFALSE;
171}
172
173//_____________________________________________________________________________
174void AliCaloRawStream::ApplyAltroMapping()
175{
176 // Take the DDL index, load
177 // the corresponding altro mapping
178 // object and fill the sector,row and pad indeces
179 Int_t ddlNumber = GetDDLNumber();
180 fModule = ddlNumber / fNRCU;
181
182 Int_t rcuIndex = ddlNumber % fNRCU;
183
cee89af9 184 if(fCalo=="EMCAL"){ // EMCAL may need to increase RCU index for the maps
185 if (fModule%2 == 1) { rcuIndex += 2; } // other='C' side maps
186 }
187
d84933b0 188 Short_t hwAddress = GetHWAddress();
189 fRow = fMapping[rcuIndex]->GetPadRow(hwAddress);
190 fColumn = fMapping[rcuIndex]->GetPad(hwAddress);
c7ecf7e8 191 fCaloFlag = fMapping[rcuIndex]->GetSector(hwAddress);
d84933b0 192
193}