]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RAW/AliCaloRawStreamV3.cxx
Fix
[u/mrichter/AliRoot.git] / RAW / AliCaloRawStreamV3.cxx
CommitLineData
0021af02 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// AliRawReader *reader = AliRawReader::Create(fileName);
28// AliCaloRawStreamV3 *stream = new AliCaloRawStreamV3(reader,calo);
29// while (reader->NextEvent())
30// while (stream->NextDDL())
31// while (stream->NextChannel()) ...
32///
33/// Yuri Kharlov. 23 June 2009
34///////////////////////////////////////////////////////////////////////////////
35
36#include <TString.h>
37#include <TSystem.h>
38
4feb8cb3 39#include "AliLog.h"
0021af02 40#include "AliCaloRawStreamV3.h"
41#include "AliRawReader.h"
42#include "AliCaloAltroMapping.h"
43
44ClassImp(AliCaloRawStreamV3)
45
46
47//_____________________________________________________________________________
48AliCaloRawStreamV3::AliCaloRawStreamV3(AliRawReader* rawReader, TString calo, AliAltroMapping **mapping) :
49 AliAltroRawStreamV3(rawReader),
50 fModule(-1),
51 fRow(-1),
52 fColumn(-1),
53 fCaloFlag(0),
4feb8cb3 54 fNModules(0),
0021af02 55 fNRCU(0),
56 fNSides(0),
57 fCalo(calo),
58 fExternalMapping(kFALSE)
59{
60 // create an object to read PHOS/EMCAL raw digits
61 SelectRawData(calo);
62
4feb8cb3 63 // PHOS and EMCAL have different number of RCU per module
64 //For PHOS (different mappings for different modules)
65 if(fCalo == "PHOS") {
66 fNModules = 5;
67 fNRCU = 4;
68 fNSides = 1;
69 }
70 //For EMCAL (the same mapping for all modules)
0021af02 71 if(fCalo == "EMCAL") {
4feb8cb3 72 fNModules = 1;
73 fNRCU = 2;
74 fNSides = 2;
0021af02 75 }
4feb8cb3 76 TString sides[]={"A","C"};
0021af02 77
78 if (mapping == NULL) {
4feb8cb3 79 // Read mapping files from $ALICE_ROOT/CALO/mapping/*.data
0021af02 80 TString path = gSystem->Getenv("ALICE_ROOT");
4feb8cb3 81 path += "/"+fCalo+"/mapping/";
82 TString path1, path2;
83 for(Int_t m = 0; m < fNModules; m++) {
84 path1 = path;
85 if (fCalo == "EMCAL") {
86 path1 += "RCU";
87 }
88 else if(fCalo == "PHOS" ) {
89 path1 += "Mod";
90 path1 += m;
91 path1 += "RCU";
92 }
93 for(Int_t j = 0; j < fNSides; j++){
94 for(Int_t i = 0; i < fNRCU; i++) {
95 path2 = path1;
96 path2 += i;
97 if(fCalo == "EMCAL") path2 += sides[j];
98 path2 += ".data";
99 AliDebug(2,Form("Mapping file: %s",path2.Data()));
100 fMapping[m*fNSides*fNRCU + j*fNRCU + i] = new AliCaloAltroMapping(path2.Data());
101 }
0021af02 102 }
103 }
104 }
105 else {
4feb8cb3 106 // Mapping is supplied by reconstruction
0021af02 107 fExternalMapping = kTRUE;
4feb8cb3 108 for(Int_t i = 0; i < fNModules*fNRCU*fNSides; i++)
0021af02 109 fMapping[i] = mapping[i];
110 }
111}
112
113//_____________________________________________________________________________
114AliCaloRawStreamV3::AliCaloRawStreamV3(const AliCaloRawStreamV3& stream) :
115 AliAltroRawStreamV3(stream),
116 fModule(-1),
117 fRow(-1),
118 fColumn(-1),
119 fCaloFlag(0),
4feb8cb3 120 fNModules(0),
0021af02 121 fNRCU(0),
122 fNSides(0),
123 fCalo(""),
124 fExternalMapping(kFALSE)
125{
4feb8cb3 126 // Dummy copy constructor
0021af02 127 Fatal("AliCaloRawStreamV3", "copy constructor not implemented");
128}
129
130//_____________________________________________________________________________
131AliCaloRawStreamV3& AliCaloRawStreamV3::operator = (const AliCaloRawStreamV3&
132 /* stream */)
133{
4feb8cb3 134 // Dummy assignment operator
0021af02 135 Fatal("operator =", "assignment operator not implemented");
136 return *this;
137}
138
139//_____________________________________________________________________________
140AliCaloRawStreamV3::~AliCaloRawStreamV3()
141{
142// destructor
143
144 if (!fExternalMapping)
4feb8cb3 145 for(Int_t i = 0; i < fNModules*fNRCU*fNSides; i++)
0021af02 146 delete fMapping[i];
147}
148
149//_____________________________________________________________________________
150void AliCaloRawStreamV3::Reset()
151{
4feb8cb3 152 // reset PHOS/EMCAL raw stream params
0021af02 153 AliAltroRawStreamV3::Reset();
154 fModule = fRow = fColumn = -1;
41ce8fa3 155 fCaloFlag = 0;
0021af02 156 fCalo="";
157}
158
159//_____________________________________________________________________________
160Bool_t AliCaloRawStreamV3::NextChannel()
161{
162 // Read next PHOS/EMCAL signal
163 // Apply the PHOS/EMCAL altro mapping to get
164 // the module,row and column indeces
165
166 if (AliAltroRawStreamV3::NextChannel()) {
167 ApplyAltroMapping();
0021af02 168 return kTRUE;
169 }
170 else
171 return kFALSE;
172}
173
174//_____________________________________________________________________________
175void AliCaloRawStreamV3::ApplyAltroMapping()
176{
177 // Take the DDL index, load
178 // the corresponding altro mapping
179 // object and fill the sector,row and pad indeces
180
181 Int_t ddlNumber = GetDDLNumber();
182 fModule = ddlNumber / fNRCU;
183
184 Int_t rcuIndex = ddlNumber % fNRCU;
185
4feb8cb3 186 if( fNModules > 1) rcuIndex += fModule*fNRCU*fNSides;
89de6b46 187 if( fNRCU == 2 ){ // EMCAL may need to increase RCU index for the maps
0021af02 188 if (fModule%2 == 1) { rcuIndex += 2; } // other='C' side maps
189 }
190
191 Short_t hwAddress = GetHWAddress();
192 fRow = fMapping[rcuIndex]->GetPadRow(hwAddress);
193 fColumn = fMapping[rcuIndex]->GetPad(hwAddress);
194 fCaloFlag = fMapping[rcuIndex]->GetSector(hwAddress);
195}