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