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