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