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