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